From ullrich at math.okstate.edu Fri Jun 15 10:27:39 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Fri, 15 Jun 2001 14:27:39 GMT Subject: call-by-reference (was Re: Any other Python flaws?) References: <9gcu9g$gm4$1@newshost.accu.uu.nl> <9gd4tq$odb$1@news.mathworks.com> Message-ID: <3b2a1aea.6118580@nntp.sprynet.com> On 15 Jun 2001 14:08:58 GMT, jcm wrote: >Martijn Faassen wrote: > >> I agree that nobody agrees on whatever 'call-by-reference' means, or what >> 'call-by-value' means. I mean, I'm here confused why you'd say C++ doesn't >> support call-by-value while Python apparently does. :) > >In my experience, there's good agreement about what call-by-reference >means just about everywhere but in newsgroups. Python supports only >call-by-value -- you can't change the value of a variable in your >caller's scope (globals aside). It's call-by-value all right. The confusion is caused by the fact that the values are references. But passing a reference "by value" is not a call by reference. David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From piet at cs.uu.nl Thu Jun 7 10:25:49 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 07 Jun 2001 16:25:49 +0200 Subject: Recursive algorithms anyone? References: <1f0uhtgmhb0vlud6pof6i4mctqjdq8l2eu@4ax.com> Message-ID: def add(x,k): if type(x)==type([]): return additem(x,k) return x+k def additem(l,k): return [add(x,k) for x in l] -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From dwig at advancedmp.net Mon Jun 4 16:18:02 2001 From: dwig at advancedmp.net (Don Dwiggins) Date: 04 Jun 2001 13:18:02 -0700 Subject: Numeric Programming for Everybody (was Re: I had a thought ...) References: Message-ID: Tim Peters writes: > [Don Dwiggins] >> See http://support.microsoft.com/support/kb/articles/Q172/3/38.ASP for >> one use of Currency having nothing to do with money. > Cute! In an earlier, unrelated thread, we learned that the Currency type is > really a 64-bit int, conceptually scaled by a factor of 10000. The > performance counter API uses 64-bit ints directly. So they're the same > thing, except that the VB code at the link has to fiddle around multiplying > the Frequency value by a magic 10000 to get VB to *treat* the value like a > real 64-bit int. OTOH, in (Ctr2 - Ctr1) / Freq, the 10000's cancel out so > they dare not play with magic multipliers in *that* context. Oh ya -- I bet > all the VB programmers understand this in sufficient detail to bet the > business on . This, and the various threads on numeric representation and computation, triggered the following thoughts: - Common number systems can't be completely and accurately represented in computers -- some limitations and/or approximations must be accepted. - This is widely acknowledged among programmers, but not obvious to newcomers. - Many of those who acknowledge it don't have a complete understanding of the "limitations and/or approximations" and the sometimes subtle consequences for building software that handles numbers "reasonably". (As evidence, I offer the discussions in this group. I also freely admit that, if I were to undertake serious floating-point programming again, I'd have to brush up on the details.) - For many purposes, a relatively naive level of understanding is sufficient -- provided it's accompanied by an appreciation that there's more to it, and that one may be required to learn the details of floating point, rational representations, etc. So, what are the implications for "Computer Programming for Everybody"? How much and what knowledge should the newbie be expected to master, to avoid falling into various traps? What conceptual model(s) of numbers should a language (say, for example, Python) present to the learner to be generally useful without making it too easy to go wrong? How can the language accommodate the differing needs of the learner and dilettante on the one hand, and the specialists in various kinds of numeric programming on the other? -- Don Dwiggins "Solvitur Ambulando" Advanced MP Technology dwig at advancedmp.net From nas at python.ca Sun Jun 24 11:23:50 2001 From: nas at python.ca (Neil Schemenauer) Date: Sun, 24 Jun 2001 08:23:50 -0700 Subject: PEP 255: Simple Generators In-Reply-To: ; from rnd@onego.ru on Sun, Jun 24, 2001 at 05:20:03PM +0400 References: Message-ID: <20010624082350.A29837@glacier.fnational.com> Roman Suzi wrote: > This implementation is cool, but how fast will be recursive generators? > How large is the overhead to defrost execution frame each time? Will it be > faster than functional gcomb? Why don't you write one and we will compare it to Tim's generator version? :-) I'll stick my neck and speculate that resuming a generator is measurably faster than calling a function. Neil From python at crazypenguins.commandprompt.com Sat Jun 30 02:57:20 2001 From: python at crazypenguins.commandprompt.com (python at crazypenguins.commandprompt.com) Date: Fri, 29 Jun 2001 23:57:20 -0700 Subject: Python book online (Graphical Programming with Py/QT) Message-ID: <20010629235720.A6112@crazypenguins.commandprompt.com> Hello, I think the subject says it all but over here at OpenDocs we have put up the first parts of our Graphical Programming with Python: QT Edition. The book is currently under development and we are actively seeking feedback. If everyone (who has an interest) could take a moment and browse the text it would be great. We will are looking for all types of feedback. It can be constructive or flame based :) The more feedback we receive the better the book will be. Here is the URL: http://www.opendocspublishing.com/entry.lxp?lxpe=93 OpenDocs From scarblac at pino.selwerd.nl Thu Jun 21 19:20:27 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 21 Jun 2001 23:20:27 GMT Subject: Pythoin MUD (PyMUD?) References: <9gqq3t$hvs$1@brokaw.wa.com> Message-ID: Jonathan Gardner wrote in comp.lang.python: > 2) Is there any mud hackers out there with advice or ideas? This thing is > as fresh as it gets, I want crazy and wacky ideas you've been mulling about > in your mind for the past 25 years, and I want this mud to be truly unique. I'm interested. Years ago I was a mud addict, always lpmuds, been admin on some. And I still think LPC is way cool. I've been thinking a bit about a mud in Python, the problems come when you run both the driver and code that was wrriten by wizards in the game (their areas) in the same interpreter. You need to shield the driver internals from the mud's objects. Although that's maybe possible with rexec and similar, it's still easy to do a DOS attack - you need only one drunken wizard to code an infinite loop, and your driver locks up. I haven't found a solution yet, haven't thought about it enough. It's very interesting :). And Stackless microthreads sound rather awesome for a mud like thing. > 3) Any newbies want to watch a mud being created? (OR - should I put this > on sourceforge? Or will you throw rotten eggs at me?) Always a big lack of free time. I'd like to see a mailing list though :-) -- Remco Gerlich From uioziaremwpl at spammotel.com Tue Jun 19 18:39:21 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Wed, 20 Jun 2001 00:39:21 +0200 (CEST) Subject: Which IDE ? In-Reply-To: <20010619144900.B7032@harmony.cs.rit.edu> Message-ID: On Tue, 19 Jun 2001, D-Man wrote: > On Tue, Jun 19, 2001 at 05:57:00PM +0100, phil hunt wrote: > | On Mon, 18 Jun 2001 22:57:13 GMT, VanPopering wrote: > [Which IDE?] > | > | I think professional programmers often prefer simple tools (i.e. > | text editor and command line). > > Sounds like a reasonable guess to me (at least wrt Unix programmers, I > think more MS Windows programmers use Visual Studio and other similar > tools). I use vim + bash also. I have tried some other environments, > but I haven't found any that I like as much. I do sometimes use some > IDE for a debugger interface (DDD, JBuilder, NetBeans, whatever - > depends on what machine I'm at and what I'm working on). Well, let me add my choice of environment, too: I'm using emacs and bash. I prefer emacs, because the provided Python mode is very elegent and makes coding much easier and faster. As I don't like xemacs, I always run emacs -nw. Using a shell as bash seems to me more flexible than some menu item "Run" in a graphical IDE. Cheers, Carsten -- Carsten Geckeler From aleaxit at yahoo.com Tue Jun 19 12:40:11 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 19 Jun 2001 18:40:11 +0200 Subject: paths: sleeping at the wheel References: <3B2F7682.D5C65F3@abaqus-sn.com> Message-ID: <9gnv9d017e3@enews2.newsguy.com> "david winkler" wrote in message news:3B2F7682.D5C65F3 at abaqus-sn.com... > I have been using Python for a while and have just noticed that when > accessing a script from the command line like this: "python > scriptname.py", the path must be cwd or fully qualified. I have tried > setting my system path without success. Is there a workaround to this > limitation (or a clarification to my misunderstanding)? I already know > how to avoid this type of situation by running the script like this: > "scriptname". I also know how to access modules using PYTHONPATH. There is no workaround that I know of to the limitation you correctly noticed. python.exe (or the python executable, on non-Windows platforms) would have to be modified to remove this limitation (or, to put it the other way 'round, to add to it some presumably-optional feature to search for the main script along some kind of 'path' -- presumably only if the main script is supplied as a bare filename bereft of path and such a named file is not found in the current directory). If you want to write down the specifications for the new requested features, it could go into a PEP -- don't worry about implementing it, that will be easily done if the PEP is approved, but rather about the pro's and con's of the proposed enhancement. Biggest pro I can think of is that people ASSUME the feature already exists and are surprised to find out it doesn't -- therefore, on the principle of least surprise, I guess it should go in, unless some serious contraindications should emerge...? Alex From sholden at holdenweb.com Wed Jun 13 17:53:29 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 13 Jun 2001 17:53:29 -0400 Subject: a newbie question about gadfly References: <9g7ter$iqo$1@plutonium.compulink.co.uk> Message-ID: wrote in message news:pn7fitoa7n6u47atng7tv0n9aroc1716ic at 4ax.com... > On 13 Jun 2001 14:30:51 GMT, gbreed at cix.compulink.co.uk wrote: > > >In article , > >jm7potter at hotmail.com () wrote: > > > >> On 12 Jun 2001 15:34:16 GMT, gbreed at cix.compulink.co.uk wrote: > >> > >> >In article , > >> >jm7potter at hotmail.com () wrote: > >> > > >> >> Why? is namex not a direct replacement for "donna" ???? > >> > > >> >Um, no, not the way you're doing it. Try replacing that > >magic > >> >line with > >> > > >> > > >> >Or even > >> > > >> >cursor.execute("insert into students (name, grade) values > >> >(%(namex)s, %(gradex)s)" % vars()) > >> > > >> >(that's sure to wordwrap!) > >> > > >> > > >> > Graham > >> > >> > >> Thanks for the help Graham, > >> > >> However, your code did not work either. The little program > >chokes every > >> time I try to > >> do anything that is not "hard-wired" into the script. > > > >Oops! There is an error: > > > >cursor.execute( > > "insert into students (name, grade) values ('%s', '%s')" > > % (namex, gradex)) > > > >might be better. I forgot to quote the arguments, and at least > >one of them is a string. > > > > It Works?!?!! It is alive!! > > Now, if you have the time and inclination --- could you explain why your first code > failed and the second worked? (I hate magic) > > And further, could you explain to a newbie why *my* code failed? > While Graham relaxes after his efforts, allow me to dive and and offer the explanations you seek. [c.l.py is like this...]. Taking them in reverse order: 1. Your original problem was why the following didn't work: namex = 'donna' gradex = 'grade 2' cursor.execute("insert into students (name, grade) values (namex, gradex)") If you had put a print statement in there, you would have seen that the statement you were trying to execute was, quite literally insert into students (name, grade) values (namex, gradex) In other words, simply using a variable name inside a string isn't enough to get its contents into the string. Perhaps you are a Perl user who is used to their language replacing variable names (easily spotted becuase they begin with a dollar sign) automatically substituted in strings. The question then becomes "How do I build a valid SQL statement with the contents of the variables in them?" There are several ways. You could have tried: cursor.execute("insert into students (name, grade) values ('" + namex + "', '" + gradex+ "')" This expression concatenates several strings, some of which are literals and some of which are variables bound to string values. Note that you needed to literally include the single quotes which delimit string values in SQL. Another way would have used the % string substitution operator, where you could have written cursor.execute("insert into students (name, grade) values ('%s', '%s')" % (namex, gradex)) In this case Python would have used the string to the left of the % operator as a format string, and eaech time it met a "%s" in the format it would substitute the next value from the tuple to the right of the %. There are many other format substitutions, and people are usually pointed at the C language's printf() function for a reference. I'm sure you can find them. 2. Graham's original suggestion (with proper continuation markup) was cursor.execute("insert into students (name, grade) values" \ "(%(namex)s, %(gradex)s)" % vars()) Note that when Python sees two string literals in juxtaposition this way it concatenates them automatically. This is a slightly different attempt at formatting: this time there is a dictionary (the dictionary of current variables) on the right of the %, and the format codes give the name of the required dictionary entry between the parentheses. Given the variable values you had, this would try to execute the SQL statement insert into students (name, grade) values(donna, grade 2) The problme with this version was Graham forgetting that SQL requires single quotes around the string values. So his final version put those in, giving you the statement insert into students (name, grade) values('donna', 'grade 2') Note also that it is really simpler and more efficient to have the SQL cursor do the value substitution, which I think Graham may have suggested as an alternative (or was it another poster?). In this case you mark the points of substitution in your SQL statement with question marks (this is the simplest style: the DB API allows five different kinds) and then give a tuple of values as a second argument to execute(). So you could have written cursor.execute("insert into students (name, grade) values(?, ?)", (namex, gradex)) and the cursor would have performed the substitution - including adding the required quotes around the string values, and excaping any single quotes that might have crept into the values to ensure that the result SQL statement was well-formed. Anyway, be that all as it may, congratulations on succeeding in writing your first Python database program. I am sure it won't be your last. regards Steve http://www.holdenweb.com/ From dalke at acm.org Thu Jun 28 16:24:56 2001 From: dalke at acm.org (Andrew Dalke) Date: Thu, 28 Jun 2001 14:24:56 -0600 Subject: PEP scepticism References: Message-ID: <9hg46o$grc$1@slb5.atl.mindspring.net> Jason F. McBrayer wrote: >>>>>> "RS" == Roman Suzi writes: >RS> There is limit after which more explanation is worse than less: > >RS> processed_list = [] >RS> for i in old_list: >RS> processed_list.append(func(i)) > >RS> adds nothing but noise, while: > >In this trivial case, probably not, but... A month or so I posted an example where I explained why I liked list comprehensions http://mail.python.org/pipermail/python-list/2001-May/042951.html It boils down to that this trivial case occurs very frequently, so I put the three lines or so into a function. But I couldn't think of a good function name. By using list comprehensions I traded off some strange syntax for the ability to describe everything in one place - more legibility in the long run. So my coding recommendation is to use list comprehensions solely for that trivial case, and use functions for more complex ones. Andrew From skip at pobox.com Fri Jun 22 07:57:46 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 22 Jun 2001 06:57:46 -0500 Subject: [Q] python embedding Demo In-Reply-To: References: Message-ID: <15155.12986.801010.331517@beluga.mojam.com> cyblue> ------------- cyblue> gcc demo.o cyblue> usr/lib/python1.5/config/libpython1.5.a -lsocket -lnsl -ldl -lreadline -lt cyblue> ermcap -lm -o demo cyblue> /usr/bin/ld: cannot find -lsocket cyblue> collect2: ld returned 1 exit status cyblue> make: *** [demo] error 1 cyblue> ---------------------- cyblue> what's wrong? Perhaps you don't need to link with the socket library. Try removing "-lsocket" from your link line. Same goes for any other libraries ld complains about. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From bokr at accessone.com Thu Jun 14 13:19:05 2001 From: bokr at accessone.com (Bengt Richter) Date: Thu, 14 Jun 2001 17:19:05 GMT Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: <9g4nec0cnr@enews2.newsguy.com> <3b266453.317327753@wa.news.verio.net> <3b2768b5.1425762@nntp.sprynet.com> Message-ID: <3b28ed01.483389587@wa.news.verio.net> On Wed, 13 Jun 2001 13:33:51 GMT, ullrich at math.okstate.edu (David C. Ullrich) wrote: >On Tue, 12 Jun 2001 19:25:25 GMT, bokr at accessone.com (Bengt Richter) >wrote: > >>[...] In general, I'd prefer that a language >>provide a clean way to create a solution to a problem, >>rather than having a particular solution built in. >>I like orthogonality too. > [...] >So just out of curiosity: Roughly what do you >mean by "orthogonality" above? Roughly, zero dot products ;-) That is, if you view program language feature space as n dimensional, and writing code using a particular feature as movement along a feature vector. Well, roughly something like that. 8-<:^P From jmarshal at mathworks.com Tue Jun 5 17:30:14 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 5 Jun 2001 21:30:14 GMT Subject: integers References: <9fjd8q$qb6$1@charm.magnus.acs.ohio-state.edu> <9fjgqf$rp0$2@brokaw.wa.com> Message-ID: <9fjj16$4in$1@news.mathworks.com> Jonathan Gardner wrote: > Locke wrote: >> is there such thing as >> someint++ >> or >> someint-- >> or >> someint += 2 >> in python?? >> >> it is a pain in the butt writing >> someint = someint + 1 >> >> Thanks! > It's also a pain in the butt writing someint += 1 (Yes, I know I am very > lazy). > What is the reason that python doesn't have increment or decrement > operators? Python isn't C - there's no reason to expect ++ or --. And I'd personally be against adding these to the language, since += and -= do increment and decrement nicely. Also, if ++ and -- were introduced people would probably expect them to be expressions (since they look like C's ++ and --). This would be another mistake, in my opinion. I like how Python keeps side-affecting language constructs in the realm of statements. From jkn at nicorp.f9.co.uk Wed Jun 20 11:56:09 2001 From: jkn at nicorp.f9.co.uk (Jon Nicoll) Date: 20 Jun 2001 08:56:09 -0700 Subject: arguments to calldll.call_foreign_function() ? Message-ID: <8351bb33.0106200756.4776fed5@posting.google.com> Hi there I want to experiment with using calldll to access a win32 function: QueryPerformanceCounter(), which has a prototype BOOL QueryPerformanceCounter( LARGE_INTEGER *lpPerformanceCount // address of current counter value ); I've got as far as this: :: testcalldll.py import calldll # get the handle of a module m = calldll.load_library('kernel32') # get the address of my function f = calldll.get_proc_address(m, 'QueryPerformanceCounter') # try to call the function # print calldll.call_foreign_function(f, '', 'l', ()) :: end but I can't work out the right parameters for the last line - the call_foreign_function(). Help, please? Thanks Jon Nicoll From ken_chiba at hotmail.com Wed Jun 20 19:45:11 2001 From: ken_chiba at hotmail.com (Ken) Date: Wed, 20 Jun 2001 23:45:11 GMT Subject: How to install python on clean RH7.1 install Message-ID: <3b313462.13451051@news1.on.sympatico.ca> Hi, I'm trying to install Python 2.1-5 onto a newly installed RH7.1. The RH install was done pretty cleanly, so not a lot of the RPMs have been installed (I've installed some along the way, as dependencies came up). My quesions are these: 1). Is it possible to "upgrade" the python 1.5.2 that is installed with RH7.1? (I couldn't easily avoid installing it - because it was a dependency for a lot of packages. That said, I cannot easily uninstall the RPM for 1.5.2). 2). If not, what way is more or less a fail-safe way of installing python into a new directory. I have tried the following already: - installing from the src.rpm file -- the installer stopped short of creating the RPM file... something about it not finding a lot of files (that it was to have compiled). It made it through the check, and did about 5 minutes of compiling, then stopped. - installing from the rpm file. The dependencies failed were libcrypto, and libssl -- but I have NO idea where to find these (preferrably RPMs). Any ideas would be greatly appreciated! Kc From grante at visi.com Sun Jun 24 20:55:43 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 25 Jun 2001 00:55:43 GMT Subject: How to install python on clean RH7.1 install References: <3b313462.13451051@news1.on.sympatico.ca> <3B33F025.D275AAB1@student.gu.edu.au> <3b35170a.268083173@news1.on.sympatico.ca> <3B353837.6A68A329@student.gu.edu.au> <3b35deb3.319196179@news1.on.sympatico.ca> Message-ID: On Sun, 24 Jun 2001 13:43:55 GMT, Ken wrote: >As to compiling the src rpm, I tried that - with less success than the >RPM. It burns through compiling for about 5 minutes (P233MMX, 64mb), >and then you see a LOT of "unrecognized file type" messages fly by, >and eventually, the compile fails. > >Any other ideas? Grab the sources. $ tar xzvf Python-2.1.tgz $ cd Python-2.1 $ ./configure $ make (su root) # make install -- Grant Edwards grante Yow! My polyvinyl cowboy at wallet was made in Hong visi.com Kong by Montgomery Clift! From deltapigz at telocity.com Sat Jun 23 17:44:40 2001 From: deltapigz at telocity.com (Adonis) Date: Sat, 23 Jun 2001 17:44:40 -0400 Subject: creating a matrix in python? Message-ID: <3B350DC7.748C3903@telocity.com> how do i go about this? i have looked into the tutorial 100+ times and cant get anything on matrices out of it? only thing i came up with was some thing like: blah = ['buh', 'blah', 'wassah'] blah[1][0] 'buh' ??? any help would greatly be appreciated. Adonis From tim.one at home.com Sun Jun 10 23:12:29 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 10 Jun 2001 23:12:29 -0400 Subject: Libraries implementation in C or in Python? Evolution of Python, Jython... In-Reply-To: <3B22D3FE.9FDA579A@earthlink.net> Message-ID: [Ron Stephens] > Are Python's libraries generally written in C or in Python, Both; e.g., look in your Lib/ directory and you'll find a couple megabytes of Python library source. > and why? Complex coding is easier in Python; low-level fiddling is easier and runs faster in C. > Someone commented on another thread that the re.search() function ran > faster in its 1.5.2 version than in its 2.1 version, because in 1.5.2 it > was implemented in C and in 2.1 it was implemented in Python. It was > suggested to instead use the "pre" module, but I see it is old and may > become obsolete? I am curious as to the reasoning behind why these kinds > of changes and decisions are made? sre was primarily motivated by the new need to support Unicode (pre couldn't handle it). Fredrik also thought he could write a matching engine faster than pre, and turns out he was right. But any project has to be completed in finite time, and there can't be a guarantee that every case will be no slower than before. In the way I use regexps, I almost always find that sre is faster. There are no "general reasons" here: each thing has its own reasons. > In general, as Python evolves from version to version, is Python code > likely to get slightly faster in execution time, or slightly slower? Neither, really, although the trend since 1.5.2 has been to get a bit slower each time. Two things account for that: 1. New features can cost. For example, rich comparisons added many more possibilities for the runtime code to sort through, and *simple* comparisons got significantly slower as a more-than-less direct result. Or cyclic gc removes worries about trash cycles leaking, but it takes time to find those cycles (before they simply leaked). 2. Fixing ancient bugs. For example, it's possible to crash any Python through 2.1 by filling a dict with class instance keys, where the class overrides comparison with a function that mutates the dict while it's comparing. This isn't sane, but it is possible. Plugging this hole required additional code in the dict lookup routines, and that slows them down. Plugging holes often costs a little, and then plugging many holes adds up to more than a little. OTOH, current CVS Python is significantly quicker than 2.1 by several accounts, as people have found 2.1 hotspots and added patches to cool them off. On the third hand, Python's speed is also significantly affected by the compiler and OS; for example, on identical hardware, pystone runs significantly faster under Win2K+MSVC than under Linux+gcc, but test_bufio runs 10x faster under Linux; etc. "The speed" of a x-platform app is a slippery concept, because it's not independent of platform. > Mind you, I am a Pythonista because of the numerous other beauties of > the language, not because of any speed issues; and I can certainly see > why Python should be and is optimized for other criteria, not speed, and > if this sometimes means a little step backwards in speed of code > execution then so be it. But I am just curious about the trade-offs, and > why such decisions are made. Decisions to accept or reject a new feature don't generally take speed into account, because it's generally impossible to predict in advance. What happens instead is that if an accepted feature is "too slow", someone who cares enough will speed it over the next release cycle. It's actually rare that anyone cares enough to do that, though. > There have been a few threads about 2.x versions of Python being a > little slower, in terms of the execution speed of similar code, than > 1.5.2. Is this speed decrement likely to be permanent? It's impossible to say without specific code to time on a specific platform. The only way you'll ever get a clear answer to something as vague as "similar code is a little slower -- permanent?" is if a developer chimes in with "Doh! I *knew* I shouldn't have left sleep(1) in the inner loop" . > ... > I hesitate to ask any of this, because my extreme state of newbieness > and lack of knowledge do not give me any right to even speak up and ask > such questions. I only rush in where I should fear to tread because the > tangible beauty of the evolutionary process of a work of art such as the > Python programming language excites my curiosity and sense of wonder. Rest assured (or appalled ) that Python is pretty much the same as any large project in this respect: the speed freaks worry about speed, the feature freaks push for new features, the good-old-days freaks complain about change, and nobody has enough time to do all they want to do. > And then there is Jython. Is Python the mother and Java the father, or > is it the other way around? They're more like teenage siblings, who can't believe their parents ever had sex so each suspects the other of being adopted. > Does anyone else see the evolution of Python, Jython and future > offspring as a living work of art? Undoubtedly. But they usually keep it to themselves . From kjetiln at kvarteret.uib.no Wed Jun 27 05:04:56 2001 From: kjetiln at kvarteret.uib.no (Kjetil =?iso-8859-1?Q?Nyg=E5rd?=) Date: Wed, 27 Jun 2001 11:04:56 +0200 Subject: Escaping SQL in python Message-ID: <3B39A1B8.A7FCE4C7@kvarteret.uib.no> Is there a method to escape ' " \ and the like in python auto-magiacaly ? -- Kjetil -------------- next part -------------- An HTML attachment was scrubbed... URL: From feedback at netlcr.de Thu Jun 14 18:41:38 2001 From: feedback at netlcr.de (Florian Scholz) Date: Fri, 15 Jun 2001 00:41:38 +0200 Subject: sorting values in dict References: Message-ID: <3B293DA2.DDE4A564@netlcr.de> > I want to display a dict sorted by value. > > This is my dict: > > total={} --------another code-snip--- def swap(el): return (el[1],el[0]); total = {} list = map(swap,total.items()); list.sort(); ------ or shorter ------ total = {} list = map(lambda el : (el[1],el[0]) ,total.items()); list.sort(); From ykingma at accessforall.nl Mon Jun 18 14:47:05 2001 From: ykingma at accessforall.nl (Ype Kingma) Date: Mon, 18 Jun 2001 19:47:05 +0100 Subject: Function lookup using a directory. References: <29pX6.14682$cF.320097@news1.nokia.com> Message-ID: <3B2E4CA6.AF9C5D84@accessforall.nl> Andy, In addition to the earlier replies: Your run() method seems to be checking for presence of arguments, so you might consider defining it with an extra '*' as: class Help0: def run(self, *which): if len(which) == 1: print 'Help no args' else: print 'Help args' This will give you a tuple with the passed arguments, in your case an empty tuple. Have fun, Ype andy.pevy at nokia.com wrote: > > Hi Guys > > I am having trouble with the directory data type. What I want to > do is to set up a directory that I can use to parse a command entered by > the user, and have a directory return the name of a class to handle the > command. Like this :- > > command_table = {'0': 'Help0', > '1': 'Help1', > '2': 'Help2', > '3': 'Help3' } > > class Help0: > > def run(self,which): > if len(which) == 1: > print 'Help no args' > else: > print 'Help args' > [snip] > > if __name__ == '__main__': > > command = user_input() > > try: > h = command_table[command[0]] > except: > print command[0]+' not found' > > h.run() # Call the run method of the selected class. > -- email at xs4all.nl From sill at optonline.net Sat Jun 16 23:37:01 2001 From: sill at optonline.net (Rainy) Date: Sun, 17 Jun 2001 03:37:01 GMT Subject: Newbie Question: Naming Conventions References: Message-ID: On 16 Jun 2001 00:39:01 -0700, Abe wrote: > I expect that this is a subject that has been beaten to death, but I > haven't been able to find much info on it: > > I've experimented with many many computer languages, and I have to say > that from what I've seen thus far of Python, it is probably the most > elegant I've encountered. The combination of its clean syntax, OO > nature, and functional aspects is excellent. HOWEVER, I'm very > frustrated over the apparent lack of stylistic conventions for method > names, etc in an otherwise consistent language. > > From a search of the archives, it appears that Guido's stance on this > is that developers should be free to choose a style that suits them. > I don't think anyone would disagree with that, but can't we at least > have some consistency for the standard packages and built in > functions? The recent trend seems to be towards CapitalWords for > classes and alllowercase for methods and packages... but then there > are builtin throwbacks like has_key and raw_input mixed in that stick > out like a sore thumb. I think the idea is that really often-used names are lower case because they'd be hard to type if they weren't, and rarely used ones like say UserDict are upper case. If you add that rule, it makes sense, I think. > > Coming from the java world where the naming style is very consistent, > having to use 'has_key' in the same code block as 'hasattr' drives me > crazy! I could easily modify the C files to alias the 'haskey' and > 'rawinput' names to the correct methods, but then my code wouldn't > work on any other python runtime. Yeah, that's true.. I'm not sure why has_key is different from hasattr, maybe somebody else can fill this one in.. > > So my question is: is there any proposal to standardize this sort of > thing? Would such an initiative be welcome in the python community, > or is it seen as not important? Does anyone see any obvious > compatibility problems with providing an extra 'correct' version of > nonconforming methods and classes until the originals can eventually > be phased out? > > Or if this has all been covered before, please let me know where I can > find the relevant discussion. > > Thanks! -- Delay not, Caesar. Read it instantly. -- Shakespeare, "Julius Caesar" 3,1 Here is a letter, read it at your leisure. -- Shakespeare, "Merchant of Venice" 5,1 [Quoted in "VMS Internals and Data Structures", V4.4, when referring to I/O system services.] From jeff at ccvcorp.com Fri Jun 22 19:55:42 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Fri, 22 Jun 2001 16:55:42 -0700 Subject: Running an .exe file with python References: <9h0jc9$npg$1@bob.news.rcn.net> Message-ID: <3B33DAFE.E4FAADAD@ccvcorp.com> Christian Reyes wrote: > you should try the os.execv method > > >>> os.execv('c:\\yourapp.exe') > > christian > > "Steve Keri" wrote in message > news:ea903c3a.0106221412.641fcf3 at posting.google.com... > > Is there a way i can run an .exe file and install a program using > > python? please help Or possibly >>> os.system("c:\\yourapp.exe") I seem to remember something in the docs regarding execv & family, and how their behavior differs between unix & win32, but don't recall details offhand--you can always check the library reference for info on the os module. Jeff Shannon Technician/Programmer Credit International From insanc at cc.gatech.edu Fri Jun 15 13:59:36 2001 From: insanc at cc.gatech.edu (Holland King) Date: 15 Jun 2001 17:59:36 GMT Subject: bad python display Message-ID: <9gdie8$r2v$1@solaria.cc.gatech.edu> sorry for the cross-posting but i am not real sure what is causing the problem. i have a python program using the tkinter module to create a gui. my local system is running woody debian with kde. i am running the program on a soloris box. on both my system and the solaris system i am using the same version of ssh, python, and tkinter lib. the problem is when i try to export the display from the solaris box to my local machine all i get is the frame and half the boxes and buttons. when i run it locally i get the correct display and when i try to export the display on other machines i get the correct display. i think it has something to do with ssh, but i have tried everything i can think of. can anyone think of what might be causing the display on my machine to be unusable? ssh -V == 2.5.2p1 python -v == 1.5 tkinter -v == 1.127 thank you. -- --- Joseph Holland King | "God whispers to us in our pleasures, speaks in our | conscience, but shouts in our pains: it is His | megaphone to rouse a deaf world." C. S. Lewis From sabren at manifestation.com Wed Jun 20 16:32:15 2001 From: sabren at manifestation.com (Michal Wallace) Date: Wed, 20 Jun 2001 15:32:15 -0500 (CDT) Subject: Pythoin MUD (PyMUD?) In-Reply-To: <9gqq3t$hvs$1@brokaw.wa.com> Message-ID: On Wed, 20 Jun 2001, Jonathan Gardner wrote: > I was tinkering around and I got the base skeleton for a python MUD > working (you can LOOK and LOOK at something... cool.) cool. :) > 1) Is there any existing python muds out there? Actually, there are a couple you might want to look at: http://moebius.bofh.net.au/ http://www.strout.net/info/coding/python/intro.html and one in jython: http://www.cabochon.com/ Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.net www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From meowbot at meowing.net Sat Jun 2 13:54:16 2001 From: meowbot at meowing.net (Indirect Meowbot) Date: 02 Jun 2001 13:54:16 -0400 Subject: What does x[:]=[4,5,6] mean? References: <9fb7cu$lq6$1@newsreaderg1.core.theplanet.net> Message-ID: <87elt2u5rr.fsf@litterbox.meowing.net> "Franz GEIGER" wrote: > In site.py I saw > sys.path[:] = L > What does this mean? Why is the '[:]'? Why not simply > sy.path = L ? In a language like C you have to work a little bit harder to get a pointer to something. In Python, you have to work a little bit harder _not_ to get just a reference. >>> meow = [1,2,3] >>> woof = meow >>> meow[0] = 42 >>> print meow, woof [42, 2, 3] [42, 2, 3] >>> # Ewww! ... >>> meow = [1,2,3] >>> woof[:] = meow >>> meow[0] = 42 >>> print meow, woof [42, 2, 3] [1, 2, 3] >>> # Yay. From paustin at eos.ubc.ca Sun Jun 24 22:36:59 2001 From: paustin at eos.ubc.ca (Phil Austin) Date: 24 Jun 2001 19:36:59 -0700 Subject: tgrind defs for python? References: <3B365F85.70952299@tundraware.com> Message-ID: This one for lgrind was posted ca 1998: python|Python|py:\ :pb=^\d?(def|class)\d\p(\d|\\|\(|\:):\ :cb=#:ce=$:sb=":se=\e":lb=':le=\e':\ :kw=accept and break class continue def del elif else except\ exec finally for from global if import in is lambda not or\ pass print raise return try while: Regards, Phil From aleaxit at yahoo.com Fri Jun 1 06:19:40 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 1 Jun 2001 12:19:40 +0200 Subject: Obsolesence of <> References: Message-ID: <9f7q7s02as4@enews1.newsguy.com> "Lulu of the Lotus-Eaters" wrote in message news:mailman.991352942.30691.python-list at python.org... ... > In the end, spelling is arbitrary, of course. But having families of > corresponding spellings for corresponding semantics makes it easier to > remember a language, and to teach it. Exactly. Teaching (and teachees' remembering:-) is my focus on such issues. "lesser/greater" is the WRONG suggestion to impart syntactically when desired semantics is "not equal", given that "ab" and "a <> b" behave differently. Not that != is ideal, of course, but at least it avoids such specific "subliminal misinformation"... "Thou shalt not kill, but needs't not strive // officiously to keep alive", as Clough might have put it:-). Alex From jh at web.de Fri Jun 29 17:20:00 2001 From: jh at web.de (Jürgen Hermann) Date: Fri, 29 Jun 2001 23:20:00 +0200 Subject: translate() Message-ID: <9hirel$iqd$00$1@news.t-online.com> Hi! I have some issues with string.translate() and want to hear some opinions: 1. The first argument (the translation table) always has to be provided. It would be nice if I could pass in None to JUST delete some chars: str.translate(None, "delchars") 2. string is deprecated, but there is no "maketrans" string method; a possible implementation would be string.maketrans(a,b) ==> a.maketrans(b) Any thoughts? Ciao, J?rgen From castor at snafu.de Wed Jun 6 18:38:41 2001 From: castor at snafu.de (Wolfgang Lipp) Date: Wed, 06 Jun 2001 22:38:41 GMT Subject: ExtensionClasses for Python 2.1? References: Message-ID: <1107_991867121@ns.seowon.ac.kr> >On 6 Jun 2001, Wolfgang Lipp wrote: >> Does anyone know whether Jim Fulton of Zope's ;-) >> ExtensionClass module is available for Python 2.1 > > Yes. Zope 2.4 will require Python 2.1, hence EC will be updated. DC >already released Zope 2.4.0 alpha1, so you can look there. > >Oleg. thanks, i wasn't aware of this. on checking however, i realized there is (of course) no *binary* release as yet, and i can't compile right now... >sigh< but thanks anyway for the tip. -wolf From 63.80.158.242 Fri Jun 8 15:12:54 2001 From: 63.80.158.242 (63.80.158.242) Date: Fri, 08 Jun 2001 19:12:54 GMT Subject: Cookbook on the DevCenter References: <84r8wwklqr.fsf@localhost.localdomain> Message-ID: Yep! We'll be publishing the "best of" recipes from the Python Cookbook site in book form. Laura LLewin at oreilly.com > > Are there any plans to bring out a 'dead trees' version of the > Python cookbook, not unlike the Perl Cookbook ? > > -arun > Stephen> The latest additions to the Python cookbook are now > Stephen> featured on the front page of the O'Reilly Network Python > Stephen> Dev Center. ================================== Poster's IP address: 63.80.158.242 Posted via http://nodevice.com Linux Programmer's Site From thecalm at NOSPAM.btinternet.com Mon Jun 25 13:28:00 2001 From: thecalm at NOSPAM.btinternet.com (Gaz) Date: Mon, 25 Jun 2001 18:28:00 +0100 Subject: how do i run a script without the console showing?? Message-ID: <9h7s9i$khc$1@uranium.btinternet.com> how do i run a script without the console showing on winME, im writting a script using Tkinter and while the console is ok showing while im developing/debugging it, when im finished i want the console to disappear! :) how do i do that? gaz. From uioziaremwpl at spammotel.com Sat Jun 23 05:13:09 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Sat, 23 Jun 2001 11:13:09 +0200 (CEST) Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: On Sat, 23 Jun 2001, Tim Peters wrote: > [Carsten Geckeler] > > I think we came to the core point. It seems that some people have > > exactly the other oppinion, i.e. that the differences how a generator > > is evaluated and used is so different that a different "def" line would > > be helpful for many people. > > Yup, that's it in a nutshell. Generally speaking, though, the people in the > latter camp have only read about generators, never used them. > > > Could you tell me, how e.g. a "generator" statement would > > be distracting? > > Sorry, no: Guido pronounced on this, and that's the end of the argument. When you make a statement in a post, it may be very nice if you could comment on it. > It's been debated to death -- see the Python-Iterators list for dozens of > repetitions of every argument made here (including this one). > > > I can't see how a more clearifying statement could possibly distract > > people. > > But it's not really clarifying if it draws a useless distinction . Cheers, Carsten -- Carsten Geckeler From edcjones at erols.com Wed Jun 20 11:45:49 2001 From: edcjones at erols.com (Edward C. Jones) Date: Wed, 20 Jun 2001 11:45:49 -0400 Subject: function attributes (ANN: Introducing PLY-1.0 (Python Lex-Yacc)) References: <3B306425.1BA938BE@lemburg.com> <15152.40380.99624.826511@gargoyle.cs.uchicago.edu> <3B30A64D.EB779804@lemburg.com> Message-ID: <3B30C52D.5040009@erols.com> David Beazley wrote: > M.-A. Lemburg writes: > I'd definitely consider using them if they were syntactically > convenient to use. However, I'm mostly at a loss as to how you > would actually go about doing that. I suppose you could > have something like this: > > def p_expr_plus(t): > .gram = 'expr : expr PLUS expr' > ... Perhaps "self" could be made a keyword. Then you could say: def p_expr_plus(t): self.gram = 'expr : expr PLUS expr' ... Ed Jones From bob at passcal.nmt.edu Wed Jun 6 14:57:35 2001 From: bob at passcal.nmt.edu (Bob Greschke) Date: Wed, 6 Jun 2001 12:57:35 -0600 Subject: Calling a C function that alters the passed argument? References: <9flmg3$1s4b$1@newshost.nmt.edu> <9flref$ong$1@nntp6.u.washington.edu> Message-ID: <9fluas$1vve$1@newshost.nmt.edu> > The last is by far the best, in most cases. The options do not > include modifying an integer parameter, that isn't how Python works. I sorta figured that when I couldn't find any examples of it. I've got a whole library of C functions to write wrappers for that are basically like this, and they can't be changed. OK, I'll TRY to EXCEPT your example. :-) Thanks! Bob "Donn Cave" wrote in message news:9flref$ong$1 at nntp6.u.washington.edu... > Quoth "Bob Greschke" : > | Here's the C function I want to call from Python: > | > | char *boo(ANumber) > | int *ANumber; > | { > | *ANumber = 42; > | > | if (something went wrong) > | return "An error message"; > | > | return (char *)NULL; > | } > | > | > | How would I write the wrapper function for this? All I can find are > | examples where the wrapper functions deal with the returned value from > | C functions. > > Trying to understand your question, the assumption I'm leaning > towards is that you want the Python function to preserve this API. > Don't even think about it. Your choices are basically > > error, number = boo(), or > number, error = boo(), or > try: > number = boo() > except SomeError, val: > print 'boo error', val > > The last is by far the best, in most cases. The options do not > include modifying an integer parameter, that isn't how Python works. > > You may want to look at some examples for the way to set an exception, > will probably look something like > PyErr_SetString(PyExc_ValueError, "error message shredded"); > > Then return 0 to signal the exception, instead of PyInt_FromLong(number). > > Donn Cave, donn at u.washington.edu From root at rainerdeyke.com Wed Jun 6 23:29:47 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Thu, 07 Jun 2001 03:29:47 GMT Subject: Interesting speed benchmark References: <3B1D6FED.4070506@nospam.yahoo.com> <3B1EC430.9020201@nospam.yahoo.com> Message-ID: "Michael P. Soulier" wrote in message news:aRBT6.147831$eK2.35759519 at news4.rdc1.on.home.com... > On Wed, 06 Jun 2001 18:00:48 -0600, Mahesh Padmanabhan > wrote: > > > > Seems like that poster was correct in pointing out that the memory > > management scheme of Java vs Python makes a difference. > > What are the disadvantages of this kind of "lazy garbage collection"? Basically that you have to do manual resource management for non-memory resources. The following function leaks a file handle under Jython but works correctly under CPython: def print_file(fname): file = open(fname) print file.read() -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From loewis at informatik.hu-berlin.de Thu Jun 21 09:56:43 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 21 Jun 2001 15:56:43 +0200 Subject: Packing a long long type References: <5c8ecb0b.0106191444.53054b47@posting.google.com> Message-ID: crj003 at yahoo.com (Rich J) writes: > Does anyone know how it would be possible to pack a list containing > 'long long' types (like 111111111111111L) and other standard types > (int, string, char). I know you can use the struct module to pack all > but the 'long long'. I also know you can use the xdrlib module to pack > the 'long long'. Any ideas? The Python version in the CVS supports a 'q' format, see http://python.sourceforge.net/devel-docs/lib/module-struct.html For Python 2.1, you probably need to split the long long into two longs, and pack them separately. Notice that the order in which to pack them depends on endianness. Regards, Martin From phd at phd.fep.ru Mon Jun 4 08:10:43 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Mon, 4 Jun 2001 16:10:43 +0400 (MSD) Subject: MySQL module In-Reply-To: <3B1B7717.7E53510F@oek.dk> Message-ID: On Mon, 4 Jun 2001, Peter I. Hansen wrote: > What is the recommended module for MySQL ? Is it the MySQL module or the > MySQLdb module (which is in v. 0.35 !) ? Or is it something completely > different ? MySQLdb Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From pythoneer at diganet.com Wed Jun 13 15:13:17 2001 From: pythoneer at diganet.com (John Tobler) Date: 13 Jun 2001 12:13:17 -0700 Subject: Python Development: San Diego Message-ID: <711a10e7.0106131113.6d3d4c9b@posting.google.com> I am compiling a list of companies doing Python software development in the San Diego, CA, area. If you know of any, please let me know. John Tobler grepninja at diganet.com http://cyberjet.tripod.com/grepninjalog/ PS: I mis-edited this the first time. Sorry. From jmarshal at mathworks.com Wed Jun 13 08:55:27 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 13 Jun 2001 12:55:27 GMT Subject: Python grammar.. References: Message-ID: <9g7nrv$nnb$1@news.mathworks.com> John Roth wrote: > So what you're saying is that if I have a function "Spam(eggs, ham) and a > function > scramble(, size = small), then I'd have to write > Spam(scramble(eggs), ham) as > Spam scramble eggs ham. > How do I tell that "ham" is an operand of Spam, and not the second operand > of scramble? The > only way this could possibly work is if the parser could tell, at compile > time, exactly how many > operands each function had. There are languages where this is possible, but > Python isn't one of them. Choose a parsing rule and use parens to group things differently. Python (and many other languages) already need parens to do this for binary operators ("1-2-3" parses as "(1-2)-3"). So you'd probably have to write "Spam(scramble(eggs), ham)" as "Spam (scramble eggs) ham". From db3l at fitlinxx.com Wed Jun 20 16:03:47 2001 From: db3l at fitlinxx.com (David Bolen) Date: 20 Jun 2001 16:03:47 -0400 Subject: PEP 255: Simple Generators References: <9gnv2o$its$1@nntp6.u.washington.edu> Message-ID: "Russell E. Owen" writes: (...) > Since a generator is very different than a function, why not mark it as > such right up front? (...) > I agree that revealing the internal implementation is bad. I disagree > that return is reasonable, though it is much less of a concern if a > generator doesn't look like a function right up front. But isn't a generator really just a function that is returning an iterator? That is, why is it "very" different from a function, internal implementation aside, which we agree it's not necessary to reveal. If I have a function that returns a sequence, then the caller is free to iterate over that sequence. A generator returns an iterator for which the caller is equally able to do so. Or in either case to apply any other methods that are applicable to the returned object type. They're a lot more alike than not to my mind - the yield permits the generator itself to be written more elegantly, but to the caller its still largely a function that returns an object supporting a particular interface. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From sholden at holdenweb.com Tue Jun 26 08:50:59 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 26 Jun 2001 08:50:59 -0400 Subject: MS SQL Server References: <51dgjtsbuureuugfcubid11tldg7077sfa@4ax.com> Message-ID: "Ben" wrote in ... > Hi, > > Unfortunately I have to upload data to a MS SQL server ... Can anyone > recommend a tool for doing this or docs\examples :] ... is it ANSI > SQL compliant like MySQL and therefore can use the same commands? > > greatly appreciate any advice > Ben: The easiest way (assuming you have the ability to connect to both databases from Python, otherwise this would be an off-topic post, woudn't it ;-) is to do the whole thing in Python. You don't make it clear whether the data is coming from other relational sources or from somewhere else. THe principle is the same in either case, however. SQL Server is (like most relational systems) ANSI compliant at the lowest level. Fortunately, since all you need to use is the INSERT statement, this should be enough. ODBC is the easiest way to connect to SQL Server, but look at using mxODBC rather than the currently-disfunctional odbc module form the win32 extensions. Hope this helps. regards Steve -- http://www.holdenweb.com/ From andy.elvey at paradise.net.nz Sat Jun 9 18:37:16 2001 From: andy.elvey at paradise.net.nz (Andy Elvey) Date: Sun, 10 Jun 2001 10:37:16 +1200 Subject: Python for win32 development, GUI, Database, dlls References: <9fnrc8$lmp$1@newnews.mikom.csir.co.za> Message-ID: <9fu954$1a82$1@raewyn.paradise.net.nz> One option you may want to check out is ReportLab (which is done in Python ) - it is free - http://www.reportlab.com Also , have a look at the data-plotting package DISLIN - free , works with Python, very good graphics. http://www.dislin.de/ Getting data from Access (using Python) - the O'Reilly book "Python programming on Win32" has some very useful code in it - chapter 13 (Databases) would be helpful to you ..... :-) . This is a very good book for anyone using Python on Win32. Karel van der Walt wrote in message news:9fnrc8$lmp$1 at newnews.mikom.csir.co.za... > I have been approached in a 'time to market situation'. > > Python appears to me to be a strategic choice, however: > > this is a number crunching application most numeric stuff in existing > (fortran) dll > the new development will entail a lot of visualization, pseudo GIS like, > animation (coloring of contours), plain media (digital picures, video) in > a rich interactive GUI > > then all of this data in MS Access (what else?), with reports and graphs on > top of it. OK the latter can be in a reportwriter as long as one can call an > .exe with commandline parms from python) Integration with MS Office formats > (not ole automation) would be important (thus MS Access for imports > exports). > > Any grave misgivings? > > Any pointers? > Commercial libraries? However the exchange rate doesn't favour that :( > > tx k > > > > > From jkraska1 at san.rr.com Sat Jun 16 03:24:18 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 16 Jun 2001 07:24:18 GMT Subject: qt or gtk? References: Message-ID: On Sat, 16 Jun 2001 05:52:12 GMT, sill at optonline.net (Rainy) wrote: > >I want to learn python gui programming in linux. I think tk looks too ugly, so >I narrowed down the choice to two main contenders, qt and gtk. Which of these >has more complete and up-to-date python bindings? Do recall that Qt is only *half* free. It is free for Linux development, but costs an arm and a leg on Windows. I might suggest you take a look at WxWindows while you're doing all this. It has a reasonably elegant interface, IMO. And, like all good things in life, it's indeed free. C// From jramas at acm.org Sat Jun 30 14:48:58 2001 From: jramas at acm.org (Joseph Ramaswami) Date: Sat, 30 Jun 2001 14:48:58 -0400 Subject: data from Acces to Excel References: <9hiie0$84o$1@news.tpi.pl> Message-ID: <9hl6ph$2m5$1@bob.news.rcn.net> Sure, you can use python to export a table form Access to Excel, but why would you? It is really simple to export it directly in Access. Just click on File, Save As/Export in the menu. Choose "To an External File or Database" and choose the correct file type. You can even script this in VBA if you have to. Hope this helps, JR "baton" wrote in message news:9hiie0$84o$1 at news.tpi.pl... > Hi, > I wonder if there is a possibilyty to export table from Access database to > Excel using python language?? If yes, could you tell me how to do it or > where I can find info how to do it? > > Sorry for my English > > From anonymous at anonymous.anonymous Tue Jun 26 16:49:32 2001 From: anonymous at anonymous.anonymous (Anonymous) Date: Tue, 26 Jun 2001 13:49:32 -0700 Subject: the indentaion for grouping thing References: <3b34de9a$1_2@anonymous> <9h2qpa$6bg$1@slb0.atl.mindspring.net> Message-ID: <3b38f4a5_1@anonymous> "Andrew Dalke" wrote in message news:9h2qpa$6bg$1 at slb0.atl.mindspring.net... > Use tabnanny, or run Python with the '-t' or '-tt' > options. If you're worried, force your version > control system to run a validation on the code > before checking it in. Like I said, all answers like "well, just use product x" don't fly because it's not just me that has to use the script. I want my scripts to be maintainable by people I don't necessarily know of. I consider it a design flaw to have the language dependent upon artificial solutions that are external to the language in order to have it be maintainable. Anyway, nothing will change, so is there a product like I asked about that validates and parsers python with paired delimiters added? Not pindent, and not comments, because the script has to be unparseable by python without the pre-processor. --------== Posted Anonymously via Newsfeeds.Com ==------- Featuring the worlds only Anonymous Usenet Server -----------== http://www.newsfeeds.com ==---------- From grante at visi.com Fri Jun 22 23:12:08 2001 From: grante at visi.com (Grant Edwards) Date: Sat, 23 Jun 2001 03:12:08 GMT Subject: [OT] MS EULA -- (will ActiveState become outlaws? ;-) References: <3B33F5E9.45730271@student.gu.edu.au> Message-ID: On Sat, 23 Jun 2001 11:50:33 +1000, Joal Heagney wrote: >> No -- it's not the Slashdot Effect (at least in the performance sense). >> It's been changed to redirect you to a 'page not found' page. >> They very clearly removed it. >> Wiser and cooler heads must have prevailed at MS. > >They have those? Yup. They bring them to Bill's office on platters. Later they're placed on pikes out in front of the building. -- Grant Edwards grante Yow! -- I have seen the at FUN -- visi.com From gmcm at hypernet.com Wed Jun 27 10:40:31 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 27 Jun 2001 14:40:31 GMT Subject: Im running Macmilan Inc's standalone.py and im having a few difficulties finding modules it requires References: <9hb4st$j5l$1@neptunium.btinternet.com> Message-ID: <90CD61E25gmcmhypernetcom@199.171.54.194> G. Willoughby wrote: >Im running Macmilan Inc's standalone.py and im having a few difficulties >finding modules it requires, any idea where these modules can be found? > >dos >mac >nt.stat >os2 >posix >strop.lowercase >strop.maketrans >strop.uppercase >strop.whitespace >ce >pwd >MACFS >macfs >MacOs None of these are problems. Some are names in modules (the strop stuff, for example), the others are conditional imports that don't apply to your platform. The warnings are there because it may be the only way to trace down a missing module. If your code did sys.path.append('funny dir') import vitalmodule Installer would almost certainly miss vitalmodule unless you doctored PYTHONPATH or used the pathprefix option. That's because your (byte)code is analyzed (not executed, which could have too many side effects), and the manipulation of sys.path won't be recognized. - Gordon From gherman at darwin.in-berlin.de Thu Jun 28 03:35:11 2001 From: gherman at darwin.in-berlin.de (Dinu Gherman) Date: Thu, 28 Jun 2001 09:35:11 +0200 Subject: PEP 260: simplify xrange() References: Message-ID: <3B3ADE2F.ED0D5099@darwin.in-berlin.de> Tim Peters wrote: > > >>> print len(frange(0.0, 1.0, 0.1)) > 11 > >>> > > That's the kind of "inexplicable" crap we don't want to have to try to > explain : repeated addition is a Bad Idea for floats. IMHO this is not Python's fault, and all other languages that don't rely on some sort of symbolic algebra should show the same "phenomenon". > You can improve the numeric quality of the results by generating via > [...] > instead (repeated addition accumulates rounding errors without bound; the > alternative suffers no more than 2 rounding errors (total) for each element > produced). Then it returns 10 elements in the example above. This is an obvious improvement - thanks! Dinu From m.hadfield at niwa.cri.nz Mon Jun 25 17:50:58 2001 From: m.hadfield at niwa.cri.nz (Mark Hadfield) Date: Mon, 25 Jun 2001 21:50:58 +0000 (UTC) Subject: 'with' statement in python ? References: Message-ID: <002a01c0fdc0$f17d1af0$d938a8c0@Hadfield> From: "asgard" > Hello, > writing self before every object's method really drives me > crazy. Shouldn't there be 'with' statement like in Pascal, ie. There was an extensive discussion on this recently. Perhaps you'd like to try a search on Google Groups. IIRC the consensus was that adding this to Python would not be a good idea, because when "with" blocks are nested they become hard to read and possibly ambiguous. --- Mark Hadfield m.hadfield at niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield National Institute for Water and Atmospheric Research -- Posted from clam.niwa.cri.nz [202.36.29.1] via Mailgate.ORG Server - http://www.Mailgate.ORG From edcjones at erols.com Thu Jun 14 17:22:02 2001 From: edcjones at erols.com (Edward C. Jones) Date: Thu, 14 Jun 2001 17:22:02 -0400 Subject: Any other Python flaws? References: <3B2914A0.6010902@erols.com> <9gb6ap$p10$1@news.mathworks.com> Message-ID: <3B292AFA.6090809@erols.com> jcm wrote: > Edward C. Jones wrote: > > >>It follows from some basic concepts of Python that >> "array = ([0] * 10) * 10" >>does not behave as usually intended. This is a well-known "dark >>corner" of Python; a place it is simply best to avoid. >> > > For this example, what would you say people would usually expect? > Here is some correct code: array = [[0] * 3] *3 print array array[0][0] = 1 print array The output is: [[0, 0, 0], [0, 0, 0], [0, 0, 0]] [[1, 0, 0], [1, 0, 0], [1, 0, 0]] One might expect: [[1, 0, 0], [0, 0, 0], [0, 0, 0]] From dgoodger at bigfoot.com Thu Jun 21 20:50:10 2001 From: dgoodger at bigfoot.com (David Goodger) Date: Thu, 21 Jun 2001 20:50:10 -0400 Subject: PEP 255: Simple Generators In-Reply-To: References: Message-ID: Generators are very cool. I'm sure I will use them. I'm glad they're getting into Python. Thank you Neil, Tim, and Magnus, for all your work. on 2001-06-21 2:57 PM, Tim Peters (tim at digicool.com) wrote: > a generator-function returns a generator-iterator That's what it boils down to. Before generators, all functions returned objects using explicit 'return' statements. Now, generator-functions return generator-iterators, but there's *nothing* explicitly saying 'return generator_iterator'. Before generators, calling a function executed its code. Now, calling a generator-function doesn't execute the code at all; you have to execute the magically returned object. Only the 'yield' indicates any of this variant behavior. Can I get used to it? Yes, I think I have enough spare brain cells. (Heck, I used to know Perl! ;-) Should I get used to it? "Explicit is better than implicit." -- David Goodger dgoodger at bigfoot.com Open-source projects: - Python Docstring Processing System: http://docstring.sf.net - reStructuredText: http://structuredtext.sf.net - The Go Tools Project: http://gotools.sf.net From m.faassen at vet.uu.nl Sun Jun 24 14:21:26 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 24 Jun 2001 18:21:26 GMT Subject: Any other Python flaws? References: <9gr8o8$hhq$4@newshost.accu.uu.nl> Message-ID: <9h5b36$cg0$2@newshost.accu.uu.nl> Remco Gerlich wrote: > Martijn Faassen wrote in comp.lang.python: >> The PSU Public License is an open source licence even more infectuous >> than the GPL. Even software that does not link to it must be released >> under the PSUPL. Even software on a completely different computer, >> even on a completely different planet. The PSU therefore holds the >> exclusive rights over very advanced Klingon first person shooters, >> which will blow away Quake & co in gore and impressiveness when the PSU >> releases it to the market. > Is the PSU license TGPLV (Totalitarian GeeInYou-Script Pubic [sic] License > Virus) compatible? > (http://catalog.com/hopkins/text/gnuscript.html) Yes, like all other software, the PSU license causes any TGPLV'ed software to be PSUPL-ed. Since PSUPL infection proceeds at a rate faster than that of the speed of light (it even has access to time travel), the PSUPL will win. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From kkto at csis.hku.hk Sun Jun 17 03:14:34 2001 From: kkto at csis.hku.hk (Isaac To) Date: 17 Jun 2001 15:14:34 +0800 Subject: Any other Python flaws? References: Message-ID: <7izob7o9wl.fsf@enark.csis.hku.hk> >>>>> "Michael" == Michael Chermside writes: Michael> Gee... I had no idea this was possible. Surely it's a bad Michael> idea... right? I object. Making it otherwise would make the language very inconsistent. Consider this. How often do you want to name a local variable as "len" in Python? How about "buffer" or "chr"? Perhaps you never. I do this regularly, though. I expect that if I don't need to use these built-in names in a function, I can use the name in whatever way I'd like. "None" is no different. You are not assigning to the system "None", but instead you're creating a new local variable called "None". I don't know why it has anything to do with the global None. So you can have two different but consistent rules: allow assignments to variables which have default built-in bindings, and ignore the issue completely. Python developers like the latter, and so do I. Just think about what will happen for the first choice. Programmers have to remember all the built-in names, other than the reserved words. Once a new built-in name is added, program can break. If you embed Python to make an extended interpretor, you'll have to think about whether you want to forbid changing the new built-in names in that extension. And then you get some inconsistencies either way. I don't like any of these ideas. If you don't know there is a thing in Python called "None", and thus assign something as the local value, chances are that your function simply don't need the global None value, so that assignment is actually quite safe. Regards, Isaac. From jparlar at home.com Tue Jun 19 10:42:13 2001 From: jparlar at home.com (Jay Parlar) Date: Tue, 19 Jun 2001 10:42:13 -0400 Subject: Simple example that won't work! Message-ID: <20010619144752.ZCXI7002.femail4.rdc1.on.home.com@jparlar> > >> My exact call was >> retval = urlretrieve(url)[0], where url is any web address. > >Some more code would be appreciated, so we don't have to spend time to >guess anything. > > >-- >Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 > >Anyone sending unwanted advertising e-mail to my address will be >charged $250 for network traffic and computing time. By extracting my >address from this message or its header, you agree to these terms. >-- >http://mail.python.org/mailman/listinfo/python-list > Well, I didn't include anymore code because it was really trivial, and I thought the problem could be found from the exceptions. However, since you asked, I'll paste the code in as well. from urllib import urlretrieve from string import strip def firstnonblank(lines): for eachLine in lines: if strip(eachLine) =='': continue else: return eachLine def firstlast(webpage): f = open(webpage) lines = f.readlines() f.close() print firstnonblank(lines), lines.reverse() print firstnonblank(lines), def download(url = 'http://www.opera.com:3600',process = firstlast): print url retval= urlretrieve(url)[0] if retval: process(retval) def urlEntry(): url2 = raw_input('Please enter the URL') download(url2,firstlast) if __name__ == '__main__': download() The error, as stated before, occurs on the call to urlretrieve(), and the exception is as follows: Traceback (most recent call last): File "C:\Program Files\Python20\Pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript exec codeObject in __main__.__dict__ File "C:\Program Files\Python20\scripts\grabweb.py", line 37, in ? download() File "C:\Program Files\Python20\scripts\grabweb.py", line 23, in download retval= urlretrieve(url)[0] File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 68, in urlretrieve return _urlopener.retrieve(url, filename, reporthook, data) File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 198, in retrieve fp = self.open(url, data) File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 166, in open return getattr(self, name)(url) File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 267, in open_http h = httplib.HTTP(host) File "c:\program files\python20\lib\httplib.py", line 640, in __init__ self._conn = self._connection_class(host, port) File "c:\program files\python20\lib\httplib.py", line 330, in __init__ self._set_hostport(host, port) File "c:\program files\python20\lib\httplib.py", line 336, in _set_hostport port = int(host[i+1:]) ValueError: invalid literal for int(): Hopefully this is enough information now, and thank you to anyone who's looking at this. Jay P. From db3l at fitlinxx.com Thu Jun 21 17:16:35 2001 From: db3l at fitlinxx.com (David Bolen) Date: 21 Jun 2001 17:16:35 -0400 Subject: Getting info on who is using a file on Windows... References: <4a249347.0106210606.ef3e16a@posting.google.com> Message-ID: bobh at hslda.org (Robert) writes: > I am on a Windows network and I am trying to see who is connected > to an access database. > > I have been perusing the docs but nothing has jumped out and hit me > in the head. > > Any ideas? If the file is being shared via Windows networking, and you're using NT/2K servers (not sure about other platforms), then Server Manager for Domains (srvmgr.exe - installs with server OS versions, also available in the resource kit) can connect to a machine and give you information about open files and files in use along with clients. That assumes that the access database is being accessed at the file level across the network, and not via some client/server approach where the actual file access is local on the server (I don't think that's usual for access, but I don't have much experience with it). -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From cyberlync at yahoo.com Sat Jun 30 10:55:41 2001 From: cyberlync at yahoo.com (Eric Merritt) Date: Sat, 30 Jun 2001 07:55:41 -0700 (PDT) Subject: Python compiler In-Reply-To: <3B3DA2BC.2E52A118@ActiveState.com> Message-ID: <20010630145541.94405.qmail@web13007.mail.yahoo.com> > > That's a strange thing to hold against a language. > How does it affect > you? I could build an executable for you in either > Java or Python that > was indistinguishable from one that was native code > compiled without > disassembling it. > > If your complaint is that Java (or Python) is too > slow, I think you > should say that. If your complaint is that you can't > write standalone > binaries in it (you can), you should say that. I'd > like to understand > what you really need so I can tell you whether > Python has what you need > or not. I wasn't trashing java as a language (or python for that matter) they are both good languages, python being better in my opinion. My complaint was about speed. Most of the time the speed of java and python is adiquate, but sometimes I require speed. Also it would be nice to get a big speed increase by just compiling. Anyhow, I did not meen it as a complaint just a nice thing to have. > > Creating a compiler for Python is difficult and as > it isn't really > needed to accomplish most people's goals, nobody has > done it. We could > put a bunch of effort into it but we'd come back to > that executable that > is basically indistinguishable from the one I could > give you today > without the compiler. Thats why I asked. Thanks four your reply. __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ From qrczak at knm.org.pl Fri Jun 22 14:22:51 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 22 Jun 2001 18:22:51 GMT Subject: function attributes (ANN: Introducing PLY-1.0 (Python Lex-Yacc)) References: <3B306425.1BA938BE@lemburg.com> <15152.40380.99624.826511@gargoyle.cs.uchicago.edu> <3B30A64D.EB779804@lemburg.com> <3B30C52D.5040009@erols.com> Message-ID: Wed, 20 Jun 2001 11:45:49 -0400, Edward C. Jones pisze: > Perhaps "self" could be made a keyword. Then you could say: > > def p_expr_plus(t): > self.gram = 'expr : expr PLUS expr' Would it assign it when the function is defined (not involed)? I would find it confusing. Alas, we do want to assign it when the function is defined! So "something = expr" at the beginning of the function body is not a good idea. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From idi.amin at NOFUCKINGSPAMORILLSUEYOURASSfrisurf.no Sat Jun 2 16:31:50 2001 From: idi.amin at NOFUCKINGSPAMORILLSUEYOURASSfrisurf.no (Polterguy) Date: Sat, 2 Jun 2001 22:31:50 +0200 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> Message-ID: [...snip...] I agree totally, but fact is 99.99999% of the commersial world uses win32. So why go through the extra trouble adding cross OS programming when it's going to increase the cost of releasing a product with a factor of 50?!? All game companies founded on cross OS releases have either gone broke or are soon to become so! How much I may hate Bill Gates and that stupid CEO of him who doesn't even know what HAL means, there's still the facts. If you want to be successfule and reach 99.9999% of the world use technology built on win32, DirectX, C++, hell fucking ay, if you can get away with it use VB!!. Use OBJECT tags in your HTML, use ASP (especially the new ASPX and the webforms i find XTREMELY interresting...). This is my opinion and I realize this will probably become my own social suicide, but fact is that every successfule software dealer don't give a shit about anything but windows... ...all though it's really sad, and I wish the world was different... From nas at python.ca Thu Jun 21 16:44:45 2001 From: nas at python.ca (Neil Schemenauer) Date: Thu, 21 Jun 2001 13:44:45 -0700 Subject: PEP 255: Simple Generators In-Reply-To: ; from glyph@twistedmatrix.com on Thu, Jun 21, 2001 at 01:59:08PM -0500 References: <20010621083153.A19734@glacier.fnational.com> Message-ID: <20010621134445.B20524@glacier.fnational.com> Glyph Lefkowitz wrote: > Generators solve *some* problems for which synchronous execution is > desirable, but not others. They change the semantics of function > definition (despite the BDFL's pronouncement, my favorite piece of python > zen is still "explicit is better than implicit" ^_^). They add a keyword. > They do not fill my needs, or the needs of anyone working with simulation > code, network dispatching, or massively parallel computing; whereas the > simpler solutions which *do not* add a keyword and *do not* change the > semantics of function definition can fill the needs of a far greater > group, as well as the same set that would require generators. PEP 255 is not intended to solve everyone's problems. It is an attempt at doing _something_ useful. Is it better to have generators in Python 2.2 or should we wait indefinately for microthreads? Even if we do get microthreads I still see the extra syntax being useful. Have you ever tried implementing generators using Stackless's continuation primitives? How would you explain to new users what those magic functions do? > Stackless is problematic, but I think that an implementation > similiar to that of generators could give us microthreads. > When I get back from vacation I'll write up a PEP; if you'd > like to give me a hand, feel free to drop me an email :) This would indeed be great news. I've spent quite a bit of time thinking about this and the stackless approach is best solution I can think of. Neil From tim.one at home.com Mon Jun 18 20:09:11 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 18 Jun 2001 20:09:11 -0400 Subject: idle BUG In-Reply-To: <3b2d9e55.354289@nntp.ix.netcom.com> Message-ID: [Mike Clarkson] > ... > Tim, I know you're very busy these days (learning to sketch? :-), but > could you examine the MSVC compile and link flags with a microscope > for similarities and differences between _tkinter.c and tkappinit.c > and tkAppinit.c for wish. You might be able to talk Fredrik into that, but I have to pass: we don't build Tcl or Tk on Windows, we ship the precompiled versions as installed by the Scriptics tcl832.exe, from http://dev.scriptics.com/software/tcltk/downloadnow83.html My knowledge of Tcl + Tk is 0; IOW, if something's wrong there, I wouldn't notice it if it stuffed a banana up my nose and gave me a dozen roses. not-a-gui-guy-ly y'rs - tim From thamza.nospam at flash.net Tue Jun 26 01:29:12 2001 From: thamza.nospam at flash.net (Tim H) Date: Tue, 26 Jun 2001 05:29:12 GMT Subject: win32ras on win98? References: Message-ID: A little preemptive replying here. Yes I searched google and there are several recent threads on this but they all die out with the suggestion to use a utility like rasdial95, or the NT util rasdial. That's been in my C:\bin for years and works fine. By the way another neat program like this is DOS Dial (ddial.exe) which has a little more functionality and can be scripted a little bit. I'm not affiliated, etc. I'm sure there are others. But anyway does the win32ras module work on win9x for anybody? Tim H From thinkit8 at lycos.com Tue Jun 12 11:39:37 2001 From: thinkit8 at lycos.com (thinkit) Date: 12 Jun 2001 08:39:37 -0700 Subject: humans and logic Message-ID: <9g5d3p0f0p@drn.newsguy.com> humans should use a power of 2 as a base. this is more logical because it synchs with binary, which is at the very heart of logic--true and false. it is more natural perhaps, to use decimal--but logic should, and will, win out. From jwc3f at Virginia.EDU Thu Jun 21 17:15:53 2001 From: jwc3f at Virginia.EDU (Jeffrey W. Collyer) Date: 21 Jun 2001 21:15:53 GMT Subject: Thread safety of UDP sendto Message-ID: <9gto69$ij2$1@murdoch.acc.Virginia.EDU> An odd question perhaps, but is Python's UDP socket.sendto() thread safe? I have a multi-threaded app that I would like to send off some UDP packets. The data for the packets is gathered in each thread. If I get a socket handle in each thread it will be less efficient than if I open one upon program start and then have each thread just do an ubersocket.sendto(data,ADDR). Or am I missing something more basic? What I really need is an atomic write function that handles threading, but I'll settle for a cheap UDP solution. -- peace Jeffrey W. Collyer jwc3f at virginia.edu From loewis at informatik.hu-berlin.de Tue Jun 12 13:35:31 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 12 Jun 2001 19:35:31 +0200 Subject: localisation of IDLE? References: Message-ID: Roman Suzi writes: > it turned out that under Windows IDLE doesn't allow > cyrillic to be print. People pointed me that the > problem is with TK support for Unicode, which > broke cyrillic support. > > Is there some edit-the-registry, tweek-Windows solution > to this problem (that is, solution, which doesn't > require to change files from Python distribution? I believe setting the default encoding in site.py should do the trick. Regards, Martin From ullrich at math.okstate.edu Mon Jun 4 10:17:45 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 04 Jun 2001 14:17:45 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> <3b19393d.703539923@news.okstate.edu> <3B1ADE2D.A6E86ECE@san.rr.com> Message-ID: <3b1b978e.3996421@nntp.sprynet.com> On Mon, 04 Jun 2001 01:02:37 GMT, Darren New wrote: >"David C. Ullrich" wrote: > >> That's assuming that physics is not all wrong. And >> probably I should not have said what I did the >> way I did, because my impression is that there >> is really no such thing as complete information >> about a physical system. > >Last I heard, the "hidden variable" theory was disproved by the Bell >Inequality. I.e., there's no information in a system that is just >invisible but really controlling when the atom will decay. Instead, that >information just isn't there. Apparently, you can actually do >experiments to tell the difference. Boggle indeed. Actually the "no-hidden-variables theorem" goes back to before Bell (I think to VN); coming up with that inequality and the experiment to test it was kind of incredible. I forget where I saw this: "Quantum Mechanics: The dreams stuff is made of." >Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. > San Diego, CA, USA (PST). Cryptokeys on demand. > This is top-quality raw fish, the Rolls-Rice of Sushi! David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From daniels at mindspring.com Tue Jun 5 23:01:00 2001 From: daniels at mindspring.com (Alan Daniels) Date: Tue, 05 Jun 2001 23:01:00 -0400 Subject: Bios calls in Python? References: Message-ID: On Tue, 5 Jun 2001 19:46:28 -0400, Humanity let out a collective sigh of relief when "Bill Walker" finally typed: >Is it possible to make BIOS calls in Python (Windows version)? In >particular, I would like to plot graphic points in EGA resolution to the >console screen. Depending on the version of Windows, I don't believe direct BIOS calls to the screen are possible any longer, unless you're writing a device driver (and that's one of the few programming tasks Python can't do). You *could* call DirectX via Python's COM library, but unless you already know DirectX, it would take forever to learn. Your best option is to go get SDL (Simple DirectMedia Layer, at http://www.libsdl.org), which, while not perfect or even 100% complete yet, has Python bindings and lets you draw directly to the screen. ============================== Alan Daniels daniels at alandaniels dot com From greg at cosc.canterbury.ac.nz Wed Jun 6 01:47:07 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 06 Jun 2001 17:47:07 +1200 Subject: I had a thought ... (I know, call the newspapers). References: <9f5nhn02816@enews2.newsguy.com> <9fb78v$qf5$1@216.39.170.247> Message-ID: <3B1DC3DB.A9F38F4C@cosc.canterbury.ac.nz> David LeBlanc wrote: > > Currency might be a comfortable metaphor for people, > especially accounting types who probably think a number is naked without > a currency symbol. But you need *some* numbers other than currency. If I buy 3 widgets at $1.23 each I'm spending 3 * $1.23, not $3 * $1.23, which would give a result in square dollars. I don't know what square dollars look like, but I'm sure my bank wouldn't accept them... -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From scarblac at pino.selwerd.nl Wed Jun 20 02:36:22 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 20 Jun 2001 06:36:22 GMT Subject: RFD comp.lang.python.zope & ZPugDC Meeting Tomorrow References: Message-ID: Chris Abraham wrote in comp.lang.python: > I have two sort notes. First one is I would like to test the waters > before I take the initiative to put a proposal together for a newsgroup > for Zope. I suppose it's more useful to test waters on the Zope mailing list, but then it's almost certain that this group would get loads of votes. > I envision this to be a subgroup of comp.lang.python, > comp.lang.python.zope. As Zope is really an application made of python, > just as Mason is of Perl and Midgard is of PHP and Enhydra is of Java, > methinks this is appropriate. I'm not sure. Just that it's written in Python doesn't seem very relevant, and it can be extended in Perl now as well. Other options would be comp.soft-sys.zope or comp.infosystems.www.appservers.zope or something like that. If you want a smooth news.groups discussion (is that even possible these days?), at least try to give more explanation why your name is better in the RFD :). Would the group mirror the Zope list the way comp.lang.python and the mailing list do? Anyway, I'd like to see it happen. Comp.lang.python is a very busy group, but splitting it won't work well. Maybe the best way is to make some of the mailing lists into newsgroups, and Zope is obviously big enough. -- Remco Gerlich From greg at cosc.canterbury.ac.nz Thu Jun 21 01:12:38 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 21 Jun 2001 17:12:38 +1200 Subject: PEP 255: Simple Generators References: Message-ID: <3B318246.6E4FD8AA@cosc.canterbury.ac.nz> Tim Peters wrote: > > Since generators produce an iterator > object, you can very easily tie your head into knots already, if you're > determined to. And glossing over the mechanism by which they're produced makes it even easier! -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From aleaxit at yahoo.com Wed Jun 6 12:23:17 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 6 Jun 2001 18:23:17 +0200 Subject: random References: <3b1cf00f.5441109@nntp.sprynet.com> <3b1e43f4.1661099@nntp.sprynet.com> Message-ID: <9flldm01o6s@enews2.newsguy.com> "David C. Ullrich" wrote in message news:3b1e43f4.1661099 at nntp.sprynet.com... ... > I didn't bother mentioning the semantics before getting straight > whether the syntax counted as "self-delimiting". It is very > easy to design a Turing-complete programming language where > the syntactically valid programs are exactly the bitstrings > consisting of all 0's terminated by a 1. Assunming that If so, then the set of Turing-machine program must be enumerable (alpha-0). But is it? > "arbitrary binary data" means only finitely much binary > data that's no problem. I think there is the rub. What I find in the "Stanford Encyclopedia of Philosophy", e.g: """ A Turing machine is an abstract representation of a computing device. It consists of a read/write head that scans a (possibly infinite) two-dimensional tape divided into squares, each of which is inscribed with a 0 or 1. Computation begins with the machine, in a given "state", scanning a square. It erases what it finds there, prints a 0 or 1, moves to an adjacent square, and goes into a new state. This behavior is completely determined by three parameters: (1) the state the machine is in, (2) the number on the square it is scanning, and (3) a table of instructions. The table of instructions specifies, for each state and binary input, what the machine should write, which direction it should move in, and which state it should go into. (E.g., "If in State 1 scanning a 0: print 1, move left, and go into State 3".) The table can list only finitely many states, each of which becomes implicitly defined by the role it plays in the table of instructions. These states are often referred to as the "functional states" of the machine. """ Finite-state machine at the 'core', infinite tape (sorry I used more than two tape symbols in my previous post and assumed an 'output' that was not to the tape itself, but I believe it's easily proved that you can map any finite number of tapesymbols to two, and use [e.g] even squares of the tape as 'input' aka 'program' and odd ones for 'output', etc, etc). This is the TM (not yet necessarily Universal, all depends on that FSM at the core) as I recalled it, after lo these many years... [E.g. to treat even and odd squares differently you "just" have to split the core FSM appropriately, so it 'remembers' whether it's on an odd or even square of the tape -- that is just one bit so at most it doubles the FSM's states -- doing it all with 0 and 1 is unwieldy but you can move to any finite number of symbols by using N squares with 0 and 1 to represent up to 2**N distinct symbols and complicating the FSM accordingly -- etc, etc... but of course it's possible to slip in one of these "etc"s:-)] Alex From jochen at riekhof.de Thu Jun 14 07:59:53 2001 From: jochen at riekhof.de (Jochen Riekhof) Date: Thu, 14 Jun 2001 13:59:53 +0200 Subject: substitute for c/java's ?: References: Message-ID: <9ga8ue$7aj$07$1@news.t-online.com> > Trust me, this is true. Nope. haha, the usual examples that shall prove how great one's favorite language is. During the many years of programming I finally managed to drop the evangelism (am, well... almost ;-). I can encourage everyone to do the like, as one lives more comfortable and has a greater chance to be unbiased. The longish java code can e.g. be rewritten as /**Utility which returns 'a' or 'an' for a given noun. */ public static final String aan(String name) { return ("aeiou".indexOf(name.toLowerCase().charAt(0)) < 0) ? "a" : "an"; } which, compared to def aan(name): """Utility which returns 'a' or 'an' for a given noun. """ if string.lower(name[0]) in ('a','e','i','o','u'): return 'an ' else: return 'a ' is not all that bad ;-). Of course you can use if else you like this better. In particular this is not my favourite use of ?:, I would probably have used if/else as well here.. But there is often the need to assign one of two values depending on a simple condition. if a == 0: result = value1 else: result = value2 This is more readable and faster to understand (just because there is less code) with ?:. result = (a == 0) ? value1 : value2; This is especially important when result is a more longish expression. With only moderate experience the meaning is clear at a glance. For this cases I miss ?:. Just my opinion ;-) What do you think? Neil and Remco wrote: >cases = {"dog": Dog, "cat": Cat, "rabbit": Rabbit} > > def createPet(type="cat"): > if casses.has_key(type): return casses[type]() #Good input... > else: return None # bad input, or 'default' in C/java Nice trick! >result = option and value1 or value2 also nice, almost forgot about this feature (result is last evaluated code)! Thanks! Ciao ...Jochen From frank at opticode.co.za Sat Jun 16 04:43:17 2001 From: frank at opticode.co.za (Frank Conradie) Date: 16 Jun 2001 01:43:17 -0700 Subject: ihooks or imputil? Message-ID: <233dd1ac.0106160043.5e4bd1a5@posting.google.com> Hi there I've searched the archives for everything on custom importers that I could find, and there seems to be two ways to create them: ihooks or imputils. Can anybody please tell me which is the "preferred" or "official" way to create custom importers, and where I can find *recent* example code or documentation? Thanks, Frank From ullrich at math.okstate.edu Mon Jun 4 14:53:48 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 04 Jun 2001 18:53:48 GMT Subject: random References: Message-ID: <3b1bd138.873545372@news.okstate.edu> On Sun, 3 Jun 2001 18:14:47 -0400, "Tim Peters" wrote: >[David C. Ullrich] >> ... >> Not that readers are likely to be reading carefully enough that it's >> going to matter, but just for the sake of telling no lies: I put >> my finger on what was bothering me about what I said here. >> It's not true that the sequence of bits of Omega is recursively >> enumerable. What's true (assuming that the N-th bit is 1 if the >> N-th program halts and 0 otherwise) is that the sequence of N >> for which the N-th bit is 1 is recursively enumerable. The >> set of N for which the N-th bit is 0 is _not_ recursively >> enumerable (and hence the sequence of bits of Omega is not >> recursively enumerable.) > >It's the "assuming that the N-th bit is 1 [iff] the N-th program halts" >that's off. Omega is the probability that "a random" program halts, and it >won't take long to figure out that "N'th-bit = halts(N-th program)" doesn't >work for that Drat. I looked, and of course I did in fact have the definition bollixed - the method he uses to "generate a program by coin-tossing" is not what I recalled. We _do_ need a definition of "random program", and he does give one, but it's not what I thought it was. So much of what I said just now about Omega is not correct. But otoh it's because I mis-recalled the definition of "generate a program by coin tossing". It is _not_ true that it doesn't take long to figure out that "n-th bit = 1 iff n-th TM halts" cannot give the probability that a random TM halts - the following parenthetical comment cannot show that Omega could not be what I thought, because you don't use anything about the particular distribution Chaitin uses, and with _some_ distributions Omega _would_ be as I said. Or to put it another way: > (e.g., if the 0'th program happens to halt, that would imply >the halting probability is >= 1/2 across all programs -- but the 0'th >program isn't generally that smart ). Nope - this sounds good but it's specious. With the distribution I thought Chaitin was using it _would_ follow that Omega > 1/2 if the 0-th program happened to halt, and with the distribution he _does_ use things that are equally winkie-sounding _do_ follow: Pick a program that does happen to halt. If that program is K bits long then the fact that that particular program halts _does_ show that Omega > 2^{-K}. That program happens to be smart enough to imply that the halting probability is larger than something - with a different distribution it would just imply that the halting probability is larger than a different thing. So I lied, but it's not as obvious as you say that my lie _must_ have been wrong - as long as we're just talking about "a random program" without specifying the distribution what I said could have been right regardless of questions of how smart the first program is. I guess I was misled by his display

W = å p halts 2 -|p|

which certainly looks like the binary expansion of a number if you don't look closely - each program that halts adds a power of 2 to the probability, just like in

W = å pj halts 2 -j

That's the best excuse I can contrive. Oh well. Thought I had the problem of inexact floating point solved. David C. Ullrich *********************** "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From phrxy at csv.warwick.ac.uk Fri Jun 29 15:48:42 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Fri, 29 Jun 2001 20:48:42 +0100 Subject: noncommercial Python+QT on Windows? (was Re: qt or gtk?) In-Reply-To: References: <9gk8he$8gl$1@brokaw.wa.com> <16074dce.0106181045.139d80a5@posting.google.com> <3b3b40a0@news.uia.ac.be> <9hfjho05to@enews1.newsguy.com> Message-ID: On Fri, 29 Jun 2001, Toby J Sargeant wrote: > On Thu, Jun 28, 2001 at 05:47:03PM +0200, Alex Martelli wrote: > > Very interesting -- NOW, is there a way one can develop Python > > software, cross-platform, using Qt, and redistribute it: legally, > > for free and with sources? > > You should have a look at PyQt. For some reason it's relatively > unknown, Isn't PyQt what he was referring to? Maybe I misunderstood... > PyQt should also be available for mac development, given that Qt is free > for the mac as well, but I don't think I've ever heard of anyone trying > to build it there. Hasn't been released yet, and will only be available for MacOS X. I don't think Trolltech has stated what the license options will be. John From tdelaney at avaya.com Fri Jun 29 00:57:07 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Fri, 29 Jun 2001 14:57:07 +1000 Subject: list of lists, object doesn't support item assignment? Message-ID: > >>> xy = (1,2),(2,2) > >>> print xy, xy[0] > ((1, 2), (2, 2)) (1, 2) > >>> xy[1]=(3,4) > TypeError: object doesn't support item assignment > > Is there a way to assign the list (3,4) to an element of xy? > What am I missing? Quite simple: (1,2) or 1,2 is not a list, but a tuple. Tuples are immutable. Lists are created with square backets. Try this: xy = [(1,2),(2,2)] print xy, xy[0] xy[1] = (3,4) Tim Delaney From michael at trollope.org Sat Jun 23 14:26:21 2001 From: michael at trollope.org (Michael Powe) Date: 23 Jun 2001 11:26:21 -0700 Subject: namespace issue? References: <87k825ljrz.fsf@elbereth.ccraig.org> <87wv64hg87.fsf@elbereth.ccraig.org> Message-ID: <87ae2z2gtu.fsf@cecilia.trollope.org> >>>>> "Christopher" == Christopher A Craig writes: Christopher> Michael Powe writes: >> Actually, it doesn't contain the dash. The dash is only >> inserted if I press the enter key, leaving the PN string empty. >> In the case of an Christopher> I see that now. I was really only paying attention Christopher> to the conditional... >> So now the question is, 'why'? Am I misusing the string.find() >> function? Okay, string.find() returns -1 when the string is not >> found, which would seem to be what I expected, a false result. >> Maybe python doesn't treat -1 as false? Well, I'll try being >> explicit and testing for -1 return. I probably have just >> confused myself hopelessly. Christopher> As others have pointed out, -1 is not false in Christopher> Python. I would highly recommend you (and anyone Christopher> else just learning the language) read section 2 Christopher> (Built-in types) of the Library reference thoroughly. Christopher> There is a lot of very useful information on how Christopher> builtin types and functions work in there. Thanks, I'll take a closer look. I've only looked at it piecemeal, trying to work things out. Christopher> More importantly though your code (which I quote Christopher> below for readability), does not initialize Ph if the Christopher> conditional is false. Even if you fix the logic Christopher> error in the code, you are left with something that Christopher> possibly returns an uninitialized value, which is bad Christopher> practice. I presume that you want the program to Christopher> return a value even when that condition is false, so Christopher> you should have an else clause. If you want an error Christopher> condition to occur when the condition is false then Christopher> you should assert() the condition. Right. The end result looks like this: def GetPhone(): CC = raw_input("Country Code (ENTER for none): ") AC = raw_input("Area Code: ") PN = raw_input("Phone Number: ") if not AC : AC = '503' if not PN : PN = '000-0000' i = string.find(PN, '-') if len(PN) < 8 and i == -1 : Ph = '(' + AC + ') ' + PN[:3] + '-' + PN[3:] elif len(PN) >= 8 and i == -1 : Ph = CC + " " + PN[:4] + '-' + PN[4:] else : Ph = AC + PN return Ph That seems to be working. Obviously, I don't have any errorchecking yet. Functionality first. Thanks for the help, I appreciate it. mp -- Michael Powe Portland, Oregon USA 'Unless we approve your idea, it will not be permitted, it will not be allowed.' -- Hilary Rosen, President, Recording Industry Association of America From not.this at seebelow.org Wed Jun 27 23:44:45 2001 From: not.this at seebelow.org (Grant Griffin) Date: Wed, 27 Jun 2001 22:44:45 -0500 Subject: Check out O'Reilly's Open Source Convention Highlights References: Message-ID: <3B3AA82D.1A0FE860@seebelow.org> Guido van Rossum wrote: > > I promise this is a one-time ad! Check out the Python track: > > http://conferences.oreillynet.com/cs/os2001/pub/w/os2001/sessions_python.html Durn--it's in California. Why aren't these things ever held in the Midwest?--it's centrally located, ya' know. must-be-some-kindda-darn-conspiracy-for-you-East-Cost-folks-to -rack-up-frequent-flyer-miles--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From menscher+python at uiuc.edu Fri Jun 8 14:37:30 2001 From: menscher+python at uiuc.edu (Damian Menscher) Date: Fri, 08 Jun 2001 18:37:30 GMT Subject: run function in background? Message-ID: Is there a way to run a function in python in the background? Ideally I'd want something like def my_func(params): stuff here for i in range(10): print "starting a process" my_func(params) & where the & indicates that shouldn't stop the flow of the program, so the loop would continue and have all 10 go simultaneously. (Doing this using map() won't work for me, since my actual problem is a bit more complex.) Email replies appreciated, since I check email more often than news. Damian Menscher -- --==## Grad. student & Sys. Admin. @ U. Illinois at Urbana-Champaign ##==-- --==## www.uiuc.edu/~menscher/ Ofc:(217)333-0038 ##==-- --==## Physics Dept, 1110 W Green, Urbana IL 61801 Fax:(217)333-9819 ##==-- From uioziaremwpl at spammotel.com Wed Jun 27 15:08:50 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Wed, 27 Jun 2001 21:08:50 +0200 (CEST) Subject: PEP 260: simplify xrange() In-Reply-To: <3B3A1DC0.3583E9D8@ccvcorp.com> Message-ID: On Wed, 27 Jun 2001, Jeff Shannon wrote: [snip] > To make a long story short, the discussion regarding FP boils down to the > fact that "1.0" cannot be exactly represented in FP. Well, 1.0 *can* be represented exactly in floating point. Even 0.5. >>> 0.5 0.5 >>> 1.0 1.0 >>> 0.1 0.10000000000000001 >>> 438.9375 438.9375 >>> 438.937 438.93700000000001 >>> 438.9374 438.93740000000003 Now can think about the reason, why some real numbers can be represented exactly in FP, and some not. ;) Cheers, Carsten -- Carsten Geckeler From nhodgson at bigpond.net.au Tue Jun 19 22:16:39 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Wed, 20 Jun 2001 02:16:39 GMT Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: <73PX6.317$zE1.418988@news.uswest.net> <3B2FE2BD.F210FA8A@home.net> <3B2EA829.39DE6527@earthlink.net> Message-ID: Ron Stephens: > (from SourceForge) > > """A card file program (in the spirit of Apple's HyperCard) designed to > store and search thousands of cards > containing megabytes of > text. Uses gzip to compress text. Uses > superimposed coding > (signature file indexing) for fast > searching. Written in Python""" One of the most hyped aspects of HyperCard initially was its text searching feature which used content hints (I imagine a form of lossy/fuzzy hashed index) to allow fast searching in many cases without the storage overhead of complete indexing. Neil From kamikaze at kuoi.asui.uidaho.edu Sat Jun 2 13:41:09 2001 From: kamikaze at kuoi.asui.uidaho.edu (Mark 'Kamikaze' Hughes) Date: 2 Jun 2001 17:41:09 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> Message-ID: Sat, 2 Jun 2001 17:28:22 +0200 in <9fb0ju01a8a at enews2.newsguy.com>, Alex Martelli spake: > "David C. Ullrich" wrote in message > news:3b18ea18.332276 at nntp.sprynet.com... >> Probably "is in a state of sin" is not well-defined. > Presumably was meant as a humorous quip? IIRC, JVN wrote that in a paper on arithmetic methods of generating pseudo-random numbers, so the word you're grasping for is "ironic". >> I take the comment to mean that there is no "percect" >> arithmetical RNG. It seems extremely clear to me that >> there isn't, and I haven't heard anything that explains >> how Chaitin's work _does_ show that there exists >> a perfect arithemtical RNG. > I'm not sure what you mean by "perfect" (or "percect" -- > not sure if that was a typo, and if so, whether it was for > 'percept' or 'perfect'). If you mean one requiring an > infinite amount of information for prediction, A true random number generator is not one that requires an infinite amount of information to predict, it is one that is *impossible* to predict, regardless of how much information you have. Anything else is a pale substitute. You can have pseudo-random algorithms with varying degrees of randomness, but they are ultimately predictable. Now, if Chaitin's come up with a better PRNG, that's fine work, and could be very useful. But he's still "in a state of sin", because it isn't truly random. > Meanwhile I still see nothing 'sinful' in dealing with > randomness finitely, It's simple. If you have a pseudo-random number generator, you will eventually repeat, and other people, given the right information, can duplicate your random numbers. This is, to put it mildly, not a good thing (the word "catastrophic" comes to mind in crypto applications). -- Mark Hughes "I will tell you things that will make you laugh and uncomfortable and really fucking angry and that no one else is telling you. What I won't do is bullshit you. I'm here for the same thing you are. The Truth." -Transmetropolitan #39 From john.thai at dspfactory.com Thu Jun 7 11:09:30 2001 From: john.thai at dspfactory.com (John) Date: Thu, 7 Jun 2001 11:09:30 -0400 Subject: py2exe -i list Message-ID: Hi, What is the syntax for the -l option for py2exe? When I try : python setup.py py2exe -i "foo.lib.x" This works. But when I add another module like so: python setup.py py2exe -i "foo.lib.x, foo.lib.y" It complains that there is no module named foo.... Thanks, John From aahz at panix.com Mon Jun 18 10:05:36 2001 From: aahz at panix.com (Aahz Maruch) Date: 18 Jun 2001 07:05:36 -0700 Subject: locking dictionaries (was Re: New statement proposal for Python) References: Message-ID: <9gl1rg$p45$1@panix2.panix.com> In article , Tim Peters wrote: > >One concern: since dicts are crucial to Python's performance, we're loathe >to add any code to their critical paths, or more memory to the object. >Indeed, I spent a fair chunk of my life reducing the internal dict bloat >after 2.1 was released, and we got some nice speedups in return. OTOH, there's been some discussion of locking dicts during certain operations to prevent some ugly bugs and crashes. Given the amount of code simplification that would generate overall, would it maybe make sense to add an external interface to the locking mechanism? -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "It's not what you know, it's what you *think* you know." --Steve Martin From nas at python.ca Tue Jun 19 23:27:17 2001 From: nas at python.ca (Neil Schemenauer) Date: Tue, 19 Jun 2001 20:27:17 -0700 Subject: How do I access the last "un-caught" variable in the interpreter? In-Reply-To: <39503ed5.0106191912.5b054b42@posting.google.com>; from danielm@cronus.res.cmu.edu on Tue, Jun 19, 2001 at 08:12:16PM -0700 References: <39503ed5.0106191912.5b054b42@posting.google.com> Message-ID: <20010619202717.A15689@glacier.fnational.com> Dan Moskowitz wrote: > Pretty simple question: > > >>> 2+2 > 4 > >>> # can i access the 4 if i didn't catch it in a var? >>> _ 4 From bokr at accessone.com Fri Jun 15 18:59:28 2001 From: bokr at accessone.com (Bengt Richter) Date: Fri, 15 Jun 2001 22:59:28 GMT Subject: Any other Python flaws? References: <#72#QIT9AHA.262@cpmsnbbsa09> Message-ID: <3b2a7edd.586265184@wa.news.verio.net> On Thu, 14 Jun 2001 20:26:10 -0400, "Steve Holden" wrote: [...] >Despite the fact that our Fearless Leader and BDFL has already revered >himself once on this issue, I'd like to see strict syntactical equity >between function definitions and class definitions, which is to say that a >class with no superclasses should be declarable as: > > class myClass(): > pass Why not the other way around? I.e., drop the mandatory "()" for function defs with no args. A bare 'foo' could still evaluate to and foo() would do what it does now. You could consider '()'-less execution like Pascal, if you could define a reasonable "__"-ism to condition the definition of the function for that. I sort of like the idea of a symbol being able to yield a string transparently either by plain dereferencing or by having a function produce it, without any difference in the expression. Of course, you'd need some kind of quote function if you wanted to bind another symbol to the function object iself. From mlh at idi.ntnu.no Thu Jun 7 14:14:00 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Thu, 7 Jun 2001 20:14:00 +0200 Subject: Dictionary comprehension Message-ID: <9fog99$gis$1@tyfon.itea.ntnu.no> It seems to me that dictionary comprehension (in exactly the same style as list comprehension [1], and as proposed for set comprehension [2]) might be useful, and I wondered if anyone else agreed (and perhaps if work had already been done on this, or if it has already been discussed somewhere...) While list comprehension works like this [expr for var1 in seq1 for var2 in seq2 ... if bool] set comprehension will (if approved) work in the same manner, except with curly braces: {expr for var1 in seq1 for var2 in seq2 ... if bool} My suggestion for dictionary comprehension syntax is (IMO) obvious: {expr1:expr2 for var1 in seq1 for var2 in seq2 ... if bool} where expr1 is the key corresponding to expr2. Duplicate keys will overwrite earlier ones, the order being uniquely determined by the generator part (for var in seq ...). Any thoughts? Should a PEP be written, or is this just an Evil(tm) idea? If nothing else, it would give a simple solution to the frequently asked question "how to I invert a dictionary (with unique values)?": inverted = {dict[key]:key for key in dict} or possibly faster (I don't really know): inverted = {val:key for key, val in dict.iteritems()} (assuming that the new dictionary iteration syntax will make its way into 2.2...) [1] http://python.sourceforge.net/peps/pep-0202.html [2] http://python.sourceforge.net/peps/pep-0218.html -- Magnus Lie Hetland http://www.hetland.org "Reality is that which, when you stop believing in it, doesn't go away." -- Philip K. Dick From Randy.L.Kemp at motorola.com Thu Jun 7 12:04:18 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Thu, 7 Jun 2001 12:04:18 -0400 Subject: Windows editor? Message-ID: Thanks. I hope I didn't send the poor guy to one of those XXX entertainment sites by mistake. -----Original Message----- From: Keith Woeltje [mailto:kwoeltje at mail.mcg.edu] Sent: Thursday, June 07, 2001 10:04 AM To: python-list at python.org Subject: Re: Windows editor? actually the URL is http://www.ultraedit.com/ >K Kemp Randy-W18971 wrote: > Ultra Edit (www.ultra.com) with the macro extension developed for Python is > great, and only $30. You have to download the free Python, macro extension. > > -----Original Message----- > From: Wolfgang Lipp [mailto:castor at snafu.de] > Sent: Wednesday, June 06, 2001 6:36 PM > To: python-list at python.org > Subject: Re: Windows editor? > > > > > > >What's a good Python editor for programming under Windows, > specifically > > > > > >Windows 2000? According to Google archives it seems this question > > try www.textpad.com > > -wolf From eppstein at ics.uci.edu Fri Jun 15 15:00:45 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Fri, 15 Jun 2001 12:00:45 -0700 Subject: coroutines? Message-ID: I'm working on writing a prog (using W windowing in MacPython) that handles a list of items. For each item, it needs to open a dialog and gather some user information. So, the natural way to structure it is for each item in list: handle dialog I guess it would be possible to run that way in a separate application, by setting up a new instance of W every time, but that wouldn't allow me to reuse windows and wouldn't work well when running interactively in the IDE. Instead, what it looks like I would end up doing is to have a queue of list items sitting around somewhere, and (whenever the ok button of my dialog is pressed) go on to the next item and reset all the windowing objects. Which would work, but is logically upside-down. What I really want is coroutines. That way I could have my outer structure be for each item in list: set up dialog then coreturn to W while the "ok" button of the dialog would simply coreturn to this loop. The last time I was actually able to write a coroutine was 15 years ago when I was programming assembler. Most modern languages don't have them. Threads are not really an appropriate substitute. But I'm new to Python, and maybe it has something the other languages don't have. Is there a clean way to do coroutines in Python? -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From emile at fcfw.fenx.com Tue Jun 26 08:22:47 2001 From: emile at fcfw.fenx.com (Emile van Sebille) Date: 26 Jun 2001 07:22:47 -0500 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Jun 26) Message-ID: Guido announces the release of Python 2.0.1, a maintenance release with a revised license that is GPL compatible. http://groups.google.com/groups?ic=1&q=msgid:mailman.993230040.28120.python-list at python.org Andrew MacIntyre releases an OS/2 port of python 2.1. http://groups.google.com/groups?ic=1&q=msgid:mailman.992804846.18097.python-list at python.org Michael Stroeder releases web2ldap, a web-based generic LDAP client written in Python. http://groups.google.com/groups?ic=1&q=msgid:3B3517E0.9571A361 at stroeder.com David Beazley sparks discussion on function attributes when he announces PLY-1.0, a 100% Python implementation of the common parsing tools lex and yacc. http://groups.google.com/groups?ic=1&q=msgid:mailman.992921580.28727.clpa-moderators at python.org Markus Gritsch introduces VideoCapture, a Python extension for Win32 which makes it possible to access the video device. http://groups.google.com/groups?ic=1&q=msgid:mailman.992921580.28726.clpa-moderators at python.org Dave Cole announces Sybase module 0.26, which provides a Python Database API version 2.0 interface to the Sybase relational database system. http://groups.google.com/groups?ic=1&q=msgid:m33d8xkuvz.fsf at vole.object-craft.com.au Robin Becker release version 1.08 of the ReportLab toolkit, which now includes initial support for Mac OS 9. http://groups.google.com/groups?ic=1&q=msgid:oX4bSqA5yzL7Ew5m at jessikat.demon.co.uk Fred Drake issues updates of the 2.2 development version... http://groups.google.com/groups?ic=1&q=msgid:mailman.993236248.3156.python-list at python.org ...and the 2.1.1 maintenance version documentation. http://groups.google.com/groups?ic=1&q=msgid:mailman.993234922.2134.python-list at python.org Michel Pelletier has written the first in a series of articles on the Zope Object Database (ZODB). http://groups.google.com/groups?ic=1&q=msgid:mailman.992895416.23209.python-list at python.org David Goodger starts reStructuredText, a candidate markup syntax for the Python Docstring Processing System as per PEPs 256, 257 & 258. http://groups.google.com/groups?ic=1&q=msgid:B7558512.13268%25dgoodger at bigfoot.com Kevin Altis starts a mailing list to discuss creation of PythonCard. http://groups.google.com/groups?ic=1&q=msgid:qdVX6.1963$zE1.721339 at news.uswest.net Paul Prescod shows us where to find pyperl, a module that allows Perl code to be run from Python... http://www.cpan.org/modules/by-module/LWP/GAAS/pyperl-1.0.readme ... and Alex Martelli points us to Minotaur, which allows mixing Python, Perl and TCL. http://www.equi4.com/minotaur/minotaur.html Steve Majewski found that Microsoft's EULA for the Mobile Internet Toolkit Beta 2 restricts developers from distributing the software in conjunction with Potentially Viral Software. http://groups.google.com/groups?ic=1&q=msgid:mailman.993174742.10326.python-list at python.org It appeared the page referred to was quickly removed from Microsoft's site; then Alastair Burt re-found it. http://msdn.microsoft.com/downloads/eula_mit.htm The Vienna Python Interest Group (PIGgie) has just been formed this month. http://groups.google.com/groups?ic=1&th=1c92ecc5f025a11f,1 IBM devloperWorks has just published the second part of Uche Ogbuji's PyXPCOM article. Great quote: "Python is famous for making rapid development in Java actually possible, and PyXPCOM brings the same benefit to XPCOM." http://www-106.ibm.com/developerworks/components/library/co-pyxp2.html developerWorks is really digging Python these days. They've also published David Mertz's article on Python and XML: http://www-106.ibm.com/developerworks/xml/library/l-pxml.html?open&l=913,t=grx,p=xpyth Python's growth into the educational market continues. Eric Raymond spotted this endorsement from a university in the land down, under and a little to the left: http://it.mycareer.com.au/news/2001/06/05/FFX9ZT7UENC.html If your local college doesn't provide it then maybe you can get to Learning Tree's classes in Chicago during the next few hours (June 26): http://www.learningtree.com/us/ilt/courses/430.htm You may have heard that there is now an operating system for Lego (Lego Mindstorms LegOS). And there is even a Python module to talk to it. These aren't the inanimate blocks of our childhood! http://www.hare.demon.co.uk/lego/pylnp.html A new Python user proclaims that his relationship with Python has moved to a new level. There's a lot of love in this newsgroup . http://groups.google.com/groups?ic=1&th=8a31b51350a5fcc9,1 Pgnotify is still wet behind the ears (ver 0.1) but we're proud to announce it: "a PostgreSQL client-side asynchronous notification handler for Python." http://www.post1.com/home/ngps/pgnotify/ Python receives a lot of good press in an article on Slashdot asking about the next step beyond Visual Basic. While the questioner is eviscerated (Slashdot style), reviews of Python are positive: http://slashdot.org/comments.pl?sid=01%2F06%2F08%2F2140257 ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the daily python url http://www.pythonware.com/daily comp.lang.python.announce announces new Python software. Be sure to scan this newly-revitalized newsgroup at least weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Michael Hudson continues Andrew Kuchling's marvelous tradition of summarizing action on the python-dev mailing list once every other week. http://starship.python.net/crew/mwh/summaries/ http://www.amk.ca/python/dev The Vaults of Parnassus ambitiously collect Python resources http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ The Python Software Foundation has replaced the Python Consortium as an independent nexus of activity http://www.python.org/psf/ Cetus does much of the same http://www.cetus-links.de/oo_python.html Python FAQTS http://python.faqts.com/ 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 tricks of the trade: http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python&num=100 http://groups.google.com/groups?meta=site%3Dgroups%26group%3Dcomp.lang.python.* Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://groups.google.com/groups?oi=djq&as_q=+Python-URL!&as_ugroup=comp.lang.python Suggestions/corrections for next week's posting are always welcome. [http://www.egroups.com/list/python-url-leads/ is hibernating. Just e-mail us ideas directly.] To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From kbk at shore.net Wed Jun 6 20:25:13 2001 From: kbk at shore.net (Kurt B. Kaiser) Date: Thu, 07 Jun 2001 00:25:13 GMT Subject: floating point in 2.0 References: <3B1E50C9.7D2509F4@shore.net> <9flkoi$ofu$1@panix2.panix.com> <3B1E6A67.2B33C197@shore.net> <9fm9kg05qs@enews1.newsguy.com> Message-ID: <3B1EC916.C427EFF2@shore.net> Alex Martelli wrote: > I did most of my thesis work in APL (then had to redo it in Fortran > and Assembler, but that's another story) and used APL2 heavily > later (in IBM Research), and I recall those darned globals that > broke my routines when used in somebody else's workspaces as > the worst blights on an otherwise interesting language (if you > had the right terminal/keyboard/typewriter ball/&c:-). > > Alex balls, you say? I remember being hunched over an IBM 5100 (the first PC?) for months on end coding AR filters on semiconductors. The screen was about 3 inches by 4 inches, about 4 inches off the desk. But it really worked, was built like a tank, and was only about $15,000, as I recall... and APL worked like a charm for that application. Just don't let anyone mess with your globals =) But you know, an explict FUZZ brings the float comparison problem out in the open and promotes documentation. Now, if you are going to use floats as keys in a dict, heaven help you! Regards, KBK From maus at netz.klinik.uni-mainz.de Fri Jun 15 06:07:10 2001 From: maus at netz.klinik.uni-mainz.de (Christian Maus) Date: Fri, 15 Jun 2001 12:07:10 +0200 Subject: Problems with readlines() Message-ID: <9gcmt4$d28$1@bambi.zdv.Uni-Mainz.DE> hello there, i wrote a function readfile() which reads all lines in a file and stores them in an array. infile = open('/tmp/tacfile', 'r') array = infile.readlines() infile.close() return array the strange thing is, the more often I call this function, the lines read by it decrease, e.g I have a file containing 838 lines, i get 838 lines, then 738 lines, then 624 and so on... When I simply do cut and paste for this code in my program, everything works fine, only when I call it via it's functionname I get this strange effect. Any idea what the problem might be? best regards christian From com-nospam at ccraig.org Thu Jun 28 08:15:29 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 28 Jun 2001 08:15:29 -0400 Subject: C extension problem (Solaris) Message-ID: <874rt0hkbi.fsf@elbereth.ccraig.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I was working with the Rational.py that comes with Python trying to improve it's speed and I decided I could save quite a bit if I wrote it as a C extension (mainly because I was doing a couple hundred operations on long integers for each add, which could be done much faster if I didn't have to go through PyNumber_ each time). So I wrote (and am nearly finished with) a rational type available at http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/~checkout~/pythonic/crat/cratmodule.c?rev=1.12&content-type=text/plain (currently cvs only). Though I have used the C API before, this was my first attempt at defining a new type with it, and I had a problem. It works fine on my Linux/Intel box, but when I try to compile it on my Solaris 8 UltraSPARC box it has an item in the module dictionary that contains a non-working reference to the subtraction routine. I've looked over it and I didn't define anything as non-static, so I can't figure out where that reference came from. Any suggestions? - -- Christopher A. Craig "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Douglas Adams -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Processed by Mailcrypt 3.5.6 and Gnu Privacy Guard iEYEARECAAYFAjs7H9gACgkQjVztv3T8pzvktgCfREn2BkxskWmHKNVwZJudpUFY JvkAoKMxppjgn5KpkqwWILcNmJ/Gyo+w =AFF2 -----END PGP SIGNATURE----- From rnd at onego.ru Sun Jun 17 16:03:25 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 18 Jun 2001 00:03:25 +0400 (MSD) Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? In-Reply-To: Message-ID: On Sun, 17 Jun 2001, res04o20 wrote: >Hi y'all. I'm new here so bear with me. ;-) > >Now. Here's another way to go. Just use VB or some Office VBE with Forms2 >(or even Word fields or Excel cells) as your gui. The other great book I've >read, "Programming Python on Win32" shows you how to do it. It's not hard. >That's of course, if you have access to VB/Office and can stomach using it. >Some folks just refuse, and I can't blame 'em. 2 months ago I did a simple Visual Basic macro to search-replace and wow! it was so much fun to see how your screen is filled with trash (even though I switched screen refresh off), scroll-bar in convulsions, etc. It was also funny that converting my special markup into HTML+another markup by Python on Linux was 2 times faster than it takes MS Word to read HTML + convert another markup (mostly by search-replace regex)! (And what a pitiful regex MS Word has!!! I wonder, where have they took it.) Maybe, my approach was too direct, but I had enough "fun" to remember using MS Word in batch processing mode to guess how it feels in programmed interactive GUI mode... Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, June 17, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Tis better to have loved a short than to never have loved a tall." _/ From mstevens at firedrake.org Fri Jun 22 10:11:48 2001 From: mstevens at firedrake.org (Michael Stevens) Date: 22 Jun 2001 14:11:48 GMT Subject: Jython for Servlets References: Message-ID: On Thu, 21 Jun 2001 11:59:08 -0500, Michael Chermside wrote: >I would like to use Jython to write servlets in python and run them >on a java application server (WebLogic or one if its ilk). Seem like >this should be pretty easy to do... does anyone have a "hello world" >example I can work from? I wrote this a while ago playing with jython and servlets: import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import org.python.util.PythonInterpreter; import org.python.core.*; public class JythonServlet extends HttpServlet { protected void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); out.println("JythonServlet"); out.println("

JythonServlet

"); try { PythonInterpreter interp = new PythonInterpreter(); interp.exec("import sys"); interp.set("out", out); interp.exec("out.println('

the jython interpreter lives!

')"); interp.exec("ver = sys.version"); PyObject ver = interp.get("ver"); out.println("

The jython version is " + ver + "

"); } catch (PyException e) { out.println("Help! Python Exception"); } out.println("
"); out.close(); } protected void doPost (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { this.doGet(req, res); } public String getServletInfo() { return "Jython Servlet - Michael Stevens - michaels at iii.co.uk"; } } From cribeiro at mail.inet.com.br Fri Jun 8 23:51:57 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Sat, 09 Jun 2001 00:51:57 -0300 Subject: Python Shareware? In-Reply-To: References: Message-ID: <5.0.2.1.0.20010609005018.02639180@mail.inet.com.br> At 02:39 09/06/01 +0000, Will Ware wrote: >How does this relate to shareware? Publish an initial version for free and >place it in the public domain. Include with it the URL for your website and >an announcement that when you receive N hundred dollars in donations, you >will fix any reported bugs and add several new features. As you work on the >new features, periodically publish test output (not the code itself) as a >teaser for the new features. When you've received the N hundred dollars of >donations, publish the new code and place it in the public domain. Again >announce that you will fix any new bugs and add some more features for >some fixed total of donations. Repeat until you are fabulously wealthy. May we call your proposal "good-willware", instead of "shareware"? Sorry. Could not resist :-) Carlos Ribeiro From reageer.in.de.nieuwsgroep at onzin-adres.nl Sat Jun 9 05:36:15 2001 From: reageer.in.de.nieuwsgroep at onzin-adres.nl (Rene Pijlman) Date: Sat, 09 Jun 2001 11:36:15 +0200 Subject: Python/Zope vs. Java/JSP References: <9e7og6$utc$1@slb1.atl.mindspring.net> <9ebtpi$3k1$1@apollo.csd.net> <23891c90.0105230113.86063c9@posting.google.com> Message-ID: <3br3it8e2evmhqpsd4qn158rou3ov7nksg@4ax.com> paul at boddie.net (Paul Boddie) schreef: >For a long time, however, there weren't really any decent manuals - at >least not on product development. There are three new books coming up: http://www.amazon.com/exec/obidos/ASIN/0735711372/o/qid=992079065/sr=2-2/ref=aps_sr_b_1_2/104-6176306-8012743 http://www.amazon.com/exec/obidos/ASIN/1886411573/o/qid=992079065/sr=2-1/ref=aps_sr_b_1_1/104-6176306-8012743 http://www.amazon.com/exec/obidos/ASIN/0672321335/o/qid=992079065/sr=2-3/ref=aps_sr_b_1_3/104-6176306-8012743 The first one is also freely available on http://www.zope.org/Members/michel/ZB/ of course. Regards, Ren? Pijlman From emmanuel.astier at winwise.fr Wed Jun 27 09:26:34 2001 From: emmanuel.astier at winwise.fr (Emmanuel Astier) Date: Wed, 27 Jun 2001 13:26:34 GMT Subject: Python for Commercial Games? References: <9haoiv$jnv$1@mtc1.mtcnet.net> Message-ID: <3b39de57.103502578@news.iway.fr> On Tue, 26 Jun 2001 14:46:36 -0500, "Kevin Riggle" wrote: >I *do* realize that I'm posting to comp.lang.python , so please humor me >anyway... > >I am in process of designing a computer game; problem is, I want to at >least have a snowball's chance in Hades of selling the game. My question: >Would it be possible to write the dang thing in Python (PyWin), or is C/C++ >the better option in the Windows-centric world of game development right >now? Thanks in advance, > >Kevin > > Most (ALL ?) commercial games that use Python only use it as a script language. Most of the real code ( display, 3D, Ia ) is made in C/C++ for performance reasons. Python just use this code... It really depends on what your game looks like, but I don't think it is really possible now to write a full real commercial game in python without extend / embed it with C/C++. From thomas.heller at ion-tof.com Mon Jun 18 13:58:39 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Mon, 18 Jun 2001 19:58:39 +0200 Subject: why is there no class (static) methods in Python ? References: <3B2D114E.7B39D954@intraware.com> <3B2D6669.7DEFD13F@intraware.com> <3B2E31A6.9A5B378@intraware.com> Message-ID: <9glfdf$9fj2g$1@ID-59885.news.dfncis.de> > > > In fact, constructors (and destructors) are class methods, not instance > > methods, but they are handled specially in the language so they appear as > > instance methods.. > > > > No, constructors (at least as available in Python, C++, and Java), are really > > initialization methods, and thus instance methods. This is easily seen as they > > get an object as implicit argument. > > Yes, I agree that the concrete purpose of constructors is to initialize > instances. But more generally, and from a semantical point of view, calling a > constructor *creates* a new instance, even if the programmer gains control only > on the init part. Then I'd say that a constructor belongs to the class as well as > to the instance being created. Much confusion: Maybe we should carefully separate between the _creation_ of the instance, and _initialization_ of it. In current Python, the _creation_ is hidden in C, and you cannot override it. The _initialization_ is exposed as the __init__ method. The most useful pattern which has emerged from numerous discussions on the list is to hide the class itself in an instance of another class. This recipe can be refined, but basically it goes like this: class ClassMeta: class Instance: def __init__(self, ...): # initialize the new instance .... def inst_method(self): # an instance method def new(self, *args): # a class method acting as a constructor return self.Instance(arg1, arg2): def a_class_method(self, ...): # another class method .... Class = ClassMeta() Now you can use it in this way to invoke 'class methods': Class.a_class_method(spam) Create an instance: obj = Class.new(...) and invoke 'instance methods': obj.inst_method() Regards, Thomas From aleaxit at yahoo.com Fri Jun 29 10:40:47 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 29 Jun 2001 16:40:47 +0200 Subject: the center of the world (was Re: Check out O'Reilly's Open Source Convention Highlights) References: <3B3AA82D.1A0FE860@seebelow.org> <3B3B2DED.5303198A@seebelow.org> <9hhri7019jd@enews2.newsguy.com> Message-ID: <9hi42h01og2@enews2.newsguy.com> "Konrad Hinsen" wrote in message news:m33d8j8j2j.fsf at chinon.cnrs-orleans.fr... > markus at kepler.ibp.de writes: > > > Then find first the weighted average as a point in three-dimensional > > space, i.e. as (an approximation to) the center of gravity of the > > human population. This will be some point deep in the interior of the > > Earth, which you could the project back to the surface. > > But that doesn't minimize the distance on the surface. Doesn't it (in terms of great-circle distance)? I can't prove it in my head either way, but trying to visualize a few cases does suggest the requested surfacepoint IS obtained this way. > Actually, we should > minimize something even more pragmatic, such as travel cost, travel time, > or some weighted combination. You could presumably get enough data to estimate travel costs and time between any two large cities from databases available on the net. But then for pragmatism one should count frequent-flyer miles as a bonus, shouldn't one? Alex From emile at fenx.com Tue Jun 19 19:02:36 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 19 Jun 2001 16:02:36 -0700 Subject: How can I format the string according to its length at runtime? References: Message-ID: <9golt9$a47e8$1@ID-11957.news.dfncis.de> Does this do what you're looking for? >>> print "(0x%X)" % 123 (0x7B) >>> print "(0x%-6X)" % 123 (0x7B ) HTH -- Emile van Sebille emile at fenx.com --------- wrote in message news:mailman.992971110.11976.python-list at python.org... > How can I format the string but according to the length it has? > > I have the following code: > > l = 6 - len(str(values)) > printwrite(trcfile, "Rx value = %-5s (0x%-6X)- OK\n"%(str(values), > values),tag ) > > Currently I displays: > > Check : TPreason = 120 (0x78) Rx value = > 120 (0x78 )- OK > > function printwrite is just a wrapper function of sys.file.write and > print that prints the info to the screen, or a trace window and to a > file accordingly. The string formmating is he same as the python doc. > > values in the above code is a integer number. > The above statement tries to diplay the input string [ from str > (values ] and convert values to be displayed as hexadecimal. > > My problem is when it displayed in hexadecimal, there are extra > spacing because it of the statement 0x%-6X when the lengeth of values > is 3. But I will no know in advance what is the length of values, it > can reach 6. How can I dynmically alter the number of spaces in this > case? > > Thanks > > > > From tdelaney at avaya.com Wed Jun 13 23:31:25 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Thu, 14 Jun 2001 13:31:25 +1000 Subject: Python grammar.. Message-ID: > >> "Delaney, Timothy" wrote in message > >> news:mailman.992393599.3573.python-list at python.org... > >> ... > >> > way to do it - a subroutine may or may not return a value, at its > >> > discretion, and I should be able to ignore any returned value. > >> > >> Yes, but if I were designing a language today, I think I would > >> request you to be EXPLICIT about "ignoring the return value" -- > >> explicit is better than implicit. It IS an occasional cause of > >> errors in Python (particularly with newbies) that an expression > >> statement's value is silently and implicitly ignored... > >> > >> > >> Alex > > > >So you would prefer that functions whose return value is ignored must > > be called with a keyword ... such as in VB > > > > call aFunction() > > > >Personally, I absolutely hate this. > > Seems like you could do it the other way around...add a bit of > something to the function def to say "this is a procedure". Should > you actually want to do such a thing... (it may be the path to the > dark side, a la "static final private void deranged lunatic spam()" > ...) This goes back to my original argument, that there should be no distinctions between subroutines which return a value, and those that don't. We've had this before (see procedure and function in Pascal, sub and function in VB). I hate it. Python does the Right Thing (TM) IMO - one way of defining a subroutine, which may or may not (explicitly) return a value (all Python functions implicity return None if no other value is specified). The result of the subroutine call can be ignored. However, the most important thing is that whatever is correct in the language must be enforced. VB is particularly bad for this - calling a function with a single parameter as function a (b) end function a 1 ' OK a(1) ' memory leak but both are syntactically correct. To avoid the memory leak, you must do call a(1) A 2-parameter function (or sub) cannot even be called like that ... function b (a, c) end function b 1, 2 ' OK b(1, 2) ' syntax error call b(1, 2) ' OK VB is the most pathological case I can think off at the moment, and it serves as a good argument that there should be one and only one calling convention. Tim Delaney From altis at semi-retired.com Wed Jun 20 00:02:06 2001 From: altis at semi-retired.com (Kevin Altis) Date: Tue, 19 Jun 2001 21:02:06 -0700 Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: <3B2EADB0.9DBC6FC8@earthlink.net> <3B2EC98E.FE0F1B6E@earthlink.net> Message-ID: Well, I started a separate mailing list. http://groups.yahoo.com/group/pythoncard Joining the list is a relatively small hurdle, so hopefully a reasonable number of people will join and start discussing. I'll act as fearless leader until someone else wants the job or sets up a better area for discussion. I think this idea is at least worth taking through the early idea and design phases. If it still looks good and there is consensus on the direction then we can get started on coding. ka "Ron Stephens" wrote in message news:3B2EC98E.FE0F1B6E at earthlink.net... > Sigh, sounds like we got a lot of folks, of whom I am by far the worst, who > would love to contribute. I would think the hardest part would be to find a > couple of truly competent leaders, who are expert programmers, sort of our own > mini-Linus's or Guido's. The leaders could then moderate the "toolkit wars" and > make final decisions. > > My guess is it might be extraordinarily hard to find such leaders for an open > source project like this ;-(((((. > > One could only suggest Roman Suzi and Neil Hodgson since they were the first two > to mention HyperCard. (and it sounds like they know what they're talking about) > > Anyway, should anyone be foolish enough to reluctantly volunteer as fearless > leaders, it looks like they could expect lot of eager followers... > > Of course one would hope that some of the followers could actually produce good > code...;-))))) > > rs > > Neil Hodgson wrote: > > > Ron Stephens: > > > Of course, each person undoubtedly has a different set of concepts in mind > > > when he thinks of "PythonCard"..still, an intriguing amount of interest in > > 24 > > > hours... > > > > I'd like, at least initially, a fairly straight clone of HyperCard but > > with true colour graphics. While my other open-source activities don't leave > > much time for contributing, I'd be able to do a script editor / debugger. > > > > Is it time to have the toolkit war? > > > > How suitable would ZODB be as the persistence back end? > > > > Neil > > > > From phrxy at csv.warwick.ac.uk Mon Jun 4 11:50:21 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Mon, 4 Jun 2001 16:50:21 +0100 Subject: Python-GnuPlot : Plotting problems In-Reply-To: References: Message-ID: On 2 Jun 2001, Prem Rachakonda wrote: [...] > 1. I have a set of z values in a matrix of [5000,100] from which I > have to get the contour of a surface and the lenghts of x and y are > 5000 and 100. > If I try to plot by using the following function, I am not getting the > contour > > g.splot(Gnuplot.GridData(z,x,y, binary=0)) What *do* you get? And what do you mean by 'the' contour? You can set the number of contours (and probably the contour levels as well) by sending a command to Gnuplot directly, I think, if that's what you want: g("set cntrparam levels 10") # command sent directly to Gnuplot I'm not sure what your x and y are, but try: x = arange(z.shape[0]); y = arange(z.shape[1]) followed by the splot command you give above. > I tried to use only one set of values ie. The sizes of matrices are > given below > z[5000,1] > x[5000] > y[1] > > This gave me a perfect profile of the contour( It extends in the y > direction) > > When I went for 2 sets of values, ie. z[5000,2], x[5000], y[2] then I > get 4 plots of the contours > > 1st two plots are in the x-z plane (at y[1]), the first one from x[0] > to x[2500] and the other from x[2501] to x[5000] > > 2nd two plots are a mirror of the above 2 plots but at y[2] > > This is absolutely out of my understanding. Can someone explain why > this is happening. Hmm, this kind of thing is painful to describe in flat ASCII, isn't it? I'm not sure exactly what you're getting / expecting. > 2.Also how to issue command to Gnuplot. I want to change the view of a > plot and the Gnuplot's way it to say 'set view 90,0'.How to issue > command from Python to execute this command. g.("set view 90,0") John From mwh at python.net Thu Jun 28 05:13:25 2001 From: mwh at python.net (Michael Hudson) Date: 28 Jun 2001 10:13:25 +0100 Subject: PEP 260: simplify xrange() References: <3B39480C.F4808C1F@Lugoj.Com> <9hc97q$rpt$1@slb6.atl.mindspring.net> <3B3A9C39.64C3E1C6@seebelow.org> <9hef08$urt$1@slb3.atl.mindspring.net> Message-ID: "Andrew Dalke" writes: > Grant Griffin: > >BTW, among its many other technological advances, Goggle frees you from > >having to put "+" in front of stuff. > > Huh. Showing my heritage of using altavista for a couple years. > If I had read the top of the results page I would have seen > > ] Google always searches for pages containing all the words in your > ] query, so you do not need to use + in front of words Google confuses me; if you search for "michael hudson" my page is the third hit - but my name doesn't actually appear anywhere on the linked page! The "did you mean to search for ..." feature is also downright uncanny. They've clearly sold their souls to the devil - there's no other explanation. Cheers, M. -- 39. Re graphics: A picture is worth 10K words - but only those to describe the picture. Hardly any sets of 10K words can be adequately described with pictures. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From dvanpope at bookworm.suffolk.lib.ny.us Mon Jun 18 18:57:13 2001 From: dvanpope at bookworm.suffolk.lib.ny.us (VanPopering) Date: Mon, 18 Jun 2001 22:57:13 GMT Subject: Which IDE ? Message-ID: Which IDE would you recommend for someone *just starting out* with Python? -I'm not a professional programmer but Im interested in learning Python -I want to use opensource whenever possible -For now I'm just here for the basics; some scripting etc. I'd LOVE to use idle since its part of it and free, but I have heard that it freezes upand has other problems...is this really a problem that it happens a lot? Are there things I can do to avoid this - does it happen with larger more complex programs only? If it froze while running the script and that was the only potential problem, then I'd just save it first... I am wondering if these were copmplaints by professional programmers who needed and expected more... Komodo looks interesting, but I do admit it looks like a bit much for my purposes: I want to write, edit, debug, and run simple python thingys I hope I misunderstood what I had heard about Idle's short comings - *I dont know yet and thats why Im asking* (I wonder what Guido uses...) -David ______________________________________________________________________ David van Popering Running Linux I'm not sleeping, I'm checking my eyelids for holes. From threeseas at earthlink.net Sat Jun 16 18:03:03 2001 From: threeseas at earthlink.net (Timothy Rue) Date: Sat, 16 Jun 2001 22:03:03 GMT Subject: (LONG!) Re: Python version of IQ has been updates (IQ v0.34.python) References: <505.566T11T1243597threeseas@earthlink.net> <4a7fde99.0106150124.7376da0b@posting.google.com> Message-ID: <14187.567T2362T10775380threeseas@earthlink.net> On 15-Jun-01 04:24:40 Ryan wrote: >"Timothy Rue" wrote in message >news:<505.566T11T1243597threeseas at earthlink.net>... >> http://www.mindspring.com/~timrue/python/IQ.34.py >> >> Read the code header. >> >> http://www.mindspring.com/~timrue/python/python-IQ.html >> >> >> --- >> *3 S.E.A.S - Virtual Interaction Configuration (VIC) - VISION OF VISIONS!* >> *~ ~ ~ Advancing How we Perceive and Use the Tool of Computers!* >> Timothy Rue What's *DONE* in all we do? *AI PK OI IP OP SF IQ ID KE* >> Email @ mailto:timrue at mindspring.com >INPUT->(Processing)->OUTPUT>v >> Web @ http://www.mindspring.com/~timrue/ ^<--------<----9----<--------< >you might want to change line 85 to >if fromf in ('', '?', 'help', '-h', '-?'): Thanks for the tip. I do seem now to recall this method, but being a python rookie and lacking the time to spend enough time with python to drill it into my dreams....I'm bound to miss simple and basic things, such as this. >just a slight change with a negligable speed up, but slightly easier >to read. Alot easier! Thanks. >I'm just now trying to figure out the interface and figure out exactly >what it dose, if it's what I think it is I'll be more than happy to >help hack it (i'm hoping it is a small search engine type tool) Yes, IQ is a small search engine, stand alone but also a part of a larger project. The general difference with this search engine is that it follows the generic triplet of how we define things for looking up later. i.e. Unix manual pages can be tagged for 'word', 'sub' and 'file' and can even use different 'filekeys' (legends like a map or blue print) Look at the following AWK manual page. I've added keys here where ':' tags for 'word', '::' tags for 'subs' and ':::' tags for file. The CAPITALIZED words are original in the manual pages. But there is also where I have added other keys for words, subs and files (in small case). This further breaks down to more specific details of the awk man page, but to use it, you need to change the 'filekey' to 'filekey :: ;; :::' which allows you to access the finer details. But Unix manual pages are one of many other expample of how we use this triplet in defining and accessing information. Any Programming language quick reference can be tagged or even non programming information like catalog of parts or human language dictionaries or encylopedias, medical references, etc.. Like I said, it's the "generic triple of how we define things to later look up'. That's what the IQ search engine is about. And it's only one of nine things we do in anything we do. Nine actions/functions that I call "action constants". If you use the command line on the KNMVIC.iq file: '>python IQ.py -k KNMVIC.iq "*" "*" the result will appear to be a table of context of the KNMVIC document, so even on a larger scale of perception, IQ is handy. I hope all this help you to understand what the objective of IQ is. And that if used to output specific parts, such as code, the '-s' option is used to cause only the code or part to be output, without the word/sub/filename key. There is also the http://www.mindspring.com/~timrue/IQ.html file to read. -------->8------- filekey : :: ::: :AWK(1) AWK(1) ::NAME awk - pattern-directed scanning and processing language ::SYNOPSIS awk [ -F fs ] [ -v var=value ] [ 'prog' | -f progfile ] [ file ... ] ::DESCRIPTION Awk scans each input file for lines that match any of a set of patterns specified literally in prog or in one or more files specified as -f progfile. With each pattern there can be an associated action that will be performed when a line of a file matches the pattern. Each line is matched against the pattern portion of every pattern- action statement; the associated action is performed for each matched pattern. The file name means the standard input. Any file of the form var=value is treated as an assignment, not a filename, and is executed at the time it would have been opened if it were a filename. The option -v followed by var=value is an assignment to be done before prog is executed; any number of -v options may be present. The -F fs option defines the input field separa? tor to be the regular expression fs. An input line is normally made up of fields separated by white space. (This default can be changed by using the FS built-in variable or the -F fs option.) The fields are denoted $1, $2, ..., while $0 refers to the entire line. A pattern-action statement has the form pattern { action } A missing { action } means print the line; a missing pat? tern always matches. Pattern-action statements are sepa? rated by newlines or semicolons. ::statements An action is a sequence of statements. A statement can be one of the following: if( expression ) statement [ else statement ] while( expression ) statement for( expression ; expression ; expression ) statement for( var in array ) statement do statement while( expression ) break continue { [ statement ... ] } expression # commonly var = expression print [ expression-list ] [ > expression ] printf format [ , expression-list ] [ > expression ] return [ expression ] next # skip remaining patterns on this input line delete array[ expression ]# delete an array element exit [ expression ] # exit immediately; status is expression Statements are terminated by semicolons, newlines or right braces. An empty expression-list stands for $0. String constants are quoted " ", with the usual C escapes recog? nized within. Expressions take on string or numeric val? ues as appropriate, and are built using the operators + - * / % ^ (exponentiation), and concatenation (indicated by a blank). The operators ! ++ -- += -= *= /= %= ^= > >= < <= == != ?: are also available in expressions. Variables may be scalars, array elements (denoted x[i]) or fields. Variables are initialized to the null string. Array sub? scripts may be any string, not necessarily numeric; this allows for a form of associative memory. Multiple sub? scripts such as [i,j,k] are permitted; the constituents are concatenated, separated by the value of SUBSEP. The print statement prints its arguments on the standard output (or on a file if >file or >>file is present or on a pipe if |cmd is present), separated by the current output field separator, and terminated by the output record sepa? rator. file and cmd may be literal names or parenthesized expressions; identical string values in different state? ments denote the same open file. The printf statement formats its expression list according to the format (see printf(3)). The built-in function close(expr) closes the file or pipe expr. ::math The mathematical functions exp, log, sqrt, sin, cos, and atan2 are built in. Other built-in functions: ::built-ins ;;length length the length of its argument taken as a string, or of $0 if no argument. ;;rand rand random number on (0,1) ;;srand srand sets seed for rand and returns the previous seed. ;;int int truncates to an integer value ;;substr substr(s, m, n) the n-character substring of s that begins at posi? tion m counted from 1. ;;index index(s, t) the position in s where the string t occurs, or 0 if it does not. ;;match match(s, r) the position in s where the regular expression r occurs, or 0 if it does not. The variables RSTART and RLENGTH are set to the position and length of the matched string. ;;split split(s, a, fs) splits the string s into array elements a[1], a[2], ..., a[n], and returns n. The separation is done with the regular expression fs or with the field separator FS if fs is not given. ;;sub sub(r, t, s) substitutes t for the first occurrence of the regu? lar expression r in the string s. If s is not given, $0 is used. ;gsub gsub same as sub except that all occurrences of the reg? ular expression are replaced; sub and gsub return the number of replacements. ;;sprintf sprintf(fmt, expr, ... ) the string resulting from formatting expr ... according to the printf(3) format fmt ;;system system(cmd) executes cmd and returns its exit status The ``function'' getline sets $0 to the next input record from the current input file; getline 72 Print lines longer than 72 characters. { print $2, $1 } Print first two fields in opposite order. BEGIN { FS = ",[ \t]*|[ \t]+" } { print $2, $1 } Same, with input fields separated by comma and/or blanks and tabs. { s += $1 } END { print "sum is", s, " average is", s/NR } Add up first column, print sum and average. /start/, /stop/ Print all lines between start/stop pairs. BEGIN { # Simulate echo(1) for (i = 1; i < ARGC; i++) printf "%s ", ARGV[i] printf "\n" exit } ::SEE ALSO lex(1), sed(1) A. V. Aho, B. W. Kernighan, P. J. Weinberger, The AWK Pro? gramming Language, Addison-Wesley, 1988. :::lex.man :::sed.man ::BUGS There are no explicit conversions between numbers and strings. To force an expression to be treated as a number add 0 to it; to force it to be treated as a string con? catenate "" to it. The scope rules for variables in functions are a botch; the syntax is worse. ---------8<----------- --- *3 S.E.A.S - Virtual Interaction Configuration (VIC) - VISION OF VISIONS!* *~ ~ ~ Advancing How we Perceive and Use the Tool of Computers!* Timothy Rue What's *DONE* in all we do? *AI PK OI IP OP SF IQ ID KE* Email @ mailto:timrue at mindspring.com >INPUT->(Processing)->OUTPUT>v Web @ http://www.mindspring.com/~timrue/ ^<--------<----9----<--------< From asolis at mobilian.com Thu Jun 7 13:14:55 2001 From: asolis at mobilian.com (Adrian Solis) Date: Thu, 7 Jun 2001 10:14:55 -0700 Subject: Task isolation in Python? In-Reply-To: <871yow4549.fsf@penguin.aktivist.ru> Message-ID: Hi! I am writing a program to run test scripts, and I need to have tasks running sequentially. However, I'd like to ensure (to a reasonable degree) that if one task fails or takes too long, the others can still run. Is there a good way to do this in Python running in a Win2k environment (some monitoring software I have to use run only on that platform)? I'm thinking that if I spawn new processes and kill misbehaving ones, I'll be able to mostly acheive this goal, but Python's process control under Win2k is lacking. Has anyone run into this problem before? What could be possible solutions? Thank you! Adrian From garry at sage.att.com Tue Jun 26 13:18:31 2001 From: garry at sage.att.com (Garry Hodgson) Date: Tue, 26 Jun 2001 17:18:31 GMT Subject: newbie with major "lambda" problem (perhaps a scope problem as well) References: Message-ID: <3B38C3E7.A1F5C394@sage.att.com> Joe Potter wrote: > > On Tue, 26 Jun 2001 16:09:06 GMT, "Rainer Deyke" wrote: > > >"Joe Potter" wrote in message > >news:j5ahjtkfmf32lkqtap0q1u6rig385d7b5i at 4ax.com... > >> # the "button" below works like a champ !! > >> #Button(root, text='Fetch', > >> #command=(lambda v=vars: fetch(v))).pack(side=LEFT) > >> > >> # the "button" below does not do anything ?????? > >> Button(root, text='Fetch', command=(fetch(vars))).pack(side=LEFT) > > > >Of course this doesn't work. It calls 'fetch(vars)', and passes the result > >to 'Button'. Use the lambda, that's what it's there for. Or use one of the > >'curry' alternatives (see archives). > > My question is *why* the lambda is allowed to call the perfectly defined function > fetch, but a direct call of fetch is not. > > In other words --- I already knew that I had to use lambda, but I do not know why! lambda is a special kind of function. it creates, on the fly, another, un-named function, and returns that as its value (much like def, but def also binds the function to a name). so the first (commented out) case above sets command equal to a function, which will be called when the button is clicked. in the latter (non-working) case, you actually run your fetch function when this code is executed, and then bind whatever it returned to the command variable. when you later click your button, tkinter tries to use this value as a callback funtion, and will fail. i'm surprised you don't get an exception. --- Garry Hodgson sometimes we ride on your horses Senior Hacker sometimes we walk alone Software Innovation Services sometimes the songs that we hear AT&T Labs are just songs of our own garry at sage.att.com From greg at cosc.canterbury.ac.nz Tue Jun 26 20:02:47 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 27 Jun 2001 12:02:47 +1200 (NZST) Subject: Defining accessor methods In-Reply-To: Message-ID: <200106270002.MAA05093@s454.cosc.canterbury.ac.nz> Roman Suzi : > [=] ... b.width # is get > b.width = # is set > del b.width # is del But currently the only way of customising those incurs far too much overhead, particularly __setattr__ which incurs overhead for *every* attribute assignment, not just the ones you want to trap. I believe Guido has a scheme afoot to allow get/set methods to be defined for individual attributes, so this may change one day. But even then, I'd be reluctant to use it for everything. In my GUI library, many of the things I'm using set_xxx methods for have noticeable side effects, e.g. changing the size of a widget causes things to move on the screen. Hiding functionality like that behind what looks like an ordinary attribute assignment seems like a bad idea to me. So, I stand by my opinion that having methods called set_xxx is quite Pythonic, on the grounds that explicit is better than implicit. Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+ From whisper at oz.nospamnet Thu Jun 14 22:37:51 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 15 Jun 2001 02:37:51 GMT Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> Message-ID: <9gbsdv$8ft$9@216.39.170.247> In article , skip at pobox.com says... > > David> My proposal: > > David> alias httpport : 80 > ... > > Interesting idea. Why do you prefer ":" over "="? > > I prefer : to = because this isn't an assignment per se. It is not, imho, a departure from python usage: def fn(a,b,c): if something: for thing in things: etc. (in fact it occurs to me that at least the def statement is a form of alias where (argument) substition is done! At least conceptually the body of a function replaces it at invocation time.) Creating an inherent means of creating constants (or my preferred aliases) is good computer science as someone else mentioned in a reply post. Magic numbers are bad - they're sloppy programming and a source of errors if they must be used in several places etc. OTOH, aliases clarify program meaning and imho make things more comprensible to newbies. I think all would agree that "if something is true:" is clearer then "if something is not 0:". Likewise, "userpermissions" is much more meaningful then 0677 (or whatever - it's been too long since i've used unix heavily, but I think the point is clear). As for the distinction between const(ant) and alias: Perhaps it's a matter of aesthetics, but somehow alias is more descriptive then const since it suggests the substition that's happening. Further, it's incorrect to call "alias true: not 0" a constant imho. To further belabour (with a tip of the hat to the english cousins) the point, it read so nicely to be able to say "if something is true" rather then "if something is not 0" (saves on typing too :-)). Other suggestions to import large libraries or make modules instances are not things calculated to gladden the heart of a newbie who seeks simplicity, nor would the code enlargement (my aren't I diplomatic ;)) win the approval of an experienced developer who doesn't want to search exteraneous lines when a bug pops up - which is statistically more likely with more lines of code, not to mention the antics needed to do something that should be as simple as possible (imho). One can certainly argue that this is syntactical sugar. It does however serve a multitude of good purposes among which are: maintainability; clarity; consistancy; correctness; good programming habbits; - a not inconsiderable set of advantages for a little sugar. Finally, this wouldn't break any code, nor would anything (excepting perhaps peer pressure) force anyone to use it. Sincerely, Dave LeBlanc From loewis at informatik.hu-berlin.de Sat Jun 16 13:32:38 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 16 Jun 2001 19:32:38 +0200 Subject: Reference Counts & Extensions.. References: <6fvV6.248430$Z2.2868464@nnrp1.uunet.ca> Message-ID: "John" writes: > I'm writing an extension module and in my functions I return something > like: > > return Py_BuildValue("i", 1); > > Will this cause a memory leak? No, extension methods always return new references, so does Py_BuildValue. In this specific case, I'd recommend to use PyInt_FromLong, though; it's faster and says more directly what you want to return > Also, what if I make pyObj a global variable, can I then use the first > method since the reference will be borrowed, like so: > > return pyObj; No, you must Py_INCREF(pyObj). You cannot return borrowed references; the interpreter will decref your result when it is not longer needed, releasing your object. This will make pyObj an invalid pointer. Regards, Martin From chrishbarker at home.net Fri Jun 8 17:33:57 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 08 Jun 2001 14:33:57 -0700 Subject: How do you develop in Python? References: <050620011516094693%pecora@anvil.nrl.navy.mil> <9fjfer$gt0$1@nereid.worldonline.nl> <3B2129AC.90BA8650@home.net> <9frc6v$b20$1@nereid.worldonline.nl> Message-ID: <3B2144C5.7FA3C7C4@home.net> Gerrit Muller wrote: > I understand the problem from implementers point of view. Being a free softwaqre project, the implimenters are the users. As a rule, free software is very good when it is software for programmers, and not so good when it is for "naive" users. The general response form developers that I have gotten when asking for this feature is: "It would be a lot of work, adn I don't really need it, so I'm not going to do it. Feel free to work it out and contribute it yourself." I don't have the time or skills to do that, so until someone does that wants the feature, it won't happen. > Hunting for the CP4E vision requires thinking from > "naive" programmer point of view. Some brilliant idea appears to be > necessary to satisfy this need, without making the IDE's too complex. sure, but with no funding for CP4E, who's going to impliment them? > Thinking out loudly: For many naive users the automated stop/restart might > be fully acceptable, while it might also be simple to implement. It's not easy, because the IDE uses the saem interpreter. > Although, > how much unexpected state needs to be persistent, like open files and > windows; when would this same naive user start hating to see windows > disappear and reappear? May-be it is already too complex ). Yes, they would. Starting and re-starting the entire IDE really would be unacceptable. Gerrit, you and I are on the same page here, but for some reason, the ability to run a program "from scratch" doesn't seem to be important enough to the IDE developers for them to put the work into making it possible. I think that's because it is a lot of work. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From barry at digicool.com Wed Jun 20 18:13:00 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Wed, 20 Jun 2001 18:13:00 -0400 Subject: PEP 255: Simple Generators References: <9gnv2o$its$1@nntp6.u.washington.edu> Message-ID: <15153.8172.199565.119556@anthem.wooz.org> >>>>> "DB" == David Bolen writes: DB> But isn't a generator really just a function that is returning DB> an iterator? That is, why is it "very" different from a DB> function, internal implementation aside, which we agree it's DB> not necessary to reveal. They are very different because the body of a generator function defines the generator object's .next() method, but the def names the generator object's factory function. -Barry From cribeiro at mail.inet.com.br Wed Jun 20 21:41:52 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Wed, 20 Jun 2001 22:41:52 -0300 Subject: Anyone used Pippy? In-Reply-To: Message-ID: <5.0.2.1.0.20010620223911.026d64a0@mail.inet.com.br> I've installed Pippy on my Palm IIIxe some time ago. I found it to be a nice toy, just that, mainly because of how difficult is to download Python scripts into the Palm. As of now you have to build Pippy with the scripts you want to run, and this is not exactly easy to do. As someone else pointed out on the list today (on another topic), we're just too lazy - there must be a convenient way to make it. If I only had time... Carlos Ribeiro From quite at dial.pipex.com Thu Jun 21 04:16:53 2001 From: quite at dial.pipex.com (Aandi Inston) Date: Thu, 21 Jun 2001 08:16:53 GMT Subject: Interfacing GUI applications..? References: <3B18032E.21AF631E@pfortin.com> <3b312734.173247661@reading.news.pipex.net> <3B314622.1EB391F5@pfortin.com> Message-ID: <3b31ad12.207484109@reading.news.pipex.net> Pierre Fortin wrote: >> Why does this need scripting? Isn't this solvable in a supported way >> using FDF files? > >Say what...?! Are you suggesting I write code which generates hundreds of >values only to have to manually transcribe the results into a "fill-in" PDF >file...? If so... :^P Where did I say anything about "manually transcribe"? Perhaps you do not know how to open an FDF file in order to fill in a form. Or perhaps this does not work in *nix? ---------------------------------------- Aandi Inston quite at dial.pipex.com http://www.quite.com Please support usenet! Post replies and follow-ups, don't e-mail them. From cce at clarkevans.com Sat Jun 2 11:28:25 2001 From: cce at clarkevans.com (Clark C . Evans) Date: Sat, 2 Jun 2001 10:28:25 -0500 Subject: Inexact representation cases (Re: Against PEP 240) In-Reply-To: ; from tim.one@home.com on Thu, May 31, 2001 at 01:17:31AM -0400 References: <9f273c21ar5@enews2.newsguy.com> Message-ID: <20010602102825.A24372@doublegemini.com> On Thu, May 31, 2001 at 01:17:31AM -0400, Tim Peters wrote: | >>> 1.1 | 1.1000000000000001 | >>> 7.35 | 7.3499999999999996 What is the general pattern for these types of inexact represenatation? Clark From Bill.Scherer at VerizonWireless.com Wed Jun 20 14:14:50 2001 From: Bill.Scherer at VerizonWireless.com (Scherer, Bill) Date: Wed, 20 Jun 2001 14:14:50 -0400 (EDT) Subject: OOP in Python In-Reply-To: <4e2ddb70.0106200954.11faa218@posting.google.com> Message-ID: On 20 Jun 2001, Jonas Bengtsson wrote: > Ok I admit - I am a Python-newbie! > > What about local variables and class variables when dealing with > classes? > With local vars I mean temporaryly used variables in a function. Will > they be treated as 'normal' instance attributes? Do I have to delete > them by myself when I'm leaving a function? No, reference counting or garbage collection will take care of these for you. > With class vars I mean if many class instances of a class may share a > variable. In C++ this is accomplished by a static variable. How do I > do in Python? class spam: classVariable1 = "howdy y'all" classVariable2 = 22.7 def __init__(self): self.instanceVariable1 = time.time() All instances of spam will have the same (classVariable1, classvariable2). Each instance of spam will (generally) have a unique value for instanceVariable1. > > Thanks in advance, > Jonas B > William K. Scherer Sr. Member of Applications Staff - Verizon Wireless Bill.Scherer_at_VerizonWireless.com From see at my.signature Tue Jun 12 22:13:24 2001 From: see at my.signature (Greg Ewing) Date: Wed, 13 Jun 2001 14:13:24 +1200 Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> <3b266270$1_7@news5.uncensored-news.com> Message-ID: <3B26CC44.ABC71BDD@my.signature> Doug Fort wrote: > > If I need to communicate a number to you, my software agent or > PDA should convert it Loss of precision may occur - e.g. 0.1 (base 10) is not exactly representable in binary. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From chat at linuxsupreme.homeip.net Sat Jun 23 23:01:25 2001 From: chat at linuxsupreme.homeip.net (Chad Everett) Date: 23 Jun 2001 22:01:25 -0500 Subject: How useful do you find the interactive interpreter? References: <4688f24b.0106231658.43d2c446@posting.google.com> Message-ID: On 23 Jun 2001 17:58:18 -0700, slaytanic killer wrote: >Hi, > >I am looking at Python seriously, and I can see that the interpreter >would be really good for testing out ideas. Getting small things to >work and then switching over to a text editor to generalize what I've >learned. Is this how people generally use it? Or is it an even >deeper part of coding? > >Thanks. I am in the process of developing a command line interface that provides users a set of commands and an environment that allows them to "browse" scientific data files. The Python interpreter is an essential part of the application I'm developing. I have inherited the Cmd class and have overriden many of its methods in order to provide the command line interface to the user. I also give the users a way to exit the Cmd based parser and interact with the Python interpreter directly so that they can do their own Python scripting and manipulation of the data objects I've created which represent the data in the scientific data files. -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From bawolk at ucdavis.edu Sun Jun 3 15:34:23 2001 From: bawolk at ucdavis.edu (Bruce Wolk) Date: Sun, 03 Jun 2001 12:34:23 -0700 Subject: Python 2.1 dependencies References: <3B18151A.E95C4E4B@ucdavis.edu> <3B1A1EB9.C051301D@student.gu.edu.au> Message-ID: <3B1A913F.CB24619D@ucdavis.edu> Joal Heagney wrote: > Bruce Wolk wrote: > > > > On an RH 7.1 system I rebuilt the source RPMs for Python 2.1. But when > > I tried to install expat-1.1-3tummy.i386.rpm, I got the following error > > > > error: failed dependencies: > > libexpat.so.0 is needed by abiword-0.7.13-2 > > > > This is odd, since /usr/lib/libexpat.so.0 is present on my system, but > > also what does Python have to do with abiword? > > > > Bruce > > Abiword wants libexpat. That much I can figure out, but I'm still > confused how you got that message. If expat-*tummy replaces whatever > package libexpat.so.0 comes in but doesn't have libexpat.so.0 itself > you'll get that message. (Basically abiword is saying, "Hey, I still > need that.") Now I don't know why expat-tummy wants to overwrite > libexpat.so.0, that's what's got me confused. A listing of expat-tummy > only gives > > /usr/bin/xmlwf > /usr/include/expat/xmlparse.h > /usr/lib/libexpat.a > /usr/share/doc/expat-1.1 > /usr/share/doc/expat-1.1/expat.html > > Of course if you're really worried about this, you could always > uninstall abiword. > > Joal Heagney/AncientHart I decided to cross my fingers and install the rpms using "--nodeps " and so far everything seems to work fine, including abiword. Bruce From scarblac at pino.selwerd.nl Tue Jun 26 03:09:34 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 26 Jun 2001 07:09:34 GMT Subject: Should I use a dictionary? References: Message-ID: Gustaf Liljegren wrote in comp.lang.python: > I have an object type for e-mail messages based on the rfc822 module. After > picking out some messages from several sources, I want to sort them in > order of the date property of the message object (as far as I understand, > everything in this process needs to be kept in memory). Anyway, the problem > is that I need some hints about how to sort the messages, as they are not > sorted in way I get them. > > One idea I came up with was to put the date property of the message object > as a key in a dictionary, and let the rest of the message be the value! But > even if it would work, I think it's ugly. If someone can convince me that > it's not ugly, or give a better (i.e. faster) solution, I'd be happy. Although dictionaries are neat, I don't see how they would work here - you can't sort a dictionary, and two messages may have the same date. Often, if you want to sort things on some field, you want the "decorate, sort, undecorate" pattern (aka Schwartzian transform). In this case, if you have a list of messages, you want to change it into a list of (date, message) tuples, sort that, then change it back into a list of messages. Something like messages = [...] decorated = [ (get_date_in_seconds(message), message) for message in messages] decorated.sort() messages = [ part[1] for part in decorated ] -- Remco Gerlich From dsh8290 at rit.edu Fri Jun 1 15:39:39 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 1 Jun 2001 15:39:39 -0400 Subject: Iteration index In-Reply-To: <9f8pvv$7ss$1@panix3.panix.com>; from aahz@panix.com on Fri, Jun 01, 2001 at 12:21:35PM -0700 References: <9f63lo$rb0$1@zeus.polsl.gliwice.pl> <9f8pgk$11l6$1@agate.berkeley.edu> <9f8pvv$7ss$1@panix3.panix.com> Message-ID: <20010601153939.B7896@harmony.cs.rit.edu> On Fri, Jun 01, 2001 at 12:21:35PM -0700, Aahz Maruch wrote: | | Dunno whether it's in the docs, but retrieving a list element is | definitely O(1). Ok, so I'm wrong, the speed is better than I guessed :-). -D From claird at starbase.neosoft.com Thu Jun 21 11:43:01 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 21 Jun 2001 10:43:01 -0500 Subject: Standalone .exe's using installer/builder question References: <9gsld3$5n6$1@plutonium.btinternet.com> <90C76054Egmcmhypernetcom@199.171.54.155> Message-ID: In article <90C76054Egmcmhypernetcom at 199.171.54.155>, Gordon McMillan wrote: . . . >>C:\WINDOWS\Desktop\temp\Standalone.py test.py -tk >> >>anyideas??? > >Yes. Due to a Windows problem, you have to say: > >python C:\WINDOWS\Desktop\temp\Standalone.py test.py -tk >^^^^^^ > >or the command line args don't make it to Standalone.py. > >- Gordon Let me be sure I understand: it's not a "problem" in the sense that there is a fault specific to the installer or Python that anyone expects to change, right? Windows is *designed* in such a way that natural installations, in effect, discard command-line arguments--correct? Incidentally, I believe there's a tweak we can make to the Windows installation (basically, complexifying some of the data inserted in the Registry) to allow such shortcuts to work as those of us coming from Unix expect. I've never pursued it, out of fear for what could go wrong once we get intimate with the Registry. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From thomas at cbs.dtu.dk Wed Jun 13 15:50:32 2001 From: thomas at cbs.dtu.dk (Thomas Sicheritz-Ponten) Date: 13 Jun 2001 21:50:32 +0200 Subject: kmeans cluster analysis ? Message-ID: Hej, Before reinventing the wheel ... does anybody know of a python implementation of the kmeans cluster analysis or (preferable) bi-secting kmeans ? thx -thomas -- Sicheritz-Ponten Thomas, Ph.D CBS, Department of Biotechnology thomas at biopython.org The Technical University of Denmark CBS: +45 45 252489 Building 208, DK-2800 Lyngby Fax +45 45 931585 http://www.cbs.dtu.dk/thomas De Chelonian Mobile ... The Turtle Moves ... From paulp at ActiveState.com Thu Jun 28 18:33:00 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Thu, 28 Jun 2001 15:33:00 -0700 Subject: PEP: Support for "wide" Unicode characters Message-ID: <3B3BB09C.E686DF85@ActiveState.com> PEP: 261 Title: Support for "wide" Unicode characters Version: $Revision: 1.3 $ Author: paulp at activestate.com (Paul Prescod) Status: Draft Type: Standards Track Created: 27-Jun-2001 Python-Version: 2.2 Post-History: 27-Jun-2001, 28-Jun-2001 Abstract Python 2.1 unicode characters can have ordinals only up to 2**16 -1. These characters are known as Basic Multilinual Plane characters. There are now characters in Unicode that live on other "planes". The largest addressable character in Unicode has the ordinal 17 * 2**16 - 1 (0x10ffff). For readability, we will call this TOPCHAR and call characters in this range "wide characters". Glossary Character Used by itself, means the addressable units of a Python Unicode string. Code point If you imagine Unicode as a mapping from integers to characters, each integer represents a code point. Some are really used for characters. Some will someday be used for characters. Some are guaranteed never to be used for characters. Unicode character A code point defined in the Unicode standard whether it is already assigned or not. Identified by an integer. Code unit An integer representing a character in some encoding. Surrogate pair Two code units that represnt a single Unicode character. Proposed Solution One solution would be to merely increase the maximum ordinal to a larger value. Unfortunately the only straightforward implementation of this idea is to increase the character code unit to 4 bytes. This has the effect of doubling the size of most Unicode strings. In order to avoid imposing this cost on every user, Python 2.2 will allow 4-byte Unicode characters as a build-time option. Users can choose whether they care about wide characters or prefer to preserve memory. The 4-byte option is called "wide Py_UNICODE". The 2-byte option is called "narrow Py_UNICODE". Most things will behave identically in the wide and narrow worlds. * unichr(i) for 0 <= i < 2**16 (0x10000) always returns a length-one string. * unichr(i) for 2**16 <= i <= TOPCHAR will return a length-one string representing the character on wide Python builds. On narrow builds it will return ValueError. ISSUE: Python currently allows \U literals that cannot be represented as a single character. It generates two characters known as a "surrogate pair". Should this be disallowed on future narrow Python builds? ISSUE: Should Python allow the construction of characters that do not correspond to Unicode characters? Unassigned Unicode characters should obviously be legal (because they could be assigned at any time). But code points above TOPCHAR are guaranteed never to be used by Unicode. Should we allow access to them anyhow? * ord() is always the inverse of unichr() * There is an integer value in the sys module that describes the largest ordinal for a Unicode character on the current interpreter. sys.maxunicode is 2**16-1 (0xffff) on narrow builds of Python and TOPCHAR on wide builds. ISSUE: Should there be distinct constants for accessing TOPCHAR and the real upper bound for the domain of unichr (if they differ)? There has also been a suggestion of sys.unicodewith which can take the values 'wide' and 'narrow'. * codecs will be upgraded to support "wide characters" (represented directly in UCS-4, as surrogate pairs in UTF-16 and as multi-byte sequences in UTF-8). On narrow Python builds, the codecs will generate surrogate pairs, on wide Python builds they will generate a single character. This is the main part of the implementation left to be done. * there are no restrictions on constructing strings that use code points "reserved for surrogates" improperly. These are called "isolated surrogates". The codecs should disallow reading these but you could construct them using string literals or unichr(). unichr() is not restricted to values less than either TOPCHAR nor sys.maxunicode. Implementation There is a new (experimental) define: #define PY_UNICODE_SIZE 2 There is a new configure options: --enable-unicode=ucs2 configures a narrow Py_UNICODE, and uses wchar_t if it fits --enable-unicode=ucs4 configures a wide Py_UNICODE, and uses whchar_t if it fits --enable-unicode same as "=ucs2" The intention is that --disable-unicode, or --enable-unicode=no removes the Unicode type altogether; this is not yet implemented. Notes This PEP does NOT imply that people using Unicode need to use a 4-byte encoding. It only allows them to do so. For example, ASCII is still a legitimate (7-bit) Unicode-encoding. Rationale for Surrogate Creation Behaviour Python currently supports the construction of a surrogate pair for a large unicode literal character escape sequence. This is basically designed as a simple way to construct "wide characters" even in a narrow Python build. ISSUE: surrogates can be created this way but the user still needs to be careful about slicing, indexing, printing etc. Another option is to remove knowledge of surrogates from everything other than the codecs. Rejected Suggestions There were two primary solutions that were rejected. The first was more or less the status-quo. We could officially say that Python characters represent UTF-16 code units and require programmers to implement wide characters in their application logic. This is a heavy burden because emulating 32-bit characters is likely to be very inefficient if it is coded entirely in Python. Plus these abstracted pseudo-strings would not be legal as input to the regular expression engine. The other class of solution is to use some efficient storage internally but present an abstraction of wide characters to the programmer. Any of these would require a much more complex implementation than the accepted solution. For instance consider the impact on the regular expression engine. In theory, we could move to this implementation in the future without breaking Python code. A future Python could "emulate" wide Python semantics on narrow Python. Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil End: From skip at pobox.com Fri Jun 8 12:01:31 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 8 Jun 2001 11:01:31 -0500 Subject: gc issues In-Reply-To: References: <655abd4a.0106080504.66a9d6a0@posting.google.com> Message-ID: <15136.63195.486799.400475@beluga.mojam.com> Lothar> But Python has no GC, it has reference counting ... Cyclic garbage collecting of containers (lists, tuples, dicts, etc) was introduced in 2.0. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From phrxy at csv.warwick.ac.uk Wed Jun 6 07:32:32 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Wed, 6 Jun 2001 12:32:32 +0100 Subject: Plotting Surfaces with GnuPlot-Python?? In-Reply-To: References: Message-ID: On 5 Jun 2001, Prem Rachakonda wrote: > Hi, > I have a problem in plotting contours/surfaces. The problem > description is as follows: [...] > I have the above matrix z of size [100,5000], each value representing > the height in z-axis(5000 points in x multiplied by 100 scans in y) > > I have three matrices now, x[5000], and y[100] and z[100,5000] > > And I would like to plot the contour(surface) with this x,y,z data. > > My python code goes like this:(Only a part of it is displayed here) > [...] To be honest, I don't want to try and debug your program remotely: please try and reduce your problem to something simple (and preferably illustrate it with a program that doesn't have lots of 'magic numbers' in it). Please cut and paste rather than than typing it in by hand, too. Can you get a simple surface plot with the couple of lines of code I posted two days ago? John From barry at digicool.com Mon Jun 25 16:37:51 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Mon, 25 Jun 2001 16:37:51 -0400 Subject: Is this a mimetools/rfc822 bug? References: Message-ID: <15159.41247.812177.613322@anthem.wooz.org> >>>>> "SK" == Sheila King writes: SK> So far as I know, leading newline characters are not allowed SK> in the header. A newline character indicates the end of the SK> headers. Correct, and rfc822 is fairly strict about what it accepts. Leading empty lines in the text will toggle it over from "reading-headers" mode to "reading-body" mode. It's even worse if you have no headers, but your first body line has a colon in it! Moral: massage and normalize your text before feeding it to rfc822. -Barry From aleaxit at yahoo.com Thu Jun 14 07:15:13 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 13:15:13 +0200 Subject: Office's Access XP ODBC DBI from PythonWin References: Message-ID: <9ga6cd02m44@enews1.newsguy.com> "Steve Holden" wrote in message news:OJj8WlH9AHA.185 at cpmsnbbsa07... ... > Has the Win32 odbc module been updated at all since 2.0? I have a feeling > you might find it less than satisfactory for extended use - I've certainly > had problems myself. Hmmm, I did send you my partially-fixed version, yes...? > Unfortunately the dbi.dbiDate object has a null __doc__,but I notice the > dbi.py module requires mx.DateTime. Had you considered using mx.ODBC instead > of ODBC? If you don't plan commercial use it is free, and I can certainly > recommend it for ease of use. Seconded. But a minimally-working free odbc would still be a good thing IMHO. Say I write utilities to be internally used here at work (commercial use by mx's terms). As long as I run them on Windows only, I'm OK -- I can program to ADO and connect that to whatever DB engine. But -- no funds for mxODBC for that use. So -- no running my utilities on Linux boxes. Notch one more black mark discouraging this spread of Linux boxes around here:-(. Alex From jussij at zeusedit.com Thu Jun 28 18:39:07 2001 From: jussij at zeusedit.com (Jussi Jumppanen) Date: Fri, 29 Jun 2001 08:39:07 +1000 Subject: ANN: Free SCC-CVS Version Control Interface Message-ID: <3B3BB20B.7514@zeusedit.com> Zeus SCC-CVS for Windows Version 1.10 ===================================== The Zeus SCC-CVS is new release of the "free of charge" SCC plug-in for the Concurrent Versions System (CVS) version control system. The installer for this package can be downloaded from the following web page: http://www.zeusedit.com/archives/scccvs.html The package also includes a HTML tutorial that explains how to setup the Zeus SCC-CVS to work with local or remote CVS projects. IMPORTANT NOTE! =============== The Zeus SCC-CVS software package has been specifically designed to work with the Zeus for Windows programmer's editor: http://www.zeusedit.com but since the Zeus SCC-CVS is a full implementation of the Microsoft SCC interface, the software should in work with any IDE that supports the SCC interface. NOTE: This version has also only been tested and found to work with the Zeus and Codewrite editors. Jussi Jumppanen xidicone at iname.com From aleaxit at yahoo.com Tue Jun 12 18:23:46 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 13 Jun 2001 00:23:46 +0200 Subject: New guy question References: <3B255439.DFD33F59@home.net> <9g4ik305pa@enews2.newsguy.com> Message-ID: <9g64uv1j8j@enews1.newsguy.com> "D-Man" wrote in message news:mailman.992364979.25779.python-list at python.org... ... > Some dinosaurs aren't all that old ;-). I don't think the shell on > NT/2000 is any better, except maybe the screen drawing is less buggy > (helps for bash, vim, less, man, mutt, etc.). Oh come on, we just went over this -- would you rather have: C:\> peep 2>err.txt run peep with stderr redirection, a la NT, or run peep with stdout redirected and an argument of 2, a la 95/98, for example...?! And how can a shell where you can run foo.py directly "not be any better" than one where you just *can't* extend the range of executable extensions? Again, NT is the former, 95/98 the latter. Specifically, cmd.exe in one case, command.com in the other. And don't let me get started about how the *consoles* (not strictly a shell problem, but that's where you run shells) behave for copy and paste in the two systems, etc, etc... !!! bash may well be better than either, but that's no excuse for ignoring the large differences between them. And they're all in NT/cmd.exe's favor... Alex From peter at engcorp.com Sun Jun 17 14:52:47 2001 From: peter at engcorp.com (Peter Hansen) Date: Sun, 17 Jun 2001 14:52:47 -0400 Subject: Python-list: the list with everything! References: <9gdmil$61k$1@newshost.accu.uu.nl> Message-ID: <3B2CFC7F.FCFF286@engcorp.com> Martijn Faassen wrote: > > Bill Bell wrote: > > > Gotta love this list. > > > Brain teasers. Friendly discussion. Intellectual diversion. ... and > > tips about newly available porno sites. > > And conspiracies! Don't forget about the conspiracies, like the PSU's plan > to send a I don't understand why you always insist on writing the acronym in full like that. Isn't it obvious that when you do, their scanners are going to flag the message and they'll be able to cut you off? After they cut off my net-access several months ago, I've spent a lot of time thinking about this. I've come up with what I think is a fool-proof way to prevent the pee ess you from censoring our posts. What you need to do is described in my page at http://www. From brian at rk-speed-rugby.dk Thu Jun 14 02:43:49 2001 From: brian at rk-speed-rugby.dk (Brian Elmegaard) Date: Thu, 14 Jun 2001 08:43:49 +0200 Subject: History substitution on dos Message-ID: <3B285D25.3D9B9851@rk-speed-rugby.dk> Hi, (I think) I have been through the faq, but I can't find out how to make use of the command history when running python interactively from a dos-prompt. Can it be used? -- Brian (remove the sport for mail) http://www.et.dtu.dk http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug \TeX, tak From paulp at ActiveState.com Fri Jun 29 19:12:17 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 29 Jun 2001 16:12:17 -0700 Subject: Not enough Python library development [was PEP scepticism] References: <3dy9qalxii.fsf@ute.cnri.reston.va.us> Message-ID: <3B3D0B51.7F458525@ActiveState.com> Andrew Kuchling wrote: > > Roman Suzi writes: > > CPyAN is much more complex task, because there are: > > > > - security considerations > > - integration with distutils > > - probably, one day python will allow the "import" shown above > > (I even think it is already possible) > > - dependency resolution framework... > > Not necessarily. An annoying habit of the Python community is to > write an initial requirement list that's so forbiddingly long that > everyone is frightened away and nothing is ever implemented. But you > don't have to implement everything to have something useful. Case in > point: Parnassus, which does exactly 0 of the above 4 items, yet it's > definitely not useless. I agree. We've decided at ActiveState to try and push the penny ahead a few inches by the O'Reilly Open Source conference. We're working on a minimalist repository that can evolve into the repository of our dreams. It isn't a trivial job but we can at least leverage some of our existing security infrastructure, proficiency with Zope, etc. One good example of what our web team has put together is here: http://aspn.activestate.com/ASPN/Python/Mail I find these archives to be better than other Python archives available on the Web. Consider this feature: http://aspn.activestate.com/ASPN/Mail/Leaders/python-dev/ We hope to do the same thing with module repositories. We'd also like to integrate some of the security, commenting, rating and reviewing features from the Python cookbook: http://aspn.activestate.com/ASPN/Cookbook/Python But this is mostly a spare-time project because it is not product -- so I don't want to lift expectations too high...we're doing what we can do just like any other contributors to open source. Nevertheless, I have high hopes that we can plant the seeds and the community will help us harvest. I'm holding a BOF on the topic at the O'Reilly conference (just like at the last Python conference) and we'll share our progress and see what other people are up to. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From quango at watervalley.net Fri Jun 29 20:19:09 2001 From: quango at watervalley.net (Chris Lawrence) Date: Sat, 30 Jun 2001 00:19:09 GMT Subject: getopts confusion References: Message-ID: <20010629.191845.971899228.5270@watervalley.net> In article , "Rob Brown-Bayliss" wrote: > On 29 Jun 2001 08:13:50 -0400, Steve Holden wrote: >> > Error on option -s: unknown option. >> > Run './gearbox.py --help' to see a full list of available command >> > line options. > > I have checked indentation, it's fine. > > >> I conclude that the getopt code is working correctly, but your >> application is somehow failing to test for the options. >> >> Hope this helps. > > Yes, some. I played around some more, and the app that fails has a GUI, > the other is a command line app. There is a single import I do (from > gnome.ui import *) that stuffs it up, if the getopt stuff comes before > this import I don't get that error, if I cut and paste the getops till > after this import I get the above error. > > Does any one know why? IIRC gnome.ui does some options processing when it is imported (actually the GNOME libraries do it). This may be the cause of the problem you're having. I dunno if there's any way to get around it. Chris From mwright at pro-ns.net Tue Jun 5 15:30:58 2001 From: mwright at pro-ns.net (Mark Wright) Date: 5 Jun 2001 12:30:58 -0700 Subject: How do I return binary data from a python CGI called from CGIHTTPServer? References: <9f96kb01mq8@enews1.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:<9f96kb01mq8 at enews1.newsguy.com>... > "Mark Wright" wrote in message > news:f9ff3f62.0106011427.6243e5e9 at posting.google.com... > ... > > But my original problem/question remains: how does a CGI program > > return binary data on windows? Is it even possible? The problem is > > python.exe must be run with option -u, to have binary standard input > and output streams, rather than text ones as it has by default. > > > Alex This works correctly for 0x0a, but it still gets upset about 0x1a - a.k.a. ctrl-Z, a.k.a. end of file. If there's a ctrl-z in the output of my CGI script CGIHTTPServer truncates the data. At this point, I've given up using the standard CGIHTTPServer. I've created a modified version that runs python scripts inline, rather than forking (well, popening - I'm on Win2k) a new process and piping the output back to the client. Problem solved. Still, others out there must be returning binary data from a CGI script on NT/2000, right? How are they doing it? Mark From tdelaney at avaya.com Tue Jun 12 20:52:02 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Wed, 13 Jun 2001 10:52:02 +1000 Subject: Python grammar.. Message-ID: > deprecating parens as argument grouping operators is one > thing i'd love > to see happen in Python! And postfix (only!) ++ and -- and > .... and .... > aond of course implied self! > > Regards, > > Dave LeBlanc I don't often say things like this but ... If you want this, use another language, or write your own. Just don't call it Python (or anything close). One of the *worst* things I have ever come across (in VB of course) was "sometimes you have to call functions with parentheses, sometimes you don't, and if you call it with parentheses incorrectly, you get a memory leak. For function/method/procedure calling, there should be one and only one way to do it, and it must be unambiguous. Oh - and the distinction between a "function" and a "sub/procedure" has always annoyed the hell out of me. I way to do it - a subroutine may or may not return a value, at its discretion, and I should be able to ignore any returned value. I also dislike increment and decrement operators - the only times I use them in C/C++ is when I'm doing something idiomatic, such as while (*(str++)) { } at all other times I use += and -=. It looks better, is more versatile (what happens when I want to change from +1 to +2?) and doesn't suffer from side effects. Tim Delaney From dnew at san.rr.com Mon Jun 4 12:37:48 2001 From: dnew at san.rr.com (Darren New) Date: Mon, 04 Jun 2001 16:37:48 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> <3B1A82DD.C4D78472@san.rr.com> <9fe2g302841@enews2.newsguy.com> <3B1AE07F.CEDA4A3A@san.rr.com> <3b1b98fa.4361196@nntp.sprynet.com> Message-ID: <3B1BB95E.2C1DEC9@san.rr.com> "David C. Ullrich" wrote: > >Sure. *I* can write an algorithm to calculate the bits of Omega. > > If I have the "definition" of Omega straight actually you can't. > (If an "algorithm" is required to halt, which is part of "my" > definition...) Well, yes. I figured from context that the obvious implication was there: If *you* can write an algorithm to calculate bits of Omega, then so can I. The assumption was that he had a deterministic computer calculating Omega somehow, yet that I couldn't do the same calculation. Of course, if he can't calculate bits of Omega, then Omega is a pretty poor random number generator, as you've been saying. :-) -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. This is top-quality raw fish, the Rolls-Rice of Sushi! From whisper at oz.nospamnet Thu Jun 14 12:23:58 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 14 Jun 2001 16:23:58 GMT Subject: Tkinter GUI Designer References: <8yRV6.2345$9r1.347361@e3500-atl1.usenetserver.com> <3B27EF9D.54ED6BB9@bt.com> Message-ID: <9gaoeu$8ft$8@216.39.170.247> In article <3B27EF9D.54ED6BB9 at bt.com>, alan.gauld at bt.com says... > Michael Davis wrote: > > > > I've found several GUI Designers for wxPython, but where are the TK > > Interface builders? > > Try SpecTcl with specPy add in. > Obsolete but functional. > > Its the only one I know of but the good news is that the > documentation is very good, albeit in Tcl/Tk... > > Alan g > Visual Tcl (http://sourceforge.net/projects/vtcl/) isn't python-aware, but it does do a decent job of laying out Tk widgets etc. Dave LeBlanc From aleaxit at yahoo.com Mon Jun 18 12:05:43 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 18 Jun 2001 18:05:43 +0200 Subject: nested classes References: <3B2E2D3A.75F329D@sympatico.ca> Message-ID: <9gl8sn09sc@enews2.newsguy.com> "Stefan Seefeld" wrote in message news:3B2E2D3A.75F329D at sympatico.ca... > hi there, > > I'd like to provide a hierarchy of config data by means of > nested classes and static variables, such as: > > class A: > prefix='usr/local' > class B: > datadir = A.prefix + '/share' > ... > > however, I get a NameError: name 'A' is not defined class-object A does not yet exist (and thus in particular its name is not yet bound to it) until its classbody has _finished_ executing. You could do something like: class A: prefix = '/usr/local' class B: pass # or whatever... B.datadir = prefix + '/share' Alex From apost at cbmi.upmc.edu Mon Jun 25 13:48:55 2001 From: apost at cbmi.upmc.edu (Andrew Post) Date: Mon, 25 Jun 2001 13:48:55 -0400 Subject: How to determine if something is hashable? Message-ID: <3B377987.4010304@cbmi.upmc.edu> Hello, I want to write a function that takes a list of keys and a list of values and returns a hash. I want to test, however, that all of the items in the list of keys are hashable. How do I do this? The only way that I've come up with so far is to do: try: myDict[ keyList[ i ] ] = valList[ i ] except (TypeError): print keyList[ i ], 'is not hashable' TypeError isn't specific to finding a non-hashable key, though, right? Thanks, Andrew Post From tim.one at home.com Sat Jun 16 02:52:01 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 16 Jun 2001 02:52:01 -0400 Subject: sorting values in dict In-Reply-To: <3b2ab4dc.600088671@wa.news.verio.net> Message-ID: [Victor Muslin] > This may not be the shortest or most efficient, but it does the trick: > > a={'a':9,'b':8,'c':7} > l=[] > for k,v in a.items(): > l.append((v,k)) > l.sort() > for v,k in l: > print v,k [Bengt Richter] > Nobody seems to be doing it my way: That's because they've been brainwashed . > def sortedItemsOfDir(d,dir='a'): #'d'escending else default > if dir=='d': > def cmpi(x,y): #descending > if x[1]>y[1]: return -1 > if x[1] return 0 Note that hard tab characters display differently in different news and mail readers, so it's better to stick to spaces for posted code. With that out of the way, note that cmpi is easier written: def cmpi(x, y): return cmp(y[1], x[1]) That is, you're simulating "by hand" what cmp() does for you; no need. > else: > def cmpi(x,y): #descending > if x[1]>y[1]: return 1 > if x[1] return 0 Likewise: def cmpi(x, y): return cmp(x[1], y[1]) You probably shouldn't have a "#descending" comment on both . > items = d.items() > items.sort(cmpi) > return items The reason people don't *usually* post this kind of solution is fear of sloth: the compare function will get called about N*log2(N) times, and calling a Python function that often is expensive. The decorator pattern (building a list of tuples, sorting that directly, then undecorating) takes O(N) operations on each end to decorate and undecorate, but as N grows large that's insignificant compared to the N*log2(N) Python-level calls saved during the sort. Tuple comparison proceeds at C speed, and a Python function call is typically much more expensive than a comparison. That said, I pass functions to list.sort() all the time -- but, when I do, I'm very careful not to complain to myself about the speed . speed-is-for-speeders-ly y'rs - tim From cyboy20x at usa.net Tue Jun 5 11:46:20 2001 From: cyboy20x at usa.net (CyForce) Date: Tue, 5 Jun 2001 17:46:20 +0200 Subject: Free Downloads, Wallpapers, Games, Eroticgames, Handy-Logos and much more Message-ID: <9fiunl$u0c$15792@riker.addcom.de> Hello, on www.cyload.de.vu you get Free Downloads, Free Eroticgames Free Wallpapers Free Handy-Logos Free Applications and much more Enjoy Your CyForce _____________________________________________________________ This message posted with trial version of Express News Poster From tim.one at home.com Fri Jun 1 16:06:39 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 1 Jun 2001 16:06:39 -0400 Subject: Sourceforge break-in and Python 2.1 security In-Reply-To: <200106011547.AA2156593690@mail.mamey.com> Message-ID: [Andres Corrada-Emmanuel > I've been reading the reports of the break-in into SourceForge with > increasing alarm and I'm wondering if there is a security protocol in > place that guarantees the integrity of the Python code being developed > there. Yes, with the US$500,000.00 seed money kindly contributed by the community, we hired a battalion of guards to watch each byte 'round the clock . > That is, should I worry that "Fluffy Bunny" claims that he broke into > SourceForge 5 months ago and I downloaded Python 2.1 after that? "Can", sure, "should" depends on whether you want a life. Any effective change to the source code would have shown up on each developer's machine at their next update, and most of us pay attention to which files have changed. So even without particular effort, chances are good someone would have caught a bogus change. Someone clever and knowledgable about Python internals, who watched the Python checkin-list for a ripe opportunity, could have snuck in a change related to a recent checkin that would escape casual notice or even superficial scrutiny. But that would take some work and nobody would be impressed -- on ego-bang for the buck, cracking Python is a no-payback game. "kewl!-i-cracked-a-system-with-no-security-at-all!"-ly y'rs - tim From glyph at twistedmatrix.com Sat Jun 9 20:07:26 2001 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: Sat, 9 Jun 2001 19:07:26 -0500 (CDT) Subject: Learning OOP... In-Reply-To: <9ftk3h$i7m$1@newshost.accu.uu.nl> Message-ID: On 9 Jun 2001, Martijn Faassen wrote: > Rod Weston wrote: > > The reasons I feel a need to learn OOP languages are as follows: > > > 3. I want to reuse code as much as possible. > > While OO techniques can help here, don't expect anywhere close to a silver > bullet. Creating reusable code is *hard*. Furthermore, I'd say that creating reusable code is *wrong*. To clarify: if code is "usable", that implies that it is a standalone piece of software which does something that you want to use. Is libjpeg software reuse? Probably not classified as such, but simple C programs like that get a lot more "re-use" than their entangled, more OO counterparts, precisely because of their simplicity. One of the things I like the most about python is the first-class treatment of modules. A module is a far more important unit for useage than an object. (I do wish that Python had better support for packages; syntax support for swalow in Py3k, anyone? :)). If you plan to produce assets which can be used again on a software project, *separate them out into a separate project*. Then dependencies are clearly maintained, and responsability for the code remains where it should be. Most OO "reuse" involves copying huge blobs of code between projects, eventually evolving massive, poorly understood, and subtly incompatible subsystems on multiple projects. Keep your systems small and have them communicate clearly and sparsely over encapsulation boundaries, and your code will be useful for years; and you'll never have to re-cycle it. Insofar as OO helps, it is because OO has a simple and relatively universal metaphor for communicating between programs written with vastly different design assumptions, even in different languages: message sending between objects. However, OO also has the notion of inheritance, which is a *huge* impediment to reuse between projects (but can be useful for other things). Also, some systems which claim to be "OO" also have static typing, which partially negates the value of sending messages. > > 5. I want strong and flexible data typing - I know it sounds like an > > oxymoron. I want the typing to be especially powerful (restrictive) > > but I want to be able to define the constraints of the types myself. > > This isn't the case for Python. Python is flexible and powerful but doesn't > do constraints very well. :) We like it that way. A language like Java or > Ada or (perhaps especially) Eiffel is better suited for that. This is also, IMHO, against the spirit of object orientation. Smalltalk, frequently regarded as the "one true" OO language, has pure dynamic typing, and relies upon that for many of the advantages ascribed to OO. Provable correctness requires type validation and compile-time checkable assertions (preconditions and postconditions) but I don't believe those have anything to do with object orientation. Certainly, provable correctness and static typing are at odds with reuse, since they make your software more resistant to change. > > 11. I want good quality but free or inexpensive tools - especially a > > validated compiler to properly optimize my code for the task at hand > > and catch as many errors as possible at compile time. > > Python doesn't do any of this, except that it's completely free and excellent > quality. I've worked with C++ which does attempt to do the catching of errors > at compile time and optimization, and you see which newsgroup I'm posting > in. :) Ada or Java or C++ would help for those things. > (or say, Ocaml) Do you know the rules for software optimization? 1: Don't do it. 2: (For experts only!!) Don't do it *yet*. The easiest way to have a responsive, efficient program is to prototype and prototype and prototype in a flexible, "slow" language, until you've got the fastest possible high-level algorythm, then optimize for constant factors by pushing the slow code into a "fast" language. Transliterating well-understood python into C is a relatively easy task and can give you immense benefits; changing the structure of a huge C program to be more efficient is complex and difficult to get right. > > Not all the objectives relate to OOP, but most do. > Just remember: OO is far from a silver bullet! Especially the whole 'reuse' > advantage has been overdone in the beginning years. Also try to form for yourself a clear definition of what "OOP" is. Many of these things are conventions which some OOP languages tend to follow, but may or may not be a core part of what "OOP" is. You seem to have a pretty clear idea of your objectives; but I'd recommend taking a look at the eXtreme programming books for a differing perspective on software engineering. ______ __ __ _____ _ _ | ____ | \_/ |_____] |_____| |_____| |_____ | | | | @ t w i s t e d m a t r i x . c o m http://twistedmatrix.com/users/glyph From carlf at panix.com Sat Jun 23 11:34:56 2001 From: carlf at panix.com (Carl Fink) Date: 23 Jun 2001 15:34:56 GMT Subject: Is this a true statement? References: <3b34939b.410758@nntp.sprynet.com> Message-ID: In article , Chris Gonnerman wrote: > Writing TO a device driver is easy enough... the previous poster > was talking about writing the DRIVER in Python. No OS I'm aware > of takes device drivers in any languages other than assembler, C, > and/or C++. He's making a very finicky, nitpicking, and frankly silly point: the device driver is a sequence of bytes. You can write that sequence of bytes *directly as machine code* from Python, in the sense that you can have a Python program that would create a valid device driver file by opening it, writing those bytes to it, and closing it. Essentially he's deliberately misunderstanding what "write" means, using the "write to a file" meaning instead of "create a new program" meaning. -- Carl Fink carlf at dm.net From sasha at spuni.is Fri Jun 1 11:12:25 2001 From: sasha at spuni.is (Sasa Zivkov) Date: Fri, 1 Jun 2001 15:12:25 -0000 Subject: join does not call __str__ In-Reply-To: <15127.43981.921007.235051@anthem.wooz.org> Message-ID: >>> class A: ... def __str__(self): ... return "str-a" ... >>> a = A() >>> print a str-a >>> b = ['c', 'd', a] >>> "".join(b) Traceback (most recent call last): File "", line 1, in ? TypeError: sequence item 2: expected string, instance found Somehow I expected that join method would use __str__ method to convert instance to string... Your opinion ? -- Sasa From sill at optonline.net Wed Jun 13 17:31:39 2001 From: sill at optonline.net (Rainy) Date: Wed, 13 Jun 2001 21:31:39 GMT Subject: humans and logic References: Message-ID: On Wed, 13 Jun 2001 10:53:00 +0200 (MET DST), Eugene Leitl wrote: > On Tue, 12 Jun 2001, Rainy wrote: > >> >> Try writing 1,388,034,093 in binary on a piece of paper >> > 101,0010,1011,1011,1011,1000,0010,1101-ly y'rs -- Jan >> >> That's much more unweildy, isn't it? > > It's not the representation, it's the operation. Try adding these things > manually, or, worse, multiplying, or dividing them. Lots of little bitsys > to keep track of. Is that because we aren't accustomed to binary or something inherently wrong with it? > > If you want it compact, or succinct, that's what octal or hex is for. > Decimal needs not apply, because you can't just take three or four groups > of bits, and convert them back and forth via lookups. How's decimal less compact or succinct than octal? I can see why hex would be, but 32-mal is more so. And you have to append 0x to unambiguate hex. I imagine how teaching math in 1st grade would be, kids, 0x1 + 0x1 = 0x2 :-) > > And of course the question is not for people using the numbers daily > (though binary should be the first number system taught in school), but > for digital hardware (hint: it's called digital for a reason. No, it > hasn't got fingers, guess again). The original poster seemed to imply he wants everybody using it for all purposes. If it's not for daily use why teach it in schools? Even people who are actively employed in programming rarely if ever need binary or hex representations (excluding drivers and OS programmers, of course). Isn't that why we have compilers, they go and translate something that almost looks like normal human language into gory machine details? ;-) > > -- Eugen* Leitl > ______________________________________________________________ > ICBMTO : N48 10'07'' E011 33'53'' http://www.lrz.de/~ui22204 > 57F9CFD3: ED90 0433 EB74 E4A9 537F CFF5 86E7 629B 57F9 CFD3 > > -- Jupiter and Saturn Oberon Miranda And Titania Neptune Titan Stars can frighten - Syd From aleaxit at yahoo.com Fri Jun 1 04:11:10 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 1 Jun 2001 10:11:10 +0200 Subject: Obsolesence of <> References: <3B17787F.266644CB@student.gu.edu.au> Message-ID: <9f7imv01muo@enews1.newsguy.com> wrote in message news:3B17787F.266644CB at student.gu.edu.au... > > > "Alex Martelli" wrote: > > | Sorry, you're behind the times: ... > > | TypeError: cannot compare complex numbers using <, <=, >, >= > > I haven't checked the PEP's (I'm down to 4 h on my uni network account, > so I'm being conservative), but I'd hasard a guess this is because > there's several ways to compare complex numbers. 5 + 8j is obviously Quite likely, and it's very Pythonic for the language to REFUSE to guess in an ambiguous situation. But my point was that, EXACTLY because, as Lulu explained, <> is reminiscent of < and/or >, it's hard to maintain that <> should continue to apply where neither < nor > now do anymore:-). Alex From amardeep at tct.hut.fi Sat Jun 23 06:03:07 2001 From: amardeep at tct.hut.fi (Amardeep Singh) Date: Sat, 23 Jun 2001 13:03:07 +0300 (EET DST) Subject: emacs speedbar for python mode? In-Reply-To: <9h1h0f$9kh$1@news1.xs4all.nl> Message-ID: try M-x speedbar On 23 Jun 2001, Boudewijn Rempt wrote: > I've learnt to use XEmacs for Python programming - mostly because > I had to use it to write docbook source for my book on PyQt. However, > when editing Java with Xemacs I have a handy speedbar - file and > class browser in one. Is there something comparable for the Python > mode? > > -- ------------------------------------------------------------- amardeep singh iit guwahati iamamardeep at yahoo.com From bsass at freenet.edmonton.ab.ca Fri Jun 29 17:04:49 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Fri, 29 Jun 2001 15:04:49 -0600 (MDT) Subject: Not enough Python library development [was PEP scepticism] In-Reply-To: Message-ID: On Sat, 30 Jun 2001, Roman Suzi wrote: <...> > CPyAN is much more complex task, because there are: > > - security considerations > - integration with distutils Don't forget (at least considering the issues surrounding) integration with something like... http://packages.debian.org/unstable/admin/auto-apt.html - Bruce From rhystucker at rhystucker.fsnet.co.uk Wed Jun 6 15:11:03 2001 From: rhystucker at rhystucker.fsnet.co.uk (rhys) Date: Wed, 06 Jun 2001 20:11:03 +0100 Subject: How to change Pythonwin background colour? Message-ID: <3B1E8047.17E114FC@rhystucker.fsnet.co.uk> I need to change Pythonwin's background colour from bright white. I've managed to change a lot of it through the colour configuration options but not the interactive window. regards, rhys From sill at optonline.net Sun Jun 17 00:21:49 2001 From: sill at optonline.net (Rainy) Date: Sun, 17 Jun 2001 04:21:49 GMT Subject: pair programming, vim? References: Message-ID: On Sat, 16 Jun 2001 07:25:59 GMT, Courageous wrote: > >>Did anyone try pair programming over the net? In particular, is it possible >>to set up vim with a shared buffer or, failing that, some other editor? > > I believe that this isn't possible, although I could be mistaken. If you > *do* happen to find a multi-user text editor (multiple cursors, perhaps) > on windows, please let me know. This would be useful to have around. > Although network latencies can lead to some... ah, wierd... outcomes, > yes. The company I work for years ago had a product like this for Unix. > It was called "Slate". > > C// > Well, i was thinking more like one person codes, while another *looks* at the buffer and they have a query window through irc to talk. In that scenario latency isn't a big deal, I guess. That doesn't sound too hard to implement, i can't believe it hasn't been done to vim. -- Delay not, Caesar. Read it instantly. -- Shakespeare, "Julius Caesar" 3,1 Here is a letter, read it at your leisure. -- Shakespeare, "Merchant of Venice" 5,1 [Quoted in "VMS Internals and Data Structures", V4.4, when referring to I/O system services.] From aleaxit at yahoo.com Thu Jun 7 12:20:23 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 7 Jun 2001 18:20:23 +0200 Subject: random References: <3b1cf00f.5441109@nntp.sprynet.com> <3b1e4957.3040319@nntp.sprynet.com> <9flkqc01nfp@enews2.newsguy.com> <3b1f97ca.4530449@nntp.sprynet.com> Message-ID: <9fo9k50gl6@enews2.newsguy.com> "David C. Ullrich" wrote in message news:3b1f97ca.4530449 at nntp.sprynet.com... ... > >I think a Universal Turing Machine should by definition > >accept programs of infinite length. > > I don't think that it should. It's supposed to be able to > "emulate" an arbitrary TM. It takes only finitely much > space to define a given TM - I don't see any _reason_ > to use infintely much space to hold finitely much data. I did find a different definition from the Stanford one, that did include the condition "there can be only finitely many non-blank squares on the tape" (presumably, although that wasn't clear to me from that definition, this means at the START of a run -- if the machine doesn't halt it may still be allowed to fill the tape with infinitely many non-blank squares eventually -- but I did not see this stated unambiguously one way or another). Not all the definitions I've found strewn around include this provision, and it does make a huge difference of course. Alex From reageer.in at de.nieuwsgroep Mon Jun 11 17:44:46 2001 From: reageer.in at de.nieuwsgroep (Rene Pijlman) Date: Mon, 11 Jun 2001 23:44:46 +0200 Subject: Newbie References: <20010611151900.11318.00004174@ng-mp1.aol.com> Message-ID: justsurfn2004 at aol.com (Justsurfn2004) schreef: >Can anyone reccommend any websites for me to go to on how to use it? http://www.python.org/doc/current/tut/tut.html -- Vriendelijke groet, Ren? Pijlman Wat wil jij leren? http://www.leren.nl/ From rnd at onego.ru Fri Jun 29 16:29:58 2001 From: rnd at onego.ru (Roman Suzi) Date: Sat, 30 Jun 2001 00:29:58 +0400 (MSD) Subject: Not enough Python library development [was PEP scepticism] In-Reply-To: Message-ID: On Fri, 29 Jun 2001, Guido van Rossum wrote: >Roman Suzi writes: > >> Is there a formal TODO list of the libraries and respective priorities? > >No, although there's a PEP for small feature requests (PEP 42). > >If you want to start making a list of missing libraries and submit a >PEP, please do! I'm sure many people will want to contribute. Python could have better CPAN than CPAN by having non-existent modules included ;-) import cpan.load.non_existent will cause "NotImplemented" exceptions ;-) I think, for having TODO list is sufficient to have Wiki somewhere and a preamble which says what is this about and there will be lots of suggestions... CPyAN is much more complex task, because there are: - security considerations - integration with distutils - probably, one day python will allow the "import" shown above (I even think it is already possible) - dependency resolution framework... Oh... It's already put on catalog-SIG. >> For example, I think that some sort of standard GUI could help Python to >> fight Java with it's Swing/AWT... > >This was tried many times -- there was even a GUI-sig with this goal. >Well, propose one. But what exactly is the point of adding it to the >standard library when you can get mxDateTime if you need it? I'd say >your energy is better spent on reviving the catalog-sig (Python's >CPAN-like effort, which needs new energy!) catalog-sig is dead? Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Friday, June 29, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "I failed attitude in school." _/ From aleaxit at yahoo.com Thu Jun 14 15:21:14 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 21:21:14 +0200 Subject: weird behavior wrapping global functions into classes References: <0cahit44sql68p8pd2qgt59f600neha687@4ax.com> <9gah5j02v9@enews1.newsguy.com> Message-ID: <9gb2ra0quv@enews1.newsguy.com> "Les Schaffer" wrote in message news:ofohitsq7c4u4jitvoltev8pp5ctnvmule at 4ax.com... > On Thu, 14 Jun 2001 16:19:26 +0200, "Alex Martelli" > wrote: > > >Whenever a function is accessed as an attribute of a class or > ^ > |___ python coded Yes, an object of function type (as opposed to builtin-function-type, or any other callable). > >instance (and in the latter case, it's found in the class and > >not in the instance itself), it's transmuted into a method > >(unbound and bound, respectively). > > > $$!!@(*!#(#!!@!@!!@ > what the ?????!!!!! > sssssssssssssssssss....ssss......s.... > > > how come the built-in open doesnt get transmuted but shelve.open does? just > because its not "python-coded"??? Because it's a different type. D:\py21>python Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. Alternative ReadLine 1.4 -- Copyright 2001, Chris Gonnerman >>> type(open) >>> import shelve >>> type(shelve.open) See? shelve.open is of type 'function'. __builtin__.open is of type 'builtin_function_or_method'. Only objects of type 'function' (i.e., functions in the proper sense, in Python terms) are subject to the transformation. All other kinds of callable objects (including builtin_function_or_method's, instances with a __call__ special method, classes, bound and unbound methods, and other types you can code in extensions) aren't. > your Callable thingy looks okay, but if its that easy, some such thing > should be built right into Python so this issue is crystal clear and I agree -- it should be. But if I so propose, I'll be told "go write a PEP". Given it's about 5 lines of code, I'd feel silly if I had to write 50 lines of PEP justifying it (and I've never seen a PEP as short as just 50 lines:-), so I don't think I'll ever propose it. > upfront/outfront. i never asked for dbopen to be a class method, or so i > thought, yet i get hammered in an inconsistent way (built-in open: good, > python-coded shelve.open: bad). The rule is pretty consistent -- function, gets transformed, anything else, doesn't. Erroneously considering other callables 'functions' is a very understandable confusion of course (I think the docs are guilty of that too -- often they talk of 'a function' where actually they MEAN 'any callable'). The magic transformation, btw, does have its usefulness -- that is how EVERY method of a Python instance or class is treated, and it makes it easy to add methods to classes outside of the class's body (not a frequent need, but...). > anyway, .... thanks, alex.... You're welcome! Alex From rdsteph at earthlink.net Thu Jun 21 18:08:54 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Thu, 21 Jun 2001 22:08:54 GMT Subject: My PyGUI (Re: ANN: PythonCard mailing list) References: <3B31931E.D2F54D78@cosc.canterbury.ac.nz> Message-ID: <3B31214D.CBB01D44@earthlink.net> Could you please post this at http://groups.yahoo.com/group/pythoncard whre there is a lively discussion on PythonCard ongoing? Would you mind if I post a link??? Greg Ewing wrote: > You might be interested in looking at a project I > started on a while ago to create an almost-pure-python > GUI library: > > http://www.cosc.canterbury.ac.nz/~greg/python_gui/ > > I haven't worked on it for a while, but there's > actually a more recent version of the implementation > available than the one for downloading from that > page. If anyone is interested I can update the > download links. > > -- > Greg Ewing, Computer Science Dept, University of Canterbury, > Christchurch, New Zealand > To get my email address, please visit my web page: > http://www.cosc.canterbury.ac.nz/~greg From twofingersalute at atl.mediaone.net Tue Jun 12 20:30:53 2001 From: twofingersalute at atl.mediaone.net (myself) Date: Wed, 13 Jun 2001 00:30:53 GMT Subject: tummy compile Mandrake 7.2 References: <20010608.214013.1469262009.16325@K7.atl.mediaone.net> <20010609.104451.1884661237.1229@K7.atl.mediaone.net> <3B24154E.C70211ED@student.gu.edu.au> <20010610.232821.1789366143.1225@K7.atl.mediaone.net> <3B25F742.F4E25C37@student.gu.edu.au> Message-ID: <20010612.203418.76065818.14030@K7.atl.mediaone.net> In article <3B25F742.F4E25C37 at student.gu.edu.au>, "Joal Heagney" wrote: > myself wrote: > hey Joal, I hate to break it to ya, but YOU'RE DA MAN!! I never would have figured all that out, and certainly would never have proceeded to the rpm -bb stage after what looked like a total failure of the rpm -bi. So far it looks good, but even if it turns out things aren't exactly right, I learned a lot, and could go back in and try again. A few notes- used python2-2.1-5.src.rpm- changelog looked ok, so why not; along the way installed openssl & -devel-0.9.6-7, expat & -devel-1.95.1-3, and libgmp3-3.11-3, all mdk.i586.rpm, mostly cooker IIRC, no dep. probs. w/ any. Line #'s were different in spec file, but your instructions were clear enough that it didn't matter. from reprtest: 122 tests OK. 1 test failed: test_socket ("already in use"). 14 tests skipped: test_al test_bsddb test_cd test_cl test_dbm test_dl test_gl test_idev test_sundry test_winreg test_winsound which is vast improvement- as user I previously had more skips and crashes on some imp't ones like _builtin_ and _types_! many thanks! and to the group- in most other ng's, there are always folks whose purpose in life seems to be ridiculing the newbie (and other lost souls). That almost never happens here; I've only posted in two threads, and already given you guys ample opportunity. Thank you for your civility and patience. ps- do toilets *really* flush clockwise in the land downunder? From uioziaremwpl at spammotel.com Sat Jun 23 03:21:56 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Sat, 23 Jun 2001 09:21:56 +0200 (CEST) Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: On Fri, 22 Jun 2001, Tim Peters wrote: > [Carsten Geckeler] > > ... > > I just wanted to point out that "calling a class" (i.e. creating an > > instance by calling class(args)) also returns an object, but that this > > is of course not a reason to define it with "def", because the way the > > definition is evaluated and what is returned is completly different as > > how a function definition is evaluated (as you pointed out). And the > > same with generators. > > If you're only interested in the first 100 nanoseconds of a generator's > life, that's true . But when you write a generator, or analyze a > generator, or think about a generator, or step thru a generator in a > debugger (etc), they're just resumable functions; much like class methods > are just functions with a magical first argument. We spell class methods > with "def" to emphasize the similarities; ditto for generators. That > doesn't mean differences don't exist, but that the similarities are so deep > that harping on the differences is more distracting than helpful. I think we came to the core point. It seems that some people have exactly the other oppinion, i.e. that the differences how a generator is evaluated and used is so different that a different "def" line would be helpful for many people. Could you tell me, how e.g. a "generator" statement would be distracting? I can't see how a more clearifying statement could possibly distract people. The changed use of "def" in class definitions is clear for me, because all the method "def"s are inside of a `class definition scope'. I've problems that the generator "def" changes behaviour (and that quite heavily in my oppinion, because they don't return what they `should', i.e. what is written in the "return" statements) in `normal scope' just by any occurence of a "yield" statement, even if it's buried somewhere in the suite. Cheers, Carsten -- Carsten Geckeler From dsh8290 at rit.edu Sat Jun 9 22:03:37 2001 From: dsh8290 at rit.edu (D-Man) Date: Sat, 9 Jun 2001 22:03:37 -0400 Subject: New guy question In-Reply-To: ; from Glen.Mettler@home.com on Sat, Jun 09, 2001 at 11:28:51PM +0000 References: Message-ID: <20010609220337.B21681@harmony.cs.rit.edu> On Sat, Jun 09, 2001 at 11:28:51PM +0000, Glen Mettler wrote: | I have a small script I entered from a Python book that works when I run it | using F5. | However, when I go to the console and enter python alook.py, I get an error | message: | | >>> python alook.py | SyntaxError: invalid syntax | | I am too new to this to know why. As Alex indicated, it is not a problem with understanding python. I have seen that "new" Wintel-PC users often don't know what a shell is. A "shell" is a prompt provided by the OS to enter commands. On "Wintel" boxes it used to be called DOS. Now it is either called "MS-DOS Prompt" or "Command Prompt" and can be found under the Start menu. On a Unix system their are many different shells, and the shell is the first thing you will learn. A shell is where you would type things like "cd" "copy" "del", etc. There you can type "python alook.py" (assuming alook.py is in the current directory) to run the program. The prompt (for a DOS shell) is "C:\>" or something similar. You have the "Python Interactive Interpreter" there, indicated by the ">>>" prompt. In this shell-like window you can enter python statements only. No OS commands are allowed because they aren't python code. If you have any more questions re shells and DOS/Windows feel free to ask. You may also be interested in the "Tutor" list, tutor at python.org. HTH, -D From duncan at NOSPAMrcp.co.uk Tue Jun 5 04:39:45 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Tue, 5 Jun 2001 08:39:45 +0000 (UTC) Subject: why huge speed difference btwn 1.52 and 2.1? References: <9f8fgs$ooo$1@knot.queensu.ca> <9fdjsc$pn4$1@panix2.panix.com> <3b1bcf7a.12528354@news.ccs.queensu.ca> Message-ID: rsenior at hotmail.com (Robin Senior) wrote in news:3b1bcf7a.12528354 at news.ccs.queensu.ca: > On 3 Jun 2001 08:07:56 -0700, aahz at panix.com (Aahz Maruch) wrote: > >>In article <9f8fgs$ooo$1 at knot.queensu.ca>, >>robin senior wrote: >>> >>>I have a pretty simple script for processing a flat file db, running >>>on Python 2.1; I tried running it under 1.52 for kicks, and to my >>>surprise it ran almost 10 times as fast! Could someone let me know why >>>2.1 would be so much slower? Probably the regular expressions. Why are you compiling your regular expressions every time round the loop? Why are you using two regular expressions when one would do? Why are you using regular expressions at all. As far as I can tell your code reads a line in and then looks to see whether the line contains a word that ends in a state name or a state abbreviation. So if the line is "Today waz blowy, tomorrow may be better" is in the input it will be copied to the output files for Arizona and Wyoming. Is this correct? I would be tempted to rewrite the code, either to not use regular expressions at all, or to use a single regular expression for everything. If you build one big regular expression that matches all states and state abbreviations, then you can extract the match out of the line and use what matched as a dictionary key to find the right filename (provided you first build a dictionary with both state names and abbreviations as keys mapping to the filenames). Oh, and you upper cased the input, so you don't need a case insensitive search. -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From reageer.in at de.nieuwsgroep Mon Jun 25 15:17:08 2001 From: reageer.in at de.nieuwsgroep (Rene Pijlman) Date: Mon, 25 Jun 2001 21:17:08 +0200 Subject: creating a matrix in python? References: <3B350DC7.748C3903@telocity.com> Message-ID: Adonis schreef: >how do i go about this? Goto www.python.org (*not* considered harmfull), click "search" and enter "matrix". Regards, Ren? Pijlman From whisper at oz.nospamnet Tue Jun 12 13:22:01 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 12 Jun 2001 17:22:01 GMT Subject: WHY is python slow? References: Message-ID: <9g5j3p$ird$3@216.39.170.247> In article , tim.one at home.com says... > C++ adds nothing to C that can't be done just as well with > preprocessor macros, > there's-no-accounting-for-mass-delusion-ly y'rs - tim Didn't you ever use AT&T CFront? That was "C with classes" implemented as a set of macros - it was god-aweful. Also, the first commercially available C++ implementation from Microsoft likewise had a part of the language still in macros - it was even more god-aweful (consider the source!) and was widely ignored in favor of Borland and Zortech (later Symantec) "native" C++ products. Aside from massive code bloat and agonizingly slow compiles, there are just some things in C++ that cannot be expressed using the C preprocesser. Dave LeBlanc From volucris at hotmail.com Sat Jun 30 17:00:25 2001 From: volucris at hotmail.com (Volucris) Date: Sat, 30 Jun 2001 16:00:25 -0500 Subject: Can I list the functions inside a module References: <3B3DFF55.2030701@stu.ust.hk> Message-ID: <3b3e3d78$0$331$6e49188b@news.goldengate.net> I would guess that dir() and callable() would be availbale in Pippy. # This will list everything(almost) in ConfigParser and whether it's callable. # Note that while funtions are callable, so are classes and instances with a # __call__ method. import ConfigParser los = dir(ConfigParser) for object in los: if callable(eval('ConfigParser.%s' % object)): print '%s is callable.' % object else: print 'You can\'t call %s' % object Now I suppose you just hope that those modules have good docstrings. ;) -- Volucris (a) hotmail.com "Eu n?o falo uma ?nica palavra do portugu?s." "Calvin Fong" wrote in message news:3B3DFF55.2030701 at stu.ust.hk... > Greetings, > I'm running Piggy 0.7 on my palm m100. Piggy is a python interperter for > palm OS. As there is some platform specific modules for it, I want to > know what function do they contain. Please, can anyone teach me how to > show the function inside a modules. > > By the way, in case you have the passion to help me. Can you please send > the solution to my email, because I don't have a very good internet > connection for reading news > > Yours > Calvin > The Matrix is out there > From paul at boddie.net Tue Jun 5 04:45:39 2001 From: paul at boddie.net (Paul Boddie) Date: 5 Jun 2001 01:45:39 -0700 Subject: floating point in 2.0 References: Message-ID: <23891c90.0106050045.75c548f9@posting.google.com> msoulier at storm.ca (Michael P. Soulier) wrote in message news:... > Greetings people. > > My apologies if this has been covered. > > In Python 1.5.2, I could do this: > > good = (0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0) > > I could then get back exactly this when I output the value of "good". Yes, but what was actually stored was what you see now, at least when you ask about it at Python's interactive prompt. Python was doing some rounding in the *output* of your stored numbers, I believe. > However, with Python 2.0, I get this: > > >>> good > (0.0, 0.10000000000000001, 0.20000000000000001, 0.29999999999999999, > 0.40000000000000002, 0.5, 0.59999999999999998, 0.69999999999999996, > 0.80000000000000004, 0.90000000000000002, 1.0) > > Now, I'm assuming that this has something to do with the way that Python > 2.0 stores floating-point numbers, but this could get confusing during > debugging. It's really the way that floating point numbers are stored on any particular platform, although such a naive statement needs clarification that I am not prepared to give. ;-) > Could someone explain this behaviour? Floating point numbers are stored in such a way that not all decimal numbers can be represented exactly and, as you can see from your test, certain numbers come out "all weird". It's a bit like 1/3 not being representable exactly in the decimal number system within a finite number of digits: it comes out as 0.3333... Of course, someone will undoubtedly correct me, but that is a reasonable way of thinking about this kind of situation. Take a look at Python 2.0's release notes on http://www.python.org for more information. The big change was in the built-in 'repr' function. Basically, the formatting of numbers was changed in 'repr' between 1.5.2 and 2.0. Regards, Paul From splat_360 at flashmail.com Mon Jun 18 14:37:39 2001 From: splat_360 at flashmail.com (Nik Goodey) Date: Mon, 18 Jun 2001 13:37:39 -0500 Subject: sendmail Message-ID: I am trying to get a form on my page email me some info. I can;t figure out how to get sendmail to get the form info and email it. Nik From meowbot at meowing.net Fri Jun 8 02:10:31 2001 From: meowbot at meowing.net (A Meowbot) Date: 08 Jun 2001 02:10:31 -0400 Subject: random References: <3b1cf00f.5441109@nntp.sprynet.com> <3b1e4957.3040319@nntp.sprynet.com> <9flkqc01nfp@enews2.newsguy.com> <3b1f97ca.4530449@nntp.sprynet.com> <9fo9k50gl6@enews2.newsguy.com> Message-ID: <87snhblcx4.fsf@litterbox.meowing.net> scarblac at pino.selwerd.nl (Remco Gerlich) wrote: > No matter how long you let it run, there will always be a finite amount of > non-blank squares. The number may grow larger than any N you want to name, > but it'll never be infinite (I wonder what the last step would look like, > right before it becomes infinite). It would look really, really big. From rajarshi at presidency.com Mon Jun 4 03:36:35 2001 From: rajarshi at presidency.com (Rajarshi Guha) Date: Mon, 4 Jun 2001 13:06:35 +0530 Subject: Python output for Glade References: <9fdprb$3hpec$2@ID-91520.news.dfncis.de> Message-ID: <9ffdos$3oliu$1@ID-91520.news.dfncis.de> Rajarshi Guha wrote in message news:9fdprb$3hpec$2 at ID-91520.news.dfncis.de... > Hi, > does anybody know of patches etc that can give me Python source for a > Glade project. I tried using glade.py but it gives a number of errors and I follwowed up the pointers regarding using Glade and Python and it seems pretty neat. However I have a question. There aree two ways to use a Glade file to generate the UI. One is to use libglade and generate it on the fly and the other involves converting the XML description to Python src. Which is a better? Or rather when would I use on the fly generation or conversion to Python source? TIA, -- ------------------------------------------------------------- Rajarshi Guha email: rajarshi at presidency.com web: http:/www.psynet.net/jijog From aleaxit at yahoo.com Tue Jun 12 17:56:36 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 12 Jun 2001 23:56:36 +0200 Subject: Learning OOP... References: <9fm8ti$d92$1@newshost.accu.uu.nl> <503ca784.0106112030.3d434e08@posting.google.com> Message-ID: <9g632f0f69@enews1.newsguy.com> "Mike" wrote in message news:f25b4a41.0106121309.126d753f at posting.google.com... ... > The Java Virtual Machine is just not efficient and is not integrated > well enough into operating systems such as Windows. How many > applications, besides Java IDE's, are actually in widespread use? I No idea in general, but a couple of things... the best bridge-playing program you can buy (www.gib.com) uses Java for all of its GUI and file-handling (the actual core program that chooses bids and plays is a separate C-coded executable). It's available for Windows and Linux, which may explain the choice of Java for the front-end (though Python with wxWindows would also be a natural!-). But clearly, in the mind of GIB's father, "the play's the thing" -- he freely gives away improved versions of the front-end, "bridge improvements" in the back-end is the only thing he charges for (he's also a leading researcher in bridge-play algorithms and he codes the back-end personally, while the front-end he had coded by another guy). On the other hand, one of our competitors (in the PDM field -- that's Product-Data Management) recently made a big fuss about their latest, huge improvement to their program -- apparently, they threw away their whole Java implementation and recoded the whole thing in C++. They can't stop vaunting how much faster and memory- leaner it's become:-). [considering that many of their competitors, us included, never left C++ as the main implementation language, I wonder how good a marketing differentiator it is for them to have come _back_ to C++ after a long Java excursion, but...:-)] Alex From tim.one at home.com Tue Jun 19 20:19:29 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 19 Jun 2001 20:19:29 -0400 Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: [Denys Duchier] > The one thing that rubs me the wrong way with this proposal is that it > is not compositional. Unless I misread the PEP, the entire generation > logic must be defined in a single function (because the `yield' > keyword must statically occur within the body of the generator > function). This makes it impossible to use higher-order programming > to assemble complex generators from smaller blocks. Since higher-order programming is an aberration (meaning statistically rare) in idiomatic Python, a specific example would help. If, e.g., you want to build a generator that delivers the results from generators g and h alternately, it's easy (although I personally don't want to ): def zipgen(g, h): giter = g() hiter = h() while 1: yield giter.next() yield hiter.next() def g(): i = 1 while 1: yield i i += 1 def h(): i = -1 while 1: yield i i -= 1 count = 0 z = zipgen(g, h) while count < 10: print z.next(), count += 1 print which prints 1 -1 2 -2 3 -3 4 -4 5 -5 It's the iteration protocol that's flexible, not generators per se. > One way to address this issue would be to make the dynamic bracketing > explicit, for example as an annotation on the function which is > intended to wrap the generator (this has been proposed by many, albeit > for different reasons). The title of the PEP is "Simple Generators", and the adjective is important: these will never make it in if they explode anyone's head, and this isn't meant to be esoteric wizard stuff but useful to everyday programmers. > I won't make a proposal of my own, but I'll just point out that the > issue is very much related to the old duality control/prompt > (Felleisen) or later shift/reset (Filinski) in the continuation world. Heh. If you don't spell out what the concern is, I can pretty much guarantee nobody else is going to . This flavor of generator is a semi-coroutine, much the same as Icon's, Sather's and CLU's (although they're called "iterators" in the latter two languages). From padf at ihug.com.nz Fri Jun 15 05:34:22 2001 From: padf at ihug.com.nz (Patrick Ford) Date: 15 Jun 2001 21:34:22 +1200 Subject: Python version of IQ has been updates (IQ v0.34.python) References: <505.566T11T1243597threeseas@earthlink.net> Message-ID: <3B2A7F5E.MD-1.4.4.padf@ihug.com.nz> Timothy Rue wrote: > http://www.mindspring.com/~timrue/python/IQ.34.py Python??? Oh no don't go there Tim! Rebol rocks. -- -- My domain contains .co, not .com as appears in the header. Patrick Ford Auckland, Aotearoa (New Zealand) From akuchlin at mems-exchange.org Thu Jun 28 10:21:22 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 28 Jun 2001 10:21:22 -0400 Subject: Check out O'Reilly's Open Source Convention Highlights References: <3B3AA82D.1A0FE860@seebelow.org> <3B3B2DED.5303198A@seebelow.org> Message-ID: <3dk81w1y8t.fsf@ute.cnri.reston.va.us> Grant Griffin writes: > But now that you mention it, the US Midwest *is* pretty centrally > located on a "world" basis. >From a quiz for mad scientists I once saw: Complete the following sentence: "Unless I receive a billion dollars by midnight, I will destroy a world-famous centre of culture and history, _______" A. New York B. London C. Spooner, Wisconsin. D. that little pancake place, remember, where you once had the mushroom omelet? --amk (www.amk.ca) It's funny, but you know, before I met you, I was actually willing to be impressed. -- Romana to the Doctor, in "The Ribos Operation" From tim.one at home.com Thu Jun 14 01:33:28 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 14 Jun 2001 01:33:28 -0400 Subject: Build problem with unicode and 2.1 In-Reply-To: <3B264EE9.4010405@lbl.gov> Message-ID: [David P Grote] > I am trying to build python 2.1 on a 64-bit machine (Cray-T3E) and > have run into a problem with unicode. The Py_UNICODE type is required > to be a 16-bit long, unsigned int. But, on the T3E, there are no types > that are less than 4 bytes long. Not even char? In any case, I'm afraid you're out of luck for now (this is a known problem): http://sf.net/tracker/?group_id=5470&atid=105470&func=detail&aid=405227 Patches to it and Cray-T3E config sufficient to fix it gratefully accepted. > ... > Will the code work OK if I just comment out the line in the unicode > init routine which checks the length of the Py_UNICODE type and run > with a 4-byte long Py_UNICODE? No; see the bug report; if the code didn't care, it wouldn't go out of its way to complain. From nickatvideosystemdotcodotuk Fri Jun 29 11:42:19 2001 From: nickatvideosystemdotcodotuk (Nick Trout) Date: Fri, 29 Jun 2001 16:42:19 +0100 Subject: Python VC++ integration / COM question Message-ID: <3b3ca1e3@news.xtml.co.uk> I'm trying to write an addin for Vis C++ so that I can hit a button and run Python scripts. Then, using automation, the script can control/edit VisC. eg. to add comments and do source code processing. I'm a bit new to COM. I found the useful win32com Makepy utility to generate a wrapped for the TextEditor type library. I've looked at the examples and I can automate Word but I'm having trouble with VisC. I cant seem to create/grab an application object. Is this possible? Or do I somehow have to pass the Application COM object from the AddIn to Python so that it can automate VisC? Are there any simple examples of how to use the modules generated by Makepy? It may be I'm just confused about their functionality! Any help/pointers very gratefully received. Ta, Nick --- It is requisite for the relaxation of the mind that we make use, from time to time, of playful deeds and jokes. - Thomas Aquinas, Italian theologian and philosopher From aleaxit at yahoo.com Sat Jun 9 17:31:57 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 9 Jun 2001 23:31:57 +0200 Subject: Learning OOP... References: <3B2117AF.864050C1@earthlink.net> Message-ID: <9fv6sr0183i@enews2.newsguy.com> "Ron Stephens" wrote in message news:3B2117AF.864050C1 at earthlink.net... ... > My suggestion is learn and use Python, the cost to benefit ratio just > can't be beat. Then, if you feel yo need more strict discipline, go on > and learn Java or C++; the education you got form Python will hold you in > good stead and may be the best investment you have ever made. ;-)))) Basically OK, but Java and C++ are not really the best for "strict discipline". They're too lax for that. Rather, I keep suggesting to Bondage & Disciplne fans either Eiffel (for pretty classic 'static typing' in an OO setting), or Haskell (O'Haskell if you insist on OO) for a taste of what static typing SHOULD be (type infererence by the compiler, the brilliant concept of typeclasses, &c). Alex From wa at net-federation.de Tue Jun 26 08:50:27 2001 From: wa at net-federation.de (Wendelin Auer) Date: Tue, 26 Jun 2001 14:50:27 +0200 Subject: urllib: geturl with max filesize? Message-ID: <9ha08v$n0s$02$1@news.t-online.com> hello. I'm planning to 'pull' a file header from a different urls than the rest of my page. I'm not very introduced in python, but I tried and the following code is doing well (scripted html in an output-template of a python-search-server): The url is coming out of a parameter in the search request, so this can be changed by anybody. So what, if some nice guy puts an url of a 10 GB-file on a fast server at this place? I have to prevent that. - Does anybody know how to limit the filesize of this geturl-function? - Is there maybe another security problem? Thank You, Wendelin Auer From thomas at xs4all.net Tue Jun 5 08:53:28 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 5 Jun 2001 14:53:28 +0200 Subject: Is PyRun_String() broken? In-Reply-To: ; from davygrvy@pobox.com on Tue, Jun 05, 2001 at 03:40:55AM -0700 References: Message-ID: <20010605145328.W690@xs4all.nl> On Tue, Jun 05, 2001 at 03:40:55AM -0700, David Gravereaux wrote: > I tried Py_eval_input, but I can't send it arbitrary code, such as "import > sys". That's because import is a statement, not an expression. See below. If you want to import a module and get the module object, use '__import__()'. > If I use Py_file_input, PyRun_String accepts the code, but no return value is > used. Just some string that say 'None'. I'll assume that means "no exception > generated". No, it means 'No return value'. There is a big difference between 'statements' and 'expressions', in Python. Statements can't be chained or nested (unless the statement explicitly allows that, like the assignment statement) and they do not return a value. You can't "eval" statements, only expressions. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From uioziaremwpl at spammotel.com Fri Jun 29 15:33:09 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Fri, 29 Jun 2001 21:33:09 +0200 (CEST) Subject: PEP scepticism In-Reply-To: Message-ID: On Fri, 29 Jun 2001, phil hunt wrote: > On Thu, 28 Jun 2001 12:26:08 -0700, stevencooper at isomedia.com wrote: > > > >Keystroke reduction saves the original programmer time. > > True. > > > But it costs > >other people more time when they read the code. > > Really? > > Is this: > > self.total[player] += s > > any harder to understand than this: > > self.total[player] = self.total[player] + s > > I don't think so. It is harder to understand, when the statements do different things. Cheers, Carsten -- Carsten Geckeler From BrianQ at ActiveState.com Tue Jun 12 16:09:46 2001 From: BrianQ at ActiveState.com (Brian Quinlan) Date: Tue, 12 Jun 2001 13:09:46 -0700 Subject: Any tool for code coverage analysis on Python program In-Reply-To: <9g5n9i$qig@news.or.intel.com> Message-ID: <003601c0f37b$a5416ff0$b503a8c0@activestate.ca> > Hi I am trying t find a tol that do code analysis on program > in python. > where can I find it? > I am using Python 1.5.2 I can't recall if it was available in Python 1.52, but in Python 2.0 and above there is a script called trace.py in the Python tools directory. It might do what you want. From mwright at pro-ns.net Fri Jun 1 18:27:38 2001 From: mwright at pro-ns.net (Mark Wright) Date: 1 Jun 2001 15:27:38 -0700 Subject: How do I return binary data from a python CGI called from CGIHTTPServer? References: Message-ID: Skip Montanaro wrote in message news:... > Mark> out_file.write('Content-type=application/octet-stream\n\n') > > Should be > > Content-type: application/octet-stream > > (colon, then space instead of equals). Well, that explains why nothing was working under Mozilla ('Content-type=' works under IE - go figure), good thing I didn't finish that bug report I was working on. And a bunch of debuging code 'print's that occurred before the 'Content-type' line explain why garbage appeared on IE's screen. But my original problem/question remains: how does a CGI program return binary data on windows? Is it even possible? The problem is that this chunk of code in a CGI-program doesn't seem to work under Windows: data = open('mybinaryfile.dat', 'rb').read() print data presumably because of \r\n issues. Is there a way to convince CGIHTTPServer to read data as binary and not perform CRLF conversion? Mark From fredrik at pythonware.com Mon Jun 18 15:26:50 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 18 Jun 2001 19:26:50 GMT Subject: ftplib possible bug? Please help. References: <4b866f80.0106180908.31a3b6b5@posting.google.com> Message-ID: <_BsX6.1423$e5.531093@newsb.telia.net> "Marshall" wrote: > I am using Python 2.0 on NT 4.0 > When I ftp a file from one NT server to another, using ftplib, it > changes the end of the line from CRLF to LF. It does this EVEN when > the transfer is Binary. > Is this a known problem? you need to open the local file in binary mode too. e.g: ftp.retrbinary("RETR " + file, open(file, "wb")) or ftp.storbinary("STOR " + file, open(file, "rb"), 1024) the "open" function is documented under "built-in functions" in the library reference. From jkraska1 at san.rr.com Sat Jun 16 20:58:51 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 17 Jun 2001 00:58:51 GMT Subject: qt or gtk? References: <9ggof8$gmd$1@brokaw.wa.com> Message-ID: >Now I feel stupid. I thought Qt was free to use if your software is free, >but costs money if you plan to sell it. There are two versions - commercial >and free software, and you have to buy a license if you want to use the >commercial version. I assumed the difference between the two is only in >name and license, and the source is the same, however. Actually, I believe that what you said is correct for the Linux platform, but I'm not sure. What I am sure of is that Qt is not free for Windows, irrespective of how you intend to use it. C// From jwelby at waitrose.com Wed Jun 20 18:28:41 2001 From: jwelby at waitrose.com (Julius Welby) Date: Wed, 20 Jun 2001 23:28:41 +0100 Subject: launching a file with its associated application on windows References: <9gr70q$bac$1@bob.news.rcn.net> Message-ID: Try this: import os os.startfile(r"C:\yourfile.htm") "Christian Reyes" wrote in message news:9gr70q$bac$1 at bob.news.rcn.net... > Is there a method that takes a file as an argument and then opens that file > with the its associated viewer? > > Thanks, > christian > > From thomas.heller at ion-tof.com Mon Jun 25 11:36:58 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Mon, 25 Jun 2001 17:36:58 +0200 Subject: DistUtils and optimized compile References: <3B375869.E417C833@stroeder.com> Message-ID: <9h7lng$cdpjl$1@ID-59885.news.dfncis.de> [posted and mailed] "Michael Str?der" wrote in message news:3B375869.E417C833 at stroeder.com... > HI! > > I'd like to use DistUtils for a pure Python module package. > Everything seems to be ok so far but when doing python setup.py > install only the .pyc byte-code is compiled and installed. I'm > missing the .pyo files with the optimized compiled byte-code. > > Any help's appreciated. Use the -O1 or -O2 command line flag: python install -O2 Thomas From tim.one at home.com Tue Jun 19 20:06:04 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 19 Jun 2001 20:06:04 -0400 Subject: PEP 255: Simple Generators In-Reply-To: <3B2F9758.4B69F032@ActiveState.com> Message-ID: [Carsten Geckeler] > But when I'm browsing through a source it may help me very much > if I could see at the `def' line if it's a regular function or a > generator. [Paul Prescod] > I see this as an important point. It would be redundant to add a > generator modifier to functions but I think that that redundancy would > actually help people. It would help new users to understand that a > generator is a *type of function*, *determined at compile time* and not > a behavior of a function, determined at runtime. def xyz(i): return abc(i) can also return a generator-iterator in 2.2, and it's what the function *returns* that's important to users. There's no way in Python to communicate that apart from docstrings and comments, and PEP 255 doesn't change that. > It would help even expert users to spot generators in code. Unlike most of the participants in this discussion , I've used generators heavily, and I don't *care* where the generators are in the code. This is like saying that functions returning integers should be declared "defint" instead, or some such gibberish. Ya, maybe once in 10 years you're going to want to find all your functions that return ints; same thing with generator-functions (a proper subset of the set of all functions that return generator-iterators), except they're already much easier to find. > It would help documentation-generation programs like pydoc to "flag" > generators without massive complexity. Static typing would be much more effective for this, and not limited to a single obscure case. > It would help all of us ensure that our code is inline with our > intentions. And it doesn't seem like it would hurt anything. Drawing pointless distinctions is a distraction -- whether a function is or isn't a generator-function simply isn't interesting for most people, most of the time. From rgruet at intraware.com Mon Jun 18 12:51:53 2001 From: rgruet at intraware.com (Richard Gruet) Date: Mon, 18 Jun 2001 16:51:53 GMT Subject: why is there no class (static) methods in Python ? References: <3B2D114E.7B39D954@intraware.com> <3B2D6669.7DEFD13F@intraware.com> Message-ID: <3B2E31A6.9A5B378@intraware.com> Martin von Loewis wrote: > Richard Gruet writes: > > > But the reason to choose to define a function as a class method rather than a > mere (static) function is -obviously- when this > > function is closely related to the class itself, not to one of its > instances. > > Depending on how exactly it is related, provinding a module function might > *still* be the better solution - even if class methods were available. Only if the module contains only one class.. > > In fact, constructors (and destructors) are class methods, not instance > methods, but they are handled specially in the language so they appear as > instance methods.. > > No, constructors (at least as available in Python, C++, and Java), are really > initialization methods, and thus instance methods. This is easily seen as they > get an object as implicit argument. Yes, I agree that the concrete purpose of constructors is to initialize instances. But more generally, and from a semantical point of view, calling a constructor *creates* a new instance, even if the programmer gains control only on the init part. Then I'd say that a constructor belongs to the class as well as to the instance being created. > > Typical examples of class methods: > > loadInstanceFromStream(aStream) # Create an instance from its persistent > > That is a factory function, something that should be separate from the class > itself. Yes, I read the GoF too. But a class is a factory of instances, no ? > > getInstanceCount() # returns the number of instances > > getInstanceList() # returns the list of > > getClassName() or getAnyInfoOntheClass() ...... > > These ought to be globl functions, taking the class as an argument. Some of > these are really easy to implement in Python: > > def get_class_name(x):return x.__name__ No, I completely disagree. WHY should they be *global* functions rather than *class* functions (since they are strictly related to the class) ? You provide no arguments ! Using the class namespace rather than the module namespace for class-related functions seems more natural (and object oriented) to me. And finally, I wonder why they are class methods in Java ? They should listen to your arguments and remove them ;-) But I don't want to dispute endlessly. I -and other people- would simply like that such a feature be available in Python, that's all! regards, Richard -------------- next part -------------- A non-text attachment was scrubbed... Name: rgruet.vcf Type: text/x-vcard Size: 370 bytes Desc: Card for Richard Gruet URL: From email Thu Jun 7 10:36:34 2001 From: email (=?Big5?B?uOqwVLresnqxTbd+qPO3fA==?=) Date: Thu, 7 Jun 2001 22:36:34 +0800 Subject: =?Big5?B?pOW+zLCqr8Wk5b7Msqa3fqTlvsy+x6RoutOkaL3StXs=?= Message-ID: <9fo3c0$4qc8307@rain.i-cable.com> IT Management Association UK University of Devonshire UK Any enquiry please contact Sunny Cheung Email: sunny at itma-uk.org URL: www.itma-uk.org Tel: 27108382 (Office hour) Add: Rm. 2103 Hollywood Plaza, 610 NAthan Rd., Mongkok, Lowloon. Open entry Anyone aged 17 or above is eligible to apply. No entry qualifications are required except for professional programs. Distance learning You will enjoy maximum flexibility through distance learning. You will learn through the printed materials, set texts and other materials that we suggest. Financial assistance Low-interest loans are available to help students with financial difficulties. Credit transfer You may transfer credits gained at local or overseas universities to our programs. It depends on your previous qualifications and their relevance to the program you wish to enroll. Recognition IT Management Association UK and University of Devonshire UK awards are widely recognized for employment?Bprofessional bodies, and further studies both in Hong Kong and overseas. Institutional credit transfer arrangements have been signed with institutions in U.K., Canada, Australia, USA and New Zealand. Assessment Our programs are widely recognized for its high quality. Your study will be assessed by subject paper throughout a course taken and no examination is required. Tuition Master Degree HK$42,000 Bachelor Degree Final Stage HK$18,000- Diploma -> Bachelor Degree Combination HK$48,000- Diploma -> Graduate Diploma Combination HK$38,000- Diploma -> Advanced Diploma Combination HK$28,000- Diploma, Advanced Diploma, Graduate Diploma HK$18,000- Entry to any level diploma / final year of Bachelor Degree with previous education qualifications or working experience Bachelor of Business Administration Course Contents 1. Introduction to Business 2. Fundamental Accounting Principles 3. Approach to Management 4. Introduction to Business Communication 5. Principles of Economics 6. Financial Accounting 7. Marketing 8. Organizational Behavior 9. Introduction to Corporate Finance 10. Financial Markets 11. Entrepreneurship 12. Business Administration 13. Introduction to Human Resource Management 14. Introduction to Law for Business 15. Contemporary Advertising 16. International Marketing Bachelor of Science in Computer Science Course Contents 1. Introduction to Business 2. Computer Studies 3. Fundamentals of the Internet and World Wide Web 4. Learning C++ 5. Introduction to Computer Science 6. Fundamental Accounting Principles 7. Introduction to Languages and Computation 8. Software Engineering with Java 9. Database Systems Concepts 10. Introduction to Business Communication 11. Classical and Object-Oriented Software Engineering with Java and UML 12. Database Management Systems 13. Problem Solving Using C 14. Computer Organization 15. Computer Architecture 16. Machine Vision Bachelor of Science in Management Information Systems and Technology Course Contents 1. Introduction to Business 2. Communication Networks 3. Corporate Information Systems Management 4. Learning C++ 5. Fundamental Accounting Principles 6. Building the Information-Age Organization 7. Competitive Advantage (IT) 8. Software Engineering with Java 9. Introduction to Information Systems 10. Information Technology for Management 11. Information Systems 12. Accounting Information Systems 13. Principles of Management 14. Managing Information Systems in the Information Age 15. Classical and Object-Oriented Software Engineering with Java and UML 16. Problem Solving Using C Students completing all required subjects can obtain a Bachelor Degree from The University of Devonshire. The Bachelor Degree can normally be completed within 16 to 48 months. Students enrolled in the Graduate Diploma will complete 12 subjects from the list. The Graduate Diploma can normally be completed within 12 to 36 months. Students enrolled in the Advanced Diploma will complete 8 subjects from the list. The Advanced Diploma can normally be completed within 8 to 24 months. Students enrolled in the Diploma will complete 4 subjects from the list. The Diploma can normally be completed within 4 to 12 months. Master's of Business Administration Course Contents 1. Corporate Finance Essentials 2. Managerial Economics 3. Principles of Management II 4. Marketing Management 5. Management Competition 6. Integrated Business 7. Modern Business Law 8. Advanced Financial Accounting 9. Business Communication in the Professional Setting 10. Consumer Behavior and Marketing Strategy 11. Global Marketing E-Commerce MBA Course Contents 1. International Business 2. Cases in Electronic Commerce 3. E-Business 4. Management Information Systems for the Information Age 5. Investment Experience 6. Security, Risk Management, and Control 7. E-Business: Roadmap to Success 8. Internet Marketing 9. E-Business Revolution 10. Accounting Information Systems 11. Global Marketing Master's in Computer Science Course Contents 1. Advanced Studies in Programming Languages 2. Database Systems 3. Computer Systems: Organization and Operating Systems 4. Advanced Studies in Algorithm Design and Analysis 5. Software Engineering 6. Computer Graphics 7. Network Design and Analysis 2 Students completing all required subjects could obtain a Master Degree from The University of Devonshire. The Master Degree can normally be completed within 9 to 24 months. 2 Students completing 2/3 required subjects from the list could obtain a Postgraduate Diploma. 2 Students completing 1/3 required subjects from the list could obtain a Postgraduate Certificate. ?M?~???? (Professional Diploma) ???{?G ?M?~???M?a???????{???b?????????????n?M?~???M???S?????~???N???????N?V?m?A???L???????q?????M?????~?????k???t?C???????????C ?????U?M?~???????{?????G ???????????????~?????|???^???????F?????????H?W?A ?????????~?{???????}?n?^?y?\?????g?@???O?A ???w?????????????{???|?????????A ??19???H?W???~?????A?????@?~?????u?@?g???C 2 ?q???t???????????N?????u?{?v?M?~???????{ Professional Diploma in Computer System & Network Support Engineer ?????{?????b???????????q?????{???q???q???t?????N?????H?h?A?????M?~?????????????|?A?????????????p?U?G 1. Hardware Introduction - I?]?q???w???@?^ Computer Keyboards, Data Processing, Electrical requirements of computer systems, Printer Management, Disk Management, Central Processing Units and Memory, Storage Systems, Input and Output Devices, Data Communications, Networking, Process Control. 2. Hardware Introduction - II ?]?q???w???G?^ Processors, Memory and Benchmarking, Buses and Interfaces, Mass Storage Devices, Input Output Devices, Power Supplies, Testing Procedures, Configuring Peripheral Devices. 3. Operating System ?]?q?????@?t???^?? What is an Operating System, Various parts of an Operating System, What is a Process, Operating System Load, File Management, Software Tools, Basic Features of Graphical Interfaces, Windows Objects and Components. 4. Windows 95/98 and MS-DOS Operating System ?]?????E?????E?K?????????@?t???^?? Why Windows 95/98, Basic Features, Starting Up, Using Applications, Managing Files and Folders, Managing the Desktop. 5. Introduction to Networking ?]?q???????^?? Network Concepts Components, Adapters, Wiring Guide, ELA TIA-568 Standard, Twisted Pair, Coaxial, Fiber, OSI Model, Network Segments, Spanning Tree Algorithm, Repeaters, Bridges, Routers, Hubs, Ethernet Switches, Virtual Networking Network Topology Bus, Bus-Physical Layout, Ethernet 802.3-CSMA/CD, 10Base2-Ethernet, 10Base5-Ethernet, 10BaseT-Ethernet, Bus-Physical Cable Limits, Ring, Ring-Physical Layout, IEEE 802.5 Token Ring, Ring-Physical Cable Limits, Star, FDDI, Logical vs Physical. Connecting Computers Peer to Peer, Workgroups, Workgroup Resources, Belonging to a Workgroup, Sharing Resources, Accessing Resources, Novell File and Print Services, Domains, User Accounts, Computer Accounts, Groups, Domain Models, Single Domain Model, Trust Relationships, Single Master Domain Model, Complete Trust Domain Model. Troubleshooting Cable Testing, General Troubleshooting Principles, Hardware Diagnostics, Using a TDR, Using a multi-meter. 6. Windows 2000 Server/NT Server 4.0 ?]???????????A???????????????D???^?? Operating Systems, Windows NT Services, Workgroups and Domains, Domain Name System, Active Directory, Administering Active Directory, Security and Permissions, Supporting Users, Managing S/W Applications, Managing Printers, System Recovery. 7. Introduction to Internet and Web Pages Development?]???p?????????????}?o?^?? Understand basic Internet concepts and terminology, Use a browser to explore the WWW, Locate information using search engines, Use FrontPage to create web sites, Use E-mail, Video and communication tools. 8. Linux Server Engineering ?]Linux ???????A???^ Hardware and Installation (x86 Architecture), Configuration and Administration, Alternate Installation Methods, Kernel Services and Configuration, TCP/IP Networking, Samba File Server Configuration, Apache Web Server Configuration, NFS Network File Service Configuration, X Window System, User and Host Security, Routers & Firewalls Configuration. 2 ?????}?o?????z???N?????u?{?v?M?~???????{ Professional Diploma in Web Site Development & Management Support Engineer ?????{?????b???????????q?????{???q?????????z?u?@???H?h?A?????M?~?????????????|?A?????????????p?U?G 1. Operating System ?]?q?????@?t???^?? What is an Operating System, Various parts of an Operating System, What is a Process, Operating System Load, File Management, Software Tools, Basic Features of Graphical Interfaces, Windows Objects and Components. 2. Windows 95/98 and MS-DOS Operating System ?]?????E?????E?K?????????@?t???^?? Why Windows 95/98, Basic Features, Starting Up, Using Applications, Managing Files and Folders, Managing the Desktop. 3. Introduction to Networking ?]?q???????^?? Network Concepts Components, Adapters, Wiring Guide, ELA TIA-568 Standard, Twisted Pair, Coaxial, Fiber, OSI Model, Network Segments, Spanning Tree Algorithm, Repeaters, Bridges, Routers, Hubs, Ethernet Switches, Virtual Networking Network Topology Bus, Bus-Physical Layout, Ethernet 802.3-CSMA/CD, 10Base2-Ethernet, 10Base5-Ethernet, 10BaseT-Ethernet, Bus-Physical Cable Limits, Ring, Ring-Physical Layout, IEEE 802.5 Token Ring, Ring-Physical Cable Limits, Star, FDDI, Logical vs Physical. Connecting Computers Peer to Peer, Workgroups, Workgroup Resources, Belonging to a Workgroup, Sharing Resources, Accessing Resources, Novell File and Print Services, Domains, User Accounts, Computer Accounts, Groups, Domain Models, Single Domain Model, Trust Relationships, Single Master Domain Model, Complete Trust Domain Model. Troubleshooting Cable Testing, General Troubleshooting Principles, Hardware Diagnostics, Using a TDR, Using a multi-meter. 4. Windows 2000 Server/NT Server 4.0 ?]???????????A???????????????D???^?? Operating Systems, Windows NT Services, Workgroups and Domains, Domain Name System, Active Directory, Administering Active Directory, Security and Permissions, Supporting Users, Managing S/W Applications, Managing Printers, System Recovery. 5. Introduction to Internet and Web Pages Development?]???p?????????????}?o?^?? Understand basic Internet concepts and terminology, Use a browser to explore the WWW, Locate information using search engines, Use FrontPage to create web sites, Use E-mail, Video and communication tools. 6. Internet Management?]???p?????z?^ Introduction to Internet Management, Networks Components, Network Topology and Cabling, Security, Management, Auditing, Intranets, Extranets, WAN's, Managing Users, Security of data, Clistering, UPS, Backup, Virus, Capacity Planning, Asset Management, Managing Web Sites, Log Files, Tracking Users. 7. Web Sites Development and Programming using JAVA Script ?]JAVA Script ?????}?o???{???s?g?^ What is JavaScript, HTML-Document, Frames Programming, Status bar and Timeouts Programming, Predefined Objects, Forms Programming, Image Object. _____________________________________________________________ This message posted with trial version of Express News Poster From objectway at divalsim.it Wed Jun 27 04:10:27 2001 From: objectway at divalsim.it (Nicola Musatti) Date: Wed, 27 Jun 2001 10:10:27 +0200 Subject: Newbie seeks help on case preserving substitutions References: <3B3767BB.A882F8@divalsim.it> <3B383B3A.F63FBA56@divalsim.it> Message-ID: <3B3994F3.D38A2616@divalsim.it> Marcin 'Qrczak' Kowalczyk wrote: [...] > So there are only three case forms. You can perform three passes over > each line, each pass being a case-sensitive replacement of constant > strings prepared before the loop. > > This can be done without regexps, using .replace(old,new) method of > strings (or string.replace(s,old,new) in Python < 2.0). Dang! I underspecified my problem. I do need regexps because my files may contain different strings, all to be substituted by the same string. It all comes from the reorganization of a large application which is split in different projects, where I used the same naming convention across all projects, based on the project names. So I may have files named "PRojName.cpp", containaining macros named PROG_SOMETHING, which are built into projname.dll; now I'm combining some projects together and I'm using my script to substitute old names with the new one. The snippet I presented in my original post is surrounded by a loop on all the files in the new project. What I've done is modify the inner loop to take into account the new string's length and to check the first, third and fourth letter in the original string to decide which variation to write in. For a first "useful" Python program I'm reasonably satisfied, even if it is a bit too C-ish (or shellish, if you like). Thank you to everybody for your suggestions! Cheers, Nicola From chat at linuxsupreme.homeip.net Thu Jun 7 13:59:33 2001 From: chat at linuxsupreme.homeip.net (Chad Everett) Date: 7 Jun 2001 12:59:33 -0500 Subject: Recursive algorithms anyone? References: <1f0uhtgmhb0vlud6pof6i4mctqjdq8l2eu@4ax.com> Message-ID: On Wed, 06 Jun 2001 22:18:12 -0700, Kirby Urner wrote: > > >How to implement in Python the classic thing of >adding k to every item in a list. Except a list >may contain other lists to arbitary depth? > >I say classic because it's the kind of thing you >do in computer science 101. > >E.g. >>> additem(1,[1,2,[3,4,[5,6]],7]) > [2,3,[4,5,[6,7]],8] > >Here's the Scheme solution: > >(define (additem items k) > (cond ((null? items) null) > ((not (pair? items)) (+ items k)) > (else (cons (additem (car items) k) > (additem (cdr items) k))))) > > >My best Python attempt so far: > > >>> def additem(items, k): > if not type(items) == type([]): return items + k > if len(items)==0: return [] > return [additem(items[0],k)] + additem(items[1:],k) > > >>> additem([[9,8],1,2,3,4,[1,2, [5,6]]],1) > [[10, 9], 2, 3, 4, 5, [2, 3, [6, 7]]] > >But maybe there's a better solution? > >Kirby > I don't think this is "better", but I think it's more readable: def addcomp(L,num): if type(L) != type([]): return L+num if L == []: return L return [addcomp(L[0],num)] + addcomp(L[1:],num) -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From rjroy at takingcontrol.com Sun Jun 24 11:56:39 2001 From: rjroy at takingcontrol.com (Robert Roy) Date: Sun, 24 Jun 2001 15:56:39 GMT Subject: Dynamic binding of class functions References: <3B31922A.F03D3DD2@computer.org> Message-ID: <3b360d62.1083468421@news1.on.sympatico.ca> On Thu, 21 Jun 2001 08:20:27 +0200, gideon may wrote: >Hi, > >I have the following problem. I would like to dynamically add methods >to existing instances of classes. I've succeeded creating a new function > >on the fly and adding it to the dictionary of the class instance, but >when >I try to call the method through class.newmethod(), the method >doesn't receive the self paramater in the parameter list. I've tried the >following code : > >def makefunc(r): > func = 'def ' + r + '(self):\n' > func = func + ' print "called ' + r +'"\n' > func = func + ' print "dir = ", dir()\n' > func = func + ' return "Done ' + r + '"\n' > return func > >class Device: > def __init__(self): > self.host = "localhost" > r = 'xxxx' > f = makefunc(r) > print f > exec f in self.__dict__ > >if __name__ == "__main__": > d = Device() > print dir(d) > d.xxxx() > >What am I doing wrong ? > > You need to use the new module to bind the method to the instance. The following works. Bob ######## import new def makefunc(r): func = 'def ' + r + '(self):\n' func = func + ' print "called ' + r +'"\n' func = func + ' print "dir = ", dir()\n' func = func + ' return "Done ' + r + '"\n' return func class Device: def __init__(self): self.host = "localhost" r = 'xxxx' f = makefunc(r) print f exec f setattr(self, r, new.instancemethod(eval(r),self,self.__class__))# in self.__dict__ if __name__ == "__main__": d = Device() print dir(d) d.xxxx() From phd at phd.fep.ru Mon Jun 11 07:00:53 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Mon, 11 Jun 2001 15:00:53 +0400 (MSD) Subject: Exceptions In-Reply-To: <3B2480A3.D6B3E5D6@usa.net> Message-ID: On Mon, 11 Jun 2001, mixo wrote: > How does one find out the last error that occured or > the last exception that was raised? sys.exc_info() Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From menscher+python at uiuc.edu Fri Jun 8 17:26:28 2001 From: menscher+python at uiuc.edu (Damian Menscher) Date: Fri, 08 Jun 2001 21:26:28 GMT Subject: run function in background? References: Message-ID: <8qbU6.8833$ki5.122980@vixen.cso.uiuc.edu> Piet van Oostrum wrote: >>>>>> Damian Menscher (DM) writes: > DM> Is there a way to run a function in python in the background? > DM> Ideally I'd want something like > DM> def my_func(params): > DM> stuff here > DM> for i in range(10): > DM> print "starting a process" > DM> my_func(params) & > DM> where the & indicates that shouldn't stop the flow of the program, > DM> so the loop would continue and have all 10 go simultaneously. > Use threads. Thanks for the response. That worked (though it took me a while to figure out how to use threads). Thanks also to Fellowship CRC, whose response was perfect, but about 30 minutes too late. I'll quote it here for anyone else interested: import thread def my_func(params): print params for i in range(10): print "starting a process",i thread.start_new_thread(my_func,(i,)) Damian Menscher -- --==## Grad. student & Sys. Admin. @ U. Illinois at Urbana-Champaign ##==-- --==## www.uiuc.edu/~menscher/ Ofc:(217)333-0038 ##==-- --==## Physics Dept, 1110 W Green, Urbana IL 61801 Fax:(217)333-9819 ##==-- From cer at tutopia.com Sat Jun 30 00:23:49 2001 From: cer at tutopia.com (Cristian Echeverria) Date: Sat, 30 Jun 2001 00:23:49 -0400 Subject: Python compiler References: Message-ID: <9hjjrm$e7jm2$1@ID-44371.news.dfncis.de> On win32 check McMillan Installer (http://www.mcmillan-inc.com/builder.html) and Py2exe (http://py2exe.sourceforge.net/). These are not real compiler but are very close. "Eric Merritt" escribi? en el mensaje news:mailman.993870107.10231.python-list at python.org... > Hello All, > > I am new to python after having converted from java. > One of the problems I always had with java was the > lack of a native code compiler. Will python ever have > one of these? I have seen references to projects such > as py2c etc, but they all seem dead. Is there an > inherent problem in creating a compiler for python or > is it just very difficult. Unfortuanatly I am not a > big compiler guru though I would be willing to help if > I could. Just curious. > > > __________________________________________________ > Do You Yahoo!? > Get personalized email addresses from Yahoo! Mail > http://personal.mail.yahoo.com/ > From m.faassen at vet.uu.nl Tue Jun 19 16:32:18 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 19 Jun 2001 20:32:18 GMT Subject: where's laura? References: <3B2EF0D5.BA50ABF0@trispen.com> Message-ID: <9gocsi$i4a$1@newshost.accu.uu.nl> Gerrie Roos wrote: [nothing] Abducted by the PSU. The same thing happened to Moshe. I miss her too. :) I-suspect-she's-just-busy-ly yours, Martijn P.S. I miss Moshe too. :) -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From paulp at ActiveState.com Thu Jun 21 17:49:13 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Thu, 21 Jun 2001 14:49:13 -0700 Subject: ActivePython 2.1.0 build 211 References: <3B32026F.89DB4FD7@agere.com> Message-ID: <3B326BD9.B3D26B3E@ActiveState.com> Jim Gurnavage wrote: > > Paul, > > I believe there is a problem with the win32commc.pyd (DLL) in the 211 build for In case anyone else has this problem: win32commc.pyd doesn't actually come with ActivePython. It is very plausibly named but actually is unrelated to ActivePython. It is so unrelated that I don't know where it comes from and neither does Google or AltaVista. :) -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From mwright at pro-ns.net Mon Jun 18 16:52:34 2001 From: mwright at pro-ns.net (Mark Wright) Date: 18 Jun 2001 13:52:34 -0700 Subject: Is anyone using CGIHTTPServer on a non-Unix/Windows platform? Message-ID: I'm having problems getting it to work. I'm running python CGI scripts using the execfile() part of CGIHTTPServer (i.e. !has_fork and !has_popen2), and it works like a charm when I do a GET. But when I try to do a POST, the thing just hangs in telnet and I get the "Page could not be displayed" error in IE and a blank page in Mozilla. (Techinically, I am running on Windows, but I've commented out the popen2() section due to text/binary file conversion issues.) Is anyone else having this problem? The following script is an example of one that fails (but works fine in Apache): import os import sys import cgi # ---------------------------------------------------------------------- if __name__ == '__main__': # parse parameters form = cgi.FieldStorage() out_file = sys.stdout if os.environ['REQUEST_METHOD'] == 'POST': out_file.write('Content-Type: text/html\n\n') out_file.write("\n") out_file.write(" Did this work? \n") out_file.write("\n") # keys = os.environ.keys() # keys.sort() # for key in keys: # out_file.write("
" + key + ':' + cgi.escape(os.environ[key]) + \ # '\n') out_file.write("Did this work?\n") out_file.write("\n") else: out_file.write('Content-type: text/html\n\n') out_file.write("\n") out_file.write(" Did this work? \n") out_file.write("\n") out_file.write( """

try this out
""") out_file.write("\n") From jeff at ccvcorp.com Wed Jun 27 13:54:08 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 27 Jun 2001 10:54:08 -0700 Subject: PEP 260: simplify xrange() References: <3B398BBE.A2D455C9@darwin.in-berlin.de> <9hclc1$qv5$1@panix2.panix.com> <3B3A08B5.3C142546@darwin.in-berlin.de> Message-ID: <3B3A1DC0.3583E9D8@ccvcorp.com> Dinu Gherman wrote: > Aahz Maruch wrote: > > > > >PS: BTW, why not *add* something useful and make float > > > increments work "as expected" in range/xrange...? > > > > And how do you expect floating point increments to work? (Have you paid > > any attention to the extensive threads on FP over the past few months?) > > No, I haven't followed the discussion... but you asked > about an implementation; I'm using the one below. To make a long story short, the discussion regarding FP boils down to the fact that "1.0" cannot be exactly represented in FP. Every time you increment your "frange", you are introducing nasty rounding errors, and by the time you've done several thousand iterations, they're going to be very significant rounding errors. And the worst part is that there will be *no indication* of where the wrong answers are coming from unless you happen to monitor your frange index throughout a debugging run... and even then it'll only be clear if you know that the FP problem exists. Jeff Shannon Technician/Programmer Credit International From thomas at gatsoft.no Tue Jun 19 05:25:16 2001 From: thomas at gatsoft.no (Thomas Weholt) Date: Tue, 19 Jun 2001 09:25:16 GMT Subject: Extracting words from a string : *fast* Message-ID: <0UEX6.268$8H6.170349568@news.telia.no> Hi, I need to extract words from a string. This method will be used extensivly in a indexer so it needs to be as fast as possible. It needs to split words by case, numbers, spaces and chars like ,.-_/\*' etc. Returns a list of lower-case entries of the words found or a dictionary of were the words are keys and number of occurences are values. Ex. s = 'This is a.test for ThomasWeholt - magic42' print getWords(s) ----------------------------------------------------- ['this','is','a','test','for','thomas','weholt','magic','magic42'] The text to be processed are mostly small in size but can also be huge, etc. 1-10MB. Thomas From bos at hack.org Mon Jun 18 03:01:05 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Mon, 18 Jun 2001 09:01:05 +0200 Subject: list.sort() References: <3B2CEBF1.CCF5377D@hack.org> Message-ID: <3B2DA731.1BAA305E@hack.org> Martin von Loewis wrote: > Now, some people might expect sort and reverse to return a *new* > array. That would be more expensive in many cases. Plus, changing it > *now* is not appropriate: it would break code that expects that .sort > sorts inplace, whereas a method that returns a new object would not > sort the object itself. I'm aware that changing is not a good idea at all. How about adding two extra methods for sort/reverse, that actually returns the list instead of changes it inplace? I think changing the list in place is very unPythonic. -- Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From gustafl at algonet.se Sat Jun 2 08:45:51 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 2 Jun 2001 12:45:51 GMT Subject: Printing getopt.GetoptError message? Message-ID: I'm trying to print the GetoptError message that I get if I don't use the try-except construction, but it won't work: try: opts, args = getopt.getopt(sys.argv[1:], "c:d:h:") except getopt.GetoptError: print getopt.GetoptError.msg sys.exit(2) All I get is an empty string. What is wrong here? Regards, Gustaf Liljegren From piet at cs.uu.nl Mon Jun 11 07:04:17 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 11 Jun 2001 13:04:17 +0200 Subject: detecting idle processor References: Message-ID: >>>>> s_gherman at yahoo.com (Sorin Gherman) (SG) writes: SG> How can I use Python to detect when the processor is idle? You can't because the processor wouldn't be idle if your Python program is running. So you first have to define what you mean with "idle". SG> Or when the network traffic is idle, for a given computer? That is very much system dependent. SG> I need this to implement a background program. The easiest is probably to run your program at a low priority. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From disser at san.rr.com Mon Jun 4 15:07:38 2001 From: disser at san.rr.com (Dave Disser) Date: Mon, 04 Jun 2001 19:07:38 GMT Subject: streaming data with XML-RPC Message-ID: I have an application for which I would like to use xmlrpclib.py. However, I need to send large files over the network as well. I notice in RedHat's up2date program that the following is done for the client side (error handling omitted): s = getServer() pkgStream = s.up2date.package(getSystemId(), pkg) chunk = pkgStream.read(1024) ...more reading What is needed on the server side for this to work? Unless there's some serious magic in xmlrpclib, just opening a file handle and returning wouldn't work. --Dave From sholden at holdenweb.com Wed Jun 13 22:23:50 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 13 Jun 2001 22:23:50 -0400 Subject: Office's Access XP ODBC DBI from PythonWin References: Message-ID: "Dirk Leas" wrote in message news:mailman.992468723.17992.python-list at python.org... > Anybody luck working w/ DbiDate from query result? Check out the > following: > > >>> import dbi, odbc > >>> db = odbc.odbc('testAccess') > >>> cursor = db.cursor() > >>> cursor.execute('select * from person') > 0 > >>> rows = cursor.fetchall() > >>> rows > [(1, 'Joe Smith', ), (2, 'Mary Smith', > )] > >>> str(rows[0][2]) > '__builtins__\x00])\n\n\x00\x00\x00\xd0\xb2\x12\x1e' > > I'm running the latest of AS's Python with the Win32 extensions against > Office XP Access. > Has the Win32 odbc module been updated at all since 2.0? I have a feeling you might find it less than satisfactory for extended use - I've certainly had problems myself. Unfortunately the dbi.dbiDate object has a null __doc__,but I notice the dbi.py module requires mx.DateTime. Had you considered using mx.ODBC instead of ODBC? If you don't plan commercial use it is free, and I can certainly recommend it for ease of use. regards Steve -- http://www.holdenweb.com/ From kgmeyer at comundo.de Sat Jun 16 13:14:56 2001 From: kgmeyer at comundo.de (C. Meyer) Date: Sat, 16 Jun 2001 19:14:56 +0200 Subject: BUG? Unicode and Python 2.0 Message-ID: <9gg48t$8tkqu$1@ID-58571.news.dfncis.de> Hello, the file tkfiledialog.py from python/lib/lib-tk has some test code: if __name__ == "__main__": print "open", askopenfilename(filetypes=[("all filez", "*")]) print "saveas", asksaveasfilename() I tried it, but it won't work, if i select filenames with umlaut: C:\Programme\Python\Lib\lib-tk>python tkfiledialog.py open Traceback (most recent call last): File "tkfiledialog.py", line 105, in ? print "open", askopenfilename(filetypes=[("all filez", "*")]) UnicodeError: ASCII encoding error: ordinal not in range(128) The reason is (i think), that askopenfilename surprisingly returns unicode string instead of string. If functions return sometimes unicode strings, how should this be done? Is this a bug or a design problem, or do i misunderstand this? From prem at engr.uky.edu Tue Jun 5 17:55:40 2001 From: prem at engr.uky.edu (Prem Rachakonda) Date: 5 Jun 2001 14:55:40 -0700 Subject: Python Equivalent of Matlab's size() Message-ID: Hi, What is the Python equivalent of Matlab's size() function. I need to find the confirm the size of an reshaped array. Prem. From magic00666 at yahoo.com Fri Jun 22 14:05:33 2001 From: magic00666 at yahoo.com (S.K.) Date: 22 Jun 2001 11:05:33 -0700 Subject: Has anyone used UML? References: <9flodi$32m$1@brokaw.wa.com> <3b228485.13884244@news.laplaza.org> <3B250921.F9F1D571@bt.com> <9g5oml$ird$6@216.39.170.247> <3B27F193.DD94F852@bt.com> Message-ID: <437d313c.0106221005.234d81b1@posting.google.com> Hi, I have read the all messages of this thread, there is no mention of DOME from www.htc.honeywell.com/dome which is also a GPL program, runs on both linux and window. The package is a 9M zip file. Good documentations. Personally, I like it because, as a diagramming tool, it is small, simple, and fast. It looks we can define our own tool specs with the builtin extended R4 Scheme language and.... (I know nothing about it, and haven't got the the time to look into it yet). Then it would be very nice when methodology changes, or new one pops-up, or anytime I would like to create something of my own. > But they are all complex tools doing a very complex job > so they cost lots. Best tool for small projects is > a tool like Visio, DIA, SmartDraw etc. IMHO > > Alan G From aleaxit at yahoo.com Wed Jun 20 08:50:54 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 20 Jun 2001 14:50:54 +0200 Subject: Class destructors References: Message-ID: <9gq67q0kjb@enews1.newsguy.com> "Graham Ashton" wrote in message news:Se_X6.1458$h45.9288 at news.uk.colt.net... > I understand that Python doesn't have the equivalent of the DESTROY() > method in Perl, as the tutorial says: > > "There are no special constructors or destructors." > > Surely there is a way of executing some code before the garbage collector > destroys the object though? Can anybody give me some pointers? Special method __del__, already mentioned by several respondants, is really a finalizer, rather than a destructor. In the current version of Python, o.__del__() will be called when AND if o's refcount drops to 0 -- but it's *NOT* a language guarantee. If o is in a reference cycle, the whole cycle becomes un-garbage-collectable due to o.__del__'s existence. In other Python implementations (Jython, Python.NET, and possibly future Classic-Python implementations too), finalization might happen later, possibly MUCH later, than o becoming unreachable -- in other words, exactly as for any other language in a JVM or .NET world. I know it sounds unwieldy to people used to C++'s destructors (and in particular the nice way they work for objects of storage class auto), but there are good reasons for this. And Java's success shows it's anything but impossible to program WITHOUT relying on certainty of finalizers getting called. When you DO need to ensure finalization, well, that's what try/finally is for, in both Python and Java. > Specifically, I want to close a socket when I've finished with my object > without having to do so explicitly from with the program that uses the > object. Explicit is better than implicit. Use a try/finally. One day you'll be happy you did!-) Alex From wware at world.std.com Fri Jun 15 07:16:20 2001 From: wware at world.std.com (Will Ware) Date: Fri, 15 Jun 2001 11:16:20 GMT Subject: Python 2.0.1c1 - GPL-compatible release candidate References: Message-ID: Mike C. Fletcher (mcfletch at home.com) and several others wrote: > This is a GPL-compatible release, not a GPL release. Doh! Never mind. Seems I *should* go back on my meds, or try to read text at a rate more commensurate with my humble cognitive powers. > Forcing all extensions to be GPL-compatible is not something > I think Guido (or anyone) is really looking to impose on > extension writers. Strict-GPL fans would of course consider it a virtue. IANAL and all that, but I think it's possible to release a program simultaneously under multiple licenses, allowing a recipient to choose for himself which license he wishes to observe. This might offer the best of all worlds; the GPL fans could build a body of GPL-ware within which further derived works would be GPLed, and other-license folks could go off and do other things. -- -----------------------------------+--------------------- 22nd century: Esperanto, geodesic | Will Ware domes, hovercrafts, metric system | wware at world.std.com From sdm7g at Virginia.EDU Thu Jun 21 16:38:41 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Thu, 21 Jun 2001 16:38:41 -0400 (EDT) Subject: Properties in Python In-Reply-To: <3b31ebb9.553666@nntp.sprynet.com> Message-ID: On Thu, 21 Jun 2001, David C. Ullrich wrote: > On Wed, 20 Jun 2001 02:04:33 GMT, "Peter Caven" > wrote: > > >I'm sure that many people reading this newsgroup are aware that the C# > >(C-Sharp) language has a syntax for 'Properties' that allows a class > >implementor to hide the implementation of an instance's attribute behind a > >'get'/'set' interface. > > It's curious, the guy who wrote C# seems to be a fan > of Object Pascal, aka Delphi... (maybe there's a > simple explanation for that) > I believe that they guy microsoft hired to do C# is the same guy that did Delphi -- would that be a simple enough explanation ? -- Steve From tundra at tundraware.com Mon Jun 25 16:40:02 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 25 Jun 2001 20:40:02 GMT Subject: Is this a true statement? References: <8NuZ6.362378$oc7.42924874@news2.rdc2.tx.home.com> <3B3788A2.3BD1D672@tundraware.com> <9qMZ6.368197$oc7.44797813@news2.rdc2.tx.home.com> Message-ID: <3B37A15D.DF05A331@tundraware.com> Rainer Deyke wrote: > > > I still do not understand/agree with this line of reasoning entirely. > > Your reasoning is flawed. Perhaps, but thus far, I've only seen assertion to that effect, not proof. > > Interaction with the outside world is, by definition, *not* algorithmic. Nope. All computational activity is algorithmic. The thing that *causes* the input to be what it is may- or may not be guided by algorithm but insofar as a program sees input, it is algorithmic by nature. "Input" can be subtle. It can be a numeric value, a keystroke, the closing of a switch in a mechanical device, or simply a measure of time, but all these are meaningless (in our context) without algorithmic processing. > Consider this diagram of a typical computer program: > > Input -> Computation -> Output > > Only the "computation" part is algorithmic, and those who use the term > "Turing complete" generally only concern themselves with the computation Nope. Formally, an "algorithm" is something which when presented with a given set of inputs will always produce the same output. (This, BTW, is why Genetic Algorithms are a contentious case because given a particular input, a GA will NOT give the same results repeatably.) So, by the very definition of what an algorithm is and does, it embraces the notion of both input and output. > part. As I understand it, a Turing machine has the ability to input and > output single characters/numbers through a single input stream and a single Nope. This is only one kind of Turing Machine which is often used as a teaching tool. A Turing Machine may have as many inputs and outputs as you like, as many symbol types as you like, and move in as many directions as you like. It turns out, however, that *all* TMs are reducible to a 1-tape, two-symbol TM (a very deep theorem of Computer Science in its own right) and that is why this type of TM is typically taught first. > output stream. A Turing machine does *not* have the ability to display > graphics of any kind. There is the possibility that another machine turns > the output of the Turing machine into graphics, but then it is that machine, > not the Turing machine, which is generating the graphics. Nope. *All* computation (including graphics generation) is reducable to a Turing Machine. In your example, the machine that turns things into graphics is itself a TM (if it is a digital computer) or it is the end analog device which is irrelevant to this entire discussion. The computer that generates graphics on my video card is a TM. The math co-processor that does floating point is a TM. My word processing program is a TM. When I follow a set of directions for assembling something in a consistent and repeatable way, I am acting as a TM. ALL computation can be reduced to a TM - this is an essential theorem of Computer Science. > > > (Fine Point: There is a debatable point here about whether adaptive > > algorithms like those found in Genetic Programming are really formally > > "algorithms" at all because they do not behave consistently when faced > with > > he same input conditions, but that's way outside the scope of this > discussion.) > > All computer programs are deterministic. Any computer program that Nope. Not even close to true. The entire family of NP-Complete algorithms (Traveling Salesman, Knapsack Packing, et al) are NON-deterministic (that's what the 'N' stands for. > generates output O from input I will always generate output O from input I. > This is true for all things which are formally "algorithms". But this is not the same thing exactly as "deterministic". The Traveling Salesman problem meets your I/O criteria, but as I said above, it is a Non-Deterministic algorithm. See almost any book on algorithm complexity for an explanation of why this is the case. > > Now, back to the debate at hand. We've all agreed that some things > > are easier to do in C++ (yuck) than Python. Let's take the example > > of writing device drivers. Using today's language and syntax to > > handle interrupts in Python, you realistically have only a few > > choices: > > > > 1) Write a library in another language that implements > > interrupt handling and then give it a Python interface. > > > > 2) Have Python write out a set of machine code bits which > > are understood by the underlying implementation and > > hardware to be the correct handling of an interrupt. > > Only if the system has a writeable disk with sufficient empty space. This > is not a given. Well no it's not, but this is irrelevant to the discussion. Clearly, some implementations of any algorithm are more time/space efficient - Bubble Sorts run in O(n^2) but Heap Sorts run in O(n log n) yet both are still just sorting. The limitations of disk, memory, and CPU merely define how big a problem we can solve, or how fast we can solve it, not *how many* different kinds of problems we can solve, which is the debate here. For example, a machine with limited disk space can solve the same *set* of problems as a machine with Terabytes of disk, just much slower and less efficiently. The minimums necessary to compute everything which is computable were defined initially by Turing and later by Bohm and Jacopini and in no case was disk space, memory space, or CPU speed a foundational condition. As I said, these real-world constraints speak to how fast or how efficiently we can run a given algorithm, not how many *different* kinds of algorithms we can do. > > > 3) Add a native interrupt object to the language. > > > > 1) clearly takes us out of "pure Python" and is thus of no further > > interest (unless you actually want to *solve* this problem in the > > real world, in which case this is probably the best solution ;))) > > > > 2) Works just fine, but is kind of clumsy and unnatural to use. > > Note, however, that it is 2) that gives us the ability to do *anything* > > in Python which we can "do" in any other Turing-Complete language. > > > > 3) is where the rocks start to get thrown. If I do 3), have I "extended" > > the language to do something it could not previously? NO! I have > > implemented what I could already do with 2) in a more programmer-friendly > > manner, but I have not changed the net computational power of the > language. > > "Net computational power" is irrelevant in this context. If you say so. I thought this was the exact point of the debate: Can C++ and Python "do" the same things. i.e., Do they possess equivalent abilities to compute the same set of problems - Computational Power. -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From philh at comuno.freeserve.co.uk Fri Jun 29 14:22:19 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 29 Jun 2001 19:22:19 +0100 Subject: Augmented Assignement (was: Re: PEP scepticism) References: <6qn16r7i69.fsf@abnoba.intevation.de> <9hhu6701d5j@enews2.newsguy.com> <6qae2r71hd.fsf@abnoba.intevation.de> Message-ID: On Fri, 29 Jun 2001 16:13:29 GMT, Guido van Rossum wrote: >Bernhard Herzog writes: > >> Augmented assignment doesn't actually offer anything that couldn't have >> been done with explicit method calls, at least as far as in-place >> modification is concerned, because under the covers it actually is a >> method call. Explicit is better than implicit. > >Sorry, I don't understand why people can seriously argue *against* >augmented assignment. It just baffles me. What kind of Spartan >upbringing did you have? Scheme? Really, I just don't get it. This >was by far the most asked-for feature ever! And that quote "explicit >is better than implicit" quote is pretty tired by now. It can be used >against a whole lot of Python features. Indeed, the reductio ad absurdum of it is that all coding should be done in assembler, or at least, nothing more high-level than C. -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From tony at lsl.co.uk Tue Jun 19 06:03:27 2001 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Tue, 19 Jun 2001 11:03:27 +0100 Subject: Any other Python flaws? In-Reply-To: Message-ID: <003b01c0f8a7$15de2200$f05aa8c0@lslp7o.int.lsl.co.uk> Duncan Booth wrote: > BCPL Octal constants use '#', e.g. #177 and hex constants > are '#X', e.g. #X7F, so like the dangling else, the leading > 0 was an 'improvement' brought in post BCPL. Yes - BCPL is another of those languages that was (in various ways) much in advance of its descendants. > BTW, I'm not really so sad as to still remember that much > BCPL, I keep the BCPL book handy though in case of emergencies. Ah - mine is at home, which is why I couldn't look it up. ObPython: I find it interesting how many Python appreciators also fondly remember BCPL and Algol68 (one totally untyped, and the other, well, shall we say STRONGLY statically typed). Tibs -- Tony J Ibbs (Tibs) http://www.tibsnjoan.co.uk/ Which is safer, driving or cycling? Cycling - it's harder to kill people with a bike... My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.) From akuchlin at mems-exchange.org Thu Jun 14 16:35:44 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 14 Jun 2001 16:35:44 -0400 Subject: Any other Python flaws? References: <3B2918C1.8060906@erols.com> Message-ID: <3d1yomg5pb.fsf@ute.cnri.reston.va.us> "Edward C. Jones" writes: > Something like SWIG should be built into Python for wrapping code > written in other languages, especially C, C++, and FORTRAN. > Perhaps the output of some program-transformation code can be fed > into Boost.Python. That's a property of a particular implementation, and I'm only interested in issues with the language design itself, things that are equally problematic in different implementations such as JPython. If the interpreter dumped core twice in every three times it was invoked, that would not meet my definition of a wart. --amk From mwh at python.net Thu Jun 14 06:12:07 2001 From: mwh at python.net (Michael Hudson) Date: 14 Jun 2001 11:12:07 +0100 Subject: Need Help building COM server in python References: <844df35f.0106140116.5f706fcf@posting.google.com> Message-ID: michiel at htcs.nl (michiel) writes: > Hi, > > First of all, I'm a newbie, so my question may be simple. > > I have tried to make a simple COM object in python for the use in VB > or Visual FoxPro. Therefore I have used the tutorial for building a > COM server object in python. > > CODE CLASS: > > class HelloWorld: > _reg_clsid_ = "{D4FF29AD-BCDE-4FE2-9896-892D2EBB5180}" > _reg_desc_ = "Python Test COM Server" > _reg_progid_ = "Python.TestServer" > > _public_methods_ = ['Hello'] > _public_attrs_ = ['softspace', 'noCalls'] > _readonly_attrs_ = ['noCalls'] > > def __init__(self): > self.softspace = 1 > self.noCalls = 0 > def Hello(self, who): > self.noCalls = self.noCalls + 1 > return "Hello" + " " * self.softspace + str(who) These methods need to be indented into the class body. I've no idea if that's your only problem... > > if __name__=='__main__': > import win32com.server.register > print "Registering COM server..." > win32com.server.register.UseCommandLine(HelloWorld) Cheers, M. -- That one is easily explained away as massively intricate conspiracy, though. -- Chris Klein, alt.sysadmin.recovery From sill at optonline.net Sun Jun 17 00:31:07 2001 From: sill at optonline.net (Rainy) Date: Sun, 17 Jun 2001 04:31:07 GMT Subject: qt or gtk? References: <3B2B609B.285DCB06@web.de> Message-ID: On Sat, 16 Jun 2001 15:35:23 +0200, Dominic wrote: > > > Rainy wrote: > >> I want to learn python gui programming in linux. I think tk looks too ugly, so >> I narrowed down the choice to two main contenders, qt and gtk. Which of these >> has more complete and up-to-date python bindings? Are there other reasons >> to prefer one of these over another for python gui work? >> > > The QT toolkit is technically better (quality of code). So some time > has passed since I had compared them. But I do not know how good > or bad the bindings are. I suggest you should use the tk toolkit > it seems to have a good binding and comes with the standard > python distribution. And the TCL/TK toolkit has a high quality. > So TK would be best in my humble opinion, and QT second. > (QT is not completely free but that doesn't make it bad, actually > it's the best X- Toolkit for C++ programming.) > > Ciao, > Dominic Thanks for the answer, but I did mention that I don't like how tk looks.. I can't really pinpoint what is it that annoys me in tk, but somehow it looks like win3.1 to me, while qt and gtk look as good or better than window95+ widgets.. Does anyone else get this anachronistic 'feel' from tk? > > > >> >> -- >> "Your password must be at least 18770 characters and cannot repeat any of your >> previous 30689 passwords. Please type a different password. Type a password >> that meets these requirements in both text boxes." >> (Error message from Microsoft Windows 2000 SP1) > -- Delay not, Caesar. Read it instantly. -- Shakespeare, "Julius Caesar" 3,1 Here is a letter, read it at your leisure. -- Shakespeare, "Merchant of Venice" 5,1 [Quoted in "VMS Internals and Data Structures", V4.4, when referring to I/O system services.] From web.mail at lycos.com Tue Jun 12 16:30:50 2001 From: web.mail at lycos.com (Alan Green) Date: 12 Jun 2001 13:30:50 -0700 Subject: Recursive algorithms anyone? References: <1f0uhtgmhb0vlud6pof6i4mctqjdq8l2eu@4ax.com> Message-ID: <270c68fe.0106121230.7b5b0671@posting.google.com> "Nick Perkins" wrote in message news: > def additem(x): > if type(x) is type([]): return map(additem,x) > else: return x+1 I have to have a go at this too! Combining Nick's with Piet's... def add(x, k): if type(x) == type([]): return [add(l, k) for l in x] return x+k From me at nospam.com Fri Jun 1 13:46:15 2001 From: me at nospam.com (Bart Kowalski) Date: Fri, 1 Jun 2001 13:46:15 -0400 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> Message-ID: > > Did the OP mention anything about Windows? Then why the heck are you suggesting > > an extremely platform-dependent solution based on specific technologies from a > > specific vendor? > > That's what was surprising me as well. I wonder why nobody seems to know > Java3D, although it's not a new Java extension. Despite great platform support > (please read my other posts), it's easy to use (a high level 3D language). > > E.g.: I have a Quake3 Java model editor that uses Java3D. > You only need to download a plugin, which will store a few extra files into > your JVM directory, as well as a JAR file with the classes...that's all. As > long as your PC has OpenGL support (or in case of Windows, both OpenGL and > Direct3D is supported...whereby OpenGL looks better and is faster) nothing > speaks against good looking 3D graphic in Java. > > But most people prefer to use poor company solutions over open standards. Most > games use DirectX instead of OpenGL (if they'd use OpenGL, porting them to > other platforms would be a lot easier). > > Instead of getting browser companies to finally implement CSS2 (which can be > used together with JavaScript to make incredible text and graphic animations), > they rather force everyone to download a plugin for Flash. > > Instead of implementing a full VRML2 support, they will force people to > download a plugin for Shockwave3D. Instead of using PNG (open standard), they > use GIF. The list is endless ... > > People always use the first solution they can find, which is usually the one > most propagated. Those are usually commercial solutions, as companies earn > money by propagating them (meaning they make a lot of advertising for their > standard ... something that isn't done enough for open standards). That this > solution may not be the best that exists (there are often a lot better > solutions), that this solution belongs to a single company (and thus only they > have the power to alter or improve it and only they can write viewers for their > standard) and that this solution might be limited to the platform you are using > at the moment is simply ignored. > > I mean, how many webpages are there that say "You NEED IE 5.5 to watch this > page"? Too many. The fact that this means 50% (or more) of all surfers will > simply skip this page is a risk they are willing to take. More, actually. By doing such stupid things they are completely ignoring all of the Unix world and technologies far superior to anything that Windows users could ever dream of using. It's amazing how some people are so easily influenced by commercial propaganda. Bart. From just at letterror.com Fri Jun 22 04:14:17 2001 From: just at letterror.com (Just van Rossum) Date: Fri, 22 Jun 2001 10:14:17 +0200 Subject: PEP 255: Simple Generators References: <20010621083153.A19734@glacier.fnational.com> Message-ID: <3B32FE58.ACBC2401@letterror.com> Glyph Lefkowitz wrote: > Stackless is problematic, but I think that an implementation > similiar to that of generators could give us microthreads. > When I get back from vacation I'll write up a PEP; if you'd > like to give me a hand, feel free to drop me an email :) Neil Schemenauer wrote: > This would indeed be great news. I've spent quite a bit of time > thinking about this and the stackless approach is best solution I > can think of. It sure is. The other good news is that if "all" we want is microthreads and coroutines, and forget about multi-shot continuations, stackless would become quite a bit simpler, as quite a bit of code and quite a bit of the overall design of stackless came from Christian's desire for multi-shot (reusable) continuations. I think PEP 255 is extremely important for the future of stackless, as it exposes many similar issues to a much larger audience, but on a much smaller scale, in a more understandable way. In other words: understanding PEP 255 and it's implementation makes the things that stackless offers much less obscure, so there's a much better chance of Python adapting something not quite unlike stackless... Just From james at daa.com.au Thu Jun 7 06:00:08 2001 From: james at daa.com.au (James Henstridge) Date: Thu, 7 Jun 2001 18:00:08 +0800 (WST) Subject: [pygtk] HTML Widget In-Reply-To: <991902727.28037.1.camel@ZOOstation.cc> Message-ID: On 7 Jun 2001, Rob Brown-Bayliss wrote: > Hi > > I am looking for a workable html widget for Python useing Pygtk. > > I have tried pygme (for embeding mozilla) and this did work, but after > upgrading to mozilla 0.9 it has died. I spent several hours downgrading > mozilla to 0.81, but now it just segfaults. Did you get a new version of pygme or recompile the existing copy of pygme when upgrading mozilla? The mozilla embedding API is not stable, and changes occasionally (the binary API breaks more often than source API). > > Is ther a binding for gtkhtml? There is a gtkhtml binding included with gnome-python. It is not built by default though. Pass the --enable-gtkhtml switch to configure to build it. James. -- Email: james at daa.com.au WWW: http://www.daa.com.au/~james/ From geek+ at andrew.cmu.edu Tue Jun 12 09:20:12 2001 From: geek+ at andrew.cmu.edu (Brian E Gallew) Date: Tue, 12 Jun 2001 09:20:12 -0400 Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: <200106112007.f5BK7eW22506@odiug.digicool.com> <3B253031.AB1954CB@lemburg.com> Message-ID: <200106121320.f5CDKCvM032104@smtp5.andrew.cmu.edu> I'm against this for the following reasons: 1) will break a lot of existing CGI code 2) will break a lot of rfc822 code 3) will break just about every file-massaging program I've written (I'm a sysadmin, I massage a lot of files) 4) the behaviour of the print statement will become non-deterministic I really like Alex's output() (or whatever you want to call it) function and would use it in a heartbeat. I would also be much more interested in being able to supply a keyword argument to readlines() that would have it strip the EOL character(s). Just my $0.02. From lac at cd.chalmers.se Mon Jun 4 00:12:44 2001 From: lac at cd.chalmers.se (Laura Creighton) Date: Mon, 4 Jun 2001 06:12:44 +0200 (MET DST) Subject: I NEED to TEACH you something, QUICK! Message-ID: <200106040412.GAA12534@boris.cd.chalmers.se> This always happens. Trust me, been here many times. This is way more cool that congratulating each other on how smug, er, kind you are, but things are about to get nasty. What is wrong with this picture:? >You raped 10 women... only 1 >massacred children... 13 year olds are not children in my culture >And killed my Irish Setter on Saturday. YOU PIG YOU PIG IT WAS AN IRISH WOLFHOUND!!!! Now 12 people chime in with the complete Book of dogs detailing exactly how to tell the difference between those two breeds, and one person reports being scared by a wolf once. **********************end description of problem********* While by all means right action dictates that you catch lies and stomp them dead, I tell you _even_ _if_ _you_ _are_ _an_ _American_ the way to tell that you are doing the correct thing is not to count the number of points you made and the bigger the number the better. The largest number of lines is not the better either. Or the fewest. This is not about counting. You need to go after the evil that it is most necessary to get rid of, not the evil it is easiest to get rid of. In other words, prioritize. So you say cool, I will FIRST do the massacring and THEN .... Do you know that when I sit down with a piece of code and treat it with the focused anger that I reserve for all new things I have to fix that somebody left lying around broken they generally end up 30% smaller? and do more? and fail in a more graceful fashion? Here is the secret. If you implement the correct elegeant hack then you can often get 3 done for the price of one. So trying on the above I come up with `lack of discipline in an invading army produces undesirable consequences'. I think that is the elegant hack. But if you aren't quite up to that one `war is bad' might do. How about `suffering is bad'? Remember that one. Lots of things can be fixed with that one. By all means be more precise if you can, because precision is mega-cool, but do not confuse precision with `I did everything in the list in order' because that is thoroughness, another hot item but not what you were looking for. Note that sometimes when you try this, wonderful things happen: >War is bad. Huh? That's the whole point. That is exactly what Tolstoy was trying to say when he wrote that scene ... ***************** Notice, again, how we have avoided spending all our time drowning in dog statistics that we really don't have any immediate need for. =================BUT THERE IS STILL A BUG============== You could implement everything I said, and end up with: >war is bad You total moron. tell me something I didn't already know, you clueless jerk. ******************************************** I got a fix for this one as well. You may not line things up like rubber ducks and try to shoot them. Why does pearl suck? because Larry Wall did not understand the difference between thoroughness and eleagant a very long time ago and made a world-changing hack that blew up in his face. We all do this from time to time. Larry gets punished for this by having to trip over a gazillion idiots who worship him and say `why bother?' when he tries to back port more elegeance into the mess, which is a damn site harder than having started with things more er ... er ... go read Christopher Alexander. Read about `the quality which has no name'. Perl and C++ give major order wizard hacker types like me major pain because they don't have enough of this stuff. Now Guido is running a very cool hack. He is a major *chaos* wizard hacker type, I am almost certain from his writings and I hope he isn't too unhappy that I am refactoring this newsgroup a bit, but this always happens whenever I hang out any place for too long, and I still code python like a psychotic preying mantis, so I need to learn more stuff here. I think. But recall (those of you that were there oh those years ago) that I set up the 23rd (or 28th .. line printer paper is so lame) usenet site, utzoo, thus making usenet international, and given that many years spent writing every day in trying to get across the notion (better world to live in, having it, good idea) which is a tremendous _hard_ sell for the same reason that Eric Raymond is seriously improving the universe by teaching (the tools you use to run your life, being able to fix them when they break, good idea). I know that reading netnews is in general the defintion of waste of time, but we are desparate. Hej Twisted Matrix! Are you chaos wizards or order wizards or a mix? Have you figured out yet that your hacks will go to hell if half of you guys are doing `first we remove sufficient order in order to find the creative heart of chaos' while across the street `first we tidy up a bit, adding enough order until our eyes stop hurting'. Unless the hack is `make the coolest party in the universe' you are better off with seprate namespaces. This is the most important thing I learned in the last 10 years, so I hope you either think that it is valuable time saved, or that you are all rolling around the isles now laughing because you are way too cool for limitations like that, and my problem is that I am not twisted enough to make it work. Can I come over and talk sometime? Or is this a no-old-farts sort of thing? Laura From dgilbert at dsl.ca Mon Jun 4 20:26:15 2001 From: dgilbert at dsl.ca (David Gilbert) Date: Mon, 04 Jun 2001 20:26:15 -0400 Subject: Wadda ya mean it's not defined? Impossible Error? Message-ID: <3B1C2727.D9E746CB@dsl.ca> I'm getting what appears to be an impossible error. Here's a code snippet: def parseLogs(paths, custs): ipfRecord = re.compile("^([0-9]+)[ ]+([0-9]+)[ ]+([0-9a-z]+)([+-])") last = {} for i in range(len(paths)): # Create start times ... and so on. Here's the error snippet: File "../devel/ditty/bandsaw2.py", line 37, in parseLogs for i in range(len(paths)): # Create start times UnboundLocalError: local variable 'paths' referenced before assignment Just when should "paths" be assigned? Dave. From rjroy at takingcontrol.com Thu Jun 28 19:21:02 2001 From: rjroy at takingcontrol.com (Robert Roy) Date: Thu, 28 Jun 2001 23:21:02 GMT Subject: ARGH! Python2.1 build References: <3B39ED9F.9772B4E9@enabledventures.com> Message-ID: <3b3bbb76.1455712281@news1.on.sympatico.ca> On Wed, 27 Jun 2001 14:34:02 GMT, Glen Starchman wrote: > >Perhaps I am in my own little problem domain, but I like to strip nearly >every module out of the interpreter when I make builds for CGIs. Under >2.0 and below this was easy: comment nearly everything in Modules/Setup >and build. Easy. > >Now, under 2.1 we are using DistUtils and it appears to me that the only >way to *remove* a module from the build process is to add the module to >disabled_modules_list in setup.py. What if I want nearly every module >disabled? I *could* edit the Makefile directly, but it seems that there >should be a better way. Edit the makefile so it does not run Setup.py? Thats a one liner. You can still choose to statically link via the Modules/Setup Bob From xyzmats at laplaza.org Sat Jun 16 23:19:37 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Sun, 17 Jun 2001 03:19:37 GMT Subject: Solaris 8/x86: Build problems References: <3b2a7fc2.5552674@news.laplaza.org> Message-ID: <3b2c215f.791227@news.laplaza.org> On 16 Jun 2001 20:31:10 +0200, Martin von Loewis wrote: >xyzmats at laplaza.org (Mats Wichmann) writes: > >> The configure and build of the Python binary itself was completely >> clean, but as soon as the modules and distutils come into play, it >> blows up completely. I built Python 2.0 some months ago and didn't >> see this, but at that point distutils weren't involved, right? > >Right. > >> I'm suspecting the autoconfigure somehow is not giving the right >> magic incantation to distutils. > >It looks that way. With the details you gave, and without access to >Solaris x86, it is hard to tell what the problem is. Seeing the line >that was used to build structmodule.o from structmodule.c would help >enormously. > >My guess is that the -fPIC option is missing in that compile step. I'll go back and extricate that soon. Up until you get to distutils, all the compile steps spit out for easy capture, but once you get the the module building phase, it not longer automatically tells you what each step is doing. Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From nperkins7 at home.com Fri Jun 15 01:25:12 2001 From: nperkins7 at home.com (Nick Perkins) Date: Fri, 15 Jun 2001 05:25:12 GMT Subject: profile.run won't run! References: <24gW6.284794$oc7.18522490@news2.rdc2.tx.home.com> Message-ID: "Rainer Deyke" wrote in message news:24gW6.284794$oc7.18522490 at news2.rdc2.tx.home.com... > ... > import __main__ > __main__.solve_problem = solve_problem > profile.run('solve_problem') Thanks, the profiler actually runs, now! but... The broblem is that it seems not to actually execute the function... ..here is a simpler script that shows what i mean... --BEGIN SCRIPT import time, profile def solve_problem(): start = time.time() print 'SOLVING PROBLEM...' x=0 for i in range(10**3): for j in range(10**3): x = i + j print x print 'DONE in %.2f seconds'%(time.time()-start) from pprint import pprint as pp print 'globals:' pp (globals()) print print 'locals:' pp (locals()) print 'direct:' solve_problem() import __main__ __main__.solve_problem = solve_problem print 'profiled:' profile.run('solve_problem') --END SCRIPT ..which produces .. --BEGIN OUTPUT globals: {'__builtins__': , '__doc__': None, '__name__': '__main__', 'pp': , 'profile': , 'pywin': , 'solve_problem': , 'time': } locals: {'__builtins__': , '__doc__': None, '__name__': '__main__', 'pp': , 'profile': , 'pywin': , 'solve_problem': , 'time': } direct: SOLVING PROBLEM... 1998 DONE in 1.75 seconds profiled: 2 function calls in 0.029 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 0.000 0.000 :1(?) 0 0.000 0.000 profile:0(profiler) 1 0.029 0.029 0.029 0.029 profile:0(solve_problem) .. the profile.run(..) seems to have not actually called the function. There is no output (which might be re-directed, i suppose), but more importantly, not enough time elapsed for the fn to have been called. .. i am stumped. what is going on? From ajwms at visto.com Sun Jun 3 11:21:23 2001 From: ajwms at visto.com (Andrew) Date: 3 Jun 2001 08:21:23 -0700 Subject: xmlrpc Server Message-ID: <2f14b602.0106030721.441faa31@posting.google.com> I am somewhat a newbie at python programming, so please be gentle...:) I have been experimenting with xmlrpc servers programming with pythonware's xmlrpc library and by using the examples written by Dave Warner at: http://www.onlamp.com/pub/a/python/2001/01/17/xmlrpcserver.html Everything works well; until I start modifying the code :)... Here is a quick excerpt of what I've done (minus Dave's sample methods): ---------------------------------------------------------------- import SocketServer import xmlrpcserver import xmlrpclib class TestRequestHandler(xmlrpcserver.RequestHandler): #Override method: def __init__(self,a,b,c): self.x = 0 xmlrpcserver.RequestHandler.__init__(self,a,b,c) def call(self, method, params): print "Dispatching: ", method, params try: server_method = getattr(self, method) except: raise AttributeError, "Server does not contain XML-RPC procedure %s" % method return server_method(method, params) def add(self, method, params): self.x = self.x + int(params[0]) return "Sum = %s" % str(self.x) if __name__ == '__main__': server = SocketServer.TCPServer(('', 8000), TestRequestHandler) server.serve_forever() ---------------------------------------------------------------- I run the above code, then create a server object and run the add method tst = xmlrpclib.Server("http://localhost:8000") print tst.add(1) -->Sum = 1 cool, looking good. print tst.add(2) -->Sum = 2 huh? Shouldn't this value be 3? Why is self.x being re-initalized whenever I call the tst.add method? Shouldn't the __init__ method be called once setting self.x to 0 and then the add method simple adds to that value keeping track of the total? Am I completely missing the boat here? TIA, Andrew From whisper at oz.nospamnet Wed Jun 13 15:58:12 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 13 Jun 2001 19:58:12 GMT Subject: Working with paths with spaces in NT References: <9fol5s$9d3$3@216.39.170.247> <3b279eaf.5984935@news.laplaza.org> Message-ID: <9g8gkk$cir$1@216.39.170.247> [This followup was posted to comp.lang.python and a copy was sent to the cited author.] FWIW, here's my latest iteration. I'm rather proud of it as a first hack in Python beyond the "enter a few lines and run a few programs" level of investigation. I'd appreciate any critique, especially wrt to better python idioms for doing things (like the spaces/tabs kiudge noted below). This reminded me so much of my beloved Smalltalk without some of it's kinks! ------------------------------------------------------------ #BEWARE of line wraps! #NOTE: Set tabstops = 2 for best viewing! import os import dircache import re dirtotal = 0 filetotal = 0 doctotal = 0 basepath = "L:/languages/python" #WRAP ERROR next line! tabs = " " extensions = ["exe", "tar", "tgz", "gz", "zip", "py", "c"] docextensions = ["html", "htm", "pdf", "ps"] filetree = {} def buildtree(path, depth, tree): global dirtotal, filetotal, doctotal, tabs, extensions, docextensions, filetree base = "" ext = "" tree["filelist"] = [] tree["dircount"] = 0 tree["filecount"] = 0 currentdepth = depth depth += 1 spaces = tabs[0:(depth * 2)] # kludge - there's a better way, # but i'm not clear on how to use it. os.chdir(path) for name in dircache.listdir("."): if os.path.isdir(name) and name != "CVS": print spaces + name tree["dircount"] += 1 tree[name] = {} buildtree(name, depth, tree[name]) else: base, ext = os.path.splitext(name) if ext[1:] in docextensions: doctotal += 1 elif ext[1:] in extensions: tree["filecount"] += 1 tree["filelist"].append(name) currentspaces = tabs[0:(currentdepth * 2)] print currentspaces + path + ": Dirs:", tree["dircount"], "Files:", tree["filecount"] filetotal += tree["filecount"] dirtotal += tree["dircount"] os.chdir("..") return tree if __name__ == '__main__': print basepath filetree = buildtree(basepath, 1, filetree) print "Total Dirs:", dirtotal, "Total Files:", filetotal print "Total Doc Files:", doctotal ---------------------------------------------------------------------- Mats, you must have missed my apology to Tim the next day - who knows why cats arch their backs at shadows ;-) I also did get the hint about dir(".") and chdir(".."). Dave LeBlanc In article <3b279eaf.5984935 at news.laplaza.org>, xyzmats at laplaza.org says... > Tim wrote: > > >> If you look at your output very carefully, you'll discover this has > nothing > >> to do with spaces. After all, you chdir'ed to > >> > >> A Gentle Introduction to Ted Nelson's ZigZag Structure_files > >> > >> just fine. If that's not enough of a hint, try this starting in > some deep > >> directory tree that doesn't have any spacey names. > >> > >> don't-use-relative-paths-unless-you're-sure-you-know-where-you- > >> are-ly y'rs - tim > > And Dave replied: > > >Thank you Tim for the warm and friendly help without a hint of > >condescension - i'm sure it really encourages people new to python > > and even more those new to programming. > > > I missed what it was raised your hackles in Tim's comment. > > He pointed out that it wasn't a space problem since you've been in a > directory with spaces already. The more obscure reference is that you > never came out of that directory before trying to go on to the next > one. > > You need an os.chdir('..') somewhere. > > -- mats > > Mats Wichmann > > (Anti-spam stuff: to reply remove the "xyz" from the > address xyzmats at laplaza.org. Not that it helps much...) > From sebrosa at artenumerica.com Fri Jun 1 12:18:27 2001 From: sebrosa at artenumerica.com (Jose' Sebrosa) Date: Fri, 01 Jun 2001 17:18:27 +0100 Subject: Fwd: Tkinter: image handling: bug or feature? References: Message-ID: <3B17C053.323EEF7@artenumerica.com> johngrayson at home.com wrote: > > --- In python-list at y..., Jose' Sebrosa wrote: > > >> Hi, > >> > >> I just figured out that this code > >> > >> I like to use local names to everything I can (so the names are not > >>available when mainloop is called) > >> > >> Or I'm simplly messing it all... > > Yes, you're messing it up... :-) > > If you insist on using local variables, then python is happily > decrementing their reference count as your 'constructor' goes > out of scope and they get garbage collected... > > The convention is to make images instance variables. If you are > paranoid about seeing the variables, mangle their names: > > self.__secret_image = .... Thank's very much for your answer. But... Of course that when I write my_img = PhotoImage(file = 'my_image.gif' ) inside a function or method, the reference my_img gets discarded when the function exits. I understand that. The problem is that when I use this reference to define an option for a Label instance in Label(self, image = my_img, bg = 'yellow').pack() it should (at least I expected so) generate another reference to the same object. But surprinsingly it seems don't. This is quite different from what happen when I do the same with a text instead an image. The code ########################################################## from Tkinter import * # class TextIsNice(Toplevel): def __init__(self, master): Toplevel.__init__(self, master = master) my_txt = 'Text is nice!' Label(self, text = txt, bg = 'yellow').pack() # if __name__ == '__main__': TextIsNice(None).mainloop() ########################################################## works just fine, as I expected from Python usual behavior. So again, what's wrong with images? Maybe this has some relation with something special about PhotoImage: In the debuging procedure, when I understood the need of explicitly keep a reference to the image generated by PhotoImage, I tried this (which I thougth, naif me, to be the same as declaring the reference global): ########################################################## from Tkinter import * # my_img = PhotoImage(file = 'my_image.gif') # <-- GLOBAL !! # class NotSoFunny(Toplevel): def __init__(self, master): Toplevel.__init__(self, master = master) Label(self, image = my_img, bg = 'yellow').pack() # if __name__ == '__main__': NotSoFunny(None).mainloop() ########################################################## On execution Python presented me this traceback: Traceback (innermost last): File "", line 4, in ? File "/usr/lib/python1.5/lib-tk/Tkinter.py", line 1874, in __init__ apply(Image.__init__, (self, 'photo', name, cnf, master), kw) File "/usr/lib/python1.5/lib-tk/Tkinter.py", line 1825, in __init__ raise RuntimeError, 'Too early to create image' RuntimeError: Too early to create image So PhotoImage itself seems to need "something more". The only thing I can imagine is PhotoImage needing to have "something" defined in its environment, and that this "something" is silently defined by *others* (which looks poor style to me). So I tried ########################################################## from Tkinter import * # dummy_call_to_perform_magic_under_the_wood = Tk() # my_img = PhotoImage(file = 'my_image.gif') # <-- GLOBAL !! # class NotSoFunny(Toplevel): def __init__(self, master): Toplevel.__init__(self, master = master) Label(self, image = my_img, bg = 'yellow').pack() # if __name__ == '__main__': NotSoFunny(None).mainloop() ########################################################## and it worked "fine" (as far as we can say "fine" about voodoo code like this). So yet again, what's wrong with images? Thanks again, Sebrosa From BPettersen at NAREX.com Thu Jun 7 15:33:53 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Thu, 7 Jun 2001 13:33:53 -0600 Subject: getch() of Turbo C in Python? Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D43C@admin56.narex.com> > From: Anurag Ved [mailto:anuragved at vsnl.com] > > Hi all, > I am using the Python interpreter under Windows. When I execute a > Python script, the console window that opens up closes immediately > after the program terminates, leaving me no time to observe the > output. One solution is to append the program with > > raw_input('') > > But, this is certainly not elegent and moreover it requires the user > to press 'enter' rather than the preferred option of 'any key'. > > Is there something similar to the getch() function of Turbo C which > reads just one key from and returns immediately? import msvcrt msvcrt.getch() -- bjorn From s713221 at student.gu.edu.au Tue Jun 5 09:53:09 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Tue, 05 Jun 2001 23:53:09 +1000 Subject: Sourceforge break-in and Python 2.1 security References: <200106012116.XAA14986@boris.cd.chalmers.se> Message-ID: <3B1CE445.C77EE144@student.gu.edu.au> petro wrote: > > >These people need some really hard unsolved algorithms in the more > >mathematical disciplines or math itself to occupy their bored > >little minds. But those of us who have _got_ some unsolved > > No, these people need a small shovel and a large stable. Or just the shovel, correctly applied. > -- > http://www.apa.org/journals/psp/psp7761121.html > It is one of the essential features of such incompetence that the person so > afflicted is incapable of knowing that he is incompetent. To have such > knowledge would already be to remedy a good portion of the offense. > -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From jafo at tummy.com Sat Jun 9 05:08:01 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Sat, 9 Jun 2001 03:08:01 -0600 Subject: tummy compile Mandrake 7.2 In-Reply-To: <20010608.214013.1469262009.16325@K7.atl.mediaone.net>; from twofingersalute@atl.mediaone.net on Sat, Jun 09, 2001 at 01:37:10AM +0000 References: <20010608.214013.1469262009.16325@K7.atl.mediaone.net> Message-ID: <20010609030801.B1598@tummy.com> >line 246: Dependency tokens must begin with alpha-numeric, '_' or '/': %defattr(-, r >oot, root) I'm not really sure what this is. I'd appreciate it if somone could tell me -- it seems to be unique to Mandrake... I don't reall get what it's trying to say, but have had the same report from another Mandrake user of getting the same error. >BuildPrereq: expat-devel >= 1.1-3tummy >BuildPrereq: db1-devel >BuildPrereq: gdbm-devel > >already have gdbm-devel, got and installed db1 and db1-devel, no >clue as to expat-devel as Mr. tummy doesn't seem to install it. The stock RedHat expat RPM includes expat-devel. If your expat RPM includes the devel files in the main package, try removing the BuildPrereq above. Sean -- "McGuyver stole all his tricks from Dr. Who." Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From petro at bounty.org Mon Jun 4 04:10:06 2001 From: petro at bounty.org (petro) Date: Mon, 4 Jun 2001 01:10:06 -0700 Subject: Sourceforge break-in and Python 2.1 security In-Reply-To: <200106012116.XAA14986@boris.cd.chalmers.se> References: <200106012116.XAA14986@boris.cd.chalmers.se> Message-ID: >These people need some really hard unsolved algorithms in the more >mathematical disciplines or math itself to occupy their bored >little minds. But those of us who have _got_ some unsolved No, these people need a small shovel and a large stable. -- -- http://www.apa.org/journals/psp/psp7761121.html It is one of the essential features of such incompetence that the person so afflicted is incapable of knowing that he is incompetent. To have such knowledge would already be to remedy a good portion of the offense. From schmitt at num.uni-sb.de Thu Jun 21 08:15:21 2001 From: schmitt at num.uni-sb.de (Uwe Schmitt) Date: 21 Jun 2001 12:15:21 GMT Subject: String --> int References: <9gsl08$gsl$1@wanadoo.fr> Message-ID: <9gsogp$1go7a$1@hades.rz.uni-sb.de> Romain Guy wrote: | Assuming fsock is a File objet, when I do: | var = fsock.read(4) | I get a String. I'd like to convert it into an integer. I haven't found any | method for this so I built this one: | def _buildInteger(bytes): | if len(bytes) != 4: | return -1 | else: | return ord(bytes[0]) | ord(bytes[1]) << 8 | ord(bytes[2]) << 16 | | ord(bytes[3]) << 24 | It works perfectly but I'd like to use one internal to Python if possible... in the module string, there's a method atoi() "ascii to integer"... or do you want to convert a hex-string to its 10-base integer representation ??? yours, uwe. -- Uwe.Schmitt at num.uni-sb.de Universit?t des Saarlandes phone: +49 (0)681/302-2468 Geb. 36.1, Zi. 4.17, PF 151150 D-66041 Saarbr?cken http://www.rocksport.de http://www.rocksport.de/first_ride.mp3 From nhodgson at bigpond.net.au Tue Jun 19 08:16:52 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Tue, 19 Jun 2001 12:16:52 GMT Subject: VI References: <9g9f1v$7oqr5$1@ID-11957.news.dfncis.de> <9gaul7$mth$2@brokaw.wa.com> <52e5ab5f.0106182325.4d1fe0d0@posting.google.com> Message-ID: Michael Robin: > I just downloaded vim - wow! (I'm going to catch up on vim in the > c.l.p archives and see what she can do python-wise. Don't suppose > there's a VI mode for Scite, PythonWin or Komodo??) No VI modes although Archaeopteryx have an EMACS mode implemented over Scintilla in their Wing IDE. Neil From new_name at mit.edu Fri Jun 29 14:05:19 2001 From: new_name at mit.edu (Alex) Date: 29 Jun 2001 14:05:19 -0400 Subject: [TO]What's the big deal with EJB? [Re: PEP scepticism] References: <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> Message-ID: > Instead people write about how convenient CPAN makes it to find > modules, or how useful the XML modules are, or how EJB lets them write > elaborate business systems. What's EJB got going for it, anyway? Alex. From emile at fenx.com Sun Jun 24 20:36:35 2001 From: emile at fenx.com (Emile van Sebille) Date: Sun, 24 Jun 2001 17:36:35 -0700 Subject: Is this a true statement? References: <3b34939b.410758@nntp.sprynet.com> <3b35ed3b.1401529@nntp.sprynet.com> <3b360fba.10233292@nntp.sprynet.com> Message-ID: <9h61aa$bg7h5$1@ID-11957.news.dfncis.de> I hadn't considered the possibility of a "deeply embedded" python solution, but it certainly has possibilities. Anyone got a virally infected copy of windows os source code to play around with? Hoping-the-evil-empire-police-have-a-sense-of-humor-ly y'rs, -- Emile van Sebille emile at fenx.com --------- "Grant Edwards" wrote in message news:slrn9jd1ki.mo.grante at tuxtop.visi.com... > On Sun, 24 Jun 2001 13:29:24 -0400, D-Man wrote: > > >When I read the original question I got the impression that > >"write a device driver in Python" meant "A person sits down at > >a console with a text editor, writes some Python code that > >implements the device's spec in terms of the driver API > >specified by the kernel". > > That's what the author meant, and what everybody understood > (with the possible exception of David Ullrich). > > One could use a "deeply embedded" Python bytecode interpreter > running inside the kernel to allow the user to write a driver > in Python. It would take a fair amount of work, but I don't > think it would be particularly difficult -- at least under > Linux. People have already a lot of the requied work in order > to run a Python interpreter on embedded systems. > > Sounds like a good MS project to me... > > -- > Grant Edwards grante Yow! - if it GLISTENS, > at gobble it!! > visi.com From bill-bell at bill-bell.hamilton.on.ca Sat Jun 23 16:23:38 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Sat, 23 Jun 2001 16:23:38 -0400 Subject: adding instance methods after instantiation In-Reply-To: <993310679.424.77410.l7@yahoogroups.com> Message-ID: <3B34C28A.23673.1E1CC8@localhost> "Chris Gonnerman" wrote, in part: > From: "Skip Montanaro" > > Lee> Is there some way to make m2 an instance method so that it > > will Lee> automatically get passed c1 as its first argument? > > > > Check out the instancemethod function of the new module. > > Here is code based on Lee's sample: > > ###################################################### > ### adding an instance method after the fact > import new > > class c: > def __init__(self): > self.a1 = 1 > def m1(self): > self.a2 = 2 > > def m2(self): #note, outside of class c definition > self.a3 = 3 > > c1 = c() > c1.m2 = new.instancemethod(m2, c1, c) > > c1.m2() > print c1.a3 Although 'a3' may appear to act as a method of instance 'c1' unfortunately not all of the properties of 'c1' are available within 'm2'. For instance, if the definition of 'm2' is replaced with def m2(self): self.a3 = 3 * self.a2 the Python interpreter complains that, "AttributeError: c instance has no attribute 'a2'". From m.faassen at vet.uu.nl Sat Jun 30 21:25:30 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 1 Jul 2001 01:25:30 GMT Subject: Is this a true statement: Part II References: <9hiifr$sjs$1@taliesin.netcom.net.uk> Message-ID: <9hlu6a$gfg$4@newshost.accu.uu.nl> MDK wrote: [snip] > Why is C++ awful; what's wrong with it? While I don't agree C++ is awful, I do agree there's plenty of things wrong with it. The very strained syntax for instance that tries to be compatible with C and still attempts to offer completely different paradigms of programming (OO, generic). Here's a discussion on C++ from a Python perspective for your amusement: http://www.pythonic.org/users/jh.twistd/python/moin.cgi/CeePlusPlus Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From bwalker at earth1.net Mon Jun 25 17:32:18 2001 From: bwalker at earth1.net (Bill Walker) Date: Mon, 25 Jun 2001 17:32:18 -0400 Subject: Python for pocket pc? Message-ID: Has anyone ported python to the Pocket PC? The Windows CE version on the Python page does NOT work, wont install -- wrong processor I think. From gbreed at cix.compulink.co.uk Fri Jun 8 05:43:53 2001 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: 8 Jun 2001 09:43:53 GMT Subject: How do I serve an image from a python script? References: <3B2039DB.8884C4B4@yahoo.com> Message-ID: <9fq6op$dnh$1@plutonium.compulink.co.uk> In article <3B2039DB.8884C4B4 at yahoo.com>, haaserd at yahoo.com (haaserd) wrote: > Hi, > > I am trying to serve an image from a Python script using Apache under > Windows. My simple HTML statement: > > a picture > > ...and my simple script: > > #!c:/Python20/python.exe > import sys > > def pix(): > n = 'c:/My Pictures/Sample.jpg' > p = open(n,'rb') > apix = p.read() > p.close() > sys.stdout.write("content-type: image/jpeg\n\n") > sys.stdout.write(apix) > sys.stdout.flush() > > if __name__ == '__main__': > pix() I've found this script to work on IIS: import cgi import sys, os input = open(r'absolute.filename.gif','rb') output = os.fdopen(sys.stdout.fileno(), 'wb') output.write('Content-Type: image/gif\r\n\r\n') output.write(input.read()) input.close() # don't close stdout! The only important difference with yours is that I'm using \r\n instead of \n. I think that os.fdopen stuff is wank, but worth a try if all else fails. > As you can see I am ignoring the CGI fields for the moment and am just > trying > to serve up an image. Through debugging statements that I have > removed, I > know the program crashes on the statement > sys.stdout.write(apix) > if the picture is over 200,000 bytes. That's above what I was testing with, hope it isn't too big a problem. Perhaps writing out the file in chunks will fix it. > On small images (10k), the script runs to completion, but no image > appears. > What am I doing wrong? When you say no image appears, does that mean nothing's being sent from the server? You can test this by changing the MIME type to text/plain (and perhaps not using IE) so you'll see some garbage appear if it's working. Anyway, I expect what you're doing wrong is not setting binary output. That would correlate with your not using the correct line termination characters. So add a -u to the command line, however that's specified. If it's that magic line at the top of the file, make it #!c:/Python20/python.exe -u Graham From m.faassen at vet.uu.nl Wed Jun 6 18:10:27 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 6 Jun 2001 22:10:27 GMT Subject: Vaults of parnassus not accepting new submissions? References: Message-ID: <9fm9oj$d92$4@newshost.accu.uu.nl> William Annis wrote: > sill at optonline.net (Rainy) writes: >> I tried to submit a program to vaults of parnassus, and it doesn't >> show up (it's been about a week). I also didn't get reply to my >> email. What's the story here? Is there some secret illuminati rite >> of passage to get a submission accepted there? :-) > Nope. I don't know the mechanism by which new entries are > verified, but it does sometimes take a week - or a bit longer - for my > updates or new code to appear. It always does eventually. > I assume the maintainer has a real job, too. :) The maintainer has a real job, and the mechanism is human mediated. He's been rather busy lately too. He's a nice guy however, and your stuff should eventually show up. There are no known secret PSU rites, as far as I know. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From tim.one at home.com Sun Jun 10 01:49:02 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 10 Jun 2001 01:49:02 -0400 Subject: extracting hex mant+exp from double? In-Reply-To: <000301c0f16e$f66a92d0$a9807018@cr706570a> Message-ID: [Mike C. Fletcher, after staring at >>> math.frexp(.1) (0.80000000000000004, -3) >>> m = _[0] ] > It's a bleeding anonymous magic variable man! Who let that into the > language! The variable is _magic_ I say. Wizardry! Sorcery! Appearing > without explicit assignment! > Pact-with-the-devil-and-dancing-at-midnight-curses-and-hexes! > Spawn-of-PERL! > Magic, I say! > > [I spent 2 minutes trying to figure out why you were translating 0, what > language you were using (base-2-eese?), and what special meaning 0 had > for translation tables. How did I miss something so... icky... > getting added?] > > Ick, > Mike Hunting this down in CVS, Guido added it in ceval.c, Revision 2.64.2.6, on Thu Apr 28 12:51:01 1994 UTC. I agree it's *so* un-Pythonic that Python really wouldn't be Python without it . practicality-beats-purity-ly y'rs - tim From jason-dated-993596726.c8fd34 at mastaler.com Mon Jun 18 19:05:25 2001 From: jason-dated-993596726.c8fd34 at mastaler.com (Jason R. Mastaler) Date: 18 Jun 2001 17:05:25 -0600 Subject: Redhat 7.1 and Python 2.1 In-Reply-To: (chat@linuxsupreme.homeip.net's message of "14 Jun 2001 15:44:22 -0500") References: <20010524235013.K690@xs4all.nl> Message-ID: chat at linuxsupreme.homeip.net (Chad Everett) writes: > >Apparently what they meant was that a module built for python on Red > >Hat Linux 7.x needs to work on all 7.x releases. Thus, the primary > >python can't be upgraded during the cycle. > > And the reason they don't ship with both Python 1.5.2 and Python 2.1 is? Because people would expect modules etc. for 2 versions of python, not just one. They might do this eventually, but not in the near future. -- (TMDA - http://tmda.sourceforge.net) (Python-based SPAM reduction system) From paul at svensson.org Sat Jun 23 08:44:32 2001 From: paul at svensson.org (Paul Svensson) Date: 23 Jun 2001 12:44:32 GMT Subject: PEP 255: Simple Generators References: <9h0crt$rq6$1@slb1.atl.mindspring.net> Message-ID: <9h22vg$jg8$1@newsy.ifm.liu.se> "Andrew Dalke" writes: >Carsten Geckeler: >>So Test is called like a function and returns an instance. But why make a >>different syntax ("class") for defining it? Just because it returns an >>instance instead an integer or another object? According to your >>argument, "def" would be fine. > >There isn't quite enough information to distinguish between at >least some class definitions and function definitions without the >use of a keyword. Consider > >>>> class SuperTest:. >... pass. >... >>>> def Test(SuperTest):. >... def __init__(self, spam):. >... self.spam = spam. >... def __str__(self):. >... return str(self.spam) >>>> t = Test("eggs") >>>> str(t) >'None' >>>> > >Changing the 'def Test' to 'class Test' changes the >entire meaning of the code. Of course -- as would changing to 'gen Test'. Consider an alternate universe, where "def" is used to define all of classes, functions, and generators. It's easy to tell one from the other: Generators use "yield", functions use "return", classes use neither. Obviously, someone decided that in the case of def/class, this was not a good idea. How is def/gen different ? Try writing a generator that always yields a fixed result; in some cases an empty list. Which of these would you like to explain to a newbie ? --------------------------------------- def one(): gen two(): yield 1 yield 1 yield 2 --------------------------------------- def empty(): gen empty(): if 0: pass yield --------------------------------------- def empty(): def empty(): return iter(()) return () --------------------------------------- /Paul From sabren at manifestation.com Wed Jun 20 00:45:54 2001 From: sabren at manifestation.com (Michal Wallace) Date: Tue, 19 Jun 2001 23:45:54 -0500 (CDT) Subject: How do I access the last "un-caught" variable in the interpreter? In-Reply-To: <39503ed5.0106191912.5b054b42@posting.google.com> Message-ID: On 19 Jun 2001, Dan Moskowitz wrote: > Pretty simple question: > > >>> 2+2 > 4 > >>> # can i access the 4 if i didn't catch it in a var? > > Is there some variable for the last result returned from the > interpreter? I thought that I used to know how to do it, but I've > forgotten. Anyone know? The magical underscore. ONLY works with the interpreter though. >>> 2+2 4 >>> _ 4 >>> Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.net www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From casevh at home.com Fri Jun 15 02:28:02 2001 From: casevh at home.com (Case Van Horsen) Date: Fri, 15 Jun 2001 06:28:02 GMT Subject: SMNP Interface(s)? References: Message-ID: I use pysnmp extensively (written entirely in Python) and am aware of yapsnmp (a wrapper for net-snmp, was ucd-snmp). Both are available on sourceforge. Case Van Horsen "Benjamin Schollnick" wrote in message news:junkster-C7253B.20553314062001 at typhoon1-3.nyroc.rr.com... > > I just checked over at the Vaults & couldn't find any, does anyone know > of any SMNP modules for python? And of course, where to find them? > > - benjamin From machin_john_888 at hotmail.com Tue Jun 12 01:59:18 2001 From: machin_john_888 at hotmail.com (John Machin) Date: 11 Jun 2001 22:59:18 -0700 Subject: PEP 259: Omit printing newline after newline References: Message-ID: <92ae279c.0106112159.27ebedee@posting.google.com> Guido van Rossum wrote in message news:... > Please comment on the following. This came up a while ago in > python-dev and I decided to follow through. I'm making this a PEP > because of the risk of breaking code (which everybody on Python-dev > seemed to think was acceptable). > > --Guido van Rossum (home page: http://www.python.org/~guido/) > > PEP: 259 > Title: Omit printing newline after newline > Version: $Revision: 1.1 $ > Author: guido at python.org (Guido van Rossum) > Status: Draft > Type: Standards Track > Python-Version: 2.2 > Created: 11-Jun-2001 > Post-History: 11-Jun-2001 > Is this message forged? Is it still April 1 out there? Have I stumbled into the comp.lang.parrot newsgroup? If all answers are "no", than all I can do is quote the advice given by Oliver Cromwell in a letter to the General Assembly of the Church of Scotland: "I beseech you, in the bowels of Christ, consider you might be mistaken." From dnew at san.rr.com Mon Jun 4 13:04:10 2001 From: dnew at san.rr.com (Darren New) Date: Mon, 04 Jun 2001 17:04:10 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> <3B1A82DD.C4D78472@san.rr.com> <9fe2g302841@enews2.newsguy.com> <3B1AE07F.CEDA4A3A@san.rr.com> <9fflo812q4r@enews2.newsguy.com> Message-ID: <3B1BBF8C.DFE4A5C2@san.rr.com> Alex Martelli wrote: > So that the randomness of an existing system can suddenly > change if somebody dies, for example? Because, e.g., part > of the information about the system was only "available" by > asking him (he had memorized it) Oh, and no, if he'd memorized it, then you could in theory dig him up and examine the neurons to figure out what he thought. Or you can just examine the existing system. If it works, the mechanisms of its working are there to look at. If the information was ever there at all, you can still get to it. Just because you don't know *how* doesn't mean it's impossible to learn. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. This is top-quality raw fish, the Rolls-Rice of Sushi! From tim.one at home.com Fri Jun 1 17:02:38 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 1 Jun 2001 17:02:38 -0400 Subject: win32 libs/Python21.lib In-Reply-To: Message-ID: [Robin Becker] > This quote appears in a recent Zope article by brian > > http://www.zope.org/Members/Brian/Misc/ExtensionBuilder/ExtensionBuilderUpda te-053101 > > ... The version [of .lib] that comes with Python2.1 does not > appear to be the correct one for building win32-x86 libraries. > I have been using this OK with VC++ 6.0 and have noticed no > problems, but what should I be worried about? Nothing, as far as I've been able to determine. Brian appears to be having a problem unique to his box, but we haven't yet figured out exactly what. From mwh at python.net Sun Jun 10 13:50:04 2001 From: mwh at python.net (Michael Hudson) Date: Sun, 10 Jun 2001 18:50:04 +0100 Subject: Use Jython to make true executable? In-Reply-To: References: Message-ID: On 10 Jun 2001, Carl Fink wrote: > In article , Michael Hudson wrote: > > > This is very unlikely to speed things up as much as you expect. I've > > never produced accurate numbers, but I'm fairly sure Python's runtime > > is dominated by locating applicable methods, not the dispatch loop in > > ceval.c. If you could analyse a program sufficently to compute (some > > of) these methods at compile time, *then* you might start to see a > > real speed up (especially if this let you unbox some integers & > > floats). > > Yeah, but Jython/gcc wouldn't involve ceval.c at all, would it? I > mean, presumably gcc would compile the methods themselves, and in an > optimized manner. > Congratulations, you have just missed the point! To be fair, I probably wasn't all that clear. What I was claiming (admittedly without proof) was that if you execute, say, d['bob'] = 'bar' for some dictionary d, a significant amount of the execution time is spent by PyObject_SetItem figuring out that d is a dict, and so that PyDict_SetItem should be called, and that this function has to work out that 'bob' is a string, and so how it should compute it's hash & possibly how to compare this to other keys in the dict, etc. Speaking roughly; this isn't exactly what goes on inside the interpreter. There will also be the time it actually takes to insert an item into a dict, and the time spent dispatching opcodes. What I was trying to say is that the dispatching opcodes time is only part of what makes Python slower than C. You can compile the methods as optimally as you like and eliminate the opcode dispatch, and Python will stay slower. Mind you, I don't know how Jython works, so maybe if you use gcj/Jython you have already eliminated the opcode dispatch - and you still get slower code (in general, obviously) than C. Cheers, M. From sholden at holdenweb.com Mon Jun 18 18:18:19 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 18 Jun 2001 18:18:19 -0400 Subject: Newbie Help on ODBC & Apostrophes References: <0zuX6.276651$eK2.57158115@news4.rdc1.on.home.com> Message-ID: The preferred way to perform operations of this nature is to use dynamic SQL. In this technique you put "parameter markers" in your SQL to represent the substitutions you intend to make, then you pass the SQL statement to cursor.execute() with an additional argument, which is a tuple containing the data you want to substitute. In this way your first example would become: myCursor.execute("SELECT * FROM MyTable WHERE Name=?", ("O'Brien",)) and your second myCursor.execute("INSERT INTO MyTable values (?)", ("Glenn",)) The cursor performs any escaping required. However, if your statements are fixed then parameterisation might seem to be an overcomplication. Your second example is valid SQL, but your first would need to become: myCursor.execute("SELECT * FROM MyTable WHERE Name='O''Brien'") In other words, doubling the quotes escapes them, and SQL treats two adjacent single-quotes inside a string constant as a single single-quote. In the general case where you are dealing wiht arbitrary strings bound to names, you can use the string replace() method to replace each single quote with two before you use the string inside a SQL statement. Hope this helps regards Steve -- http://www.holdenweb.com/ "Glenn A. Hockley" wrote in message news:0zuX6.276651$eK2.57158115 at news4.rdc1.on.home.com... > Hi, > > I have a question that probably has a very simple answer. I am trying to > use an Access database via the PythonWin ODBC modules to store a list of > names. I get these names via a form on a web page through CGI. My problem > lies with a name with an apostrophe in it, such as O'Brien for example. In > this case, the ODBC statement doesn't seem to work. > > For example, if I try to do the following: > > myCursor.execute("SELECT * FROM MyTable WHERE Name='O'Brien'") > > it obviously doesn't work. However, the name is retrieved from the web site > and is automatically insterted into this string. > > From what I have read, to use a string in an ODBC execution statement > requires that it be surrounded by single quotes. For example: > > myCursor.execute("INSERT INTO MyTable values ('glenn')") > > So is there a way to make it so that if the user enters name with an > apostrophe, that this apostrophe doesn't cause my program to crash, and that > the name is added to the database with the apostrophe in it? > > Hopefully that makes sense... > > thanks > > > > From loewis at informatik.hu-berlin.de Sat Jun 16 14:26:38 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 16 Jun 2001 20:26:38 +0200 Subject: get class instance from C++ extension? References: <8kiW6.41$%3.2442@news3.dion.ne.jp> Message-ID: "Toshiya Kawakami" writes: > ### this is ordinary way to get instance of class c1 as x. > x = c1() > ### I want to call C++ extension and get calss c1 instance to y > y = myext.meth1( 5, 6, 7.2 ) > ### and want to print attributes of the got y. [...] > return Py_BuildValue( "i", 0 ); // <--- this is not what i want to do First of all, you should stop using Py_BuildValue in cases like this; this example would better use PyInt_FromLong. In general, you do Python things in C the same way as in Python. To create an instance of c1, you need to *call* c1. So your code should read c1 = ... // lookup c1 x = PyObject_CallFunction(c1, "()"); Regards, Martin From jkraska1 at san.rr.com Wed Jun 20 21:56:53 2001 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 21 Jun 2001 01:56:53 GMT Subject: Any other Python flaws? References: Message-ID: >The GPL can not infect your non-GPLed software just because you use >GPLed software in your project -- This isn't correct. For example, RMS quite clearly states in his FAQ about the GPL that dynamically linking with GPL libraries constitutes a derived work. Under the GPL, permission to generate a derived work is only granted if one agrees to make the derived work Free Software according to the definition and license thereof under the GPL. See http://www.gnu.org for more information. C// From aleaxit at yahoo.com Fri Jun 29 09:00:40 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 29 Jun 2001 15:00:40 +0200 Subject: Augmented Assignement (was: Re: PEP scepticism) References: <6qn16r7i69.fsf@abnoba.intevation.de> Message-ID: <9hhu6701d5j@enews2.newsguy.com> "Bernhard Herzog" wrote in message news:6qn16r7i69.fsf at abnoba.intevation.de... > Carsten Geckeler writes: > > > As mentioned above, for tuples the "+=" is completely natural, but not for > > lists. > > Funny, I mostly see it exactly the other way round. += modifies the left > hand side in place, so it's natural for a list, but not for a tuple. > > I think the main problem (in as much as there actually is a problem) is > that whether augmented assignment rebinds the left hand side depends on > the type of object, i.e. whether the object implements the appropriate Right! I think the main advantage (in as much as there actually is an advantage) is that whether augmented assignment rebids the left hand side depends on the type of object. i.e. whether the object implements the appropriate methods. This is called *polymorphism* and is a concept of *HUGE* power. > methods, which is very different from normal assignment which always > rebinds. Do you consider: fee.fie = foo and/or fee[fie] = foo examples of "normal assignment"? Neither "always rebinds" -- it all depends on the type of object, i.e. whether the object (fee) implements the appropriate methods (__setattr__, __setitem__). Augmented assignment, like attribute assignment and item assignment, is polymorphic. Plain assignment to an _unqualified_ LHS isn't, so maybe *THAT* one is the "odd man out"?-) Alex From paulp at ActiveState.com Wed Jun 20 17:26:12 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Wed, 20 Jun 2001 14:26:12 -0700 Subject: PEP 255: Simple Generators References: <9gnv2o$its$1@nntp6.u.washington.edu> Message-ID: <3B3114F4.12A3D3BC@ActiveState.com> David Bolen wrote: > > "Russell E. Owen" writes: > > (...) > > Since a generator is very different than a function, why not mark it as > > such right up front? > (...) > > I agree that revealing the internal implementation is bad. I disagree > > that return is reasonable, though it is much less of a concern if a > > generator doesn't look like a function right up front. > > But isn't a generator really just a function that is returning an > iterator? That is, why is it "very" different from a function, > internal implementation aside, which we agree it's not necessary to > reveal. Those who think that generators should have a special declaration syntax are not worried about how the generator looks to the caller. They are worried about people stumbling upon the generator feature of Python without understanding that a single keyword in the middle of a function can totally change the interpretation of that function. It changes what happens when the function is first called, what the function can return, when it can return it, and what can happen in the middle of its execution (i.e. arbitrary code elsewhere in the program could be running). We think that such a radical change in semantics for the code block should be labelled with something stronger than a buried keyword. And we are discussing this on the python-iterators list. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From gerson.kurz at t-online.de Fri Jun 8 13:44:45 2001 From: gerson.kurz at t-online.de (Gerson Kurz) Date: Fri, 08 Jun 2001 17:44:45 GMT Subject: Catching Errors References: <3B20E042.DA0AF3C1@usa.net> Message-ID: <3b210ea6.15213125@news.t-online.de> On Fri, 08 Jun 2001 16:25:06 +0200, mixo wrote: > >How can I catch errors that I are usually written to standard output? I use this to display errors that my CGI BIN raises on the website itself (and not in apaches logfile), so the situation is very similar. class myerrorhandler: def write(self,x): print '',x,"
" import sys output = myerrorhandler() sys.stderr = output All you need to do is implement your own write() func. From trace at reinventnow.com Wed Jun 13 11:15:11 2001 From: trace at reinventnow.com (tracy s. ruggles) Date: Wed, 13 Jun 2001 15:15:11 GMT Subject: Problems installing MySQLdb on a VPS Message-ID: Has anyone out there had experience installing new packages on a VPS (virtual private server)? I've posted a few question about trying to install MySQLdb and haven't received any response... Are there any tricks to installing on a VPS? All of the code in distutils/sysconfig.py spits out wrong directory paths for the include and header directories. I've tried altering that code but to no avail... I still get this error: building '_mysql' extension gcc -g -O2 -Wall -Wstrict-prototypes -fPIC -I~/usr/local/mysql-3.23.38/include/mysql -I/usr/home/ol0401/usr/local/Python-2.1/Lib -c _mysql.c -o build/temp.solaris-2.6-sun4u-2.1/_mysql.o _mysql.c:31: Python.h: No such file or directory _mysql.c:40: structmember.h: No such file or directory _mysql.c:41: mysql.h: No such file or directory _mysql.c:42: mysqld_error.h: No such file or directory _mysql.c:43: errmsg.h: No such file or directory error: command 'gcc' failed with exit status 1 Does anyone know what's going? Thanks, Tracy -- Tracy S. Ruggles -- COPI / OutputLinks -- http://www.outputlinks.com Email) TR at 888999copi.com Phone) 888/999.copi ext "TR" From aleaxit at yahoo.com Sun Jun 3 13:49:08 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 3 Jun 2001 19:49:08 +0200 Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> <3b1a4ce6.577431@nntp.sprynet.com> Message-ID: <9fdtd301oqk@enews2.newsguy.com> "David C. Ullrich" wrote in message news:3b1a4ce6.577431 at nntp.sprynet.com... ... > a place where I was asked for a definition > and didn't give said definition I'll say oops, > never mind excuse me. But I don't believe that > that has happened. Accusing me of refusing to > supply definitions when asked is egregiously > insulting. Reading back on the thread I saw I did not directly ask you for the definition, just indicated that the definition you (and/or Von Neumann) were using was not clear by such "hints" as: """ If by "perfect" randomness VN meant an infinite amount thereof (by Chaitin measure), he might have said that """ But then I never accused you of not giving the definition when directly asked to give it -- show me a place where I said that? What I meant by "not deigning" to give the definition was exactly your failure to provide it when I was clearly saying that I could not be sure of what the H*** you (and/or VN) meant by that "perfect" (I believe you were actually the one to introduce "perfect" or "true" as adjectives qualifying "randomness"/"random" on this thread, but I may be wrong -- I've wasted by far enough time on this thread without going back for a detailed exegesis of it:-). You did follow up to this subthread and not offered any definition of that "perfect" (or "true") on the follow-ups, I do believe. Am I wrong -- did I miss some message in the huge complex of threads? This has surely been known to happen on Usenet news at times. Alex From db3l at fitlinxx.com Tue Jun 12 18:50:27 2001 From: db3l at fitlinxx.com (David Bolen) Date: 12 Jun 2001 18:50:27 -0400 Subject: performance of python threads References: <9g4ap8$1mh$1@news.hk.linkage.net> Message-ID: Alan Tsang writes: > I am going to code for a small system that will invoke multiple threads and > process data concurrently. Has any body done some sort of benchmark on the > performance of python threads? I think you'll probably need to be clearer on what you mean by "performance" since there are a lot of things you could measure with respect to threads. If you could describe the sort of activities that the system will be performing in the threads, it might help. But a general answer would be that Python threads are layered on top of native threads (OS-based on Windows, pthreads on most Unixes I believe, etc...) and thus most of their performance criteria are going to be tied to the underlying platform performance. In my experience (mostly Windows) I see very little additional overhead due to Python with threads than I would have seen via a straight Python script. Any overhead with items such as dispatch time, synchronization and so on are largely comprised of basic Python interpreter overhead and not really thread-specific. I believe I did read that building the interpreter with threads can cause an overall x% (x<10 in 1.5.2) hit due to handling the global lock, but at least under Windows, the presupplied binary includes threading built-in so that overhead is always there. And that % has improved in releases since 1.5.2. One thing that is worth noting - even though you may have multiple underlying platform threads for your Python threads, there is still a single interpreter lock, and the only true overlapping of execution will be when one of your threads executes code that releases the global lock. This is true during any standard library resource access (e.g., blocked on I/O or waiting on an event), or in other extension modules that specifically release the lock during some non-Python activities. So if you're just splitting out multiple computation-heavy routines, you won't see much benefit unless some of the computation is done in an extension that releases the lock. Otherwise, the interpreter will just periodically (every 'n' bytecodes) release the lock and you'll get serial execution among the threads. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From speedy911 at mindspring.com Fri Jun 22 11:07:17 2001 From: speedy911 at mindspring.com (Charles Harrison) Date: 22 Jun 2001 08:07:17 -0700 Subject: pydoc memory leak Message-ID: <6f78b8b.0106220707.64d91134@posting.google.com> Hello, My name is Charles Harrison and I work for a company out of Mclean Virginia called Innovative Concepts Inc. Our company uses Python extensively to run testing scripts on our communicartions hardware which we are developing. I recently dicovered pydoc and immediatly knew that we needed to have it for the documentation of our testing scripts. I had no problem setting it up and tweaking the output to our needs, but I noticed that there is a memory issue after the program has been running as a webserver. For every new file that is requested, more and more memory is allocated to the server which is running Linux. Some modules will add as much as 4MB to the memory allocated to the server. This would not be a problem if it was flushed as soon as the page was displayed, but the memory continues to add up and the server is eventually allocating more than 25MB to the pydoc webserver. I have tried deleting the modules after they are used in the ModuleScanner() class and some other places, but none seem to free the memory. If you have any insight to why it does this or where I could alter the code to fix this problem it would be much appreciated. Thank you very much for any help you can provide Charles Harrison From new_name at mit.edu Thu Jun 7 20:25:16 2001 From: new_name at mit.edu (Alex) Date: 07 Jun 2001 20:25:16 -0400 Subject: How can I extend raw_input to provide user w/ default input string? References: <9fmgli$43f$1@peabody.colorado.edu> <3B1F0D82.DB10E008@yahoo.com> <9fo6g6$36v$1@peabody.colorado.edu> Message-ID: > Alex> You might want to check out the readline module. > > I don't think that works. I asked about it a few months ago and got a > negatory response from Guido. Oh, sorry for the bad advice, then. Alex. From boyd at insultant.net Thu Jun 7 13:46:28 2001 From: boyd at insultant.net (Boyd Roberts) Date: Thu, 7 Jun 2001 19:46:28 +0200 Subject: best language for 3D manipulation over web ? References: <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3B1B1825.8109BA83@lmf.ericsson.se> <2v4ohtgldvce84sn87kh1eg1lnes37getq@4ax.com> <3B1C9E65.B73A4FE@lmf.ericsson.se> <3B1DFD87.F3BFDB57@lmf.ericsson.se> Message-ID: <9foeo8$fec$1@hadron.noos.net> "TGOS" a ?crit dans le message news: e03vhto1hehnstnnaj7ekru67lulnrme8v at 4ax.com... > > Now you can get Sendmail executing a command for you, like "bash" and this bash > is then a root shell, because it was invoked by a root process. > in your dreams. modern sendmails are very resistant to attack. it doesn't need to run as root, except to bind to port 25 and then it can setuid to some 'mail' user. not that i ever thought sendmail was a good idea. From infobot at skinnyhippo.com Wed Jun 13 21:11:03 2001 From: infobot at skinnyhippo.com (infobot) Date: 13 Jun 2001 18:11:03 -0700 Subject: Python win32all installation warning dialogs. Message-ID: Installing Python win32all from ActiveState (win32all.exe, build 140 (3.5 Mb) for use with PythonLabs Python 2.1) for Python2.1 running on Windows NT 4. Following warnings appeared at the end of installation procedure : "Registration of the AXScript Engine COM server failed. Installation will continue but this server will require manual registration before it will function. Pywintypes.com_error:[-2147467262, 'No such interface supported', None, None]" "Registration of the Python Interpreter COM server failed. Installation will continue but this server will require manual registration before it will function. Pywintypes.com_error:[-2147467262, 'No such interface supported', None, None]" "Registration of the Python Dictionary COM server failed. Installation will continue but this server will require manual registration before it will function. Pywintypes.com_error:[-2147467262, 'No such interface supported', None, None]" I've never had problems with Win32all before so I figure the above are out-of-the-ordinary. May I ask how I should register these items ? Thank you very much, chas ps. if it makes any difference, I used to have Python1.52 and the respective win32all installed but uninstalled both of them before installing Python2.1 From m.faassen at vet.uu.nl Fri Jun 29 19:29:36 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 29 Jun 2001 23:29:36 GMT Subject: PEP scepticism References: Message-ID: <9hj310$bdu$7@newshost.accu.uu.nl> mcherm at destiny.com wrote: [snip] > First of all, thank you Bernhard, for raising an important point. > I completely agree with you: one of the strengths of Python is its > simplicity, and I would never want to see it go the way of Perl > or C++. This slide is particularly scary in that sense. The slides are for a talk given at Yet Another Perl Conference that just occurred in Montreal. http://prometheus.frii.com/~gnat/yapc/2001-80-20/slide006.html Note the 'signs of pragmatism in a formerly ideological world' comment! This is praise coming from Perl, and I'm not sure what to think. :) (Please note that I've already given the author of the slides some suggestions on how to improve the Python on this particular slide so don't bother mailing him about it. Nathan's a nice guy.) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From bill-bell at bill-bell.hamilton.on.ca Fri Jun 8 16:25:46 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Fri, 8 Jun 2001 16:25:46 -0400 Subject: Invoking Python COM server as 'local' server In-Reply-To: <991380121.1189.50798.l10@yahoogroups.com> Message-ID: <3B20FC8A.17807.5128F54@localhost> > Bill Bell wrote: > > > To my understanding, one usually builds a local COM server as an > > EXE. However, a Python COM server is neither a DLL nor an EXE; it's > > a PY. So how the heck does the Python COM machinery decide whether > > to create an in-process server or a local server, particularly when > > the default _reg_clsctx provides for registration of a server as > > both? My thanks to Messrs Don Dwiggins, Mark Hammond and Gregory Smith for their advice and information are overdue. Truth is, I'm just returning to this task. I have read almost all of "Python Programming on Win32" with real pleasure (which is rare enough where software books are involved). Unfortunately in my haste to get work done I skipped over the part of the COM chapter to do with remote servers and therefore missed the information about how the software decides between an in- process and a local server. Thanks again! Bill Bell, Software Developer From jchen at 263.net Thu Jun 7 20:17:31 2001 From: jchen at 263.net (Jian Chen) Date: 7 Jun 2001 17:17:31 -0700 Subject: Python Shareware? Message-ID: I am considering writing some shareware in python. I got some questions about it: 1. Is there any good shareware in python? where can I find? 2. Is python suitable to write shareware? as I konw, it is not easy to pack python programs in standlone exe program? is there any tools for the packing & installing of python software? 3. How can I lock/secure my python shareware? any suggestion? TIA ;) From skip at pobox.com Tue Jun 12 15:57:00 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 12 Jun 2001 14:57:00 -0500 Subject: Any tool for code coverage analysis on Python program In-Reply-To: <9g5n9i$qig@news.or.intel.com> References: <9g5n9i$qig@news.or.intel.com> Message-ID: <15142.29708.19962.444596@beluga.mojam.com> Edward> Hi I am trying t find a tol that do code analysis on program in Edward> python. where can I find it? I am using Python 1.5.2 Well, I once modified the code profiler to do statement coverage. Go here: http://musi-cal.mojam.com/~skip/python/ and search for "test coverage tool". Take a look here: http://musi-cal.mojam.com/~skip/python/Python/dist/src/Lib/StringIO.py to get an idea of the sort of output it generates. At one point I was cvs up'ing from the Python CVS repository each night and generating browsable C and Python statement coverage output, which is available here: http://musi-cal.mojam.com/~skip/python/Python/dist/src/ This little project used the above Python statement coverage generator as well as gprof and some glue scripts to generate the output you see. It wasn't perfect, but still useful. I don't have the spare CPU cycles on that machine anymore to bear the extra load. If someone would like to resurrect that, let me know. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From donod at home.com Mon Jun 4 12:33:21 2001 From: donod at home.com (Don O'Donnell) Date: Mon, 04 Jun 2001 16:33:21 GMT Subject: Decimal can be Binary Too (was decimal or rational) Message-ID: <3B1BB896.72B17D78@home.com> Tim Peters wrote: > > [Don O'Donnell] > > ... > > If by "floating-point-decimal" you mean internal representation of > > both the mantissa and the exponent by some sort of a binary-coded > > decimal, let me point out that it is not necessary to go to full > > decimal in order to to achieve the `7.35` == "7.35" goal.> > > By letting the exponent represent powers of 10 rather than 2, the > > base (or mantissa) and exponent can both be represented in binary > > as an int or long. Thus, the internal calculations can use the > > fast integer hardware instructions, rather than decimal arithmetic > > which would have to be done by software. > > ... > > See > > nt.py> > > for a fixed-point version of that. For "typical" commercial use, the > problem is that converting between base-2 (internal) and base-10 (string) is > very expensive relative to the one or two arithmetic operations typically > performed on each input. For example, hook up to a database with a million > sales records, and report on the sum. The database probably delivers the > sale amounts as strings, like "25017.18". Even adding them into the total > *as* strings would be cheaper than converting them to a binary format first. > > In addition, once you're outside the range of a native platform integer, > you're doing multiprecision operations by hand anyway. Python's longs use > "digits" in base 2**15 internally, but *could* use, say, base 10**4 instead. > The code would be almost the same, except for using different low-level > tricks to find twodigits/base and twodigits%base efficiently. Thanks for your comments, Tim. I agree that in most commercial environments, input, moving, formatting and output of numbers exceeds the amount of actual calculations that are done with them. Hence the early business oriented computers did all their calculations in some form of decimal format, to save the costly dec-bin-dec conversion steps. The "revolutionary" IBM 360 of the '60s was the first to have both floating-point hardware for scientific processing as well as fixed-point "packed-decimal" hardware for business use. With today's fast processors however, the radix conversion steps are hardly noticeable. I've done a lot of COBOL (yuck) programming on Univac/Unisys mainframes, which, lacking hardware decimal instructions, did all their fixed-point processing in binary. I never encountered any performance problems. Quite the contrary, they were incredibly fast machines for commercial work. I took a look at your FixedPoint.py module. Very nice work, thanks. As it turns out I already had downloaded ver 0.0.3, but had forgotten about it. Thanks for the update. I notice that you are also using a long integer internally to store the base number and an int to store a power of 10, as I suggested in my original posting. I was thinking more along the lines of a floating-point type rather than your fixed-point. I.E., with your FixedPoint class: 5.12 * 4.22 == 21.61 (it's rounded to two decimal places) With my dfloat class: 5.12 * 4.22 == 21.6064 (result is exact) I think there is a real need for both types of numbers. Especially in view of the fact that with Python's built in types, what we get today is: >>> 5.12 * 4.22 21.606400000000001 Do you think it would be possible or desirable to extend/generalize your FixedPoint class to handle the "floating decimal" as an option? Or would it be better to make it a separate class or subclass? Any opinions? BTW, I believe we also could use a rational type for representing numbers like 1/3 which can't be represented exactly by a finite number of decimal or binary digits. still-learning-from-reading-your-code-ly y'rs -Don From barry at digicool.com Thu Jun 21 00:39:38 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Thu, 21 Jun 2001 00:39:38 -0400 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) References: <200106201855.OAA21119@panix3.panix.com> <15153.15434.385992.754443@beluga.mojam.com> Message-ID: <15153.31370.394582.914528@anthem.wooz.org> >>>>> "SM" == Skip Montanaro writes: SM> I agree with Jeremy. I wasn't keenly interested in python SM> iterators from the get-go (you can't follow everything), so I SM> missed all the discussion until PEP 255 was released. Then SM> within a day or two it winds up in the head branch of CVS. SM> That's not to say it doesn't deserve to be there, but it seems SM> thtat the time from PEP to CVS was rather short. I thought so too. It definitely wasn't on my radar until it was checked in. In general I think that it's fine to continue to discuss PEPs on alternative forums until they are pretty well fleshed out. But once there's a serious move to include the code into CVS in a non-experimental way (as I gather is the case with the generators feature), I really think it the discussions have to be moved to python-dev at the very least. Unless there's heated objections, I'll update the PEP 1 procedures to describe this workflow. -Barry From gustafl at algonet.se Tue Jun 26 07:28:29 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: Tue, 26 Jun 2001 13:28:29 +0200 Subject: Adding unknown variables to time.mktime() References: Message-ID: <9h9rii$n5v$1@cubacola.tninet.se> "Roman Suzi" wrote: > >to be able to give only the 6 first values, since I've never heard of > >Julian days, and week day is not significant in this case. > try with all 9 integers. > RTFM time module docs. Read before you post. I always check the library reference, but it doesn't give any hints on what I asked for. If mktime() can't do it, maybe there's anyother way that you could suggest? Gustaf From nas at python.ca Fri Jun 22 11:35:57 2001 From: nas at python.ca (Neil Schemenauer) Date: Fri, 22 Jun 2001 08:35:57 -0700 Subject: pydoc memory leak In-Reply-To: <6f78b8b.0106220707.64d91134@posting.google.com>; from speedy911@mindspring.com on Fri, Jun 22, 2001 at 08:07:17AM -0700 References: <6f78b8b.0106220707.64d91134@posting.google.com> Message-ID: <20010622083557.A22232@glacier.fnational.com> I bet pydoc is creating reference cycles that are not being cleaned up by the GC. The GC currently does not track frame objects. If you get a frame object and assign it to a local variable you are probably creating a reference cycle. Here's some sample code that leaks memory: import sys def a(): return sys._getframe() def b(): frame = a() # Oops, reference cycle! #del frame # this would break the cycle while 1: b() HTH, Neil From thinkit8 at lycos.com Sun Jun 17 22:54:26 2001 From: thinkit8 at lycos.com (thinkit) Date: 17 Jun 2001 19:54:26 -0700 Subject: humans should use a power of 2 Message-ID: <9gjqh201q0o@drn.newsguy.com> please stop using decimal. most people already only use hexadecimal. "0x" is your friend...soon enough humans will be only using powers of 2 as general purpose bases. From akuchlin at mems-exchange.org Tue Jun 26 17:18:56 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 26 Jun 2001 17:18:56 -0400 Subject: ZODB packaging References: Message-ID: <3dk81zszwf.fsf@ludwig.cnri.reston.va.us> "Bjorn Pettersen" writes: > Any chance of a Windows version of your ZODB packaging? No Windows development environment -- so, "no". --amk From paulp at ActiveState.com Thu Jun 14 20:13:50 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Thu, 14 Jun 2001 17:13:50 -0700 Subject: Upon reflection... References: <20010614163301.G18379@mail.coursepeek.com> Message-ID: <3B29533E.69E5614E@ActiveState.com> James Turner wrote: > >... > > It's a bit like the dating game (bad metaphor, I know...): It's a > bad idea to just ask your friends who the best catch is, and marry > blindly. You probably should date and get to know people yourself! I think it is a good metaphor. The reason that you shouldn't pick a programming language based on feature lists is analogous to the problem with picking a mate that way. The issues are way too subtle. The "features" interact in too many unpredictable ways. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From jonas.b at home.se Wed Jun 20 17:31:17 2001 From: jonas.b at home.se (Jonas Bengtsson) Date: 20 Jun 2001 14:31:17 -0700 Subject: OOP in Python References: <4e2ddb70.0106200954.11faa218@posting.google.com> Message-ID: <4e2ddb70.0106201331.4ec406ba@posting.google.com> Thank you all for those terrific answers!! btw. I find the interactive mode in *Python Shell* to be the best way to get to know a programming language! Python is great! /Jonas B jonas.b at home.se (Jonas Bengtsson) wrote in message news:<4e2ddb70.0106200954.11faa218 at posting.google.com>... > Ok I admit - I am a Python-newbie! > > What about local variables and class variables when dealing with > classes? > With local vars I mean temporaryly used variables in a function. Will > they be treated as 'normal' instance attributes? Do I have to delete > them by myself when I'm leaving a function? > With class vars I mean if many class instances of a class may share a > variable. In C++ this is accomplished by a static variable. How do I > do in Python? > > Thanks in advance, > Jonas B From pieter at kotnet.org Sun Jun 3 04:32:06 2001 From: pieter at kotnet.org (Pieter Laeremans) Date: Sun, 03 Jun 2001 10:32:06 +0200 Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> Message-ID: <991557126.662806@seven.kulnet.kuleuven.ac.be> In article <991550033.146 at nntp01.uskonet.com>, "Frank Millman" wrote: > After 15 years of designing applications using the good old "seat of the > pants" method, I have decided that, if I am to move forward, I need a > more formal methodology. > > I have recently read about UML (Unified Modelling Language), a > standards-based method of designing and documenting any software > project. It looks interesting, but it seems to have a steep learning > curve. > > Does anyone have any knowledge or experience of UML that they would like > to share? > Hi. I didn't used it myself so far. However in my next year at college. I'll have to. They use a textbook from Martin Fowler : "Applied UML". UML is quite large. And Fowler describes how you can modify most problems using a smaller but funcitonal subszt of UML. Greetz, Pieter P.S.: sorry for the bad English From feedback at netlcr.de Thu Jun 14 11:12:38 2001 From: feedback at netlcr.de (Florian Scholz) Date: Thu, 14 Jun 2001 17:12:38 +0200 Subject: bsddb: must bsddb write a file ? Message-ID: <3B28D465.229D7BF7@netlcr.de> hi again.. the bsddb: class (binary tree, hash-table,..) needs to write its data to a file: db = bsddb.btopen('filename','c'); the file can be removed, but is there a way to avoid the file ? From mwh at python.net Fri Jun 15 19:21:20 2001 From: mwh at python.net (Michael Hudson) Date: 16 Jun 2001 00:21:20 +0100 Subject: [Python-iterators] RE: PEP 255: Simple Generators In-Reply-To: "Tim Peters"'s message of "Fri, 15 Jun 2001 17:02:33 -0400" References: Message-ID: (I'm following up in an odd place for no good reason, in case you have a mail client that can tell and were wondering). I think the PEP could use a little discussion about the interactions between yielding and try/except/finally blocks. What actually happens is the only plausible behaviour, but I'm not sure I'd see that if I wasn't already pretty familiar with Python internals. Here's a fun example if you're on Unix: ->> import termios, tty, select, errno, os />> def gen(): |.. try: |.. term = termios.tcgetattr(0) |.. tty.setraw(0) |.. while 1: |.. try: |.. r, w, e = select.select([0],[],[]) |.. if 0 in r: |.. c = os.read(0,1) |.. if c == '\004': # control-D |.. return |.. else: |.. yield c |.. except OSError, err: |.. if err.errno == errno.EINTR: |.. pass |.. else: |.. return |.. finally: |.. termios.tcsetattr(0, termios.TCSADRAIN, term) \__ "list(gen)" is a good way to drive it; type that and batter some keys, then press control-d. Arguably the try/finally should be around the call to os.read, and not contain the yield. It depends on what you're doing with the generator I guess. Also: ->> import keyword ->> 'yield' in keyword.kwlist 0 But, generally speaking, I like. Cheers, M. From CCRazy1 at msn.com Fri Jun 22 01:15:23 2001 From: CCRazy1 at msn.com (James) Date: 21 Jun 2001 22:15:23 -0700 Subject: A recommendation on programming tutorials? Message-ID: <7417e9e.0106212115.20f3fafe@posting.google.com> I've just started studying the Python programming language 3 days ago. Though I've already found a tutorial on Python programming and am fully aware of the tutorial published with the Python Compiler, I would appreciate further recommendation on online reading regarding Python Programming. Thanks in advance. From phd at phd.fep.ru Thu Jun 21 06:51:19 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Thu, 21 Jun 2001 14:51:19 +0400 (MSD) Subject: Managing Python sources in CVS & whitespace In-Reply-To: Message-ID: On 21 Jun 2001, Ville Vainio wrote: > Are there any issues with Python sources and CVS (I'm thinking of the Not at all. > whitespace thing here)? Do the diffs or merging branches get screwed > up? Other way around - consistent whitespaces make it much better. > Are there any special considerations? No one. PS. For those who want CVS+Python: http://viewcvs.sourceforge.net/ I use it and I am pretty happy with it. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From s713221 at student.gu.edu.au Fri Jun 22 21:50:33 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Sat, 23 Jun 2001 11:50:33 +1000 Subject: [OT] MS EULA -- (will ActiveState become outlaws? ;-) References: Message-ID: <3B33F5E9.45730271@student.gu.edu.au> > > No -- it's not the Slashdot Effect (at least in the performance sense). > It's been changed to redirect you to a 'page not found' page. > They very clearly removed it. > Wiser and cooler heads must have prevailed at MS. They have those? -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From ohyvarin at cc.helsinki.fi Mon Jun 4 09:05:34 2001 From: ohyvarin at cc.helsinki.fi (Otto T Hyvarinen) Date: 4 Jun 2001 13:05:34 GMT Subject: Strange behaviour of Numeric.where Message-ID: Perhaps there is a rational explanation to this: " Python 2.0 (#5, Feb 20 2001, 11:00:04) [GCC 2.95.3 19991030 (prerelease)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import Numeric >>> a=Numeric.array([1,2,0,4,1]) >>> Numeric.where(Numeric.equal(a,0),0,1/a) Traceback (most recent call last): File "", line 1, in ? ZeroDivisionError: divide by zero >>> Numeric.where(Numeric.equal(a,0),0,1./a) array([ 1. , 0.5 , 0. , 0.25, 1. ]) >>> " The first version is a bit stupid, because it will only return ones and zeros. But why it returns division by zero is beyond me. I tried this on Python1.5.2 with Irix, and got the same results except that with Irix I get: " >>> Numeric.where(Numeric.equal(a,42),0,1/a) array([1, 0, 0, 0, 1]) " and with Linux: " >>> Numeric.where(Numeric.equal(a,42),0,1/a) Traceback (most recent call last): File "", line 1, in ? ZeroDivisionError: divide by zero " Strange. Otto Hyv?rinen, otto.hyvarinen at fmi.fi From mwh at python.net Sat Jun 2 06:45:00 2001 From: mwh at python.net (Michael Hudson) Date: 02 Jun 2001 11:45:00 +0100 Subject: Executing a shell command References: <9f901k$ffa$1@mtc1.mtcnet.net> Message-ID: "Kevin Riggle" writes: > Is there any way to take a command in a string in Python, execute it in the > shell, and read the output into a variable of some sort, like > > result = execute(cmdline) >>> import commands >>> print commands.getoutput.__doc__ Return output (stdout or stderr) of executing cmd in a shell. Cheers, M. -- > Look I don't know. Thankyou everyone for arguing me round in > circles. No need for thanks, ma'am; that's what we're here for. -- LNR & Michael M Mason, cam.misc From quinn at regurgitate.ugcs.caltech.edu Fri Jun 29 18:40:26 2001 From: quinn at regurgitate.ugcs.caltech.edu (Quinn Dunkan) Date: 29 Jun 2001 22:40:26 GMT Subject: [Python-iterators] While we're at it... References: Message-ID: On Fri, 29 Jun 2001 14:34:44 -0700, David Eppstein wrote: >In article , > "Tim Peters" wrote: > >> - The following functions were generalized to work nicely with iterator >> arguments: >> map(), filter(), reduce(), zip() > >Is there a PEP for this? It doesn't seem to be in 234. >Can I assume that "work nicely" means they act like simple generators in >yielding partial results even when their inputs are infinite sequences? I assume they all still return normal sequences, not iterators, since returning an iterator would break a lot of code. So they can take iterator args now, but an infinite iterator will hang just the same. Of course, an iterator map would be useful: def iter_map(f, seq): for o in seq: yield f(o) which would work with an infinite sequence. It's sort of another way to write a lazy list, after all. From pmoscatt at bigpond.net.au Fri Jun 8 07:50:33 2001 From: pmoscatt at bigpond.net.au (Peter Moscatt) Date: Fri, 08 Jun 2001 11:50:33 GMT Subject: TIX - How to envoke ?? Message-ID: I have just recently succeeded in installing Tix 8.2 and have tested it through the SHELL. Under KDE I use the "ActiveState Komodo" interpreter. I am not too sure how I let Komodo know that there is now a Tix module to be used. Is it just a matter of using: import Tix Or is there another method ?? Regards Pete From aleaxit at yahoo.com Sat Jun 2 14:31:01 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 2 Jun 2001 20:31:01 +0200 Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> Message-ID: <9fbbds01pk0@enews2.newsguy.com> "Mark 'Kamikaze' Hughes" wrote in message news:slrn9hi99k.9ns.kamikaze at kuoi.asui.uidaho.edu... ... > A true random number generator is not one that requires an infinite > amount of information to predict, it is one that is *impossible* to > predict, regardless of how much information you have. OK, that's your definition. Do you agree with Ullrich's apparent thesis that _any_ physical system is such a 'true random number generator' because of inevitable quantum effect _no matter at how macroscopic a level you look at the system_, and secondarily that 'true randomness' (he calls it 'perfect') only exists at all _because_ of quantum effects? If so, then I'm not really interested in pushing the debate much further or splitting hairs between 'requiring an infinite amount of information to predict' and 'impossible to predict regardless of how much' (finite amount, presumably?) 'information you have'. As ANY experiment we can make runs on physical systems (including possibly our minds), then true total randomness, by this thesis, is ALWAYS present and there is nothing we can do to remove it, so we might just as well use some idiotic library rand() that LOOKS like it's a horrid generator -- we cannot predict the next bit (it MIGHT come from an intrinsically unpredictable flipping somewhere in a transistor), thus it must be OK, right? It's not right *FOR ME*: it is, in fact, utterly useless -- one might just as usefully argue the solipsistic thesis that you're all figments of my imagination, or whatever other such way to waste one's time and others'. If this is NOT what you mean, then let's find out what you DO mean by "impossible to predict" if it's not some quantum sophistry:-). What about shuffling a deck of cards, spinning a roulette wheel, or rolling dice? These are the traditional ways to generate randomness. Are all of these a "true random number generator" by your definition? Couldn't I for example in principle predict the outcome of dice being rolled, if I did have a sufficient but finite amount of information on the state of the dice? There only seem to be macroscopic phenomena involved -- in the same sense in which computer systems are designed to eschew errors from unpredictable bitflipping, but the dice have it easier, as they're rather more massive than the typical tiny packet of particles used in a computer today. > > Meanwhile I still see nothing 'sinful' in dealing with > > randomness finitely, > > It's simple. If you have a pseudo-random number generator, you will > eventually repeat, If the 'eventually repeat' is sufficiently longer than the time to the expected heat death of the Universe, for example, is that a real problem? Any more than it is a real problem that "in theory" all particles on the seat I'm sitting on MIGHT simultaneously and unpredictably just happen to move one meter to the right and I'd have a rather nasty fall thereby? Expected time to such an event is many times the expected time to the end of the Universe, so I don't often worry about that. > and other people, given the right information, can > duplicate your random numbers. This is, to put it mildly, not a good > thing (the word "catastrophic" comes to mind in crypto applications). I like the crypto 'adversarial' way of looking at randomness, it seems quite fruitful. So, suppose the intended application IS a one-time pad for perfect cryptography -- it has to be a finite amount of bits since I do have to transfer a copy of it (and by costly secure channels too) to the intended recipient before it's any use. Now, what difference does it make whether the bits in the pad are generated by using a system that is _impossible_ to predict (sufficient amplification of some tastefully chosen quantum effect, say -- assuming quantum effects ARE indeed intrinsically unpredictable), or one that WOULD be possible to predict EXCEPT for the little detail of needing *a sufficiently large amount* of information that is just not there? N coin-flips, for example, to generate N bits. Each flip is presumably predictable (with a probability as close to 1 as one wishes) GIVEN information about initial coin state and forces applied, that, besides being a LOT of bits:-), was simply not recorded at the time -- it's not around, that info. How do you like that one-time pad now? Now what, if anything, is different about using some program implementing a given algorithm to generate the pad? What else except the amount of bits of information that are needed for the prediction? I.e., the amount of randomness. If high enough, if a large-enough number M of bits of information is needed to predict the N bits on the pad, then the system is as secure as with N coin-flips. There is clearly no problem with M being _FINITE_ -- only, quite possibly, with it being _SMALL_. So, I badly need to measure that M -- how else can I reject too-weak solutions, if I can't measure how good they are but only mutter ironies about M being finite anyway? Alex From sheila at spamcop.net Mon Jun 18 20:55:16 2001 From: sheila at spamcop.net (Sheila King) Date: Mon, 18 Jun 2001 17:55:16 -0700 Subject: Sorting Apache Log Files In-Reply-To: <15150.39175.371647.917021@beluga.mojam.com> References: <15150.39175.371647.917021@beluga.mojam.com> Message-ID: <4B9BE9657A1@kserver.org> On Mon, 18 Jun 2001 19:12:55 -0500, Skip Montanaro wrote about Re: Sorting Apache Log Files: : Sheila> I need to search on Apache's date string.: : Sheila> How about this? Create a list of tuples, where the tuple is:: : Sheila> (datestamp, full_line) : :That will work, as long as you convert the string representation into :something that will sort chronologically (e.g. mxDateTime). Good point, although the person asking the question really indicated that his difficulty was sorting on something that was not at the beginning of the line. :I missed the beginning of this thread, so perhaps this was already :discussed, but I'm a bit unclear why you should need to sort an Apache log :file by date/time, since it should already be in chronological order. He had two different log files that he wanted to merge. Why they wouldn't be in order to begin with, I really don't know. I just went with the assumptions presented in the original post. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From samschul at pacbell.net Sat Jun 2 03:09:22 2001 From: samschul at pacbell.net (Samuel Schulenburg) Date: 2 Jun 2001 00:09:22 -0700 Subject: Embedded 'C' problem? Message-ID: Given the following string: EB70:|30 E8 8A 17 00 00 66 89 04 9F 83 C4 08 43 3B 5C 0.....f......C;\ and using the following 'C' wsprintf() function to build ucPyString causes a print format error. wsprintf(ucPyString,"print \"\"\"%s\"\"\"",ucMsgStr); PyRun_SimpleString(ucPyString); ERROR: File "", line 1 print """EB70:|30 E8 8A 17 00 00 66 89 04 9F 83 C4 08 43 3B 5C 0.....f......C;\""" ^ SyntaxError: invalid token The problem is final "\" in the origional string is interfering with the final tripple quote forming a \""" which is interprited as an escape sequence. My question is. How can I generate a format specifier so I can have a ucMsgStr that contains any printable characters, and does not interfer with the Python print function? Sam Schulenburg From loewis at informatik.hu-berlin.de Sun Jun 17 16:29:37 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 17 Jun 2001 22:29:37 +0200 Subject: list.sort() References: <3B2CEBF1.CCF5377D@hack.org> Message-ID: "Nick Perkins" writes: > I do find it a bit strange that list.sort() returns None, but I am sure > there is a good reason for that. The reason is that returning a value might trick you into believing that you got a copy. E.g. you could write for k in foo.sort(): and it would work alright at the surface, but it might be confusing that the order of elements has actually changed. Returning None is also confusing to some people, but they'll notice their error much quicker. In short, returning None tells you that you got a procedure, not a function. > It is also strange that you can legally do: > [3,2,5].sort() [...] > I presume that the list actually gets sorted, but since no referece is > maintained to the list, it immediately becomes 'garbage', and is lost > forever. Exactly. Same issue: You might expect this to work, and it doesn't. This is no big deal, as you'll immediately notice the problem when running the code. Now, some people might expect sort and reverse to return a *new* array. That would be more expensive in many cases. Plus, changing it *now* is not appropriate: it would break code that expects that .sort sorts inplace, whereas a method that returns a new object would not sort the object itself. Regards, Martin From aleaxit at yahoo.com Tue Jun 12 05:29:50 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 12 Jun 2001 11:29:50 +0200 Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: Message-ID: <9g4nec0cnr@enews2.newsguy.com> "Roman Suzi" wrote in message news:mailman.992325753.25339.python-list at python.org... > On Mon, 11 Jun 2001, Glyph Lefkowitz wrote: > > >I'm for it. In fact, we should do things like this more often -- if the > >semantics of "print" change once per release, everyone will stop using it, > >the keyword/bytecode will vanish, and people will use a function for > >writing to standard out, as it should have been all along! :) > > Why do you insist on using function instead of print statement? > Maybe, we can also eliminate del statement because there is no > "new" cunterpart of it? Axiom: a function does not affect its caller's namespace -- it does not bind, it does not unbind, it does not re-bind. Lemma: any construct that, by design, must affect the "caller's" namespace should not be a function, but rather a statement. ObBadExample: execfile. It's a statement in function's clothing. And thus, it works quite badly: D:\py21>python Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. Alternative ReadLine 1.4 -- Copyright 2001, Chris Gonnerman >>> print open('fo.py').read() a=23 >>> execfile('fo.py') >>> a 23 >>> del a >>> def f(): ... execfile('fo.py') ... print a ... >>> f() Traceback (most recent call last): File "", line 1, in ? File "", line 3, in f NameError: global name 'a' is not defined >>> >>> def g(): ... a=5 ... execfile('fo.py') ... print a ... >>> g() 5 >>> Clearly we do NOT want other such semi-working hacks -- one is more than enough:-). Therefore: assignment and del, whose PRIMARY purpose is affecting the namespace in which they're used, MUST be statements. class, def, import, from, for, affect the namespace in which they're used as part of their operation -- this is maybe a secondary effect that is not always wanted in the case of 'for', but it's very much a part of normal operation for the others. OK so far...? Oh, exec, too -- to ALLOW it to affect the namespace in which it's used, specifically! Another reason to make something a statement is when the 'something' contains one or more blocks of code and/or affects control flow. class, def and for meet this test too. while, if, try, raise, break, return, continue -- all affect control flow. pass can also be seen this way -- it has NULL effect on control flow (or anything else), making it a suitable place-holder and allowing Python to avoid the syntax problems that come with a "null statement" like in C & descendants. So, summarizing: in Python, keyword statements either affect the namespace using them, or affect the control flow that uses them. All, that is... except ONE. That one is: print. A keyword statement that neither affects the namespace, nor control flow. An anomaly, therefore, that sticks out like a sore thumb. Surely not such a huge one that it's worth breaking 99% of existing scripts to remove it:-). *However* -- why keep overloading it with magic and extra "convenience" features...? Glyph may be right in paradoxically claiming that just such tweaking will eventually show everyone that print is just best not used:-). To HELP migration to a function for what is now done with print, I think such a built-in function should be added contextually to this latest 'print' change. Yes, yes, it IS un-Pythonic to provide several ways to do the same task, but, here, I think, we need to patch over the non-Pythonic existence of print itself:-). I believe the new print-like built-in function should ideally be named print, but we can't do it, because keywords are reserved. Sigh. Among the alternatives, we have: write (misleading as it recalls the write method of file-objects), output (makes for a nice pair with input, which, however, has its own nasty problems:-), emit, say (a la Rexx), echo (a la sh), and many others, including non-words that decorate these basic words (doprint, etc). Whatever name is used (assume 'output' for definiteness, without loss of generality), I think the print-like function should accept arbitrary unnamed arguments (to be treated just like the items now passed to print) optionally followed by named arguments to supply the same tweaks that now print supplies (and maybe a few more) -- names are doubtful, but...: file=sys.stdout the output file-object to use newl=1 1 emit a newline at the end UNLESS the last item printed is a string ending in \n (like print will now work) 0 no newline at the end (like print with a trailing comma) 2 force newline at the end in any case (like print today) (others?) a la (2.2 syntax, untested): def output(*args, **kwds): file = sys.stdout newl = 1 for k in kwds: if k=='file': file=kwds[k] elif k=='newl': newl=kwds[k] else: raise TypeError, \ "output() got an unexpected keyword argument '%s'"%k # I'm just approximating softspace behavior here...: soft = getattr(file, 'softspace', 0) no_end_nl = 1 for a in args: if soft: file.write(' ') towrite = str(a) no_end_nl = towrite=='' or towrite[-1]!='\n' file.write(towrite) soft = file.softspace = no_end_nl if newl: file.softspace = 0 if newl==2 or no_end_nl: file.write('\n') Having output as a built-in function would encourage using it in lieu of the print statement, which, in turn, would allow the usual kind of tricks that are available for built-ins but not for statements, such as wrapping/overriding (you can do that for print with a user-defined file-like object, to some extent, but not fully -- the file-like object cannot know where a given print statement begins or ends, it can only intercept specific write and softspace accesses). Alex From philh at comuno.freeserve.co.uk Sat Jun 30 17:39:05 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Sat, 30 Jun 2001 22:39:05 +0100 Subject: Is this a true statement: Part II References: Message-ID: On Sat, 30 Jun 2001 00:19:56 +0200 (CEST), Carsten Geckeler wrote: >On Fri, 29 Jun 2001, phil hunt wrote: > >> On Fri, 29 Jun 2001 14:48:23 -0400, MDK wrote: >> > >> >Why is C++ awful; what's wrong with it? >> >> I don't think it is awful. >> >> But it does have drawbacks. The main one, IMO, is that the tasks >> it is good at are not the tasks it is mostly used for. >> >> C++ is a very good system programming language. For wiritng >> operating systems, device drivers, windowing systems, programing >> language compliers and interpreters, it's a natural choice. >> >> But for writing GUI applications, it typically isn't, unless >> speed is imperative. > >Well, at least most GUIs _themselves_ are programmed in C/C++. I was making a distinction between GUIs and GUI applications. -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From arisen at start.no Thu Jun 21 14:35:51 2001 From: arisen at start.no (=?ISO-8859-1?Q?Andr=E9?=) Date: 21 Jun 2001 11:35:51 -0700 Subject: Python COM: Unable to create server-side object. Message-ID: Hi. Something strange is happening to in my Python / COM recently (ActiveState Python 2.0 on Win2K). I have created this small class in the file short.py: class Short: _reg_clsid_ = "{74471ADF-9453-4135-87E6-22E1B9499B0D}" _reg_progid_ = "Python.Short" _reg_desc_ = "PythonCOM test" _public_methods = ["isShort"] def __init__(self): self.short = "yes" def isShort(self): return self.short if __name__=="__main__": import win32com.server.register win32com.server.register.UseCommandLine(Short) And registered it succcessfully. ($ python short.py) When i try >>> import win32com.client >>> s = win32com.client.Dispatch("Python.Short") I get the following error: (-2147221231, 'ClassFactory cannot supply requested class', None, None) If i try it again i get another: (-2147467259, 'Unspecified error', None, None) I have tried with diffeetn class names, prog ids and clsids. This used to work fine, and i have written several com servers in python before which still work. Any ideas? -- Regards Andr? Risnes From tim.one at home.com Fri Jun 29 01:22:32 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 29 Jun 2001 01:22:32 -0400 Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: [David Eppstein] > So, back to the topic of PEP255: am I the only one bothered by the fact > that the inorder example in the PEP is quadratic time, Well, sum of the path lengths, and "quadratic time" is a worst case. If someone has a binary tree that's degenerated into a linear list, they've likely got worse problems than the time it takes to enumerate the leaves. > and that it seems difficult to use simple generators to yield a > tree's nodes in inorder in linear time? I'm not bothered -- this comes with the territory. If/when full-fledged coroutines make it in too, people worried about that can use them instead. Curious fact: I *was* worried about the worst-case time aspects of "simple generators" in Icon years ago, but in practice never ever got burned by it. And rewriting stuff to use Icon co-expressions instead invariably resulted in messier code that ran significantly slower in virtually all cases, except for the ones I *contrived* to prove the O() difference. BTW, Python almost never worries about worst-case behavior, and people using Python dicts instead of, e.g., balanced trees, get to carry their shame home with them hours earlier each day . "simple"-means-"simple"-ly y'rs - tim From uioziaremwpl at spammotel.com Wed Jun 27 13:33:32 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Wed, 27 Jun 2001 19:33:32 +0200 (CEST) Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: On Wed, 27 Jun 2001, Tim Peters wrote: > [Paul Prescod] > > Others seem to want to teach them alongside other flow control > > keywords. > > [Greg Ewing] > > You might get away with teaching generators without > > mentioning iterator objects if you say that they can > > only be called in a special context, i.e. > > > > for x in g(): > > > > and that each time you hit a yield, the value gets > > bound to x and the for-loop body is executed, then > > execution resumes after the yield. > > That's what works for teaching generators in Icon, Do you really mean that? I would not start teaching Icon generators in the context of simple looping like in every i:= 1 to 10 do write(i) > except that Icon also has many other kinds of "special context" where > generators act reasonably. This other "secial context" of expressions failing and fallback is acutally the core idea of Icon. Probably most of the readers of this list are not really familiar with Icon, so some examples may be useful. Assuming that prime() is a generator, giving all the prime numbers starting from 2, we can do: if (i := prime()) & (i > 7) then write(i) # prints 11 every (i := prime()) & (i > 7) do write(i) # prints 11 13 17 ... write(prime()) # print 2 So generators in Icon an Python are very different. Cheers, Carsten -- Carsten Geckeler From peter.nye at verizon.net Wed Jun 6 12:11:16 2001 From: peter.nye at verizon.net (Peter Nye) Date: 6 Jun 2001 09:11:16 -0700 Subject: Running mod_python on NT Message-ID: <1a18c6fa.0106060811.5f09477f@posting.google.com> Has anyone been able to overcome the error message: python_handler: make_obcallback returned no obCallBack! and successfully run mod_python on NT. I have read all kinds of postings of people having this problem but have not found any answers. Thank you for any help you can give. Running NT 4.0 Apache 1.3.14 Python 2.0 mod_python 2.7.2 Peter Nye From matt at mondoinfo.com Sun Jun 10 14:01:30 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Sun, 10 Jun 2001 18:01:30 GMT Subject: return from class? References: Message-ID: On Sun, 10 Jun 2001 12:21:38 +0000 (UTC), Jacek Pop?awski wrote: >I will try to explain this better... I need to select >"corporation". I need it in many places in my application, so I >decided to create class SelectCorporation. This class should open >window with Listbox. User should select one item from that Listbox, >then click "OK". I don't know what to do when OK is clicked. I >should destroy window, and class instance, but how to return value to >the class which called SelectCorporation? Dear Jacek, Thanks for working to make your question as clear as possible. In fact it was very clear from the start. I remember having the same problem myself. I think that the easiest way to solve it is to look at the problem the other way round. That is, instead of having an entry that is trying to pull a value from your new window, let the new window push the value into the entry. The only trick is to give your sub-window a reference to the entry that it will want to put the value in. I'll append an example of what I mean. Best regards, Matt from Tkinter import * class mainWin: def __init__(self,root): self.e=Entry(root) self.e.pack() b=Button(root,text="Sub-window",command=self.newWin) b.pack() return None def newWin(self): subWin(self.e) return None class subWin: def __init__(self,mainWinEntry): self.mainWinEntry=mainWinEntry self.t=Toplevel() b=Button(self.t,text="Push",command=self.putTextInEntry) b.pack() return None def putTextInEntry(self): self.mainWinEntry.insert(END,"Wibble") self.t.destroy() return None def main(): root=Tk() mainWin(root) root.mainloop() if __name__=="__main__": main() From mlunnay at ihug.com.au Mon Jun 18 02:36:11 2001 From: mlunnay at ihug.com.au (Michael Lunnay) Date: Mon, 18 Jun 2001 16:06:11 +0930 Subject: why is there no class (static) methods in Python ? References: <3B2D114E.7B39D954@intraware.com> <3B2D6669.7DEFD13F@intraware.com> Message-ID: <3b2d8c49$0$420$603e2862@news.adl.ihug.com.au> why do you need it as part of the class, if it is related to the class just have it in the same module so you can do: import foo x = foo.foo() print foo.staticfunction() Michael "Richard Gruet" wrote in message news:3B2D6669.7DEFD13F at intraware.com... > Martin, > > > Martin von Loewis wrote: > > > Richard Gruet writes: > > > > > I (and other people on the Python french mail list) wonder why there > > > are no class (static) methods in Python. You cannot define a really > > > unbounded (ie to an instance) method within the namespace of a class. > > > > First of all, you *can* define such a thing if you absolutely want, see > > > > http://www.python.org/doc/FAQ.html#4.84 > > > > Thanx for the info. But the FAQ confirms that there is no way to define easily > a class method. What is recommended (define a module fct) is already what I > use. > > > > It's not natural nor elegant to have to create an instance to call a method > > which is not related to a particular instance. We would like to be able to > > write things like: > > > > > > class C: > > > def staticFoo(x): print x > > > > > > C.staticFoo(1) > > > > I'd like to question why you want to do this. Isn't it much better to write > > > > class C: > > pass > > > > def staticFoo(x): > > print x > > > > I.e. what has class C to do with staticFoo? > > Of course, my example is fictitious and was only intended to show the desired > syntax. But the reason to choose to define a function as a class method rather > than a mere (static) function is -obviously- when this function is closely > related to the class itself, not to one of its instances. Some languages like > smalltalk even define classes as instances of metaclasses, which makes sense. > Then you can see class methods like methods of instances that are actually > classes. > In fact, constructors (and destructors) are class methods, not instance > methods, but they are handled specially in the language so they appear as > instance methods.. > > Typical examples of class methods: > loadInstanceFromStream(aStream) # Create an instance from its persistent > state read on a stream > getInstanceCount() # returns the number of instances > of this class > getInstanceList() # returns the list of > instances of this class > getClassName() or getAnyInfoOntheClass() ...... > > > Richard > > From tim.one at home.com Sun Jun 17 20:37:14 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 17 Jun 2001 20:37:14 -0400 Subject: Type/Class Distinction (was: RE: Future floating point directions? [was Re: floating point in 2.0]) In-Reply-To: Message-ID: [Glyph Lefkowitz] > Could somebody please explain to me why removing the type/class > distinction is a good idea? Have you read Guido's PEPs on the topic? http://python.sourceforge.net/peps/pep-0252.html http://python.sourceforge.net/peps/pep-0253.html http://python.sourceforge.net/peps/pep-0254.html > I rather like the fact that it is readily apparent which objects > are implemented in Python and which in C Why would your code care what a thing is implemented in? Right now it sometimes *has* to care, but that's a consequence of the split. > (and my code is rife with 'if type(xxx) is types.StringType'); That is a problem, but you already "should be" checking via isinstance(xxx, types.StringType) instead. > if I can't *implement* in Python I don't understand > why it makes sense to subtype it. You're getting closer : the reason you can't implement the float type in Python is precisely because of the type/class split. > It seems like an "OO purity" issue, and as we all know, practicality > beats purity; but if Guido is personally working on it, there's > surely something I'm missing. For most apps most of the time it doesn't really make much difference. The problem is for extension writers, and even Python's own implementation, because types and classes are implemented in entirely different ways, leading to lots of irksome *almost*-duplication ("ok, if it's not an instance, do this block of code, but if it is, do it this other strangely twisted way"). Trying to implement a Python class in C is a close approximation to hell now (this is why Jim Fulton created ExtensionClasses); and trying to implement a Python type in Python is impossible now. You should read the PEPs for details. Note that the type/class split doesn't really exist in Jython (they had no choice but to model everything as "a class" there), so it's not like anyone should fear the C-based language is going to fall apart at the seams. It's a lot of work to heal in CPython only because the split is so old and so deep. From new_name at mit.edu Mon Jun 25 17:46:31 2001 From: new_name at mit.edu (Alex) Date: 25 Jun 2001 17:46:31 -0400 Subject: Can I start asynchronous threads in .pythonrc? References: <9h80cn$t3p$1@panix2.panix.com> Message-ID: Yeah, I was thinking about that. Thanks, Aahz. Alex. From aahz at panix.com Sun Jun 3 11:07:56 2001 From: aahz at panix.com (Aahz Maruch) Date: 3 Jun 2001 08:07:56 -0700 Subject: why huge speed difference btwn 1.52 and 2.1? References: <9f8fgs$ooo$1@knot.queensu.ca> Message-ID: <9fdjsc$pn4$1@panix2.panix.com> In article <9f8fgs$ooo$1 at knot.queensu.ca>, robin senior wrote: > >I have a pretty simple script for processing a flat file db, running on >Python 2.1; I tried running it under 1.52 for kicks, and to my surprise it >ran almost 10 times as fast! Could someone let me know why 2.1 would be so >much slower? This script is so poorly formatted that I can't read it. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 I surf faster than you do, monkey boy. (My take on Netscape vs. Lynx) From burt at dfki.de Sun Jun 24 04:25:46 2001 From: burt at dfki.de (Alastair Burt) Date: 24 Jun 2001 10:25:46 +0200 Subject: Python scripting [was: Re: emacs speedbar for python mode?] References: <9h24tq$f7b$1@news1.xs4all.nl> <9h2bo2$335$1@news1.xs4all.nl> Message-ID: pinard at iro.umontreal.ca (Fran?ois Pinard) writes: > By the way, and despite I'm awake by now, did someone ever benchmarked > Python vs Emacs LISP for comparable algorithms, at least speed-wise, > and maybe memory-wise also? Doug Bagley did: http://www.bagley.org/~doug/shootout/ Skimming through the figures, it seems that XEmacs Lisp takes 60-80% of the CPU time of Python, whilst taking more memory. The greater memory use is probably accounted for by the 5MB needed for a virtual machine that also includes a powerful text editor. The two languages need a similar number of lines of code to express the algorithms. Two other things I notice from this study: * XEmacs would not gain much, if anything, performance-wise from moving to a Guile engine for the Lisp code. * Ocaml, compiled to native code, is a rocket. I do not know why this language is not more popular. --- Alastair From mwh at python.net Wed Jun 13 07:35:18 2001 From: mwh at python.net (Michael Hudson) Date: 13 Jun 2001 12:35:18 +0100 Subject: All functions from self and inherited classes References: <1KFV6.110$Qo.373723164@news.euroconnect.net> Message-ID: "Christer ?stergaard" writes: > Very interesting... i'm currently working v. 2.0, and no module > "inspect" seems to be part of my pakage... Nope, when Skip saiud new he meant 2.1. > do you know if there any possibility of me fetching the module, and > thereby not being forced to upgrade the full monty? It should be gettable from http://www.lfw.org/python/, specificcally http://web.lfw.org/python/inspect.py. Cheers, M. -- surely, somewhere, somehow, in the history of computing, at least one manual has been written that you could at least remotely attempt to consider possibly glancing at. -- Adam Rixey From ullrich at math.okstate.edu Tue Jun 26 09:32:09 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Tue, 26 Jun 2001 13:32:09 GMT Subject: Is this a true statement? References: <3b3745bd.2217895@nntp.sprynet.com> Message-ID: <3b388dfd.504830@nntp.sprynet.com> On Mon, 25 Jun 2001 15:33:11 GMT, grante at visi.com (Grant Edwards) wrote: >In article <3b3745bd.2217895 at nntp.sprynet.com>, David C. Ullrich wrote: > >>>>> He's making a very finicky, nitpicking, and frankly silly point [...] >>>> >>>>I don't think the point was entirely silly! It was a valid and >>>>interesting point (despite being finicky and nitpicking!) >>> >>>Yes, it's trivially and obviously valid: a driver is a bit >>>pattern, and you can write a bit pattern to a file with Python. >>> >>>If you show an example of how this is a useful and productive >>>way to generate a device driver, _then_ it will be interesting. >>>Until then, it's just somebody chattering to hear themselves >>>talk. >> >>That's a truly remarkable attitude. Nothing is worth knowing >>unless it solves a practical problem right now. > >Not true -- but using a Python program to write into a file a >bit pattern that is known a-priori to be a device driver for a >particular OS just isn't interesting (IMO). If you used a >Python program to _generate_ the bit pattern from some higher >level source, that would be interesting. Right. Now show exactly where I said anything that would indicate that the second is not what I had in mind. It was someone else who said sure, you could just copy a device driver. It was also someone else who said ok, you could write a device driver with a hex editor as well - my reply to that said that using Python would be easier than using a hex editor. >>I actually learned something about device drivers from all >>this. Not from something that anyone actually said - I learned >>something about device drivers by assuming that people _must_ >>be making much more sense than they _appeared_ to be making, >>and trying to figure out what I could be misconceiving that >>would make all those comments that must actually be sensible >>appear like nonsense to me. >> >>"Chattering to hear themselves talk" indeed. > >I apologize -- I really thought that you knew what a device >driver was and you were being intentionally obtuse. > >>Figured out the answers for myself last night, then this >>morning the first thing I said was "no, of course in that sense >>you cannot write device drvers in Python". > >Not using currently available tools. I do maintain that it >wouldn't be terribly difficult to do, but for performance and >resource reasons it would be largely an academic exercise. The original topic was "True or False: Python can do anything C can do, just slower." How can the answer to _that_ question be anything _but_ purely academic? >Grant Edwards grante Yow! I put aside my > at copy of "BOWLING WORLD" > visi.com and think about GUN > CONTROLlegislation... David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From ChuckEsterbrook at yahoo.com Thu Jun 21 22:46:39 2001 From: ChuckEsterbrook at yahoo.com (Chuck Esterbrook) Date: Thu, 21 Jun 2001 22:46:39 -0400 Subject: Another Wart! string.find() [ was: namespace issue? ] In-Reply-To: References: <112e9d13.0106211743.39215b91@posting.google.com> Message-ID: <5.0.2.1.0.20010621223405.02b6dec0@mail.mindspring.com> At 10:19 PM 6/21/2001 -0400, Steven D. Majewski wrote: >On 21 Jun 2001, Chuck Esterbrook wrote: > > > "Steven D. Majewski" wrote in message > news:... > > [snip] > > > > > > I'ld love to see it fixed, however, I suspect that in this case, > > > many lines of installed code trumps Computer Programming for > Everybody! > > > > > > > So is it a flaw, relative to CP4E, that sequences start at index 0 > > instead of 1? An 'everybody' kind of person would think of the "first" > > element as e[1]. Only someone familiar with pointer arithmetic from C > > or assembly would think that "first" is 0. > >No -- that's not a "flaw" , it's an "engineering tradeoff" -- i.e. >you can't please everyone all the time! > >Zero is natural whenever you are thinking in terms of offsets: > every ruler starts with an implied 0 inches (or cm. or other). Rulers don't have much to do with lists. The first measures; the second contains. Also, if you ask an 'ordinary' person to write down a list of numbered items on paper, they will give you: 1. red 2. green 3. blue >Zero based indexing makes slice indexing much easier to figure -- > one-based indexing would make that more confusing to everyone. Perhaps. There are different ways to do slices. Python uses a start and a stop. Obj-C uses a start and a count. They both have their neat little properties, but in the end they seem about even. >Lots of other technical fields besides programming use zero based > indexing -- where do you think C got it ? Probably from mathematics I know exactly where C got it from: assembly. In assembly if you have a label FOO that points to your array, then to get the first element of that array you add 0, for the second add 1 (times the size of the element), for the third add 2, etc. C kept that approach. It had nothing to do algebra, trig, etc. > or engineering. Most high-school grads should be familiar with > the notation. AFAIK the standard mathematical notation for tuples is (x1, x2, ..., xN). A high school grad who remembers that will expect 1, not 0. You can find a reference at: http://web.mit.edu/wwmath/vectorc/3d/nplets.html >Yeah -- there are arguments for 1 over 0, but whatever you choose >is going to be 'wrong' for somebody, some of the time. The context I created was CP4E. Consequently, I think 1 is a much stronger case than 0. This is similar to the 3/5 = 0.6 vs. 0 debate. Under a CP4E ideology, 0.6 wins. >And not surprising C programmers does have *some* value. I suppose. :-) -Chuck From winterdk at hotmail.com Wed Jun 13 07:40:22 2001 From: winterdk at hotmail.com (Christer Østergaard) Date: Wed, 13 Jun 2001 13:40:22 +0200 Subject: All functions from self and inherited classes References: Message-ID: Hi again! I've tried both of your suggestions and can conclude the following for both: When i use inspect.getmembers([something]) or megadir([something too]) from "outside" a class, it works great. I get all methods from a certain class and it's ancestors. But, if I include the functions in GeneralClass.doc(), and try calling b.doc() i get the following: 1. the inspect only gives me methods for class B... not inherited functions (which I want! :-). 2. megadir gives me nothing, since it relies on "__bases__" (which is emtpy when called from WITHIN a class method...) Because of my urge to crack this one, i hereby send you the code for GeneralClass (called Component): As you can see, _getDocList() only iterates over list from dir(self.__class__) ... it is this part, that i want to reengineer to a recurcive method, collecting all methods from self and inherited classes. Go to #LOOK HERE :-) Looking forward to your responses... :-) [CODE SNIPPET BEGIN] """ NAME: SYNOPSIS: NOTES: SEEALSO: STORYCARD: """ class Component: """ NAME: SYNOPSIS: NOTES: EXAMPLE: BUGS: SEEALSO: INTERNALS: """ def __init__(self, attr={}, req={}, debug=0): self.attrList = attr self.reqList = req self.debug = debug def doc(self): """ NAME: doc() SYNOPSIS: FUNCTION: To write docstring for a given class and all it's methods. INPUTS: self RESULT: Text output NOTES: EXAMPLE: t.doc() BUGS: None reported SEEALSO: INTERNALS: TASKCARD: """ #Write header print "Documentation for class \"" + str(getattr(getattr(self, "__class__"), "__name__")).upper() + "\"" #print self #Write class docstring if self.__doc__ != None: print self.__doc__ else: self._noDoc("class \"" + getattr(getattr(self, "__class__"), "__name__") +"\"") self._getDocList() def _getDocList(self): """ NAME: _getDocList() SYNOPSIS: FUNCTION: To write methods and their docstring INPUTS: self RESULT: Text output NOTES: EXAMPLE: self._getDocList() BUGS: None reported SEEALSO: INTERNALS: TASKCARD: """ #LOOK HERE #Iterate over functions of current class for m in dir(self.__class__): #If function is not "private" if m[0]!="_": print "FUNCTION: " + str(m) #if anything in m.__doc__, print it if getattr(getattr(self, m), "__doc__") != None: print getattr(getattr(self, m), "__doc__") else: self._noDoc("method \"" + getattr(getattr(self, m), "__name__") +"\"") def _noDoc(self, aString): """ NAME: _get() SYNOPSIS: FUNCTION: To write a "no doc" string INPUTS: self aString: string containing class or method name RESULT: Text output NOTES: EXAMPLE: self._noDoc() BUGS: None reported SEEALSO: INTERNALS: TASKCARD: """ #print no doc string print "No documentation for " + str(aString) class tk(Component): def tst(self): pass def test(): o = Component() o.doc() if __name__ == '__main__' : test() [CODE SNIPPET END] Christer From chrishbarker at home.net Tue Jun 12 20:04:38 2001 From: chrishbarker at home.net (Chris Barker) Date: Tue, 12 Jun 2001 17:04:38 -0700 Subject: is c faster? References: <9ftlpv029hk@enews2.newsguy.com> <3B2550F5.ED7F54D@home.net> <9g4jh20712@enews2.newsguy.com> Message-ID: <3B26AE16.7186810B@home.net> Alex Martelli wrote: > whatnot. I think this is the kind of benefit one > might expect from a simpleminded 'compiler':-). That's why we need a not so simple minded compiler. I have a friend that keeps harping on the fact that LISP can be as fast as C and as dynamic as Python. Why can't Python do that? > > > it's possible) and as big as 1,000%, i.e., 10 times faster (again, > > > I haven't seen anything more than that on real code, although in > > > > I got an approx 100X speedup in my only substantial extension (still not > > that big). I was already using NumPy arrays, but there was just no way > > to "vectorize" the whole thing. I may have been able to get a 10X > > speed-up or so keeping it in just Python if I put some time into it, but > > I knew I wasn't going to get what I needed, so I went to C. > > So, the roughly-ten-times ratio (between speediest fine-tuned > Python and C) might still apply here (maybe)... Maybe. My 10 X speed up in Python is an optimistic guess, based nno my extensive MATLAB experience. I'm not sure I see the point of testing it, however. Another note: in my example, I was making extensive use of NumPy, whithought it, it would have been hopeless in Python. NumPy arrays are homogenous sequences, so if my hypothetical not-so-simple-minded compiler saw a couple of loops like: A = array(stuff,Float) #Py2C A:type=Float,rank=2 for i in range(A.shape[0]): for j in range(A.shape[1]): A[i,j] = A[i,j] *2 It should be able to know what the types are the inside of that loop, (if you gave it the hint that A was of rank 2 anyway) and turn this into as fast as C compiled code. Of course, this is trivial, and could be done with NumPy as A = A*2, or multiply(A,2,A), but more complex cases would work as well. If Py2C knew about NumPy arrays, and you had a way to give it a couple of hints, you could save a lot of C coding! hmm, maybe I'll actaully try to work on this some day! It seems that the general case of Python knowing about homogenous sequences could make for far more optimised Python interpreting as well. for example: map(string.split, list_of_strings) could be highly optimized if Python has kept track of the fact that list_of_strings was in, fact, a list of strings. "All" you'd have to do is keep a "homogenous" flag with the list, which would get turned off if you ever added anything non-homogenous to it, and then when "map" was called, itwould only have to check the type of the first item. I know that many, if not most, of my lists are homogenous, I imagine that's true for a lot of folks. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From philh at comuno.freeserve.co.uk Fri Jun 15 07:18:40 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 15 Jun 2001 12:18:40 +0100 Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> Message-ID: On 15 Jun 2001 02:37:51 GMT, David LeBlanc wrote: > >Creating an inherent means of creating constants (or my preferred >aliases) is good computer science as someone else mentioned in a reply >post. Magic numbers are bad - they're sloppy programming and a source of >errors if they must be used in several places etc. OTOH, aliases clarify >program meaning and imho make things more comprensible to newbies. Surely a newbie can understand that if you assign a variable to a value, and then never change it, then it is working as a constant. I have no problem having cxonstants like this, e.g. programVersion = "0.2.7" it seems to me that: alias programVersion: "0.2.7" is no clearer, and is an extra something for a learner to have to learn. Entities should not be multiplied unnecessarily! > I >think all would agree that "if something is true:" is clearer then "if >something is not 0:". What's wrong with: if something: which is what I would use here. > Likewise, "userpermissions" is much more meaningful >then 0677 Indeed so. And in python, one can say: userPermissions = 0677 (Personally I prefer the way Smalltalk handles non-decimal radixes, i.e. 8r677) >One can certainly argue that this is syntactical sugar. It does however >serve a multitude of good purposes among which are: maintainability; >clarity; consistancy; correctness; good programming habbits; When I hear that phrase, I reach for my gun. Go and use Pascal or Eiffel if you're into bondage-and-discipline. -- ## Philip Hunt ## ## philh at comuno.freeserve.co.uk ## From steff at rebecca.chermisey.fr Thu Jun 14 17:38:11 2001 From: steff at rebecca.chermisey.fr (=?iso-8859-1?Q?St=E9phane?= BAUSSON) Date: Thu, 14 Jun 2001 21:38:11 GMT Subject: Parsing C code with Python Message-ID: Hello, I am interested by examples of program parsing C code. The C code generates raw data, and these raw data I want to parse them after with python to display the data in something meaning full for human. The problem is how to analyze the C code, with the struct, union, etc .... If somebody has some idea ... Stephane -- stephane.bausson at free.fr - Toulouse (France) From romain.guy at jext.org Thu Jun 21 09:48:04 2001 From: romain.guy at jext.org (Romain Guy) Date: Thu, 21 Jun 2001 15:48:04 +0200 Subject: String --> int References: <9gsl08$gsl$1@wanadoo.fr> Message-ID: <9gstpp$3hc$1@wanadoo.fr> tahnks -- Romain "Java Swinguer !" Guy romain.guy at jext.org www.jext.org "Now, don't you worry. The saucers are up there. The graveyard is out there. But I'll be locked up safely in there." - Paula Trent, Plan 9 From Outer Space "Skip Montanaro" a ?crit dans le message news: mailman.993126872.31239.python-list at python.org... > > Romain> Assuming fsock is a File objet, when I do: > Romain> var = fsock.read(4) > > Romain> I get a String. I'd like to convert it into an integer. > > Check out the struct module. > > From m.faassen at vet.uu.nl Fri Jun 29 19:25:26 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 29 Jun 2001 23:25:26 GMT Subject: PEP scepticism References: <3dbsn71iac.fsf@ute.cnri.reston.va.us> Message-ID: <9hj2p6$bdu$6@newshost.accu.uu.nl> Andrew Kuchling wrote: > "Tim Peters" writes: >> So what do you do about the curious disconnect between supply and demand in >> Open Source projects? You got list comprehensions because Greg Ewing (and > Beats me. This is nothing new, in that interesting tasks get worked > on, and boring ones don't. I haven't updated the bookstore in a > while, or tried to kick the catalog-sig into life, or released various > bits of software sitting on my disk, because such tasks would be > pretty boring, and I have more entertaining possibilities open to me. > Greg Ward moved back to Montreal, and now does practically no hacking > or writing in his spare time at all. Unfortunately, practically > *everyone* considers these tasks dull. Which is why a system more or less *forcing* core developers to look at these issues *only* for a while may be good. See my earlier post on that. We could propose that all uneven release of Python have no changes to the interpreter that change the language syntax/semantics. (this is more strict than I proposed in my previous post, as I saw Tim is actually more afraid of the 'make the semantics more coherent' attempts than new syntactic features). That would force the core developers to focus on: a) bug fixes b) optimizations to the interpreter c) library changes d) infrastructure improvements (catalog, etc) for a while, until the next release comes around. Wouldn't that help? Of course this measure could be considered rather draconian. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From tim.one at home.com Fri Jun 1 15:42:50 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 1 Jun 2001 15:42:50 -0400 Subject: Iteration index In-Reply-To: <20010601153537.A7896@harmony.cs.rit.edu> Message-ID: [D-Man] > ... > It is probably O(n) because it is a linked structure and indexing > isn't a computed offset (like C arrays) Python lists are contiguous vectors, same as C arrays in that respect. see-listobject.c-ly y'rs - tim From aleaxit at yahoo.com Mon Jun 11 15:27:32 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 11 Jun 2001 21:27:32 +0200 Subject: Basic gadfly question References: <9e6V6.15027$lq1.4843531@typhoon.austin.rr.com> Message-ID: <9g364p02a5k@enews1.newsguy.com> "W. Jarrett Campbell" wrote in message news:9e6V6.15027$lq1.4843531 at typhoon.austin.rr.com... ... > I'm new to the world of Python, Databases, and SQL but it has been a fun > adventure so far! > > I have basic question regarding the Gadfly package. I'm working with the > sample database generated by the gftest.py module. I'm trying to execute an > SQL statement such as: > > INSERT INTO frequents (DRINKER, BAR) values ('Jarrett', 'cheers') > > When I do this I get an error back saying that I did not define a value for > the column 'PERWEEK' > > My questions are these? Do you have to set all values in the insert > statement or is there some way around this? Is this bad database > programming form to want to set only some fields? Is this related to gadfly > not supporting Null values? Yes, it's related to Nulls not being supported. NULL means "value not known". If a column is constrained to NOT NULL, and in Gadfly in practice they all are (although you're not allowed to SAY so in the CREATE TABLE statement:-), this means you HAVE to give a value for it on each insert. It's absolutely NOT bad DB design to desire NULL fields (that's why they're there... Dr Codd well knew whereof he spoke!-) -- it's just that you can't have them in Gadfly. > When using the ODBC package in the win32all distribution, I can achieve this > functionality with MS Access databases. I wanted to stick with gadfly to > remain platform independent and not require my users to purchase Access. > Any advice? The Jet engine (which is probably what you mean by the widely but incorrectly used name "MS Access database" -- Access is just a front end, able to interface to many different engines -- MS marketing was first guilty of these confusions, many years ago) is freely redistributable as part of your application. So are MUCH better engines -- if you're keen on Microsoft products, I suggest MSDE, the engine underlying MS SQL Server -- you cannot distribute the GUI tools for various admin tasks etc, but the engine and some basic command line tools are OK (and you can use ODBC, though Lemburg's mxODBC is no doubt preferable to the odbc package currently in the win32all pack). BTW, "win32all's" odbc.cpp has some horrid bugs, although I guess Hammond's build process may make them disappear (I do not have a sufficient understanding of that build process to say for sure!). As distributed, for example, it builds objects with PyObject_NEW (yes, the _macro_...), then frees them with PyMem_DEL (the macro, again). I don't think you're supposed to do that (I was rightly admonished for it when I did it in a toy source I posted:-), and sure enough it "reliably" crashes on my machine. Fortunately, it's easy enough to fix, the sources are still marked as public domain ("Donated to the Python community by EShop"), and distutils (what a GREAT idea!) make it trivial to package the thing up, so I did although unsure of how to feed it back to win32all (not understanding the basis of the special build process makes that a bit iffy:-). Unfortunately I still have a crash in some error-cases (apparently only when using the thing with Ocelot's ODBC -- Ocelot is an excellent, tiny, free SQL-92 standard-with-SQL99-extensions database -- not open source, nor redistributable, one has to go to their site and download it, I think their business model is selling books, training and consulting -- but I don't think the bug is with Ocelot, as other ODBC clients works happily with it:-) -- I keep telling myself I'll debug it well one of these days, but round tuits supplies are scarce... Anyway... this is all by the by, because...: This won't let you be cross-platform, admittedly. Gadfly is quite attractive that way. Besides the NULL's, there's the fact that it uses the now-obsoleted regex and regsub modules, so it spews warnings under Python 2.1 -- somebody should port it...:-). Also attractive is MySQL, though, particularly now that it FINALLY supports some form of transactions; and PostgresSQL (maybe overkill for your needs). Lots of people seem keen to donate DB's, at least to developers (SAP, for example, seems to be donating it freely; Borland, with Interbase; Oracle, and IBM with DB/2, with restrictions...). But that still doesn't solve the problem of finding ONE simple, lightweight, usable, standard-ish SQL DB for free, unencumbered cross-platform redistribution in a package with one's programs using it... Alex From aleaxit at yahoo.com Wed Jun 20 15:14:15 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 20 Jun 2001 21:14:15 +0200 Subject: OOP in Python References: <4e2ddb70.0106200954.11faa218@posting.google.com> Message-ID: <9gqsku01cma@enews1.newsguy.com> "Jonas Bengtsson" wrote in message news:4e2ddb70.0106200954.11faa218 at posting.google.com... > Ok I admit - I am a Python-newbie! > > What about local variables and class variables when dealing with > classes? > With local vars I mean temporaryly used variables in a function. Will > they be treated as 'normal' instance attributes? Do I have to delete > them by myself when I'm leaving a function? No, local variables are local, and go away as soon as the function terminates. > With class vars I mean if many class instances of a class may share a > variable. In C++ this is accomplished by a static variable. How do I > do in Python? A class may have attributes (it's also possible to use a module attribute, aka 'global variable', of course). Example: class Totalizer: grand_total = 0 def inc(self): self.__class__.grand_total += 1 def dec(self): self.__class__.grand_total -= 1 def __str__(self): return "Total is %d"%self.__class__.grand_total # two separate instances one = Totalizer() two = Totalizer() # but they share state! Try: one.inc() two.inc() one.inc() two.inc() print one You may choose to spell the shared-variable access as Totalizer.grand_total += 1, but that relies on Totalizer being a global name. The way I've chose to spell it breaks the sharing if separate classes inherit from Totalizer -- you may choose either semantics. Alex From m.faassen at vet.uu.nl Tue Jun 26 07:30:03 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 26 Jun 2001 11:30:03 GMT Subject: new to python References: Message-ID: <9h9rnr$c54$1@newshost.accu.uu.nl> Beebe wrote: > Hello comp.lang.python, > I am a Linux User and I am new to Python Programming and this > newsgroup. I don't really know what python is all about so it would be > much appreciated if you would answer my following questions. > - Is python like c/c++ where you can make pretty much any kind of > program you want whether is be games, gui apps, etc. or is it like cgi > where you can only use it in websites? You can make whatever you like in Python. One advantage you to have with C and C++ code is that this can be compiled with an optimizing compiler, while Python is interpreted. This means that while it is definitely easier to write software in Python, it's somewhat easier to make your C/C++ code run really fast. If speed is no such primary concern Python is fine, however, and please do note that there's a _lot_ you can do to improve the speed of a Python program (including moving little speed critical parts to C or C++ extension modules). For many types of application you'd like to develop you need a set of extra libraries that enable Python to do something new. For instance, if you want to program GUIs, you could install PyQT if you want to use the QT library, or PyGTK for GTK GUIs. Tcl/Tk is needed if you want a cross-platform Tk based GUI (the library you need is Tkinter). Then there's PyWX for the wxWindows interface; there are bindings for FOX and many other GUI libraries as well. For games, check out www.pygame.org. - Is python object oriented? For most definitions of object oriented, sure. There's objects, classes, inheritance, polymorphism, and even more important, dynamic type checking. > - Should I develop in Python? No! The PSU will come for you if you do. :) Seriously, I don't know you and you haven't made it clear what exactly you want to do with it, so I can't really say. :) I just can say it's easy to learn, powerful, and many people like it, including myself. > Is it good for programming, It's a programming language; any programming language makes the claim it's good for programming. :) > is it powerfull Any programming language makes this claim too. Depends on what powers you'd like to have. To a great extent programming languages tend to give you the same set of powers; it's just some powers are easier to use in some languages than in others. > and are job opportunities good for Python developers? If you want good job opportunities, learn Java. :) If you learn Python you might have to look a bit harder to find an interesting job, but this depends on where you are and what kind of job you want. > - When I make a Python program, do I just leave it as a .py file or is > there a way to make it into some kind of executable file like in C++? Usually we leave them as a bunch of .py modules, but there are tricks to pack them up together with the Python interpreter so it'll be stand alone. Since you're on Linux and you might very well be creating in-house or open source software, there is usually no good reason to do that. > When I make a program in Python, how do I distribute it out to people? > Do I just send out the .py file? Usually your program will consist of a bunch of .py files, so you'd send those, together with any supporting files your program may need (packed up in a tar.gz file is the usual thing to do in Linux). On Linux most distributions come with packages for the Python interpreter; some even install Python by default (such as Red Hat). > Does the user need some kind of runtime environment or something? Yes, the Python interpreter and the standard libraries. Note that the same is true for most languages; virtually all C programs need a bunch of supporting libraries as well to work, for instance. Of course, most operating systems provide this library by default, so you don't have to manually install it. > Do they need to download something else rather than my program? A Python installation if this doesn't come with their distribution. Good luck, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From pwxau at yahoo.com.au Wed Jun 27 23:24:12 2001 From: pwxau at yahoo.com.au (Patrick Wray) Date: Thu, 28 Jun 2001 13:24:12 +1000 Subject: KDE and Windows References: <993660235.135465@seven.kulnet.kuleuven.ac.be> Message-ID: <1ax_6.13372$qJ4.526424@ozemail.com.au> "D-Man" wrote in message news:mailman.993663428.8908.python- > [...] However Qt is not free for Windows (as-is). There is now a "free beer" version of Qt for Windows (released yesterday). Unlike it's X11 cousin, it's binary only, and not GLP'd. As I understand it, their licensing policy gives you these choices: If you want to write open-source software for Windows, you can use the BSD or Artistic License, or something similar. You can't use the GPL because that would require you to distribute the Qt source. (If you want to go GPL, just use the X11 version). If you want to write closed-source freeware for Windows, you don't need to buy a license. If you want to write commercial software for Windows, either for sale or for in-house use in a commercial setting, you obviously need to buy a commercial license. Perhaps someone who IAL can clarify how this affects PyQT. From chrishbarker at home.net Tue Jun 19 15:24:44 2001 From: chrishbarker at home.net (Chris Barker) Date: Tue, 19 Jun 2001 12:24:44 -0700 Subject: Extracting words from a string : *fast* References: <0UEX6.268$8H6.170349568@news.telia.no> Message-ID: <3B2FA6FC.1346CAFE@home.net> Thomas Weholt wrote: > I need to extract words from a string. This method will be used extensivly > in a indexer so it needs to be as fast as possible. You might want to check out mxTextTools, adn see if it can help you: http://www.lemburg.com/files/python/ -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From guido at python.org Fri Jun 29 08:47:01 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 29 Jun 2001 12:47:01 GMT Subject: Comment on PEP-0238 References: <3B3BE855.A6223E70@3-cities.com> Message-ID: "Robert J. Harrison" writes: > From recent discussion it is not clear to me if > PeP 0238 (http://python.sourceforge.net/peps/pep-0238.html) > has gained favor, or not. > > Two comments. First, its major emphasis is on benefitting > inexperienced programmers, but, by being inconsistent with > other mainstream languages, it is not clear to me that it > is actually a benefit for them. Perl is not mainstream? ;-) > It is certainly not a benefit for experiencd programmers that > routinely switch between Python and other languages. Your argument ends up pleading to repeat the mistakes of other languages -- in fact, taken to the extreme it would mean there should be only on language. I don't find it a very strong argument. > Second, even if the change of behavior for divide (/) is accepted, I > see no point in introducing the // operator. A plethora of > infrequently used operators will make Python more Perl-like. Better > an explicit 'cast' to integer. I agree here. But, unless more people speak out in favor of this PEP, it's not going to happen in Python 2.2 -- there's too much other stuff on the table already. --Guido van Rossum (home page: http://www.python.org/~guido/) From tdickenson at devmail.geminidataloggers.co.uk Fri Jun 29 04:56:04 2001 From: tdickenson at devmail.geminidataloggers.co.uk (Toby Dickenson) Date: Fri, 29 Jun 2001 09:56:04 +0100 Subject: PEP 255: Simple Generators References: Message-ID: <8hgojtgi94l6ldiafvi06mhfd7cnlo1fbp@4ax.com> David Eppstein wrote: >In article , > "Tim Peters" wrote: > >> Tail-recursion is pretty much insane for that in Python, as >> processing list[0] then recursing on list[1:] turns a speedy task into a >> quadratic-time mess. > >So, back to the topic of PEP255: am I the only one bothered by the fact >that the inorder example in the PEP is quadratic time, and that it seems >difficult to use simple generators to yield a tree's nodes in inorder in >linear time? As implemented today, yes it is quadratic. If that quadratic term is actually dominant for sensibly deep trees, then I suspect it would not be too hard to optimise away this very common case at C level: for x in : yield x Toby Dickenson tdickenson at geminidataloggers.com From see at my.signature Tue Jun 12 02:06:57 2001 From: see at my.signature (Greg Ewing) Date: Tue, 12 Jun 2001 18:06:57 +1200 Subject: Why no 'elif' in try/except? References: <3B1A06EE.F484930A@snakefarm.org> <9fuqou$rep$1@brokaw.wa.com> Message-ID: <3B25B181.66E0756D@my.signature> Jonathan Gardner wrote: > > Wouldn't an 'eltry' (= "else: try:" ) make more sense? While we're hypergeneralising, how about allowing any sequence of keyword1: keyword2: keyword3: ... be contracted to keyword1 keyword2 keyword3... : e.g. if fooble: ... else: while x < 10: ... becomes if fooble: ... else while x < 10: ... -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From m.faassen at vet.uu.nl Fri Jun 15 17:09:50 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 15 Jun 2001 21:09:50 GMT Subject: call-by-reference (was Re: Any other Python flaws?) References: <9gcu9g$gm4$1@newshost.accu.uu.nl> <9gd4tq$odb$1@news.mathworks.com> <9gdn37$61k$3@newshost.accu.uu.nl> <9gdt4j$b86$1@news.mathworks.com> Message-ID: <9gdtiu$61u$1@newshost.accu.uu.nl> jcm wrote: [snip] > Note I said you can't change the value of a _variable_ in your > caller's scope. Changing the state of an object isn't the same. I think the use of the word 'variable' is ambiguous. :) When I hear variable I'm not quite sure if we're talking about the reference or what's referenced. Perhaps that's just me, though. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From zihonglu at home.com Sun Jun 24 19:45:09 2001 From: zihonglu at home.com (zihonglu) Date: Sun, 24 Jun 2001 23:45:09 GMT Subject: win32 extension installation problem References: <3B355CE8.8060605@ActiveState.com> Message-ID: <9YuZ6.123682$%i7.85882471@news1.rdc1.sfba.home.com> Mark, Thanks for your reply. I have tried changing the version in Python21.dll to "MyPython21", changing registry version accordingly, and put the file back to c:\winnt\system32 directory, manually put win32 extension files under the python directory. It worked. However, since the Python21.dll has been changed, I wanted it to be located in c:\MySoftware\Python to prevent being accidentally overwritten . As far as python is concerned, it seems to work fine. I could register the PythonService.exe as well. However, I can't start my python service. The problem went away as soon as I put the modified Python21.dll back to the system32 directory. I vaguely remember I have the same problem with PyWinTypes.dll. Any solution? -Zihong Mark Hammond wrote in message news:3B355CE8.8060605 at ActiveState.com... > zihonglu wrote: > > > We are building a product with python and the win32 extension, in win32 > > environment. I have a problem in shipping the product with win32 extension. > > > > What I really want is to have the python interpreter and the win32 extension > > installed inside our product's directory, say c:\MySoftware\Python, and in > > the registry, set python's keys under HKLM\Software\MySoftware\Python, > > instead of the typical HKLM\Software\Python, to avoid conflict with > > customer's possible existing python installation or possible future python > > installation change. I can achieve that by change python's source code to > > look for the new registry key. > > > The best solution is to change Python's view of the core registry key. > > The default Python registry key is > HKLM\Software\Python\PythonCore\{version-id} > > This {version-id} is loaded from the Python.dll string resource table. > You can open Python.dll in MSVC (ie, the pre-built version - no need to > rebuild anything) and locate the one-and-only string resource. This will > say, eg, "2.1". Hence the registry used for 2.1 is: > > HKLM\Software\Python\PythonCore\2.1 > > You can change this to any value you like (numeric or otherwise). This > will change the registry key used by that DLL. FYI, this value is > reflected into Python as sys.winver - however, you can not simply change > it at runtime, as the value has already been used by the time you get > your first opportunity to change it. > > So, although you can not simply change the "root" of the registry, > changing this version string will give you your own playground that will > not affect pre-installed versions. > > > However, since I am also using the win32 > > extension, it looks HKLM/Software/Python for its installation and execution, > > not my new keys. I also use PythonService.exe, which checks for its key > > under HKLM/Software/Python for registering the service, not the one I set > > under my new keys. > > > You probably don't want to use the win32all installer - simply install > these extensions along with your software into the appropriate directories. > > At runtime, there is nothing hard-coded to use the version number. > pythonservice.exe and all other code that needs the registry at runtime > uses sys.winver to determine where to put it. Hence, pythonservice.exe > running with a patched python.dll should magically do the right thing. > > This mechanism was added specifically for this situation, so you may as > well use it. > > > > To solve these problems, how many places I need to change the win32 > > extension source code, if I can find them? Is there a better way? Where do > > I get the source code? > > You get the source code via > http://starship.python.net/crew/mhammond/cvs.html > > Mark. > From graham at coms.com Fri Jun 22 07:16:23 2001 From: graham at coms.com (Graham Ashton) Date: Fri, 22 Jun 2001 12:16:23 +0100 Subject: A recommendation on programming tutorials? References: <7417e9e.0106212115.20f3fafe@posting.google.com> Message-ID: In article <7417e9e.0106212115.20f3fafe at posting.google.com>, "James" wrote: > I've just started studying the Python programming language 3 days ago. I am constantly reading bits of Dive Into Python by Mark Pilgrim. If you've got some programming experience then it's a very good way to find out what Python is capable of, and how it goes about it. It's a work in progress and is still being written, but you wouldn't know whilst reading it. http://diveintopython.org/ From loewis at informatik.hu-berlin.de Mon Jun 25 10:09:34 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 25 Jun 2001 16:09:34 +0200 Subject: problem building 2.1 on SunOS 5.7 References: <3B325CF1.9A970D6D@sage.att.com> <3B3362CF.5210C665@sage.att.com> Message-ID: Garry Hodgson writes: > > /usr/local/lib/gcc-lib/sparc-sun-solaris2.4/2.7.2/include/time.h:90, [...] > okay, i'm answering my own question. but just in case anyone else trips > over this, i got it to work using ./configure --without-gcc > > the regular sun c compiler built it without a hiccough. If you would use a gcc version compiled for Solaris 7, instead of the one compiled for Solaris 2.4, gcc would work as well. Alternatively, if you just delete your outdated gcc, configure would not attempt to use gcc. Regards, Martin From oblivious at web.de Sat Jun 16 10:38:51 2001 From: oblivious at web.de (Dominic) Date: Sat, 16 Jun 2001 16:38:51 +0200 Subject: qt or gtk? References: Message-ID: <3B2B6F7B.D7A3D8C6@web.de> Amardeep Singh wrote: > On Sat, 16 Jun 2001, Dominic wrote: > > > > > > > Rainy wrote: > > > > > I want to learn python gui programming in linux. I think tk looks too ugly, so > > > I narrowed down the choice to two main contenders, qt and gtk. Which of these > > > has more complete and up-to-date python bindings? Are there other reasons > > > to prefer one of these over another for python gui work? > > > > > > > The QT toolkit is technically better (quality of code). > ^^^^^^^^^^^ ^^^^^^ > > care to explain why? > Sure. When I compared the source code of qt and gtk some time ago I came to the conclusion (other people might think different though) that qt's code is 1) easier to understand and 2) better structured, 3) more complete, 4) few bugs, | whereas gtk's (way of -) emulating oo-features in c and signal/callback looked clumsy to me. I mean all the code seemed to be like a quick hack to me. But I've to admit that I used gtk twice for some programming taks at university while playing with glade. The code worked fine, but was also very ugly then. I also think it's ugly to code own widgets with gtk because of it's way to emulate oo. QT has a rich set of classes for all kind of tasks, it's well tested and documented. It's something which I would associate with industry quality code or whatever term you would use for solid, well-done code. (Because industry quality code sounds like opensource could't be good, which is wrong.) Last but not least it's the best get the job done in C++ on X-Windows. (Though for python one would better use tk.) P.S. I dislike gtk only because of technical reasons. I myself like free-software and open-source like python, perl, FreeBSD and Linux (which are running on my own computer. :-) Ciao, Dominic > > So some time > > has passed since I had compared them. But I do not know how good > > or bad the bindings are. I suggest you should use the tk toolkit > > it seems to have a good binding and comes with the standard > > python distribution. And the TCL/TK toolkit has a high quality. > > So TK would be best in my humble opinion, and QT second. > > (QT is not completely free but that doesn't make it bad, actually > > it's the best X- Toolkit for C++ programming.) > > > > Ciao, > > Dominic > > > > > > > > > > > > -- > > > "Your password must be at least 18770 characters and cannot repeat any of your > > > previous 30689 passwords. Please type a different password. Type a password > > > that meets these requirements in both text boxes." > > > (Error message from Microsoft Windows 2000 SP1) > > > > From gtcopeland at earthlink.net Sat Jun 2 15:42:44 2001 From: gtcopeland at earthlink.net (Greg Copeland) Date: 02 Jun 2001 14:42:44 -0500 Subject: Python + threads + wxWindows = segfault, help! References: <9f8f7j$k5c$1@panix6.panix.com> Message-ID: Thanks! My forehead won't be so sore now! BTW, if you need any help working on it, or you just want someone to help test, please let me know. I'll be glad to help. Thanks again for the response!!! Greg P.S. This application does not use wxPostEvent(), so I'm guessing the problem doesn't lie there. "Robin Dunn" writes: > > The application design is using the parent for the GUI and > > threads for communication. Data is passed back and forth via > > Python's Queue class. > > > > Most of the segs that I get seemingly have to do with threads. > > I think I'm the only SMP user on the project and oddly enough, > > I think I'm the only user seeing issues like this. > > This is a known bug that has been around for some time. It only happens on > SMP hardware, which I don't have yet, so there have been a couple blind > attempts at a fix that have failed. > > My new SMP motherboard and processors and etc. arrive next week, so > hopefully soon I'll be able to better understand the problem and then come > up with a solution. (Just don't tell my wife that all this new hardware > ($$$) was only bought to squash a bug in free software...) > > NT and Win2k users can work around the problem by telling the OS to keep the > process on just one processor: > > import win32api, win32process > cp = win32api.GetCurrentProcess() > win32process.SetProcessAffinityMask(cp, 1) > > > You can keep track of the bug here: > http://sourceforge.net/tracker/?func=detail&aid=223169&group_id=9863&atid=10 > 9863 > > > -- > Robin Dunn > Software Craftsman > robin at AllDunn.com Java give you jitters? > http://wxPython.org Relax with wxPython! > > > > > -- Greg Copeland, Principal Consultant Copeland Computer Consulting -------------------------------------------------- PGP/GPG Key at http://www.keyserver.net DE5E 6F1D 0B51 6758 A5D7 7DFE D785 A386 BD11 4FCD -------------------------------------------------- From gerhard.nospam at bigfoot.de Sat Jun 16 12:11:57 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sat, 16 Jun 2001 18:11:57 +0200 Subject: gzip.py failure References: Message-ID: On Sat, 16 Jun 2001 16:38:57 GMT, John Weeks wrote: >I'm running Python 2.0 from the SuSE 7.1 distribution. > >I'm getting an attribute error when trying to umcompress a gziped file. The >error occurs on line 210 of the gzip.py module: > > if self.decompress.unused_data != "": > >There doesn't seem to be an "unused_data" attribute for the "decompress" >object. > >Running this program: > > from gzip import * > def gf(): > f=GzipFile("g.data","r") > c=f.read() > print c > > gf() > >produces the following: > > Traceback (most recent call last): > File "tt.py", line 7, in ? > gf() > File "tt.py", line 4, in gf > c=f.read() > File "/usr/lib/python2.0/gzip.py", line 149, in read > self._read(readsize) > File "/usr/lib/python2.0/gzip.py", line 210, in _read > if self.decompress.unused_data != "": > AttributeError: unused_data > >Anybody have any ideas? On my second SuSE 7.1 machine I still have Python 2.0, so I tried there. Let me guess! You have Zope installed? I knew 8-) I have had a similar problem, and uninstalling Zope helped. Your test script runs fine w/o Zope, but crashes w/ Zope installed on my machine. Consider this: gerhard at gargamel:/tmp > rpm -qf /usr/lib/python2.0/lib-dynload/zlibmodule.so python-2.0-6 gerhard at gargamel:/tmp > rpm -qf /usr/lib/python2.0/lib-dynload/zlib.so zope-2.2.5-0 Seems the Zope RPM installs a different zlib module and Python loads zlib.so instead of zlibmodule.so I'd recommend that, if you don't need Zope, throw it away, else try deleting/renaming that zlib.so Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://highqualdev.com public key at homepage public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From t_messmer at yahoo.com Wed Jun 13 13:20:54 2001 From: t_messmer at yahoo.com (Tom Messmer) Date: 13 Jun 2001 10:20:54 -0700 Subject: os.statvfs on FreeBSD Message-ID: For some reason the default installation of python-1.5 and Python-2.0 on FreeBSD(From the ports collection) does not include the os.statvfs() routine. Does anyone know A. Why? and B. How to fix it? I need this thing! Thanks! Tom From root at rainerdeyke.com Fri Jun 22 14:06:08 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 22 Jun 2001 18:06:08 GMT Subject: File name from file descriptor? References: <3B335A1E.809B3FF7@snakefarm.org> Message-ID: "Carsten Gaebler" wrote in message news:3B335A1E.809B3FF7 at snakefarm.org... > Carlos Ribeiro wrote: > > > functionality depend a lot on the OS being used. Could you please tell us > > why do you *need* to make it work using file descriptors? > > The problem is this: I have a script that is called like > > ./myscript.py < somefile > > where somefile is a text file which may or may not be gzipped. To > determine whether or not the data is gzipped I read in one byte via the > gzip module. If that raises an exception I know the data is not gzipped. Even if 'gzip' accepts the first byte, it might not be a gzipped file. > But I'd miss the first byte if it is gzipped. Yes, I could store this byte > somewhere and then pass it around somehow, but ... you know? :-) So I'd > like to open a second 'instance' of the file for reading but I only have > sys.stdin's file descriptor. If you have enough memory, a better approach would be to read all of 'sys.stdin' into memory (with the 'read' method) and use the 'cStringIO' module to create a stream. Multiple 'cStringIO' streams can use the same string as source. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From shredwheat at mediaone.net Sat Jun 2 13:40:50 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Sat, 02 Jun 2001 17:40:50 GMT Subject: What does x[:]=[4,5,6] mean? References: <9fb7cu$lq6$1@newsreaderg1.core.theplanet.net> Message-ID: "Franz GEIGER" wrote > In site.py I saw > sys.path[:] = L > What does this mean? Why is the '[:]'? Why not simply > sy.path = L ? hello franz. what this syntax means is, replace the contents of a list with a different list. the reason "sys.path = L" does not work, is it actually changes sys.path to reference a different list. the original sys.path list is unchanged in memory. on its own this could work other way, but consider when more than one variable is referencing the same list. for example: >>> list1 = [1,2,3] >>> list2 = list1 >>> print list1, list2 [1, 2, 3] [1, 2, 3] >>> print id(list1), id(list2) 7937452 7937452 #now lets try changing with the [:] syntax >>> list1[:] = [4,5,6] >>> print list1, list2 [4, 5, 6] [4, 5, 6] >>> print id(list1), id(list2) 7937452 7937452 #now we'll change without the [:] syntax >>> list1 = [7,8,9] print list1, list2 [7, 8, 9] [4, 5, 6] 7936508 7937452 hopefully this examples well enough what i've described up top. :] From gardner at cardomain.com Thu Jun 14 14:06:51 2001 From: gardner at cardomain.com (Jonathan Gardner) Date: Thu, 14 Jun 2001 11:06:51 -0700 Subject: VI References: Message-ID: <9gauc2$mth$1@brokaw.wa.com> F. Tourigny wrote: > VI is fun in its own special way, and portable, > and I'm using it all the time but, personnaly, > I definitely wouldn't promote its use for regular > python programming, expecially for large scripts. > Relatively powerful, but too basic. > Au contraire... I find the new feautures in Vim 6.0 to be quite useful for programming python. You can fold text based on its indention level. Isn't this a minimal way of folding text with *no* added effort on the programmer's part? I admit *vi* is too basic, but *vim* is extremely useful. From mlh at idi.ntnu.no Sat Jun 30 20:22:53 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Sun, 1 Jul 2001 02:22:53 +0200 Subject: Python for air traffic control? References: Message-ID: <9hlqgt$sca$1@tyfon.itea.ntnu.no> "Russ" <18k11tm001 at sneakemail.com> wrote in message news:bebbba07.0106291642.6c799d15 at posting.google.com... > I am thinking about using Python for a unique safety-critical > application in air traffic control. It will monitor a few hundred > aircraft for conformance to assigned trajectories, and it will > initiate an automatic alarm (for both controller and pilot) if an > aircraft deviates from its assigned trajectory and is in danger of a > collision. (The trajectory and tracking data will come from existing > C/C++ programs.) The software must be as simple, clean, and robust as > humanly possible. The default languages here are C/C++, but I am > toying with the idea of using Python instead. However, I am a bit > nervous about the lack of type checking and function prototyping, > among other issues. Is Python up to this task? Thanks for your > insights. Just an amusing parallel... A snippet from the current JDK (Java) license: --- begin --- 8.1 Licensee acknowledges that Licensed Software may contain errors and is not designed or intended for use in the design, construction, operation or maintenance of any nuclear facility ("High Risk Activities"). Sun disclaims any express or implied warranty of fitness for such uses. Licensee represents and warrants to Sun that it will not use, distribute or license the Licensed Software for High Risk Activities. ---- end ---- I seem to remember a notice in earlier licenses about air traffic-control as well (which is why I at first thought your posting was a joke), but it may just be my mind playing tricks on me. I'm sure Python can be fine for high risk systems... But perhaps you should look into one of the few languages actually designed for this sort of thing, Ada? Just a thought... And, of course, there are books out there on how to remove as many bugs as possible from your programs... I like "Toward Zero-Defect Programming" by Allan M. Stavely [1]. Implementing its principles may not be an easy task, but it would probably increase the stability of the system. (And, having a couple of backup-servers running might not be a bad idea either ;) [1] http://www.amazon.com/exec/obidos/ASIN/0201385953/ -- Magnus Lie Hetland http://www.hetland.org "Reality is that which, when you stop believing in it, doesn't go away." -- Philip K. Dick From aleaxit at yahoo.com Sun Jun 17 08:01:09 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 17 Jun 2001 14:01:09 +0200 Subject: Python version of IQ has been updates (IQ v0.34.python) References: <505.566T11T1243597threeseas@earthlink.net> <3B2A7F5E.MD-1.4.4.padf@ihug.com.nz> <3871.567T2214T9794928threeseas@earthlink.net> <87puc3ao42.fsf@pooh.honeypot> Message-ID: <9gi679018ia@enews1.newsguy.com> "Kirk Strauser" wrote in message news:87puc3ao42.fsf at pooh.honeypot... ... > > There was a recent article on slash dot about Python becomming GPL > > compatiable. It's open source and has a rich pattern matching module > > amoung many other note worthy things about it. ... > Have you ever looked into Perl? We use it almost exclusively for > integrating large distributed systems, and its regular expression system is > second-to-none in my experience. Python's a good language (from what I hear > - I keep meaning to look into it), but Perl has a lot going for it also. It In terms of RE's, I think one can consider Perl and Python about even. Perl has RE's integrated right inside the language, Python chooses a more modular and O-O approach. This generalizes to other features too: in Perl, they're "parts of the language" -- in Python, they are in standard modules, generally with an OO architecture. Unless one really loves modular and OO approaches, or simple and clean syntax, one can consider the resulting functionality to be roughly equivalent in power. For RE's in particular, the syntax of the RE's themselves is, I believe, close to identical. The licensing situation is also roughly equivalent. Alex From fredrik at pythonware.com Mon Jun 4 10:08:45 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 04 Jun 2001 14:08:45 GMT Subject: xmlrpc Server References: <2f14b602.0106030721.441faa31@posting.google.com> <3b1a674e$1_1@news5.uncensored-news.com> <2f14b602.0106040504.3a8997d7@posting.google.com> Message-ID: Andrew Williams wrote: > So... How in the world do I keep a persistent object as the request > handler? For example, what if I wanted to use xmlrpc as a front-end > to a db; I would want the connection to the db to be persistent so I > wouldn't incur a speed penalty for connecting/disconnecting whenever > the request handler was called. as its name implies, a request handler object handles a single request. to create a "persistent" object, attach it to the server class. something like this could work: class TestRequestHandler(xmlrpcserver.RequestHandler): ... def add(...): self.server.x = self.server.x + value return "sum = %s" % self.server.x class TestServer(SocketServer.TCPServer): def __init__(self, port=8000): self.x = 0 SocketServer.TCPServer.__init__(self, ('', port), TestRequestHandler) server = TestServer() server.serve_forever() From tgos at spamcop.net Fri Jun 1 13:06:25 2001 From: tgos at spamcop.net (TGOS) Date: 1 Jun 2001 12:06:25 -0500 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> Message-ID: On Thu, 31 May 2001 21:08:09 -0400, "Bart Kowalski" wrote: > Did the OP mention anything about Windows? Then why the heck are you suggesting > an extremely platform-dependent solution based on specific technologies from a > specific vendor? That's what was surprising me as well. I wonder why nobody seems to know Java3D, although it's not a new Java extension. Despite great platform support (please read my other posts), it's easy to use (a high level 3D language). E.g.: I have a Quake3 Java model editor that uses Java3D. You only need to download a plugin, which will store a few extra files into your JVM directory, as well as a JAR file with the classes...that's all. As long as your PC has OpenGL support (or in case of Windows, both OpenGL and Direct3D is supported...whereby OpenGL looks better and is faster) nothing speaks against good looking 3D graphic in Java. But most people prefer to use poor company solutions over open standards. Most games use DirectX instead of OpenGL (if they'd use OpenGL, porting them to other platforms would be a lot easier). Instead of getting browser companies to finally implement CSS2 (which can be used together with JavaScript to make incredible text and graphic animations), they rather force everyone to download a plugin for Flash. Instead of implementing a full VRML2 support, they will force people to download a plugin for Shockwave3D. Instead of using PNG (open standard), they use GIF. The list is endless ... People always use the first solution they can find, which is usually the one most propagated. Those are usually commercial solutions, as companies earn money by propagating them (meaning they make a lot of advertising for their standard ... something that isn't done enough for open standards). That this solution may not be the best that exists (there are often a lot better solutions), that this solution belongs to a single company (and thus only they have the power to alter or improve it and only they can write viewers for their standard) and that this solution might be limited to the platform you are using at the moment is simply ignored. I mean, how many webpages are there that say "You NEED IE 5.5 to watch this page"? Too many. The fact that this means 50% (or more) of all surfers will simply skip this page is a risk they are willing to take. -- TGOS From rnd at onego.ru Fri Jun 29 11:02:36 2001 From: rnd at onego.ru (Roman Suzi) Date: Fri, 29 Jun 2001 19:02:36 +0400 (MSD) Subject: Not enough Python library development [was PEP scepticism] In-Reply-To: <20010629074443.A9409@glacier.fnational.com> Message-ID: On Fri, 29 Jun 2001, Neil Schemenauer wrote: > Guido van Rossum wrote: > > I'm guilty of this myself: by nature, I'm more interested in making > > the language better than in adding convenience to finding 3rd party > > modules. > > I think many people on the python-dev list are guilty. We should > concentrate more on improving the standard library. IMHO, there is lots > of room there for improvement. Is there a formal TODO list of the libraries and respective priorities? For example, I think that some sort of standard GUI could help Python to fight Java with it's Swing/AWT... It could be also interesting to have time module as powerful as mxDateTime in standard library. And so on. Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From davygrvy at pobox.com Thu Jun 14 16:54:17 2001 From: davygrvy at pobox.com (David Gravereaux) Date: Thu, 14 Jun 2001 13:54:17 -0700 Subject: when embedding Python, how do you redirect stdout/stderr? References: <992537747.711779@rexx.com> Message-ID: Dave Kuhlman wrote: >However, if you want to do some of it in Python and initiate it >from C, then create a Python class with a "write" method and use >PyRun_SimpleString to assign an instance of that class to >sys.stdout. PySys_SetObject("stdout", myObj); , probably... >You can read about it at: > > http://www.python.org/doc/current/lib/module-sys.html That gets me going, thanks. I'm starting to better picture an abstraction layer into my application. -- David Gravereaux -=[ Ray's Famous and Truly the Original Pizza, NYC ]=- From tim.one at home.com Tue Jun 19 19:54:13 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 19 Jun 2001 19:54:13 -0400 Subject: PEP 255: Simple Generators In-Reply-To: <9gnv2o$its$1@nntp6.u.washington.edu> Message-ID: [Russell E. Owen] > In my opinion, "use the documentation", "if you are modifying it then > you'd better know what it does", "it'll be clear from context" are all > red flags. That sort of thinking leads to confusing write-only code. Then you must have terrible problems reading Python functions today, yes? "def" doesn't tell you *anything* about their behavior, and, e.g., whether a function adds 1 to an input and returns that, or returns nothing at all, or sends email to Afghanistan and returns a tuple of time.time() values, are all mysteries. > Since a generator is very different than a function, why not mark it as > such right up front? >From my POV, because there's no practical benefit. BTW, they are very much functions: they happen to return a generator-iterator, though. This function *may* also return a generator-iterator in 2.2: def fgh(i): return xyz(i) Ditto: def xyz(i): return external.table[i] Do you want to call those "gen" too? If you want to know what a function returns, docstrings and comments are the only ways Python supports now. Static typing is the way out of that one, not a profusion of new synonyms for "def". From phd at phd.fep.ru Fri Jun 8 12:34:58 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Fri, 8 Jun 2001 20:34:58 +0400 (MSD) Subject: WHY is python slow? In-Reply-To: Message-ID: On Fri, 8 Jun 2001, Niklas Frykholm wrote: > Ruby and Python are my favorite languages. It just breaks my heart to > see them claw at each other's eyes. C'mon guys, can't we just get > along? No, we cant! Live free or die!! Stop M$!!! (Joke, really :) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From hughett at mercur.uphs.upenn.edu Sun Jun 10 14:02:45 2001 From: hughett at mercur.uphs.upenn.edu (Paul Hughett) Date: 10 Jun 2001 18:02:45 GMT Subject: is c faster? References: Message-ID: <9g0co5$6su$1@netnews.upenn.edu> Sean 'Shaleh' Perry wrote: : On 09-Jun-2001 akhar wrote: :> I have a script I wrote in python , I love the time it took me to devellop :> it faster than i could have done it in C. however after full review of my :> code I am not sure I can optimize it any more( it basicaly consist of :> importing an image and tranforming into a matrix to perform some for-looped :> operations on it) : I went from 20 seconds to 2. I can't seem to bring the :> execution time down :( . would C code be faster? by what factor? can I :> optimise my code more? how? :> : the C version COULD be faster. However, have you tried some of the python : imaging libs? Many of them are implemented in C. : Another option is to put the heavy computation in C, wrap it with your : existing python and get the best of both worlds. For an example, see the bblimage package at http://www.med.upenn.edu/bbl/publications_downloads/downloads/software.shtml This package uses Python as a scripting language to control a C library optimized for high performance on multi-dimensional images. It will do a lowpass filter on a 256 x 256 x 256 image in a few seconds, using only a few lines of Python code. Paul Hughett From phd at phd.fep.ru Tue Jun 19 04:59:55 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Tue, 19 Jun 2001 12:59:55 +0400 (MSD) Subject: Getting all client http headers In-Reply-To: <3B2F1C80.DF4CEB85@nokia.com> Message-ID: On Tue, 19 Jun 2001, Joonas Paalasmaa wrote: > > > How can I get all client http headers in python. > > > Can I use cgi-module? > > > > Assuming that you implement a simple CGI-BIN program you have to > > stick to the CGI-BIN environment vars which contain some of the HTTP > > header information (usually prefix HTTP_). > > Do you mean os.environ? > Does it contain ALL headers? No, it is not. And there is no way to get them all until you write your own Web-server. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From ryanmorillo at hotmail.com Fri Jun 15 05:24:40 2001 From: ryanmorillo at hotmail.com (Ryan) Date: 15 Jun 2001 02:24:40 -0700 Subject: Python version of IQ has been updates (IQ v0.34.python) References: <505.566T11T1243597threeseas@earthlink.net> Message-ID: <4a7fde99.0106150124.7376da0b@posting.google.com> "Timothy Rue" wrote in message news:<505.566T11T1243597threeseas at earthlink.net>... > http://www.mindspring.com/~timrue/python/IQ.34.py > > Read the code header. > > http://www.mindspring.com/~timrue/python/python-IQ.html > > > --- > *3 S.E.A.S - Virtual Interaction Configuration (VIC) - VISION OF VISIONS!* > *~ ~ ~ Advancing How we Perceive and Use the Tool of Computers!* > Timothy Rue What's *DONE* in all we do? *AI PK OI IP OP SF IQ ID KE* > Email @ mailto:timrue at mindspring.com >INPUT->(Processing)->OUTPUT>v > Web @ http://www.mindspring.com/~timrue/ ^<--------<----9----<--------< you might want to change line 85 to if fromf in ('', '?', 'help', '-h', '-?'): just a slight change with a negligable speed up, but slightly easier to read. I'm just now trying to figure out the interface and figure out exactly what it dose, if it's what I think it is I'll be more than happy to help hack it (i'm hoping it is a small search engine type tool) From paulp at ActiveState.com Fri Jun 29 15:33:48 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 29 Jun 2001 12:33:48 -0700 Subject: Is this a true statement: Part II References: <9hiifr$sjs$1@taliesin.netcom.net.uk> Message-ID: <3B3CD81C.DD94C6A9@ActiveState.com> MDK wrote: > >... > > 1. Excluding writing device drivers the answer is a clear yes. Here's how I would summarize it. Programs have three main parts: getting data (including user events) into the program, doing computation on it, and getting data out of the program (including user feedback). All proper programming language are equivalent on the "doing computation" part. But the input and output parts depend on the environment that the program is runing in. You could write an operating system that could only be directly programmed in Python. If you wanted to program in C++ or some other language you would have to do it through a Python "glue" layer. But that's a fantasy world. In the real world, most operating systems are designed so that they can only be directly programmed in C or languages at roughly the same abstraction level. Those of us who want to use Python have to use the "glue". There is so much Python glue available that it is easy to forget that it was all written. You couldn't do GUIs in Python until someone wrote Tkinter or wxPython or Jython... You couldn't remove files until someone wrote the "os" module. There isn't a whole lot of interest in writing device drivers in Python (for performance and security reasons) so nobody has written that glue. > Why is C++ awful; what's wrong with it? >... C++ is a large and complex language. In my opinion it tries but fails to work both on the abstraction level of a high level language and a low-level language which gives it a very confusing runtime model. One minute you are doing things that look low-level but are really very computationally expensive and the next you are being constrained from doing something that seems reasonable because C++'s designers didn't want to take the performance hit. Plus it is so complicated that the implementations still vary widely so you have to "port" code from one compiler to another. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From junkster at rochester.rr.com Sun Jun 10 10:29:13 2001 From: junkster at rochester.rr.com (Benjamin Schollnick) Date: Sun, 10 Jun 2001 14:29:13 GMT Subject: Win32 Installer on 2.1? References: <50be6f7c.0105220115.612c9912@posting.google.com> <50be6f7c.0106062352.a6f2670@posting.google.com> <50be6f7c.0106071259.13fcbfc3@posting.google.com> <90BA710B4gmcmhypernetcom@199.171.54.154> Message-ID: In article <90BA710B4gmcmhypernetcom at 199.171.54.154>, gmcm at hypernet.com (Gordon McMillan) wrote: > Matt Butler wrote: > > [Benjamin Schollnick guesses Installer 4 works with 2.1] > > >Thanks for your response, I have actually not had a problem yet with > >2.1, it's just that the readme omits 2.1 from the list of > >configurations on which Installer has been tested. > > I'm finally testing with 2.1 (I use *lots* of C extensions in my work, and > recompiling for a new release of Python is a royal PITA). > > So far I've found some minor stuff in doing Windows version resources > (which slipped by me in testing Python 2.0, where it also fails). If anyone > needs that, drop me a note. Otherwise, I'll keep plugging and roll it into > 4a2. > > - Gordon Gordon, I've noticed some oddities, which only seem to occur on w95, w98, wme.... But on NT platform (w-Nt, W-2k) everything works fine... This might be related, but I haven't had a chance to actually go through and inspect everything to ensure that it is a INSTALLER error, or a Python / ActivateState Python issue... - Benjamin From etoffi at bigfoot.com Fri Jun 8 09:04:23 2001 From: etoffi at bigfoot.com (e toffi) Date: 8 Jun 2001 06:04:23 -0700 Subject: gc issues Message-ID: <655abd4a.0106080504.66a9d6a0@posting.google.com> hello lets say i wanted to integrate 2 languages with gc's (lua, [small]eiffel, python, javascript). how do i keep the gc's from eating each other? i know this will require some *very* careful prgramming techniques. can anyone point me in the right direction? -- etoffi From s713221 at student.gu.edu.au Fri Jun 22 21:25:57 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Sat, 23 Jun 2001 11:25:57 +1000 Subject: How to install python on clean RH7.1 install References: <3b313462.13451051@news1.on.sympatico.ca> Message-ID: <3B33F025.D275AAB1@student.gu.edu.au> Ken wrote: > > Hi, > > I'm trying to install Python 2.1-5 onto a newly installed RH7.1. The > RH install was done pretty cleanly, so not a lot of the RPMs have been > installed (I've installed some along the way, as dependencies came > up). > > My quesions are these: > > 1). Is it possible to "upgrade" the python 1.5.2 that is installed > with RH7.1? (I couldn't easily avoid installing it - because it was a > dependency for a lot of packages. That said, I cannot easily > uninstall the RPM for 1.5.2). > > 2). If not, what way is more or less a fail-safe way of installing > python into a new directory. I have tried the following already: > > - installing from the src.rpm file -- the installer stopped short of > creating the RPM file... something about it not finding a lot of files > (that it was to have compiled). It made it through the check, and did > about 5 minutes of compiling, then stopped. > > - installing from the rpm file. The dependencies failed were > libcrypto, and libssl -- but I have NO idea where to find these > (preferrably RPMs). > > Any ideas would be greatly appreciated! > > Kc Question 1. To find out which packages require python, use the following command: rpm -q --whatrequires python I haven't tried to replace python1.5 in a distro, prefering to install python2.1 beside the system python, but if I were going to do this, I'd install python2.1 either from the source using --altinstall rather than --install, with --prefix=/usr during the configure step, or build and install python2 from any of the python2*src.rpm files out there. This will install python2 under /usr, but your /usr/bin directory will (or should) look like this (for the python2.src.rpm option) -rwxr-xr-x 1 root root 423260 Oct 1 2000 python -> python1.5 -rwxr-xr-x 1 root root 423260 Oct 1 2000 python1.5 -rwxr-xr-x 2 root root 521020 Jun 15 20:39 python2 -> python2.1 -rwxr-xr-x 2 root root 521020 Jun 15 20:39 python2.1 Then I'd get all the packages that depend on python1.5, preferably in src.rpm form. Go to /usr/bin and swap around the default python cd /usr/bin mv python python-old ln -s python2.1 python and build each of the dependancies packages, but don't install them. Fix the hacking you did on the /usr/bin directory rm python mv python-old python Then rebuild the python2 src.rpm but edit the spec file so that it build python2 as the package python rpm -i python2*src.rpm cd /usr/src/RPM/SPECS emacs python.spec (Focus on the first 5 to 8 lines, and save the file) rpm -bb python.spec cd /usr/src/RPM/RPMS/i386 rpm -i python.rpm If things stuff up, you may have to go back to your old packages. Cd to your CD, and rpm -U --oldpackage python.rpm In fact, if you're worried, I'd build all your dependancies packages from source (Which you can retrieve from your src.rpm packages after you install them.), making sure they go into python2.1, test each one out, and then do what I suggested above. What you have to ask, is it worth it? Will a coexistant install do what you require with far less effort than a total replace? Question 2. You need to install the development packages of crypto and ssl, they'll be on your cd. Also, install the readlines development library before your build. With this, python will install readlines into the binary, and when you're working in interactive mode, you'll be able to repeat any of your previous commands by tapping the up-down arrows (Like xterm/bash, as opposed to the _ trick, which only repeats the last command.) This also goes for any other modules that you want, but will probably require system libraries to build. (Read the python documentation for hints as to this.) -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From vj$ri^gg#guess#l55e at mt$*guess#&cn1e#t.! Fri Jun 15 23:44:24 2001 From: vj$ri^gg#guess#l55e at mt$*guess#&cn1e#t.! (Kevin Riggle) Date: Fri, 15 Jun 2001 22:44:24 -0500 Subject: Suggestions for a Strange Project? References: <3b2abb77_1@news3> Message-ID: <9gekf2$ocd$1@mtc1.mtcnet.net> I believe that a 'time server' may solve the clock problem. Security may be an issue -- I've never tried to set one up myself. The others may require a bit more coding. You might be able to run a modification of the Python-based chat program at http://strout.net/python/server.py and have each computer post the clipboard contents periodically. Just a thought. - Kevin "Mega Hurts" wrote in message news:3b2abb77_1 at news3... > One computer has never been enough for me. > Even back in the olden days of Z80 S-100 machines > (pre IBM PCs), I used TurboDOS with multiple SBCs, > and a strange multiple MicroAngelo graphics setup > of my own design. > > Some things never change. > > My current setup consists of four machines, running > Win98. I use a single monitor and infrared keyboard/ > mouse, and switch from one machine to another with > a KVM switch. I connect to the internet on the first > machine, which runs a proxy, and the other machines > can run mail, FTP, news and web clients. I use a couple > of the boxes for compute-intensive MPEG recording, and > when they are busy, can switch to the others for office > activities. Soon I will change the fourth box to Linux. > > To switch from box to box, I press CTL-CTL-1, or > CTL-CTL-2, etc. The fun begins: > > [1] I use background colors and a labeled icon to remind > me which context I'm in. Things get fun when I am > working in a file, copy text or a graphic, switch to > another machine- AND FORGET THAT I CAN'T PASTE. > > [2] Or I'm using my beloved and vital graphics pad and > switch machines, only to be reminded that the cursor > on one machine and one only is under Wacom control. > > [3] All the clocks lose and gain time at different > rates. This becomes important when recording off-air > scheduled events, and updating the clocks on four machines > is just another chore. > > Well, Rochester... I'm thinking. All these boxes can > talk to each other via that zippy 100Mb LAN. > > Now, why can't machine #1 share its web-updated clock > info, and machine #2 share its graphics-tablet cursor > info when needed, and all of them write to a common > 'clipboard'? > > A lightweight task running on all machines should provide > the connectivity and clock awareness, cursor and mouse-key-awareness. Any > suggestions on where to start? > > Thanks > > > > > From trace at reinventnow.com Tue Jun 12 16:03:23 2001 From: trace at reinventnow.com (tracy s. ruggles) Date: Tue, 12 Jun 2001 20:03:23 GMT Subject: Distutils doesn't like VPS's (virtual private servers) Message-ID: Hi, I'm having the darndest time trying to install something on my VPS (a shared hosting setup that pretends to be its own machine). The problems seems to be in Distutils/sysconfig.py where it tries to get the library directories to run the installation. It spits out /usr/local, but on a VPS it actually is /usr/home/[user]/usr/local where [user] is your account name. So, I tried changing sysconfig.py so that it would prefix anything it spit out with the proper directory. But, I mustn't have found everywhere it does it (or, maybe it's getting a directory listing from some other module). The output of my attempt to install MySQLdb is below. You'll notice that it's looking for: /usr/home/ol0401/usr/local/Python-2.1/Lib/lib/python2.1/config/Makefile ...which doesn't exist because I've got my own installation of python (since a VPS won't let me install anything in the shared library folder). It's appending /lib/python2.1/ automatically somewhere in the code when it shouldn't be. Here's my problem, I need the installation to find the right include directory for *my* installation of python at ~/usr/bin/python (which is actually /usr/home/ol0401/usr/bin/python). Where in the world is the include directory specified. Or, at least, where can I override it? Can anybody help? Please? Thanks, Trace .. ol0401.vwh.net% ~/usr/bin/python setup.py build running build running build_py not copying CompatMysqldb.py (output up-to-date) not copying _mysql_exceptions.py (output up-to-date) not copying MySQLdb/__init__.py (output up-to-date) not copying MySQLdb/converters.py (output up-to-date) not copying MySQLdb/connections.py (output up-to-date) not copying MySQLdb/cursors.py (output up-to-date) not copying MySQLdb/sets.py (output up-to-date) not copying MySQLdb/times.py (output up-to-date) not copying MySQLdb/constants/__init__.py (output up-to-date) not copying MySQLdb/constants/CR.py (output up-to-date) not copying MySQLdb/constants/FIELD_TYPE.py (output up-to-date) not copying MySQLdb/constants/ER.py (output up-to-date) not copying MySQLdb/constants/FLAG.py (output up-to-date) not copying MySQLdb/constants/REFRESH.py (output up-to-date) not copying MySQLdb/constants/CLIENT.py (output up-to-date) running build_ext Traceback (most recent call last): File "setup.py", line 110, in ? extra_objects=extra_objects, File "/usr/home/ol0401/Python-2.1/Lib/distutils/core.py", line 138, in setup File "/usr/home/ol0401/Python-2.1/Lib/distutils/dist.py", line 899, in run_commands File "/usr/home/ol0401/Python-2.1/Lib/distutils/dist.py", line 919, in run_command File "/usr/home/ol0401/Python-2.1/Lib/distutils/command/build.py", line 106, in run File "/usr/home/ol0401/usr/local/Python-2.1/Lib/cmd.py", line 328, in run_command print "\n" File "/usr/home/ol0401/Python-2.1/Lib/distutils/dist.py", line 919, in run_command File "/usr/home/ol0401/Python-2.1/Lib/distutils/command/build_ext.py", line 231, in run File "/usr/home/ol0401/usr/local/Python-2.1/Lib/distutils/sysconfig.py", line 124, in customize_compiler (cc, opt, ccshared, ldshared, so_ext) = \ File "/usr/home/ol0401/usr/local/Python-2.1/Lib/distutils/sysconfig.py", line 369, in get_config_vars func() File "/usr/home/ol0401/usr/local/Python-2.1/Lib/distutils/sysconfig.py", line 305, in _init_posix raise DistutilsPlatformError, my_msg distutils.errors.DistutilsPlatformError: invalid Python installation: unable to open /usr/home/ol0401/usr/local/Python-2.1/Lib/lib/python2.1/config/Makefile (No such file or directory) From qrczak at knm.org.pl Sat Jun 23 11:54:41 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 23 Jun 2001 15:54:41 GMT Subject: stumbled on python iif() equivalent, at last References: <3B34B8DE.67D97C24@q-survey.be> Message-ID: Sat, 23 Jun 2001 17:42:22 +0200, Laurent Szyster pisze: > so, there's an iif (condition, is_true, is_false) python equivalent: > > >>> 1 and 'c' or 'o' > 'c' > >>> 0 and 'c' or 'o' > 'c' It works correctly only if 'c' is true. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From pj at sgi.com Fri Jun 1 21:46:07 2001 From: pj at sgi.com (Paul Jackson) Date: 2 Jun 2001 01:46:07 GMT Subject: Indentation style... References: <3B15DA5F.CF69F9F@my.signature> Message-ID: <9f9ggv$d2nid$1@fido.engr.sgi.com> |> It's interesting to note that, in the typewriter era, |> there was no such thing as a tab *character*. In other |> words, expand-tabs-to-spaces was the *original* method |> of handling tabs! I don't recall a space *character* either -- just carriage motions, of one character size (space) or up to the next physical tab stop (tab). The tab key didn't invoke the space bar mechanism, but rather just let the carriage slide freely, pulled left by the big spring (what was it called), until it rammed into the next pin (tab stop). -- I won't rest till it's the best ... Manager, Linux System Software Paul Jackson 1.650.933.1373 From SBrunning at trisystems.co.uk Wed Jun 20 09:42:26 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Wed, 20 Jun 2001 14:42:26 +0100 Subject: smtplib security risk Message-ID: <31575A892FF6D1118F5800600846864D78BD6E@intrepid> > From: Roman Suzi [SMTP:rnd at onego.ru] > No. It's a security risk. Just ALWAYS check user inputs on > CGI or other places. Strip "../" and other things, depeding > on what you do with your data. Etc. > > Even if you are the only user of your CGI, make it a habit to > check input. It's a good habit. > > And your mail template is exploitable, I guess, to spam the World, > because you direct user input into it, checking nothing. > Eeek! Thanks for pointing this out! What can be smuggled into the message parameter of a smtplib.SMTP's sendmail method that I want to protect against? Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From BPettersen at NAREX.com Tue Jun 5 17:58:29 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Tue, 5 Jun 2001 15:58:29 -0600 Subject: integers Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D436@admin56.narex.com> > From: Joshua Marshall [mailto:jmarshal at mathworks.com] > > Jonathan Gardner wrote: > > Locke wrote: > >> is there such thing as > >> someint++ > >> or > >> someint-- > >> or > >> someint += 2 > >> in python?? > >> > >> it is a pain in the butt writing > >> someint = someint + 1 > >> > >> Thanks! > > > It's also a pain in the butt writing someint += 1 (Yes, I > know I am very > > lazy). > > > What is the reason that python doesn't have increment or decrement > > operators? > > Python isn't C - there's no reason to expect ++ or --. And I'd > personally be against adding these to the language, since += and -= do > increment and decrement nicely. Also, if ++ and -- were introduced > people would probably expect them to be expressions (since they look > like C's ++ and --). This would be another mistake, in my opinion. I > like how Python keeps side-affecting language constructs in the realm > of statements. And introducing them now would change the meaning of: x--1 besides-Guido-doesn't-want-them'ly y'rs -- bjorn From duncan at NOSPAMrcp.co.uk Mon Jun 18 11:42:01 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Mon, 18 Jun 2001 15:42:01 +0000 (UTC) Subject: Any other Python flaws? References: Message-ID: "Tony J Ibbs (Tibs)" wrote in news:mailman.992601984.7190.python-list at python.org: > The one thing I *really* hate in Python is the fact that starting a > number with a zero suddenly magically changes its base - yuck. One thing > we could have done with *not* keeping from the C family. > > I still remember the first time (obviously not in Python itself) I tried > to lay a series of numerical choices out neatly (did BCPL have this > "feature" too? was it really that far back?), and to make it neat, I > naturally padded with spaces on the left. Humph. I just couldn't believe > that anyone would create such a daft heffalump trap. Hi Tibs, BCPL Octal constants use '#', e.g. #177 and hex constants are '#X', e.g. #X7F, so like the dangling else, the leading 0 was an 'improvement' brought in post BCPL. BTW, I'm not really so sad as to still remember that much BCPL, I keep the BCPL book handy though in case of emergencies. I think my sig in BCPL would be: LET MONTH(P) = (TABLE 5,8,3,6,7,11,1,9,10,2,0,4)!(124864/((p%1+p%2- p%3)+1)%12) but I don't have a compiler handy to check. -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From mmueller at dgfz.de Fri Jun 8 08:34:16 2001 From: mmueller at dgfz.de (=?ISO-8859-1?Q?Mike_M=FCller?=) Date: 8 Jun 2001 05:34:16 -0700 Subject: Error connecting to COMServer Message-ID: <7049ba55.0106080434.1bcbc8d2@posting.google.com> Hi, with the help of a wizard in a compiler I managed to create an COM server in FORTRAN. Testing from VB works fine just by choosing the registered server in the projects/Verweise (sorry only German Version) menu. Dim Adder As New AddingMachine creates the server object. Unfortunately from python I get: >>> from win32com.client import Dispatch >>> a = Dispatch("Adder.AddingMachine") Traceback (innermost last): File "", line 1, in ? File "D:\code\Python\win32com\client\__init__.py", line 94, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "D:\code\Python\win32com\client\dynamic.py", line 66, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "D:\code\Python\win32com\client\dynamic.py", line 57, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147418113, 'Schwerer Fehler', None, None) which is a 'Catastrophic failure' at least the –2147418113 translates to this. It does not matter if I use COM Makepy or not, the error remains. I do NOT know where to look. The compiler generated a bunch of files (*.idl, *.f90., *.def). Where could be the problem? What would be the most important place to look? Can I conclude anything if I look into at the file generated by COM Makepy? Thanks for some hints? Mike From chatme at 263.net Thu Jun 7 20:13:40 2001 From: chatme at 263.net (limodou) Date: 7 Jun 2001 17:13:40 -0700 Subject: Regex error? References: Message-ID: Drew Fisher wrote in message news:... > Hi, > > I'm trying to write a python script to parse an email header for IP > addresses and dates, and I keep on getting an error that says: > > RuntimeError: maximum recursion limit exceeded > > The regex is a little lengthy, but I didn't think it would be a > problem: > > rfc822_re = re.compile ('\[(\d+\.\d+\.\d+\.\d+)\].*?\w+,\s+(\d+\s+\w+\s+\d+)\s+(\d+:\d+:\d+)\s+(\w+)') > > The script dies when I try to do: > > rfc822_test = rfc822_re.findall (rawdata) > > rawdata is just a string containing the entire email. > > The regex finds the IP address, the date, the time, and the timezone > from where the email address came. > > Can anyone tell me what that error means, and how I could possibly get > around it? > > Thanks, > > Drew Fisher I'v met this error too, and I found that once you reduce the length of the string the error will disappear. I think it may be a bug, and the length may be limited in 16K. I don't know whether my thought is right. From deblNonoNOspammy at theworld.com Fri Jun 22 21:26:53 2001 From: deblNonoNOspammy at theworld.com (David Lees) Date: Sat, 23 Jun 2001 01:26:53 GMT Subject: cmdline.py not working in ActiveState Python 2.1 References: <3B339168.9D7A9094@raqia.com> Message-ID: <3B33F05E.56DAA9DD@theworld.com> Yup, it was not getting the command line, because I was not calling the cmdline 'init' function. It works just fine when you add cmdline.init(sys.argv) Thanks, david lees Alan Miller wrote: > > David Lees (DavidLSpamNoNo at raqia.com) wrote: > >when called with command line 'testcmd.py -x 3' > >from a Linux version of Python 2.1 it works correctly. However, using > >the same build (ActiveState) under windows NT, the command line option > >is not recognized and 'b' has value zero. > > > >Any idea what is going on here? I think this command line parser used > >to work on older windows Python distributions. > > Are you sure it's getting the command line at all? There was some > discussion recently about the requirement to launch python programs on > NT as "python testcmd.py -x 3" instead of just "testcmd.py -x 3" to get > command line options passed correctly. > > ajm From dsh8290 at rit.edu Wed Jun 27 13:12:43 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 27 Jun 2001 13:12:43 -0400 Subject: [OT] Is there any tutorial for those who learn Java after Python ;-) In-Reply-To: <3B3928F3.CCAA71CA@hotmail.com>; from smarsh@hotmail.com on Wed, Jun 27, 2001 at 12:30:47AM +0000 References: <3B3928F3.CCAA71CA@hotmail.com> Message-ID: <20010627131243.A17001@harmony.cs.rit.edu> On Wed, Jun 27, 2001 at 12:30:47AM +0000, scott wrote: | D-Man wrote: | > | And some simple things makes me wonder: | > | | > | public class JavaRules { | > | public static void main(String args[]) { | > | System.out.println(2+2+"a"); | > | > This line is a type error. Doh! I was sure I'd been bitten before by not putting a string first. | You'd better stick to Python advice for the time being. ;-). -D From gustafl at algonet.se Sun Jun 10 14:36:39 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 10 Jun 2001 18:36:39 GMT Subject: Problem with UnicodeError and xml.dom.minidom Message-ID: When I scan previous posts on this, it seems like a lot of people are having trouble with UnicodeError. I don't use any non-ASCII characters (yet), but still I got this uninterpretable error: E:\test>python count.py Traceback (most recent call last): File "count.py", line 37, in ? message = domext.createElementEmpty(doc, root, u'message') File "e:\python\gustaf\domext.py", line 12, in createElementEmpty parent.appendChild(e) File "E:\python\_xmlplus\dom\minidom.py", line 144, in appendChild if node.nodeType not in self.childNodeTypes: UnicodeError: ASCII decoding error: ordinal not in range(128) I'm converting mails to XML, using xml.dom.minidom. Works fine in interactive mode, but not when I run it as a script! Here's the function in my domext.py module that appears to raise the error: # Create an element-only or EMPTY element def createElementEmpty(doc, parent, name): e = doc.createElement(name) parent.appendChild(e) return e It takes the DOM object, a parent node and a name for the element to create. The call that fails looks like this: message = domext.createElementEmpty(doc, root, 'message') This is line 37 in count.py. No non-ASCII characters here, and it works fine in Idle. I'm paralysed. Can someone break the spell? Gustaf Liljegren From rapto at arrakis.es Sat Jun 2 02:57:15 2001 From: rapto at arrakis.es (Marcos =?iso-8859-1?Q?S=E1nchez?= Provencio) Date: Sat, 02 Jun 2001 08:57:15 +0200 Subject: ODBC in web pages References: <3AFF21DC.D1217D7A@iname.com> <9e318r$27vm$1@news5.isdnet.net> Message-ID: <3B188E4B.657F4DDA@arrakis.es> Gilles Lenfant wrote: > > 'mydata' should be a system DSN. If it'a a user DSN (for you) and your web > server runs from another user's account... No connection is possible. > It's perhaps your problem. Watch out for the use of network mapped drives (if the DSN uses a file, as in MS Access) > You should prefer mxOdbc which API is 99% DBI 2.0 compliant in place of the > default odbc service that comes with PythonWin. > > http://www.lemburg.com/files/python/mxODBC.html It must be pointed out that mxODBC has a commercial license, though. I have nothing against commercial software (it pays my bills), but the fact has to be considered (the "should" sounded funny). From rcameszREMOVETHIS at dds.removethistoo.nl Sat Jun 2 19:08:12 2001 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Sat, 02 Jun 2001 23:08:12 GMT Subject: asyncore: suggested patch References: Message-ID: Jonathan Feinberg wrote: > rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) writes: > >> Jonathan Feinberg wrote: >> >>> rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) writes: >>> >>>> If Jonathan Freiberg wants to make his connect-patch work on >>>> more > ^^^^^^^^ >>>> platforms, notably Windows, he'll have to put in a bit more >>>> effort. >>> >>> Hmm. If Robert Azesm >> >> Congratulations. I never saw anyone garble my last name quite as >> badly as that. ;-) > > Nor I. I was dropping you a hint. Oops. Too subtle, I'm afraid. Try whacking me on the head with a mallet next time. >> The added select() in your connection function will *block* the >> system. This means that during a long wait for a connection to be >> established (or time out) asyncore totally grinds to a halt. > > This is, in fact, how asyncore currently behaves, *without* my > patch. My patch is intended to *address* this behavior. It blocks in the sense that calling the loop() function doesn't return, of course. It also blocks in the sense that if a connection can't be made asyncore will never call any handler function for that dispatch object (socket). It will, however, continue to manage all the dispatch objects it's supposed to manage. Your patch disrupts that processing. The best solution is to extend asyncore to generate timeout events, and call appropriate handler functions if those occur. It's not trivial, but it shouldn't be too hard either. Robert Amesz From piet at cs.uu.nl Tue Jun 26 11:25:52 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 26 Jun 2001 17:25:52 +0200 Subject: Adding unknown variables to time.mktime() References: Message-ID: >>>>> Roman Suzi (RS) writes: RS> On Tue, 26 Jun 2001, Gustaf Liljegren wrote: >> "Roman Suzi" wrote: >> >> > >to be able to give only the 6 first values, since I've never heard of >> > >Julian days, and week day is not significant in this case. >> >> > try with all 9 integers. >> > RTFM time module docs. >> >> Read before you post. I always check the library reference, but it doesn't >> give any hints on what I asked for. If mktime() can't do it, maybe there's >> anyother way that you could suggest? RS> In the docs it is said what those 3 last parameters are about RS> and how you can specify them if you do not know their values. it only says something about non-specifying DST, not about the others. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From MarkH at ActiveState.com Sat Jun 2 20:53:16 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sun, 03 Jun 2001 00:53:16 GMT Subject: Copying files to multiple comp's on a lan References: <9f8k3v$1i04$1@news.cybercity.dk> <9fbmbk$2acl$1@news.cybercity.dk> Message-ID: <3B198B17.3060409@ActiveState.com> Henrik Berg Nielsen wrote: > programming). So far I haven't been able to access file on the remote > machines via the open() method. What should I write if I wanted to access > the file called "foo.txt" located in the "temp" folder on the C drive of the > machine named "Orion"? In general, you need to know how the C:\TEMP directory is "shared" by the machine "Orion". If you have administrator rights, you will probably find that: r"\\Orion\c$\temp" will work. In general, whatever string you can pass to the command prompt's "dir" command to see the file can be passed to open(). Remember that Python sometimes requires backslashes to be doubled - hence my r"..." notation above - it uses raw strings which do generally not need slashes doubled. ie, without raw strings, you would need to say "\\\\Orion\\c$\\temp" If you don't have access to the 'C$' share, then you need to investigate the specific settings for the specific server. There are some obscure ways to determine this stuff programatically, but let's get the simple things working first :) > I like the approach more where I let os.system() do the copying for me, but > it really doesn't work all that good if I can't assemble the proper network > paths. Experiment with assembling the paths from the command prompt. > On a side note; what does os.sytem() do specifically? Executes the command - almost as if you typed the command from a DOS prompt. > Also I tried "import win32api, win32file, win32net" and it can't find > neither of them, should I install these seperately or what? (plz don't laugh > :)) You probably need win32all from http://aspn.activestate.com/ASPN/Downloads/ActivePython/Extensions/Win32all If you installed ActivePython itself, they should all be there already. Mark. From jmv at yandex.ru Thu Jun 7 23:58:37 2001 From: jmv at yandex.ru (Eugene Morozov) Date: 08 Jun 2001 07:58:37 +0400 Subject: UML <-> Python References: Message-ID: <87iti78vwy.fsf@lucifer.home.spb> Roman Suzi writes: > Hello, > > It occured to me that probably Python language has some abilities > which couldn't be expressed in UML. > I'm a newbie in UML, but I disagree with you. First of all UML isn't just about design, I use it mostly for analysis. And when designing python program using UML you can avoid things you mentined completely (adding attributes on the fly, etc.) or invent some kind of notaion for them by yourself. This could cause problem only in round-trip engineering tools but no such tools exist for Python, AFAIK. Eugene -- Email: http://www.geocities.com/roshiajin/ The whole problem with the world is that fools and fanatics are always so certain of themselves, but wiser people so full of doubts. -- Bertrand Russell From gregj at pobox.com Thu Jun 7 02:44:01 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Thu, 07 Jun 2001 06:44:01 GMT Subject: Windows editor? References: <3af2c38f.341431824@News.CIS.DFN.DE> <1103_991870550@ns.seowon.ac.kr> Message-ID: Look at Edit+, http://www.editplus.com/. You can download Python syntax/auto-complete definitions from the site. -- Greg Jorgensen PDXperts LLC Portland, Oregon, USA gregj at pobox.com From tl_news at nexgo.de Fri Jun 29 13:10:27 2001 From: tl_news at nexgo.de (Tino Lange) Date: Fri, 29 Jun 2001 19:10:27 +0200 Subject: WinNT: Delete to recycle bin? References: <9hg04d$r9f$1@iocextnews.bls.com> Message-ID: Hallo John! Because there's no wrapper for the API-Functions that delete to the Recycle Bin (yet?), you can just use some other external command to delete files. Get the small freeware tool "Delete97" from http://www.easytools.com/index.asp?page=freebies#delete97 This tool is a a very useful replacement for the "del" command that deletes to the recycle bin on all M$ Systems. If you call it from Python it does what you want. Ciao Tino From pfortin at pfortin.com Wed Jun 20 20:56:02 2001 From: pfortin at pfortin.com (Pierre Fortin) Date: Wed, 20 Jun 2001 20:56:02 -0400 Subject: Interfacing GUI applications..? References: <3B18032E.21AF631E@pfortin.com> <3b312734.173247661@reading.news.pipex.net> Message-ID: <3B314622.1EB391F5@pfortin.com> Aandi Inston wrote: > > claird at starbase.neosoft.com (Cameron Laird) wrote: > > >In article <3B18032E.21AF631E at pfortin.com>, > >Pierre Fortin wrote: > >>Hi, > >> > >>I've been searching for a couple of days now and must resort asking for help... > >> > >>Does anyone know if it's possible to interface to a GUI application via a Python > >>script? I'm writing an application and would like to invoke Adobe's AcroRead > >>(on Linux) and feed data to a "fill-in" PDF file. > > Why does this need scripting? Isn't this solvable in a supported way > using FDF files? Say what...?! Are you suggesting I write code which generates hundreds of values only to have to manually transcribe the results into a "fill-in" PDF file...? If so... :^P I am looking for a way to plug the results into a PDF file which is available online (i.e, IRS forms). Pierre > ---------------------------------------- > Aandi Inston quite at dial.pipex.com http://www.quite.com > Please support usenet! Post replies and follow-ups, don't e-mail them. From sam at ddmweb.com Mon Jun 11 16:26:19 2001 From: sam at ddmweb.com (Sam Penrose) Date: Mon, 11 Jun 2001 13:26:19 -0700 Subject: CGI Empty Form problem (over https) Message-ID: <01061113285500.03484@frock.ddmweb.com> The FieldStorage object is not getting any data. It gets data from two places: os.environ and sys.stdin. I would start by attempting to print os.environ on both sides. >>> I'm having a problem with a cgi form in a cgi script. Running over a secure connection (https:..), my CGI script gets an empty cgi-form, ie FieldStorage(None, None, []) whereas running the same script in a non-secure environment works fine. Any ideas on what might be happening (eg is there something in the cgi module which requires special 'tweaking' to run over SSL)??... <<< From jochen at riekhof.de Wed Jun 13 12:03:16 2001 From: jochen at riekhof.de (Jochen Riekhof) Date: Wed, 13 Jun 2001 18:03:16 +0200 Subject: substitute for c/java's ?: References: <9g5fc4$m8u$01$1@news.t-online.com> <3B2671AF.B226FC54@accessforall.nl> Message-ID: <9g82qt$8ab$06$1@news.t-online.com> Hi... > Instead I usually write: > if option: result = value1 > else: result = value2 > just dropping the newlines. It's more verbose than > result = option ? value1 : value2 > but at least it's clean. Found a somewhat unclean solution that also has the drawback to process both operands any way, but it is sometimes nice because short: result (value1, value2)[not option] It assumes that the only booleans emerging from not x are 1 and 0, I hope this is defind in the language. > There is no real equivalent of 'switch' in python. > IIRC a few weeks ago there was a thread about using classes to > get a similar effect. Good idea! Thanks! So, I just continue using python and wat for ?: to make its way into the language (hinthint) ;-) Ciao ...Jochen From sholden at holdenweb.com Fri Jun 29 07:34:50 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 29 Jun 2001 07:34:50 -0400 Subject: threading question? References: Message-ID: "Blue whale" wrote in message news:c022af13.0106281926.34770583 at posting.google.com... > I am relatively new to python. Can anyone guide me to a good > resource where I can learn more about the threading module > in python. I just know that using threads one can write a > program which can perform multiple tasks indepedently and > simultaneously. > > Any help in regard to this is appreciated.. > To save Aahz his usual trouble: http://starship.python.net/crew/aahz/ regards Steve -- http://www.holdenweb.com/ From nperkins7 at home.com Wed Jun 20 14:23:10 2001 From: nperkins7 at home.com (Nick Perkins) Date: Wed, 20 Jun 2001 18:23:10 GMT Subject: Partially evaluated functions References: Message-ID: Oh, and one more thing: The cookbook version is the only one of the three which gives priority to kw args supplied at call-time over args supplied at create-time. eg. def f(color='black'): print color f2 = curry(f,color='blue') f2(color='red') The cookbook version will print 'red', Rainer and Alex both print 'blue'. (easy to change, of course) From glyph at twistedmatrix.com Sun Jun 24 16:18:32 2001 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: Sun, 24 Jun 2001 15:18:32 -0500 (CDT) Subject: PEP 255: Simple Generators In-Reply-To: <20010621134445.B20524@glacier.fnational.com> Message-ID: On Thu, 21 Jun 2001, Neil Schemenauer wrote: > PEP 255 is not intended to solve everyone's problems. It is an > attempt at doing _something_ useful. Is it better to have > generators in Python 2.2 or should we wait indefinately for > microthreads? Even if we do get microthreads I still see the > extra syntax being useful. If python's answer to "what should we do with new feature X"? is "add a keyword" it will turn into Perl before too long. I think that most of us agree that print>> is a disturbing symptom of this already :) And yes, we should wait indefinitely for microthreads. If generators are implemented as a syntax feature, then microthreads are implemented as a module (or should we have syntax for that too? 'task' anyone?) then we're again falling prey to a sin of perl; there will be more than one way to do it. This is, after all, not a new *capability* of python per se, like the ability to parse XML or display 3D objects using OpenGL; it's just an attempt to build a particular idiom into the language, by providing a convenience. Of course, it's all a matter of opinion (and the BDFL's opinion is the only one that really matters), but I think that sometimes this works -- 'for', for example -- but 'yield', and generators in general, are too specific of an idiom to codify at the syntax level. It reeks of perl's arbitrary syntactic nastiness... and at least perl has a way of *dealing* with syntax nastiness! Without some keyword distinction, you're going to instantly break anyone who's calculating yield, for example. (Anyone using python for investment calculations?) At least from my point of view, generators are a solution to a problem which does not exist. There's nothing I can see which would be *significantly* easier using generators. In addition, the implementation side of this is just an efficiency hack. It's not hard to make this work using threads; but since python doesn't have real microthreads, generators won't be built on top of anything except the interpreter itself; and they will hinder the future implementation of microthreads should they happen and probably cause some pretty fruity interoperability issues (if it's a syntax feature). > Have you ever tried implementing generators using Stackless's > continuation primitives? How would you explain to new users what > those magic functions do? New users should not be using generators -- it's an advanced control structure with some interesting uses, but neither would I try to explain to a newbie how to write a task scheduler by putting hooks into ceval.c. Programming is just hard sometimes. (This is one of the reasons I use python and *NOT* icon; for me, generators are not an important enough feature to worm their way into everything.) ______ __ __ _____ _ _ | ____ | \_/ |_____] |_____| |_____| |_____ | | | | @ t w i s t e d m a t r i x . c o m http://twistedmatrix.com/users/glyph From johnroth at ameritech.net Wed Jun 27 00:34:20 2001 From: johnroth at ameritech.net (John Roth) Date: Tue, 26 Jun 2001 21:34:20 -0700 Subject: python as plugin language References: <993529827.54981@newsmaster-04.atnet.at> Message-ID: "Lyle Johnson" wrote in message news:tji6ftsb4dlla3 at corp.supernews.com... > > As someone who may need this in a couple of months, I'd like to ask for > > a bit of clarification. There may be a real obvious answer, but how do you > > get the application and the separately compiled and linked extension > module > > to talk to each other when you can't pass a communication parameter? > > Why can't you pass a communication parameter? You certainly can pass one - if you expect your users to muck it up regularly. I'd rather not give them the opportunity - it's easier on both of us. > That is in fact the approach I > think they described in "Internet Programming with Python", where they refer > to it as registering a "callback" object. Right after you initialize the > Python interpreter, you call out to Python to create an instance of your > callback object (let's call it "callbackObj") and then register that object > with your extension module, e.g. > > callbackObj = MyCallbackObject() > myExtensionModule.setCallbackObject(callbackObj) > > The rest of this message is a quote from "Internet Programming with Python", > Chapter 12: > > """ > After everything has been initialized properly, the Python subsystem and the > main program may then communicate as follows. When the main application > program desires a service of Python the program calls a method of the > callback object, as in: > > PyObject *dummy = PyObject_CallMethod(callbackObj, "someMethod", ...); > > To Python, this appears exactly as if a Python program had executed: > > dummy = callbackObj.someMethod(args) > > The Python interpreter then performs the requested service by executing the > method and returns a value to the main program as the result of the method > call. See below. I'm not interested in the main program requesting a service of Python. I'm interested in Python requesting a service of the main program during it's servicing of a request from the main program. In other words: C calls Python, which in turn calls C. > > On a first scan, "Programming Python" doesn't deal with this issue at all. > > It deals with a lot of other stuff, but if it deals with this, I missed it. > > I'm looking at "Programming Python", 1st ed.; I don't know how much he > changed for the 2nd ed. But in Chapter 15, "Embedding Python", my copy has > an extended case study entitled "Embedding User-Coded Validations", which > should be useful reading. It's followed up by a section entitled "Other > Approaches: Registering Callable Objects", which describes the approach I > mentioned earlier. All the cases you cite miss the essential point - how does the Python code call a function in the C language program it's embedded in? It's relatively easy for the C program to call a pure Python function - it checks its parameters, calculates a result, and returns it. I'm more interested in being able to expose a complete object model, with real, working functions and data. In other words, what you can do with Python in a Web browser under Windows using the Active Scripting interface, although that's a specialized, Windows only implementation. Callback functions, as mentioned in "Programming Python, 2nd Edition" Chapter 20, page 1162, do exactly the opposite. They allow the C program to call Python functions asynchronously. I know what that does, and that's not what I want to do. I'm perfectly happy with the C program calling the Python function synchronously - the function just needs access to objects and methods that are part of the C program. I think the functions I need are in the Python/C API, but I've never seen those functions referenced in any example, or in any of the books. John Roth From phd at phd.fep.ru Sat Jun 2 05:49:03 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Sat, 2 Jun 2001 13:49:03 +0400 (MSD) Subject: MONEY 4 U In-Reply-To: Message-ID: On Sat, 2 Jun 2001, Gerhard [iso-8859-1] H?ring wrote: > Could someone who can get the neccessary information out of the headers please > get this spammer f...ed? I am unable to get enough clues out of the posting > headers. The headers indicte that it is newspost originated at ukr.net. I sent a copmplain (I am sending complains, mostly using SpamCop.net; for newspost I use adcomplain program). But newsposts are very easy to forge. :( Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From lac at cd.chalmers.se Fri Jun 1 00:44:12 2001 From: lac at cd.chalmers.se (Laura Creighton) Date: Fri, 1 Jun 2001 06:44:12 +0200 (MET DST) Subject: "Look, Rocky! Watch me pull a better USENET protocol out of my hat!" Message-ID: <200106010444.GAA08272@boris.cd.chalmers.se> ...I'll bet you can do it with Narval.... Laura From ken_chiba at hotmail.com Sun Jun 24 22:38:13 2001 From: ken_chiba at hotmail.com (Ken) Date: Mon, 25 Jun 2001 02:38:13 GMT Subject: Question re: PyApache Message-ID: <3b36a3a8.369556684@news1.on.sympatico.ca> Hi, I was wondering if anyone out there has any experience with PyApache (python embedding module for Apache 1.3.x). I installed it, and it IS running (using the DSO module). However, I wanted to make sure it was running off python 2.1 (/usr/lib/python2.1/) instead of the old distro version (/usr/lib/python1.5). Is there an easy way to find out? And if it is running off 1.5.2, is there a way to switch it over? Thanks in advance! kc From support at internetdiscovery.com Sat Jun 9 15:18:57 2001 From: support at internetdiscovery.com (Mike Clarkson) Date: Sat, 09 Jun 2001 19:18:57 GMT Subject: TIX - How to envoke ?? References: Message-ID: <3b22769c.23626780@nntp.ix.netcom.com> On Fri, 08 Jun 2001 11:50:33 GMT, Peter Moscatt wrote: >I have just recently succeeded in installing Tix 8.2 and have tested it >through the SHELL. > >Under KDE I use the "ActiveState Komodo" interpreter. > >I am not too sure how I let Komodo know that there is now a Tix module to >be used. > >Is it just a matter of using: > > import Tix > Should be if your Komodo is Python 2.1 based. Mike. From johann at physics.berkeley.edu Tue Jun 19 12:53:04 2001 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 19 Jun 2001 09:53:04 -0700 Subject: Function lookup using a directory. References: <29pX6.14682$cF.320097@news1.nokia.com> Message-ID: andy pevy writes: > The killer was the actual code to call the looked up class :- > try: > h = command_table[command[0]] > except: > print command[0]+' not found' > h.run(h(),command) > It seems that you have to manually pass in the 'self' parameter > when calling functions this way. Two points: 1. That last line should be "h().run()" to be idiomatic. First create the instance, then run the "run" method. 2. Why are you using classes at all? If things are really as simple as you make it seem, just use functions. -- Johann Hibschman johann at physics.berkeley.edu From new_name at mit.edu Fri Jun 22 19:00:59 2001 From: new_name at mit.edu (Alex) Date: 22 Jun 2001 19:00:59 -0400 Subject: many independent python instances in multithreaded application References: Message-ID: > Is it possible to instantiate the python interpreter in each thread > and is there no problem in doing so? I do this a lot. Nothing related to having simultaneous python's running has ever bitten me, as far as I can tell. Alex. From aleaxit at yahoo.com Fri Jun 15 15:29:57 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 15 Jun 2001 21:29:57 +0200 Subject: VI References: <3B278900.5828FB59@Lugoj.Com> <9gaunm$mth$3@brokaw.wa.com> <9gdcl10oti@enews1.newsguy.com> <3B2A4CB4.FE31CB72@Lugoj.Com> Message-ID: <9gdnq5015en@enews1.newsguy.com> "James Logajan" wrote in message news:3B2A4CB4.FE31CB72 at Lugoj.Com... > Alex Martelli wrote: > > "Jim Hill" wrote in message > > > And since the expected editor war hasn't broken out, I'll launch a > > > different offensive by proclaiming absolutely and without room for > > > disagreement that it is pronounced "vee eye" and those who say "vye" > > > are bloody peasants who should be repressed by the violence inherent > > > in the system. > > > > I thought _everybody_ knew it's pronounced "six" -- like in "Pope > > Paul VI", no?! > > Is the Pope Muslim? > > (Since Unix is case sensitive, VI is a different command from vi....) But VIM (and other vi versions) run excellently well under Microsoft, Digital and IBM OS's whose shells are NOT case sensitive, so... Alex From machin_john_888 at hotmail.com Tue Jun 19 00:28:54 2001 From: machin_john_888 at hotmail.com (John Machin) Date: 18 Jun 2001 21:28:54 -0700 Subject: Problem running python program? References: Message-ID: <92ae279c.0106182028.579cd16c@posting.google.com> Timothy Reaves wrote in message news:... > When I run a couple different programs, the following is what happens. > Do I have python setup incorrectly? Definitely. See below. > > [treaves at double treaves]$ export PYTHONHOME=/usr/lib/python2.1/ > [treaves at double treaves]$ gnucash > Could not find platform independent libraries > Could not find platform dependent libraries > Consider setting $PYTHONHOME to [:] > 'import exceptions' failed; use -v for traceback > Warning! Falling back to string-based exceptions > 'import site' failed; use -v for traceback > Fatal Python error: couldn't import os > Aborted (core dumped) [second example snipped] My guess is that you have a Python binary without a whole lot of supporting *.py files. Also [based on 'import exceptions' failed] you are running an old Python [exceptions module was in exceptions.py, is now built into the base executable]. Maybe your PYTHONHOME is wrong (but PYTHONHOME is an *alternate* directory!?) or the files have vanished. Instead of running gnucash etc, try just python -v The problem may be in your gnucash etc scripts; this will help isolate the problem. If the problem is more widespread, the messages that come out might help diagnose the problem. This is something like what you should see from a succesful python -v (produced on a Windows machine). 8<================================================= # C:\PYTHON21\lib\site.pyc matches C:\PYTHON21\lib\site.py import site # precompiled from C:\PYTHON21\lib\site.pyc # C:\PYTHON21\lib\os.pyc matches C:\PYTHON21\lib\os.py import os # precompiled from C:\PYTHON21\lib\os.pyc import nt # builtin # C:\PYTHON21\lib\ntpath.pyc matches C:\PYTHON21\lib\ntpath.py import ntpath # precompiled from C:\PYTHON21\lib\ntpath.pyc # C:\PYTHON21\lib\stat.pyc matches C:\PYTHON21\lib\stat.py import stat # precompiled from C:\PYTHON21\lib\stat.pyc # C:\PYTHON21\lib\UserDict.pyc matches C:\PYTHON21\lib\UserDict.py import UserDict # precompiled from C:\PYTHON21\lib\UserDict.pyc Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> 8<================================================ You will note that the version info is printed *AFTER* the (successful) importing of various modules -- if you get failed import messages and it aborts without telling you the version, try python -V Sorry I can't help you more: (a) you need to say what Python version, how you built/installed it, which platform you are on ... (b) I know little about Python on Unix. Hopefully once you have remedied (a) and the time-zones are favourable, you will get more & better help from others. Cheers, John From emmanuel.astier at winwise.fr Thu Jun 7 12:19:18 2001 From: emmanuel.astier at winwise.fr (Emmanuel Astier) Date: 7 Jun 2001 09:19:18 -0700 Subject: problem with Extending and Embedding Python with BOOST * Solved... Message-ID: Hi, Sorry for this wasted bandwith : I just had to enable the RTTI to get BOOST working... Sorry... Emmanuel From com-nospam at ccraig.org Thu Jun 28 08:01:22 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 28 Jun 2001 08:01:22 -0400 Subject: PEP 260: simplify xrange() References: <3B3A9E5E.D7919F1F@seebelow.org> Message-ID: <878zichkz1.fsf@elbereth.ccraig.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Grant Griffin writes: > [stuff about str] > which, coincidently, looks a lot more like: > > >>> repr(xrange(5)) > 'xrange(5)' > > than: > > >>> str(range(5)) > '[0, 1, 2, 3, 4]' > str(xrange(5)) actually looks _exactly_ like repr(xrange(5)), probably because str() falls back to repr() if it is undefined. Coincidentally (or not), str(range(5)) look exactly like repr(range(5)) as well (probably for the same reason). The reason that they don't look alike is because when range(5) is executed it returns [0, 1, 2, 3, 4] whereas xrange(5) returns an xrange object. - -- Christopher A. Craig "There's no reason the CEO has to write C code." Bill Gates -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Processed by Mailcrypt 3.5.6 and Gnu Privacy Guard iEYEARECAAYFAjs7HIAACgkQjVztv3T8pzs/UACgrdAmcsnAUHksU3GOXbu03ijA TvMAoNWSmtnLItHb1CuYgM3CwwTc3Mou =R19I -----END PGP SIGNATURE----- From sholden at holdenweb.com Fri Jun 29 07:44:50 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 29 Jun 2001 07:44:50 -0400 Subject: module for A/D-converter? References: <20010629.7381058@fb11lfm15.fh-muenster.de> Message-ID: <_QZ_6.11796$zT1.422570@e420r-atl3.usenetserver.com> "Arend von der Lieth" wrote ... Hi everybody, I am wondering if there is a way to implement a program (with python of course) that reads values from an A/D-converter card. More precisely: I want to read data from an oscilloscope and do not want to use the languages that we used before (C, Pascal, VBS) "It depends" is the best answer from the available information. What does it depend on? Well, your OS environment and the interface to the hardware. If you have it attached to a serial port you might look at: http://www.python.org/cgi-bin/faqw.py and query for "serial". Do you have a device driver? If so then Python might well be able to use it. At the very worst, you could write a C extension to do the hardware accesses. This might require root (Unix) or Administrator (NT/2000) privileges to get access to the hardware. regards Steve -- http://www.holdenweb.com/ From hemmi at crc.co.jp Thu Jun 21 08:03:56 2001 From: hemmi at crc.co.jp (HEMMI Shigeru) Date: Thu, 21 Jun 2001 21:03:56 +0900 Subject: Extremely strange problem with httplib/urllib References: <3B2FF349.DE4BF886@crc.co.jp> Message-ID: <3B31E2AC.CE9EDFBA@crc.co.jp> Gustaf Liljegren wrote: > > HEMMI Shigeru wrote: > > >I am using Python 2.1 on Win98. > >I was able to use urllib from my computer. > > I really appreciate your help, but it's not a problem of understanding how > to use urllib/httplib. I have used them before in various scripts, without > this error. The scripts still work: it's only that I get a invalid page > fault error afterwards all the time, and always when I have attempted a web > connection using any of these two modules. I tried your code too, with the > same result. > > So it's nothing wrong with the code. It's something strange going on > between Python and my instance of Windows. It would problaby help to > reinstall Windows, but I hope this won't be needed. I am sorry my word was short. I didn't think that there was a problem in your program. The reason why I attached a program is simply I have it and I was able to verify urllib feature with it. Since the Win9x is very problematic OS, I suspect that to clarify if the trouble is Win9x specific or not is significant. > > Any other suggestions? Sorry I do not have. -- HEMMI Shigeru From jkraska1 at san.rr.com Sun Jun 17 12:21:04 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 17 Jun 2001 16:21:04 GMT Subject: qt or gtk? References: <9ggof8$gmd$1@brokaw.wa.com> <9ghg8c$teo$1@brokaw.wa.com> Message-ID: >> Qt is distributed under the GNU Public License and TrollTech's >> Commercial License. What this means is that if you write a program >> using Qt, you have two choices: you can distribute your program in the >> whole, source code and all, or your can pay TrollTech's licensing >> contract and keep your source code secret. > >Is this true for both qt for X and qt for windows or only for X qt? Just X Qt. He was elaborating on the Linux point, saying that, since its GPL, anyone who has a hold of it can do anything the GPL allows. C// From rdsteph at earthlink.net Thu Jun 21 18:25:58 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Thu, 21 Jun 2001 22:25:58 GMT Subject: PythonCard, wxPython, and Boa... Message-ID: <3B312549.FE255C4F@earthlink.net> For those who offered suggestions, help etc. on my recent event-driven gui programming questions thread, I have decided to intensively concentrate on wxPython first. It just feels right, is highly recommended, Robin Dunn is a great guy, and the wxPython toolkit will probably be used in the potential "PythonCard" project that has arisen. For those who might be interested in PythonCard, the idea only arose on Sunday and was extensively discussed on this list. Since then, however, discussion had moved to a new Yahoo groups list at http://groups.yahoo.com/group/pythoncard which has already been joined by 16 people and has a lively discussion going, so if you are still interested you will have to follow it over there rather than here. Just go to the link and click "join" and follow the steps. Who knows what will arise, if anything, but the basic idea is to create a Python-based higher-level gui-creator, that will be easy to use and still powerful. Since I really getting into wxPython, I am also diving into Boa Constructor, since it uses wxPython. I am sure I will also learn Tkinter by using the Programming Python book, but wxPython is just too enticing for now... ;-))))) Ron Stephens From tim at digicool.com Thu Jun 21 14:57:18 2001 From: tim at digicool.com (Tim Peters) Date: Thu, 21 Jun 2001 14:57:18 -0400 Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: [Terry Reedy] > When I first read the PEP, I assumed that def'ed generators would > somehowreturn the successive yielded values on successive calls (wrong). Alas, I believe that. For good or ill, PEPs aren't tutorials, they're aimed much more at developers of Python (as distinguished from developers using Python). A good user's intro to Python generators doesn't exist yet (AFAIK). > ... > As I now understand it, putting 'yield' somewhere within a function > body will *also* magically transform the function definition into > syntactic sugar for an iteration factory function. Using the grownup words can help : a generator-function returns a generator-iterator, which latter is an object that implements the iterator interface. All the *interesting* questions you're wondering about can be answered by reading the PEP on *iterators* in 2.2. PEP 255 assumes intimate knowledge of the latter, and indeed doesn't make sense without it. > ... > Question: am I correct in thinking that separating > iterator-generation from iterator-first-use makes it possible to have > multiple iterators from the same generator in simultaneous use, as in > > sq10 = squares(10) > sq20 = squares(20) > ... > ? Yes, and this follows from that generator-functions return objects that implement the iterator interface; it's got little to do with generators themselves (apart from that they're not implemented insanely ). Note that this is an "advanced" use, though, and I expect that most uses of generators will be of the simple for object in generator(): ... object ... form. The underlying iteration machinery is exposed so that advanced users *can* do fancier things, but you're not required to do fancier things. In a decade of Python, I believe I can count the number of times I've actually implemented a __getitem__ method that raises IndexError on one hand; I don't expect to *habitually* use advanced generator capabilities either -- but more often that I've used explicit IndexError, because the latter was a much clumsier approach to iteration. From matthew at topic.com.au Wed Jun 27 21:17:04 2001 From: matthew at topic.com.au (Matthew Hawkins) Date: Thu, 28 Jun 2001 11:17:04 +1000 Subject: Zope and PHP Nuke References: <9guphk$5in$1@news.netpower.no> Message-ID: <20010628.111703.1573908495.34940@topic.com.au> In article <9guphk$5in$1 at news.netpower.no>, "David Brown" wrote: > I have been looking around some websites, and have come across Zope and > PHP Nuke. As far as I can see, both systems provide a basis for a > complex website including discussion forums and the like. Would it be > fair to say they cover similar uses, or are there major differences? PHP Nuke seems to be directed exclusively at providing a discussion forum similar to web sites like Slashdot (http://slashdot.org/). Zope is a much more general application foundation for providing a browser based interface to a backend whatever. This is probably why it is more demanding than PHP Nuke, it's far more feature-rich. While you can probably find Zope applications to do what you want, there's plenty more that already exist such as DCL (http://dcl.sourceforge.net/) and Keystone (http://keystone.whitepj.net/) that, if issue tracking etc. is all you're after, will do quite nicely. -M From scarblac at pino.selwerd.nl Wed Jun 20 05:17:37 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 20 Jun 2001 09:17:37 GMT Subject: humans should use a power of 2 References: <9gjqh201q0o@drn.newsguy.com> <9gjshe02115@drn.newsguy.com> <3B301E71.BC0D575B@my.signature> Message-ID: Greg Ewing wrote in comp.lang.python: > thinkit wrote: > > > > In article <9gjqh201q0o at drn.newsguy.com>, thinkit says... > > > > > >please stop using decimal. most people already only use hexadecimal. "0x" is > > >your friend...soon enough humans will be only using powers of 2 as general > > >purpose bases. > > > > > > > sigh...this troll has been posting this same drivel all over all kinds of > > boards. plus trolling IRC with the same junk. just *plonk* this troll. > > Huh? thinkit is accusing *himself* (or herself?) of > being a troll?!-) > > Some attribution or other seems to have gone > astray here... No, he's just that kind of troll. -- Remco Gerlich From chrishbarker at home.net Mon Jun 18 19:02:18 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 18 Jun 2001 16:02:18 -0700 Subject: Teaching Pyhton on Wintel References: <1ev6xe3.15eskd91k2u1eaN%p.agapow@ic.ac.uk> Message-ID: <3B2E887A.92DE8176@home.net> I second the notion to use PythonWin (it comes with the activestate distribution). I found it a lot easier to get started with than IDLE. Also, if you are working with scientists, you will probably want to intoduce NumPy as well, it is a critical component in any Python based number crunching. http://sourceforge.net/projects/numpy -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From aleaxit at yahoo.com Mon Jun 18 11:39:22 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 18 Jun 2001 17:39:22 +0200 Subject: How to tell if interpreter is in interactive mode References: Message-ID: <9gl7ba07u8@enews2.newsguy.com> [posted and mailed] "John Copella" wrote in message news:irMV6.446535$o9.72583096 at typhoon.tampabay.rr.com... > Thanks for your suggestions folks. Basically what I have is a module that I > want to have print some identifying information when it is imported, but > only during interactive sessions -- if the user imports the module from a > script I don't want to clutter the tty with this stuff when the script runs. > I hadn't thought about the IDE aspect as I use the command line for my work, > but it's something to consider. > > Either way, I'm a little surprised this isn't easier to determine. It IS pretty easy -- sorry, hadn't noticed your question earlier! Hoping the answer is still of interest despite the 5 days since you asked...: In module sys, an attribute named ps1 exists during interactive interpreter sessions. IDE's such as IDLE and PythonWin also set it (it's normally the string ">>> "). This attribute is *NOT* set if the interpreter is NOT interactive. Assuming other IDE's etc also follow this sensible convention (can anybody using other IDE's pls check...?), then: def aminteractive(): import sys return hasattr(sys, 'ps1') Alex From tim.one at home.com Sat Jun 30 22:28:41 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 30 Jun 2001 22:28:41 -0400 Subject: [Python-iterators] While we're at it... In-Reply-To: <9hkckn$lsr$00$1@news.t-online.com> Message-ID: [Eduard Hiti] > Could iterators be made slicable? Sure. We could give them .write() methods too . > Then a 'fib()[3:6]' would give you the third to fifth fibonacci numbers. As what, another iterator? A list? A tuple? [Michael Hudson] > I'm not sure that's a good idea, but I would like to see an > "iterators" module that provided various common iterator > manipulations, so you could have eg: > > def slice(it, lo, hi): > for i in range(lo): > it.next() > for i in range(hi - lo): > yield it.next() The number of choices becomes mind-boggling, so prototype this module about 6 times first. Like, who said slice should be a generator? Maybe they want an explicit list. Maybe they don't want that iterating "it" after calling slice() can change the values slice() *later* returns. Maybe they want slice() to return an indexable object too. Etc. The 2.2 test_generators.py has a cute class: class LazyList: def __init__(self, g): self.sofar = [] self.fetch = g.next def __getitem__(self, i): sofar, fetch = self.sofar, self.fetch while i >= len(sofar): sofar.append(fetch()) return sofar[i] def clear(self): self.__dict__.clear() This materializes an explicit list from an iterator, but doesn't compute anything until you force it to by indexing with a value it hasn't seen before; e.g., getting back to Eduard's example, >>> def fibgen(a, b): ... ... def sum(g, h): ... while 1: ... yield g.next() + h.next() ... ... def tail(g): ... g.next() # throw first away ... for x in g: ... yield x ... ... yield a ... yield b ... for s in sum(iter(fib), ... tail(iter(fib))): ... yield s >>> fib = LazyList(fibgen(1, 2)) >>> firstn(iter(fib), 17) [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584] where def firstn(g, n): return [g.next() for i in range(n)] Should probably derive that from UserList instead, to give it a full set of list methods. But then it's not clear what all of them should do. Since there are so many possibilities, and so little Python experience here, I'm very happy to leave the iterator protocol with the single method it *must* have. Anything beyond that is muddy at best, so better to leave it alone at first. From maxm at normik.dk Tue Jun 19 04:25:34 2001 From: maxm at normik.dk (=?iso-8859-1?Q?Max_M=F8ller_Rasmussen?=) Date: Tue, 19 Jun 2001 10:25:34 +0200 Subject: Article on ZODB Programming Message-ID: <7BD10B680501D411B9DF009027E06F32197D6A@exchange> > From: Michel Pelletier [mailto:michel at digicool.com] > I've written the first in a series of articles on the Zope Object > Database (ZODB). These articles show you how you can use ZODB in your > python programs to save your objects in a database transparently. Hi Michel As far as I can see the Zodb is invoked each and every time you start your program. Doesn't that give some kind of startup penalty? In Zope the Zodb is started as a deamon and thus runs constantly withour startup penalty. I am thinking of using Zodb in an asp project, but if I have to reload the database every time it will probably be to slow for my own good. Whou couldn't I just as easily use marshal or pickle then. And that would really be a pitty as I have a small internal project comming, where nobody will nag me about the technology ;-) So it would be great for a tryout project. regards Max M From guido at python.org Thu Jun 21 09:06:00 2001 From: guido at python.org (Guido van Rossum) Date: Thu, 21 Jun 2001 13:06:00 GMT Subject: PEP 255: Simple Generators References: Message-ID: Roman Suzi writes: > I've not been heard or commented. It seems that everybody is happy with > simple generators (and discuss syntax) while I am not. > > I dare think that proposed gen/generator/def-yield thing is doomed to be > phased out in some future Python version, because it creates frozen > context for very narrow task of providing generators and in the future (I > hope) there will be normal parallel programming in Python, which will > solve the problem simply and efficiently. > > I am not against PEP 255. The feature is cool. But it is a feature which > requires new keyword, new function class, etc. In one way or another, it > modifies function and it implicitely lead to the same syntax beasts > as in C++/Java/Pascal. > > PEP 255 is not Pythonish enough. To the contrary, PDP 255 is very Pythonic: it doesn't try to provide the theoretically "best" solution, it provides something that is just as usable in most cases and much easier to implement. This is the essence of many of Python's "innovations" over languages like C++ or Lisp. Some "Zen of Python" (http://www.python.org/doc/Humor.html#zen) rules that apply to the situation: - Simple is better than complex. - Practicality beats purity. - Now is better than never. - If the implementation is easy to explain, it may be a good idea. (The importance of the latter becomes clear to anyone who has had a look at Neil Schemenauer's code for generators.) > Let's better think about more general things like: > * co-routines (which "generator" is an example, if I understand it > correctly) > * adding parallel programming paradigm (which is even better > for long term), where objects live their lifes and could serve > other objects as generators, gatherers, services, etc. > > OOP was made easy by python. I hope parallel programming > to be added and made equally easy, without all those > modifiers and zillion of new keywords and modifiers. > > Sincerely yours, Roman A.Suzi I personally don't believe that parallel programming will ever become the most common way of programming. I know that *my* mind boggles as soon as I try to figure out what a piece of code that uses parallel programming features does, so I expect the same is true for, oh, 99% of the programmers. --Guido van Rossum (home page: http://www.python.org/~guido/) From gregj at pdxperts.com Thu Jun 28 02:50:56 2001 From: gregj at pdxperts.com (Greg Jorgensen) Date: Thu, 28 Jun 2001 06:50:56 GMT Subject: Handling IP's References: <3B39EB71.DEBBF242@usa.net> Message-ID: The functions in this module may help: http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/65219 Greg Jorgensen PDXperts LLC Portland, OR, USA "mixo" wrote in message news:3B39EB71.DEBBF242 at usa.net... > Is there a built function/method to check if an IP falls within a > certain range? > For example, if you have a network a.b.c.d, where "a", and "b" are > fixed but > "c"and "d" variy (I think this a class B network), is there a function > that can > check that some ip say, j.k.l.m, is part of the network? > From edwardt at trillium.com Tue Jun 12 14:33:20 2001 From: edwardt at trillium.com (EdwardT) Date: Tue, 12 Jun 2001 11:33:20 -0700 Subject: Any tool for code coverage analysis on Python program Message-ID: <9g5n9i$qig@news.or.intel.com> Hi I am trying t find a tol that do code analysis on program in python. where can I find it? I am using Python 1.5.2 Thanks From willenpart at a1.net Mon Jun 4 04:29:50 2001 From: willenpart at a1.net (Michael Willenpart) Date: Mon, 4 Jun 2001 10:29:50 +0200 Subject: Zyclic updating of toplevel windows Message-ID: Hi! I've written a small program which mainly consists of a simple options window. Within this window it's possible to select a time interval and the type of an report. Depending of this time interval 2 log files were parsed and a summary of these files is provided as a line and a bar diagram in a separate window (using the toplevel function). If the user generates 3 reports, 3 graphic windows were displayed on the screen. Now my question: Is is somehow possible to auto-update the toplevel-windows? e.g. to redraw the diagrams every 10 minutes. Thanks, Michael From chat at linuxsupreme.homeip.net Fri Jun 15 17:27:27 2001 From: chat at linuxsupreme.homeip.net (Chad Everett) Date: 15 Jun 2001 16:27:27 -0500 Subject: Do Nested try: ... except: 's work? References: Message-ID: On Fri, 15 Jun 2001 19:10:38 -0000, jestes39 at yahoo.com wrote: >I am trying to use the try: ... except: structure as it is used in >Oracle for flow control. I am nesting try/except blocks and raising >named excepts. Each time it gets to a raise statement that is >referencing an except outside the current block, it fails and gives >me an error similar to 'there is no variable named '. >Here is a short section to illustrate my point: > > import telnetlib > > try: > try: > tn = telnetlib.Telnet('xxx.xxx.xxx.xxx') > except: > no_connect_flag = 'TRUE' > > if no_connect_flag == 'TRUE': > raise no_connect > > try: > tn.set_debuglevel(100) > except: > print 'couldn''t set the debug level' > except no_connect: > print 'couldn''t open telnet connection' > >When I run this script through the debugger, I get the error: > > NameError: There is no variable named 'no_connect' > >Any help would be appreciated. Thanks. > >jestes3 at logicon.com > > import telnetlib import exceptions class no_connect(exceptions.Exception): def __init__(self,args=None): self.args = args try: try: tn = telnetlib.Telnet('xxx.xxx.xxx.xxx') except: no_connect_flag = 'TRUE' if no_connect_flag == 'TRUE': raise no_connect try: tn.set_debuglevel(100) except: print 'couldn''t set the debug level' except no_connect: print 'couldn''t open telnet connection' -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From rdskar1 at home.com Tue Jun 5 23:27:45 2001 From: rdskar1 at home.com (rdskar1 at home.com) Date: Wed, 06 Jun 2001 03:27:45 GMT Subject: multifile and mimetools to parse email folder References: Message-ID: I played around with multifile and mimetools again tonight and found out a few things. when a boundary is found (for a multipart message), multifile methods push, next and pop make it easy to move through the parts of the message. when next returns a zero (end of message), one readline will move to the start of the next message. the readline() method can be used on a multifile to move through an email file if the message headers does not provide a boundary item. the problem is having a reliable way of identifying the first line of the next message. Worst case is that mimetools.Message can be created and interrogated on each read. there should be a better way. there is a Lines: item in the header that would tell how many readlines until the next message.. I'm not sure if I can rely on that item being there. In article , rdskar1 at home.com wrote: > I want to read through an email folder (I use mutt on debian, the > 'folder' is a text file) and decode the attachments. I understand how > mimetools works, but I am having trouble moving from message to message > with multifile. I have been trying various combinations off multifile > push, pop and readline methods, but I haven't hit on the right > combinations. > > infl=open('emailfile','r') file=multifile.MultiFile(infl) > msg=mimetools.Message(file) file.push(msg.getparam('boundary')) > file.next() repeat until returns 0 how do I get to the next message? > > Thanks in advance, Bob From nas at python.ca Wed Jun 27 11:43:09 2001 From: nas at python.ca (Neil Schemenauer) Date: Wed, 27 Jun 2001 08:43:09 -0700 Subject: ARGH! Python2.1 build In-Reply-To: <3B39ED9F.9772B4E9@enabledventures.com>; from glen@enabledventures.com on Wed, Jun 27, 2001 at 02:34:02PM +0000 References: <3B39ED9F.9772B4E9@enabledventures.com> Message-ID: <20010627084309.A4635@glacier.fnational.com> Glen Starchman wrote: > Now, under 2.1 we are using DistUtils and it appears to me that the only > way to *remove* a module from the build process is to add the module to > disabled_modules_list in setup.py. What if I want nearly every module > disabled? You could just not install them or remove them after doing an install. All the modules built by setup.py are shared. BTW, why are you disabling most of the modules? Neil From root at rainerdeyke.com Mon Jun 4 10:53:36 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 04 Jun 2001 14:53:36 GMT Subject: I NEED to TEACH you something, QUICK! References: Message-ID: "Laura Creighton" wrote in message news:mailman.991627986.11067.python-list at python.org... > > This always happens. Trust me, been here many times. This is way > more cool that congratulating each other on how smug, er, kind you > are, but things are about to get nasty. What is wrong with this > picture:? Did you actually write all that, or was it algorithmically generated? -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From brakedon at hotmail.com Mon Jun 4 07:39:02 2001 From: brakedon at hotmail.com (eric_brake) Date: 4 Jun 2001 04:39:02 -0700 Subject: create backup script in python References: <7b515e0f.0106011730.6b1aa82d@posting.google.com> Message-ID: <7b515e0f.0106040339.2649f63d@posting.google.com> sill at optonline.net (Rainy) wrote in message news:... > On 1 Jun 2001 18:30:48 -0700, eric_brake wrote: > > What is the easiest way to write a file copy script in python? I want > > to use the script as a way to backup any file I choose on my hard > > drive. Binary mode is best while handling this range of file types, > > Correct? > > > > thank you > > Backup to where? I made a little script that backs up my home directory > to a cdrw disk, it uses mkisofs and cdrecord (unix programs). Never mind, I found what I wanted already. thanks anyway From root at rainerdeyke.com Wed Jun 27 20:40:46 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Thu, 28 Jun 2001 00:40:46 GMT Subject: exec "global" problem References: Message-ID: "Michaell Taylor" wrote in message news:mailman.993683261.32750.python-list at python.org... > My real question is how can I get around this without specifying each of the > 600 variables which need global declarations. There are no 600 variables which need global declaration. You're trying to solve the wrong problem. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From paulp at ActiveState.com Tue Jun 26 15:03:59 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Tue, 26 Jun 2001 12:03:59 -0700 Subject: PEP 255: Simple Generators References: <9h1tt9$16i$1@slb1.atl.mindspring.net> <3B37E7B4.AA2A1095@cosc.canterbury.ac.nz> Message-ID: <3B38DC9F.C3DC34FC@ActiveState.com> Greg Ewing wrote: > >... > > > Me: Well, you can think of a class as a function that returns > > a special kind of object. > > You're going way too fast for this guy, given that > he doesn't know about OO yet. He needs to become > comfortable with OO concepts first, then you can > explain iterator objects, *then* you can explain > what generators do. This is a key question. I also would define generators in terms of methods and iterators. On the other hand, those with the icon mentality consider that just an implementation artifact. I would teach generators only to people who understand most of the "rest of Python". Others seem to want to teach them alongside other flow control keywords. It will be interesting to see how this shakes out in practice. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From sebrosa at artenumerica.com Fri Jun 1 19:21:04 2001 From: sebrosa at artenumerica.com (Jose' Sebrosa) Date: Sat, 02 Jun 2001 00:21:04 +0100 Subject: Obsolesence of <> References: <3B17787F.266644CB@student.gu.edu.au> <3B1707A3.86AB1789@artenumerica.com> <3B17E8B3.F64581DE@artenumerica.com> <3B17FE8E.EFDF95F2@san.rr.com> Message-ID: <3B182360.1C6362FB@artenumerica.com> Darren New wrote: > > Jose' Sebrosa wrote: > > > Thats the only way I can figure to invent a comparison between two complexes, > > and it seems preety absurd to me... > > If you're looking for a consistant but nonsense way of comparing tuples, > you could compare them as tuples of floats. A < B if A.real < B.real || > (A.real == B.real && A.imag < B.imag). Gosh! So simple! Of course you are right! > Not very good mathematics, but then mathematicians don't try to do that. > :-) It certainly doesn't make any *less* sense than "foo" < 27. Not very good mathematics but that's not the point, it is surely very good Python! Sebrosa From tim.one at home.com Wed Jun 27 00:38:15 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 27 Jun 2001 00:38:15 -0400 Subject: PEP 260: simplify xrange() In-Reply-To: <3B39480C.F4808C1F@Lugoj.Com> Message-ID: [James Logajan] > Design mistakes one has made do tend to weigh on one's soul (speaking > from more than two decades of programming experience) so I understand > the primal urge to correct them when one can, and even when one > shouldn't. Is this a case when one shouldn't? That is, is it a specific comment on PEP 260, or just a general venting here? > So although I'm quite annoyed by all these new-fangled gimmicks being > added to the language (i.e. Python generators being added to solve > California's power problems) I have no problem with xrange being fenced > in. OK. > (I find the very existence of the PEP process somewhat unsettling; > there are now thousands of programmers trying to use the language. Why > burden them with insuring their programs remain compatible with yet- > another-damn-set-of-proposals every year? You can ask the C, C++, Fortran, Perl, COBOL (etc, etc) folks that too, but I suspect it's a rhetorical question. I wish you could ask the Java committee, but they work in secret . > Or worse: trying to rewrite their code "more elegantly" using all the > latest gimmicks. Use of new features isn't required by Guido, and neither is downloading new releases. If *you* waste your time doing that, we both know it's because you can't resist <0.5 wink>. > ... > Speaking of "generators", I just want to say that I think that > "generator" makes for lousy terminology. A generator, umm, *generates* a sequence of values. It's neither more specific nor more general than that, so we're pretty much limited to vaguely suggestive terms like "generator" and "iterator"; Python already used the latter word for something else. I'd be happy to call them pink flamingos. > If I understand correctly, "generators" are coroutines They're formally semi-coroutines; it's not symmetric. > that have peer-to-peer synchronized messaging (synchronizing and > communicating at the "yield" points). Way too highfalutin' a view. Think of a generator as a resumable function, and you're not missing anything -- not even an implementation subtlety. They *are* resumable functions. A "yield" is just a "return", but with the twist that the function can resume executing after the "yield" again. If you also think of ordinary call/return as a peer-to-peer etc etc, then I suppose you're stuck with that view here too. > To my mind, "generators" does not evoke that image at all. Good, because that image was overblown beyond recognition . >> although-it-would-be-impolite-to-ask-we-why-still-ship-a-directory- >> full-of-crufty-old-irix5-demos-in-the-std-library-ly > Perhaps because the Irix community would be quite Irate if they were > removed? Doubt it: the Irix5 library files haven't really been touched since 1993. For several years we've also shipped an Irix6 library with all the same stuff. But I suppose releasing a new OS was a symptom of SGI picking on its users too . From flognat at flognat.myip.org Sat Jun 2 18:37:22 2001 From: flognat at flognat.myip.org (Andrew Markebo) Date: Sat, 02 Jun 2001 22:37:22 GMT Subject: Sockets References: <3B193770.30999EAC@telocity.com> Message-ID: You will probably get an exception raised when stuff like timeout, connection error and so on happens.. Throw an eye at try: except:, and the docs to see which exceptions are thrown (Hmm does the docs tell this?) Or do as I do.. I found the errors the experimental way :-) Insufficient memory, that can be hard to detect.. Probably the programme just gets killed by the os? /Andy / Adonis wrote: | *newbie question* | | how can i check for errors when using the socket module? | errors like: unable to connect; insufficient memory etc. | | thanks in advance, | | Adonis From pih at oek.dk Mon Jun 4 08:48:11 2001 From: pih at oek.dk (Peter I. Hansen) Date: Mon, 04 Jun 2001 14:48:11 +0200 Subject: makepasswd Message-ID: <3B1B838B.BC9FD4CC@oek.dk> Hi, Is there a python funtion to generate passwords ? (Like the perl makepasswd) /Peter From dirkLeas at mac.com Wed Jun 13 17:43:14 2001 From: dirkLeas at mac.com (Dirk Leas) Date: Wed, 13 Jun 2001 17:43:14 -0400 Subject: Office's Access XP ODBC DBI from PythonWin In-Reply-To: Message-ID: <003c01c0f451$dacadc70$9865fea9@leascray> Anybody luck working w/ DbiDate from query result? Check out the following: >>> import dbi, odbc >>> db = odbc.odbc('testAccess') >>> cursor = db.cursor() >>> cursor.execute('select * from person') 0 >>> rows = cursor.fetchall() >>> rows [(1, 'Joe Smith', ), (2, 'Mary Smith', )] >>> str(rows[0][2]) '__builtins__\x00])\n\n\x00\x00\x00\xd0\xb2\x12\x1e' I'm running the latest of AS's Python with the Win32 extensions against Office XP Access. TIA, D From root at rainerdeyke.com Mon Jun 18 22:25:19 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Tue, 19 Jun 2001 02:25:19 GMT Subject: PEP 255: Simple Generators References: <9glhg7$dlk$1@nntp6.u.washington.edu> Message-ID: "Neil Schemenauer" wrote in message news:mailman.992912968.20037.python-list at python.org... > Not really. For example, the functions > > def f1(n): > for i in range(n): > yeild i > > def f2(n): > return iter(range(n)) > > do pretty much the same thing. "yeild" is just a handy way of > creating iterators. In other words, whether a function is a generator or not is determined at run-time. The following would work, right? def f(x): if x == 5: yield 5 # Look ma, I'm a generator. return else: return x # Or maybe not. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From paul at calendargalaxy.com Tue Jun 5 14:34:20 2001 From: paul at calendargalaxy.com (Paul Winkler) Date: Tue, 05 Jun 2001 18:34:20 GMT Subject: why huge speed difference btwn 1.52 and 2.1? References: <9f8fgs$ooo$1@knot.queensu.ca> <9fdjsc$pn4$1@panix2.panix.com> <3b1bcf7a.12528354@news.ccs.queensu.ca> Message-ID: <3B1D250B.66FCE4BD@calendargalaxy.com> Hmmm, I don't see any big speed diff between 1.5 and 2.1 - with the script as posted, if anything 2.1 has a slight edge on my machine (Pentium II 366, linux). Robin's original script (modified so it wouldn't close input on blank lines) python 1.5.2: average 20 seconds python 2.1: average 19.5 seconds This can be improved a lot, regardless of the version of python. Duncan Booth wrote: > As far as I can tell your code reads a line in and then looks to see > whether the line contains a word that ends in a state name or a state > abbreviation. So if the line is "Today waz blowy, tomorrow may be better" > is in the input it will be copied to the output files for Arizona and > Wyoming. Is this correct? Not exactly, as I read it Robin has a space before and a space or comma after the state name or abbreviation, and it can be anywhere in the line. > I would be tempted to rewrite the code, either to not use regular > expressions at all, or to use a single regular expression for everything. Me too. And if you do decide to use regexps, you only need to build it once, before the while loop. > If you build one big regular expression that matches all states and state > abbreviations, then you can extract the match out of the line and use what > matched as a dictionary key to find the right filename (provided you first > build a dictionary with both state names and abbreviations as keys mapping > to the filenames). Yeah! I thought of building the filename out of the match, but didn't think of pre-building filenames for all possible matches. It would save some work on lines that match the regexp. That could be a big win if you match a *lot* of lines. In general, you want to do as little work inside the loop as possible. > Oh, and you upper cased the input, so you don't need a case insensitive > search. Yep! One or the other. If you need the line uppercased for some reason, skip the IGNORECASE; if not, try it both ways and see what's faster. Here's my time results for my version - I found a file with a bunch of addresses and copied it to the necessary input filenames, then ran it a few times under each version of python. My implementation of Duncan's suggestions: python 1.5.2: average 5.7 seconds python 2.1: average 5.1 seconds What was the problem again? :) And here's my version of the script - it does everything Duncan suggested except avoiding regexps altogether. (You could do that by building a list of strings to match, then looping through this string once for each line of the input file.) ------------------------------------- import re import string states = { 'ALABAMA':'AL', 'ALASKA':'AK', 'ARIZONA':'AZ', 'WISCONSIN':'WI', 'WYOMING':'WY' } filenames = { 'AL': 'ALABAMA', 'ALABAMA': 'ALABAMA', 'AK':'ALASKA', 'ALASKA':'ALASKA', 'AZ':'ARIZONA', 'ARIZONA':'ARIZONA', 'WI':'WISCONSIN', 'WISCONSIN':'WISCONSIN', 'WY':'WYOMING', 'WYOMING':'WYOMING' } #(STATENAME) OR (STATE ABBREVIATION) # only needs to be built once statepattern = " (" for name, abbr in states.items(): statepattern =statepattern +name +'|' +abbr +'|' # take off the last "|" statepattern = statepattern[:-1] # close the state group; then match space or comma statepattern = statepattern +")[ ,]" ## print `statepattern` stateregex = re.compile(statepattern) for year in range(1994, 1998): f = open('states/USA'+str(year)+'.TXT') counter = 1 while(1): print str(year), counter counter = counter + 1 #convert city name to allcaps (db outputs in allcaps) line = f.readline() #check for EOF if not line: break # Strip the line. I do this AFTER the above test # because it would break on blank lines, # not just EOF. # Is that what you wanted? line = string.upper(string.strip(line)) # it could be faster to skip this and make a # case-insensitive regexp... or not. try that too. result = stateregex.search(line) if result: state = result.group(1) # get the filename filename = filenames[state] filename = string.replace(filename, ' ', '_') g = open('states/'+filename+'/'+str(year)+'.TXT', "a") g.write(line + "\n") g.close() f.close() From sill at optonline.net Sat Jun 16 01:52:12 2001 From: sill at optonline.net (Rainy) Date: Sat, 16 Jun 2001 05:52:12 GMT Subject: qt or gtk? Message-ID: I want to learn python gui programming in linux. I think tk looks too ugly, so I narrowed down the choice to two main contenders, qt and gtk. Which of these has more complete and up-to-date python bindings? Are there other reasons to prefer one of these over another for python gui work? -- "Your password must be at least 18770 characters and cannot repeat any of your previous 30689 passwords. Please type a different password. Type a password that meets these requirements in both text boxes." (Error message from Microsoft Windows 2000 SP1) From deltapigz at telocity.com Tue Jun 12 16:19:54 2001 From: deltapigz at telocity.com (Adonis) Date: Tue, 12 Jun 2001 16:19:54 -0400 Subject: Global Variables + Threads Message-ID: <3B26796A.C3FAF2E3@telocity.com> in python im declaring varibles in which willbe used by Tkinter as objects within itself; now since they are globally declared i assumed they would be fill as soon as the class thread finishes execution. or by being a thread; thus being pushed to its own thread makes it lose "contact" with the global variable and instead declares it as local? if this is the case then how may i fix it? thanks in advance, Adonis --begin code-- from Tkinter import * from threading import Thread import sys root = Tk() b = 0 e = 0 t = 0 frame = 0 class pshgui(Thread): def __init__(self): Thread.__init__(self) def run(self): frame = Frame(root, width=200, height=15) frame.grid(row=0, column=0) # creating textbox field t = Text(frame, width=50, height=10, fg="darkblue") t.grid(row=1, column=0) # setting color tags to use inthe text box t.tag_config("ver", foreground="blue", justify=CENTER) t.tag_config("err", foreground="red") # entry box e = Text(frame, width=26, height=1, fg="darkblue") e.grid(row=0, column=0, sticky=W) # create a button b = Button(frame, text="connect", width=6, height=1, command=frame.quit) b.grid(row=0, column=0, sticky=E) # inserting program version+platform running t.insert(END, "Py 01.1/" + sys.platform + "\n\n","ver") gui = pshgui() gui.start() root.mainloop() From avv at quasar.ipa.nw.ru Fri Jun 8 15:57:35 2001 From: avv at quasar.ipa.nw.ru (Alexander V. Voinov) Date: Fri, 08 Jun 2001 12:57:35 -0700 Subject: getch() of Turbo C in Python? References: <9fongm01ic6@enews1.newsguy.com> Message-ID: <3B212E2F.4E9BB1E4@quasar.ipa.nw.ru> Hi Alex Martelli wrote: > "Anurag Ved" wrote in message > news:fa4233c9.0106071108.7b1c4ed8 at posting.google.com... > ... > > Is there something similar to the getch() function of Turbo C which > > reads just one key from and returns immediately? > > Yes, it's called getch() and is exported from module msvcrt (in > Windows versions of Python). With the use of pyslang you may probably be able to do this in a cross-platform way, if you care. Alexander From cfelling at iae.nl Fri Jun 15 18:22:17 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 16 Jun 2001 00:22:17 +0200 Subject: PEP 259: Revise to remove context-driven magic from print References: <486de2.0106131406.5c0cbef9@posting.google.com> <9gamor$8ft$6@216.39.170.247> <9gap8i0fss@enews1.newsguy.com> <9gco3r0305m@enews1.newsguy.com> Message-ID: <9ge1qp$8co$1@animus.fel.iae.nl> Alex Martelli wrote: > ... >> > No, __print__ would rather underlie the print statement just like >> > __import__ underlies the import (and from) statements. But I guess >> > I gotta write a PEP about it... please do, and... > __builtin__.__print__ would be allowed to be any callable with a > compatible interface to a 'bundled' __print__. The latter would > encode the current magic features of the print statements as kw > arguments with optional values: > file=sys.stdout set by the >>fileobject hack to file=fileobject > nl=1 set by a trailing-comma to nl=0 consider making this newline=1, as it's probably infrequent use will make it hard to get to remember the shorthand. (I myself, I've always to think again seeing nl to map it to newline and not to Nederland, if I'm the only one, don't bother) > settable to nl=-1 to get the nl-stripping > behavior that Guido wanted (no syntax for > that in the print statement) > (still to be designed: what if anything to do about .softspace play &c; > whether to supply a few more kw's, without syntax for them in the print > statement, just to ease customization & direct use -- I guess not, but...). consider enhancing the print statement to resemble __print__ calls. I think someone else already proposed it, like in: >>> print "spam", newline=1; print "and spam", softspace=0 spamand spam I'm not sure I like this, as it suggest that the place of the keyword assignment matters. People could expect things like: >>> print "spam", softspace=0, 'and spam" spamand spam And I'm *not* advocating such extra print magic, I'd rather have it raise "SyntaxError: non-keyword arg after keyword arg", and have softspace only deal with the first space. (maybe an extra kw-arg softspaces to overrule the special treatment of , all together?) -- groetjes, carel From guido at python.org Fri Jun 29 08:21:32 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 29 Jun 2001 12:21:32 GMT Subject: PEP 260: simplify xrange() References: <3B3AA1AE.AC965683@seebelow.org> <3B3C1F61.F904199B@letterror.com> Message-ID: Just van Rossum writes: > Erm, now that "for line in file" works (in 2.2 that is), doesn't that > mean that xreadlines() is superfluous? Or: what does xreadlines() offer > that "for line in file" doesn't? file.xreadlines() offers nothing except backwards compatibility. (It's also used internally to *implement* "for line in file:" but that's an invisible design choice.) On the other hand, the xreadlines *module* offers fast buffering reads on any file-like object that supports the readlines(sizehint) method. It also supports the iterator interface now, serving as its own interator (I suppose the getitem interface should be deprecated). --Guido van Rossum (home page: http://www.python.org/~guido/) From dsh8290 at rit.edu Sat Jun 30 13:06:42 2001 From: dsh8290 at rit.edu (D-Man) Date: Sat, 30 Jun 2001 13:06:42 -0400 Subject: 'with' statement in python ? In-Reply-To: ; from sholden@holdenweb.com on Thu, Jun 28, 2001 at 10:13:40PM -0400 References: Message-ID: <20010630130642.A22184@harmony.cs.rit.edu> On Thu, Jun 28, 2001 at 10:13:40PM -0400, Steve Holden wrote: | The reappearance of the FAQ wizard allowed me to enter: | | 6.31. Why doesn't Python have a "with" statement like Delphi's Object | Pascal? I just found out that JavaScript has a "with" statement (spelled "with" too). Might want to add that. -D From brakedon at hotmail.com Wed Jun 6 08:55:50 2001 From: brakedon at hotmail.com (eric_brake) Date: 6 Jun 2001 05:55:50 -0700 Subject: Error checking for 'raw_input( )'? Message-ID: <7b515e0f.0106060455.4093daa0@posting.google.com> What is the best way to detect whether number or letter strings were entered into the "raw_input( )" field. I want to be able to send a error message to the user if they enter the incorrect type (numbers,letters,etc). From deltapigz at telocity.com Fri Jun 1 11:09:16 2001 From: deltapigz at telocity.com (Adonis) Date: Fri, 01 Jun 2001 11:09:16 -0400 Subject: newbie to python. Message-ID: <3B17B01B.7A1C85E0@telocity.com> i am completely new to python so my knowledge on this script language is completely null; nevertheless here is my question: how can i error check the sockets module; i.e. if the socket returns 10060 or conection refused; etc. thanks in advance, Adonis From geckeler at gmx.net Tue Jun 19 18:47:49 2001 From: geckeler at gmx.net (Carsten Geckeler) Date: Wed, 20 Jun 2001 00:47:49 +0200 (CEST) Subject: Any other Python flaws? In-Reply-To: <9glg6m$gp2$2@newshost.accu.uu.nl> Message-ID: On 18 Jun 2001, Martijn Faassen wrote: > Carsten Geckeler wrote: > > On 14 Jun 2001, Martijn Faassen wrote: > [snip] > >> This may be considered a minor quibble; the mandatory use of () in > >> case of multiple arguments to the % string interpolation operator: > >> > >> "%s" % "foo" > >> > >> "%s %s" % "foo", "bar" # doesn't work right > >> > >> "%s %s" % ("foo", "bar") > > > This has nothing to do with "mandatory" or optional. This is a question > > of operator precedence. The "%" operator has higher precedence as the "," > > operator, so grouping with (..) is necessary. > > Sure, so ( and ) is mandatory. :) I know it's due to operator > precendence issues. Doesn't mean it's not something that doesn't bite > people. The actually really weird case is the single element tuple, > which you can instead write as '% foo'. Are you annoyed that Python provides this simplification? Surely not. > But since single element tuples are a wart by themselves, this extra > magic is necessary. Perhaps a language is possible where single > element tuples actually are single elements, though that may introduce > other warts. So that's your point. But then propose another way of making one-element tuples. BTW, I don't see "(1,)" as magic, more as simple given syntax. Since the curly brackets {} are used for dictionaries, normal brackets [] for lists, there are only the parenthesis () left. And since they are used for grouping, this special case for one-element tuple is needed. Although I admit that I doesn't look very nice, I don't see any alternatives. Cheers, Carsten -- Carsten Geckeler: geckeler at gmx dot net From new_name at mit.edu Thu Jun 14 13:28:45 2001 From: new_name at mit.edu (Alex) Date: 14 Jun 2001 13:28:45 -0400 Subject: Extending methods References: <3B28DE51.B9A71F2F@usa.net> Message-ID: > How does one extend a method in a class that has been inherited from > another class? class A: def method_name(self): print 'executing A.method_name' class B(A): def method_name(self): print 'executing B.method_name' A.method_name(self) b = B() b.method_name() HTH. Alex. From tim_one at email.msn.com Fri Jun 29 14:16:49 2001 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 29 Jun 2001 14:16:49 -0400 Subject: functional programming and default parameters In-Reply-To: Message-ID: [Ralf Muschall] > ... > Unfortunately, in Python writing > > for i in range(3): > j=i > fns[i]()=lambda:j > > fails, and even this fails too: > > for i in range(3): > j=i+10 > a[i]=lambda:j > > map(x:x(),fns) gives [12,12,12]. "for" doesn't create a new scope in Python: in both examples, *everything* is taking place in the same namespace (scope). "lambda: j" compiles to a code block that returns the current binding of the non-local name j, whatever that happens to be when the body of the lambda is executed. Because the loop didn't create a new scope, assigning to j inside the loop has nothing to do with the value the lambda returns at *its* runtime. > My guess is that the interpreter detects the *creation* of the > variable "j" in the loop and optimizes by shifting that in front of > the loop, leaving only the *assignment* in the loop body. No, Python does no optimizations at all: WYSIWYG. But you're carrying a scope model over from Lisp that doesn't apply in Python. In general, the only way to get a Lispish new scope in Python is via nesting a def. From abbn at v-share.com Thu Jun 7 12:46:26 2001 From: abbn at v-share.com (Vassilis Vassiliou) Date: Thu, 7 Jun 2001 19:46:26 +0300 Subject: Shareware Software Registration Services Message-ID: <200106071646.f57GkQY13287@v-share.com> Dear Software Vendor, Our company Visage Services Inc. offers valuable shareware software registration services to many developers for the past 4 years. Being ourselves shareware software developers we created in 1998 a state of the art service administration system which proved very reliable and prosperous, due to its highly adaptable flexibility. Taking into consideration our very attractive fee schedule this could be a major opportunity to enhance your profits at a minimum cost. Please visit our site at http://www.v-share.com for a detailed description of these services and our fee schedule. Should you need assistance, feel free to contact me anytime. Thank you for your time reading my mail. Sincerely, Vassilis Vassiliou Sales Manager VISAGE SERVICES INC. abbn at v-share.com From atodd at spam.free.email.com Thu Jun 28 01:00:11 2001 From: atodd at spam.free.email.com (Andy Todd) Date: Thu, 28 Jun 2001 05:00:11 GMT Subject: Check out O'Reilly's Open Source Convention Highlights References: <3B3AA82D.1A0FE860@seebelow.org> Message-ID: Grant Griffin wrote in <3B3AA82D.1A0FE860 at seebelow.org>: >Guido van Rossum wrote: >> >> I promise this is a one-time ad! Check out the Python track: >> >> http://conferences.oreillynet.com/cs/os2001/pub/w/os2001/sessions_pytho >> n.html > >Durn--it's in California. Why aren't these things ever held in the >Midwest?--it's centrally located, ya' know. > >must-be-some-kindda-darn-conspiracy-for-you-East-Cost-folks-to > -rack-up-frequent-flyer-miles--ly y'rs, > >=g2 Hummpph, bah humbug. Blimey. Time to pull out the atlas again and redefine 'world' from "between-the- east-coast-and-the-west-coast" to "blimey-its-a-big-ball-type-thing-that- doesn't-just-stop-when-you-get-to-the-wet-bits" ;-) Greetings from far, far, away, Andy -- Content free posts a speciality From phd at phd.fep.ru Wed Jun 13 03:57:10 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Wed, 13 Jun 2001 11:57:10 +0400 (MSD) Subject: Python for MS-DOS (was: Re: RS232 support for DOS on 486?) In-Reply-To: Message-ID: On 12 Jun 2001, Cyril Slobin wrote: > > Do you know you can put this into init.py (I hope your Python executes > > init.py upon interactive startup) and have history load/save automatically? > > > import rlcompleter, readline > > Unsafe. I have three different python executables floating around, one > of them haven't readline at all and one have old-styled readline. So my > startup.py have a lot of try/except's to catch all the possible cases. > > > histfile="%s/.python-history" % os.environ["HOME"] > > Unportable. Use os.path.join instead; Sure, thanks. BTW, here is my entire init.py. May be you find something useful: from pydoc import help # From Bruce Edge, http://groups.yahoo.com/group/python-list/message/128961 import rlcompleter, readline #readline.parse_and_bind("tab: complete") readline.parse_and_bind("tab: menu-complete") import os histfile="%s/.python-history" % os.environ["HOME"] readline.read_history_file(histfile) def savehist(): global histfile readline.write_history_file(histfile) import atexit atexit.register(savehist) # From Randall Hopper, http://groups.yahoo.com/group/python-list/message/130175 import sys if os.environ.get("TERM") in ["xterm", "rxvt", "vt100"]: sys.ps1 = "\001\033[0:1;32m\002>>> \001\033[0m\002" sys.ps2 = "\001\033[0:31m\002... \001\033[0m\002" # From: Paul Magwene, http://groups.yahoo.com/group/python-list/message/129882 class DirLister: def __getitem__(self, key): s = os.listdir(os.getcwd()) return s[key] def __getslice__(self,i,j): s = os.listdir(os.getcwd()) return s[i:j] def __call__(self, path=os.getcwd()): path = os.path.expanduser(os.path.expandvars(path)) return os.listdir(path) def __repr__(self): return str(os.listdir(os.getcwd())) class DirChanger: def __init__(self, path=os.getcwd()): self.__call__(path) def __call__(self, path=os.getcwd()): path = os.path.expanduser(os.path.expandvars(path)) os.chdir(path) def __repr__(self): return os.getcwd() ls = DirLister() cd = DirChanger() # From Thomas Heller, http://groups.yahoo.com/group/python-list/message/133035 import sys def info(*args): import pdb pdb.pm() sys.excepthook = info Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From laurent.pointal at wanadoo.fr Tue Jun 12 15:45:18 2001 From: laurent.pointal at wanadoo.fr (Laurent Pointal) Date: Tue, 12 Jun 2001 19:45:18 GMT Subject: Global in multiple files References: Message-ID: [posted and mailed] arturs at iidea.pl (Artur Skura) wrote in news:slrn9i6mb8.1vb.arturs at aph.waw.pdi.net: > > I'm not a fan of OO but I decided to give it a try. After all, Python > makes it elegant. > > So I wrote a program usuing classes, methods etc. All nice. Then it > grew up and I decided to split it in several files - one class into > each class as Guido asked us to do. > > And then, I came across my first problem: I had had a global variable > (just one!) and it wouldn't work anymore. At all. Any 'global' > declarations wouldn't help, and without it I'm lost. > > So, I thought I might be smarter than it. I would pass this > variable to where I need it, but... it stil obstinately refuses to > work. But then, my ex-global is a list of instances of a class, > and methods in instances of another class won't accept it as > an argument. If you split class AClass in module A and class BClass in module B, and need to access a global globlist: You can: -------- Put globlist in A as a global. In A access globlist directly as a global. In B do an "import A". In B access globlist via "A.globlist". Or you can: ----------- Put globlist in a tierce G module. In A and B do n "import G" In A and B access globlist via "G.globlist" (second solution can solve cross reference between several modules by moving shared references into one common place, and it has the advantage to use the same access method for everybody) The use of module.name syntax ensure that everybody will use the same global, even if it the referenced object is changed. To enforce this rule you can prefix the global by an _ so that it cannot be imported directly. Finally you can: ---------------- Define a module with accessor functions (or accessor classe methods), which will be used to manipulate the global. A+ Laurent. From johnroth at ameritech.net Wed Jun 27 10:21:38 2001 From: johnroth at ameritech.net (John Roth) Date: Wed, 27 Jun 2001 07:21:38 -0700 Subject: newbie with major "lambda" problem (perhaps a scope problem as well) References: Message-ID: "Joe Potter" wrote in message news:gkkjjts1msjq3ps19qs1aobi6m06jtscpc at 4ax.com... > On Tue, 26 Jun 2001 22:00:52 -0700, "John Roth" wrote: > > > > >"Joe Potter" wrote in message > >news:n8dhjt8qmel0ajjae7tv9gmjf60c39qag5 at 4ax.com... > >> On Tue, 26 Jun 2001 16:09:06 GMT, "Rainer Deyke" > >wrote: > >> > >> >"Joe Potter" wrote in message > >> >news:j5ahjtkfmf32lkqtap0q1u6rig385d7b5i at 4ax.com... > >> >> # the "button" below works like a champ !! > >> >> #Button(root, text='Fetch', > >> >> #command=(lambda v=vars: fetch(v))).pack(side=LEFT) > >> >> > >> >> # the "button" below does not do anything ?????? > >> >> Button(root, text='Fetch', command=(fetch(vars))).pack(side=LEFT) > >> > > > > > > > > >Then in effect I'm building an unnamed function definition, and assigning > >default > >values to the two parameters. Those default values will travel with the > >definition, > >so when Tkinter calls it later, they will be availible to the actual > >execution. > > > >The call of foo(a,b) in the definition above is part of the definition - it > >won't be > >executed until the function object is executed later. > > > > Thanks John, > > I think I see it. If I can get a look at the solution to the code example that I used > in my reply to Chris Barker --- I'll have it made. > > Perhaps you can take a look at that example also? > > Thanks again. > > Regards, Joe You don't need to create a frame at all - the classes I write just go right ahead and start loading widgets into the parent widget, which is passed in as a parameter. Setting up your class as a frame is somewhat better for code reuse, but it really depends on what you want to do with it If it's a one-shot, a frame is redundant. If it's a group of controls you're likely to want to use somewhere else, then putting it in a frame makes it much more portable. The following snippet shows one I wrote recently: class ADataEntryUI: def __init__(self, parent, frame): self.ParentClass = parent self.DateType = "Gregorian" self._DateVar = StringVar() self._DateError = "" self.TimeType = "AM" self._TimeVar = StringVar() self._TimeError = "" As you can see, it doesn't subclass anything! John Roth From pinard at iro.umontreal.ca Tue Jun 26 07:57:44 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 26 Jun 2001 07:57:44 -0400 Subject: Python scripting [was: Re: emacs speedbar for python mode?] In-Reply-To: References: Message-ID: [Roman Suzi] > The question was about Python scripting editor, though. In my original message, I was dreaming to script Emacs with Python. In the resulting thread, someone suggested that Cool Edit could satisfy my dream. > Emacs is at least 2 times older than Python and is in it's 20/21's > versions. No wonder it's different calibre! It might not only be a question of age. My feeling is that Cool Edit would need re-orientation for becoming able to grow as featureful as Emacs is. But once again, please do not take it as a criticism against Cool Edit. Not at all. I would warmly recommend it to friends working on X, as being friendly, supporting Latin-1 and UTF-8 out of the box, and Python scriptable. I also found the display to use especially legible default fonts. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From junkster at rochester.rr.com Thu Jun 14 19:43:56 2001 From: junkster at rochester.rr.com (Benjamin Schollnick) Date: Thu, 14 Jun 2001 23:43:56 GMT Subject: Office's Access XP ODBC DBI from PythonWin References: <9ga6cd02m44@enews1.newsguy.com> Message-ID: > mx.ODBC > instead > > of ODBC? If you don't plan commercial use it is free, and I can certainly > > recommend it for ease of use. > > Seconded. But a minimally-working free odbc would still be > a good thing IMHO. Say I write utilities to be internally > used here at work (commercial use by mx's terms). As long > as I run them on Windows only, I'm OK -- I can program to > ADO and connect that to whatever DB engine. But -- no funds > for mxODBC for that use. So -- no running my utilities on > Linux boxes. Notch one more black mark discouraging this > spread of Linux boxes around here:-(. Seconded here.... I was told point blankly by Marc that even though I was using MxODBC, for my own non-commercial projects, that since I was using it at work it had to be commercially licensed.... Even though the app was not be distributed, and just a simple CGI script... I don't mind that, I can understand where he was coming from... But win32's ODBC code seems to work fine for our purposes, and should still be developed....or maintained... MxODBC can't be the only ODBC code out there..... - Benjamin From johnroth at ameritech.net Mon Jun 4 01:15:23 2001 From: johnroth at ameritech.net (John Roth) Date: Sun, 3 Jun 2001 22:15:23 -0700 Subject: Why no 'elif' in try/except? References: <3B1A06EE.F484930A@snakefarm.org> <3B1A29DE.9876770D@accessforall.nl> Message-ID: Because it makes no sense? The except clauses are for handling exceptions, the else clause is for handling the case when everything worked fine. Mixing the two makes no sense. In an except clause, there is no result to test; in an else clause, there is. Is the elif supposed to execute when there are exceptions, or when there aren't? If it's simply an extension to the else clause, then I suppose it doesn't harm anything, but it adds complexity to the language definition. At this point in my life, I tend to agree with Einstein - make everything as simple as possible, but no simpler. The last place (or at least one of the many last places) I want additional complexity is in exception handling. John Roth "Ype Kingma" wrote in message news:3B1A29DE.9876770D at accessforall.nl... > > > Carsten Gaebler wrote: > > > > Hi there! > > > > How about adding an 'elif' to try/except? I.e.: > > > > try: > > res = dosomethingnasty() > > except: > > complain() > > elif res == 1: > > behappy() > > > > instead of > > > > try: > > res = dosomethingnasty() > > except: > > complain() > > else: > > if res == 1: > > behappy() > > > > Any opinions? > > The 'else:' in 'try: except: else:' should have been called 'normally:'. > > Regards, > > Ype > > > P.S. A possible cause of this problem is that sheep normally don't fly: > > try: > sheep.fly() > except: > sheep.fell() > normally: > ??? > > P.P.S. Perhaps this code be preceeded by "while 1:" to make it more clear. > > -- > email at xs4all.nl From vdelft at itmasters.com Wed Jun 20 08:56:22 2001 From: vdelft at itmasters.com (vincent delft) Date: Wed, 20 Jun 2001 14:56:22 +0200 Subject: memory bug in win32pdh Message-ID: <3B309D76.354E2692@itmasters.com> I'm written a small python script to get, each seconds, the list of process running on a W2K box. During that develoment I've founded a strange behaviour. I've isolated the problem to 1 simple command. Try the following code, and look in your "Task Manager", the "memory usage" for your python process will grow and grow. Within 10 minutes the "memory usage" grow up to 800kb. import time import win32pdh while 1: win32pdh.EnumObjectItems(None,None,'Process', win32pdh.PERF_DETAIL_WIZARD) time.sleep(1) If someone have a solution .... Thanks From emile at fenx.com Fri Jun 15 09:16:44 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 15 Jun 2001 06:16:44 -0700 Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> <9gceld02n4c@enews1.newsguy.com> Message-ID: <9gd23d$86ls4$1@ID-11957.news.dfncis.de> "Alex Martelli" wrote in message news:9gceld02n4c at enews1.newsguy.com... > value to that same named attribute (since it's EXACTLY the > same operation...); by your logic, "it should therefore use > the same syntax". So how comes: > fee.fie = foo.fum > and > setattr(fee, 'fie', foo.fum) > and > fee.fie = getattr(foo, 'fum') > and > setattr(fee, 'fie', getattr(foo, 'fum')) > use four widely divergent syntax forms for the same op?-) Well, really eight if you note that fum requires arguments: ;-) fee.fie = foo.fum(eggs.spam) But could you explain why I see this as two forms but you see it as four? Is it a left/right thing? -- Emile van Sebille emile at fenx.com --------- From loewis at informatik.hu-berlin.de Tue Jun 5 04:24:48 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 05 Jun 2001 10:24:48 +0200 Subject: Compile times? References: Message-ID: Paulo Jan writes: > I am aware that my CPU is not the fastest in the world, but 4 > or 5 hours for just one extension is ridiculous; it compiled the rest > in just a couple of hours!!! Can anybody tell me if these compile > times (assuming my slow CPU) are normal? Am I missing any library or > something? How long does it take to compile for everybody else? We have a report that there might be problems with multi-threading on OpenBSD 2.8, so I recommend to configure without threads. Please let us know whether that helps. Regards, Martin From Glen.Mettler at home.com Sun Jun 10 09:04:35 2001 From: Glen.Mettler at home.com (Glen Mettler) Date: Sun, 10 Jun 2001 13:04:35 GMT Subject: New guy question References: Message-ID: OK...I went back to the beginning and discovered that the author of the tutorial showed me three windows. One with a black background that he described as the Python prompt (>>>) (title is Python) One with a white background that he described as IDLE - also with a Python prompt (title is Python Shell) One with a black background that he described as the "command" window that in fact is the DOS window (title MS DOS Prompt) I went to the MS DOS Prompt ("Command") and typed in python alook.py and got an error message: Bad command or file name. "Glen Mettler" wrote in message news:TiyU6.127784$I5.32725119 at news1.rdc1.tn.home.com... > I have a small script I entered from a Python book that works when I run it > using F5. > However, when I go to the console and enter python alook.py, I get an error > message: > > >>> python alook.py > SyntaxError: invalid syntax > > I am too new to this to know why. > > Glen > > From jhweeks at earthlink.net Sat Jun 16 17:40:13 2001 From: jhweeks at earthlink.net (John Weeks) Date: Sat, 16 Jun 2001 21:40:13 GMT Subject: gzip.py failure References: Message-ID: <1nQW6.11369$Kq4.1058859@newsread2.prod.itd.earthlink.net> Gerhard H?ring wrote: > On Sat, 16 Jun 2001 16:38:57 GMT, John Weeks > wrote: >>I'm running Python 2.0 from the SuSE 7.1 distribution. >> >>I'm getting an attribute error when trying to umcompress a gziped file. >>The error occurs on line 210 of the gzip.py module: >> >> if self.decompress.unused_data != "": >> >>There doesn't seem to be an "unused_data" attribute for the "decompress" >>object. >> >>Running this program: >> >> from gzip import * >> def gf(): >> f=GzipFile("g.data","r") >> c=f.read() >> print c >> >> gf() >> >>produces the following: >> >> Traceback (most recent call last): >> File "tt.py", line 7, in ? >> gf() >> File "tt.py", line 4, in gf >> c=f.read() >> File "/usr/lib/python2.0/gzip.py", line 149, in read >> self._read(readsize) >> File "/usr/lib/python2.0/gzip.py", line 210, in _read >> if self.decompress.unused_data != "": >> AttributeError: unused_data >> >>Anybody have any ideas? > > On my second SuSE 7.1 machine I still have Python 2.0, so I tried there. > > Let me guess! You have Zope installed? I knew 8-) I have had a similar > problem, and uninstalling Zope helped. Your test script runs fine w/o > Zope, but crashes w/ Zope installed on my machine. > > Consider this: > > gerhard at gargamel:/tmp > rpm -qf > /usr/lib/python2.0/lib-dynload/zlibmodule.so python-2.0-6 > gerhard at gargamel:/tmp > rpm -qf /usr/lib/python2.0/lib-dynload/zlib.so > zope-2.2.5-0 > > Seems the Zope RPM installs a different zlib module and Python loads > zlib.so instead of zlibmodule.so > > I'd recommend that, if you don't need Zope, throw it away, else try > deleting/renaming that zlib.so > > Gerhard Brilliant! You are exactly correct. I uninstalled zope and everything works the way it should. I was going to play with zope sometime, but when or if I need to I'll deal with the zlib problem. Thanks, JW jhweeks at earthlink.net From stain at prigioniero.it Tue Jun 12 13:25:17 2001 From: stain at prigioniero.it (Nicola S.) Date: Tue, 12 Jun 2001 17:25:17 GMT Subject: [Tkinter]: tkMessageBox Internazionalization? Message-ID: Is there a comfortable way to change the text of the buttons in the dialog window shown, for example, by tkMessageBox.askokcancel? I'd like to use another language for the text 'OK' 'Cancel'; but maybe this concerns tcl/tk internals. thanks to everyone. From phrxy at csv.warwick.ac.uk Fri Jun 22 17:34:39 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Fri, 22 Jun 2001 22:34:39 +0100 Subject: Another Wart! string.find() [ was: namespace issue? ] In-Reply-To: <3B33B0E2.867053FE@ccvcorp.com> References: <3B33B0E2.867053FE@ccvcorp.com> Message-ID: On Fri, 22 Jun 2001, Jeff Shannon wrote: [...] > Except that, even if string.find() returned None (false), it still > wouldn't work: > > s = "spam" > sub = "sp" > if string.find(s, sub): > dospam() > > In this case, dospam() never executes, even though our substring *is* > found. > > While you *could* explicitly test > > if string.find(s, sub) is not None: > > I don't see this as being really any better than > > if string.find(s, sub) >= 0: > > or > > if string.find(s, sub) == -1 [...] In fact, I think you've just demonstrated why -1 is actually *better* than None. If it did return None, people would forever be testing if string.find(s, sub): foo() and forgetting about the 0 case. At least, I would be, I'm sure. John From tim.one at home.com Sat Jun 2 18:12:59 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 2 Jun 2001 18:12:59 -0400 Subject: Why isn't Python king of the hill? In-Reply-To: <393D961EA4FCD311B03F00D0B746D65803275E5F@HQSXCH01> Message-ID: [Geoffrey Gerrietts] > ... > Rational numbers are tracked as a numerator and denominator, nothing > more complicated than that. The danger with rational numbers is that > they require a lot of storage space, and that the integers involved > sometimes get really, really big. They *can*, and that can make them as surprising to newbies as anything else. OTOH, sometimes they don't . For example, let's imagine a hypothetical Python using rational arithmetic, and a newbie computing sum = 0 for i in range(1, 101): sum += 1/i It can be very surprising at first that the result is 14466636279520351160221518043104131447711 ----------------------------------------- 2788815009188499086581352357412492142272 In floating-point instead they'd get 5.1873775176396206 and much quicker. OTOH, it may be years before they learn (and perhaps "the hard way") that adding the reciprocals from largest to smallest is numerically worse than adding them in the other direction under f.p. (and whether binary or decimal) -- but it doesn't matter at all under rationals. On the third hand, if you're just adding dollars-and-cents things under a rational system, all the denominators are the same and then nothing "gets real big" under the covers (the denominator of the final result won't be larger than 100). Unfortunately, *all* finite representations of reals suffer surprises, some gross, some subtle. If you have more than one choice, you need some amount of expertise to choose wisely, and no single system is best for all purposes. > I'm told that you can't reasonably limit the size of the integers, > either, because if you do, your accuracy will suffer even worse > than if you'd stuck to floats. Eh -- highly debatable. Much work has been done on so-called "floating slash" (or "flash") systems, but they still have a specialized audience. If there are physical reasons to suspect the true results are relatively simple fractions, they can beat the accuracy pants off of f.p. But for newbies they (IMO) combine the worst of all worlds: exact results in simple cases, but "suddenly and for no reason at all" inexact results creep in without warning. > I guess that means that asking for the answer to exactly the right > question could result in a single absolutely enormous number, and > it could take a very long time to arrive at that number. This was a common newbie experience in ABC (a language Guido worked on before Python, where all arithmetic was rational by default). In "serious work", just as experts need to keep track of worst-case error bounds in f.p. arithmetic, when using rational arithmetic for problems where exact results aren't required, experts need to keep track of worst-case *size* bounds and explicitly round back at appropriate points to keep computation time tractable. a-fast-answer-is-useless-if-it's-wrong-but-an-exact-answer-is-useless- if-you-can't-get-it-by-the-time-it's-needed-ly y'rs - tim From paul at svensson.org Tue Jun 12 11:15:55 2001 From: paul at svensson.org (Paul Svensson) Date: 12 Jun 2001 15:15:55 GMT Subject: Playing with the grammar: part 1, else if Message-ID: <9g5bnb$pg3$1@newsy.ifm.liu.se> While poking around to figure out the Python lexer/parser/grammar all hangs together, I happened on the discussion here about the merits of 'else if' vs 'elif'. Changing it turned out to be much easier than I had expected, so now you can try for yourself which one you like better. Apply this patch to your Python 1.2, and it will understand both. /Paul ------------------------------------------------------------------------------ diff -r -c Python-2.1/Grammar/Grammar Python-2.1-UNRESERVED/Grammar/Grammar *** Python-2.1/Grammar/Grammar Tue Feb 27 13:36:14 2001 --- Python-2.1-UNRESERVED/Grammar/Grammar Fri Jun 8 12:20:47 2001 *************** *** 57,63 **** assert_stmt: 'assert' test [',' test] compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef ! if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] while_stmt: 'while' test ':' suite ['else' ':' suite] for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] try_stmt: ('try' ':' suite (except_clause ':' suite)+ #diagram:break --- 57,63 ---- assert_stmt: 'assert' test [',' test] compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef ! if_stmt: 'if' test ':' suite (('elif' | 'else' 'if') test ':' suite)* ['else' ':' suite] while_stmt: 'while' test ':' suite ['else' ':' suite] for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] try_stmt: ('try' ':' suite (except_clause ':' suite)+ #diagram:break diff -r -c Python-2.1/Modules/parsermodule.c Python-2.1-UNRESERVED/Modules/parsermodule.c *** Python-2.1/Modules/parsermodule.c Sun Jan 7 00:59:59 2001 --- Python-2.1-UNRESERVED/Modules/parsermodule.c Thu Jun 7 12:34:22 2001 *************** *** 937,983 **** } /* if_stmt: ! * 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] */ static int validate_if(node *tree) { int nch = NCH(tree); int res = (validate_ntype(tree, if_stmt) && (nch >= 4) && validate_name(CHILD(tree, 0), "if") - && validate_test(CHILD(tree, 1)) && validate_colon(CHILD(tree, 2)) && validate_suite(CHILD(tree, 3))); ! if (res && ((nch % 4) == 3)) { /* ... 'else' ':' suite */ ! res = (validate_name(CHILD(tree, nch - 3), "else") && validate_colon(CHILD(tree, nch - 2)) && validate_suite(CHILD(tree, nch - 1))); nch -= 3; } ! else if (!res && !PyErr_Occurred()) (void) validate_numnodes(tree, 4, "if"); ! if ((nch % 4) != 0) ! /* Will catch the case for nch < 4 */ ! res = validate_numnodes(tree, 0, "if"); else if (res && (nch > 4)) { ! /* ... ('elif' test ':' suite)+ ... */ ! int j = 4; ! while ((j < nch) && res) { ! res = (validate_name(CHILD(tree, j), "elif") ! && validate_colon(CHILD(tree, j + 2)) ! && validate_test(CHILD(tree, j + 1)) ! && validate_suite(CHILD(tree, j + 3))); ! j += 4; } } return (res); } /* parameters: * '(' [varargslist] ')' * --- 937,1007 ---- } + /* if_stmt: ! * 'if' test ':' suite (('elif' | 'else' 'if') test ':' suite)* ['else' ':' suite] */ static int validate_if(node *tree) { + int j = 0; int nch = NCH(tree); + node *last_else = nch > 4 ? CHILD(tree, nch - 3) : NULL; int res = (validate_ntype(tree, if_stmt) && (nch >= 4) && validate_name(CHILD(tree, 0), "if") && validate_colon(CHILD(tree, 2)) + && validate_test(CHILD(tree, 1)) && validate_suite(CHILD(tree, 3))); ! if (res && last_else && TYPE(last_else) == NAME ! && STR(last_else) == "else") { /* ... 'else' ':' suite */ ! res = (validate_name(last_else, "else") && validate_colon(CHILD(tree, nch - 2)) && validate_suite(CHILD(tree, nch - 1))); nch -= 3; } ! else if (!res && !PyErr_Occurred()) { (void) validate_numnodes(tree, 4, "if"); ! } else if (res && (nch > 4)) { ! /* ... (('elif' | 'else' 'if') test ':' suite)+ ... */ ! j = 4; ! while (res && j < nch) { ! res = validate_ntype(CHILD(tree, j), NAME); ! if (!res) ! break; ! if (strcmp(STR(CHILD(tree, j)), "else") == 0) { ! if (j > nch - 5) ! break; ! res = (validate_name(CHILD(tree, j), "else") ! && validate_name(CHILD(tree, j + 1), "if") ! && validate_colon(CHILD(tree, j + 3)) ! && validate_test(CHILD(tree, j + 2)) ! && validate_suite(CHILD(tree, j + 4))); ! j += 5; ! } ! else { ! if (j > nch - 4) ! break; ! res = (validate_name(CHILD(tree, j), "elif") ! && validate_colon(CHILD(tree, j + 2)) ! && validate_test(CHILD(tree, j + 1)) ! && validate_suite(CHILD(tree, j + 3))); ! j += 4; ! } } } + if (res && j != nch) { + /* Will catch the case for nch < 4 */ + res = validate_numnodes(tree, 0, "if"); + } return (res); } + /* parameters: * '(' [varargslist] ')' * diff -r -c Python-2.1/Python/compile.c Python-2.1-UNRESERVED/Python/compile.c *** Python-2.1/Python/compile.c Sat Apr 14 13:51:48 2001 --- Python-2.1-UNRESERVED/Python/compile.c Thu Jun 7 14:00:39 2001 *************** *** 2813,2825 **** static void com_if_stmt(struct compiling *c, node *n) { ! int i; int anchor = 0; REQ(n, if_stmt); ! /*'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] */ for (i = 0; i+3 < NCH(n); i+=4) { ! int a = 0; ! node *ch = CHILD(n, i+1); if (is_constant_false(c, ch)) continue; if (i > 0) --- 2812,2830 ---- static void com_if_stmt(struct compiling *c, node *n) { ! int i, a; int anchor = 0; + node *ch; REQ(n, if_stmt); ! /*'if' test ':' suite (('elif' | 'else' 'if') test ':' suite)* ['else' ':' suite] */ for (i = 0; i+3 < NCH(n); i+=4) { ! a = 0; ! if (TYPE(CHILD(n, i+3)) == COLON) { ! i++; ! if (i+3 >= NCH(n)) ! break; ! } ! ch = CHILD(n, i+1); if (is_constant_false(c, ch)) continue; if (i > 0) From shalehperry at home.com Sat Jun 9 02:18:38 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Fri, 08 Jun 2001 23:18:38 -0700 (PDT) Subject: is c faster? In-Reply-To: Message-ID: On 09-Jun-2001 akhar wrote: > I have a script I wrote in python , I love the time it took me to devellop > it faster than i could have done it in C. however after full review of my > code I am not sure I can optimize it any more( it basicaly consist of > importing an image and tranforming into a matrix to perform some for-looped > operations on it) : I went from 20 seconds to 2. I can't seem to bring the > execution time down :( . would C code be faster? by what factor? can I > optimise my code more? how? > the C version COULD be faster. However, have you tried some of the python imaging libs? Many of them are implemented in C. Another option is to put the heavy computation in C, wrap it with your existing python and get the best of both worlds. From aleaxit at yahoo.com Fri Jun 29 08:43:47 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 29 Jun 2001 14:43:47 +0200 Subject: PEP scepticism References: <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> Message-ID: <9hht6a01bqn@enews2.newsguy.com> "Bernhard Reiter" wrote in message news:9hfqb5$dsllb$3 at ID-89274.news.dfncis.de... ... > But as Dennis Ritchie said about the C99 standard commitee: > "I wish they had resisted more firmly." > http://www.itworld.com/Comp/3380/lw-12-ritchie/ ...but as Ritchie ALSO said in the very same interview...: """ What is changing is that higher-level languages are becoming much more important as the number of computer-involved people increases. Things that began as neat but small tools, like Perl or Python, say, are suddenly more central in the whole scheme of things. ... higher-level ways of instructing machines will continue to occupy more of the center of the stage. """ *Higher-level ways of instructing machines* include list comprehensions as compared to fully-written-out-loops, generators as compared to laborious saving of state, etc. I read Ritchie as saying he wished C could remain C (though he does admit that some evolution is absolutely inevitable, and refuses to second-guess the C99's committee work, having chosen not to participate in it), but also that, while C has its niches (and they'll remain!), the "higher-level" way of like *has JUST begun* and has a way to go towards "occupying more of the center of the stage" Simplicity is an important Pythonic value, as it was (and to some extent still is) for C (albeit for different reasons and with different slant) -- Python must not become Perl, just like C must not become C++. As Python *sheds* unused features (xrange's deadweight parts, etc -- and maybe one day those parts of the standard library that are little-used and specific to peculiar platforms), it can hardly be accused of not keeping simplicity firmly in its sights. But that simplicity must not be pursued at the cost of "the higher-level ways" of doing things. Now *THAT* would be language suicide by inaction!-) Alex From heikowu at ceosg.de Fri Jun 29 10:23:29 2001 From: heikowu at ceosg.de (Heiko Wundram) Date: Fri, 29 Jun 2001 16:23:29 +0200 Subject: zope en cmf References: <9hhfdh$5odi$1@reader02.wxs.nl> Message-ID: <9hi2t7$58a$06$1@news.t-online.com> Lk wrote on Fri, 29 Jun 2001 10:48:43 +0200: (<--- use your real name for posts on USENET!) Hey, > Ben er niet zeker van of dit de goede groep is indien niet wie wil me > verder brengen? Dit is niet de goeie groep om naar Zope en CMS te vraagen, het is allen maar en Python (dat is de programeer-taal waarin ZOPE geschreven is) groep, en nederlandse posts kunnen ook niet vele mensen die hier schrijven verstaan. Ga beter naar www.zope.org, daar zouden ze een Mailinglist hebben. Daar moet je subscriben, en dan kan je je vraag stellen, en je krijgt dan ook zeker antwoord. Mischien hebben ze ook een forum. Maar ze zijn zeker allemaal in engels. Hope this helps! (And sorry for my Dutch, haven't spoken it for the last five years ;)) Heiko W. From new_name at mit.edu Sun Jun 17 13:04:50 2001 From: new_name at mit.edu (Alex) Date: 17 Jun 2001 13:04:50 -0400 Subject: Data Structure Question References: <20010617.090337.1987231011.7258@behemoth.miketec.com> Message-ID: If you're storing hashable objects in your dictionary, you could try something like this: from UserDict import UserDict class MultiDict(UserDict): def __setitem__(self, key, value): l = self.data[key] = self.data.get(key, {}) l[value] = None d = MultiDict() d['key'] = 'value1' d['key'] = 'value2' d['key'] = 'value1' assert d['key'] == {'value1': None, 'value2': None} HTH Alex. From graham at coms.com Sun Jun 24 13:06:04 2001 From: graham at coms.com (Graham Ashton) Date: Sun, 24 Jun 2001 18:06:04 +0100 Subject: Wrapping text? Message-ID: <06pZ6.1489$h45.9652@news.uk.colt.net> I've got XML files that define the contents of emails, that look a bit like this: Blah blah blah Lots more of the same, ... This bit is indented. ... blah blah blah. When I parse it with xml.sax I get the same indentation, so that my body variable starts with a new line and then 4 spaces. What I'd like is to be able to chop the white space off the front of each line, but not so much that the indented line in the middle of the body doesn't lose it's indentation. The only idea I've had so far is to write my startElement() method so that it keeps track of indentation and doesn't store the leading whitespace where I don't want it to. I'm sure I could do that bit (though I'm hoping that there's a much easier way), but what about wrapping the resulting text so that it's 76 cols wide? (I've no control over the width of the paragraphs that are entered by users). Thanks. -- Graham From graham at coms.com Wed Jun 20 05:43:14 2001 From: graham at coms.com (Graham Ashton) Date: Wed, 20 Jun 2001 10:43:14 +0100 Subject: Class destructors Message-ID: I understand that Python doesn't have the equivalent of the DESTROY() method in Perl, as the tutorial says: "There are no special constructors or destructors." Surely there is a way of executing some code before the garbage collector destroys the object though? Can anybody give me some pointers? Specifically, I want to close a socket when I've finished with my object without having to do so explicitly from with the program that uses the object. Thanks. -- Graham From pecora at anvil.nrl.navy.mil Wed Jun 6 08:17:48 2001 From: pecora at anvil.nrl.navy.mil (Louis M. Pecora) Date: Wed, 06 Jun 2001 12:17:48 GMT Subject: How do you develop in Python? References: <050620011516094693%pecora@anvil.nrl.navy.mil> <3B1D4916.8F572A51@letterror.com> Message-ID: <060620010819553923%pecora@anvil.nrl.navy.mil> In article <3B1D4916.8F572A51 at letterror.com>, Just van Rossum wrote: > Lou Pecora wrote: > > > > I program in Python occassionally and would like to do more of it. But > > here's a development conundrum I run into a lot (there are more complex > > examples, but I'll give an easy one). I am developing module A.py > > which imports B.py in the IDE. I am running test code which is also in > > A.py as I incrementally develop A.py. Then I need to change B.py and, > > of course, the import does not import the new changes since import only > > works once. Hence, to "refresh" B.py I have to quit the IDE and > > restart, open A.py and run. This is clumsy. However, the above > > scenario is not uncommon and more complex interdependencies of modules > > appear to make it unavoidable. Anyone know a way to get around this > > "import" problem? I know there is a "reload", but then I have to > > import and change my modules' code to "reload" or something each time I > > work with them. Any help appreciated. > > > > I use Python on a Macintosh. Nice IDE, otherwise. > > It's simple: if you modify B.py, _run_ B.py to refresh it (*). A.py will see > the changes. It's hardly ever neccesary to quit the MacPython IDE. > > *) In other words: if B.py has already been imported, running it it will > execute it in B's old namespace, effectively refreshing it for everybody > to see. > > Just Hi, Just, I see what you're saying. That sounds like a nice easy step for someone like me. :-) Thanks very much for a simple, but very useful pointer. From m.faassen at vet.uu.nl Sun Jun 3 10:08:32 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 3 Jun 2001 14:08:32 GMT Subject: New language References: <9dse3h$7s5$1@wanadoo.fr> <9er0s9$9i2$2@newshost.accu.uu.nl> <9err9a$aq0$1@newshost.accu.uu.nl> <9f10ta$eua$1@newshost.accu.uu.nl> <9f7fep$hb8$1@newshost.accu.uu.nl> Message-ID: <9fdgd0$fi2$1@newshost.accu.uu.nl> In comp.object Topmind wrote: [snip] >> I think I did elsewhere. Too heavy in syntax, > The difference is minor between arrays and > tables for a well-tuned table API. I was talking about the difference between tuples and dictionaries, not arrays and tables. > I will usually take the slightly-more up-front syntax in > order to get longer-term adaptability any day. Less syntax sometimes helps you with longer-term adaptibility. This is another tradeoff. As I tried to express before, I use tuples, dictionaries, arrays and tables in different contexts and I don't have to switch between them often. For me, the specialized syntax/semantics help me far more than they harm me. > I already gave an example of where I was burned by > dictionaries about 5 or so messages ago. I'll have to go look it up. >> However, as I said before, it's mostly a syntax issue to me >> [not just speed]. There is >> a case to be made for a kind of tuple-like dictionary, though the >> advantages of that are minimal in my opinion; for anything more complex >> I'd be inclined to use a full-fledged object anyway. > But an object does not give you a full-fledge collection still. > I can view a table while the program is running, for example. > All an object gives you above a basic array is more columns. > http://www.geocities.com/tablizer/collrght.htm And a full fledged table doesn't give me a list of objects still. It goes both ways. Objects can have attached methods and together with polymorphisms this can be exploited. You can of course make an object wrapper above tables to do the same thing, and for scalable apps with lots of data this can obviously be useful, but I frequencly have collections of dozens of objects, not thousands. Doing a decent object wrapper above a table is a lot of work, too, and it often pays to do something simpler. [snip] >> >> I disagree; I think a distinction like this can help sometimes. Look at >> >> Perl and their scalars, which merges things like integers, floats and >> >> strings into 'one thing'. >> >> > I like that approach. It makes the code leaner and cleaner IMO. >> > Less casting, converting, and declaration clutter. It allows >> > you to look at raw business logic instead of diddling with >> > conversions, casting, and bloated declarations. >> >> You're confusing things here; you're confusing the effect of static >> type checking (declarations and casting) with that of having different >> datatypes. In Python, you don't need to declare or cast integers, only >> convert when necessary. You need to convert an integer to a string if you >> want to use integers in a string, for instance. >> >> Because of this, the program stops when you do something silly, instead of >> going on blindly and making a mishmash of your data. > I prefer that the "conversion" be done when comparing. IOW, having > an API that says "compare as numbers" or "compare as strings". I find the conversion doesn't happen that often to make something like that pay for the drawbacks it has (doing 'magical things' by trying to guess what the programmer really meant; what integer value does the string "foo" have? What about "1foo"? What about "foo1"?). I convert things on input only once; this is the more efficient way to do it anyway. Similarily, I convert things to a string on output; I don't mind a little bit of automation there -- everything can be made to have *some* string representation. So I rather like that: "%s" % foo in Python converts foo, whatever it may be, to a string (the %s indicates that). > In my pet language, a comparison might look like: > if x %cta> y > ..... > end if > The "c" means compare as character and the t means trim and > the "a" means compare case-sensative. > Most languages require one to do this: > if trim(uppercase(toString(x))) > trim(uppercase(y)) then ..... > I factor these operations into the middle. Frequently it's quite possible to factor them out before you do the comparison. You also haven't addressed the case where you want to do different things to x than you want to y, right? It's an interesting idea, though. You can of course also simply produce a comparison function which does the same: def cta_greater(a, b): return str(a).upper().strip() > str(b).upper().strip() And then you could just use: if cta_greater(a, b): ... Effectively you could reach your result by going one step further; introducing the ability to use cta_greater as an infix operator instead. >> This is *not* the same argument as that for static type checking however; >> it is important to see the distinction. It's an argument for a light-weight >> dynamically checked type (or interface/protocol) system. >> >> What you seem to be describing as the benefits of the Perl scalar may >> instead be the benefits of the absence of statically checked types. > Perhaps. I still have not got the hang of Python's typing system > approach yet. I don't like types anymore. Types create "hard > to disect binary blobs" in my view. I have grown toward the > Unix philosophy of "every interface between systems should > be ASCII" (Or UNICODE, perhaps) if possible. I now apply this at a > smaller level than just "between systems and applications". > (Accept I evolved it up to tables also. The ultimate > xfer protocol: text and tables.) Starts to sound like XML. :) Python's 'type system' is fairly simple; if you call a method on any object, it just tries to find a method of that name on the object (looking in base classes if available) and if it succeeds it happens. The 'special things' just get translated to such method calls; they're just syntactic sugar: a[i] a.__getitem__(i) str(a) a.__str__() a() a.__call__() a + b a.__add__(a, b) There's a bit of subtlety that's planned to go away soon in that built-in types coded in C are somewhat different from the 'types' you can create by defining a class in Python. The __add__ defined on strings and integers (the built-in variety) refuses to add a string to an integer just like that; instead it raises an exception. You can write your own string or integer classes if you really insist on doing that (presumably by trying to convert the strings to integers), though (though I doubt anybody actually does). >> > A jillion messages >> > are already devoted to that topic, with no "killer proof" >> > on either side. It may be subjective which is the "best". >> > I grew up on strong typing, but have gravitated toward >> > prefering dynamic typing over the years. >> >> Me too. > I should change that to "type-free". I grew up on strong > and explicit typing, but have completely reversed > and wish my language of use was completely type free. So how does the '+' operator deal with adding two integers? Two strings? A string that can't be converted to an integer sensibly to one that can? Two collections? Note that I'm talking the language of types here, but I don't see how to avoid it; not all strings make sensible integers. If it 'all just works', then I'll have to remember a tremendous lot about the + operator, and if I accidentally add the wrong things together my program will happily continue mulching the data and it'll come out wrong (and where did it fail?). Effectively + may have to define n * n operations, where 'n' is a 'category of things' (if we want to avoid the word 'type'). An other alternative similar to this to make + do an implicit conversion of both its operands, say, to integer. Non-integer scalars will be converted to say, 0, if they can't be converted to a sensible integer. Collections will also be converted to integers; lets say it's their size, or 0 as well. The result of + will always be an integer-category scalar. This still needs you to remember the n conversions that + may do, for all 'categories of things', including special casing like strings that may or may not contain integers. The data mulching problem remains as well. Yet another alternative is to make + fail on all categories of things it can't really add. You'll have to use another operator for that. This is in effect Python's or Smalltalk's system; though for 'operator' you should read method. Methods fail whenever the system just doesn't know what to do (the method is not defined on the object you're calling it on). You can see this as a 'typeless' system; in effect types are an abstraction that the language doesn't really have to know about; the language only cares about operations. In this "typeless" system you get some of the effects of a typed system if you want to; I can't add 'foo' to 'bar' if foo and bar don't know how to be added. > My pet language has only one type: a dictionary > array. It is used for *everything* including scalers. > scalers are simply a shortcut for something like: > x = 5 > x.__value__ = 5 // same > (It does not use underscores, but something > equivalent.) You'll have to show more about this for me to make sense of it. Is 5 a dictionary too? If not, not everything's a dictionary; literals evidently aren't. Is 'x' a reference or an actual value? Is assignment polymorphic based on the left hand side, and if so, there must be more than just dictionaries on the left hand side. How does your language know what to do with this? x = y If y is a dictionary, then this could rebind the reference of name 'x' to whatever dictionary is pointing at. However, how would you do this, then? y = 5 x = y > Well, I should say everything except for internal > structures. I'm not sure what you mean by this either. > It is not like Python that way. I > see no real need for that. I would probably use > tables to pull off what others would use the > Python meta language tools for. > My pet language in many ways is similar to Python, > but much more minimalist WRT types and collections. > Python has too many syntax variation IMO. Note that this is in the end mostly syntactic sugar in Python as described before; I won't go into how syntactic sugar can help again, I did that before. >> >> It's funny you should compare tuples with dictionaries and say they >> >> should be conflated; most people complaining about tuples say they're >> >> too much like *lists* (arrays). They're right that they're very much >> >> like lists, >> >> > That too. Roll 'em all up. Requirements change. I hate recoding >> > from lists to touples to dictionaries to tables, etc. >> > Make the interfaces the *same*, and only swap the engine, NOT >> > the interface. >> >> Oh, I'd say make the interfaces different, use the same engine where >> possible. > Why make the interface different? Then you have to overhaul > everything if your collection needs change. (A Meyerian > Continuity sin.) I already said before why I said this type of collection change is not as frequent as you say it is, at least in my programs. I think the tradeoffs way into different directions than you do. > It is not just "minimalism", but anti-sub-typing also. There's no sub-typing here; just things with different interfaces. A single interface for everything simply does not make any sense; you'll have to have different interfaces at some level; if they're not explicit they'll be implicit in use, and that can lead to hackery (trying to use an interface beyond its design constraints) and maintenance problems (due to the hackery and because the reader of the code gets little clues about what you're doing at any particular point with the interface). >> I changed my mind a little about dictionaries; in practice >> they're often used to store lots of homogenous values, not as a kind >> of datatype (in Python, class instances (objects) are used for that). >> >> I think it's a myth that having a universal rolled-into-one collection >> type helps your program deal with change more easily. > Well, I am pushing that "myth" and have no reason to > back down. >> In my Python >> programs, I use lists and tuples and dictionaries and tables in >> rather different places in different idioms. > But do they STAY different? Not always, but usually. The constraints of the average application don't change that radically. Change happens more often if you're whipping up a quick prototype of something that you'll do again in a more robust fashion later, but then the 'throw-away' is planned, and you know it's not going to scale. > I find that collections often need more than what they started > out needing. IS-A collections cannot hop IS-A fences very well. > Perhaps an example would help. Okay; thought I gave you some before, but I'll try: lists: homogenous ordered collections of objects: # going through all the lines in a shortish file and doing something to them f = open(filename) lines = f.readlines() for line in lines: ...some processing here... Lists generally have dozens to thousands of elements, are often thrown away after use and tend to be generated by iteratively using .append() or .extend() to add new elements to the end. The same thing frequently gets done to all elements, such as in a for loop. dictionaries: homogenous unordered keyed collections of objects: # totalling something dict = {} for element in something: dict[element.id] = dict[element.id] + element.get_some_number() Similar to lists, but order is not important or can alternatively be easily derived by sorting the keys. New elements are frequently added by indexing to new keys; deleting occurs occasionally as well. Asking for an object by key happens a lot. Loops are common to do the same thing to all key/value pairs. objects (class instances): heterogenous unordered keyed collection of objects: # setting some attributes a.foo = "a text" a.bar = [1, 2, 3] Each attribute of an object is completely different and treated in a different way. Loops through all attributes are extremely rare. Attributes are often queried for and changed. Order of attributes is unimportant. Just a few attributes, though some may of course be other collections. New attributes are rarely added after initialization. Deletion of attributes is even rarer. tuples: heterogenous ordered collection objects: a, b = foo() Just a few elements, though of course some may be other collections. Each element is different; loops through all elements are infrequent. Elements are rarely added and virtually never removed; the only way to 'add' an element in fact it to create a new tuple. Frequently thrown away after temporary use. tables: homogenous keyed/ordered collection objects: Often very many elements. Access by key is frequent; access by query is frequent. Ordering can often be easily imposed (and internal ordering often exists), and operations to all or subsets of elements are fairly common. Elements are added and removed fairly frequently. Usually persistent. Switching from a heterogenous collection to a homogenous collection is extremely rare. Switching inside the categories is more frequent; while moving from a list to a dictionary and vice versa (ordered to keyed) is relatively infrequent, switching from either to a table is more common as the application needs to scale. Heterogenous collections such as instances can then be mapped to records. Such scalability is often completely unnecessary though, and can hinder by taking a lot of resources and program space/programmer mind. Frequently data structures are temporary, or you know you're not dealing with more than just dozens of objects. >> While it is possible I >> change one into the other on occasion, this is the exception, not the rule. > For what I do, rule. > At least frequent enuf to want to prevent it up front. Yes, this often makes sense. Scalability is important. But in my applications this still leaves very many situations where I know my list isn't going to be that large. >> When such changes do happen so many other changes tend to happen it >> doesn't really matter anymore anyway; the change in collection type is >> probably caused by such a larger change. > I disagree. It might simply be another view of the *same* data, > another new column, etc. One thing about custom business > programming is that many different parts often need the > same data, but with a different view, lookup, join, sort, > etc. I frequently use tables for that kind of thing. But that's not the only thing that happens in my programs. There is user interface code, there are throwaway data structures. > IOW, you never know what or who will need data from > your collection(s). For some collections, yes. But there is a large set of collections used in other contexts, in my programs. >> With a universal collection type you lose some of the benefit of these >> separate idioms (which can help with the readability of the program). > I disagree about readability. When collection needs change, trying > to force a linked list or dictionary into something else makes for > a much larger readibility problem. > Like I said, array syntax may give you a SLIGHT benefit up > front, but the loss down it road more than makes up for > this. Again, depends on what your usage is. >> You >> also may increase errors, as due to the absence of different interfaces >> and idioms you run a higher risk the program will continue after an error >> and mangle your data in unpredictable and hard to track down ways. > I would have to see some examples of this. I think using an array for something you really need heterogenous collection for is an example. a[0] = "foo" a[1] = 2 a[2] = [1, 2, 3] is going to cause no end of confusion. Same for most, though not all, uses of dictionaries in that way. This is also why table records are not tables; a table record is a heterogenous collection. > The "protection" needs > often don't align along the collection type's boundaries > or features. Not allowing dictionaries to be sorted (in place) is > an *arbitrary* limit in my book. Then you don't want to implement your dictionaries using a hash table but some form of tree. Just a side-note. >> Anyway, as I said before, you're in the minimalist camp here, along with >> Smalltalkers (everything's an object with messages) and Lispers (everything's >> a list). > WRT to collections, yes, but not control structures > (IF, loops, etc.) And not with respect to operators either, as we saw before. :) >> I take the position that syntactic sugar can help with idioms, >> which can help with clarity, readability and error detection. > Well, we will just have to agree to disagree. I have used > both approaches, and don't like collection type proliferation > the least bit. All right. We'll agree to disagree. Note that I never said tables suck; tables are cool. I'm interested in seeing a language which tries to push tables further; allow light-weight throwaway tables that do have querying abilities. You may run into some difficulties, however; I've actually tried to use a light-weight table system, called MetaKit, in a Python XML DOM implementation. It turned out to be rather slow still. You may call it my fault, but when I created another backend which used dictionaries and lists, it was faster. :) Still, Metakit was neat and certainly could be the right solution in other circumstances. You may want to look at it for inspiration, or perhaps even to use as a backend for your pet language (does it have a name?). Metakit: http://www.equi4.com/metakit/ >> >> except that they're immutable (like integers and strings >> >> in Python, but unlike lists and dictionaries and instances). Your >> >> desire to conflate them with dictionaries is in my opinion wrong as well, >> >> but you're more right than those who want to merge them with lists; >> >> > Show me "wrong". >> >> Wrong as in "I think there are arguments against this which you are missing >> and I disagree with your evaluation of the tradeoffs". This is a >> subjective issue. I imagine you can do empirical research about programming >> language effectiveness and these issues, but I'm not going to do it. >> Are you? > Nope. I won't challenge any agreement that it is subjective. I > should be happy enough that you agree it is likely subjective. This is > a lot more than I often get out of the pro-OO camp. Of course since it's *my* subjective impression I think it's important, just like you think yours is. Like you, I think others may benefit from my impression. :) > I just wish the industry would realize this and knock it off > with the one-paradigm/language-fits all scenario, such as the > Java-tization of everything. Me too. It just seems to be industry; there seems to be a longing for 'magic pixie dust' you just sprinkle over your problems in IT and it'll solve everything. Java, XML, OO, open source, structured programming, 4GL languages, whatever is the hype of the moment. All can be good tools and you can learn something from them (if even how not to do it :); but there simply is no silver bullet, as it'll always be a question of tradeoffs, which will be different in each new context. >> >> tuples are generally used as 'records' (heterogenous objects) and not >> >> as lists of homogenous objects. >> >> > Doesn't matter. Needs change. See above. Homo today, hetero tomorrow. >> > Micheal Jackson Collections, you could say. >> >> Heterogenous collections are not going to change into homogenous collection >> and vice versa in by far the most circumstances. If you disagree, you >> should name some cases; I can't think of any. > You would have to leave an actual example because "heterogenous" may > depend on how one classifies the world in their head. Okay, see examples higher up. To be short; a heterogenous collection rarely has the same thing done to all elements; all elements are created and treated *differently*, while a homogenous collection usually has all elements created and treated in the same way. [snip] > It would be interesting to see some of your designs. Hm, it's mostly a bunch of idioms I and other python programmers use in our code. I can't think of any good source code to show you that would make much sense in isolation from the framework in which it is used... I'll try to think of something. [reference parameters versus returning multiple things in a tuple] >> > But harder than looking at the top. >> >> Yes, but the problem already exists in any dynamically typed language >> where any kind of heterogenous collection can be returned, and you said >> you prefer dynamic typing. It doesn't add to the problem therefore; >> it's just as hard if you're returning a record or dictionary. The >> advantage of tuples is that they can be instantly unpacked after the >> function call. > Another point where a specific example might be helpful. > You argument has "when X happens..." arguments in them, > and the way I code/design, X may not happen very often. Well, imagine you have a function which returns a year, a month and a day. Using by reference parameter in some imaginary language, it could look like this: def current_datetime(&ref_year, &ref_month, &ref_day): ... calculate year/month/day ... ref_year = year ref_month = month ref_day = day You use it like this: year = None month = None day = None current_datetime(year, month, day) print year, month, day But, almost certainly, if this language is dynamically typed, you can instead do something like this: def current_datetime(): ... calculate year/month/day ... return { 'year': year, 'month': month, 'day': day } result = current_datetime() print result['year'], result['month'], result['day'] I myself would be inclined to do this, as it's less verbose and more clear. If you do that, you'll have to look at the result type anyway, which was your objection to the even less verbose use of tuples: def current_datetime(): return year, month, day year, month, day = current_datetime() print year, month, day [snip] >> > Having to also check return statements is a two-stop deal. >> > (I don't end up looking at return statements very often.) >> >> The other deal is that I don't have to go look up the function definition >> each time I see a function call I don't know about, just in case this may >> involve reference parameters! That's a huge deal in my opinion. :) > I guess the naming conventions I use for routines is the > primary indicator as to whether it is mostly changing > or using info. I tend to use prefixes like "put" or > "change" or "move" to indicate that a lot of changing > is going on. Makes sense. Anyway, it still seems more unwieldy to me, but let's just quit this argument too. :) [snip] > To say that "math didn't do it" is misleading IMO. What is good > for math may not be good for programming. No, of course not. But I still can make my case that output parameters were a hack introduced to be able to return multiple values by saying originally languages didn't have them (and many still don't). >> (and of course in Python you can mutate mutable objects passed to a function and >> *any* variable in Python is a reference. But it's better style to avoid >> mutating input if possible, in my opinion. It encourages more independent >> functions which makes for easier to maintain and debug code). > Yip. Complex things passed in are alterable anyhow. For example, > it makes more sense to change a large array *in place* rather > than make a copy and pass it back out. If the array is expected to be large, yes. I usually prefer generating a new array, though. > Thus, you have *two* param changing > conventions floating around in Python. Not exactly; it's just that all variables are references in Python. If I pass in immutable references (integers, strings, tuples), or simply choose not to mutate the references, it's fine. That's different somewhat from pass-by-reference, which would allow me to do this: a = 1 foo(a) print a # prints 2 That's impossible. It's impossible to make 'a' point to any other object than the one you passed in, though you may change the object. If you call it another param changing convention, then allowing this behavior would give the language *three* conventions. :) [snip] [snip] >> > I meant industry domains, like business versus embedded systems versus >> > scientific computing, etc. I don't do a lot of X, Y coordinate work, BTW. >> >> European example for the industry domain is a 'year/weeknumber' tuple. >> In Europe industry often works with (ISO) weeknumbers. To calculate >> weeknumers back to a date (beginning of the week), you need the year as well, >> so it can make sense to pass these around as pairs in ones application. > I prefer to pass dates around as single strings. Formatting it for > different countries is a formatting (output) issue and not an internal > issue. IOW, the internal representation and the external do not > have to be the same. Of course; but I need these functions for input/output issues, right? :) [snip more tuple stuff] > I guess I don't see a significant net value of touples. They > just complicate the syntax and are often used for > stuff that can be done other ways. That's true for most things in programming. Assembler language has a very simple syntax. :) [more tuples] >> I tried to show you how this *is* common stuff. Not swapping variables, >> but collecting a bunch of things together and passing them around as >> a whole, and returning them as a whole, and easily separating them into >> pieces again. It happens frequently in software. > Not in a way that makes much use in touples. Perhaps you use > touples the way that I use relational tables, and that is > why my approach has less use for them. Hm, I don't know how you use relational tables, but I'm hard pressed to think of an example here. :) [snip] >> Yes, a small record can grow into a large one, and you will have to adapt >> some code when it does (in a dynamically typed language, not a lot). >> There are many cases when this just doesn't happen, though; x, y coordinates >> are an example, so are year/weeknumbers, or 'year/month/day' pairs, or >> 'amount/currency_type' pairs, and so on. > Well, I don't use much X and Y coordinates, and would probably > use tables if I did, since such an app probably has lots of them. r/g/b color triplets are another good example. A table can be rather heavy weight if it's a persistent relational one; in graphics applications one doesn't need that. Also, x, y pairs are often calculated, not stored. > Often in table-land you pass around a record ID or record > reference instead of the record contents. Such a > record reference is similar in concept to a touple > of X and Y. Yes, though a bit harder to handle, and likely less efficient once you need to access the fields (though that depends on implementation, I guess). I frequently pass around record IDs as well, and of course everything in a language like Python is a reference *already* so that happens all the time. You're just passing around a reference to the tuple, by the way; the tuple itself stays where it was. It may be in a list or dictionary or wherever. [snip] >> > Performance often only becomes an issue when stupid programmers play with >> > too many features. Thus, reduce the syntax features and you have less >> > playing around with wasteful things and cryptic tricks. >> >> The tradeoff here is that one thing often doesn't fit all. > But most :-) > That is the prestine beauty of tables. They flex like nothing > else I have ever seen in programming. I am trying to spread > the Table Godspel. Mabye we will get our own common language > and widely used buzzwords just like everybody else. Oh no! So in 2010 everybody is using TOP, the Java of its day, and I hang out in comp.table saying how OO works great and you have object databases and so on? :) Anyway, I'd be interested in seeing a language that tries to push the table concept further into the syntax and semantics. It could have some interesting features. In fact many OO languages try to gain such features by doing things like mapping objects onto tables, etc. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From mertz at gnosis.cx Wed Jun 20 15:29:20 2001 From: mertz at gnosis.cx (Dr. David Mertz) Date: Wed, 20 Jun 2001 15:29:20 -0400 Subject: Anyone used Pippy? Message-ID: I am hoping that someone on the Python list will have some experience they would share. I wrote to the Pippy list (message below), but that list seems pretty dead (and my message did not seem to make it there). It would be great to get some feedback either on the Python list, or by email. Yours, David... -------- Forwarded message -------- Date: Tue, 19 Jun 2001 01:08:47 -0400 To: pippy at endeavors.com, pippy-dev at endeavors.com Subject: Help on PalmForm/input methods Hi All, I am fairly new to all things Palm, so excuse any possible naivety. I am also a computer journalist/writer, and am working on an article on Pippy for IBM developerWorks (check out http://ibm.com/developer/ or http://gnosis.cx/publish/ for background on some of my other writing on Python and a little bit on PalmOS). Anyway, what I am hoping to do is a fairly general introduction to Pippy, but with a bit of practical examples of using Pippy. To this end, the release of 0.7 and its memoimp module goes a long way towards an explainable practical use. "Hello world" that is stored in the Memo Pad rather than only interactively entered is still a big gain. That said, being able to print "hello world"--or even to perform something more computationally interesting--is only part of the way to an interesting sample application. The rest of the way is some way to enter data *into* an application. After fumbling for a while, I figured out that input() and raw_input() aren't doing anything because of the lack of the concept of a "file" under PalmOS (I hope I understand things correctly). And I can even make a good guess that palmform is the right module for entering in some data. But beyond that, the documentation I can find is thin, and any actual samples are missing. So my hope here is that someone can point me toward either some documentation of using input under Pippy... or maybe to a few sample applications that folks are using. Something simple would be fine for illustration to my readers (and to me). Something more complicated and useful that I could write about publicly might be even better... especially if it used several input techniques or the like. My main interest, btw. is being able to download and use the actual pre-built executables. I played a bit today with trying to compile Pippy from source.... to no success yet. But I might make it though the Linux library dependency game after a while. Or CodeWarrier might go easier when I try it. But my initial pass is enough to know that I don't want to recommend the effort to casual readers just yet. However, creating a little custom app in Memo Pad is plenty easy enough for readers, assuming I can tell them how to do something useful in that app. Yours, David... -- _/_/_/ THIS MESSAGE WAS BROUGHT TO YOU BY: Postmodern Enterprises _/_/_/ _/_/ ~~~~~~~~~~~~~~~~~~~~[mertz at gnosis.cx]~~~~~~~~~~~~~~~~~~~~~ _/_/ _/_/ The opinions expressed here must be those of my employer... _/_/ _/_/_/_/_/_/_/_/_/_/ Surely you don't think that *I* believe them! _/_/ From michael at trollope.org Sun Jun 24 13:04:48 2001 From: michael at trollope.org (Michael Powe) Date: 24 Jun 2001 10:04:48 -0700 Subject: emacs speedbar for python mode? References: <9h24tq$f7b$1@news1.xs4all.nl> <9h2o5m$8is$1@news1.xs4all.nl> Message-ID: <87u21524i7.fsf@cecilia.trollope.org> >>>>> "Alex" == Alex writes: Alex> Oh. perhaps it's that I'm using FSF emacs, then. Makes no difference. I use speedbar with emacs and it works fine. It's a godsend for multi-file source. Are you doing `M-x speedbar'? And, of course, you must be in X for it to work correctly (or using NTemacs in Windoze). mp -- Michael Powe Portland, Oregon USA 'Unless we approve your idea, it will not be permitted, it will not be allowed.' -- Hilary Rosen, President, Recording Industry Association of America From djc at object-craft.com.au Tue Jun 26 10:17:07 2001 From: djc at object-craft.com.au (Dave Cole) Date: 27 Jun 2001 00:17:07 +1000 Subject: Sybase module 0.27 released References: Message-ID: >>>>> "Pieter" == Pieter Claerhout writes: Pieter> Does anyone know if this will work for MS SQL Server as well? Pieter> It's a rip-off of Sybase anyway, as far as I remember. It will work for some things but not all - your best bet it to give it a try and report back with the results. Once someone tells me about their success or lack thereof I can document it :-) - Dave -- http://www.object-craft.com.au From DOUGS at oceanic.com Fri Jun 22 21:10:27 2001 From: DOUGS at oceanic.com (Doug Stanfield) Date: Fri, 22 Jun 2001 15:10:27 -1000 Subject: (no subject) Message-ID: <8457258D741DD411BD3D0050DA62365907A8FE@huina.oceanic.com> To prove its possible, here's my interactive session. Some comments are interspersed in yours below: Python 1.5.2 (#1, Apr 18 1999, 16:03:16) [GCC pgcc-2.91.60 19981201 (egcs-1.1.1 on linux2Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> a, b = 0, 1 >>> while b < 1000: ... print b, ... a,b = b, a+b ... 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 >>> [crombie ] > newbie question: > trying to type this in: > >>> a, b = 0, 1 > >>> while b < 1000: > ... print b, > ... a, b = b, a+b > ... > 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 > > > but result is this: > >>> while b< 10 > SyntaxError: invalid syntax > >>> while b < 10: > ... print b > IndentationError: expected an indented block (line 2) > >>> while b < 10: > print b > a, b = b, a+b ... > > SyntaxError: invalid syntax > >>> while b < 1000: > ... print b, > IndentationError: expected an indented block (line 2) > >>> while b < 1000: > ... print b, > > SyntaxError: invalid syntax > >>> > > anyone know why? To me it looks like you might have messed up understanding what is your input versus what is the computer output in the example you're copying. To try to illustrate I'll put square brackets around the output of the interpreter and indicate other key presses by enclosing them in <>. Particularly notice the spaces. I hope its not too confusing: [Python 1.5.2 (#1, Apr 18 1999, 16:03:16) [GCC pgcc-2.91.60 19981201 (egcs-1.1.1 on linux2Copyright ][1991-1995 Stichting Mathematisch Centrum, Amsterdam] [>>> ]a, b = 0, 1 [>>> ]while b < 1000: [... ] print b, [... ] a,b = b, a+b [... ] 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 > much thx, tc > HTH, -Doug- From robin at jessikat.fsnet.co.uk Tue Jun 5 16:06:56 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Tue, 5 Jun 2001 21:06:56 +0100 Subject: Dynamic class problem Message-ID: <9nie+IAgvTH7Ew4A@jessikat.fsnet.co.uk> I'm trying to figure out how to recode a class that is giving a shadow warning under 2.1 the relevant code is def __getitem__(self, index): try: return self._children[index] except KeyError: Klass = self._prototype if Klass in _ItemWrapper.keys(): WKlass = _ItemWrapper[Klass] else: class WKlass(Klass): def __getattr__(self,name): try: return Klass.__getattr__(self,name) except: return getattr(self._parent,name) _ItemWrapper[Klass] = WKlass child = WKlass() child._parent = self for i in filter(lambda x,K=child.__dict__.keys(): x in K,child._attrMap.keys()): del child.__dict__[i] self._children[index] = child return child the idea is that I want to generate a child instance based on the _prototype class which has a single overridden getattr method. This code seemed to be working in 2.0, but I'm getting warnings now c:\python\reportlab\graphics\widgetbase.py:181: SyntaxWarning: local name 'Klass ' in '__getitem__' shadows use of 'Klass' as global in nested scope 'WKlass' def __getitem__(self, index): must I write the inner class as class WKlass(Klass): def __getattr__(self,name): try: return WKlass.__bases__[0].__getattr__(self,name) except: return getattr(self._parent,name) and is that backwards compatible in 2.0? -- Robin Becker From whisper at oz.nospamnet Tue Jun 12 13:42:52 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 12 Jun 2001 17:42:52 GMT Subject: WHY is python slow? References: Message-ID: <9g5kas$ird$4@216.39.170.247> In article , kamikaze at kuoi.asui.uidaho.edu says... > Fri, 8 Jun 2001 22:42:02 +0100 in > , > John J. Lee spake: > > *Are* there any good (as opposed to 'good enough') operating systems in > > existence? > > Completely off-topic, I know: just ignore me... > > No. It's been proven that all operating systems suck, all languages > suck, all software sucks, and all hardware sucks. Does this mean that all programmers are suckers? Of course, it's well known that all sys admins suck ;-) > There are degrees of suckiness for any particular purpose, but none > are sans suckage. Programmers will be the first to tell you that they don't suck, their programs don't suck, anything they like or approve of doesn't suck and anything that you like that they don't implies that you suck and more then likely also abuse small furry animals as well. Most programmers will further state that they're sans suckage since they rarely get any ;-) > Once people learn to accept this and abandon their unrealistic beliefs > in *good* software or hardware, they become much more content. Castration works quite well for this too and saves heaps of money spent in persuit of the unobtainable. It also removes the regret one experiences from having sat in front of the computer for 80 hours a week for the last 5 years instead of going in pursuit of the unobtainable. Of course, if one does manage to attract the unobtainable, one will end up poor, grumpy and only really happy if one spends 80 hours per week in front of the computer to avoid the bi... errr.. lovely person who shares your pocketbook. ;-) Tongue firmly in cheek (yes MY cheek ya perv! ;-)), Dave LeBlanc P.S. In our next installment, we'll discuss the implications inherent in programmers who like to play with their Python. ;-) From chrishbarker at home.net Tue Jun 26 15:03:44 2001 From: chrishbarker at home.net (Chris Barker) Date: Tue, 26 Jun 2001 12:03:44 -0700 Subject: newbie with major "lambda" problem (perhaps a scope problem as well) References: Message-ID: <3B38DC90.176CD7FD@home.net> Joe Potter wrote: > >> # the "button" below works like a champ !! > >> #Button(root, text='Fetch', > >> #command=(lambda v=vars: fetch(v))).pack(side=LEFT) > >> > >> # the "button" below does not do anything ?????? > >> Button(root, text='Fetch', command=(fetch(vars))).pack(side=LEFT) > My question is *why* the lambda is allowed to call the perfectly defined function > fetch, but a direct call of fetch is not. Rainer tried, but I'll use more words and see if that makes it clearer. > In the 6 or 7 other languages I have used over time --- if you call a defined > function it works --- but in Python there is a mystery here. yes, if you call a defined function it works, the question is when is the function called? In your version, the "fetch" function is called when this code is run, so command gets set to the result of calling fetch(vars), using the value of vars at that time. fetch returns nothing, so you get comamnd set to None. What you want is for command to be set to a function, not the result of the function. What lambda does is create a function without giving it a name. You could also have done: def command_fun(v = vars): return fetch(v) Button(root, text='Fetch',command=command_fun).pack(side=LEFT) > Or, perhaps the mystery is deep down in Tkinter? Sort of. When the button is pressed, the function that command is set to is called. So why can't you do?: Button(root, text='Fetch',command=fetch).pack(side=LEFT) Because when the button is pressed, no parameters will be passed to the command function, and fetch needs a list of variable to be passed in. That's what the default parameter assignment does: my command_fun (or the lambda function) does not need to have any parameters passed to it, it will assign v to vars, and then pass that in to fetch. I'm not sure I made this very clear, but I tried -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From scarblac at pino.selwerd.nl Fri Jun 8 01:20:32 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 8 Jun 2001 05:20:32 GMT Subject: random References: <3b1cf00f.5441109@nntp.sprynet.com> <3b1e4957.3040319@nntp.sprynet.com> <9flkqc01nfp@enews2.newsguy.com> <3b1f97ca.4530449@nntp.sprynet.com> <9fo9k50gl6@enews2.newsguy.com> Message-ID: Alex Martelli wrote in comp.lang.python: > I did find a different definition from the Stanford one, > that did include the condition "there can be only finitely > many non-blank squares on the tape" (presumably, although > that wasn't clear to me from that definition, this means > at the START of a run -- if the machine doesn't halt it > may still be allowed to fill the tape with infinitely many > non-blank squares eventually -- but I did not see this > stated unambiguously one way or another). Not all the > definitions I've found strewn around include this > provision, and it does make a huge difference of course. No matter how long you let it run, there will always be a finite amount of non-blank squares. The number may grow larger than any N you want to name, but it'll never be infinite (I wonder what the last step would look like, right before it becomes infinite). -- Remco Gerlich From ctavares at develop.com Wed Jun 20 23:10:51 2001 From: ctavares at develop.com (Chris Tavares) Date: Thu, 21 Jun 2001 03:10:51 GMT Subject: Aargh! Function takes exactly x arguments, y given.. References: <9gkrud$pru$1@news.inet.tele.dk> <3B2E1C02.109197B5@alcyone.com> <3b2f3759.467766@nntp.sprynet.com> Message-ID: <%AdY6.24501$Kq4.2305781@newsread2.prod.itd.earthlink.net> "David C. Ullrich" wrote in message news:3b2f3759.467766 at nntp.sprynet.com... > On Mon, 18 Jun 2001 08:19:30 -0700, Erik Max Francis > wrote: > > >Anders And wrote: > > > >> I am a happy pythoneer using a combination of C++ and Python for my > >> everyday > >> work. > >> Usually, debugging is easy but every now and then, I get the "function > >> takes > >> exactly x arguments, y given" error message, clearly due to some other > >> problem than what Python thinks. Does anybody have any experience with > >> this > >> particular error message? I don't know what triggers it and thinking > >> back, I > >> think I have solved most of my problems with this message with a major > >> code > >> rewrite. > > > >The error means just what it says: You are calling a function with too > >many or too few arguments. Why you're doing that exactly is something > >we couldn't tell you without code examples that actually give you the > >error. > > > >Only thing I can think of is that you've got a confusion with bound and > >unbound methods; if you call an unbound method (C.f where C is a class > >and f is a method), then you need to provide an instance of C as the > >first method (the implicit self method becomes explicit). > > Or he's not calling the function that he thinks he is, possibly > because of an "import *". > > (I refrained from guessing at first cuz I didn't want to leave > anything out. Is there a natural third possibility?) > The problem I still hit quite often is this: class Foo: def MyMethod( x, y ): pass foo = Foo() foo.MyMethod(1, 2) Boom! Called with three args, expected two. -Chris From hamish_lawson at yahoo.co.uk Mon Jun 25 18:32:24 2001 From: hamish_lawson at yahoo.co.uk (=?iso-8859-1?q?Hamish=20Lawson?=) Date: Mon, 25 Jun 2001 23:32:24 +0100 (BST) Subject: Here's how to get time.strptime on Windows Message-ID: <20010625223224.73212.qmail@web11006.mail.yahoo.com> [Reposted with clarified subject line. Original was perhaps ambiguous about whether it was offering or asking for information. Sorry about the duplication.] On various occasions people who have missed having the time.strptime function on Windows have been referred to a Python implementation by Andy Markebo that is available at http://www.fukt.hk-r.se/~flognat/hacks/strptime.py After installation in a suitable place on the Python path, this is then available as strptime.strptime. However perhaps you would like to be able to refer to it as time.strptime (maybe you have other code that expects to call it as such)? But there's no time.py file to cut and paste the code from strptime.py into. We can, though, make use of the fact that imported modules are mutable objects in Python and so make time.strptime be an alias for strptime.strptime: import time, strptime time.strptime = strptime.strptime del strptime You can even have this aliasing done automatically by putting the above code in a file sitecustomize.py on the Python path; the Python interpreter automatically tries to import this module when it starts up. Thus: Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> from time import strptime >>> strptime('2001-07-8', '%Y-%m-%d') (2001, 7, 8, 0, 0, 0, 0, 0, 0) Hamish Lawson ____________________________________________________________ Do You Yahoo!? Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk or your free @yahoo.ie address at http://mail.yahoo.ie From greg at cosc.canterbury.ac.nz Tue Jun 26 23:20:13 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 27 Jun 2001 15:20:13 +1200 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) References: Message-ID: <3B3950ED.8002AF8@cosc.canterbury.ac.nz> Tim Peters wrote: > > We didn't *have* to expose Python's generator-iterator object > either Out of curiosity, what would a Python generator implementation look like that didn't expose generator-iterators? What would happen if you called a generator outside of a for-loop context? -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From gmcm at hypernet.com Mon Jun 18 09:51:01 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 18 Jun 2001 13:51:01 GMT Subject: Loading select queries into objects References: Message-ID: <90C466E0Dgmcmhypernetcom@199.171.54.194> Graham Ashton wrote: > self.column1(tup[0]) # this could be better! > self.column2(tup[1]) > self.some_column(tup[2]) self.column1, self.column2, self.some_column = tup - Gordon From nperkins7 at home.com Sun Jun 3 21:02:42 2001 From: nperkins7 at home.com (Nick Perkins) Date: Mon, 04 Jun 2001 01:02:42 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3B183CFF.A90213BA@san.rr.com> <9fa54s0fkb@enews2.newsguy.com> <3B1A7FEB.E466824E@san.rr.com> <9fe5q302hbg@enews2.newsguy.com> Message-ID: ...fascinating discussion gentlemen! (for the most part) I thought I might try to pin down exactly what people here agree on, and what they dont. I suggest the following eleven statements, and invite others to say whether each is True or False... ( phrased such that I beleive each is True ) 0. 'Perfect Randomness' is a well-defined concept. 1. 'Perfect Randomness' is attainable with a suitable physical RNG, eg. one that measures some quantum-level effect, such as radioactive decay. 2. There is a continuum of 'degrees of randomness', ranging from the trivially predictable to the very hard to predict. (and up to infinity?) 3. For any useful, practical purpose, there is a degree of randomness that is sufficiently random, even if it is not 'perfectly random'. 4. The result of rolling dice is determined not by any random behaviour of the cubes themselves, but by the unpredictability of the exact muscle movements of the thrower, which are determined by nerve impulses which are controlled by the brain. Predicting the roll of a dice thus requires knowlege about the state of the throwers mind and body, which can be thought of as a huge program.( or perhaps, even unknowable?) 5. Quantum random effects can be amplified to produce a 'macroscopic physical RNG' which exhibits 'perfect randomness'. 5 1/2. A multitude of random quantum effects tend to cancel each other out in a mocroscopic system, resulting in a very close approximation to Newtonian physics, and thereby losing the original randomness of each individual quantum effect. 6. 'Perfect Randomness' can not be produced by an algorithm, or.. 7. 'Perfect Randomness' can be produced by an algorithm, but the algorithm a) would have to be infinitely large b) would never halt 8. The phrase "state of sin" means beleiving that a RNG is perfect, when it is not, and says nothing about the usefullness of a RNG which is sufficiently random for one's purpose. 10. 'Perfect Randomness' is a mathematical curiosity which has no effect on the lives of us mere mortals, for whom 'sufficient randomness' will always be indistinguishable from 'perfect randomness' (hmmm....) 11. There is another point of disagreement, not listed here, which is: _________________ (fill in the blank) From sill at optonline.net Sun Jun 17 04:54:00 2001 From: sill at optonline.net (Rainy) Date: Sun, 17 Jun 2001 08:54:00 GMT Subject: humans and logic References: <9gbuci019gt@drn.newsguy.com> <20010617043302.26506.00001812@ng-xb1.aol.com> Message-ID: On 17 Jun 2001 08:33:02 GMT, Rory Baker wrote: > Humans are naturally illogical. It was illogical to raise a point that so many > people could argue against. It is illogical for me to waste my time pointing > out flaws in an argument that may no longer exist in about a year. But I do it > anyway, because part of myself (the illogical part) compells me to do this. > Yeah, binary *might* be a good mathmatical base to work upon, but there will > always be some dude in the back that won't switch. People have machines to > convert number systems and languages and all this nice stuff so that people > aren't spending days just trying to say 'hi' to one another. There is no > 'ideal' operating system, no 'ideal' language, no 'ideal number system. Even The problem is, even if there were, it's impossible to tell. We don't know everything and we don't know all the laws. So it's kind of like solving one equation with two unknown variables. Then again, even if one did know that using hex is, indeed, better, and he knew it for a fact, he still wouldn't have any way to prove it to the world that converting to it is worth its while. So, this guy comes here and posts (OT!) that 1) using hex is more logical than using dec and 2) implied that we should therefore start using hex and lead some sort of uprising to convert everyone to hex, because 'logic will win out in the end' (which is an oddly mystical kind of statement from a logical don quixote). Both of these points are obviously unprovable. This guy is a nut. > the most "logical" concepts of human thought are flawed. Take, for example, the > concept of negative numbers. Except for financial cases where negative numbers > indicate debt, or graphing, where negative numbers indicate position, negative > numbers have no relavance in a positive universe. I cannot run negative miles. > I cannot go to McDonalds and order the McNegative Cheeseburger with a side of > negitavesize fries, and by paying for this negative meal with negative money, > gain positive money. Then there is the question of dividing by zero. How much > of nothing can you fit in to 1? How much nothing can you cram in to nothing? To > paraphrase "The Hitchhikers Guide To The Galaxy" (Douglas Adams), you could, > for example, have both a cup of tea and no tea at the same time. In one hand, > you have tea, and in the other, you have no tea. To conclude, everybody is > kinda right and kinda wrong on this one. Then again, maybe it's just me. I > don't know. Anyone want to help me out? Anyone? -- Shine on you crazy diamond - Roger From s713221 at student.gu.edu.au Sun Jun 24 01:01:47 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Sun, 24 Jun 2001 15:01:47 +1000 Subject: How useful do you find the interactive interpreter? References: <4688f24b.0106231658.43d2c446@posting.google.com> Message-ID: <3B35743B.8BA99627@student.gu.edu.au> Chad Everett wrote: > > On 23 Jun 2001 17:58:18 -0700, slaytanic killer wrote: > >Hi, > > > >I am looking at Python seriously, and I can see that the interpreter > >would be really good for testing out ideas. Getting small things to > >work and then switching over to a text editor to generalize what I've > >learned. Is this how people generally use it? Or is it an even > >deeper part of coding? > > > >Thanks. For quick tests, the interpreter is handy. But for long blocks of codes involving for/until, if/then, try/except blocks, you may find the Python shell of Idle a more user-friendly environment - plus you can drop your successful attempts straight into a python script. :) -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From dsh8290 at rit.edu Tue Jun 26 13:45:34 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 26 Jun 2001 13:45:34 -0400 Subject: 'with' statement in python ? In-Reply-To: <5.0.2.1.0.20010626103003.02841da0@mail.inet.com.br>; from cribeiro@mail.inet.com.br on Tue, Jun 26, 2001 at 10:41:31AM -0300 References: <3b3875f1.110436929@news.tpi.pl> <5.0.2.1.0.20010626103003.02841da0@mail.inet.com.br> Message-ID: <20010626134534.G16298@harmony.cs.rit.edu> On Tue, Jun 26, 2001 at 10:41:31AM -0300, Carlos Ribeiro wrote: | At 11:49 26/06/01 +0000, Maciej Pilichowski wrote: | >I have just started learning Python yesterday but... | > | > >def with_is_broken(a): | > > with a: | > > print x | > > | > >The snippet above assume that "a" must have a member attribute called "x". | > | >Nope. As you referred to Pascal -- if "a" has a member "x" it is read | >as "a.x", if not it is standalone "x". | | There must be some misunderstanding here. My snippet (incomplete, as I | pointed out) assumed that Python had a "with" keyword, just to show the | kind of problems that arise. In Python, the compiler/interpreter has no way | to tell beforehand if x is a member of a, a local variable, a module level | variable, or a global variable. This ambiguity makes the use of with in | Python impossible. It's not impossible, it would just be a runtime determination. Already for bare names python looks in locals(), then up through the nested scopes (if enabled) and in globals() and __builtin__. It _could_ do the same for instances in the presence of a 'with' statement. After stating that it _could_ be implemented, I think it is a BAD idea because it is just some more magic and can make it really hard to trace through how the code will act. Normally trying to access a member of an instance that doesn't exist is an error and should raise AttributeError. If this sort of Pascal-ish magic is used then more obscure bugs can be introduced. It also makes it hard to tell (like in C++ and Java) whether a variable is local, global, "static", or a part of this instance. | member of "a", then the compiler will recursively search on the outer | namespaces until it finds a definition for "x". If it does not find, it | will stop - it is a fatal error, caught at compile time. This isn't quite as bad as it would be with Python because it is a compile-time message. -D From gustafl at algonet.se Tue Jun 26 05:11:00 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 26 Jun 2001 09:11:00 GMT Subject: Adding unknown variables to time.mktime() Message-ID: I have a problem with time.mktime(): >>> t = ('1999', '02', '12', '01', '34', '12', '', '', '-1') >>> myTime = time.mktime(t) Traceback (most recent call last): File "", line 1, in ? myTime = time.mktime(t) TypeError: an integer is required I have tried integers too, in the touple, but then there's a syntax error, as you can't have empty fields in the touple like that. Ideally, I'd like to be able to give only the 6 first values, since I've never heard of Julian days, and week day is not significant in this case. Regards, Gustaf Liljegren From mertz at gnosis.cx Thu Jun 14 15:10:30 2001 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Thu, 14 Jun 2001 15:10:30 -0400 Subject: New statement proposal for Python (fwd) Message-ID: David LeBlanc wrote: |One thing that bugs me about Python is that there's no really good way to |have named constants so that magic numbers can be avoided. Assigning to a |variable that (should) never changes is not the same (i.e. the "should |never" part). One way to solve the "-should- never change" thing is to use the Xoltar Toolkit's functional module, and its 'Bindings' class. Of course, I happened to have contributed that class to Bryn Keller, so I may be biased... and moreover, I happened to have written an article that, in part, discusses this: ) :-). Here's an example from the article: Listing 2. Python FP session with guarded rebinding ------------------------------------------------------------------------ >>> from functional import * >>> let = Bindings() >>> let.car = lambda lst: lst[0] >>> let.car = lambda lst: lst[2] Traceback (innermost last): File "", line 1, in ? File "d:\tools\functional.py", line 976, in __setattr__ raise BindingError, "Binding '%s' cannot be modified." % name functional.BindingError: Binding 'car' cannot be modified. >>> car(range(10)) 0 An even shorter spelling is: _= Bindings() _.SPAM = 'eggs' myvar = _.SPAM + "more eggs" HTH. Yours, Lulu... From gtcopeland at earthlink.net Mon Jun 25 03:44:42 2001 From: gtcopeland at earthlink.net (Greg Copeland) Date: 25 Jun 2001 02:44:42 -0500 Subject: PEP 255: Simple Generators References: Message-ID: "Tim Peters" writes: > Also none: a generator can yield only to its immediate caller. In that > sense it's no more powerful (or difficult to implement) than call/return. > It can't "remember the state of the call stack", a generator can only > remember its own local state, and it can't yield to any places other than > the places from which it's explicitly called. That's what spares generators > from the implementation headaches of full-blown continuations. > > think-of-'em-as-resumable-functions-ly y'rs - tim > > So what happens when you have two threads calling a generator. I guess they are distinct... Greg From owen at astrono.junkwashington.emu Mon Jun 18 14:32:31 2001 From: owen at astrono.junkwashington.emu (Russell E. Owen) Date: Mon, 18 Jun 2001 11:32:31 -0700 Subject: PEP 255: Simple Generators References: Message-ID: <9glhg7$dlk$1@nntp6.u.washington.edu> In article , "Tim Peters" wrote: >You can view an HTML version of PEP 255 here: > > http://python.sourceforge.net/peps/pep-0255.html ... > > This PEP introduces the concept of generators to Python, as well > as a new statement used in conjunction with them, the "yield" > statement. This sounds like an interesting and really useful proposal. However,a few details are worrisome to me: * A generator looks like a function until you find the "yield" statement inside. I think this will make the code much harder to read. One keyword buried anywhere in a function totally changes its behavior. If a generator acted like a function until it hit "yield", this wouldn't be so bad, but it sounds as if generators have enough significant differences (such as restrictions on and a changed meaning for return) that they are very different beasts. I'd much rather see a declaration up front that this is going to be a generator. E.g. add a new keyword such as "generator". * The unusual use of "return" and the associated restriction of no expression list. What "return" means in a generator is "raise StopIter", not return. I personally really dislike using a keyword for multiple vaguely similar purposes. Look at "static" in C++ for an example of where this can lead. Several proposals come to mind. They are all compatible with each other: 1) Have users explicitly say "raise StopIter" when they mean it. This is my first choice. Sure it's two words, but has the huge advantages of: -- saying exactly what it means -- not cluttering up "return" with multiple meanings -- not having to explain to users why no expression list is allowed on "return" -- it leaves the door open for a Better Way, should one be proposed; meanwhile, no damage has been done 2) Add a keyword, such as "stop". It could always raise StopIter, or raise a new exception Stop in a non-generator and StopIter in a generator. On the plus side, stop might be handy in other contexts. On the minus side, I doubt it's worth the fuss. 3) Have "return" mean exactly what it means now, but also have a generator raise StopIter for the next call following a return. This is a natural meaning for return (and allows an expression list), but has the disadvantage that it doesn't permit one to say "I'm done and have no more data to return". -- Russell From gregj at pobox.com Thu Jun 14 03:14:08 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Thu, 14 Jun 2001 07:14:08 GMT Subject: HREF to same server, different port References: Message-ID: <4vZV6.166230$p33.3509665@news1.sttls1.wa.home.com> Relative HTTP URLs are relative to the host header portion of the URL, so a relative URL can't specify a different scheme, host, or port. You'll have to take the URL apart, change the port number (or add it), and use the resulting absolute URL. -- Greg Jorgensen PDXperts LLC Portland, Oregon, USA gregj at pobox.com "Steve Holden" wrote in message news:OWi6PtJ9AHA.281 at cpmsnbbsa07... > Sorry this is off-topic, but I'm trying to create a relative url to a > different port on the same server (inheriting the server name or address > from the current URL). I've tried //:8081/ and :8081/ and neither works. > > ANyone tell me how? > > regards > Steve > -- > > http://www.holdenweb.com/ > From akhar at videotron.ca Sat Jun 2 14:54:33 2001 From: akhar at videotron.ca (akhar) Date: Sat, 2 Jun 2001 11:54:33 -0700 Subject: QuickCam and python? References: <3dae3r3uzc.fsf@ute.cnri.reston.va.us> Message-ID: SANE in PIL? I haven't seen that mentionned on their web site? Does it do realtime or picture by picture? "Andrew Kuchling" wrote in message news:3dae3r3uzc.fsf at ute.cnri.reston.va.us... > "akhar" writes: > > Is it possible to read direcltly from a quickcam or any other video camera > > from python, and use pil(for example) to stream it? I am still shopping for > > a camera to use for my project if there is one that is better ... > > If you're on a Unix platform, it's possible to use the SANE module in > PIL to read from a QuickCam and get an Image object containing the > data, which can then be saved, manipulated, or whatever. > > If you're on Windows, I have no clue. > > --amk > From eppstein at ics.uci.edu Tue Jun 19 12:15:39 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Tue, 19 Jun 2001 09:15:39 -0700 Subject: Obsolesence of <> (fwd) References: <9f6el30dv5@enews2.newsguy.com> <3B16D681.E12A4554@Lugoj.Com> <9f7pmt029se@enews1.newsguy.com> <3B17D9B9.E3CA8EC8@Lugoj.Com> <9fjgjl$rp0$1@brokaw.wa.com> <3B1D8504.434DA7DD@Lugoj.Com> <9gnsi8$6c9$1@beta.qmw.ac.uk> Message-ID: James Logajan (JamesL at Lugoj.Com) wrote: > : Nicely done! You've worked out how to have your cake and Edith too! Now if I > : can only think of real world situation where <> does what you want and != > : doesn't (since the latter seems to include the former, but note vice versa). > : Any case where an element of a ordered set can be NOT less than AND NOT > : greater than another element and still be NOT EQUAL to it? I'm not a > : mathematician, but do infinities have these properties? Check out Conway's theory of combinatorial games. Any game has a value; if A and B are two game values, then A and B can be equal, A < B, A > B, or "fuzzy" (written "||"). These are mutually exclusive possibilities. Certain game values are numbers (in Conway's Surreal number system, which includes all the familiar real numbers) in which case these comparisons are just the same as the usual numeric comparisons, but of course two numbers are never fuzzy. If a game is positive or negative, one of the two players wins (with perfect play) regardless of who wins first. If it is zero, the second player wins, and if it is fuzzy with respect to zero, the first player wins. Surreal numbers have lots of interesting infinite values, but these are numbers (so not fuzzy) -- the fuzzies are near zero in value. The relevant references are Conway, _On Numbers and Games_, and Berlekamp, Conway, and Guy, _Winning Ways_, both of which are I think finally back in print. What this has to do with Python programming I'm not sure... -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From claird at starbase.neosoft.com Mon Jun 18 17:37:22 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 18 Jun 2001 16:37:22 -0500 Subject: Two more questions, and a comment: Cross-Platform... References: <3B2B60AD.942719AE@earthlink.net> <3B2BF029.14AAF29E@earthlink.net> <170620012336202508%sburr@nospammac.com> Message-ID: In article , I emitted: . . . >The Mac-Python SIG gives false impressions. Here's >what Apple employee and recognized Tk expert Jim >Ingham just told me: > I am still working slowly on a Carbon > port of Tk. I should be able to have > something stable enough that others > can hack on it in a month or two. . . . *I* give false impressions. Jim's an employee of Apple. He's working on a Carbon port. However, he is NOT work- ing on the Carbon port *as* an Apple employee; it's private work, on his own time. I apologize for the confusion I've created. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From paulp at ActiveState.com Wed Jun 20 21:46:01 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Wed, 20 Jun 2001 18:46:01 -0700 Subject: ActivePython 2.1.0 build 211 Message-ID: <3B3151D9.D43659CB@ActiveState.com> ActiveState is pleased to announce ActivePython 2.1.0 build 211. This is an incremental improvement over the first build based on Python 2.1.0 (build 210). Many build 210 users will not need to upgrade. Users of Tk and/or Active Server Pages should upgrade because this release fixes bugs relating to those environments. There are also minor fixes to PythonWin and the win32 extensions. (see below) If you are a new user to Python, this version is designed to make ActivePython the most new-user friendly distribution of Python. It has a new, more integrated help system, and better documentation for new Python programmers. It includes Mark Pilgram's "Dive Into Python" and Josh Cogliati's "Non-Programmers Tutorial For Python". In addition, various forms of extended Python documentation (FAQs, HOWTOs, etc.) have been included. As usual, ActivePython is 100% compatible with the reference implementation of Python. It is designed to be an easier-to-use distribution that supports more platforms than the reference implementation. It comes with: * a rich library of pre-built, pre-installed modules such as Tkinter (and Tk itself, on Windows), the Expat XML Parser and the ZLib compression library. * an integrated repository of downloadable extensions to Python including Numeric, PIL, PyXML and many more. * Red Hat, Debian and Solaris installers for easy package maintenance. * On Windows, support for COM, MFC, ASP, ODBC. * On Windows, the easy-to-use PythonWin IDE. Along with the new-user features, this build fixes various bugs: * mixing resources (text, cursors) in Tk Windows * Tk radiobuttons not displaying * ASP engine not properly registering itself * PythonWin crash on long lines * Bug fixed in makepy for certain "dual" interface objects, and gracefully handle some objects that don't follow the rules. Notably, Lotus Notes * Remove warnings in ActiveX Scripting regarding regsub module, and an unhandled exception in __del__ * Fix overflow errors when using methods that use 64 bit integers, as well as in some security related functions * win32clipboard handles bitmap formats correctly * Fix thread-state errors in some win32gui and win32ui methods, and add win32gui.SendMessageTimeout() * Other minor bug and documentation fixes It also adds some Windows-related features: * New file and session related methods in win32net module * added win32file.GetDiskFreeSpaceEx() to correctly handle large drives * Add new methods to win32print Unfortunately, due to an unforeseen side effect of the MSI packaging scheme, ActivePython Build 210 must be removed before 211 may be installed. Installed extensions and modules will continue to work however. Future versions of ActivePython will upgrade over each other without the uninstall requirement. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From dennis at cobolt.net Sun Jun 3 11:13:43 2001 From: dennis at cobolt.net (Dennis Schoen) Date: Sun, 3 Jun 2001 15:13:43 +0000 Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> <991574786.733151@nntp01.uskonet.com> Message-ID: On Sun, 3 Jun 2001 15:29:01 +0200, Frank Millman wrote: > >> >>Does anyone have any knowledge or experience of UML that they would like to >>share? >> > > > I realise belatedly that, as this question has got nothing to do with > Python, it should not have been posted to this group. My apologies. > > Having said that, can anyone suggest an appropriate news group for this kind > of question. comp.object Ciao Dennis -- "The Idea Is Good But The World Isn't Ready Yet" - Tocotronic (The Hamburg Years - 1998) From geoff at homegain.com Tue Jun 12 21:58:20 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Tue, 12 Jun 2001 18:58:20 -0700 Subject: humans and logic Message-ID: <393D961EA4FCD311B03F00D0B746D65803275E95@HQSXCH01> > From: thinkit [mailto:thinkit8 at lycos.com] > Sent: Tuesday, June 12, 2001 4:36 PM > > nobody INVENTED logic. logic exists outside of > time...anybody can come upon it. > what of the person on the deserted isle who comes up with the > same principles? The debate's still out on that. A good many contemporary philosophers are somewhat of the more chic opinion that all human modes of thought are artifacts of biological necessity or artifacts of language-based communication. The very fact that some decimal items can't be represented effectively in powers of two argues against widespread use. The supremacy of logic is undercut by the very notion that some artifacts of existence, representable by decimal numbers, but not easily representable in terms of powers of two. Move to hex, and you'll talk to machines quite naturally. The machines are only a small part of the world we must teach them to model, however. --- Geoff Gerrietts Software Engineer, HomeGain.com 510-655-0800 x4320 From ocschwar at mit.edu Fri Jun 15 04:54:15 2001 From: ocschwar at mit.edu (Omri Schwarz) Date: 15 Jun 2001 04:54:15 -0400 Subject: WxPython questions. Message-ID: I am teaching myself Python and wxPython (unless you tell me to "get out, get out while you still can" on the latter of the two) and am trying to run the program in the wxPython tutorial: http://www.wxpython.org/tut-part1.php The first example works, but the second gives me these errors when I try to run it interactively (works fine when I save to a file 'foo' and do 'python foo'). (Errors are below.) So my question is, is there a more interactive way to play around with wxPython? __ begin errors from interactive session: [omri at percy-hobbs omri]$ python Python 2.1 (#1, Apr 20 2001, 20:30:42) [GCC 2.95.3 20010315 (release)] on linux2 Type "copyright", "credits" or "license" for more information. >>> from wxPython.wx import * >>> >>> ID_ABOUT = 101 >>> ID_EXIT = 102 >>> >>> class MyFrame(wxFrame): ... def __init__(self, parent, ID, title): ... wxFrame.__init__(self, parent, ID, title, ... wxDefaultPosition, wxSize(200, 150)) ... self.CreateStatusBar() ... self.SetStatusText("This is the statusbar") ... >>> menu = wxMenu() File "", line 1 menu = wxMenu() ^ SyntaxError: invalid syntax >>> menu.Append(ID_ABOUT, "&About", File "", line 1 menu.Append(ID_ABOUT, "&About", ^ SyntaxError: invalid syntax >>> "More information about this program") File "", line 1 "More information about this program") ^ SyntaxError: invalid syntax >>> menu.AppendSeparator() File "", line 1 menu.AppendSeparator() ^ SyntaxError: invalid syntax >>> menu.Append(ID_EXIT, "E&xit", "Terminate the program") File "", line 1 menu.Append(ID_EXIT, "E&xit", "Terminate the program") ^ SyntaxError: invalid syntax >>> >>> menuBar = wxMenuBar() File "", line 1 menuBar = wxMenuBar() ^ SyntaxError: invalid syntax >>> menuBar.Append(menu, "&File"); File "", line 1 menuBar.Append(menu, "&File"); ^ SyntaxError: invalid syntax >>> >>> self.SetMenuBar(menuBar) File "", line 1 self.SetMenuBar(menuBar) ^ SyntaxError: invalid syntax >>> >>> >>> class MyApp(wxApp): ... def OnInit(self): ... frame = MyFrame(NULL, -1, "Hello from wxPython") ... frame.Show(true) self.SetTopWindow(frame) ... return true ... >>> app = MyApp(0) >>> app.MainLoop() >>> -- Omri Schwarz --- ocscwar at mit.edu ('h' before war) Timeless wisdom of biomedical engineering: "Noise is principally due to the presence of the patient." -- R.F. Farr From nospam at nospam.com Sun Jun 24 11:19:46 2001 From: nospam at nospam.com (Bill Rodgers) Date: Sun, 24 Jun 2001 11:19:46 -0400 Subject: Win32GUI Question... References: <9h0eqp$4c6$1@bob.news.rcn.net> <3B353E09.1080909@ActiveState.com> Message-ID: <9h50gp$f7s$1@bob.news.rcn.net> I found it. It looks like exactly what I need. I'll give it a try and let you know how it works out. Thanks, Bill Rodgers "Mark Hammond" wrote in message news:3B353E09.1080909 at ActiveState.com... > > See my post regarding "closing a windows app" just a few days ago. It > demonstrates how to enumerate all top-level windows and get the text of > the window. This can be expanded to enumerate children windows and get > their text, etc. > > Mark. > From emmanuel.astier at winwise.fr Thu Jun 7 11:42:05 2001 From: emmanuel.astier at winwise.fr (Emmanuel Astier) Date: 7 Jun 2001 08:42:05 -0700 Subject: Problem with embedding AND extending with BOOST Message-ID: Hi, I'm quite new to python, and try to extend/embed it (under Windows/VC6) To extend it, I'm using the BOOST python library. But I have a problem whenever I want to import a class and use it. Here's my code : ---------------------------------------------- main.c : ---------------------------------------------- namespace hello { class world { public: world(int) {} ~world() {} int get() const { return 5; } }; size_t length(const int& x) { return x;} } #include // Python requires an exported function called init in every // extension module. This is where we build the module contents. extern "C" #ifdef _WIN32 __declspec(dllexport) #endif void inithello() { try { // create an object representing this extension module boost::python::module_builder hello("hello"); // Create the Python type object for our extension class boost::python::class_builder world_class(hello, "world"); // Add the __init__ function world_class.def(boost::python::constructor()); // Add a regular member function world_class.def(&hello::world::get, "get"); // Add a regular function to the module hello.def(hello::length, "length"); } catch(...) { boost::python::handle_exception(); // Deal with the exception for Python } } void main() { PyObject* modname, * mod, *func, *mdict; long Answer; Py_Initialize(); inithello(); modname = PyString_FromString("Totohello"); mod = PyImport_Import(modname); // Initialisation et verification de Python : if (mod) { Answer = 1; mdict = PyModule_GetDict(mod); func = PyDict_GetItemString(mdict, "MyFunction"); if ( func ) { Answer = 2; if ( PyCallable_Check(func) ) { PyObject* rslt; rslt = PyObject_CallFunction(func, "i", 5); if (rslt) { Answer = PyInt_AsLong(rslt); Py_XDECREF(rslt); } else { PyErr_Print(); Answer = 3; } } } } printf("Answer : %i", Answer ); Py_XDECREF ( mod ); Py_XDECREF(modname); Py_Finalize(); } ---------------------------------------------- Totohello.py : ---------------------------------------------- def ChangeFov(a): from hello import * MyInst = world(2) #print MyInst.get() <- Crash when uncommented ! val = length(5) return 14 + val The linker report 2 errors, one of those is : :\dev\boost\boost_1_22_0\boost\python\detail\extension_class.hpp(225) : warning C4541: 'dynamic_cast' used on polymorphic type 'class boost::python::detail::instance_holder_base' with /GR-; unpredictable behavior may result d:\dev\boost\boost_1_22_0\boost\python\detail\extension_class.hpp(218) : while compiling class-template member function 'class hello::world *__cdecl boost::python::python_extension_class_converters >::non_null_from_python(struct _object *,struct boost::python::type)' and effectively, it crashes in the "non_null_from_python" function... As someone suceeded in extended AND embedding python using BOOST ? Thanks for any help, Emmanuel From robin at jessikat.fsnet.co.uk Fri Jun 8 14:45:57 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 8 Jun 2001 19:45:57 +0100 Subject: nested scopes oddity/BUG Message-ID: When I try to run this script ##################### from __future__ import nested_scopes def gen(B): class W(B): __base=B def __init__(self): B.__init__(self) return W class C: def __init__(self): pass ##################### I get Fatal Python error: non-string found in code slot abnormal program termination this with 2.1 on Win9x. It works fine and dandy if I remove the spurious __base=B -- Robin Becker From tim.one at home.com Thu Jun 7 01:59:37 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 7 Jun 2001 01:59:37 -0400 Subject: Recursive algorithms anyone? In-Reply-To: <1f0uhtgmhb0vlud6pof6i4mctqjdq8l2eu@4ax.com> Message-ID: [Kirby Urner] > How to implement in Python the classic thing of > adding k to every item in a list. Except a list > may contain other lists to arbitary depth? Something you'll probably never do in Python again <0.9 wink>. > I say classic because it's the kind of thing you > do in computer science 101. > > E.g. >>> additem(1,[1,2,[3,4,[5,6]],7]) > [2,3,[4,5,[6,7]],8] > > Here's the Scheme solution: > > (define (additem items k) > (cond ((null? items) null) > ((not (pair? items)) (+ items k)) > (else (cons (additem (car items) k) > (additem (cdr items) k))))) > > > My best Python attempt so far: > > >>> def additem(items, k): > if not type(items) == type([]): return items + k > if len(items)==0: return [] > return [additem(items[0],k)] + additem(items[1:],k) > > >>> additem([[9,8],1,2,3,4,[1,2, [5,6]]],1) > [[10, 9], 2, 3, 4, 5, [2, 3, [6, 7]]] > > But maybe there's a better solution? Depends on what's meant by "better". The Python there isn't idiomatic, as the natural way to process sequences in Python is via a "for" loop, not recursion. So 99 of 100 Pythonistas would first write something like this: from types import ListType def additem(items, k): result = [] for x in items: if type(x) is ListType: result.append(additem(x, k)) else: result.append(x + k) return result "for x in whatever" says "I'm marching over a list" in Python like "(cond ((null? whatever) ...) ((pair? whatever) ...) (else ...))" says "I'm marching over a list" in Scheme. Get used to that, and the Python way puts a lot less strain on your mental pattern-matcher . Exercise: now write a version in each language that modifies the list *in place* instead of constructing a new list. Define beforehand what the desired outcome is for: x = [1, 2] y = [x, x] additem(y, 42) Then do it all over again picking "the other" answer . teasingly y'rs - tim From PoulsenL at capecon.com Tue Jun 5 18:12:27 2001 From: PoulsenL at capecon.com (PoulsenL at capecon.com) Date: Tue, 5 Jun 2001 18:12:27 -0400 Subject: need help inverting DerivVar array (Numpy/Scientific Python Quest ion) Message-ID: I am having trouble inverting an array of DerivVar objects. Here is the code and error: >>> a = Numeric.array([[DerivVar(-2.5,0,1),DerivVar(.45,1,1)],[DerivVar(5.5,2,1),Der ivVar(-4.5,3,1)]]) >>> Numeric.sum(a) array([(3.0, [1, 0, 1]) , (-4.0499999999999998, [0, 1, 0, 1]) ],'O') >>> Numeric.invert(a) Traceback (most recent call last): File "", line 1, in ? AttributeError: DerivVar instance has no attribute '__invert__' Any help would be greatly appreciated. Thanks, Loren Poulsen -------------- next part -------------- An HTML attachment was scrubbed... URL: From janawills at icqmail.com Sat Jun 16 11:16:12 2001 From: janawills at icqmail.com (UNO) Date: Sat, 16 Jun 2001 23:16:12 +0800 Subject: GREAT DISCOVERY!!! Message-ID: <3B2B783C.AAC57BCA@icqmail.com> Have a look at www.drho.com is a live casino with its REAL dealers over video and REAL live games - no more playing against the random number generators or the computer. And from 6 July to 8 July, www.drho.com also offers the internet's first world BlackJack tournament and US$10,000 is waiting you to be won. It's fun to play and easy to win!!! So enjoy your visit to www.drho.com!!! -------------- next part -------------- An HTML attachment was scrubbed... URL: From root at rainerdeyke.com Thu Jun 28 21:39:28 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 29 Jun 2001 01:39:28 GMT Subject: Augmented Assignment (was: Re: PEP scepticism) References: Message-ID: "David Bolen" wrote in message news:uwv5wjepu.fsf at ctwd0143.fitlinxx.com... > I think that if the operation is phrased from the start as an action > undertaken by the source object itself and that the source object's > mutability can affect behavior, that it's not too big of a hurdle. This dual meaning of augmented assignment makes it dangerous: to get reliable behavior, you need to be absolutely sure whether or not your object is mutable before you attempt augmented assignment. I cringe in horror when I think about people intentionally using the dual meaning of augmented assignment. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From db3l at fitlinxx.com Thu Jun 14 18:45:46 2001 From: db3l at fitlinxx.com (David Bolen) Date: 14 Jun 2001 18:45:46 -0400 Subject: VI References: Message-ID: Geoffrey Gerrietts writes: > On the other hand, I use vim religiously now. I can't imagine editing in > anything else. I've used emacs, and it used to drive me absolutely insane > the way 9/10 of what I wanted to do required typing M-x > really-longass-function-name, and how I had to re-bind my keyboard to be > useful on every new machine I worked on. Ah, that's what your .emacs is for... I think mine is probably closing in on 12+ years old now (before that it was Tops-20 Emacs which was a different beast) and aside from tweaks/enhancements when upgrading Emacs it just follows me to each new machine and each new job :-) -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From scarblac at pino.selwerd.nl Tue Jun 5 06:12:50 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 5 Jun 2001 10:12:50 GMT Subject: floating point in 2.0 References: Message-ID: Michael P. Soulier wrote in comp.lang.python: > Greetings people. > > My apologies if this has been covered. And covered again, and again, and again, ... > In Python 1.5.2, I could do this: > > good = (0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0) > > I could then get back exactly this when I output the value of "good". > However, with Python 2.0, I get this: > > >>> good > (0.0, 0.10000000000000001, 0.20000000000000001, 0.29999999999999999, > 0.40000000000000002, 0.5, 0.59999999999999998, 0.69999999999999996, > 0.80000000000000004, 0.90000000000000002, 1.0) > > Now, I'm assuming that this has something to do with the way that Python > 2.0 stores floating-point numbers, but this could get confusing during > debugging. The way they're stored hasn't changed, it's just that 2.0 doesn't lie anymore when writing the repr() of a float. This is how the floats are represented internally, there is no exact binary representation for any of them except 0.5. There is something on it in the FAQ (see inaccurate floating point or something like that), or use Google to find a post about it - about half the posts in recent months were on this subject, it seems :-) -- Remco Gerlich From sholden at holdenweb.com Fri Jun 29 08:28:49 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 29 Jun 2001 08:28:49 -0400 Subject: Augmented Assignement (was: Re: PEP scepticism) References: <6qn16r7i69.fsf@abnoba.intevation.de> Message-ID: "Bernhard Herzog" wrote in message news:6qn16r7i69.fsf at abnoba.intevation.de... > Carsten Geckeler writes: > > > As mentioned above, for tuples the "+=" is completely natural, but not for > > lists. > > Funny, I mostly see it exactly the other way round. += modifies the left > hand side in place, so it's natural for a list, but not for a tuple. > I suppose that depends. Given the following initialization code: lst = [1, 2, 3] tpl = (1, 2, 3) lstx = lst tplx = tpl would you expect the same results from lst += ["extra"] tpl += ("extra", ) and lst = lst + ["extra"] tpl = tpl + ("extra", ) to be the same? In the first case lstx changes (since the value it's bound to has mutated). In the second, it doesn't. In both cases tpl and tplx end up bound to different values, because the immutability of tuples forced the creation of a new object rather than the modification of an existing one.\ > I think the main problem (in as much as there actually is a problem) is > that whether augmented assignment rebinds the left hand side depends on > the type of object, i.e. whether the object implements the appropriate > methods, which is very different from normal assignment which always > rebinds. > This is the feature most likely to cause confusion in beginners, but then one side or the other of this particular equation is always going to be confusing to someone who's not used to working with Python-style name bindings... regards Steve -- http://www.holdenweb.com/ From nhodgson at bigpond.net.au Tue Jun 12 07:22:10 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Tue, 12 Jun 2001 11:22:10 GMT Subject: Rejected Message References: <3B25FA2D.504AAA10@student.gu.edu.au> Message-ID: Joal Heagney: > *laughs* I get the feeling that this was an automated reject. I had to > use the find button on netscape to locate the word(s)/phrase(s). Do I > get a prize? Rejection-bot: > > The attached mail message has been rejected for the following reason: > > > > Body contained word(s)/phrase(s): fuck, shit Will the rejection-bot now get caught in a loop as it sees its own message reflected back with the words it doesn't like? Neil From nperkins7 at home.com Tue Jun 5 17:08:42 2001 From: nperkins7 at home.com (Nick Perkins) Date: Tue, 05 Jun 2001 21:08:42 GMT Subject: PyGame, IDE problems Message-ID: I can not run the example programs from Pygame from within either PythonWin or IDLE. I am running Py 2.1 on NT4. ( They both freeze up ) The examples do run by themselves, (ie not from within an IDE). Also, curiously enough, they do run from within Boa Constructor's editor. Does anyone know why this is so? Does anyone have the same problem, or is it just me? From mertz at gnosis.cx Sun Jun 3 10:54:03 2001 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Sun, 03 Jun 2001 10:54:03 -0400 Subject: random Message-ID: "Alex Martelli" wrote: |"Even given (a powerful army) I could not (defeat Napoleon)". |Do you read this as "having a powerful army IMPLIES I |cannot defeat Napoleon"? This doesn't sound right to me. |Surely it's "NOT (having a powerful army IMPLIES I can |defeat Napoleon)"? Perhaps I should give up, since there me little progress to be made. But conditionals just seems too interesting and subtle to leave to the Boolean logicians. Let's leave all the quanta and Laplacian fantasies aside, and just look at defeating Napolean. (1) Even given (a powerful army) I could not (defeat Napoleon) The very first thing I would claim about this conditional is that there is an important implicature to be noted: (2) Someone claims that (given a powerful army...) The statement only makes sense given the background claim. Really, what (1) says is not firstly -anything- about the comparative truth values of its antecedent and consequent; rather (1) disputes the imagined interlocutor of (2). The next thing I would claim about (1) is that, conversationally, it must be taken as true, or at least -arguably- true. Moreover, the sentence contains a clear negative epistemic attitude towards its antecedent. Among other things, (1) asserts: (3) I do not have a powerful army It provides no new information--and indeed wholly misses the structure of the statement--to launch into an investigation or dispute about whether the speaker of (1) has a powerful army. A stipulation is not a bare fact. The final note I would make is that (1) specifically authorizes consideration of statements with a common consequent with (1). While not affirmatively asserting any such statement is true, it strongly suggests that not every such statement is false. So for example: (4) But given (time to wait out his death) I could (defeat Napolean) should be given consideration as plausible, according to the urging of (1). Needless to say, the material conditional captures little of this... not matter where you want to put the NOT in the affair. Yours, Lulu... From greg at cosc.canterbury.ac.nz Mon Jun 25 23:17:44 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Tue, 26 Jun 2001 15:17:44 +1200 Subject: Defining accessor methods References: Message-ID: <3B37FED8.2DBA3AC2@cosc.canterbury.ac.nz> Graham Ashton wrote: > > I thought of having get_my_attribute() and set_my_attribute() but I don't > really like the idea because it just makes code that uses them more > (unnecessarily) long winded, and the author of the above URL advises > against it (though they don't say why). They're talking about Smalltalk, and in that context it *is* unnecessarily long-winded to include 'get' and 'set' in the method names. What they do suggest, i.e. obj attrname obj attrname: value works well in Smalltalk, and is a standard idiom used throughout the Smalltalk system itself, which is probably why they recommend it. Note that those are two separate methods, with different names (the ':' is part of the method name in Smalltalk). It doesn't imply that translating this idiom to Python requires using a single method with a variable argument list. The convention I would recommend in Python is obj.attrname() obj.set_attrname(value) Since getting attributes tends to be more common than setting them, this isn't unbearably verbose, and I find that having 'set' in the setting method's name helps to make the code read more explicitly. > I've not noticed any use of accessor methods in sample Python code > (i.e. in books/tutorials); do people use them much in Python? I make extensive use of them in the API of my Python GUI project (http://www.cosc.canterbury.ac.nz/~greg/python_gui/). I want the API to be as future-proof as possible, so all publically-visible attributes of my GUI objects are accessed through methods. I use the convention I recommended above, plus a couple of others. One is that the constructors of my objects allow initial values to be given for all its attributes using keyword arguments, so that e.g. b = Button(width = 42, height = 17, text = "Boo!") is equivalent to b = Button() b.set_width(42) b.set_height(17) b.set_text("Boo!") My objects also have a set() method which takes keyword arguments in the same way, so if you want to change a bunch of attributes you can set them all in one go with a statement like b.set(width = 200, text = "Start Spanish Inquisition") These two things help to cut down a lot on the verbosity of using set_xxx methods. I tend not to use accessor methods so much in code which is internal to an application or library. Whether this is a good or bad habit is a matter of judgement. It's a tradeoff between time spent writing and using the accessor methods, and time spent revising the rest of the code when the implementation of an attribute changes. My experience suggests that, for internal code, it's usually easier not to bother with accessor methods until a clear need for them arises. But, as they say, your kilometerage may vary. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From loewis at informatik.hu-berlin.de Sun Jun 17 16:11:23 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: Sun, 17 Jun 2001 22:11:23 +0200 (MEST) Subject: Writing new codecs In-Reply-To: <002d01c0f753$95a8ae60$445d4540@D1XYVL01> (brian@sweetapp.com) References: <002d01c0f753$95a8ae60$445d4540@D1XYVL01> Message-ID: <200106172011.WAA23264@pandora.informatik.hu-berlin.de> > > Personally, I think on systems that offer iconv, the iconv codec > > should be the only one you'd ever need - although the UTF-7 converter > > is supported in gconv only starting with glibc 2.2. > > What is iconv? iconv is a standard Unix function for converting encodings, see http://www.opengroup.org/onlinepubs/7908799/xsh/iconv.h.html http://www.opengroup.org/onlinepubs/7908799/xsh/iconv_open.html http://www.opengroup.org/onlinepubs/7908799/xsh/iconv.html http://www.opengroup.org/onlinepubs/7908799/xsh/iconv_close.html for details. gconv is a GNU implementation of this interface. Regards, Martin From davidw at weblink.com.au Mon Jun 25 19:29:55 2001 From: davidw at weblink.com.au (David White) Date: 25 Jun 2001 16:29:55 -0700 Subject: ActiveX Controls in Python References: Message-ID: <4dfd15be.0106251529.54b71a63@posting.google.com> "Bill Bell" wrote in message news:... > davidw at weblink.com.au (David White) wrote: > > I'm a C++ programmer whose considering using Python to prototype an > > ActiveX control. However, I can't seem to find any samples or > > resources on implementing ActiveX controls in Python. Would anyone be > > able to give me any pointers on how to do it? > > > > Also, the control will have to make heavy use of a grid control, what > > grid controls are available that have Python interfaces? > > David, your message reminded me that Mark Hammond, one of the main, if > not the main expert on this topic wrote, "Python's COM support does not > support fully-fledged controls. The win32comext/axcontrol directory is > the start of work in this direction, and supports many of the interfaces > needed." I googled to find that he wrote that about 6 May (and you > might want to read the rest of that thread). I read the rest of the thread - and it seemed to indicate that extending the support for ax controls wouldn't be *too* difficult. However, I doubt I'd have time to do this. (convincing my boss to give me time to extend Python in win32 when I'm meant to be writing a C++/win32 application would be difficult to say the least!) > I'm curious about what your > control will do. Would it be possible to say? - Bill I can't say too much about it, but basically it's a hierarchial grid, with data being streamed into the grid from a server, and the user being able to analyse and perform calculations on the data. I would likely leave the server-connection bit out of the prototype, and just use canned data. However, I'd want everything else to look as close to possible as the final C++ implementation will be, as the main reason I'm doing the prototype is because my boss has a penchant for requesting whole series of "minor" changes to the user interface that each take a couple of days to implement. I'm really hoping I can do the prototype in Python, because I don't want to even think about touching Visual Basic. David White Programmer WebLink Pty Ltd From urpala at ampeeri.ee.tut.fi Wed Jun 6 12:19:50 2001 From: urpala at ampeeri.ee.tut.fi (Uoti Urpala) Date: 6 Jun 2001 16:19:50 GMT Subject: random References: <3b1cf00f.5441109@nntp.sprynet.com> <3b1e43f4.1661099@nntp.sprynet.com> Message-ID: In article <3b1e43f4.1661099 at nntp.sprynet.com>, David C. Ullrich wrote: >On 5 Jun 2001 16:54:34 GMT, urpala at ampeeri.ee.tut.fi (Uoti Urpala) >wrote: > >>In article <3b1cf00f.5441109 at nntp.sprynet.com>, David C. Ullrich wrote: >>>Indeed the exact value of Omega depends on the details of the >>>encodings. What I'm wondering today is how many of his conclusions >>>also depend on the details of the encoding. >> >>>Suppose I have a syntax where a valid program is precisely >>>a sequence of 0's terminated by a 1. Any such string is a >>>valid program. Does this count as "self-delimiting"? >> >>That probably does count as self-delimiting, but it doesn't fill other >>requirements of the results. The encoding must allow "arbitrary binary >>data" to be included. > >I didn't bother mentioning the semantics before getting straight >whether the syntax counted as "self-delimiting". It is very >easy to design a Turing-complete programming language where >the syntactically valid programs are exactly the bitstrings >consisting of all 0's terminated by a 1. Assunming that >"arbitrary binary data" means only finitely much binary >data that's no problem. > >(It's not going to be an easy programming language to read or >write but a syntax checker is easy...) > >>The proof basically says "you need n bits of >>program to calculate n bits of Omega". This is a strong result if the >>encoding is efficient, but the above encoding needs a lot of bits to >>calculate anything, so in that case the result doesn't say much about >>the associated Omega (and the same proof wouldn't work, since it >>depends on the ability to give an arbitrary program as an argument to >>another with limited overhead). > >What I'm trying to track down is what does make the proof work. >In particular what I'm curious about is whether the requirments >that make the proof of the randomness work are really all that >natural, or whether they were just chosen to make the randomness >come out right in the end... > >I can easily give an argitrary program to another in the silly >0000....1 syntax, but not with limited overhead. (I think.) >Looking through more of Chaitin yesterday it seemed like the >bit about how H((X,Y)) <= H(X) + H(Y) + O(1) was probably >kind of important (the complexity of a program generating the >concatentation of two lists is bounded by the sum of the >complexities, more or less.) > >I should probably either just give up on extracting an >understanding of this or give up and dive into the actual >stuff, as has been suggested. Not really motivated enough >to learn LISP - also I don't care much about results that >are valid for one particular LISP encoding. You know a >place to start that's going to be proving things based >on _assumptions_ about an arbitrary encoding (as opposed >to proving things about a specific encoding, where one >then has to dig in and figure out what aspects of the >encoding are relevant)? > >>Proving the randomness of Omega basically works like this: >>You can create a program that, given the first n bits of Omega, solves >>the halting problem for all programs of size <= n. (Details below) >>If you can calculate the first m bits of Omega with a program of size >>p, you can add a bit of extra code to create a program of size p+e (e >>constant) that solves the halting problem for itself and then does the >>opposite (the standard contradiction for a program solving the halting >>problem for itself). So p+e must be greater than m to avoid a >>contradiction, and a program to calculate the first m bits of Omega >>must have size at least m-e. (You can generalize this to calculating >>_any_ bits of Omega in whatever position - if you can calculate some >>with a short program, you can hardcode the missing ones to get a full >>initial segment). >> >>Solving the halting problem for a program P of size s given the first >>s bits of Omega: >>Calculate lower bounds for Omega (as mentioned in other posts) until >>the first s bits agree with the known bits. Now you have either found >>that program P halts, or you know that it halting would raise the >>lower bound so much that it could no longer match the known bits, so P >>cannot halt. >> >>Exercise: Show that the first bit of Omega whose value is independent >>of ZFC is a 0. > >Obvious nonsense. No wait, not nonsense. Trivial. No, there's a >little error there... Is there a due date? > >>Uoti Urpala > > > >David C. Ullrich >********************* >"Sometimes you can have access violations all the >time and the program still works." (Michael Caracena, >comp.lang.pascal.delphi.misc 5/1/01) From learnpython at hotmail.com Fri Jun 22 02:32:40 2001 From: learnpython at hotmail.com (Learn Python) Date: Fri, 22 Jun 2001 06:32:40 -0000 Subject: How to display all the methods supported by an instance using dir( )..please hel Message-ID: hi all, i'm a begginer in python, This is what i have: class test: def __init__(self): self.data = 100 def func(self): pass if __name__ == '__main__': t = test() dir(t) ==> i want this to list data and func But it does'nt list func :-(. What methods s'd i provide in addition so that dir( ) can recognize func() which happens to be a instance method attribute? I guess this s'd be possible bcos when i say l = [] and then dir(l), i get all the list attributes. I want the same kind of behaviour for my class instance as well. thanks in advance karthik. _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. From njm at rectec.net Sat Jun 23 11:42:29 2001 From: njm at rectec.net (NJM) Date: Sat, 23 Jun 2001 10:42:29 -0500 Subject: Tkinter widget hieght?? Message-ID: I can't seem to find a way to dictate what the height of a widget. Of coarse, width is typically in the options. Where is the height?? From atodd at spam.free.email.com Wed Jun 27 20:36:57 2001 From: atodd at spam.free.email.com (Andy Todd) Date: Thu, 28 Jun 2001 00:36:57 GMT Subject: zodb install problem on Windows References: Message-ID: "Neil Hodgson" wrote in : >Andy Todd: >> A-ha, I almost suspected as much ;-) Thanks very much for the info. >> [snipped] > There is now a package available at: >http://scintilla.sourceforge.net/zodbwin.zip > This includes 4 setup programs that should each be run. There may be > an >installation order required and the README says to install in this order >(the 5th step for ZEO is omitted because I don't have it installed): >1) zodb-basic >2) ExtensionClass >3) ZODB >4) BTrees > > Neil > Thanks Neil, champion effort. I can confirm that it installed smoothly on Win98 and NT4. Regards, Andy -- Content free posts a speciality From mwh at python.net Wed Jun 13 16:05:44 2001 From: mwh at python.net (Michael Hudson) Date: 13 Jun 2001 21:05:44 +0100 Subject: PyArg_ParseTuple part 2 References: <4OOV6.248837$Z2.2878033@nnrp1.uunet.ca> Message-ID: "John" writes: > Okay, here's some code Right, I think I've spotted your problem. > (I've omitted some of the error checking for simplicity): Hmm, and I've put some of it back in. Never mind... > static PyObject *PyGetComInterface(PyObject *self, PyObject *args) { > > PyObject *t; > PyObject *pyList; > int x; ^^^ should probably be a long; Python ints are C longs. > // extract list > PyArg_ParseTuple(args, "O!", &PyList_Type, pyList); ^ this should be &pyList. This is your main problem, I think. and the whole statement should be if (!PyArg_ParseTuple(args, "O!", &PyList_Type, &pyList)) { return NULL; } > // make a tuple version of list > t = PyList_AsTuple(pyList); > > // extract an integer from list *Note: t is always null at this point > if (t != NULL) { probably make that if (t != NULL && PyInt_Check(PyTuple_GET_ITEM(t, 0))) { > PyArg_ParseTuple(t, "i", &x); so you can write this as x = PyInt_AsLong(PyTuple_GET_ITEM(t, 0)) (what you were doing before could have lead to you setting an exception but not returning NULL, very much a no-no). Hmm. This still isn't really right (think 0 length tuple). I'd write the function something like this: static PyObject* PyGetComInterface(PyObject *self, PyObject *args) { PyObject* list; long x; if (!PyArg_ParseTuple(args, "O!", &PyList_Type, &list)) { return NULL; } if (PyList_GET_SIZE(list) < 1) { PyErr_SetString(PyExc_TypeError, "GetComInterface: expected list of length >= 1"); return NULL; } if (!PyInt_Check(PyList_GET_ITEM(t, 0))) { PyErr_SetString(PyExc_TypeError, "GetComInterface: list[0] must be integer"); return NULL; } x = PyInt_AsLong(PyList_GET_ITEM(t, 0)); fprintf(stderr, "x is %d\n", x); Py_INCREF(Py_None); return Py_None; } This is probably not perfect, but I hope it gets you on your way. HTH, M. -- ARTHUR: Don't ask me how it works or I'll start to whimper. -- The Hitch-Hikers Guide to the Galaxy, Episode 11 From matt at mondoinfo.com Wed Jun 6 21:00:50 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Thu, 07 Jun 2001 01:00:50 GMT Subject: TypeError: object is not callable References: Message-ID: On 7 Jun 2001 00:43:10 GMT, Gustaf Liljegren wrote: >I have done a class which is in placed in a directory within >sys.path, and the class works as intended when I test it by adding >some main() code in it. But when I call it from another module I get >this strange error "TypeError: object is not callable". No way I can >get the same error in Idle... >From the docs, it seems that it has something to do with the >constructor, so here is the constructor: >class Friend: > def __init__(self, id, file): > self.id = id > self.name = "" > self.emails = [] > self.file = file > self.load() Gustaf, It's hard to be sure what the problem is without seeing an example that fails but if the problem in in the constructor, it seems likely that it's in the last line since that's the only place that you're trying to call something. If self.load is something other than a method there, you'll get the error message you mention. You might try printing self.load (note no parentheses) just before that line. Regards, Matt From guido at python.org Wed Jun 27 13:07:55 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 27 Jun 2001 17:07:55 GMT Subject: PEP 260: simplify xrange() References: <3B39237F.1A7EF3F2@Lugoj.Com> Message-ID: James Logajan writes: > Guido van Rossum wrote: > > Here's another sweet and short PEP. What do folks think? Is > > xrange()'s complexity really worth having? > > Are there still known bugs that will take some effort to repair? Is xrange > constantly touched when changes are made elsewhere? If no to both, then I > suggest don't fix what ain't broken; life is too short. (Unless it is > annoying you to distraction, then do the deed and get it over with.) I thought about adding an xrange-specific iterator to make it faster, but found that the current implementation makes that more complicated than it should be (because you have to keep track of repetitions). It's also just an eyesore, and it seems to attract well-meaning folks who want to make it more sequence-like (which has caused me and others too much time already reviewing their code). Others proposed to extend xrange() to grow a shortcut for xrange(len(sequence)). I'm not very keen on that; it's up to the proposers to write the PEP that motivates it. Note that there are already other PEPs proposing to solve this problem differently, so you'd have to explain why adding something to xrange() is a better. I haven't heard any real objections here, so I'm going to go ahead and make this change (ripping the fancy stuff from xrange()) later this week. Boy does that feel good. ;-) --Guido van Rossum (home page: http://www.python.org/~guido/) From mlh at idi.ntnu.no Thu Jun 7 15:33:36 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Thu, 7 Jun 2001 21:33:36 +0200 Subject: [Python-sets] RE: Python-sets digest, Vol 1 #23 - 2 msgs References: <930BBCA4CEBBD411BE6500508BB3328F2E2124@nsamcanms1.ca.baltimore.com> Message-ID: <016101c0ef88$bf2de2a0$156ff181@idi.ntnu.no> From: "Greg Wilson" To: Sent: Thursday, June 07, 2001 9:23 PM Subject: [Python-sets] RE: Python-sets digest, Vol 1 #23 - 2 msgs > > From: "Magnus Lie Hetland" > > I was thinking about the possibility of dictionary > > comprehension a minute ago (I vaguely recollect doing > > so before...) and came to think of the set comprehension > > syntax... Would it be possible to have two different > > syntaxes like this: > > {v:k for k, v in dict.iteritems()} > > (or {dict[k]:k for k in dict}) > > and > > {v for k in dict} > > Check out Guido's call for comments on int, str, tuple, > etc. becoming type objects: > > http://mail.python.org/pipermail/python-dev/2001-June/015256.html > > and followups that talked about dictionary construction syntax; > is there a way to marry the two syntaxes? I assume you refer to the proposed dict function? I think that would be a very nice feature too - to be able to "get back" from dict.items(). However, this is more of a parallel to the list function, isn't it? While dictionary comprehension is more of a parallel (obviously) to list comprehension... As far as I can see, there is no need to marry the syntaxes, since they do different things. If this isn't what you mean, perhaps you could point me to a specific posting? :) > Greg -- Magnus Lie Hetland http://www.hetland.org "Reality is that which, when you stop believing in it, doesn't go away." -- Philip K. Dick From bos at hack.org Wed Jun 13 19:58:50 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Thu, 14 Jun 2001 01:58:50 +0200 Subject: IP address to binary conversion References: Message-ID: <3B27FE3A.D7F9879E@hack.org> Jeroen Wolff wrote: > Can somebody help me (a newbee) to convert an ip address to is 32 bits > representation? Lucky you, I had exactly that problem yesterday and hacked this solution: ------------------[snip]------------------ import socket, struct # return true if a string could be a pure ip address (4 dotted) def is_ipaddress(str): if str.count(".") != 3: return 0 for i in str.split("."): if not i.isdigit(): return 0 i = int(i) if i>255 or i<0: return 0 return 1 def interpret_addr(str): host = None if is_ipaddress(str): res = socket.inet_aton(str) else: try: host = socket.gethostbyname(str) except: print "Can't resolve '%s'" %(str) return 0 if host: res = socket.inet_aton(host) res = struct.unpack("!l", res)[0] if res == -1: return 0 return res >>> interpret_addr("10.30.40.50") 169748530 >>> interpret_addr("www.hotmail.com") 1074015239 ------------------[snip]------------------ -- Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From vze2f978 at mail.verizon.net Sun Jun 3 09:54:59 2001 From: vze2f978 at mail.verizon.net (Lloyd Hugh Allen) Date: Sun, 03 Jun 2001 13:54:59 GMT Subject: Tabs and spaces (style) References: <9cn2a20j24@news1.newsguy.com> Message-ID: <3B1A41CA.CCE5197A@mail.verizon.net> Fredrik Lundh wrote: > > Alex Martelli wrote: > > > What is the consensus about mixing tabs and spaces in a Python script? > > > > I don't think there is one. Guido's style guide recommends using both, > > with a tabsize of 8, so I expect most Pythonistas follow that style. Yet, > > for what it counts, I personally prefer setting my editors to always save > > with spaces only > > note that the standard distribution uses spaces throughout. guess > GvR hasn't gotten around to update the style guide... > > Cheers /F I thought that that was so that I could have a use for my old (paper) Fortran program templates. From ullrich at math.okstate.edu Mon Jun 18 09:45:36 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 18 Jun 2001 13:45:36 GMT Subject: Aargh! Function takes exactly x arguments, y given.. References: <9gkrud$pru$1@news.inet.tele.dk> Message-ID: <3b2e05d0.6684306@nntp.sprynet.com> On Mon, 18 Jun 2001 14:26:13 +0200, "Anders And" wrote: >Hi! > >I am a happy pythoneer using a combination of C++ and Python for my everyday >work. >Usually, debugging is easy but every now and then, I get the "function takes >exactly x arguments, y given" error message, clearly due to some other >problem than what Python thinks. The "clearly" is not at all clear unless you give an actual example. >Does anybody have any experience with this >particular error message? I don't know what triggers it and thinking back, I >think I have solved most of my problems with this message with a major code >rewrite. > >Please help! > >Kristian > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From jm7potter at hotmail.com Fri Jun 29 20:58:58 2001 From: jm7potter at hotmail.com (Joe Potter) Date: Fri, 29 Jun 2001 20:58:58 -0400 Subject: Tkinter problem in sizing a frame References: Message-ID: On Fri, 29 Jun 2001 20:00:48 GMT, matt at mondoinfo.com (Matthew Dixon Cowles) wrote: >On Fri, 29 Jun 2001 11:04:45 -0400, Joe Potter >wrote: > >>In the following code (adopted from "Python and Tkinter Programming") >>I find that I can set the minimum size for the root widget. However, >>I can not seem to tell Tk that I want two sub-frames each of which I >>want to take up half the parent frame. All I get is two sub-frames >>that take up as much room as need to display the label in each. > >Joe, >You were very close. The problem was the fill and expand are options >to the packer, not the widgets themselves. (I don't know why the >widgets don't complain that they don't understand those options.) I >think this will do what you want: > >from Tkinter import * > >root = Tk() >root.title('Frame Size') >root.geometry("600x300") > ># Dont really need this frame f = Frame(root) >xf = Frame(root, relief=GROOVE, borderwidth=5) >jf = Frame(root, relief=GROOVE, borderwidth=5) > >Label(xf, text="You shot him!").pack(side=LEFT, pady=10) >Label(jf, text='heck if I know !??').pack(side=LEFT, padx=10) > >jf.pack(side=TOP,fill=Y,expand=1) >xf.pack(side=BOTTOM,fill=Y,expand=1) >#f.pack() > >root.mainloop() > >Regards, >Matt Matt, Thanks for the help --- that was the ticket. I did read the fine manual, but I missed that part! Regards, Joe From sholden at holdenweb.com Mon Jun 18 12:35:09 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 18 Jun 2001 12:35:09 -0400 Subject: Python Essential Reference 2d edn. References: Message-ID: Technically, by the way, I believe this book is *by* David Beazley *with a foreword* by Guido van Rossum. regards Steve -- http://www.holdenweb.com/ "Kevin Altis" wrote in message news:zY5X6.137$fr.175944 at news.uswest.net... > There is a sample chapter in PDF format online at > http://www.newriders.com/books/title.cfm?isbn=0735710910 > > If you view at "actual size" that should give you an idea of the type-size > readability. > > ka > > "Michael Prager" wrote in message > news:da5vhtcqa8tafr4edm2l5opnd65gva6osl at 4ax.com... > > Can anyone tell me whether the second edition of this book (by > > Beazley & Van Rossum, and scheduled for publication next week) > > will be printed in a larger type size than the first edition? > > -- > > Mike Prager > > NOAA, Beaufort, NC > > * Opinions expressed are personal and not represented otherwise. > > * Any use of tradenames does not constitute a NOAA endorsement. > > From loewis at informatik.hu-berlin.de Mon Jun 18 07:04:28 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 18 Jun 2001 13:04:28 +0200 Subject: list.sort() References: <3B2CEBF1.CCF5377D@hack.org> <3B2DA731.1BAA305E@hack.org> Message-ID: Rikard Bosnjakovic writes: > I'm aware that changing is not a good idea at all. How about adding two > extra methods for sort/reverse, that actually returns the list instead > of changes it inplace? > > I think changing the list in place is very unPythonic. If you think such methods should be added, please write a PEP. Regards, Martin From tim.one at home.com Sat Jun 2 23:21:05 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 2 Jun 2001 23:21:05 -0400 Subject: Against PEP 240 In-Reply-To: <20010602113558.A25579@doublegemini.com> Message-ID: [Clark C . Evans, on financial calculations] > Nod. You'd be amazed what kind of "tricks" people use > to get the "right" answer. Sorry, I'm too old for amazement . The first time I bumped into this phenomenon was when staring at a Fortran program for computing the departmental budget. It added 0.03 to the sum at the end. What?! Turned out the manager who wrote this couldn't get the pennies to add up right, so fudged it by hand to deliver the result he wanted. > It works in the short term, The program above worked great, until one of the inputs changed . > but when the money is aggregated, taxes are calculated, > and other numeric operations are carried out these > "tiny" errors do accumulate. One "minor" mistake in > an accounting program and it brings into question the > data integrety of evertyhing... Understood. > ... > There are two general approaches: (a) do all of your > calculations in "cents", or (b) use a BCD (binary > coded decimal) library. > > Unfortunately the former isn't always an option... > for two reasons, first people don't think in cents > so it makes calculations quite a bit harder. Second, > for some currencies, numeric overflows are too common. > Let's say the annual revenue of your company was > 1.5 million dollars. This is 342,540,983,606 Lire*100. > With this number, you just had an overflow if you > were using long (32) bit integers (4,294,967,296) Well, Python has unbounded ints, so there's no overflow worry here. The FixedPoint class (mentioned frequently over the last week) wraps this trick inside objects so you don't have to worry about the details. > ... > More and more people will be using Python for financial > applications, from accounting to purchase order processing. > Must we require each of these programmers, who perhaps > have business degrees, to completely "grok" all of the > subtleties of numeric analysis before they can write > their first invoice? Certainly we could write and > publish a "BCD" library... but I question how many > junior programmers would know what BCD is... let alone > taking active initiative to look for BCD. Aahz is working on that approach. > I'd rather have the default be some sort of BCD > representation... where the programmer has to "work" > to get the innaccuracy of a floating point representation. It's not a cure-all, though. For example, dividing by 7 can lead to roundoff error in either approach. Rational arithmetic cannot in that case. From thomas at xs4all.net Thu Jun 7 08:37:36 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 7 Jun 2001 14:37:36 +0200 Subject: WHY is python slow? In-Reply-To: <4.3.2.7.2.20010607193225.021c1d90@bdg.centrin.net.id>; from steven@haryan.to on Thu, Jun 07, 2001 at 07:34:32PM +0700 References: <4.3.2.7.2.20010607193225.021c1d90@bdg.centrin.net.id> Message-ID: <20010607143736.A690@xs4all.nl> On Thu, Jun 07, 2001 at 07:34:32PM +0700, Steven Haryanto wrote: > Btw, I believe, for one thing, Python's (I last tried with 1.5.2) > startup time is significantly higher than that of Perl. That's because Python sets up a nice environment for you, with locale and nicely reachable site-packages such. Try running python with '-S', which skips the loading of site.py, and compare again. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From jkraska1 at san.rr.com Thu Jun 14 21:06:17 2001 From: jkraska1 at san.rr.com (Courageous) Date: Fri, 15 Jun 2001 01:06:17 GMT Subject: VI References: <3B278900.5828FB59@Lugoj.Com> <9gaunm$mth$3@brokaw.wa.com> Message-ID: >> "vi" is the first and last word in visual editors. Every editor written >> before or after it are irrelevant. ;-) http://www.thinkgeek.com/images/zoom/vi-emacs.jpg C// From thomas at cbs.dtu.dk Wed Jun 13 19:11:34 2001 From: thomas at cbs.dtu.dk (Thomas Sicheritz-Ponten) Date: 14 Jun 2001 01:11:34 +0200 Subject: kmeans cluster analysis ? References: Message-ID: William Park writes: > On Wed, Jun 13, 2001 at 09:50:32PM +0200, Thomas Sicheritz-Ponten wrote: > > Before reinventing the wheel ... does anybody know of a python > > implementation of the kmeans cluster analysis or (preferable) > > bi-secting kmeans ? > > Need more detail (sigh!) > For a short description of kmeans and bi-secting kmeans check: http://www-users.cs.umn.edu/~karypis/publications/Papers/PDF/doccluster.pdf (preferable starting with a distance matrix ...) more details ???? -thomas -- Sicheritz-Ponten Thomas, Ph.D CBS, Department of Biotechnology thomas at biopython.org The Technical University of Denmark CBS: +45 45 252489 Building 208, DK-2800 Lyngby Fax +45 45 931585 http://www.cbs.dtu.dk/thomas De Chelonian Mobile ... The Turtle Moves ... From phd at phd.fep.ru Thu Jun 28 05:51:12 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Thu, 28 Jun 2001 13:51:12 +0400 (MSD) Subject: How to grab HTML files behind authentification In-Reply-To: Message-ID: Thank you. But do you know urllib can do the same even simpler? urllib.urlretrieve("myName:myPassword at http://www.something.com/secret/index.html") On 28 Jun 2001, Dirk Krause wrote: > I've put together some code the python community might find useful. > You can use this script to automatically spider web pages beyond the > www-authenticate Dialog Box. > > ---snip--- > import httplib, string, base64 > > # How to grab HTML files behind authentification > # author: Dirk Krause, 06/28/2001 > # change these entries below!! > > base = 'http://www.something.com' > path = '/secret/index.html' > > u_name = 'myName' > u_pwd = 'myPassword' > > > # ok, here goes > > hlink = httplib.HTTP(base) > hlink.putrequest('GET', path+' HTTP/1.0') > hlink.putheader('Host', base) > > hlink.putheader('Accept', 'text/html') > hlink.putheader('Accept', 'text/plain') > > temp = "%s:%s" % (u_name,u_pwd) > temp = base64.encodestring(temp) > temp = "Basic %s" % string.strip(temp) > hlink.putheader("Authorization",temp) > > hlink.endheaders() > > errcode, errmsg, header = hlink.getreply() > content = hlink.getfile().read() > > print content > print errcode, header Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From rnd at onego.ru Wed Jun 13 02:17:24 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 13 Jun 2001 10:17:24 +0400 (MSD) Subject: PEP 257: Docstring Conventions In-Reply-To: Message-ID: Hello, I have some questions about docstrings: 1. Are the existing docstrings in Python standard modules example of good docstrings according to this PEP? 2. Each time I wonder about this: - The docstring is a phrase ending in a period. It prescribes the function's effect as a command ("Do this", "Return that"), not as a description: e.g. don't write "Returns the pathname ..." Does it mean that docstring must describe interface, not implementation? But then again: The docstring for a function or method should 1. summarize its behavior 2. document 2.1. its arguments, 2.2. return value(s), 2.3. side effects 2.4. exceptions raised 2.5. restrictions on when it can be called (all if applicable). ... Optional arguments should be indicated. ... It should be documented whether keyword arguments are part of the interface. That is, docstring has nothing to do with internals of the function? -- http://mail.python.org/mailman/listinfo/python-list Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From msoulier at storm.ca Wed Jun 6 22:41:10 2001 From: msoulier at storm.ca (Michael P. Soulier) Date: Thu, 07 Jun 2001 02:41:10 GMT Subject: Interesting speed benchmark References: <3B1D6FED.4070506@nospam.yahoo.com> <3B1EC430.9020201@nospam.yahoo.com> Message-ID: On Wed, 06 Jun 2001 18:00:48 -0600, Mahesh Padmanabhan wrote: > > Seems like that poster was correct in pointing out that the memory > management scheme of Java vs Python makes a difference. What are the disadvantages of this kind of "lazy garbage collection"? I know that the JVM will force the garbage collector to run if it hits a real limit, causing a sudden delay in a running program, but that rarely happens on today's systems. Is there serious justification for cleaning up de-referenced objects in Python right away? A comparison would be welcome. Mike -- Michael P. Soulier "With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead." -- RFC 1925 From Attila.Feher at lmf.ericsson.se Thu Jun 7 04:09:54 2001 From: Attila.Feher at lmf.ericsson.se (Attila Feher) Date: Thu, 07 Jun 2001 11:09:54 +0300 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3b1cdc84.5514@bolder.com.co.za> <9fleid$3rp$1@oslo-nntp.eunet.no> <3b1e4ef5.3788@bolder.com.co.za> <3B1E532F.7158FCFD@lmf.ericsson.se> <9fnbll$o6v$1@oslo-nntp.eunet.no> Message-ID: <3B1F36D2.EDB971B8@lmf.ericsson.se> Thomas Hansen wrote: > > > Now that was true in Hungary! Maybe not today, but I doubt that big cos > > changed a lot. I said I want it w/o OS they said: no way. MS > > _forces_them_ to sell Windoze with every PC. I said then I don't want a > > HDD in it. They say OK, then it costs +100USD. I say: so long > > suckers... and bought a PC from a "garage company". The ridicul is that > > I had highest possible MSDN and I was buying this SMP stuff for > > development... I already bought the OS for a lot of money from MS. > > Actually _all_ OSs including the traditional Chinese versions... And > > now comes: the garage PC needed me to install a new vent into it for the > > HDD was too hot... So at least where I am you don't get a PC w/o MS OS. > > :-((( > > > > A > > This is also true for Norway!! So we can state it is true for at least 2 countries that "ignorant" users do have MS opsys and some of them might have Mac, because this is what they get ready-preinstalled and everywhere. Of course: it may not be true for everybody's target group but game manufacturers are very unlikely to fail to work for Windows only in their 1st release. BTW of course this is not true for _any_ internet client application since there the client can be literally anything - including really weird devices... And then most probably the only way is to go Java and even there there will be the problem of which version of Java you can use... A From jm7potter at hotmail.com Wed Jun 20 18:03:04 2001 From: jm7potter at hotmail.com (jm7potter at hotmail.com) Date: Wed, 20 Jun 2001 18:03:04 -0400 Subject: help with a GUI example, please Message-ID: <0q62jtkbr4qns68t8666pff2i4sn7pvqq3@4ax.com> Hello all, Here is an example from "Programming Python: 2nd Edition" by Mark Lutz from pages 407-414 and is the start of a spreadsheet program. What I would like help on; is adding a scroll bar to the example. You will see why if you run the text file below with the "load" feature. Note: the code only slightly modified so that it could be posted as just one file. Thanks in advance, Joe Potter ########### start Lutz code ###################### # recode as an embeddable class from Tkinter import * from tkMessageBox import askokcancel class Quitter(Frame): # subclass our GUI def __init__(self, parent=None): # constructor method Frame.__init__(self, parent) self.pack() widget = Button(self, text='Quit', command=self.quit) widget.pack(expand=YES, fill=BOTH, side=LEFT) def quit(self): ans = askokcancel('Verify exit', "Really quit?") if ans: Frame.quit(self) class SumGrid(Frame): def __init__(self, parent=None, numrow=5, numcol=5): Frame.__init__(self, parent) self.numrow = numrow # I am a frame container self.numcol = numcol # caller packs or grids me self.makeWidgets(numrow, numcol) # else only usable one way def makeWidgets(self, numrow, numcol): self.rows = [] for i in range(numrow): cols = [] for j in range(numcol): e = Entry(self, relief=RIDGE) e.grid(row=i+1, column=j, sticky=NSEW) e.insert(END, '%d.%d' % (i, j)) cols.append(e) self.rows.append(cols) self.sums = [] for i in range(numcol): l = Label(self, text='?', relief=SUNKEN) l.grid(row=numrow+1, col=i, sticky=NSEW) self.sums.append(l) Button(self, text='Sum', command=self.onSum).grid(row=0, column=0) Button(self, text='Print', command=self.onPrint).grid(row=0, column=1) Button(self, text='Clear', command=self.onClear).grid(row=0, column=2) Button(self, text='Load', command=self.onLoad).grid(row=0, column=3) Quitter(self).grid(row=0, column=4) # fails: Quitter(self).pack() def onPrint(self): for row in self.rows: for col in row: print col.get(), print print def onSum(self): t = [0] * self.numcol for i in range(self.numcol): for j in range(self.numrow): t[i]= t[i] + eval(self.rows[j][i].get()) for i in range(self.numcol): self.sums[i].config(text=str(t[i])) def onClear(self): for row in self.rows: for col in row: col.delete('0', END) col.insert(END, '0.0') for sum in self.sums: sum.config(text='?') def onLoad(self): import string from tkFileDialog import * file = askopenfilename() if file: for r in self.rows: for c in r: c.grid_forget() for s in self.sums: s.grid_forget() filelines = open(file, 'r').readlines() self.numrow = len(filelines) self.numcol = len(string.split(filelines[0])) self.makeWidgets(self.numrow, self.numcol) row = 0 for line in filelines: fields = string.split(line) for col in range(self.numcol): self.rows[row][col].delete('0', END) self.rows[row][col].insert(END, fields[col]) row = row+1 if __name__ == '__main__': import sys root = Tk() root.title('Summer Grid') if len(sys.argv) != 3: SumGrid(root).pack() # .grid() works here too else: rows, cols = eval(sys.argv[1]), eval(sys.argv[2]) SumGrid(root, rows, cols).pack() mainloop() ###################### ########## end code ############ start text file to go with code ############ name it anything you wish ################################ 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 ####################### ############ end of file From noselasd at frisurf.no Thu Jun 21 09:47:38 2001 From: noselasd at frisurf.no (Nils O. Selåsdal) Date: Thu, 21 Jun 2001 15:47:38 +0200 Subject: problems with jython References: Message-ID: "Tyler Coumbes" wrote in message news:tj1nkt5h4db467 at corp.supernews.com... > Nils O. Sel?sdal wrote: > > > > > "Tyler Coumbes" wrote in message > > news:tivrc9jrqd8c1e at corp.supernews.com... > > > I got jython 2.0 and am trying to run it with IBMJava2-13. > > > I get this error > > > *sys-package-mgr*: processing new jar, > > > '/home/flounder/jython-2.0/jython.jar' > > > SIGSEGV 11 (*) segmentation violation > > > stackpointer=0xbffc1cf8 > > > > > > and it just keeps going at 100% cpu and doesn't stop > > > What could cause that? > > a bug? have you tried the Sun VM, or blackdowns (www.blackdown.org) > > > > > K, I will try another java VM today. Just thought maybe I had configured > something wrong. It says on the site they have used that one though. Oh > well. Oh.. if your using newer distributions e.g. Redhat 7.1 ibm's vm does not work. With Sun's you have to do 'export LD_ASSUME_KERNEL=2.2.5' From sabren at manifestation.com Wed Jun 20 00:26:29 2001 From: sabren at manifestation.com (Michal Wallace) Date: Tue, 19 Jun 2001 23:26:29 -0500 (CDT) Subject: OOP design question In-Reply-To: <9gor4b$3jv$1@fafnir.dyndns.org> Message-ID: On 19 Jun 2001, Anthony Veale' wrote: > Let me be concrete here. I'm writing a program to edit the Opera 5 > for Linux bookmarks file. I designed some classes for Urls and > Folders and one for the bookmark file as a whole. The BookmarkFile > class contains instances of Folders and Urls. > > Then when I started to design the editing program, I found that > there are some features that I wanted to add to Folders, that are > really only applicable to Folders when editing the bookmark file. I'm not sure I really understand the problem you're having.. It kind of depends on the specific features you're trying to add. Not knowing any more than that, though, my gut feeling is to suggest making a new object (Editor, for example) that acts on a Folder. Folder itself should provide an interface for changing its data, but Editor would coordinate between the Folder instance and the UI.. I could be wrong, but I think the your situation is better solved using composition (one object using/owning another) rather than inheritance. Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.net www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From aleaxit at yahoo.com Tue Jun 5 09:43:51 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 5 Jun 2001 15:43:51 +0200 Subject: formatting numbers References: Message-ID: <9finmq012pd@enews1.newsguy.com> "michael montagne" wrote in message news:e5SS6.69668$FS3.619704 at sjc-read.news.verio.net... > Simple question. I am accessing a database of job numbers that take the > form of "00049" and "01049". These values are integers. When I return the But if the leading 0's are significant, why not just take them as the strings they are? That would be simplest. > value from the database it reads "49". I need to add the leading digits if > they are there so this number would read "00049". In MSAccess I used > Format(num,"00000"). How can I do that with Python? Several ways are available, as already mentioned in various posts, such as: "%0.5d" % 49 string.zfill(49,5) ("0"*5+str(49))[-5:] but the simplest code is that which isn't there, so if you can just keep them as string you're better off! Alex From aleaxit at yahoo.com Mon Jun 11 04:40:46 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 11 Jun 2001 10:40:46 +0200 Subject: Learning OOP... References: Message-ID: <001901c0f252$3934de20$102b2bc1@cadlab.it> "Glyph Lefkowitz" writes: ... > > > Furthermore, I'd say that creating reusable code is *wrong*. > > > > Interesting strawman, but you haven't come anywhere close > > to 'proving' it in the following. > > I'm sorry, I should have been more clear. "reusable" code is wrong; > "usable" code is right. Re-use implies recycling, dragging something out Maybe it has this implication to you -- it definitely doesn't have it to me, nor to most authors on the subject of reuse and reusability and therefore to their readers. > of the garbage to use it again. For example, when you put on your new > pair of shoes for a second time, you usually don't think of it as re-use > (although you are technically "Using them again"), but it *is* re-use when > those shoes are a hand-me-down from an older relative, and have thus > exceeded their intended usefulness. But in a context where "custom design" is the NORM, as it has long been in the software world for MOST code, ANY "second use in another project" IS "exceeding [expected] usefulness". The point of the whole software-reuse movement is exactly that of changing such expectations of customization. > > ... "The unit of reuse is the unit of release" ... Robert Martin ... > > Excellent! Where can I find some writings by this fellow? :) www.objectmentor.com, of course. > > > projects. Keep your systems small and have them communicate clearly and > > > sparsely over encapsulation boundaries, and your code will be useful for > > > years; and you'll never have to re-cycle it. > > > > "Interface segregation principle", "dependency inversion principle", > > etc. Again, www.objectmentor.com has good papers on this:-). > > I hardly think that object orientation has a monopoly on this approach :). Yeah, yeah, right. As is well known, practitioners' response to a paradigm shift goes through various typical stages, including an early "this stuff is nonsense" and a later "but that's what we've been doing all along". One would think that a quarter of a century after the OO shift most practitioners would have gotten over it, but apparently Kuhn had it right back when he wrote "The Structure of Scientific Revolutions" -- in the end, it takes a generational turnover to make a new paradigm fully accepted, ideologically as well as pragmatically. > The reason that I don't think that these are really OO principles is that > the most successful component architecture and reuse framework that I've > ever seen is UNIX, which says nothing about objects; only executables, > files, and streams. Unfortunately, this "most successful component architecture and reuse framework" today lags badly behind a component architecture and reuse framework that outsells it by at least an order of magnitude and DOES actually provide for component reuse. When a programmer has gotten used to COM and Automation, for all their warts, moving back to a world bereft of it is anything but a nice prospect. It should be a GIVEN that I can reuse the functionality of an existing application by driving it with mine -- in the world of COM, it basically is. Connecting separate executables along a couple of file-like text streams just can't compare -- and people who pretend to compare, if they know what they're talking about, are talking through their hats. Why has Unix evolved .so's, and now at long last XPCOM and other REAL component frameworks, if "executables and streams" were sufficient as a component-reuse framework?-) Alas, too many Unix fans apparently live mired in the '70s -- Unix may not get a *really GOOD *AND* WIDESPREAD* component framework until it's too late (because generational turnover is just too slow compared with technology's pace). I grieve for this prospect, since COM is perched on top of an OS architecture which can be thought of as a collection of mutually-sustaining warts -- I'd MUCH rather be doing components on top of a GOOD kernel & other OS-level components. But "network effects" (in the economic sense) are likely to ensure this won't be practicable, most particularly when coupled with this reverence you're displaying for "executables, files and streams" as component-technology. Oh well -- taking Niven and Pournelle's advice, I think of it as evolution in action:-). > The most revolutionary development in software engineering was the > subroutine, closely followed by the data structure. The notion of > "objects" has been a useful tool to think with, but much more of a small > incremental improvement than the revolution of the subroutine :) I'm not sure what the interest in this historical debate might be. What about alphabets, positional number systems, and algebraic notation -- weren't *those* even bigger "revolutionary developments" in information-processing technologies? And -- ***SO WHAT***?! I'm second to nobody in my fascination for useless tidbits of historical framing and debate, but I don't kid myself that this is a productive way to employ my time. Whether Arabic numerals actually reached European practice thanks to Pope Sylvester (born as Gerbert, and probably the only great mathematician to ever be Pope), and thus through Arabic Spain, or rather through Italian merchants' business dealings with the East, is an absolutely fascinating issue, but it makes no difference whatsoever to the way I, or anybody else, actually practice arithmetic today. It is a similarly-fascinating and equally useless "waste of time" to drag the conversation away from today's best practices and to attempts to evaluate relative importance of very different IT developments. > > Except that it's not, when applied well. Python shows well how > > suitably designed inheritance can make for smooth framework-code > > reuse, e.g. in sgmllib/htmllib and the whole server hierarchy. Code > > generators should generate base-classes that are specialized by > > inheritance, *NOT* by editing generated sources (a round-trip > > nightmare). Mixins allow seamless reuse. Etc, etc... > > I haven't had good experiences either with inheritance in either of those > examples you mentioned. "Aggregate, not inherit". Especially in python, Wrong, especially in Python. When needed semantics are exactly those of Python's inheritance (which happens very often, because Python is very well designed), it is an absurd obfuscation exercise to rebuild the same mechanism, slowly and unreadably, on top of _other_ Python building-blocks, in the name of some abstract and inapplicable principle. > when one can easily forget the oh-so-subtle method chain; > > def __init__(self, *args, **kw): > apply(self.__class__.__bases__[0].__init__, (self,)+args, kw) Do try to forget this, PLEASE. It's an absurd obfuscation all over again -- an attempt to ensure recursion when this class is inherited from. MyBase.__init__(self, *args, **kw) is the obvious way to do it. Complication for complication's sake is not Pythonic, not sensible, and not pretty. > > It's true that implementation inheritance CAN too easily create > > unintended strong coupling. Scott Meyer's rule of thumb to > > "never inherit from a concrete class" (in a C++ setting) shows > > to what extremes one could go to ward off that danger... > > A number of programmers I've met adhere to this rule (Moshe Zadka in > particular, I believe ^_^), and I aspire to now. Twisted Python (PLUG: > http://twistedmatrix.com ) began life with a rather entangled inheritance > structure and I've almost completely deconstructed it... and it's much > easier to use for it. If your structure was entangled, you did well to refactor it. But if you've replaced an entangle structure of inheritance by an entangled structure of mutual object references, particularly with circular aspects, then your "eschewing inheritance in favor of aggregation" actually made your architecture *WORSE*. The problem is the entanglement, NOT inheritance, which, in Python, is just a neat and powerful reuse-mechanism -- no more, no less. A typical case (exemplified by sgmllib, etc) is a design pattern with a general-controller and a specializer. The controller implements higher-abstraction processing by sequencing calls to lower-level methods that MAY be implemented in the specializer -- but need not be (the controller itself provides default lower-level methods that will often suffice). This is basically what the GoF call the "Template" DP, and is a very handy one. Implementing it without inheritance requires a tangled structure: the controller must hold a reference to the specializer to invoke methods on it, the specializer must refer back to the controller to re-delegate some processing to it. What a mess! Not to mention the need to use weak references or otherwise break the loop when you're done (if a __del__ interferes with GC...:-). Inheritance on the other hand makes this extremely simple and effective -- we share *object identity* between controller and specializer, AND method-overriding just works right -- no hassles, no trouble. In the general case, and particularly in Python, rewriting a structure that so obviously calls for Python's inheritance as "the obviously right way", such as the Template DP, in terms of aggregation and explicit delegation, is just to go around looking for trouble for trouble's sake. Practicality beat purity, and Python's inheritance is VERY practical. > > > things). Also, some systems which claim to be "OO" also have static > > > typing, which partially negates the value of sending messages. > > > ...and partially enhances it. > > Inheriting across language boundaries (where this communication benefit is > felt the most) is almost *never* a good idea. Wrong, if the cross-language framework is designed for it. With the Boost Python Library, for example, it's a snap. > If there were a neater way > to say "I implement this" than inheriting a base class in Jython, I'd use Why, sure -- to take 'extends' as meaning 'implements' *IS* to go begging for trouble. Confusing the two concepts is a sad C++ (and Eiffel) design mistake, which Java got right instead. There is still hope for Python -- see PEP 245 and 246:-). > trying to do cross-language metaclass hacks? :) It's a semantic accident > if any of that stuff works, which I think indicates the fragility of > inheritance. All it indicates is that inheritance is great for its job (code reuse) and NOT for jobs that it's not suited to ('implements' being one good example:-). If you think that "the fragility of inheritance" is indicated by the fact that it doesn't do well those jobs that it shouldn't be used for, why stop to 'implements': inheritance is a LOUSY way to squeeze oranges, it can't hold a candle to a shaped-charge for building-demolition purposes, AND it's really useless for fireproofing (although it doesn't suffer from the same side effects as asbestos in the latter case). If your distaste for inheritance and other OOP tools is an over-reaction to the over-use of such tools and concepts by too-eager practitioners, it's psychologically understandable. But just about ANY tool can be mis-applied to jobs it's not really well-suited for -- and that tells you nothing about the tool itself *when properly used*. > > Again, it demands very solid design (I wouldn't be Pythoning if I > > didn't think the flexibility of dynamic typing was more often useful > > than the rigidity of static typing, but I do have to play devil's > > advocate on this thread, I think:-) but when you have it you're well > > I can see advantages to static typing and efficiency as well, but I see > the need to do so. What would that make me? "God's advocate?" We can "The need to do" WHAT? I don't follow you here. > all see that Python has the divine will on its side now... ;-) > > > placed. Templates (or other mechanisms for compile-time genericity) > > recover a lot of that flexibility at no runtime cost -- Coplien's > > "pattern without a name" is IMHO mostly aboyt that (template > > class Y: public X, etc). Basically, templates give you > > signature-based polymorphism, like Python's, at compile-time only > > (thus less flexible, but easier to generate speedy code for, and > > sometimes allowing somewhat earlier error diagnosis). > > The "error diagnosis" argument I can't really argue with (C++ compilers > *do* describe more errors at compile-time), but it smells funny to me. > I'd guess that C++ just introduces more errors so it can diagnose them. > After all, which do you find is usually more error-ridden on the first run > -- C++ code or Python code you've written? :) It's roughly even, but that's because I'm MUCH more careful, slow and deliberate when I code in C++. For a given function- point set, which may take about 100 lines in Python or 400 in C++ (with liberal use of Boost &c:-), I may take about an hour to an hour and a half to code it in C++ versus about 10 to 15 minutes in Python -- a ratio of about 6 to 10 for coding time vs one of about 4 for code size. Number of errors left and time to fix them is thus back to roughly code size (4:1 in favour of Python). > Mr. Meyer's thoughts notwithstanding; static typing is a way of making OO > more linearly isomorphic to structured programming. For example; > > --- > class Foo: > def x(self): > blah() > ... > f = Foo() > f.x() > --- > > means that we have to figure out what kind of thing 'f' is before we go to > send the message 'x' to it. However, Absolutely not! As long as f implements an interface including a method x that can be called without parameters, we can call that method without caring in the least "what kind of thing f *IS*". > difference between thinking of data as "behaviorally" instead of > "structurally" composed, then non-virtual functions (and the static type > information that makes them possible) are against the spirit of OO. Now why are you dragging "non virtual functions" into the mix?! Eiffel, the "king" of static-type-checking OO languages and Meyer's cherished brainchild, has nothing to do with such strange beasts. The compiler (if it has all relevant information) MAY be able to optimize away the virtual-lookup by type-deduction, but that's a compiler-optimization issue (and, in theory, it might just as well be done in a dynamic language -- the stalin compiler for Scheme being one good example that shows such theory working in practice as well:-). > > > have anything to do with object orientation. Certainly, provable > > > correctness and static typing are at odds with reuse, since they make your > > > software more resistant to change. > > > > Making software resistant to change is neither an intrinsically > > bad thing, nor one at odds with software reuse. I DO want the > > software that I'm reusing to be unchangeable from the point > > of view of behavior that I, the reuser, observe. > > IMHO making software resistant to change *is* an intrinsically bad thing > Embrace change! :). Although I appreciate the desire for the behavior to > remain constant across project boundaries, I don't see that static typing > helps with this. You can't really argue both ways: either static typing DOES make software more resistant to change, and therefore promotes "behavior remaining constant", or it doesn't. You seem to be saying that static typing DOES facilitate constant behavior EXCEPT where such constance is desirable, yet you bring no arguments at all for such a peculiar contention of "antiselectivity"!-) Static typing really needs to be accompanied by "programming as contracting" constructs (preconditions, postconditions, and class invariants) to let you specify WHAT behavior will "remain constant" (and, by difference, what behavior will be free to change). A good set of unit-tests for a component does do SOME of that job (and other important jobs that PbyC by itself can't really do:-), but not all of it and not as well as PbyC, because what we want is a *weakest* precondition (in Djikstra's terms), not just ANY precondition -- just like, in abstract algebra and elsewhere, we need to identify the minimum set of axioms that let us prove certain theorems, not just ANY set. > Python's "file" interface convention has done a lot > towards aiding re-use; I believe that's partially because it's so easy to > implement. But it's badly under-specified. Ever tried to use your own C-implemented "file-like object" and wrestled for hours until you found that the "file-like object" needs to have a settable 'softspace' attribute for SOME uses (print) but not for others? Having to read "client-code" sources to find out if you need to implement .read() without args, .read(N), .readline(), .readlines(), or those WITH args, or whatever else, is also a recurring issue. A protocol (or rather set of protocols in this case) specified in executable, checkable terms rather than just by handwaving would do wonders to help here! Cfr PEPs 245 and 246, again. > > > The easiest way to have a responsive, efficient program is to prototype > > > and prototype and prototype in a flexible, "slow" language, until you've > > > got the fastest possible high-level algorythm, then optimize for constant > > > > Nolo contendere here, but it's SO important it's worth quoting > > just to increase the likelihood that it gets read:-). > > Yes, let's just leave it here :) One more time can't hurt:-). > critique is that high level languages are more important to > programming than object-orientation. [...] Maybe -- IF I can do something at a high-enough level, I MAY not miss O-O too badly. (E.g., for what little I've done in Haskell, its typeclasses have AMPLY filled my needs -- I've felt no need yet to experiment with O'Haskell to get OO as well). OTOH, *having* to go at things "the high level way" when you really and truly need low-level tools is no less of a bummer. A single language trying to stretch all the way (C++, probably also Eiffel, Lisp, Dylan) in my humble opinion gets too rich and complex for really-handy use -- give me mixed-language, mixed-paradigm programming any time. Alex From dsh8290 at rit.edu Tue Jun 5 16:03:51 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 5 Jun 2001 16:03:51 -0400 Subject: Manipulate file in Windows In-Reply-To: ; from ddublanc@free.fr on Thu, May 31, 2001 at 08:53:01PM +0000 References: Message-ID: <20010605160351.A14014@harmony.cs.rit.edu> On Thu, May 31, 2001 at 08:53:01PM +0000, Dublanc, David wrote: | Hello, | I have to manipulate big text files (more than 100 M ) on Windows and Unix. | | I have several questions : | | How can I count lines fastly ? ( wc -l in Unix...) $ time man bash | wc -l 5544 real 0m0.081s user 0m0.030s sys 0m0.040s $ time man bash | python -c "import sys ; print sys.stdin.read().count( '\n' ) " 5544 real 0m0.221s user 0m0.100s sys 0m0.030s Quite a bit slower. Perhaps check the implementation of wc for more speed? | When I have the total number of lines, I have to split the file into x files | of 1000 lines. How can I do this fastly ? Why do you need to count the number of lines in the first place? Couldn't you just start stuffing groups of 1000 lines into other files and count the lines as you go? | Are there functions to replace x lines of a file by y another lines ? To | delete the x to y lines in a file ? | | In brief, I am looking for useful file functions that I cannot find in the | Library reference.... These functions aren't really possible on files themselves, but rather make more sense on a string or list of strings (the data in the file). A file is just a series of bytes on a disk. Each block has a certain location. Random modification only works if the new data is the exact same size as the old data. -D From lac at cd.chalmers.se Fri Jun 1 17:43:18 2001 From: lac at cd.chalmers.se (Laura Creighton) Date: Fri, 1 Jun 2001 23:43:18 +0200 (MET DST) Subject: docstrings, invention there of Message-ID: <200106012143.XAA15211@boris.cd.chalmers.se> Can somebody please find out that RMS beat me to it so I can sleep? Having RMS as an unwanted house guest in my house for 2 months (don't ask, I am not telling) makes me the wrong person to ask. I just started using emacs 6 months ago so we can use it to make absolutely sure that our code is utterly consistant, and I moved from ed. I still don't know how to tell emacs that when I want out of a file, I want out of it immediately, usually BECAUSE there are buffers that are unmodified and I don't have time to waste with control shift underscore. Still it makes the good old 'you just typed 600 lines of code into your cat>/dev/null window mistakes a lot harder to make.... (but not impossible, did one yesterday, only 20 lines thank god.) Laura From fpm at u.washington.edu Wed Jun 20 10:47:36 2001 From: fpm at u.washington.edu (Frank Miles) Date: 20 Jun 2001 14:47:36 GMT Subject: Help installing pygtk, libglade in Windows - please Message-ID: <9gqd28$j36$1@nntp6.u.washington.edu> I'm trying to install pygtk and libglade on a Win9x system. The local Windows guy advises me that it is necessary to edit the Windows registry to install DLLs. Is this truly the case with the DLLs associated with these? Unfortunatley I don't have the tools to build for Windows, so was trying to use the binaries built for Windows; but these don't seem to have any installers. I've tried editing a setup.py written for another program so that I could use distutils, but this hasn't worked. Take pity on a Linux guy (it's _so_ much easier and simpler there)! I'm developing my app on Linux, but (sigh) others in my organization run Windows, and they have to be able to use it too... Thanks for your help! -frank -- From nospamnntp at stone.nu Sat Jun 9 07:26:21 2001 From: nospamnntp at stone.nu (Fredrik Steen) Date: 9 Jun 2001 11:26:21 GMT Subject: create backup script in python References: <7b515e0f.0106011730.6b1aa82d@posting.google.com> Message-ID: On Sat, 02 Jun 2001 15:22:44 GMT, Rainy wrote: > On 1 Jun 2001 18:30:48 -0700, eric_brake wrote: >> What is the easiest way to write a file copy script in python? I want >> to use the script as a way to backup any file I choose on my hard >> drive. Binary mode is best while handling this range of file types, >> Correct? >> >> thank you > > Backup to where? I made a little script that backs up my home directory > to a cdrw disk, it uses mkisofs and cdrecord (unix programs). > > Would you share your script? -- .Fredrik Steen http://www.stone.nu/ From deoradh at yahoo.com Sat Jun 23 05:32:38 2001 From: deoradh at yahoo.com (Keith Farmer) Date: Sat, 23 Jun 2001 02:32:38 -0700 Subject: Python extension: SHAppBarMessage in VC++ .. help? Message-ID: <9pZY6.2865$Uy4.319652@news.pacbell.net> This is only my 2nd extension for Python I've written. The idea is to provide an interface to the SHAppBarMessage function in Win32, which takes an APPBARDATA struct as its second argument, itself having a RECT struct: typedef struct _AppBarData { DWORD cbSize; HWND hWnd; UINT uCallbackMessage; UINT uEdge; RECT rc; LPARAM lParam; } APPBARDATA,*PAPPBARDATA; Here's the file: ..... /* appbar.cpp -- appbar functionality */ #include "Python.h" #include #include //#include //#include static PyObject *AppBarError; static PyObject *AppBar_SHAppBarMessage(PyObject *self, PyObject *args) { int result; UINT msg; APPBARDATA abd; if (!PyArg_ParseTuple(args, "IPIII(iiii)", &msg, // UINT &(abd.hWnd), // HWND &(abd.uCallbackMessage), // UINT &(abd.uEdge), // UINT &(abd.lParam), // LPARAM &(abd.rc.left), // int &(abd.rc.top), // int &(abd.rc.right), // int &(abd.rc.bottom) // int )) return NULL; abd.cbSize = sizeof(abd); if (SHAppBarMessage(msg, &abd)) result = 1; else result = 0; return Py_BuildValue("(l(iiii))", result, abd.rc.left, abd.rc.top, abd.rc.right, abd.rc.bottom); } static PyMethodDef AppBarMethods[] = { { "SHAppBarMessage", AppBar_SHAppBarMessage, METH_VARARGS }, { NULL, NULL } /* Sentinel */ }; #ifdef MS_WIN32 __declspec(dllexport) #endif void initAppBar() { PyObject *m, *d; m = Py_InitModule("AppBar", AppBarMethods); d = PyModule_GetDict(m); AppBarError = PyErr_NewException("AppBar.error", NULL, NULL); PyDict_SetItemString(d, "error", AppBarError); } ..... And here are the errors so far: c:\program files\microsoft visual studio\vc98\include\shellapi.h(53) : error C2065: 'HDROP' : undeclared identifier c:\program files\microsoft visual studio\vc98\include\shellapi.h(53) : error C2501: 'DECLARE_HANDLE' : missing storage-class or type specifiers c:\program files\microsoft visual studio\vc98\include\shellapi.h(55) : error C2146: syntax error : missing ';' before identifier 'UINT' c:\program files\microsoft visual studio\vc98\include\shellapi.h(55) : error C2501: 'DECLSPEC_IMPORT' : missing storage-class or type specifiers c:\program files\microsoft visual studio\vc98\include\shellapi.h(55) : fatal error C1004: unexpected end of file found Now, I'm not even certain that I'm doing this in the correct manner. I gave up trying to figure out how to calldll the function, trying to set up a struct using the python module. I'm not even certain I know how to go about testing this -- my C experience has historically been mundane, and on Unix. Keith Farmer From alan.gauld at bt.com Mon Jun 4 13:22:10 2001 From: alan.gauld at bt.com (Alan Gauld) Date: Mon, 04 Jun 2001 18:22:10 +0100 Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> Message-ID: <3B1BC3C2.CDBE7D0E@bt.com> Tim Churches wrote: > No experience (I am in a similar situation to you wrt UML), just some > advice: don't buy the O'Reilly book 'UML in a Nutshell' Its not a tutorial but in fact is an OK reference book for UML practitioners IMHO. And that, after all, is what the nutshell books are supposed to be... Alan g From cfelling at iae.nl Thu Jun 28 07:53:34 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 28 Jun 2001 13:53:34 +0200 Subject: PEP 260: simplify xrange() References: <3B39480C.F4808C1F@Lugoj.Com> <9hc97q$rpt$1@slb6.atl.mindspring.net> <3B3A9C39.64C3E1C6@seebelow.org> <9hef08$urt$1@slb3.atl.mindspring.net> Message-ID: <9hf5ru$5el$1@animus.fel.iae.nl> Michael Hudson wrote: ... > Google confuses me; if you search for "michael hudson" my page is the > third hit - but my name doesn't actually appear anywhere on the linked > page! probably it's in a hidden field, like > The "did you mean to search for ..." feature is also downright > uncanny. can't find this option, mind to explain? -- groetjes, carel From thinkit8 at lycos.com Wed Jun 13 18:42:05 2001 From: thinkit8 at lycos.com (thinkit) Date: 13 Jun 2001 15:42:05 -0700 Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> Message-ID: <9g8q7t0uib@drn.newsguy.com> In article , Tom_Good1 at excite.com says... > >thinkit wrote in message >news:<9g5d3p0f0p at drn.newsguy.com>... >> humans should use a power of 2 as a base. this is more logical because it >>synchs with binary, which is at the very heart of logic--true and false. it is >> more natural perhaps, to use decimal--but logic should, and will, win out. > >I'm amused by the idea that "humans should [do something] because . . >. it is more logical." Ah yes, we humans are so extremely logical. >That's why advertisers -- whose livelihood depends on getting us to do >things -- inevitably appeal to our highly refined sense of logic, and >never play to our emotions or baser instincts ;-) some of us are...and those that are will easily dominate or destroy the rest. From akuchlin at mems-exchange.org Sat Jun 2 08:51:51 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 02 Jun 2001 08:51:51 -0400 Subject: QuickCam and python? References: Message-ID: <3dae3r3uzc.fsf@ute.cnri.reston.va.us> "akhar" writes: > Is it possible to read direcltly from a quickcam or any other video camera > from python, and use pil(for example) to stream it? I am still shopping for > a camera to use for my project if there is one that is better ... If you're on a Unix platform, it's possible to use the SANE module in PIL to read from a QuickCam and get an Image object containing the data, which can then be saved, manipulated, or whatever. If you're on Windows, I have no clue. --amk From whisper at oz.nospamnet Sat Jun 16 00:15:14 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 16 Jun 2001 04:15:14 GMT Subject: Python, Unicode, l8n and i18n References: <9gajd9$8ft$3@216.39.170.247> <9gb4vh0t22@enews1.newsguy.com> Message-ID: <9gemgi$324$3@216.39.170.247> In article <9gb4vh0t22 at enews1.newsguy.com>, aleaxit at yahoo.com says... > "David LeBlanc" wrote in message > news:9gajd9$8ft$3 at 216.39.170.247... > ... > > Has anyone taken a look at using the International Components for Unicode > > with/as part of Python: > > As ICU uses C++ (albeit minimally) I don't think it can become a part > of Python (Python being firmly wedded to C). *Using* it is another > matter -- as I understand, it *does* have a C-callable interface (have > not looked at it in detail, yet) -- and anyway it could no doubt be > wrapped e.g. with Boost Python, CXX, or maybe even Swig. It DOES > appear VERY interesting if one has difficult internationalization > needs (collation, calendar, currency, ...)! > > > Alex > > > > I think that ICU has a C API. I didn't mean that the ICU interface should be exposed in Python, rather that it could be used as a ready-made component for increasing Python's i18n and l8n features. I think those are a good thing and i've seen some posts from other users asking for (especially) locale specific idioms like date format, radix point character etc. Dave LeBlanc From zihonglu at home.com Wed Jun 27 01:42:35 2001 From: zihonglu at home.com (zihonglu) Date: Wed, 27 Jun 2001 05:42:35 GMT Subject: win32 extension installation problem References: <3B355CE8.8060605@ActiveState.com> <9YuZ6.123682$%i7.85882471@news1.rdc1.sfba.home.com> <3B38035F.9070303@ActiveState.com> Message-ID: Mark, It is working perfectly now. I have put the PythonService.exe AND the PyWinTypes21.dll in the same python directory, and changed the pathes in the registry accordingly. Thank you for your help. -Zihong From whisper at oz.nospamnet Fri Jun 15 16:56:31 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 15 Jun 2001 20:56:31 GMT Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> <9gclvm02tte@enews1.newsguy.com> Message-ID: <9gdspv$324$0@216.39.170.247> In article <9gclvm02tte at enews1.newsguy.com>, aleaxit at yahoo.com says... > "David LeBlanc" wrote in message > news:9gbsdv$8ft$9 at 216.39.170.247... > ... > > alias where (argument) substition is done! At least conceptually the body > > of a function replaces it at invocation time.) > > Fortunately ***NOT***!!! Such a horrible "conceptual" > choice for a function-execution model would put pay to > any chance of *RECURSION*. > > > read so nicely to be able to say "if something is true" rather then "if > > something is not 0" (saves on typing too :-)). > > Such "read so nicely" tests would of course not work as > expected (with or without alias). The object None, for > example, evaluates as false, but if you test its identity > with 0, you will of course find they're not *identical* > (how COULD they be -- they're different in every respect, > the ONLY thing they have in common is evaluating as false!). > > It seems to me that the LAST thing we need is encouraging > "read so nicely" forms that do NOT do what a naive newbie > might expect. It is absolutely fundamental that the > newbie learns to write his/her logical tests as: > if something: > ... > and > if not something: > ... > and *NOT* > if something is 1: > ... > or > if something is 0: > ... > or any "aliases" of these flawed forms. > > > > Other suggestions to import large libraries or make modules instances are > > not things calculated to gladden the heart of a newbie who seeks > > simplicity, > > The module-instance (the const.py example I gave) would of course > be made by a NON-newbie, the newbie would just USE it. Why would > "a newbie who seeks simplicity" consider: > > const.magic = 23 > > less simple than > > alias magic : 23 > > ?!?! The former uses exactly the same syntax as any other binding, > requiring the newbie to learn absolutely no new syntax. The latter > requires the newbie to learn one more "simple keyword-statement", with > a syntax totally different from that of all OTHER simple keyword > statements. It seems to me that your claim that all of the extra > conceptual and syntactical baggage FAVOURS simplicity, when common > sense suggests extra baggage REDUCES simplicity, is an extraordinary > claim, and thereby requires extraordinary proof. > > > nor would the code enlargement (my aren't I diplomatic ;)) > > win the approval of an experienced developer who doesn't want to search > > exteraneous lines when a bug pops up - which is statistically more likely > > What "code enlargement" are you talking about? Which "exteraneous" (?) > lines? In a script using "module const" there may or may not be a > single line > import const > for explicitness (the alternative is having it performed implicitly > at startup, e.g. by sitecustomize.py &c &c, placing const in the > __builtin__ module, of course). That's up to the "experienced > developer" who decides constants are necessary at his/her site. > > > with more lines of code, not to mention the antics needed to do something > > that should be as simple as possible (imho). > > What "antics"? If you want 'const' to be activated by default > in every Python installation (e.g. in site.py), write a PEP > proposing just that. You DO realize, of course, that no matter > what little chance such a PEP may have, it IS going to be at > least a thousand times more likely to be adopted than anything > that will introduce a new keyword and thereby break perfectly > working code -- that's something that can *possibly* happen > only for really momentous developments (such as the new proposed > "yield" keyword-statement for generators) which DESPERATELY NEED > a new statement (can't POSSIBLY work halfway-decently without). > > > > One can certainly argue that this is syntactical sugar. It does however > > serve a multitude of good purposes among which are: maintainability; > > clarity; consistancy; correctness; good programming habbits; - a not > > inconsiderable set of advantages for a little sugar. > > I fail to see ANY of these advantages when comparing your "alias" > with a "const" module installed by site.py. How is > alias magic : 23 > more maintainable, clearer, more consistent, more correct, or > a better programming habit than > const.magic = 23 > ?!?! Please bring SOME kind of argument for such extraordinary > assertions... your bald statements are not "support" for them! > > > > Finally, this wouldn't break any code, > > Puh-LEEZE. *ANY* use of 'alias' in existing code would be > broken. Let's not make such obviously-false assertions... > > > Alex you mistake a simple example for how something would of necessity be done. it could just as esasily be "alias true : not none and not 0" Of course you would prefer your method... Ok, so it _might_ break some existing code... so might using const or magic or many other words.. such logic suggests that since cobol was (probably) the first "high level" language that we should all still be using it since to change or add anything might break older stuff.. yeah, a somewhat contrived example, but i'm sure you get the idea... maybe staying with python 1.3 vs 2.1 would be a better example. Dave LeBlanc From pj at sgi.com Mon Jun 25 19:36:25 2001 From: pj at sgi.com (Paul Jackson) Date: 25 Jun 2001 23:36:25 GMT Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) References: <200106201855.OAA21119@panix3.panix.com> <15153.15434.385992.754443@beluga.mojam.com> <3B36DE62.7DDD28E0@cosc.canterbury.ac.nz> Message-ID: <9h8htp$jd7qm$1@fido.engr.sgi.com> |> Two days is not enough! In my view, however long Guido needs is enough. -- I won't rest till it's the best ... Manager, Linux Scalability Paul Jackson 1.650.933.1373 From vj$ri^gg#guess#l55e at mt$*guess#&cn1e#t.! Fri Jun 1 17:08:52 2001 From: vj$ri^gg#guess#l55e at mt$*guess#&cn1e#t.! (Kevin Riggle) Date: Fri, 1 Jun 2001 16:08:52 -0500 Subject: Executing a shell command Message-ID: <9f901k$ffa$1@mtc1.mtcnet.net> Is there any way to take a command in a string in Python, execute it in the shell, and read the output into a variable of some sort, like result = execute(cmdline) Something analogous to the 'shell' command in BASIC (shudder). The exec() and execfile() commands don't work for me, as I want to run a shell command, not a Python command. Any ideas? Thanks! - Kevin Riggle ---------------------------------------------------------- "We can lick gravity, but sometimes the paperwork is overwhelming." - Wernher Von Braun, rocketry pioneer From kiko at async.com.br Fri Jun 29 17:20:32 2001 From: kiko at async.com.br (Christian Robottom Reis) Date: Fri, 29 Jun 2001 18:20:32 -0300 (BRT) Subject: [pygtk] Re: getopts confusion In-Reply-To: <993844969.1531.0.camel@ZOOstation.cc> Message-ID: On 30 Jun 2001, Rob Brown-Bayliss wrote: > Yes, some. I played around some more, and the app that fails has a GUI, > the other is a command line app. There is a single import I do (from > gnome.ui import *) that stuffs it up, if the getopt stuff comes before > this import I don't get that error, if I cut and paste the getops till > after this import I get the above error. Nameclashes, perhaps? Check out the list of symbols defined inside gnome.ui - dir(gnome.ui) - and see if it clashes with something defined inside getopt. Bottom line: don't use from foo import bar, it's evil. Take care, -- /\/\ Christian Reis, Senior Engineer, Async Open Source, Brazil ~\/~ http://async.com.br/~kiko/ | [+55 16] 274 4311 From mcfletch at home.com Fri Jun 29 13:46:28 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Fri, 29 Jun 2001 13:46:28 -0400 Subject: Not enough Python library development [was PEP scepticism] In-Reply-To: Message-ID: <003201c100c3$6d6123f0$a9807018@cr706570a> My suggestions for the TODO list... ConfigStorage: Read/write, storage of Python values for configuration variables, potentially use .ini, .whatever, or registry for storage, use human-editable formats wherever possible. Replace registry settings for Python with such repositories to allow for cross-platform scripts (see config below). Purpose here is to provide a convenient and robust way for applications to store their configuration settings as Python data without needing to think about the storage mechanism. Should prevent storing huge objects in the windows registry. ZipDirectory/Virtual FileSystem: Make reading/writing into/out of archive files as trivial as reading/writing from directories (i.e. zipdirectory.open( 'z:/temp/test.zip/path/to/myfile.txt','r').read() would work). Allow for reading, modifying (the tricky one), and writing files. Should handle .zip, (.jar), .tar, potentially also .hqx (or whatever the mac standard is). Creation would follow virtual filesystem model, you create a zip "directory", then populate it with files... zipdirectory.makedirectory( 'z:/temp/test.zip', compress=1 ) zipdirectory.open('z:/temp/test.zip/path/to/myfile.py', 'w').write( somedata ) On a larger level, provide hooks for virtual filesystems of all types, so that, for instance, the ftp modules could be given a similar api, as could the urllib.retrieve stuff: file = open( 'http://www.python.org/','r') file.readline() file.read() With file being a class providing file-like semantics, a buffer into which the data is downloaded, as well as the http-specific stuff. Configure: Allow (potentially persistent) configuration of the running Python interpreter. Modify path values, modify list of scripts run at startup, modify shell action bindings (for win32). Should allow for user interaction to prevent unwanted changes I suppose. >From other threads: Cross-platform SerialPortIO Micro-threads :) GUI Front-end to Py2EXE to make inclusion/exclusion of items easier Enjoy all, Mike -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Guido van Rossum Sent: June 29, 2001 12:18 To: python-list at python.org Subject: Re: Not enough Python library development [was PEP scepticism] Roman Suzi writes: > Is there a formal TODO list of the libraries and respective priorities? No, although there's a PEP for small feature requests (PEP 42). If you want to start making a list of missing libraries and submit a PEP, please do! I'm sure many people will want to contribute. ... From spam_kill.guse at hobbiton.org Tue Jun 5 09:43:19 2001 From: spam_kill.guse at hobbiton.org (goose) Date: Tue, 05 Jun 2001 13:43:19 GMT Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3B1B1825.8109BA83@lmf.ericsson.se> Message-ID: <3b1ce1f7.5642@bolder.com.co.za> Attila Feher merely scratched his head and went: > I'd like to see you to make a full featured GUI which runs on Windows > (all the 5+1 versions in use plus CEs) _and_ all Unices with all Window > Managers with no incompatibilities (clipboard etc.). They are simply this can be done as long as cross-platform means that actuall PC's will be used, if u tell me make my sw run on ce, then u might as well ask me to run it on toasters ... tcl/tk, i have found, works quite well on all the PC's i have had occasion to use (not including the palm devices, ce, and various personal organisers - those are not PC's) - will not work on win3.1, though, as someone has yet to port it (correct me if i am wrong) regards, -- goose ----- From aleaxit at yahoo.com Wed Jun 20 09:11:29 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 20 Jun 2001 15:11:29 +0200 Subject: Loading select queries into objects References: <9gpgde02rc6@enews1.newsguy.com> Message-ID: <9gq7ek0lpa@enews1.newsguy.com> "Graham Ashton" wrote in message news:xKYX6.1456$h45.9220 at news.uk.colt.net... > In article <9gpgde02rc6 at enews1.newsguy.com>, "Alex Martelli" > wrote: > > > Assuming you mean "on the current instance", there is absolutely no need > > for eval & friends -- the following will do just fine: > > > > def applydict(self, adict): > > for name, value in adict.items(): > > try: method = getattr(self, name) > > except AttributeError: print "Warning: no method",name else: > > method(value) there should be a linebreak after ',name' and before 'else:' -- sorry if the error was in my post, can't understand how it got there... > That's much cleaner, thanks. I'm struggling my way around the standard > library at the moment trying to find out how things should be done; > pointers like that are incredibly useful, especially for people who are > used to doing it a different way in a different language (like me). I agree, and the best connection of such pointers about the standard Python library is IMHO Fredrik Lundh's "Python Standard Library", just published by O'Reilly. It doesn't _substitute_ for Python's excellent online docs (what would be the point?) but it _supplements_ them with 270 pages of brief, colloquial-tone discussion and, mostly, short, effective examples of "how to *USE*" each module in the library. Alex From mal at lemburg.com Tue Jun 19 15:51:53 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 19 Jun 2001 21:51:53 +0200 Subject: String encode() method error handling options? References: Message-ID: <3B2FAD59.BA1687B6@lemburg.com> Grant Edwards wrote: > > The documentation for the encode() method mentions that the > default action for an encoding error is to raise ValueError. > The other options are 'ignore' and 'replace'. Can anybody > point me to documentation on or examples of the ingore and > replace options? The 'ignore' option will simply drop the character which cannot be encoded (e.g. because there is no mapping for the Unicode character in the chosen character set), the 'replace' option will currently always write a '?' instead of the Unicode character which caused the trouble. > When doing encode('latin-1') on unicode strings received via > COM/MAPI, I occasionally get a value error. When I look at the > message with Outlook there's nothing obviously strange about > the text. I forgot to save an example that causes the error, > so I don't currently have any way to experiment. Latin-1 is not the same as the default Windows encoding which typically is one of the cp125x encodings depending on your locale. That could be the cause of the ValueErrors you are seeing. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From qrczak at knm.org.pl Fri Jun 8 12:12:56 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 8 Jun 2001 16:12:56 GMT Subject: Why no 'elif' in try/except? References: <3B1A06EE.F484930A@snakefarm.org> <3B1A29DE.9876770D@accessforall.nl> <3B203458.835AE30F@cosc.canterbury.ac.nz> Message-ID: Fri, 08 Jun 2001 14:11:36 +1200, Greg Ewing pisze: > The convenience is worth the extra complexity in this case, because > it's quite common to have long sequences of nested if-elses, and > without it you'd quickly run out of screen width. > > But I can't imagine long sequences of nested try-except-else-ifs > turning up very often... Neither do I. What about consistency? (I would still prefer 'else if' to 'elif'. Some languages use 'elsif' and I can't remember which is where.) -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From dalke at acm.org Tue Jun 26 17:21:39 2001 From: dalke at acm.org (Andrew Dalke) Date: Tue, 26 Jun 2001 15:21:39 -0600 Subject: PEP 260: simplify xrange() References: Message-ID: <9hav58$qjr$2@slb4.atl.mindspring.net> Guido van Rossum wrote > In particular, these behaviors will be dropped: > > x[i:j] (slicing) This is the only one on the drop list I might think is useful. However, I just searched our code and all uses of 'xrange' were in the context 'for i in xrange(' so we've no need for any other features. Plus, implementing xrange is so simple that upon consideration now I won't even claim that slicing might be useful. > x*n, n*x (sequence-repeat) > cmp(x1, x2) (comparisons) > i in x (containment test) > x.tolist() method > x.start, x.stop, x.step attributes Never used any of these features and never needed them. Andrew dalke at acm.org From fgeiger at datec.at Sat Jun 2 13:22:25 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Sat, 2 Jun 2001 19:22:25 +0200 Subject: What does x[:]=[4,5,6] mean? Message-ID: <9fb7cu$lq6$1@newsreaderg1.core.theplanet.net> In site.py I saw sys.path[:] = L What does this mean? Why is the '[:]'? Why not simply sy.path = L ? Best regards Franz P.S.: The whole sequence is: # This ensures that the initial path provided by the interpreter contains # only absolute pathnames, even if we're running from the build directory. L = [] for dir in sys.path: dir = makepath(dir) if dir not in L: L.append(dir) sys.path[:] = L del dir, L From kamikaze at kuoi.asui.uidaho.edu Tue Jun 19 17:55:37 2001 From: kamikaze at kuoi.asui.uidaho.edu (Mark 'Kamikaze' Hughes) Date: 19 Jun 2001 21:55:37 GMT Subject: Any other Python flaws? References: Message-ID: 14 Jun 2001 14:27:59 -0400 in , Andrew Kuchling spake: > I was updating my page of possible Python design flaws > (http://www.amk.ca/python/writing/warts.html) last night to take 2.1 > into account. 2.1's nested scoping fixes one major wart, and the > other major one, the type/class dichotomy, might get fixed in 2.2 if > the descr-branch in CVS turns out well. (It's neat that the two > largest ones may both get fixed before 2001 is out.) > > That leaves the remaining warts as minor wibbling about 'do' > statements, print >>, and the like. Are there any other flaws that > should be added? You missed one of the main warts of raw strings: You can't have a single \ at the end of a raw string: >>> r'foo\' File "", line 1 r'foo\' ^ SyntaxError: invalid token >>> r'foo\\' 'foo\\\\' Supporting a 'super' keyword that just referred to the first superclass would solve the base class problem most of the time, unless other people are making really heavy use of multiple inheritance and haven't mentioned it to me. Having to do it "by hand" on what I presume are only a few cases is preferable to having to do it by hand every time as we currently do. Integer division is fine and wonderful as-is, and any change to the / operator would break an amazing amount of code. Adding a new 'div' operator that does fp division if necessary would be okay, though. I dunno what that gains you over doing 7.0 / 2 or 7 / 2.0 or a/float(b), though. Yes, it's a programmer-ism. But you know, mostly programmers use Python. The lack of do...while or repeat...until is of little interest to me, but named blocks or some way of doing a break/continue from multiple nested loops would be really nice. This is mainly an issue for me because I have to do a fair amount of: for y in xrange(size): for x in xrange(size): ...stuff... if condition: breakflag=1 break if breakflag: break But I mostly wrap these loops inside methods and just return from the inner loop, so it just forces me to write smaller methods, which is good style anyway. -- Mark Hughes "I will tell you things that will make you laugh and uncomfortable and really fucking angry and that no one else is telling you. What I won't do is bullshit you. I'm here for the same thing you are. The Truth." -Transmetropolitan #39 From senux at senux.com.NOSPAM Mon Jun 11 07:38:32 2001 From: senux at senux.com.NOSPAM (Brian Lee) Date: Mon, 11 Jun 2001 11:38:32 GMT Subject: [wxPython] layout manager? Message-ID: <3B24ADE9.99D61FEE@senux.com.NOSPAM> Hi? I'm a newbie at wxPython and this is wxPython specific question. Is there any examples of controlling window layout in wxPython? I read some docs on http://wxpython.org/ but I don't understand it. And the short examples in the docs do not work. More examples on web? What I actually want is to control size of component in a window. If user resize the window, the component in the window should be resized. I think setting a static value for position and size is not good for my program. Sorry for short English and I hope my thought is in my article. - Brian,. From new_name at mit.edu Tue Jun 12 15:16:30 2001 From: new_name at mit.edu (Alex) Date: 12 Jun 2001 15:16:30 -0400 Subject: All functions from self and inherited classes References: Message-ID: > And a dir(self.__class__) returns methods, but only methods defined in > B. Someone posted this code here ages ago. It should give you all of B's methods, I guess. def unique(seq): out = [] if len(seq): out.append(seq[0]) for i in range(1,len(seq)): if seq[i] != seq[i-1]: out.append(seq[i]) return out def megadir(obj = globals()): ldir = [] for b in getattr(obj, '__bases__', []): ldir.extend(megadir(b)) if type(obj) == types.InstanceType: ldir.extend( megadir(obj.__class__) ) ldir.extend(dir(obj)) ldir.sort() return unique(ldir) HTH. Alex. From tim.one at home.com Wed Jun 6 13:33:46 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 6 Jun 2001 13:33:46 -0400 Subject: floating point in 2.0 In-Reply-To: <3B1E50C9.7D2509F4@shore.net> Message-ID: [Michael P. Soulier] > In Python 1.5.2, I could do this: > > good = (0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0) > > I could then get back exactly this when I output the value > of "good". However, with Python 2.0, I get this: > > > > >>> good > > (0.0, 0.10000000000000001, 0.20000000000000001, 0.29999999999999999, > > 0.40000000000000002, 0.5, 0.59999999999999998, 0.69999999999999996, > > 0.80000000000000004, 0.90000000000000002, 1.0) [Kurt B. Kaiser] > from sys import displayhook > def nogeekydisplay(x): > print x > > sys.displayhook = nogeekydisplay > > Put that in your .pythonrc config file so it will load at startup. That particular code doesn't work, and if it worked as intended wouldn't address Michael's complaint. First, code that works as intended: import sys def nogeekydisplay(x): print x sys.displayhook = nogeekydisplay Then for why it doesn't address Michael's complaint: >>> .1 0.1 >>> [.1] [0.10000000000000001] >>> That is, while it does effectively replace repr() with str(), the builtin container types (list, tuple, dict) pass repr() down to the things they contain, regardless of whether str() or repr() was applied to *them*. Afraid it takes more work than "it should" to worm around this. BTW, people who want to play with the display hook should start with a better simulation of the system display hook regardless, like: import sys, __builtin__ def default_display_hook(x): if x is None: return print repr(x) __builtin__._ = x sys.displayhook = default_display_hook Then replacing "print repr(x)" with "pprint.pprint(x)" is a variation I often use. From mal at lemburg.com Fri Jun 8 11:01:46 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 08 Jun 2001 17:01:46 +0200 Subject: Compiling Python2.1 under HP-UX with threads ? References: Message-ID: <3B20E8DA.7253E86F@lemburg.com> Philipp Jocham wrote: > > On Thu, 07 Jun 2001 20:08:00 +0200, M.-A. Lemburg wrote: > >I am having trouble compiling Python 2.1 under HP-UX 11.00 > >with threads. > > > >Even though the compile runs fine (ok, termios and _curses fail > >to compile, but I don't need those), the test suite fails to > >pass all tests which try to use threads. The error I get is: > > > > ThreadError: can't start new thread > > > >Does anyone have hints what I could try to debug this ? > > Does the configure process detect > __pthread_create_system in -lpthread ? > > I've compiled it with gcc-2.95.2 and it works > out of the box (besides termios and _curses). I'll check that. Thanks for the tip. About termios and _curses: these should probably be fixed to work on HP-UX too... in case someone needs them. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From aleaxit at yahoo.com Thu Jun 14 17:49:14 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 23:49:14 +0200 Subject: Any other Python flaws? References: <3B2914A0.6010902@erols.com> <9gb6ap$p10$1@news.mathworks.com> Message-ID: <9gbbe9015q8@enews1.newsguy.com> "jcm" wrote in message news:9gb6ap$p10$1 at news.mathworks.com... > Edward C. Jones wrote: > > > It follows from some basic concepts of Python that > > "array = ([0] * 10) * 10" > > does not behave as usually intended. This is a well-known "dark > > corner" of Python; a place it is simply best to avoid. > > For this example, what would you say people would usually expect? Presumably the same as array = [0]*100 but then, this *IS* what they get. Maybe Edward meant a = [[0]*10]*10 with the "well-known dark corner" that now a[i] is a[j] for all i and j in range(10), as opposed to, say, a = [[0]*10 for i in range(10)] where the 'is' doesn't hold (except when i is j:-). But I'm not sure why "it's simply best to avoid" the simple semantics that, for any expression, []*n gives me a list with n references to the SAME object (result of just ONE evaluation of ), while [ for i in range(n)] evaluates the expression n separate times (whether that gives n references to the same object being therefore strictly dependent on the expression). Alex From ajm at enteract.com Wed Jun 27 17:59:20 2001 From: ajm at enteract.com (Alan Miller) Date: Wed, 27 Jun 2001 16:59:20 -0500 Subject: Windows Printing using win32print References: Message-ID: Geoffrey Gerrietts (geoff at homegain.com) wrote: >The original question, though, asked about printing using win32print, when >in fact his output was not printer-ready -- it was a simple text string he >was trying to write to the printer. Consequently, even though he's asking >about win32print, win32print is not the most effective way to manage his >output -- unless he speaks PostScript or HPL (isn't that what HP printers >speak? I forget...) more fluently than he speaks Python, which I'm doubting. Right, but any printer that I've run into (plotters are an exception) can take a raw ASCII data stream and print it as plain text. Postscript or PCL are only needed if you want something other than fixed-width Courier. ajm From BgPorter at NOartlogicSPAM.com Sun Jun 3 23:07:30 2001 From: BgPorter at NOartlogicSPAM.com (Brett g Porter) Date: Mon, 04 Jun 2001 03:07:30 GMT Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> Message-ID: "Harald Hanche-Olsen" wrote in message news:pcolmn9y349.fsf at thoth.home... > + Tim Churches : > > | No experience (I am in a similar situation to you wrt UML), just > | some advice: don't buy the O'Reilly book 'UML in a Nutshell' - it is > | the only O'Reilly title I have encountered which is truly woeful > | (most are quite good). > > Hmm. Has it occured to you that this might be a reflection on UML > rather than on the book per se? Don't know about that -- I bought it (unseen) a week or so ago since I've never had bad luck with a book from O'Reilly. Until now. Now, I enjoy reading dense prose. But this is one of those books where I know less after reading a page than I did beforehand. It's about as clear as postmodern literary criticism. This is not a book for reading, this is a book for lying down and avoiding. BgP From opengeometry at yahoo.ca Sat Jun 23 17:42:42 2001 From: opengeometry at yahoo.ca (William Park) Date: Sat, 23 Jun 2001 17:42:42 -0400 Subject: the indentaion for grouping thing In-Reply-To: <3b34de9a$1_2@anonymous>; from anonymous@anonymous.anonymous on Sat, Jun 23, 2001 at 11:26:21AM -0700 References: <3b34de9a$1_2@anonymous> Message-ID: <20010623174242.A504@node0.opengeometry.ca> On Sat, Jun 23, 2001 at 11:26:21AM -0700, Anonymous wrote: > I want braces I guess, or some other short delimiter, e.g.: > > if 1: { > if 0: { > print '1', > print '2', > print '3', > } > print '4', > } > > or, how about: > > (if 1: > (if 0: > print '1', > print '2', > print '3',) > print '4',) I personally wouldn't mind 'endif', 'endfor', or 'endwhile' to finish off the loop, which also gives me chance to make short comment after the keywords. But, I can do that without them. Braces interrupts the flow of reading and writing. = 8. Lets drop this silly issue! -- William Park, Open Geometry Consulting, 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From gardner at cardomain.com Thu Jun 14 14:13:03 2001 From: gardner at cardomain.com (Jonathan Gardner) Date: Thu, 14 Jun 2001 11:13:03 -0700 Subject: VI References: <3B278900.5828FB59@Lugoj.Com> Message-ID: <9gaunm$mth$3@brokaw.wa.com> James Logajan wrote: > Pilgrim wrote: >> >> Can someone tell me what "vi" is for a text editor to work with python? >> Where can I get this? > > "vi" is the first and last word in visual editors. Every editor written > before or after it are irrelevant. ;-) > Amen. From jm7potter at hotmail.com Wed Jun 27 08:32:52 2001 From: jm7potter at hotmail.com (Joe Potter) Date: Wed, 27 Jun 2001 08:32:52 -0400 Subject: newbie with major "lambda" problem (perhaps a scope problem as well) References: <3B38C3E7.A1F5C394@sage.att.com> Message-ID: On Tue, 26 Jun 2001 17:18:31 GMT, Garry Hodgson wrote: >Joe Potter wrote: >> >> On Tue, 26 Jun 2001 16:09:06 GMT, "Rainer Deyke" wrote: >> >> >"Joe Potter" wrote in message >> >news:j5ahjtkfmf32lkqtap0q1u6rig385d7b5i at 4ax.com... >> >> # the "button" below works like a champ !! >> >> #Button(root, text='Fetch', >> >> #command=(lambda v=vars: fetch(v))).pack(side=LEFT) >> >> >> >> # the "button" below does not do anything ?????? >> >> Button(root, text='Fetch', command=(fetch(vars))).pack(side=LEFT) >> > >> >Of course this doesn't work. It calls 'fetch(vars)', and passes the result >> >to 'Button'. Use the lambda, that's what it's there for. Or use one of the >> >'curry' alternatives (see archives). >> >> My question is *why* the lambda is allowed to call the perfectly defined function >> fetch, but a direct call of fetch is not. >> >> In other words --- I already knew that I had to use lambda, but I do not know why! > >lambda is a special kind of function. it creates, on the fly, another, >un-named >function, and returns that as its value (much like def, but def also >binds the >function to a name). so the first (commented out) case above >sets command equal to a function, which will be called when the button >is clicked. >in the latter (non-working) case, you actually run your fetch function >when this code >is executed, and then bind whatever it returned to the command >variable. when you later >click your button, tkinter tries to use this value as a callback >funtion, and will fail. >i'm surprised you don't get an exception. > >--- Thanks Garry, That helped. Along with the other three fellow's words --- I am close to seeing it. Would you look at my reply to Chris Barker for another little code example along the same lines? If I can get that done --- and understood, I'll have it made. Thanks again, Joe From tim.one at home.com Tue Jun 5 19:44:04 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 5 Jun 2001 19:44:04 -0400 Subject: IDLE replacement? In-Reply-To: <3B1D43FF.71D53061@telocity.com> Message-ID: [Adonis] > ... > IDLE seems to crash on me everytime i attempt to create a thread and the > debug dumps all the code of IDLE at the same time locking the program > up. > > is it my code? or a bug in IDLE? It's more a problem with Tcl/Tk, and you'll find the same kind of problems trying to mix threads with many other GUI systems. You *can* mix threads with IDLE, but it requires great care: you have to make sure that "the main thread" is the only one that ever calls into Tk, or gets called back from Tk. Tk gets lost if any other thread talks to it. So, for example, you have to arrange for all stdout printing to be done only by the main thread (since Tk is actually in charge of drawing the pixels in the IDLE shell window, which is where stdout gets redirected). For example, this output: Thread 0 says 0. Thread 1 says 0. Thread 2 says 0. Thread 0 says 1. Thread 2 says 1. Thread 1 says 1. Thread 1 says 2. Thread 0 says 2. Thread 2 says 2. Thread 1 says 3. Thread 0 says 3. Thread 2 says 3. Thread 1 says 4. Thread 0 says 4. Thread 1 says 5. Thread 2 says 4. Thread 1 says 6. Thread 1 says 7. Thread 2 says 5. Thread 0 says 5. Thread 2 says 6. Thread 0 says 6. Thread 1 says 8. Thread 1 says 9. Thread 2 says 7. Thread 0 says 7. Thread 2 says 8. Thread 2 says 9. Thread 0 says 8. Thread 2 says Finished. Thread 1 says Finished. Thread 0 says 9. Thread 0 says Finished. Done. came from this program run under IDLE: from threading import Thread import Queue, time, random q = Queue.Queue() FINISHED_TOKEN = "Finished" class test(Thread): def __init__(self, id): Thread.__init__(self) self.id = id def run(self): for i in range(10): q.put((self.id, i)) time.sleep(random.random()) q.put((self.id, FINISHED_TOKEN)) N = 3 threads = [] for i in range(N): t = test(i) threads.append(t) t.start() count = 0 while count < N: tid, msg = q.get() print "Thread %d says %s." % (tid, msg) if msg == FINISHED_TOKEN: count += 1 threads[tid].join() print "Done." Note the use of a Queue object to let threads queue up printing requests for the main thread to deal with. From MarkH at ActiveState.com Thu Jun 14 22:28:45 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Fri, 15 Jun 2001 02:28:45 GMT Subject: Office's Access XP ODBC DBI from PythonWin References: <9ga6cd02m44@enews1.newsguy.com> Message-ID: <3B297318.9070506@ActiveState.com> Benjamin Schollnick wrote: > I don't mind that, I can understand where he was coming from... But > win32's ODBC code seems to work fine for our purposes, and should still > be developed....or maintained... It is. Contributions still trickle in and are always applied. I think I have personally used the module exactly once, so significant modifications are almost certainly not going to come directly from me... Mark. From objectway at divalsim.it Mon Jun 25 12:32:59 2001 From: objectway at divalsim.it (Nicola Musatti) Date: Mon, 25 Jun 2001 18:32:59 +0200 Subject: Newbie seeks help on case preserving substitutions Message-ID: <3B3767BB.A882F8@divalsim.it> Hi, I have a number of files which contain different variations of the same string, e.g. ECBASE ECBase ecbase Which I want to substitute with a different string, while preserving the original case, e.g. OWTEST OWTest owtest What I'm currently doing is search for the first string ignoring case, and substitute the second character by character according to the first string's case: for line in inFile.readlines(): matchRes = re.compile(oldString).search(line) if matchRes: found = 1 new = line[:matchRes.start()] for i in range(matchRes.start(),matchRes.end()): if line[i] in string.uppercase: new = new + string.upper(newString[i-matchRes.start()]) else: new = new + string.lower(newString[i-matchRes.start()]) new = new + line[matchRes.end():] I was wondering if there's a more compact way to do what I want. Thanks, Nicola Musatti From gmcm at hypernet.com Wed Jun 27 20:42:06 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 28 Jun 2001 00:42:06 GMT Subject: SocketServer crash on my machine References: <9hdpu1$o1h$1@troll.powertech.no> Message-ID: <90CDDC8DCgmcmhypernetcom@199.171.54.155> Syver Enstad wrote: >I was checking out the the SocketServer example in Mark Lutz rather >excellent book Programming Python 2 edition, >when [snip] > data = self.request.recv(1024) > File "", line 1, in recv >AttributeError: 'int' object has no attribute 'recv' The socket has already been closed. [more snippage] >class MyClientHandler(SocketServer.BaseRequestHandler): > def handle(self): > print self.client_address, now() > print self.request > time.sleep(5) > while 1: > data = self.request.recv(1024) > if not data: > break > self.request.send('Echo=>%s at %s' % (data, now())) > self.request.close() The code is wrong. It assumes that it is in charge of closing the socket (or that a closed socket will yield no data - which is just one way that you may find out a socket is closed). Different platforms show different behavior here (and behavior may be influenced by subtle timing issues, and whether or not the socket is blocking or non-blocking). I would guess that you got one "Echo=> ....", then the client receiving the echo shut down the socket, and you died on the 2nd recv. Always put send and recv within try: ... except (AttributeError, socket.error): ... - Gordon From danielk at aracnet.com Wed Jun 13 08:51:15 2001 From: danielk at aracnet.com (Daniel Klein) Date: Wed, 13 Jun 2001 05:51:15 -0700 Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> Message-ID: On 12 Jun 2001 08:39:37 -0700, thinkit wrote: >humans should use a power of 2 as a base. this is more logical because it >synchs with binary, which is at the very heart of logic--true and false. it is >more natural perhaps, to use decimal--but logic should, and will, win out. Are you a Vulcan or something? Live long and prosper, Dan :-) From res04o20 at gte.net Sun Jun 17 17:20:23 2001 From: res04o20 at gte.net (res04o20) Date: Sun, 17 Jun 2001 21:20:23 GMT Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? References: <3B2B60AD.942719AE@earthlink.net> Message-ID: Paul, In that case, I'll have to take another look. The Visual Python[1] could be of major interest. Thanks! Regards, Dave "Paul Prescod" wrote in message news:mailman.992809646.24580.python-list at python.org... > res04o20 wrote: > > > >... > > > > And lastly, ActiveState has announced "Visual Python". Only problem is, you > > gotta have MS .Net. (shudder) (Yet another implementation of Python. This > > time in C#. Another learning curve to be ultimately successful.) > > You are conflating two different things. Visual Python [1] and Python > .NET [2] are completely unrelated (but interoperable, of course) > > [1] http://aspn.activestate.com/ASPN/Downloads/VisualPython/ > [2] http://aspn.activestate.com/ASPN/NET/ > -- > Take a recipe. Leave a recipe. > Python Cookbook! http://www.ActiveState.com/pythoncookbook > From tomh at optiscan.com Thu Jun 28 02:28:28 2001 From: tomh at optiscan.com (Tom Harris) Date: Thu, 28 Jun 2001 16:28:28 +1000 Subject: Recursive functions Message-ID: Hi, I am very new to Python, and I am trying to get a recursive function working. The problem is that the function modifies one of its arguments, which is not a local copy of a variable (local to this stack frame of the function, like in call by value in C) but a reference to a variable owned by the function namespace, so changes to the variable are inherited by other calls to the same function. I tried copying the argument to a variable in the function body, but of course this suffers from the same problem. This is the idea, but the list just keeps on growing. def f(aList): ... aList.append(stuff) f(aList) What is the solution? Tom Harris, Software Engineer Optiscan Imaging, 15-17 Normanby Rd, Notting Hill, Melbourne, Vic 3168, Australia email tomh at optiscan.com ph +61 3 9538 3333 fax +61 3 9562 7742 This email may contain confidential information. If you have received this email in error, please delete it immediately,and inform us of the mistake by return email. Any form of reproduction, or further dissemination of this email is strictly prohibited. Also, please note that opinions expressed in this email are those of the author, and are not necessarily those of OptiScan Pty Ltd From scarblac at pino.selwerd.nl Fri Jun 1 01:59:35 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 1 Jun 2001 05:59:35 GMT Subject: Obsolesence of <> (fwd) References: Message-ID: Lulu of the Lotus-Eaters wrote in comp.lang.python: > It is very easy to read it as "is less than or greater than" on the > analogy of ">=" reading "is greater than or equal to." Since all Python > values can be compared, Alas, not anymore (complex numbers can't be compared). I checked some old code, and it seems I used != about as much as <> then. I used to program in Pascal and Java. Apparently I never thought about what to type, it just worked... that's a good thing :) Nowadays I seem to use != exclusively. -- Remco Gerlich From achim at zpr.uni-koeln.de Fri Jun 15 18:57:36 2001 From: achim at zpr.uni-koeln.de (Achim Gaedke) Date: Sat, 16 Jun 2001 00:57:36 +0200 (MET DST) Subject: Bug in expatreader... Message-ID: Hello! My intention is to write a recursive parser for nested data structures. In order to collect the data it is necessary to switch the contenthandler each step. This does NOT work for the character handler: This is my (lean) test program: import xml.sax.handler parser=xml.sax.make_parser() class second_ch(xml.sax.handler.ContentHandler): def startElement(self,name,attrs): print "start second" def endElement(self,name): print "end second" def characters(self,content): print "second: ",content.strip() class first_ch(xml.sax.handler.ContentHandler): def startElement(self,name,attrs): print "start first" self.second=second_ch() parser.setContentHandler(self.second) def endElement(self,name): print "end first" def characters(self,content): print "first: ",content.strip() first=first_ch() parser.setContentHandler(first) parser.parse('members.xml') and this is the xml file members.xml: a1b1a2 more is not necessary. This is the output with python2.0 and expat-1.95.2 python2.0 xml_test.py start first first: a1 start second first: b1 end second first: a2 end second After the first line the second content handler should get the characters! The second test is with python2.1 and expat1_1: python2.1 xml_test.py start first first: a1 start second first: b1 end second first: a2 end second the result is the same. What a pity. In expat reference it is stated, that changing of handler is possible and expected. I am running Redhat Linux 7.1 with self built python interpreters. Achim Gaedke, ZPR Weyertal 80, 50931 K?ln Tel: +49 221 470 6021 From tim.one at home.com Sun Jun 10 00:12:42 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 10 Jun 2001 00:12:42 -0400 Subject: extracting hex mant+exp from double? In-Reply-To: <2135894.0001544d.006@drn.newsguy.com> Message-ID: [thinkit] > python docs say floats are all doubles...which usually (i think > always) is the IEEE spec for 8-byte float. are there any routines > out there to extract the binary mantissa and exponent...or better > hexadecimal mantissa and exponent out of the float? i want to do > some statistics but don't want to use decimal. i know you can > access the 8 bytes with struct lib...then do some bit manipulations > to do the trick. has anybody done this already? Sorry, it's unclear what you want. How about you pretend the routine you want already existed, and give us a specific example showing exactly what it is you want this routine to accept as argument(s) and return as result(s)? It's not even clear to me that you really want to pick at the bits. Have you tried, for example, math.frexp? >>> import math >>> math.frexp(1.0) (0.5, 1) >>> math.frexp(2.**100) (0.5, 101) >>> math.frexp(.125) (0.5, -2) >>> That picks apart the mantissa and exponent in a useful way. If you then want, say, the mantissa as a 53-bit integer shown as a hex string, >>> math.frexp(.1) (0.80000000000000004, -3) >>> m = _[0] >>> m 0.80000000000000004 >>> m * 2L**53 7205759403792794.0 >>> long(_) 7205759403792794L >>> hex(_) '0x1999999999999AL' >>> From loewis at informatik.hu-berlin.de Thu Jun 7 07:41:12 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 07 Jun 2001 13:41:12 +0200 Subject: A question about MySQLdb and SSH References: Message-ID: Calishar writes: > I know that it is possible to use SSH to setup an ODBC connection to > the remote server. What I am wondering is if there is anything similar > using the MySQLdb library. Ideally it would not require setting up a > seperate SSH application (the application is for an end-user). The most recent MySQL versions offer support for OpenSSL. To use that, both client and server library need to be compiled with SSL support. MySQL will then attempt to switch to an SSL connection if both ends support it. By default, the identity of the server is trusted, and no client authentification is used. That means the connection is encrypted, but susceptible to a man-in-the-middle attack (ie. somebody could claim to be your MySQL server, and thus sneak the connection). For most purposes, this should be secure enough. MySQL 3.23.38 also offers a mysql_ssl_set call to set key, certificate, and certificate authority. MySQLdb does not support this API, but MySQL also offers to set the keys through a configuration file (on the client). However, it seems that the keys are not used, atleast not in MySQL 3.23.38. Hope this helps, Martin From meowbot at meowing.net Sat Jun 9 14:29:20 2001 From: meowbot at meowing.net (A Meowbot) Date: 09 Jun 2001 14:29:20 -0400 Subject: random References: <9fo9k50gl6@enews2.newsguy.com> <87snhblcx4.fsf@litterbox.meowing.net> <9fqmog$m7a$1@panix3.panix.com> Message-ID: <87u21pjym7.fsf@litterbox.meowing.net> aahz at panix.com (Aahz Maruch) wrote: > Does it go to eleven? It goes to 1.1000000000000001, for that extra push over the cliff. From bokr at accessone.com Sat Jun 2 21:01:16 2001 From: bokr at accessone.com (Bengt Richter) Date: Sun, 03 Jun 2001 01:01:16 GMT Subject: Embedded 'C' problem? References: Message-ID: <3b195197.147691268@wa.news.verio.net> On 2 Jun 2001 00:09:22 -0700, samschul at pacbell.net (Samuel Schulenburg) wrote: >Given the following string: >EB70:|30 E8 8A 17 00 00 66 89 04 9F 83 C4 08 43 3B 5C >0.....f......C;\ > >and using the following 'C' wsprintf() function to build ucPyString >causes a print format error. > >wsprintf(ucPyString,"print \"\"\"%s\"\"\"",ucMsgStr); >PyRun_SimpleString(ucPyString); > >ERROR: > > File "", line 1 >print """EB70:|30 E8 8A 17 00 00 66 89 04 9F 83 C4 08 43 3B 5C >0.....f......C;\""" > > ^ >SyntaxError: invalid token > >The problem is final "\" in the origional string is interfering with >the final tripple quote forming a \""" which is interprited as an >escape sequence. > Looks to me like you'd have a problem with """ embedded in ucMsgStr too. Apparently what you want is a python statement which when executed will put exactly the original characters of ucMsgStr to stdout. So the question is how to represent the string when you don't know what it contains. Any escape or quotes characters could potentially interfere. Also if you have special characters OTTOMH, [no warranty, not checked!] I'd try something like the following to escape double quotes and backslashes: #include ... #define UCPYSTRINGMAX -- whatever your buffer size, min 40 for err msg unsigned int i = wsprintf( ucPyString,"print \"\"\"" ); for(const char *p= ucMsgStr; *p; ++p ){ if( i >= UCPYSTRINGMAX-4-3-1 ){ //4hex+3"'s+term i = wsprintf( ucPyString,"print \"\"\"Insufficient Buffer\"" ); break; } if( !isprint(*p) ){ i += wsprintf( ucPyString+i,"\\x%02x",*p ); // hex if weird } else { if( *p == '\\' || *p == '"' ){ // escape dquote and backslash i += wsprintf( ucPyString+i,"\\%c",*p ); // escaped } else { i += wsprintf( ucPyString+i,"%c",*p ); // plain } } } i += wsprintf( ucPyString+i, "\"\"\"" ); // indent and \n up to you ... wsprintf is kind of overkill, but if you need to change to wide chars maybe it's easier than leaner string routines. Alternatively you could brute force escape every character in hex. Either way MAKE SURE YOU HAVE THE SPACE for worst case expansion if you don't know what's coming. The raw string format would still leave you with an escaping problem somewhere, UIAM. >My question is. How can I generate a format specifier so I can have a >ucMsgStr that contains any printable characters, and does not interfer >with the Python print function? > It's not the print function per se, it's the interpreter reading the print statement source that you've generated, and interpreting the string literal in it to make the string constant that becomes the argument for print when it executes. It doesn't like the generated string syntax. If you put "s=" in place of "print" I would expect the same problem. From ibarona at tid.es Thu Jun 14 12:43:15 2001 From: ibarona at tid.es (Isaac Barona) Date: Thu, 14 Jun 2001 16:43:15 GMT Subject: I used to like Python but... References: <25b2e0d9.0106071146.565bf774@posting.google.com> Message-ID: <3b28e993.2024983799@tid> On 7 Jun 2001 12:46:39 -0700, alankarmisra at hotmail.com (gods1child) wrote: >Now I think I'm just plain in love. I wuz reading this book on OOP >concepts which used a classic problem of chess (described below) to >illustrate the power of 'thinking OOP'. It gave a 'pseudocode' for a >possible solution to the problem. Converting the pseudocode to Python >was like typing the darn pseudocode! Man i love this language. Here's >the problem and the code for your amusement and one more reason to >pray for Python becoming king of the hill: > >The problem is to place 8 queens on a chess board such that no queen >can attack another. The solution given below takes an 'OOP' approach >where each queen queries its immediate neighbor (the one that came >before) as to where it can place itself in a specific cell. If the >neighbor accepts, it in turn politely asks its neighbor if this new >entrant should be allowed to stand in that cell until someone says >'this means war!' and the poor new entrant starts looking for a new >home. This way the queens find the acceptable solution by talking to >each other instead of Mr Garry Kasparov looking over the chess board >making decisions on behalf of each queen. BTW, i'm not a science grad >so i apologize if this is like the oldest problem in the world > ># 8 queens ># The problem is to place 8 queens on a ># chess board such that no queen can attack ># another > >class Queen: > def __init__(self, column, queen): > self.row = 1 > self.column = column > self.neighbor = queen > > def findSolution(self): > while (self.neighbor and \ > self.neighbor.canAttack(self.row, self.column)): > if(not self.advance()): > return 0 > return 1 > > def advance(self): > if(self.row < 8): > self.row += 1 > return self.findSolution() > > if(self.neighbor and not self.neighbor.advance()): > return 0 > > self.row = 1 > return self.findSolution() > > def canAttack(self, testRow, testColumn): > if self.row == testRow: > return 1 > > columnDifference = testColumn - self.column > if ((self.row + columnDifference) == testRow) or \ > ((self.row - columnDifference) == testRow): > return 1 > > if self.neighbor: > return self.neighbor.canAttack(testRow, testColumn) > > return 0 > > def getPosition(self, cells): > if self.neighbor != None: > self.neighbor.getPosition(cells) > cells[self.row-1][self.column-1] = 'X' > >lastQueen = None >for i in range(1,9): > lastQueen = Queen(i, lastQueen) > lastQueen.findSolution() > >cells = [] >for i in range(0,8): > cells.append(list('O'* 8)) > >lastQueen.getPosition(cells) >print '\n\n' >for i in range(0,8): > for j in range(0,8): > print cells[i][j], > print From johnroth at ameritech.net Wed Jun 13 00:16:24 2001 From: johnroth at ameritech.net (John Roth) Date: Tue, 12 Jun 2001 21:16:24 -0700 Subject: How to write Regression Test scripts for Tkinter Message-ID: How do I go about writing a unit test or regression test script for Tkinter? The unittest module only handles non-gui classes. I'm sure somebody has done it. It has to be possible - Google found a comment on the [incr Megawidgets] project that they had borrowed Osterhout's process for doing regression tests, but I have absolutely no clue as to how he did it, or if it can be ported to Python. Any pointers would be appreciated. John Roth From malcolm at commsecure.com.au Wed Jun 27 00:41:52 2001 From: malcolm at commsecure.com.au (Malcolm Tredinnick) Date: Wed, 27 Jun 2001 12:41:52 +0800 Subject: PEP 260: simplify xrange() In-Reply-To: <3B39480C.F4808C1F@Lugoj.Com>; from JamesL@Lugoj.Com on Tue, Jun 26, 2001 at 07:42:20PM -0700 References: <3B39480C.F4808C1F@Lugoj.Com> Message-ID: <20010627124152.B7273@Vetinari.home> On Tue, Jun 26, 2001 at 07:42:20PM -0700, James Logajan wrote: > Design mistakes one has made do tend to weigh on one's soul (speaking from > more than two decades of programming experience) so I understand the primal > urge to correct them when one can, and even when one shouldn't. So although > I'm quite annoyed by all these new-fangled gimmicks being added to the > language (i.e. Python generators being added to solve California's power > problems) I have no problem with xrange being fenced in. (I find the very > existence of the PEP process somewhat unsettling; there are now thousands of > programmers trying to use the language. Why burden them with insuring their > programs remain compatible with yet-another-damn-set-of-proposals every > year? PEP-6 partly helps that. Plus, any changes that would involve backwards compatibility get debated to death both here, on python-dev and on specialised lists. > Or worse: trying to rewrite their code "more elegantly" using all the > latest gimmicks. Protecting programmers from poor time management is not an excuse to stop improving the language. :-) > Speaking of "generators", I just want to say that I think that "generator" > makes for lousy terminology. If I understand correctly, "generators" are > coroutines that have peer-to-peer synchronized messaging (synchronizing and > communicating at the "yield" points). To my mind, "generators" does not > evoke that image at all. Assuming I understand it in my early senility.... Each call to the function generates a new value (and I think that's how I will teach generators to new programmers; not as peer-to-peer synchronized coroutines :-) ). Each to their own, I suppose, but it makes sense to me. Cheers, Malcolm -- I'm not nearly as think as you confused I am! From mwh at python.net Fri Jun 22 06:12:44 2001 From: mwh at python.net (Michael Hudson) Date: 22 Jun 2001 11:12:44 +0100 Subject: namespace issue? References: <87k825ljrz.fsf@elbereth.ccraig.org> <9gts54$bv0$1@nntp6.u.washington.edu> <87r8wd2hoh.fsf@cecilia.trollope.org> Message-ID: Michael Powe writes: > Apparently so. I'm used to C, in which any return value that is not > positive is false. In which universe? Cheers, M. -- "Well, the old ones go Mmmmmbbbbzzzzttteeeeeep as they start up and the new ones go whupwhupwhupwhooopwhooooopwhooooooommmmmmmmmm." -- Graham Reed explains subway engines on asr From grante at visi.com Thu Jun 21 13:47:21 2001 From: grante at visi.com (Grant Edwards) Date: Thu, 21 Jun 2001 17:47:21 GMT Subject: String encode() method error handling options? References: Message-ID: In article , M.-A. Lemburg wrote: >Latin-1 is not the same as the default Windows encoding which >typically is one of the cp125x encodings depending on your locale. >That could be the cause of the ValueErrors you are seeing. It's those stuped MS "smart quotes" that cause the problem. -- Grant Edwards grante Yow! I don't know WHY I at said that... I think it visi.com came from the FILLINGS inmy read molars... From ullrich at math.okstate.edu Tue Jun 5 10:41:47 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Tue, 05 Jun 2001 14:41:47 GMT Subject: random References: Message-ID: <3b1ced02.4660375@nntp.sprynet.com> On Sun, 3 Jun 2001 18:14:47 -0400, "Tim Peters" wrote: >[David C. Ullrich] >> ... >> Not that readers are likely to be reading carefully enough that it's >> going to matter, but just for the sake of telling no lies: I put >> my finger on what was bothering me about what I said here. >> It's not true that the sequence of bits of Omega is recursively >> enumerable. What's true (assuming that the N-th bit is 1 if the >> N-th program halts and 0 otherwise) is that the sequence of N >> for which the N-th bit is 1 is recursively enumerable. The >> set of N for which the N-th bit is 0 is _not_ recursively >> enumerable (and hence the sequence of bits of Omega is not >> recursively enumerable.) > >It's the "assuming that the N-th bit is 1 [iff] the N-th program halts" >that's off. Omega is the probability that "a random" program halts, and it >won't take long to figure out that "N'th-bit = halts(N-th program)" doesn't >work for that (e.g., if the 0'th program happens to halt, that would imply >the halting probability is >= 1/2 across all programs -- but the 0'th >program isn't generally that smart ). Sorry to reply three times - there's a fourth one coming soon, I think. Story so far: Just saying that Omega is the probability that a random program terminates does _not_ show that it's not true that the n-th bit is 1 iff the n-th TM halts. I showed that this does not imply that in my first reply. Now, in my first reply I was under the wrong impression about how Chaitin _did_ define "random program", so as I pointed out in second reply the comments I made about what his Omega can and cannot be aren't right. But it seems to me that I conceded too much. It seems to me today that even knowing that Chaitin's definition of "random program" is "we have a syntax allowing a program to know when it's complete. So we define a random program like so: The interpreter asks for a bit of the program, one bit at a time. The system delivers random bits. When the interpreter sees we have a valid program then that's our random program - now Omega is the probability that this random program halts" is not enough to draw his conclusions. They actually depend on the specific syntax he's using to decide when a program is complete and the syntax and semantics involved in defining whether that program halts. One can invent a system that constructs random programs one bit at a time just like Chaitin does, which has the property that programs know when they're complete, and for which defining "random program" by asking for one random bit at a time leads to a notion of "random program" precisely equivalent to what I was using in the first reply (at least for definable orderings.) I'm gonna check a few details. David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From tim.one at home.com Sat Jun 2 17:00:09 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 2 Jun 2001 17:00:09 -0400 Subject: Against PEP 240 In-Reply-To: <9fbeeh$nor$1@panix6.panix.com> Message-ID: [Roman Suzi] > This said, what is the right way to deal with>currencies in Python > right now? [Aahz] > Tim Peters's FixedPoint.py: > > > > You *probably* want to set the precision to three or four places > so that rounding errors don't propagate. Hmm. It's important to note that + and - on FixedPoints never suffer rounding errors. Add up, say, a million dollars-and-cents FixedPoint quantities each of precision 2, and the computed result is *exactly* correct. The problems with using binary f.p. in "the naive" way for financial calcuations only start with that most dollars-and-cents inputs can't be represented exactly; subsequent additions are also subject to rounding errors; FixedPoint suffers neither problem. From tim.one at home.com Sun Jun 3 14:51:29 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 3 Jun 2001 14:51:29 -0400 Subject: random In-Reply-To: <9fcu3601vet@enews2.newsguy.com> Message-ID: [Nick Perkins] > Chaitan's work as giving an algorithm for producing a 'truly' random > number. [Alex Martelli] > Chaitin. I point it out because you spell this "Chaitan" in a few more > places further on. My fault! Nick was replying to me, and just aped my misspelling. i-guess-spelling-is-inherently-randum-too-ly y'rs - tim From steven at haryan.to Thu Jun 7 03:52:36 2001 From: steven at haryan.to (Steven Haryanto) Date: Thu, 07 Jun 2001 14:52:36 +0700 Subject: WHY is python slow? Message-ID: <4.3.2.7.2.20010607144657.042f8328@bdg.centrin.net.id> Although it is generally accepted that Python is slower than Java/Perl/Ruby, a layman like me would be curious to know why exactly this is so. In other words, why is the implementation of a language like Ruby (which is on par with Python in terms of 'everything is an object', strong reflection, dynamic nature). My first guess would be the ubiquitous use of dictionaries? Steve http://stevne.haryan.to/ From gmcm at hypernet.com Wed Jun 20 17:35:02 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 20 Jun 2001 21:35:02 GMT Subject: Suggested amendment to PEP 255 (fwd) References: Message-ID: <90C6B648Agmcmhypernetcom@199.171.54.194> Dr. David Mertz wrote: >One more non-vote for a new spelling of "generator." Despite >protestations to the contrary by the timbot, I see the very subtle and >late-in-the-definition-body use of 'yield' as a train wreck waiting to >happen. Never mind newbies, I am certain that *I* would stumble over >the difference between generators and (real) functions all the time. And I'm pretty sure you're underestimating yourself. *When* might you stumble over this? In writing one? No, you have to understand "yield" and the iterator protocol before you write one, and spelling it "generator" neither helps nor hinders in that. In figuring out what's going on in a traceback? Not for long (and not likely more than once), because the traceback will already tell you that you're in the next method of an iterator, not in a "plain" function call. In random sampling of code, looking for interesting functions to call? I just did that on the standard lib, and came up with: copy_reg.pickle_complex imaplib.IMAP4._get_response random.weibullvariate my-toolbox-is-immeasurably-enriched--ly y'rs - Gordon From daniel.dittmar at sap.com Tue Jun 26 12:31:20 2001 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Tue, 26 Jun 2001 18:31:20 +0200 Subject: Mutable Strings? References: Message-ID: <9hadcr$fhi$1@news1.wdf.sap-ag.de> > Java has provided a StringBuffer class that is > basically a mutable string. Allowing you to append, > insert etc without creating a new object. Use module StringIO or rather it's faster cousin cStringIO. Daniel From emile at fenx.com Fri Jun 8 11:00:24 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 8 Jun 2001 08:00:24 -0700 Subject: Catching Errors References: <3B20E042.DA0AF3C1@usa.net> Message-ID: <9fqpii$5mk9n$1@ID-11957.news.dfncis.de> If you want to capture error output to a file, you can also try: c:\> python errors-catch.py 2>errors.txt -- Emile van Sebille emile at fenx.com --------- "mixo" wrote in message news:3B20E042.DA0AF3C1 at usa.net... > > How can I catch errors that I are usually written to standard output? > For example , say I have an error in my code, I would like to to have > the ouput written to a file.. The following is what is written to > standard output : > ------------------------------------------------- > Traceback (innermost last): > File "errors-catch.py", line 24, in ? > print "hello world! s" %test > TypeError: not all arguments converted > ----------------------------------------------- > due to the error in the statement : > print "hello world! s" %test # "s" should be "%s" > > The idea is, I want to simply write it (the error )to a file ! > (and I would n't mind as well knowing what the errors is- > even if its just an error code) > > From m.faassen at vet.uu.nl Fri Jun 1 18:49:48 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 1 Jun 2001 22:49:48 GMT Subject: Why isn't Python king of the hill? References: Message-ID: <9f966c$g46$1@newshost.accu.uu.nl> Geoffrey Gerrietts wrote: [description of a large scale Python/Zope system] > I think that answers the question without getting me in trouble? > :) That's clear, thank you. I'm interested in moving business logic out of Zope myself to do better MVC stuff, though another approach I'm taking is to to create more general Python/Zope components that help make the business logic so short and explicit you don't need lots of code for that anymore. :) I'm not saying this approach is *working*; I'm just saying I tend to think in that direction; split out abstractions from the application into generic external components so the actual business logic can be 'smaller'. One direction I'm currently thinking in is to split out workflow into an explicit workflow component (a python-based workflow management system, doing for workflow what relational database management systems do for data). It's still a lot of vague ideas and nothing serious has been hatched yet, though. > Martijn writes (quoting me): >> > I've looked at ZODB and ZEO some for my personal edification. If >> > I'm not mistaken, they provide a great mechanism for object >> > persistence with key-based retrieval. My evaluation suggested >> > that ZODB and ZEO were not very good at handling arbitrary >> > retrieval, or even retrieval at the level of a SQL select >> > statement. >> >> What do you mean with 'arbitrary retrieval'? > I'm meaning something more along the lines of a real indexing and > retrieval engine here. A query might be something like "I want > all objects that have the word 'spam' in any of their > attributes". This compares to key-based retrieval which says "I > want the object with the key 'spam'" or the SQL-style retrieval > which says "I want the objects that contain the word 'spam' in > the column 'eggs' in the table 'bacon'." Ah, a powerful query system, then. Difficult, too. Could you give a real life example of an actual arbitrary retrieval system? It's not full-text-search search, right? (the ZCatalog I believe already can do something like that, on multiple attributes). > Our application doesn't require arbitrary retrieval in its > current incarnation. [numbers with a point in there somewhere snipped :)] > To answer an un-quoted question, fixed point or decimal math is > required because dollars are involved. Binary FP's approximations > show up in odd places when you're doing decimal math, which makes > people uncomfortable when dealing with money. Okay, I figured. > Martijn writes (quoting me): >> > There's a certain draw to being able to take a single webapp and >> > deploy it on any of a dozen different app servers that know how >> > to handle the content, though it's small. >> >> What do you mean by this, exactly? Are you referring to the whole >> Enterprise JavaBeans framework (sorry if I confuse any of the >> terminology here) that's been implemented by various vendors? I've >> always been skeptical about how well that actually works, but here >> I'm skeptical without any actual real knowledge. :) > I can't speak to how easy it is to move from one app server to > another. I /can/ speak for how much of the "hard work" is done > for you by some of these enterprise containers -- a whole lot! Could you go into some more detail on this? I've heard this more often, but I'm still not entirely clear on *what* work is done. :) > I'm not sure how Python and the Python community as it currently > exists could actually /do/ the servlet thing. It's an API, but > it's also a specification of a standard; Sun can get away with > declaring The Standard because they have such tight control over > Java. Python's more open community proves something of a weakness > here -- Zope is "standard" in a de facto sense, but everyone who > sets out to develop a templating language or a content server or > an app server sets out to do it in their own way, with their own > set of interfaces in mind. That means moving between servers > requires a layer of adaptor code in the best case, or a total > rewrite in worst. I'm not interested in promoting a standard, I'm just interested in stealing ideas for Python-based APIs. I'm not interested in standardizing these APIs. :) I think Zope's new page template language (TAL and such) has some potential to become something more close to a standard for templating XHTML, though there will always be other systems, of course. Zope itself is slowly moving into the direction to be a server for simple Python objects, with (interface) adaptor layers on top to actually use the object in the Zope framework (and publish it). This will hopefully make it easier to exchange code with other Python software. This all an aside; now spill the beans about what makes these Java APIs so great! :) > Martijn writes (quoting me): >> > But the biggest draw is that someone who's proficient with >> > Java is not too hard to find. >> >> Are you sure about this? I mean, sure, lots of people are being >> cranked out that can use Java to a certain extent, but is it >> really true that it's not hard to find someone *good* at it? >> >> > Someone who's proficient with Python is considerably harder to >> > lay hands on. >> >> But I'd think that anyone who's actually good at Java would be >> retrainable to use Python in a matter of days. > Java programmers are more numerous than Python programmers. No contest. They're being cranked out, though, so the average quality is probably lower than that of still more-or-less self selected Python programmers. But there are *so* many Java programmers it's definitely more easy to find those. [snip] > I agree that a person could be retrained to use Python, and could > learn Zope. Python's not a terribly difficult language to learn, > and it's a language that keeps on giving the longer you use it. > But I do think that it would be difficult for someone hired as a > consultant to walk in cold and learn enough Python and Zope to > make sense of how the app worked. Are you sure that works for Java (or *any* language) though? :) Wouldn't any significant application be non-trivial to figure out for someone new to it, or do the standard APIs help so much? [snip people coming up to speed easily] > On the other hand, if the site had been less successful, and the > company could not afford to bring on full-time staff and pay to > have them trained -- if the company needed to hire a couple > contract programmers to come in and change a few things, add a > few things -- the company would have looked a very long time for > someone proficient enough in Zope and Python to come in cold and > make the changes they needed. Agreed, I can see this concern, especially with Zope; not so much with Python -- any decent programmer with some OO experience can pick up enough Python in no time. [snip] > If the app were done in Java, it would be a lot easier to hire > people who knew at least a little Java and could find their way > around the servlet API and JSP, whether as permanent employees or > temporary contractors. That's just because of the demographics. > Meanwhile, it's also a lot easier -- at least in our area -- to > send your employees off to a three day class on Java or JSP and > servlets, and it's easier to learn all three topics from any > number of widely-published, well-written books. Zope training > involved flying Matt out here from Digital Creations, and the > documentation is scarce. I think we need to separate comparing Zope with the Java-style solutions and Python to Java. I think there can be a good case made that switching to Python is not that big a deal. Learning about Zope is a whole different story, however. It's far easier than it used to be, on the documentation side; community knowledge has also increased. But your concerns with Zope make sense. [snip scaling java versus scaling python; the jury is mostly out] > Martijn writes: >> Any larger app will have to grow and change over time, so I >> consider this as well for my Zope/Python/relational database >> apps, which is why I'm interested in your ideas about what >> makes Java more suitable for these purposes. Not so I can go >> and use Java, but for stealing some ideas. :) > Probably the sanest thing either of us could be doing in this > discussion. :) > Let's see if we can come up with a short list -- I don't think > these belong in the PEPs, really, maybe just ideas for people's > projects? Yup. Note that Zope is onto entity/session beans or whatever bizarro terminology Java uses, though this is only in the exploration stages. The proposed terms for Zope components are Content/Application/Presentation. Here's a link into a 'half-baked wiki' (aren't they always?) discussing this: http://www.zope.org/Members/michel/Components/Components/NewReligion > Maybe the first idea is some kind of formalized > community that would provide support for these kinds of > discussions? I don't know. A 'Python generic application server APIs' mailing list? :) I'm not sure if that'd work. > But the ideas. > It would be very good if you could take an object, instantiate it > in the context of a container, and basically have proxies > propagated to all other applications that have instantiated that > container. Note that XML-RPC sort-of-almost does something like this; it looks like proxies, at least. There are actually several light-weight RPC mechanisms for Python that use proxy-objects like this (and I heard the now-cancelled Ultima Online 2 project rolled their own). Or what do you mean by 'other applications that have instantiated that container'? Presumably they've instantiated a *proxy* of the container? > Let's put it a different way, more abstract and less tied to > implementation. It would be very good if you could write an > object that conforms to a reasonable interface, and in so doing > "gain" the ability to use the object in a distributed fashion. Have you seen the interfaces PEP? The Python community is slowly moving to supporting the notion of explicit interfaces (apart from classes), with run-time querying and checking (does this object support the 'foo' interface?). > Currently, you've got to do it all by hand, and you can't count > on the way you do it one time being re-usable the next time. > There's no /standard/ way of doing it, and there's more than one > way to do it. That's treading into Perl's territory, there.... Agreed that there's a need for this. Once we have interfaces, remote querying and so on is only a small step away, of course. > Here's something I like about the servlet containers (app > servers) that I haven't seen in Zope yet (maybe it's there?): > managed sessions via cookies OR URL rewriting. Some of the > servlet containers even support persistent sessions and sessions > shared across multiple app servers. When you have fault-tolerance > at that level of the application, that's powerful juju. [snip] Check out 'Core Session Tracking' (not yet in the Zope core, they're but working on it). I think it may come close to supporting all of these, especially with ZEO. http://www.zope.org/Members/mcdonc/Products/CoreSessionTracking (see the release information, near the bottom for a description. It also has extensive docs that you'll see when you install it) [snip] > Here's another one, one we can beat Java to the punch on: it > would be nice if you could do object storage and retrieval into a > relational database using a simple management framework. The > upcoming Java Data Objects spec is an easy example to look at, > but also consider looking at Apple/NeXT's Enterprise Objects > Framework. I started working on something like this using > metaclasses, and was reasonably successful, but it's a complex > undertaking, and time consuming.... I believe there are various Zope projects looking into this (and has received quite a bit of attention recently). One is ZPatterns, something I never got into. Another recent project is SmartObjects. Finally the Digital Creations folks are looking into better relational database integration. Lots of developments that haven't been fully baked yet, of course, but they're sure being baked. :) > Martijn writes (quoting me): >> > For more modest ambitions, the factors that weigh heavy on me may >> > seem irrelevant or even overweening. :) >> >> Many people are using Python for rather less modest ambitions, >> however. >> I'm certainly planning to. :) > And I think that HomeGain is using Python in a pretty significant > application, too. We've got a lot of traffic and a whole bunch of > data. It can work! It just doesn't seem to have all the tools to > facilitate it, and it's not nearly as ubiquitous as other > solutions. It's definitely not as ubiquitous, but the tools are being worked on. And in some areas Python may be further along than the Java competition, due to its flexible nature. ZEO developments are very interesting, for instance. While Java certainly has object database, I imagine they're not as transparent in use as the ZODB can be. Thanks for your response! Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From dwig at advancedmp.net Tue Jun 5 17:29:02 2001 From: dwig at advancedmp.net (Don Dwiggins) Date: 05 Jun 2001 14:29:02 -0700 Subject: Python + ASP + COM problems in Windows In-Reply-To: D-Man's message of "Tue, 5 Jun 2001 16:03:51 -0400" Message-ID: I previously asked how to access a specific interface of a COM object, and got the following useful hint: m = Dispatch('Mycomponent.Myobject') m2 = m._oleobj_.QueryInterface(InterfaceIID,pythoncom.IID_IDispatch) m2 = DynDispatch(m2) This works beautifully when I run it directly from Python. However, when I try to use it in an ASP page, I get the following error: pywintypes.com_error (-2147352570, 'Unknown name.', None, None) ... which comes from the last statement (I've checked that m2 is correctly instantiated in the second statement, and is of type ). Any good words? BTW, I've also found that "m = Server.CreateObject('Mycomponent.Myobject')" doesn't work in my ASP page; I get the unhelpful message that "an exception occurred". Thanks, -- Don Dwiggins "Solvitur Ambulando" Advanced MP Technology dwig at advancedmp.net From kasper37 at caffeinedreams.com Fri Jun 1 06:19:11 2001 From: kasper37 at caffeinedreams.com (kasper37 at caffeinedreams.com) Date: 1 Jun 2001 03:19:11 -0700 Subject: continue loop without iteration... Message-ID: basically, this is what I need to do: x=1 y=x while x <= y: if something: x=x+1 y=y+1 continue dosomething x=x+1 therefore, if the if statement is always true, it should never end, but as soon as it's false, dosomething will happen and it will stop. Dan From James_Althoff at i2.com Mon Jun 11 18:44:57 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Mon, 11 Jun 2001 15:44:57 -0700 Subject: metaclasses -- aka Don Beaudry hook/hack (was RE: Why should i use python if i can use java) Message-ID: Geoff Gerrietts wrote: >James Althoff writes: >> From: James_Althoff at i2.com [mailto:James_Althoff at i2.com] >> >> Geoff Gerrietts wrote: >> >> >In Python, I know how to write classes whose instances are >> >other classes. >> >> Do you mean "whose instances are *themselves* classes"? And if >> so, How do you do this? >> (Can you do this in *Python* -- without doing a C extension?) > >Yes, I really meant that. :) > >This is the "metaclass" facility -- you can get a much more >formal description of how that works from looking at those docs >(and playing with the examples). Geoff, Thanks very much for your response (and all the effort you put into creating the examples and pointers to documentation!). Actually, I am familiar with metaclasses -- aka the Don Beaudry hook. What I have found is that "the hook" doesn't seem to be complete in the sense that only the "class" statement seems to know about the hook. Other parts of Python don't (unless I'm missing something). So if you use a metaclass to make a class "MyClass", its "type" will not match types.ClassType, for example. Also problematic is that "isinstance" will not accept MyClass as an argument so you can't make an instance of MyClass and then test to see that it (the instance) is an instance of MyClass (without adding some extra contortions). So it seems to me that "class-like instances" created using the Don Beaudry hook are not really "first-class" class objects (Python sees them as "instances" not as "class objects") so the "hook" is indeed a bit of a "hack" at this point (but is very clever, nonetheless :-)). And when using metaclasses you have to be aware of the parts of Python that operate on true "classes" -- and that fail on "instances" -- and keep extra machinery around to deal with this -- which is a bit of a hassle and makes metaclasses not as useful as they might otherwise be. Hopefully the new class/type healing will fix all of this. Jim "Not Really a Class" Metaclass Example: This example is an experiment to see if Don Beaudry-style metaclasses could be used to implement Smalltalk-style metaclasses in Python. It is different than the metaclass examples shown in the docs in that it doesn't use a fixed, pre-defined, secondary helper class to create the instances. Instead it makes the helper class on the fly using "new.classobj" and saves it as a metaclass instance field. ############## import new,types class MetaClass: def __init__(self,name,baseList,nameSpaceDict,isMetaClass=0): self.name = name self.baseList = baseList self.nameSpaceDict = nameSpaceDict self.isMetaClass = isMetaClass tempBaseList = [] for base in baseList: if type(base) == types.ClassType: tempBaseList.append(base) else: if base != baseList[0]: tempBaseList.append(base.classObject) self.classObject = new.classobj(name,tuple(tempBaseList),nameSpaceDict) def __call__(self,*pargs,**kargs): instance = self.classObject(*pargs,**kargs) return instance def __getattr__(self,attr): if not self.isMetaClass: attr = self.classObject.__getattr__(attr) return attr raise AttributeError Meta = MetaClass('Meta',(),{},isMetaClass=1) class MyClass1MetaClass(MetaClass): def whoami(self): print 'MyClass1MetaClass.whoami:', self MyClass1Meta = MyClass1MetaClass('Meta',(),{},isMetaClass=1) class MyClass1(MyClass1Meta): def whoami(self): print 'MyClass1.whoami:', self class MyClass2MetaClass(MyClass1MetaClass): def whoami(self): print 'MyClass2MetaClass.whoami:', self print 'and also:' MyClass1MetaClass.whoami(self) MyClass2Meta = MyClass2MetaClass('Meta',(),{},isMetaClass=1) class MyClass2(MyClass2Meta,MyClass1): def whoami(self): MyClass1.classObject.whoami(self) print 'and also:' print 'MyClass2.whoami:', self print MyClass1.whoami() mc1 = MyClass1() print mc1.whoami() print MyClass2.whoami() mc2 = MyClass2() print mc2.whoami() print print 'really a class?', type(MyClass1) == types.ClassType print 'so what am I really?', type(MyClass1) print print 'extra contortions needed:' print 'isinstance:', isinstance(mc2,MyClass2.classObject) print 'isinstance:', isinstance(mc2,MyClass1.classObject) print print 'isinstance fails here:' print 'isinstance:', isinstance(mc2,MyClass2) print 'isinstance:', isinstance(mc2,MyClass1) >>> reload(meta9) MyClass1MetaClass.whoami: MyClass1.whoami: MyClass2MetaClass.whoami: and also: MyClass1MetaClass.whoami: MyClass1.whoami: and also: MyClass2.whoami: really a class? 0 so what am I really? extra contortions needed: isinstance: 1 isinstance: 1 isinstance fails here: isinstance: Traceback (most recent call last): File "", line 1, in ? File "c:\_dev\python20\meta9.py", line 85, in ? print 'isinstance:', isinstance(mc2,MyClass2) TypeError: second argument must be a class >>> From owen at astrono.junkwashington.emu Wed Jun 6 13:04:38 2001 From: owen at astrono.junkwashington.emu (Russell E. Owen) Date: Wed, 06 Jun 2001 10:04:38 -0700 Subject: How to get a unicode degrees symbol? References: <9fj0j6$e7m$1@nntp6.u.washington.edu> Message-ID: <9flnr5$bag$1@nntp6.u.washington.edu> In article , "Fredrik Lundh" wrote: >Russell E. Owen wrote: >> I'm obvious missing some important bit of documentation, but I looked >> through the manuals and can't seem to figure out how to get unicode >> character constants into python strings. >... >not sure how you managed to miss this one: > > http://www.python.org/doc/current/ref/strings.html > >...(more useful info omitted) > >if you want the same content, but want to print it in different ways >depending on the platform's display encoding, you can use the encode >method on the way out. examples: > > u = u"\N{DEGREE SIGN}" > print u.encode("iso-8859-1") # unix (us/western europe) > print u.encode("cp1252") # windows > print u.encode("macroman") # macintosh > print u.encode("cp850") # dos window > >if the target encoding doesn't have a degree sign, encode will raise >an exception. if you don't want that, pass "replace" or "ignore" as >the second argument. Thank you very much. My main goal is to display the degree symbol (for example) on the current platform -- in a way that Tk, etc. can all handle it as a normal thing. Apparently this requires encoding the data as an ascii string. OK, but surely there must be some simple way to do this that doesn't require a big case statement (if platform x then use encoding y...) and knowing the name of the most appropriate encoding for each platform? ----- As to how I managed to miss the documentation link. I don't mean to sound ungrateful to anybody involved with Python, but in fact that was quite a battle when I first tried to figure it out. At the time I was using 2.0, but I retraced my steps today, just for the heck of it, using the 2.1 manuals. I started with my local copy of "Python Documentation", the launching point for most or all documentation. It lists the Global Module Index as being "for quick access to all documentation", so I started there (with some misgivings, since I knew strings were a built in type). The page of links sure looked promising, so I clicked on "string", but found myself in a description of the (obsolete, I think?) string module, with no pointers out to unicode or the built in data type. An up link points to "string services" which at least has an entry for "unicodedata", but was still a dead end for more info about strings. So my next try was the Python Library Reference. Alas, it's table of contents doesn't have an entry for "string". However, I knew enough about Python (barely) to try "Sequence Types", but I wasn't feeling very confident. That section does mention strings and has a link to the entry you suggested -- the string literal description in the Python Reference Manual. By the way, Python Documentation lists that as "Language Reference (for language lawyers)" -- not promising, and I wasn't even sure they were the same document until I did some hunting around. At that point I knew how to generate unicode characters, but had no idea which ones were which. Not a big hassle -- I realized I could probably find unicode documentation on line fairly easily -- but another roadblock. Also, I did find a link to unicode today in retracing my steps, but don't quite remember where it was -- it's not in the Python Reference section on string literals. Anyway, at that point I realized I could generate unicode characters, so I tried a few, just for fun. I quickly found I could not display them (for instance str() raised an exception. At that point I gave up, until my recent posting. Far more than you wanted to know, I'm sure. With a few extra links sprinkled throughout that whole process could have been nicely shortcut with a somewhat happier ending. I'd be happy to add these myself if anybody is willing to receive the edited pages. (I can also use cvs -- as very much a neophyte -- but imagine I don't have checkin permission). -- Russell From grante at visi.com Mon Jun 25 17:48:25 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 25 Jun 2001 21:48:25 GMT Subject: Is this a true statement? References: <8NuZ6.362378$oc7.42924874@news2.rdc2.tx.home.com> <3B3788A2.3BD1D672@tundraware.com> <9qMZ6.368197$oc7.44797813@news2.rdc2.tx.home.com> <3B37A15D.DF05A331@tundraware.com> Message-ID: In article , Rainer Deyke wrote: >Forget about the amount of disk space. A device driver in C++ >can run on a system with *no* writable disk. This is not true >in Python. Really? There are systems with no writable disk running Python: http://www.abo.fi/~iporres/python/ -- Grant Edwards grante Yow! I smell a RANCID at CORN DOG! visi.com From nospam at nospam.de Sun Jun 3 05:06:20 2001 From: nospam at nospam.de (Uwe Hoffmann) Date: Sun, 03 Jun 2001 11:06:20 +0200 Subject: Python and databases References: <991557251.316332@seven.kulnet.kuleuven.ac.be> Message-ID: <3B19FE0C.EE25E7AF@nospam.de> Pieter Laeremans wrote: > > Hi, > > Does python has something like perl 's DBI? > I can 't find any documentation about it in the python docs. > > Thanks in advance, > > Pieter http://www.python.org/sigs/db-sig/ and some links for resources: http://www.vex.net/parnassus/ then link Database uwe From James_Althoff at i2.com Tue Jun 19 15:17:13 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Tue, 19 Jun 2001 12:17:13 -0700 Subject: instance as fake module (Re: why is there no class (static) methods in Python ?) Message-ID: Alex Martelli wrote: >James_Althoff at i2.com> wrote in message >> How would such an approach work with "import", "from", "__import__", etc.? > >Pretty well, thanks (it DOES give problems with 'reload', though, >if that is what you mean by 'etc':-). Why not give it a try -- it >*IS* as simple as a crystal-clear spring, after all. Well I have to admit, I'm not really sure what it is that makes a "crystal-clear spring" "simple". (You are talking about water, right?) ; -). Seriously, I didn't mean to say that using a "substitute module object" was not a useful concept in general. I agree that it can be useful. I meant that in this particular case using a "substitute module object" to try to implement "inheritance with override" for module functions didn't seem (to me) like a good approach for class methods. OTOH, the idea of using a substitute module object for enforcing constants (as you posted previously) or for lazing imports, for example, seem like interesting and useful (and simple ;-) ) techniques. >> And use this as the standard idiom for modules? > >I'll pass on this one. I suspect that by-far-MOST modules have >no need for __getattr__ and __setattr__, so I don't really see >why having a module replace its entry in sys.modules would ever >become "THE standard idiom". But when I *DO* need a "module >__getattr__" etc, it seems to work pretty well today. > >I'll pass on metaclasses, "true class methods", etc, too -- it >does not appear to me that the instance-as-a-fake-module idea >gives anywhere near ALL the power that such deep concepts might >yield. But I haven't done nearly enough Smalltalking to feel >the need for such specific packaging-of-power deep in my bones. > >Specifically, my personal gut feeling is that classes are nice >but vastly overrated in most OO literature, I guess I don't feel the same about this one. I don't think classes are vastly overrated. I just like 'em! (Although I'll admit that I've seen my share of badly designed and improperly used ones. :-) ). But more to the point, I think that since in Python "everything is a first-class object" -- which is great -- and since classes, therefore, are first-class objects it would be nice (and powerful) if you could define methods that you could invoke on such class objects. (And such methods should support inheritance and override, of course.) Jim From emile at fenx.com Sat Jun 9 10:43:47 2001 From: emile at fenx.com (Emile van Sebille) Date: Sat, 9 Jun 2001 07:43:47 -0700 Subject: Why should i use python if i can use java References: <9fngvl011jg@enews2.newsguy.com> <006d01c0ef8c$01af4ee0$0300a8c0@arthur> Message-ID: <9ftdlj$61ke1$1@ID-11957.news.dfncis.de> To simplify google refs: Start with http://groups.google.com/groups?ic=1&q=msgid:, then find the message ID of the message, as per the standard mail headers. For example, when I hit reply, it shows your message ID as mailman.991984874.25882.python-list at python.org (toss the protocol identifier), yielding http://groups.google.com/groups?ic=1&q=msgid:mailman.991984874.25882.python- list at python.org as the Google ref. Other message id markers are seekm and selm. Applying this to your list of refs gives: http://groups.google.com/groups?ic=1&q=msgid:8s5afj0cov%40news2.newsguy.com http://groups.google.com/groups?ic=1&q=msgid:91d23f0jk7%40news1.newsguy.com http://groups.google.com/groups?ic=1&q=msgid:91lhdb0mb%40news1.newsguy.com http://groups.google.com/groups?ic=1&q=msgid:934uei02u7m%40news2.newsguy.com http://groups.google.com/groups?ic=1&q=msgid:9bpdsv026s8%40news1.newsguy.com http://groups.google.com/groups?ic=1&q=msgid:9c48mn020mv%40news1.newsguy.com http://groups.google.com/groups?ic=1&q=msgid:9elmp4010u1%40enews2.newsguy.co m HTH, -- Emile van Sebille emile at fenx.com --------- "Alex Martelli" wrote in message news:mailman.991984874.25882.python-list at python.org... > http://groups.google.com/groups?hl=en&lr=&safe=off&ic=1&th=303263c728caff3a, > 4&seekm=8s5afj0cov%40news2.newsguy.com#p > > http://groups.google.com/groups?hl=en&lr=&safe=off&ic=1&th=90fe81cf878b00fd, > 9&seekm=91d23f0jk7%40news1.newsguy.com#p > > http://groups.google.com/groups?hl=en&lr=&safe=off&ic=1&th=e61b533755e27c16, > 10&seekm=91lhdb0mb%40news1.newsguy.com#p > > http://groups.google.com/groups?q=singleton+design+pattern+group:comp.lang.p > ython+author:Alex+author:Martelli&num=20&hl=en&lr=&safe=off&scoring=d&rnum=6 > &ic=1&selm=934uei02u7m%40news2.newsguy.com > > http://groups.google.com/groups?q=singleton+design+pattern+group:comp.lang.p > ython+author:Alex+author:Martelli&num=20&hl=en&lr=&safe=off&scoring=d&rnum=4 > &ic=1&selm=9bpdsv026s8%40news1.newsguy.com > > http://groups.google.com/groups?hl=en&lr=&safe=off&ic=1&th=6caf333bec7f9aef, > 7&seekm=9c48mn020mv%40news1.newsguy.com#p > > http://groups.google.com/groups?q=unit+reuse+release+author:alex+author:mart > elli&num=20&hl=en&lr=&safe=off&rnum=2&ic=1&selm=9elmp4010u1%40enews2.newsguy > .com > From ullrich at math.okstate.edu Thu Jun 14 14:31:38 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Thu, 14 Jun 2001 18:31:38 GMT Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: <9g4nec0cnr@enews2.newsguy.com> <3b266453.317327753@wa.news.verio.net> <3b2768b5.1425762@nntp.sprynet.com> <3b28ed01.483389587@wa.news.verio.net> Message-ID: <3b290162.19392474@nntp.sprynet.com> On Thu, 14 Jun 2001 17:19:05 GMT, bokr at accessone.com (Bengt Richter) wrote: >On Wed, 13 Jun 2001 13:33:51 GMT, ullrich at math.okstate.edu (David C. >Ullrich) wrote: > >>On Tue, 12 Jun 2001 19:25:25 GMT, bokr at accessone.com (Bengt Richter) >>wrote: >> >>>[...] In general, I'd prefer that a language >>>provide a clean way to create a solution to a problem, >>>rather than having a particular solution built in. >>>I like orthogonality too. >> >[...] >>So just out of curiosity: Roughly what do you >>mean by "orthogonality" above? >Roughly, zero dot products ;-) Thanks. Best answer so far... (so a language in which it was essentially impossible to do mathematical programming would automatically have achieved this orthogonality: no math, hence no dot products, for a net total of zero dot products altogether. Suddenly Perl seems much more orthogonal than Python, who woulda guessed?) >That is, if you view program language feature space >as n dimensional, and writing code using a particular >feature as movement along a feature vector. > >Well, roughly something like that. 8-<:^P David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From senux at senux.com.NOSPAM Mon Jun 4 06:09:43 2001 From: senux at senux.com.NOSPAM (Brian Lee) Date: Mon, 04 Jun 2001 10:09:43 GMT Subject: Dynamically making lists? References: Message-ID: <3B1B5E80.A01DA188@senux.com.NOSPAM> Bill Witherspoon wrote: > > Hi all, > > If I have a list -> > > L = ['one', 'two', 'three',......,'one thousand'] > > and I want to split this into several lists with (say) two elements > each -> > > m = ['one', 'two'] > n = ['three', 'four'] > o = ['five', 'six'} > ...... > zz = ['nine hundred ninety nine', 'one thousand'] > > How would I do this? I don't know how many elements are in L before > I run the program. > > It seems like I have to generate variable names on the fly? > Maybe there's something simple I'm missing here. > > Any pointers would be appreciated. > > TIA, > Bill. How about to start from this code and edit for your own use. for x in range(len(L) / 2): tmp[x] = [L[x * 2], L[x * 2+ 1]] -- Brian Lee * Please remove NOSPAM in my email adress to reply to me. From kelly.kranabetter at gems6.gov.bc.ca Tue Jun 26 14:11:58 2001 From: kelly.kranabetter at gems6.gov.bc.ca (KellyK) Date: Tue, 26 Jun 2001 18:11:58 GMT Subject: Windows Printing using win32print References: <9h8smc$csrv8$1@ID-11957.news.dfncis.de> Message-ID: <3b38ce51.508966975@nntp.gov.bc.ca> On Mon, 25 Jun 2001 19:35:59 -0700, "Emile van Sebille" wrote: >I'm not sure if this helps with your specific problem is, but I can say that >you need to figure out the name the printer goes by. I've seen different >names for printers working with various applications in windows. Here are >two examples that I'm currently using. Something like this will list the names of network connected and local printers: for p in win32print.EnumPrinters(win32print.PRINTER_ENUM_CONNECTIONS): print p[2] for p in win32print.EnumPrinters(win32print.PRINTER_ENUM_LOCAL): print p[2] Full documentation on EnumPrinters is on Microsoft's site http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/hh/gdi/prntspol_9fjn.asp From donn at u.washington.edu Fri Jun 8 16:08:32 2001 From: donn at u.washington.edu (Donn Cave) Date: 8 Jun 2001 20:08:32 GMT Subject: Mutable class attributes are shared among all instances, is it normal ? References: <27vvht4uslv2ibq2q8ee4tovg86e7qempb@4ax.com> <3B201662.6DB35744@home.net> <991975696.169576@yabetcha.drizzle.com> <3B21248E.C27B8DF3@home.net> Message-ID: <9frbc0$gu4$1@nntp6.u.washington.edu> Quoth Chris Barker : ... | I think the point is not that self.x is mutable, but that self.y is NOT | mutable. In other languages, x points to a particular piece of memory, | and if you write x = somethingnew, that same memory is being used. In a | number of begining programming texts I have seen variables described as | boxes that numbers can be put in. Python mutable types can be boxes, and | their contents changed without changing the box intself, but python | imutable types are NOT boxes, so the distinction is important. Not for me. I can think of two contexts where mutable vs. immutable is an important distinction - - the list, vs. the tuple, which are similar but the former supports a modify operation and hence is "mutable". - dictionary keys, where mutability as such is indeed a big issue. The only reason to care what "mutable" means is the second one. The beginning Python programmer probably ought to stay away from boxes anyway. Can an immutable type be a box? Depends on what it means to be a box, and what it means to put something in the box. If the text goes on to show you how to put value "a" in box "x" with "x := a", then you lose, Python does not have boxes, period. Even if it somehow skirts that, what about retrieval - if it isn't a box, how come you can get stuff out of it? Bleah. Maybe boxes work so well for so many people that it's worth the trouble to make a box model of Python, but I fail to see how mutability can help with that. Donn Cave, donn at u.washington.edu From thecalm at NOSPAM.btinternet.com Mon Jun 25 07:40:06 2001 From: thecalm at NOSPAM.btinternet.com (Gaz) Date: Mon, 25 Jun 2001 12:40:06 +0100 Subject: Standalone .exe's using installer/builder question References: <9gsld3$5n6$1@plutonium.btinternet.com> <90C76054Egmcmhypernetcom@199.171.54.155> <90C7AD776gmcmhypernetcom@199.171.54.155> Message-ID: <9h77t7$kr6$1@uranium.btinternet.com> Im still having trouble getting standalone (http://www.mcmillan-inc.com/builder.html) to work on WinME, this is my autoexec.bat file:- SET PATH=C:\WINDOWS;C:\Windows\System;C:\WINDOWS\COMMAND SET windir=C:\WINDOWS SET winbootdir=C:\WINDOWS SET COMSPEC=C:\WINDOWS\COMMAND.COM SET PROMPT=$p$g SET TEMP=C:\WINDOWS\TEMP SET TMP=C:\WINDOWS\TEMP This is the command line i'm using (i just unzipped it to the desktop to play with it, is this ok?): python C:\WINDOWS\Desktop\temp\Standalone.py test.py -tk -runw -win32 This is the console grab, for your info: > "C:\PROGRAM FILES\PYTHON\PYTHON.EXE" C:\WINDOWS\Desktop\temp\Builder.py test.cfg C:\WINDOWS\Desktop\temp\projects\buildtk.cfg W: exec statement detected at line 281 of imputil W: No module named dos W: No module named mac W: No module named nt.stat W: No module named os2 W: No module named posix W: Cannot determine your Windows or System directories W: Please add them to you PATH if .dlls are not found W: exec statement detected at line 1531 of Tkinter W: exec statement detected at line 49 of os W: exec statement detected at line 102 of os W: eval hack detected at line 325 of os W: No module named strop.lowercase W: No module named strop.maketrans W: No module named strop.uppercase W: No module named strop.whitespace W: No module named ce W: No module named win32api W: No module named pwd W: No module named MACFS W: No module named macfs W: No module named MacOS any ideas why this isn't working? im thinking that when i first run 'SetupTK.py' its not finding certain .dlls or something? 'cos i get more or less the same 'No module found' in the console when i run it! suggestions would be greatly apprieciated! :) gaz. "Gordon McMillan" wrote in message news:90C7AD776gmcmhypernetcom at 199.171.54.155... > Cameron Laird wrote: > > >In article <90C76054Egmcmhypernetcom at 199.171.54.155>, > >Gordon McMillan wrote: > > > >>>C:\WINDOWS\Desktop\temp\Standalone.py test.py -tk > >>> > >>>anyideas??? > >> > >>Yes. Due to a Windows problem, you have to say: > >> > >>python C:\WINDOWS\Desktop\temp\Standalone.py test.py -tk > >>^^^^^^ > >> > >>or the command line args don't make it to Standalone.py. > > >Let me be sure I understand: it's not a "problem" in the > >sense that there is a fault specific to the installer or > >Python that anyone expects to change, right? Windows is > >*designed* in such a way that natural installations, in > >effect, discard command-line arguments--correct? > > I'm not sure I *understand* any better than you :-). Especially > when I misspoke on this one... > > [BTW, in private email, I got the actual error messages, > and was able to straighten things out. Knowing things like > what OS, and the actual errors encountered helps a whole lot.] > > It appears that when you use file associations, various > operations are done at a higher level than they need to be. > The big screw up is redirection. If you manage to convince > Windows that .py files are executable, things work more > reasonably. > > >Incidentally, I believe there's a tweak we can make to the > >Windows installation (basically, complexifying some of the > >data inserted in the Registry) to allow such shortcuts to > >work as those of us coming from Unix expect. I've never > >pursued it, out of fear for what could go wrong once we > >get intimate with the Registry. > > Actually, it's on (other peoples') Unixen that I learned to > type everything out. Uncooperative cshell bigots for sys-admins, > and all that. > > - Gordon From geoff at homegain.com Sat Jun 2 07:07:19 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Sat, 2 Jun 2001 04:07:19 -0700 Subject: Why isn't Python king of the hill? Message-ID: <393D961EA4FCD311B03F00D0B746D65803275E5F@HQSXCH01> A quick addendum to my earlier spam about number systems -- I've been corrected privately, and wanted to correct myself publicly lest I mislead someone. I try not to play fast and loose with the facts, but my explanations sometimes exceed my understanding . Fixed-point is scaled in advance. This means that you do not need to track the scaling factor: since everything is being done to the same scale, there's just one scaling factor. You scale all your numbers for storage and calculation, then move the decimal point back when you want to display them. Rational numbers are tracked as a numerator and denominator, nothing more complicated than that. The danger with rational numbers is that they require a lot of storage space, and that the integers involved sometimes get really, really big. I'm told that you can't reasonably limit the size of the integers, either, because if you do, your accuracy will suffer even worse than if you'd stuck to floats. I guess that means that asking for the answer to exactly the right question could result in a single absolutely enormous number, and it could take a very long time to arrive at that number. I was also informed that when a float and a rational are combined, that the result should be coerced to a float, because the rational is accurate and the float is an approximation. I would credit the source of all this fine information, but I think that doing so without his permission is something of an ethical violation, since he sent a private reply? Anyway, I wanted to correct myself soon, so I'll thank him when I'm allowed. :) Thanks, --G. From tom at peresys.co.za Thu Jun 7 17:36:23 2001 From: tom at peresys.co.za (Tom) Date: Thu, 7 Jun 2001 23:36:23 +0200 Subject: py2exe problem with os.path Message-ID: <9fos4p$3ms$1@ctb-nnrp1.saix.net> I have the following program to count lines in python: ''' count number of lines in source files ''' import os,sys,fnmatch total=0 fileinfo=[] exts=[] for param in sys.argv: if param[:2]=='*.': exts.append(param) subdir=0 for param in sys.argv: if param.lower()=='-r': subdir=1 break def Stat(file): lines = open(file).readlines() result=len(lines) return result def DirInfo(dirpath='./',subdir=1): global total,fileinfo,exts files=os.listdir(dirpath) files.sort() for file in files: if os.path.isfile(dirpath+file): # Problem line 35 for ext in exts: if fnmatch.fnmatch(file,ext): size=Stat(dirpath+file) total+=size fileinfo.append((os.path.abspath(dirpath+file),size)) if subdir and os.path.isdir(dirpath+file): DirInfo(dirpath+file+'/') DirInfo(subdir=subdir) fileinfo.sort(lambda x,y:cmp(y[1],x[1])) print '-'*79 for (file,size) in fileinfo: print file.ljust(70),str(size).rjust(8) print '-'*79 print 'TOTAL Lines:'.ljust(70),str(total).rjust(8) When using py2exe it builds fine but when running exe i get: Traceback (most recent call last): File "", line 4, in ? File "imputil.pyc", line 88, in _import_hook File "", line 43, in _import_top_module File "imputil.pyc", line 197, in import_top File "imputil.pyc", line 252, in _import_one File "", line 118, in _process_result File "os.pyc", line 52, in ? File "imputil.pyc", line 88, in _import_hook File "", line 43, in _import_top_module File "imputil.pyc", line 197, in import_top File "imputil.pyc", line 252, in _import_one File "", line 118, in _process_result File "ntpath.pyc", line 9, in ? File "imputil.pyc", line 88, in _import_hook File "", line 43, in _import_top_module File "imputil.pyc", line 197, in import_top File "imputil.pyc", line 252, in _import_one File "", line 118, in _process_result File "stat.pyc", line 44, in ? File "stat.pyc", line 35, in DirInfo AttributeError: path What is wrong ? From chris.gonnerman at newcenturycomputers.net Thu Jun 14 21:58:51 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Thu, 14 Jun 2001 20:58:51 -0500 Subject: sorting values in dict References: <4doiitsrkn6npivhs2l1qs9ns844uu6msu@4ax.com> Message-ID: <010501c0f547$9a8eb220$0101010a@local> ----- Original Message ----- From: "Courageous" > I don't know what you really want here. Since others have already > posted some suggestions, I'll simply observe that when a programmer > wants "fast look up, ordered entries," a tree structure of some time is > generally used. The use of the appropriate tree eliminates the need > to sort the container at any given time, as the tree is kept in order; you'll > find an entry in O(log N) time. Look in the Vaults for an implementation. Or look here: http://newcenturycomputers.net/projects/rbtree.html for a Red/Black "nearly balanced" Binary Tree module. From jkraska1 at san.rr.com Wed Jun 20 21:52:18 2001 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 21 Jun 2001 01:52:18 GMT Subject: Any other Python flaws? References: Message-ID: <68l2jt4j0ak4uft0r66nb2s7h0q75ovs5e@4ax.com> >> Python licensed under the GPL would be bad - it couldn't be embedded in >> non-GPL projects anymore. > >That is not true. Does not #including a gnu .h file count as a derived work? I thought this was the purpose of the LGPL, to specifically allow certain classes of derived works without forcing license compliance. C// From claird at starbase.neosoft.com Fri Jun 15 11:43:25 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 15 Jun 2001 10:43:25 -0500 Subject: SMNP Interface(s)? References: Message-ID: <429023331B97E191.19A4A64234FFFF12.C21E90A7975F8577@lp.airnews.net> In article , Case Van Horsen wrote: >I use pysnmp extensively (written entirely in Python) and am aware of >yapsnmp (a wrapper for net-snmp, was ucd-snmp). Both are available on >sourceforge. . . . Background information is at -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From philh at comuno.freeserve.co.uk Thu Jun 21 18:45:10 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Thu, 21 Jun 2001 23:45:10 +0100 Subject: Python Developers in the UK!? References: <300e9926.0106210819.5755d5ae@posting.google.com> Message-ID: On 21 Jun 2001 09:19:13 -0700, Adrian Spencer wrote: >Does anybody know where I might be able to source Python developers in >the UK. I work for a Pan European company currently looking at >building their online operation in Python in a Zope application server >environment. We are looking to find talented developers who wish to >join a fast moving and dynamic company, however have no idea where >these guys may be....please can somebody help? Are you based in/near London? If so, I might be interested in working for you. -- ## Philip Hunt ## ## philh at comuno.freeserve.co.uk ## From dsh8290 at rit.edu Tue Jun 26 13:54:12 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 26 Jun 2001 13:54:12 -0400 Subject: [OT] Is there any tutorial for those who learn Java after Python ;-) In-Reply-To: ; from rnd@onego.ru on Tue, Jun 26, 2001 at 09:23:20PM +0400 References: Message-ID: <20010626135412.H16298@harmony.cs.rit.edu> On Tue, Jun 26, 2001 at 09:23:20PM +0400, Roman Suzi wrote: | | I want to learn Java (Not that I am dissatisfied with Python, | but this seem to be "the must" to find a job ;-) I would recommend using Jython to start -- you can do useful stuff using your Python knowledge and use the Java libraries. It is really cool. | And some simple things makes me wonder: | | public class JavaRules { | public static void main(String args[]) { | System.out.println(2+2+"a"); This line is a type error. | System.out.println("a"+2+2); Here is a little bit of Java's magic -- the java.lang.String being first, it's '+' operator converts the other objects to a string, then concatenates them. | } | } | | Quick quiz: what this program will output? | | 1. syntax/compilation error (Java is strict typed!!!) | 2. 4aa22 | 3. 4aa4 | 4. 22aa22 | 5. 22aa4 | | Your answer: [ ] | | * | | The question is, has anybody tried to write tutorial (even joking!) for | those who wants to learn Java _after_ Python? No, but you could start with the one at http://java.sun.com. I admit that you won't enjoy it nearly as much as Python :-). -D PS. if you have some Java questions, email me privately because this list isn't about Java From skip at pobox.com Fri Jun 22 14:32:56 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 22 Jun 2001 13:32:56 -0500 Subject: How to reload a module in embedded C In-Reply-To: References: Message-ID: <15155.36696.11013.623900@beluga.mojam.com> Emmanuel> I would like to reload a module, AND the module that are used Emmanuel> in this module. Are you trying to reload an extension module written in C? I don't think that's supported. In any case, even if your Camera module is written in C, reloading it won't recursively reload the modules it imports. You'd have to grovel around in Camera's __dict__ and locate the objects there that are modules, then call PyImport_ReloadModule for them, etc. Then you have the problem of locating modules that are imported within functions. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From jamwt at jamwt.com Thu Jun 14 19:33:01 2001 From: jamwt at jamwt.com (James Turner) Date: Thu, 14 Jun 2001 16:33:01 -0700 Subject: Upon reflection... In-Reply-To: ; from rod_weston@yahoo.com on Thu, Jun 14, 2001 at 12:10:50PM -0700 References: Message-ID: <20010614163301.G18379@mail.coursepeek.com> Um. This sounds like a very idealistic way to find the "Right language to do X." Foolishly idealistic, maybe. I understand that you do not want to "collect languages," but oftentimes programmers collect them because they *are* in pursuit of the right language for X. Not just the right language, but the right language _for them_. You need to collect languages first--soon you'll find yourself tending to use one more often than the others. It's a bit like the dating game (bad metaphor, I know...): It's a bad idea to just ask your friends who the best catch is, and marry blindly. You probably should date and get to know people yourself! Anyway, stupid rant, but the way you're approaching finding "the right" language sounds a bit silly to me. I don't know if it's possible to truly be a programmer without having dabbled so that you really understand why you're making your choices. Everyone's an evalgelist anyway. You can't really find many good, unbiased opinions cruisin' mailing lists/newgroups. --James PS -- Oh what the hell, I'll save you time: Python is the best. :c) -- _ _ ___ _ | || |___ _ __ ___ _ _ / _ \ _ _ ___| |_ ___ ___ | __ / _ \ ' \/ -_) '_| | (_) | || / _ \ _/ -_|_-< |_||_\___/_|_|_\___|_| \__\_\\_,_\___/\__\___/__/ --------------------------------------------------------------------- "What's the point of going out, we're just going to end up back here anyway?" From BPettersen at NAREX.com Tue Jun 19 18:11:08 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Tue, 19 Jun 2001 16:11:08 -0600 Subject: How can I format the string according to its length at runtime? Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D49B@admin56.narex.com> > From: ed_tsang at yahoo.com [mailto:ed_tsang at yahoo.com] > > I am trying to supply the precision formating at run time: > > s = 123 > print '(0x%-6X -)'%s > > where I try to dynamically supply the number 6 from (6- length of s), > I can't find a way to dynamically supply that. Use the * specifier >>> s = 123 >>> '(0x%-*d)' % (6, s) '(0x123 )' >>> -- bjorn From thomas at xs4all.net Tue Jun 5 08:56:37 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 5 Jun 2001 14:56:37 +0200 Subject: spurious IndexError [interfacing with swig generated code] In-Reply-To: <3b1cb8cb$0$15024$ed9e5944@reading.news.pipex.net>; from jonathan@webtop.com on Tue, Jun 05, 2001 at 10:47:39AM +0000 References: <3b1cb8cb$0$15024$ed9e5944@reading.news.pipex.net> Message-ID: <20010605145637.X690@xs4all.nl> On Tue, Jun 05, 2001 at 10:47:39AM +0000, jonathan at webtop.com wrote: > We've been using swig to generate a python binding to a company > C++ class library. > I've spotted a bug/problem which occurs in the following code : > [call to unrelated SWIG generated constructor] > w ="article"; > v ="articl"; > print w==v; # fails here with a spurious IndexError (list index out of range) What is probably happening is that an earlier operation causes an IndexError exception, and the error isn't being cleared. The assignment operation only checks for errors if one of the functions called returns a value that indicates an error, so it won't get detected until either something raises an error (and overwrites the old error) or a function *might* have set an exception -- which is what the compare operation does. You can test whether an exception occured using PyErr_Occurred() from C. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From nperkins7 at home.com Tue Jun 5 23:33:42 2001 From: nperkins7 at home.com (Nick Perkins) Date: Wed, 06 Jun 2001 03:33:42 GMT Subject: Obsolesence of <> (fwd) References: <9f6el30dv5@enews2.newsguy.com> <3B16D681.E12A4554@Lugoj.Com> <9f7pmt029se@enews1.newsguy.com> <3B17D9B9.E3CA8EC8@Lugoj.Com> <9fjgjl$rp0$1@brokaw.wa.com> Message-ID: "Jonathan Gardner" wrote in message news:9fjgjl$rp0 > But, in the end we are limited by ASCII. Hopefully, when everyone uses > unicode editors, and when they figure out how to get their keyboard to work > properly, we can adopt a more mathematical terminology, and include several > more operators that aren't in ASCII (like the dot for dot product). In the > end, shouldn't we try to make what is written in the program as legible to > mathematicians as possible? I mean, the closer the language stays to math, > the more logical it will be. Speaking of mathematical notation... I have been thinking for years that mathematicians should start to use notations that are more writable (or writable at all), in ASCII. Computer languages can express exactly the same terms that mathematicians would write with their seemingly endless 'special characters', greek letters, sub-scripts, sub-sub scripts, things written over and under other things, etc,etc. Is there in fact any standard way of converting something from 'mathematical notation' to somehting in ASCII? I guess there is one for every computer language, but is there one for human consumption? When two mathematicians exchange e-mail, how do they write a formula that would otherwise use such 'mathematical notation'? From pmoscatt at bigpond.net.au Tue Jun 19 05:27:23 2001 From: pmoscatt at bigpond.net.au (Peter Moscatt) Date: Tue, 19 Jun 2001 09:27:23 GMT Subject: Setting Dialog Box Captions ?? References: <9gldqt$9gkgf$1@ID-50400.news.dfncis.de> Message-ID: <%VEX6.142689$ff.1085957@news-server.bigpond.net.au> Thanks Aurelio..... just what I needed. Pete. Aurelio Mart?n wrote: > > Peter Moscatt escribi? en el mensaje de noticias > mQlX6.140495$ff.1066592 at news-server.bigpond.net.au... >> How does one place a "Title" in the master frame ? >> >> For example, if I was to have the following code: >> >> from Tkinter import * >> root=Tk() >> w=Label(root, text="Hello World") >> w.pack() >> root.mainloop() >> >> And now I wanted to place "This is My Test Dialog" as the caption for the >> root frame - how would I doo this ? >> >> Regards >> Pete >> >> > > root.title( "This is My Test Dialog" ) > > > > From eppstein at ics.uci.edu Fri Jun 15 16:01:51 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Fri, 15 Jun 2001 13:01:51 -0700 Subject: coroutines? References: <9gdnp8$80c$1@panix3.panix.com> Message-ID: In article <9gdnp8$80c$1 at panix3.panix.com>, aahz at panix.com (Aahz Maruch) wrote: > >What I really want is coroutines. > > See PEP 255, posted just a couple of days ago. ;-) Looks like a very nice feature, but I don't think it solves my problem -- I already have everything in a nice list I can iterate over, the problem is that I have to simulate the iteration by hand rather than using a nice for loop because the control flow is incompatible with the windowing system. PEP 219 looks more relevant, but doesn't look ready for prime time (and hasn't been ported to the Mac)... -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From aahz at panix.com Fri Jun 1 12:17:55 2001 From: aahz at panix.com (Aahz Maruch) Date: 1 Jun 2001 09:17:55 -0700 Subject: Python + threads + wxWindows = segfault, help! References: Message-ID: <9f8f7j$k5c$1@panix6.panix.com> In article , Greg Copeland wrote: > >I'm working on a project that has a multithreaded wxPython >application. I working on an SMP box. Can anyone tell me >what might be causing this to happen? > >Fatal Python error: ceval: orphan tstate If you're using Python 1.5.2, upgrade to Python 2.x; there's a thread bug in 1.5.2 with SMP combined with creating/destroying large numbers of threads. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Characters exist to suffer, you know. An author needs a little sadism in her makeup." --Brenda Clough From aleaxit at yahoo.com Fri Jun 15 08:05:45 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 15 Jun 2001 14:05:45 +0200 Subject: Office's Access XP ODBC DBI from PythonWin References: <9ga6cd02m44@enews1.newsguy.com> Message-ID: <9gctnb06cu@enews1.newsguy.com> "M.-A. Lemburg" wrote in message news:mailman.992600484.5506.python-list at python.org... ... > Benjamin Schollnick wrote: > > > > > mx.ODBC > > > instead > > > > of ODBC? If you don't plan commercial use it is free, and I can certainly > > > > recommend it for ease of use. > > > > > > Seconded. But a minimally-working free odbc would still be > > > a good thing IMHO. Say I write utilities to be internally > > > used here at work (commercial use by mx's terms). As long ... > > I was told point blankly by Marc that even though I was using MxODBC, > > for my own non-commercial projects, that since I was using it at work > > it had to be commercially licensed.... Even though the app was not be > > distributed, and just a simple CGI script... > > How is this different from using say WinZIP in a commercial > environment ? I completely agree that it IS no different! That's exactly why I think we need the equivalent of PowerArchiver (see, e.g., http://www.powerarchiver.com) -- well, PA is not "minimal", but I hope the parallel is suggestive anyway. > I believe that the mxODBC license is very liberal > compared to other commercial software (usage is free for private > use, you get the complete source code, etc.) and certainly not > too expensive for a company to license. Absolute agreement. But the issue I have in mind is: Fred Smith is all fired up about using his newfound Python skills to make a little utility for company internal use, which needs to access various corporate and departmental databases. He tries doing it with the free odbc, but that one keeps crashing -- forget it. So he faces a choice: a. doing it with ADO, using the freely downloadable win32all extensions and freely downloadable MSDAC b. convincing the boss to pay for an mxODBC license Advantage of [b] is getting sourcecode AND being able to run the resulting utility on Linux boxes. Advantage of [a] is, Fred can get right down to programming and avoid the boss-convincing step. If Fred is REALLY REALLY *VERY* KEEN to have sourcecode to all he uses, he may try [b] -- and may be or not be able to convince the boss. Most Freds in this world, I fear, will go for the easier choice of [a] instead. Most bosses are Windows-heads anyway and, for an utility that's not going to be a revenue generator for the company anyway, will instantly pick [a], too. If the free odbc didn't crash quite SO much, maybe it could be kept as a viable c. choice -- and help in a tiny way to make Linux boxes (and maybe free BSD variants too:-) more viable... > > I don't mind that, I can understand where he was coming from... But > > win32's ODBC code seems to work fine for our purposes, and should still > > be developed....or maintained... > > > > MxODBC can't be the only ODBC code out there..... > > ODBC is *very* complicated and maintaining an interface for it > to make the user experience a painless one *very* time consuming. You are surely right on this (which underscores Microsoft's wisdom in not-so-opaquely divorcing themselves from ODBC in a gradual way and pushing for their Ole/DB-ADO approach...). Alex From fgeiger at datec.at Tue Jun 5 02:26:48 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Tue, 5 Jun 2001 08:26:48 +0200 Subject: PMW and Python 2.1 References: Message-ID: <9fhu3j$lp4$1@newsreaderm1.core.theplanet.net> I have none encountered so far. Regards Franz "Robert Hicks" wrote in message news:rlWS6.1419$ri1.7702492 at news2.news.adelphia.net... > Are there any problems running the latest PMW with Python 2.1? > > Bob > > From bernhard at intevation.de Thu Jun 28 13:31:53 2001 From: bernhard at intevation.de (Bernhard Reiter) Date: 28 Jun 2001 17:31:53 GMT Subject: PEP scepticism References: <9hfg1n$du33c$1@ID-89274.news.dfncis.de> Message-ID: <9hfpm9$dsllb$2@ID-89274.news.dfncis.de> In article , Steve Horne writes: > On 28 Jun 2001 14:47:19 GMT, bernhard at intevation.de (Bernhard Reiter) > wrote: > >>This a general warning against the second system syndrom in Python. > > I think you may have a good point for the future, but I'm actually a > big fan of some of those recent additions to Python. As I wrote in my post, I do not want to discuss the advantages or disadvantages of single additions even though I have mentioned them. I hope I can explain my cause without being specific. > Extremely familiar to anyone with a C, C++ or Java background, and > something that I was annoyed to have to live without when I first used > Python. I am not sure if this is good reasoning, just because people know a feature from other languages might not make it a good one (or we all end up with perl :) ). > Another large group of Python programmers have a background in > functional languages, and will immediately understand In my experiences a lot of functional programming language features are too complex and abstract for most people to really add them to their active programming vocabulary. > I can understand the wish to only have one way to solve any problem, > but it really isn't that great an approach. > have you ever met an > electrician who only owns a single screwdriver? - I think not. Doing a > good job means using the right tool for the job, not forcing a single > tool to do every job. Of course this is a matter of balance, I prefer a minimal set of tools which gives me maxmimum power. There will always be some overlap of course. Still one aim is to keep the number of tools small. Some additions to python are of course badly needed. Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) FSF Europe (fsfeurope.org) From netmgr at canterburycrest.org Thu Jun 21 18:19:09 2001 From: netmgr at canterburycrest.org (Ross Brattain) Date: Thu, 21 Jun 2001 15:19:09 -0700 Subject: Getting actual name of passed arg Message-ID: <3B3272DD.4000308@canterburycrest.org> I am thinking about a debugging function that takes an arg and prints the arg name and value. a = 1 def foo(b): print ":" + b foo(a) would print "a: 1" Mostly for simple types. I know you can get the id via id(), but that doesn't work for pass by value. I can't find anything in inspect that would work. I imagine it isn't possible because most things are passed by value. Is there someway of mapping id() to variable name. So that I could define def bar(b, c): print str(b) + str(c) bar(a, id(a)) Ross Brattain netmgr at canterburycrest.org From scarblac at pino.selwerd.nl Tue Jun 19 07:10:24 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 19 Jun 2001 11:10:24 GMT Subject: why is there no class (static) methods in Python ? References: <3B2D114E.7B39D954@intraware.com> <3B2D6669.7DEFD13F@intraware.com> <3B2E31A6.9A5B378@intraware.com> Message-ID: Richard Gruet wrote in comp.lang.python: > No, I completely disagree. WHY should they be *global* functions rather than > *class* functions (since they are strictly related to the class) ? You provide no > arguments ! Using the class namespace rather than the module namespace for > class-related functions seems more natural (and object oriented) to me. To me, a class defines what you can do with instances. It's like a blueprint for an instance. Functions that do something with an instance are inside the class. On the other hand, functions that don't operate on a specific instance but on the class as a whole, are not part of the blueprint, but something that acts on the blueprint, and should therefore be defined outside of it. > And finally, I wonder why they are class methods in Java ? They should listen to > your arguments and remove them ;-) Java no standalone functions... even main() is a class method. If you want to take that brain-damaged design as an example, don't expect me to follow :-) > But I don't want to dispute endlessly. I -and other people- would simply like > that such a feature be available in Python, that's all! Class methods would be a bit nicer when inheriting from a class. That's the main point in favor of them, imo. -- Remco Gerlich From support at internetdiscovery.com Sun Jun 10 14:05:32 2001 From: support at internetdiscovery.com (Mike Clarkson) Date: Sun, 10 Jun 2001 18:05:32 GMT Subject: Tkinter and Win 95 References: Message-ID: <3b23b495.1115860@24.0.228.33> On Wed, 6 Jun 2001 11:36:34 +0100, Robin Becker wrote: >I'm running Python 2.1 with Win32 and am using Pmw as a framework for >building an App. I'm having problems when killing the app using the >window manager. In particular under win95 although the application >window disappears I sometimes get a hanging python process. This process >can be killed using the standard techniques, but it leaves something >behind that effectively prevents Win95 from shutting down completely. >Something that is intensely annoying as it prevents clean autobooting >etc. There are a couple of different ways by which this come about, some Tk, some Tkinter. The most likely is because Tkinter is withdrawing and not using the "." window, the other toplevel windows are being destroyed and "." is still keeping the application alive. Do you have a copy of (pure Tk) tkinspect around, or any wish where you can do a [winfo interps] and [send $interp wm deiconify .] to see if "." is still around and the intepreter is responding. Is the "hung" process consuming any CPU? >I am using the traditional trick of handling the wm event as > > ..... > self.root.wm_protocol("WM_DELETE_WINDOW",self.quit) > ....... > def quit(self): > self.root.destroy() > >but how can I get this to work cleanly on Win95? As I recall, that traditional trick is a traditional pitfall under some circumstances. In self.quit you should explicitly do a self.root.wm_protocol("WM_DELETE_WINDOW", None) before calling the destroy, otherwise you can get an infinite loop. BTW, which version of Tk, which version of Tkinter, and what O/S? Mike. From rnd at onego.ru Wed Jun 20 06:08:05 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 20 Jun 2001 14:08:05 +0400 (MSD) Subject: PEP 255: Simple Generators In-Reply-To: <31575A892FF6D1118F5800600846864D78BD63@intrepid> Message-ID: Pipes instead of generators: q = openpipe() def g(pipe): for i in range(10): pipe.put(i) # this brings g into sleep till pipe is read raise StopIter # this will be raised where reading from pipeoccurs g(q) # here we call function with stops for sending to pipe for gg in q(): if cond(gg): print gg else: q.close() # kill q break There could be more objects/functions registered for certain pipe. Of course, parallelly working objects are even better, but this approach also works and doesn't restrict itself to generators. Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From ffp_randjohnson at yahoo.com Sat Jun 16 13:49:20 2001 From: ffp_randjohnson at yahoo.com (Mike Johnson) Date: Sat, 16 Jun 2001 10:49:20 -0700 Subject: Using the While Loop References: <20010616.101117.1469262009.1725@behemoth.miketec.com> Message-ID: <20010616.104916.648031326.1725@behemoth.miketec.com> Brillant! Thank you! In article , "Greg Jorgensen" wrote: > Python assignments are statements, not expressions. You are probably > used to C, C++, or Java. In Python the statement "line = > myfile.readline()" is not an expression and doesn't have a value, so > it's not syntactically valid following if or while. Your second example > is the canonical Python form for reading lines sequentially from a file. -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From davygrvy at pobox.com Sun Jun 17 13:46:01 2001 From: davygrvy at pobox.com (David Gravereaux) Date: Sun, 17 Jun 2001 10:46:01 -0700 Subject: when embedding Python, how do you redirect stdout/stderr? References: <992537747.711779@rexx.com> Message-ID: Dave Kuhlman wrote: >If you want to do it all in C, then I do _not_ have an answer for >you. > >However, if you want to do some of it in Python and initiate it >from C, then create a Python class with a "write" method and use >PyRun_SimpleString to assign an instance of that class to >sys.stdout. Ok, now I'm stuck. In my Py::Std class i'm sending it the address of 2 functions I'd like to call when text is sent to stdout and stderr. I've gotten that far, but now how do I make a python object of this? Here's what I have so far. I got kinda dizzy looking at Modules/xxmodule.c for a starting point. Any help would be most appreciated. -- David Gravereaux -=[ More Famous and Original than the Ray's across the street Ray's Pizza, NYC ]=- -------------- next part -------------- #include "PyStd.hpp" typedef struct { PyObject_HEAD WriteFunc stdChan; } StdObject; staticforward PyTypeObject Std_Type; Py::Std::Std (WriteFunc _stdOut, WriteFunc _stdErr) : stdOut(_stdOut), stdErr(_stdErr) { } Py::Std::~Std() { } void Py::Std::InitStd() { StdObject *self; self = PyObject_New(StdObject, &Std_Type); self->stdChan = stdOut; PySys_SetObject("stdout", reinterpret_cast(self)); self = PyObject_New(StdObject, &Std_Type); self->stdChan = stdErr; PySys_SetObject("stderr", reinterpret_cast(self)); } static PyObject * write (PyObject *self, PyObject *args) { PyObject *ob; if (!PyArg_ParseTuple(args, "O", &ob)) return NULL; // write here. Py_INCREF(Py_None); return Py_None; } struct PyMethodDef std_methods[] = { {"write", write, METH_VARARGS}, {0L, 0L} }; -------------- next part -------------- /* ------------------------------------------------------------------------------ * PyStd.hpp -- * * Link the standard channels. * * Copyright (c) 1999-2001 Tomahawk Software Group * * See the file "license.txt" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * * RCS: @(#) $Id: TclHash.hpp,v 1.8 2000/12/14 10:52:46 daveg Exp $ ------------------------------------------------------------------------------ */ #ifndef INC_PyStd_hpp__ #define INC_PyStd_hpp__ #include typedef void (*WriteFunc) (PyObject *); namespace Py { class Std { private: WriteFunc stdOut; WriteFunc stdErr; protected: void InitStd(); public: Std (WriteFunc _stdOut, WriteFunc _stdErr); ~Std (); }; } // namespace Py #endif // #ifndef INC_PyStd_hpp__ From bokr at accessone.com Fri Jun 15 21:22:38 2001 From: bokr at accessone.com (Bengt Richter) Date: Sat, 16 Jun 2001 01:22:38 GMT Subject: sorting values in dict References: <3b292d23.1831931958@localhost> <9gcob001ca@enews1.newsguy.com> Message-ID: <3b2ab4dc.600088671@wa.news.verio.net> On Fri, 15 Jun 2001 12:33:50 +0200, "Alex Martelli" wrote: >"Victor Muslin" wrote in message >news:3b292d23.1831931958 at localhost... >> This may not be the shortest or most efficient, but it does the trick: >> >> a={'a':9,'b':8,'c':7} >> l=[] >> for k,v in a.items(): >> l.append((v,k)) >> l.sort() >> for v,k in l: >> print v,k > >I think it's pretty close, except that, to build l, > l = [(v,k) for k,v in a.items()] >may be (very slightly) shorter and more efficient. > Nobody seems to be doing it my way: -- def sortedItemsOfDir(d,dir='a'): #'d'escending else default if dir=='d': def cmpi(x,y): #descending if x[1]>y[1]: return -1 if x[1]y[1]: return 1 if x[1]>> from sortdir import sortedItemsOfDir >>> d={'a':5,'b':2,'c':3,'d':1} >>> sortedItemsOfDir(d) [('d', 1), ('b', 2), ('c', 3), ('a', 5)] >>> sortedItemsOfDir(d,'d') [('a', 5), ('c', 3), ('b', 2), ('d', 1)] >>> for k,v in sortedItemsOfDir(d): print k,v ... d 1 b 2 c 3 a 5 >>> for k,v in sortedItemsOfDir(d,'d'): print k,v ... a 5 c 3 b 2 d 1 From syver at NOSPAMcyberwatcher.com Wed Jun 27 19:21:52 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Thu, 28 Jun 2001 01:21:52 +0200 Subject: SocketServer crash on my machine Message-ID: <9hdpu1$o1h$1@troll.powertech.no> Hi pythonistas. I was checking out the the SocketServer example in Mark Lutz rather excellent book Programming Python 2 edition, when ('127.0.0.1', 1120) Thu Jun 28 00:54:00 2001 Exception in thread Thread-1: Traceback (most recent call last): File "d:\devtools\python21\lib\threading.py", line 378, in __bootstrap self.run() File "d:\devtools\python21\lib\threading.py", line 366, in run apply(self.__target, self.__args, self.__kwargs) File "d:\devtools\python21\lib\SocketServer.py", line 246, in finish_request self.RequestHandlerClass(request, client_address, self) File "d:\devtools\python21\lib\SocketServer.py", line 495, in __init__ self.handle() File "H:\My Documents\Kode\pythonscript\Syver\class-server.py", line 20, in ha ndle data = self.request.recv(1024) File "", line 1, in recv AttributeError: 'int' object has no attribute 'recv' happened, or rather it happens everytime I try it. I've even tried it on a different machine with the ActiveState distro rather than the BeOpen distro that I am using on my machine. Is there anyone out there that can successfully run this piece of code and receive a request. If anyone cares to test it, run the code below (or the class-client.py from Mark Lutz'es book) in a shell window and popup a browser to http://localhost:50007 You should get the ipaddress of your client and the time, then after 5 seconds the server should crash with the traceback above. Needless to say this crash happens using the socket module to connect to the server too. My configuration, BeOpen python 2.1 win32all 140, win2000 pro. #--------------------------------------------------------------------------- ---- import SocketServer import time MyHost = '' # means localhost MyPort = 50007 def now(): return time.ctime() class MyClientHandler(SocketServer.BaseRequestHandler): def handle(self): print self.client_address, now() print self.request time.sleep(5) while 1: data = self.request.recv(1024) if not data: break self.request.send('Echo=>%s at %s' % (data, now())) self.request.close() # make a threaded server myaddr = (MyHost, MyPort) server = SocketServer.ThreadingTCPServer(myaddr, MyClientHandler) server.serve_forever() #--------------------------------------------------------------------------- ---- Is the code itself wrong or is it something wrong with the underlying implementation, SocketServer or the socket module? If the code isn't wrong in itself, it might well be the SocketServer as the examples with the examples with multi threaded sockets but without the Socket server run just fine on my machine (as well as the single threaded one's). From emile at fcfw.fenx.com Mon Jun 11 09:58:00 2001 From: emile at fcfw.fenx.com (Emile van Sebille) Date: 11 Jun 2001 08:58:00 -0500 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Jun 11) Message-ID: Hamish Lawson reminds us of Frank Willison's Article "Time for the Python Community to Step Up to the Plate", which calls for more contributions to the CookBook, and it appears to have spurred some on. http://groups.google.com/groups?ic=1&q=msgid:915a998f.0106040825.64991b57 at posting.google.com In this week's episodes of "Who needs bugs when you've got IEEE 754 floating point: The Series", Tim Peters takes on floating point again and conjures up a 53 place exact binary representation. http://groups.google.com/groups?ic=1&q=msgid:mailman.991786869.19811.python-list at python.org ...Don Dwiggins calls for an evaluation in light of CP4E http://groups.google.com/groups?ic=1&q=msgid:mailman.991685948.23344.python-list at python.org ... and Jason Riedy, a member of the IEEE 754R revision group, tells us that changes to the specs are in the works. http://groups.google.com/groups?ic=1&q=msgid:9fp4cd$2sgt$1 at agate.berkeley.edu David Cohen introduces pyagent version 1.00, an open infrastructure for intelligent agents based on Frederik Lundh's implementation of XML-RPC http://groups.google.com/groups?ic=1&q=msgid:PuqT6.79411$FS3.630510 at sjc-read.news.verio.net Anthony Tuininga announces a Win32 binary for Python 2.1 of cx_Oracle, a module which provides a Python DB-API 2.0-compliant method for accessing Oracle databases http://groups.google.com/groups?ic=1&q=msgid:mailman.992040540.10455.clpa-moderators at python.org Rod Weston asks about OOP, and Roman Suzi points out that it is necessary to remember that OOP is the third phase of OOA-OOD-OOP. None the less, the discussion rapidly pulls in comparisons and opinions on many languages. http://groups.google.com/groups?ic=1&q=msgid:f7ce0059.0106060942.69f28e91 at posting.google.com Steven Haryanto starts the ball rolling with "WHY is python slow?". Several people nudge it forward, but the short answer seems to be "define real-world slow". Or was it the lack of blue skies, money, and braces? http://groups.google.com/groups?ic=1&q=msgid:mailman.991900751.7603.python-list at python.org http://www.zopenewbies.net finds its own home. With 2.1 now required as of Zope 2.4.0a1 (see http://www.zope.org/Products/Zope/2.4.0a1/zope_240a1_released ) and a continuing effort to accommodate python programmers as well as content managers, this site should be a valuable resource. Bernard Herzog announces MapIt! 1.0. http://groups.google.com/groups?ic=1&q=msgid:mailman.992040540.10454.clpa-moderators at python.org Those of you familiar with GIS applications will want to take a look at MapIt!, a web-application that lets you navigate raster-maps through your web-browser and lets you zoom in and out and select objects and object classes that are identified on the map. Next time I do one of these, I'll start with this. Jesus Cea Avion asks how to examine an exception and pass it on unchanged: http://groups.google.com/groups?ic=1&q=msgid:3B20F235.1FC3A9A at argo.es Robin Becker, in the "explode your head" category, asks about the proper method for dynamically generating classes with inheritance: http://groups.google.com/groups?ic=1&q=msgid:19l8IVAAgJI7EwAk at jessikat.demon.co.uk James Althoff explains how he emulates a GUI development for Jython in the midst of discussing the benefits of Python over Java http://groups.google.com/groups?ic=1&q=msgid:mailman.991938793.12848.python-list at python.org ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the daily python url http://www.pythonware.com/daily comp.lang.python.announce announces new Python software. Be sure to scan this newly-revitalized newsgroup at least weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Michael Hudson continues Andrew Kuchling's marvelous tradition of summarizing action on the python-dev mailing list once every other week. http://starship.python.net/crew/mwh/summaries/ http://www.amk.ca/python/dev The Vaults of Parnassus ambitiously collect Python resources http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ The Python Software Foundation has replaced the Python Consortium as an independent nexus of activity http://www.python.org/psf/ Cetus does much of the same http://www.cetus-links.de/oo_python.html Python FAQTS http://python.faqts.com/ 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 tricks of the trade: http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python&num=100 http://groups.google.com/groups?meta=site%3Dgroups%26group%3Dcomp.lang.python.* Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://groups.google.com/groups?oi=djq&as_q=+Python-URL!&as_ugroup=comp.lang.python Suggestions/corrections for next week's posting are always welcome. [http://www.egroups.com/list/python-url-leads/ is hibernating. Just e-mail us ideas directly.] To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From ajwms at visto.com Mon Jun 4 14:31:28 2001 From: ajwms at visto.com (Andrew) Date: 4 Jun 2001 11:31:28 -0700 Subject: xmlrpc Server References: <2f14b602.0106030721.441faa31@posting.google.com> <3b1a674e$1_1@news5.uncensored-news.com> <2f14b602.0106040504.3a8997d7@posting.google.com> Message-ID: <2f14b602.0106041031.64f11691@posting.google.com> "Fredrik Lundh" wrote > as its name implies, a request handler object handles a > single request. I'm with you... I kind-of thought that but I still don't trust my newbie skills... > > to create a "persistent" object, attach it to the server > class. something like this could work: > > class TestRequestHandler(xmlrpcserver.RequestHandler): > > ... > > def add(...): > self.server.x = self.server.x + value > return "sum = %s" % self.server.x > > class TestServer(SocketServer.TCPServer): > > def __init__(self, port=8000): > self.x = 0 > SocketServer.TCPServer.__init__(self, ('', port), TestRequestHandler) > > server = TestServer() > server.serve_forever() > > cool. Works perfectly. Based on this, if I create a class to connect to a db and pull data, then I simply need to subclass SocketServer.TCPServer, make sure I call the SocketServer.TCPServer __init__ method in my own __init__ method and I'm off to the races... I only have to write methods in the "TestRequestHandler" to pass off the data "TestServer"... Thanks a lot!! Andrew Williams From cribeiro at mail.inet.com.br Sat Jun 30 13:05:33 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Sat, 30 Jun 2001 14:05:33 -0300 Subject: PEP scepticism In-Reply-To: References: <3dbsn71iac.fsf@ute.cnri.reston.va.us> <9hj2p6$bdu$6@newshost.accu.uu.nl> Message-ID: <5.0.2.1.0.20010630110830.0269b170@mail.inet.com.br> At 12:53 30/06/01 +0000, Guido van Rossum wrote: >So let's all do what we do best: the core developers (e.g. PythonLabs) >improve the language, and the community improves the library. If you say so it's better for us all to listen . Anyway I would like to make a distiction concerning PythonLabs work. You are not only responsible by the language development, but you also define the reference distribution. Improvements on the library - either by coding new modules or optimizing existing ones - may be made by the community, as you said, but that's not any good if these modules don't make it to the standard distribution. So I believe that PythonLabs should at least consider doing three things: - Define clearly what goes and what does not go into the standard library. I suggest that some guidelines should be written, stating what is needed for a module to be considered for inclusion into the standard library. The definition itself may be fairly broad. Quality matters, and the guidelines spec would help making the decision process more clear. - Help track the module development process. PEPs could be used for that, or a different mechanism to track requests could be devised. Sometimes the community will point out the need for a new module - one that still does not exist. In this case, a PEP-like document could be written as a kind of "requirements spec", allowing for anyone interested in contributing to know what kinds of modules are most requested, and how is the implementation expected to work. PythonLabs could coordinate this effort. The actual development could be done by anyone: PythonLabs; volunteers; or even companies, by donating working code. - Compile the standard modules for all supported platforms. As someone else said, many people find it difficult to compile extension modules themselves. I myself can't do it on my Win98 home machine, as I dont have VC++ installed (and I doubt many users have it at home). One advantage of having such a well defined process to elect the standard modules is that it will encourage people to improve the standard modules, instead of re-inventing the wheel. After seeing so many half-baked modules around one must wonder why doesn't people contribute to the existing alternatives. Having one recognized standard helps. The repository may also help to solve this problem. Carlos Ribeiro From whisper at oz.nospamnet Tue Jun 12 14:10:22 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 12 Jun 2001 18:10:22 GMT Subject: Python for win32 development, GUI, Database, dlls References: <9fnrc8$lmp$1@newnews.mikom.csir.co.za> Message-ID: <9g5lue$ird$5@216.39.170.247> In article <9fnrc8$lmp$1 at newnews.mikom.csir.co.za>, kvdwalt at csir.co.za says... > I have been approached in a 'time to market situation'. > > Python appears to me to be a strategic choice, however: > > this is a number crunching application most numeric stuff in existing > (fortran) dll > the new development will entail a lot of visualization, pseudo GIS like, > animation (coloring of contours), plain media (digital picures, video) in > a rich interactive GUI > > then all of this data in MS Access (what else?), with reports and graphs on > top of it. OK the latter can be in a reportwriter as long as one can call an > .exe with commandline parms from python) Integration with MS Office formats > (not ole automation) would be important (thus MS Access for imports > exports). > > Any grave misgivings? > > Any pointers? > Commercial libraries? However the exchange rate doesn't favour that :( > > tx k Python has a rich bag of tricks for approaching this problem. For numerics, there's NumPy at http://sourceforge.net/projects/numpy/ Also, something called ScientificPython: "ScientificPython is a collection of Python modules that are useful for scientific computing. In this collection you will find modules that cover basic geometry (vectors, tensors, transformations, vector and tensor fields), quaternions, automatic derivatives, (linear) interpolation, polynomials, elementary statistics, nonlinear least-squares fits, unit calculations, Fortran-compatible text formatting, 3D visualization via VRML, and two Tk widgets for simple line plots and 3D wireframe models." Find it at: http://starship.python.net/crew/hinsen/scientific.html The other alternative is to use a C extension module or possibly use SWIG to wrap the existing fortran.dll. For visualization, VTK (http://www.kitware.com/vtk.html) with it's python wrapper is almost unbeatable. Used in conjunction with WxWindows or the Fast Light Tookkit, which both have wrapper widgets for VTK, you have a complete open source UI solution with OpenGL based 3D visualization. (N.B. Don't let the "kitware.com" part of the url deter you - they sell support and a great fat book on how to use VTK, but the sources are free and it's unrestricted for commercial uses afaik). For charts and graphs, there is the BLT extension to tkinter. For plain images, check out the Python Imaging Library "PIL". There are ODBC and specific interface packages for all the MS databases (you have my sympathies if using Access and hope you're not in need of performance!) For links to many of these and a whole lot more, check out the Python contributed source repository at http://www.vex.net/parnassus/ Everything mentioned here is free, although the best ODBC library is not, and i'm not sure about commercial use (resale - I think internal use is unrestricted) of PIL. HTH, Dave LeBlanc From s713221 at student.gu.edu.au Sun Jun 10 20:48:14 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Mon, 11 Jun 2001 10:48:14 +1000 Subject: tummy compile Mandrake 7.2 References: <20010608.214013.1469262009.16325@K7.atl.mediaone.net> <20010609.104451.1884661237.1229@K7.atl.mediaone.net> Message-ID: <3B24154E.C70211ED@student.gu.edu.au> myself wrote: > thanks for your reply! well I guess I could have phrased the expat-devel > Q a little better- if devel is a build require, why isn't it included, or > offered as a separate srpm in ftp directory? Or are you saying I need the > "standard" expat pkgs in addition to the tummy ver? (but that's > confusing, as >=1.1-3tummy implies that there *is* a 1.1-3tummy devel > available)?? WRT line 246, surely someone here will be able to shed some > light for both our benefits- I haven't seen many problems go unsolved in > this ng (hint-hint). Actually I don't expect a necessarily specific > answer, just a clue where to look would suffice (hopefully). It depends on how the tummy-expat spec file was built. Some packagers just throw everything in together, binaries, libraries, documents and header files into a package called . Others split up a build into a .rpm, -docs.rpm, -devel.rpm and maybe even a -lib.rpm As well as removing the buildprereq: expat-devel, you can also mung it by changing it to expat only (I.E. get rid of the -devel bit.). > OTOH, this gives me an opportunity to actually post here- this really is > an _excellent_ group! If you want a prebuilt rpm for Mandrake 7.2, I could always email you my build, but I understand if you want to build it from source. Lotsa pythonieering, -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From aleaxit at yahoo.com Wed Jun 20 15:06:29 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 20 Jun 2001 21:06:29 +0200 Subject: raw_input References: <_x5Y6.18111$9r1.1628947@e3500-atl1.usenetserver.com> Message-ID: <9gqsbu01cbs@enews1.newsguy.com> "Brendhan Horne" wrote in message news:_x5Y6.18111$9r1.1628947 at e3500-atl1.usenetserver.com... > >>> raw_input ("Enter your name:") > Enter your name:Brendhan > 'Brendhan' > >>> print name > Traceback (innermost last): > File "", line 1, in ? > print name > NameError: There is no variable named 'name' > > Okay What did I do wrong it should have printed my name after the print name > command. You did not bind the result of raw_input to any variable, in particular not to one named 'name'. Change the first statement to: >>> name = raw_input("Enter your name:") Alex From arend at vonderlieth-online.de Fri Jun 29 03:38:10 2001 From: arend at vonderlieth-online.de (Arend von der Lieth) Date: Fri, 29 Jun 2001 07:38:10 GMT Subject: module for A/D-converter? Message-ID: <20010629.7381058@fb11lfm15.fh-muenster.de> Hi everybody, I am wondering if there is a way to implement a program (with python of course) that reads values from an A/D-converter card. More precisely: I want to read data from an oscilloscope and do not want to use the languages that we used before (C, Pascal, VBS) Thanks in advance, Arend From alankarmisra at hotmail.com Sun Jun 3 09:46:25 2001 From: alankarmisra at hotmail.com (gods1child) Date: 3 Jun 2001 06:46:25 -0700 Subject: I had a thought ... (I know, call the newspapers). References: <3B172894.9B64F46F@my.signature> Message-ID: <25b2e0d9.0106030546.7b0089f0@posting.google.com> would something like this work? it needs to be extended for other arithmetic ops but thats trivial if the core approach is correct. I've used the str representation of the numbers since it seems to accurately depict what the value SHOULD be as a string and not the stored numeric value. If the str depiction is incorrect in certain cases, then the whole approach is wrong. import types import string import sys class money: def __init__(self, num): if isinstance(num, money): self.accuracy = num.accuracy self.__num = num.__num else: # accuracy upto n decimal places self.accuracy = 4 # arg has to be a non-complex number self.checkArg(num) # remove the decimal point num_parts = string.split(str(num),'.') # no decimal point, int or long ? if len(num_parts)==1: # 'multiply' by pow(10,accuracy) string_num = num_parts[0] + '0' * self.accuracy # decimal places exceed accuracy limit ? elif len(num_parts[1]) > self.accuracy: raise TooManyDecimalPlacesException else: # 'multiply' by pow(10,accuracy) string_num = string.join(num_parts,'') \ + '0' * (self.accuracy - len(num_parts[1])) try: # try using the smallest holder self.__num = int(string_num) except: self.__num = long(string_num) def __add__(self,num): if isinstance(num, money): try: # convert self.__num to long to avoid integer overflow error return money((num.__num + long(self.__num))/10000.0) except TooManyDecimalPlacesException: raise ('Invalid argument ' + str(num) + \ '. Cannot work with > ' + \ str(self.accuracy) + ' decimal places.') except: print sys.exc_info() else: self.checkArg(num) try: return money(num + (self.__num/10000.0)) except TooManyDecimalPlacesException: raise ('Invalid argument ' + str(num) + \ '. Cannot work with > ' + \ str(self.accuracy) + ' decimal places.') except: print sys.exc_info() __radd__ = __add__ def checkArg(self, num): if not ( type(num) is types.IntType or type(num) is types.LongType or type(num) is types.FloatType ): raise ValueError, 'Only non-complex numbers are allowed in arithmetic operations for money' def __str__(self): return str(self.__num/10000.0) __repr__ = __str__ class TooManyDecimalPlacesException(ValueError): pass # Usage print 'Evaluating val = money(1.0) + .01 + .001 + .0001 + 1 + 1L' val = money(1.0) + .01 + .001 + .0001 + 1 + 1L print 'Result:', val print print 'Evaluating isinstance(val, money)' print 'Result:', isinstance(val, money) print print 'Evaluating anotherval = money(val): anotherval is val' anotherval = money(val) print 'Result:', anotherval is val From andy at mindgate.net Mon Jun 25 15:09:16 2001 From: andy at mindgate.net (Andy) Date: Tue, 26 Jun 2001 03:09:16 +0800 Subject: Is this a mimetools/rfc822 bug? Message-ID: samplemsg="""Date: Fri, 04 May 2001 14:29:01 +0200 From: Lars Degerstedt To: java-linux Subject: Stacktraces without line numbering? Message-ID: <3AF2A08D.9C4ACF38 at telia.com> Content-Type: multipart/mixed; boundary="------------F801EFF1B3CEC2D197CE3D3F" This is a multi-part message in MIME format. --------------F801EFF1B3CEC2D197CE3D3F Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Blah Blah --------------F801EFF1B3CEC2D197CE3D3F Content-Type: text/x-vcard; charset=us-ascii; name="lars.degerstedt.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Lars Degerstedt Content-Disposition: attachment; filename="lars.degerstedt.vcf" blah blah --------------F801EFF1B3CEC2D197CE3D3F-- """ import StringIO, mimetools msgstream=StringIO.StringIO(samplemsg) email=mimetools.Message(msgstream) print email.gettype() works fine. But when there are leading newlines in samplemsg, it can't read the headers anymore. (Of course, you can always use lstrip... but it took me a while before I found out - not a typical Python experience...) From gradha at iname.com Sat Jun 9 17:58:28 2001 From: gradha at iname.com (gradha at iname.com) Date: Sat, 9 Jun 2001 23:58:28 +0200 Subject: Is this fake module correct for distribution? Message-ID: <466uf9.h57.ln@127.0.0.1> Hi. I have been writing python code for not quite long, and I don't want to have to spend years of my life to find a style which is nice, documented and readable by other lifeforms. Hence, I've packed a small script which I will be using in another proyect as if it was a program on it's own, and I want to ask you to take a look at it and tell me as end users what you think of it, poor/good documentation, readable, wrong style, more files required containing whatever you want as a user, etc. You can get it (2327 bytes) at: http://leo.worldonline.es/jerzegor/localize_time.py.tar.bz2 Hoping to learn from your comments, TIA. -- Grzegorz Adam Hankiewicz gradha at terra.es http://gradha.infierno.org From thomas at gatsoft.no Wed Jun 27 03:09:37 2001 From: thomas at gatsoft.no (Thomas Weholt) Date: Wed, 27 Jun 2001 07:09:37 GMT Subject: Validating XML-parser using XML Schema? Message-ID: Hi, Are there any validating XML-parsers out there using XML Schema instead of DTD? Thomas From tim.one at home.com Sat Jun 30 23:40:54 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 30 Jun 2001 23:40:54 -0400 Subject: PEP scepticism In-Reply-To: <9hltd9$gfg$2@newshost.accu.uu.nl> Message-ID: [Martijn Faassen] > ... > And as I suggested in my post, if standard library development is indeed > not part of the primary sets of interests of the core developers, I'm not sure Guido expressed himself clearly enough there. All the core developers have done major work on the libraries, so that's not a hangup. What is a hangup is that people also want stuff the current group of core developers has no competence (and/or sometimes interest) to write. Like SSL support on Windows, or IPv6 support, etc. Expert-level work in a field requires experts in that field to contribute. We also need a plan to keep their stuff running after they go away again, the lack of which is one strong reason Guido resists adding stuff to the library. > perhaps it would be good to set up an semi-formal group that *does* > treat this as their 'core business' (manage core library development > and perhaps even independent releases) A library-SIG, perhaps? Start by adding some meat to PEP 2. > In general, the idea is that perhaps we don't have hundreds of Andrew > Kuchlings (to quote Tim) is because there is no place or group to > attract them. A bit of a chicken and egg problem, of course. :) Part of what makes Andrew Andrew is that he didn't wait for anyone to take him by the hand and tell him what to do. He saw things that needed to be done, and *did* them, fighting when necessary to get his work out into the world. That's how things get accomplished -- committees and study groups and Usenet debates don't; even the Python SIGs have, overall, a poor track record on delivering results (with notable exceptions). You don't need a group; you need someone able to work and motivated enough to do it without being pushed. you-do-it-for-the-glory-or-not-at-all-ly y'rs - tim From geoff at homegain.com Thu Jun 14 15:14:46 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Thu, 14 Jun 2001 12:14:46 -0700 Subject: base converter Message-ID: <393D961EA4FCD311B03F00D0B746D65803275EA4@HQSXCH01> > From: Fredrik Lundh [mailto:fredrik at pythonware.com] > > (why has decimal to binary conversion suddenly turned into a > FAQ the last few months? it wasn't this way in the old days, > and I cannot remember ever having to output things as binary > numbers in a real-life project... can anyone explain?) I didn't ask, but I ran into a similar question not too long ago. I was looking for a relatively painless way to do the same thing urllib.quote() does for you, except that I needed to convert a handful of "sensitive" characters that urllib.quote() doesn't handle according to the rules I need to use (' ' -> '%20', ',' -> '%2c', '-' -> '%2d', '.' -> '%2e'). I was looking because it seemed like hex(ord(matchObj.group(0)))[2:] was two operations too many for what I was trying to accomplish. At the time, one of my routes of investigation was hunting for something that would give me -just- the string represention of the number in a hexadecimal base, rather than an eval()-able string. I was looking mostly because it seemed like a solved problem, and solved problems are generally represented in the libraries somewhere. It didn't occur to me at the time how difficult it would be to generalize the solution. Later, I came up with "%%%x" % ord(matchObj.group(0)), which was somewhat speedier. But in the end, it was faster in almost all cases to use urllib.quote(), then go back and convert the leftovers one at a time using string.replace(). I'm not sure that a tool to convert between arbitrary bases would be generally useful, or be easy to prepare in such a way as to be more suitable than the tools we already have. And for most common applications, a hand-rolled version as offered in this thread would do just fine. I think converting string data to binary is something you need to do for steganography, too, isn't it? Thanks, --G. --- Geoff Gerrietts Software Engineer, HomeGain.com 510-655-0800 x4320 From elf at halcyon.com Sun Jun 10 13:24:30 2001 From: elf at halcyon.com (Elf Sternberg) Date: 10 Jun 2001 17:24:30 GMT Subject: Has anyone used UML? References: <3b228485.13884244@news.laplaza.org> Message-ID: <9g0age$hrh$1@brokaw.wa.com> In article <3b228485.13884244 at news.laplaza.org> xyzmats at laplaza.org (Mats Wichmann) writes: >on the other hand, it may be that Rational Rose really is >"that damn good" (personally, I have zero experience with it). My experience has been that Rational Rose, in an attempt to cash in and keep up with the demand for a working implementation, have violated the non-Rational parts of the programming paradigm. Their stuff may be designed with UML, but it's often insufficiently tested and their UIs are atrocious. UML does not help one be a better programmer; it helps make one a better component designer. But both UI design and component and system testing are different disciplines. Elf -- Elf M. Sternberg, rational romantic mystical cynical idealist http://www.halcyon.com/elf/ Dvorak Keyboards: Frgp ucpoy ncb. ru e.u.bo.v From root at rainerdeyke.com Wed Jun 6 12:48:50 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 06 Jun 2001 16:48:50 GMT Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3B1B1825.8109BA83@lmf.ericsson.se> <2v4ohtgldvce84sn87kh1eg1lnes37getq@4ax.com> <3B1C9E65.B73A4FE@lmf.ericsson.se> <3B1DFD87.F3BFDB57@lmf.ericsson.se> <3B1E5912.CBB0BCA9@lmf.ericsson.se> Message-ID: "Attila Feher" wrote in message news:3B1E5912.CBB0BCA9 at lmf.ericsson.se... > Rainer Deyke wrote: > > SDL: Game API wrapper. LGPL, so it can be (and has been) used in > > closed-source commercial software. > > > > wxWindows: GUI API wrapper. LGPL with additional permission to redistribute > > in binary form without restriction, so it can be (and has been) used in > > closed-source commercial software. > > > Thanx! I have never payed enough attention than... So you use > wxWindows? Not yet, but I'm planning to. > Last time I saw some important stuff was missing. I don't > do games (YET) but could you post me (Email) a URL to this SDL? http://www.libsdl.org > Who > knows :-))) Do U think I could write a UML thing based on wxWindows? I'm not really qualified to comment on that. > What OSs does it support? Is Apple in it? As far as I remember it > supported X only, which is a trouble if you want to write sthg you whish > to be used in high security places... (like Pentagon :-))) >From the wxWindows FAQ: What platforms are supported by wxWindows 2? * Windows 3.1, Windows 95/98, Windows NT; * Linux and other Unix platforms with GTK+; * Unix with Motif or the free Motif clone Lesstif; * Mac OS; A Mac OS X port is in progress. * A BeOS port is being investigated. * A Windows CE port is being investigated. * An OS/2 port is in progress, and you can also compile wxWindows for GTK+ or Motif on OS/2. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From support at internetdiscovery.com Mon Jun 18 02:26:32 2001 From: support at internetdiscovery.com (Mike Clarkson) Date: Mon, 18 Jun 2001 06:26:32 GMT Subject: idle BUG References: Message-ID: <3b2d9e55.354289@nntp.ix.netcom.com> On Thu, 14 Jun 2001 22:24:47 -0400, "Tim Peters" wrote: >[Robin Becker] >> I think this must be a bug in Tkinter, but since no one ever responds I >> thought I'd whine about idle instead. > >See > >http://sf.net/tracker/?group_id=5470&atid=105470&func=detail&aid=216289 That it. It also happens on Win98. >> I run python2.1 Win95 OSR2. >> Start a command window >> run python idle.py >> >> Kill the idle window using the mouse (click on the x). In some unknown >> percentage of cases (like 50%) the process hangs and doesn't return to >> the command window. >> >> The hung process is very destructive and makes it impossible to reboot >> the machine properly. This bug has been present for a very long time >> and I'm fed up with it. > >Use pythonw instead. Then it doesn't hang. Nobody knows how to fix it, or >even what causes it (follow the link). Unfortunately that's not a complete solution: I've seen this with frozen Tkinter applications too (Python 2.1 Tk 8..3.3 Win98). >> It's clearly some kind of race between python and Tcl/Tk. I don't thiink it's a race condition with Tk. If you modify idle before invoking the mainloop with root.tk.eval('tk appname Idle') root.tk.eval('package require dde') root.tk.eval('dde servername Idle') you can see that the 'hung' process so longer has a Tcl interpreter alive, although the Python process is still alive and consuming CPU. >Fredrik Lundh has provoked the same problems with pure Tcl/Tk apps run from >a wish shell -- no Python components involved. That is, there's no reason >to believe Tkinter or Python have anything to do with this. I've never seen this in the last five years of Tk apps or embedded Tk apps. There's every reason to believe that it's the way Tk is being compiled invoked or closed by Python. The difference between pythonw and python.exe points to a stdin/stdout issue. >> The problem doesn't occur on win2k so I guess there's some >> difference between the run times that helps. Not necessarily - nt and win95 differ hugely in that command.com is 16 bit and cmd.exe is 32. The likely difference could also be something to do with stdin and stdout, which are also treated differently. >Win9x suffers many flaky behaviors related to consoles and processes. >pythonw appears to avoid the hangup problems simply by getting the console >window out of the equation. Without MS's source code at hand, I doubt we'll >ever get a deeper understanding than that. It's not necessarily a flaky behaviour. Harder than getting MS source code is finding someone who understands MSVC's compile and link time options. Rather than assume it's bugs in M$'s code (still present in Win98), we should make sure that it's not Python's fault. From my memory of earlier experiences with the MSVC makefile.vc for Tk, the -DCONSOLE and -subsystem:console compiler and linker flags took a lot of trial and error to get right for wish. Tim, I know you're very busy these days (learning to sketch? :-), but could you examine the MSVC compile and link flags with a microscope for similarities and differences between _tkinter.c and tkappinit.c and tkAppinit.c for wish. Robin, another thing you might try, is after the idle .mainloop() call, do a root.tk.eval('tk_messageBox ...') call to make sure you are exiting the mainloop, and maybe look to see what top level windows are around with root.tk.eval('tk_messageBox [winfo child .] ...') I'm going to try root.tk.eval('catch {close stdin; close stdout}') The problem is serious as you can kill the winoldap but the python.exe is unkillable, an thus inhibits shutdown.* It probably means that anyone who distributes frozen applications may be generating unkillable python processes. It would be nice to kill this problem. PS: The windows process monitor AMD (http://atm.idic.caos.it) shows the python.exe in a T state. PPS: Neither Python nor Tk handle windows WM_QUERYENDSESSION and WM_ENDSESSION events - another topic. From christian at rocketnetwork.com Wed Jun 13 14:05:01 2001 From: christian at rocketnetwork.com (Christian Reyes) Date: Wed, 13 Jun 2001 11:05:01 -0700 Subject: binary file comparison with the md5 module Message-ID: <9g8ahr$s6t$1@bob.news.rcn.net> I'm trying to write a script that takes two binary files and returns whether or not their data is completely matching. One of my peers suggested that an efficient way to do this would be to run the md5 algorithm on each file and then compare the resultant output. Since md5 returns a unique 128-bit checksum of it's input, this should theoretically work. The problem i'm having is with reading the binary file in as a string. I tried opening the file with the built-in python open command, and then reading the contents of the file into a buffer. But I think my problem is that when I read the binary file into a buffer, the contents get tweaked somehow. I would expect the print statement to give me some huge string of gibberish but instead what I get is 'RIFFnap'. Regardless of what size the file is. I'll try to read in a 5 meg file and all I get when I try to print the buffer is some variation of 'RIFFxxx' (where xxx is any arbitrary set of 3 characters). >>> x = open('d:\\binary.wav') >>> buf = x.read() >>> print buf 'RIFFnap' Anyway, if any of you have a better suggestion for me, I'd really appreciate it. Basically all i'm looking for is an efficient method of comparing binary data files. Thanks for your time, christian From sheila at thinkspot.net Mon Jun 25 16:45:47 2001 From: sheila at thinkspot.net (Sheila King) Date: Mon, 25 Jun 2001 13:45:47 -0700 Subject: Is this a mimetools/rfc822 bug? In-Reply-To: <15159.41247.812177.613322@anthem.wooz.org> References: <15159.41247.812177.613322@anthem.wooz.org> Message-ID: <673D8B1EC8@kserver.org> On Mon, 25 Jun 2001 16:37:51 -0400, barry at digicool.com (Barry A. Warsaw) wrote about Re: Is this a mimetools/rfc822 bug?: : :>>>>> "SK" == Sheila King writes: : : SK> So far as I know, leading newline characters are not allowed : SK> in the header. A newline character indicates the end of the : SK> headers. : :Correct, and rfc822 is fairly strict about what it accepts. Leading :empty lines in the text will toggle it over from "reading-headers" :mode to "reading-body" mode. It's even worse if you have no headers, :but your first body line has a colon in it! But, according to the RFC's a header is required. A message body is not required. According to RFCs I recall: Your message header must have at least one of the following headers: To, Bcc, or CC. I believe that is the minimal header: any one of the To-type fields. No other headers are required, and no message body is required. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ :Moral: massage and normalize your text before feeding it to rfc822. : :-Barry : From bsb at winnegan.de Sat Jun 23 12:00:09 2001 From: bsb at winnegan.de (Siggy Brentrup) Date: 23 Jun 2001 18:00:09 +0200 Subject: Tkinter widget hieght?? In-Reply-To: References: Message-ID: <871yobxk3a.fsf@winnegan.de> "NJM" writes: > I can't seem to find a way to dictate what the height of a widget. Of > coarse, width is typically in the options. Where is the height?? >>> from Tkinter import * >>> root=Tk() >>> root.keys() ['background', 'bd', 'bg', 'borderwidth', 'class', 'colormap', 'container', 'cursor', 'height', 'highlightbackground', ------------------------^^^^^^ 'highlightcolor', 'highlightthickness', 'menu', 'relief', 'screen', 'takefocus', 'use', 'visual', 'width'] Regards Siggy -- Siggy Brentrup - bsb at winnegan.de - http://www.winnegan.de/ ****** ceterum censeo javascriptum esse restrictam ******* From p.agapow at ic.ac.uk Mon Jun 18 04:17:08 2001 From: p.agapow at ic.ac.uk (Paul-Michael Agapow) Date: Mon, 18 Jun 2001 09:17:08 +0100 Subject: Teaching Pyhton on Wintel Message-ID: <1ev6xe3.15eskd91k2u1eaN%p.agapow@ic.ac.uk> Call me misguided, but I've decided to teach an introduction to programming class using Python. The audience are the scientists in my (evolution/ecology research centred biology) department and we'll be using the local computer lab, which is kitted out out with a network of modestly powered Wintel machines. So: 1. Any advice on which IDE etc. of Win Python to use? 2. Anyone done a similar class, like to advise on approaches or books to base it off? thanks -- Paul-Michael Agapow (p.agapow at ic.ac.uk), Biology, Imperial College "Pikachu's special power is that he's monophyletic with lagomorphs ..." From tim.one at home.com Wed Jun 27 14:47:43 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 27 Jun 2001 14:47:43 -0400 Subject: PEP 260: simplify xrange() In-Reply-To: Message-ID: [Michael Hudson] > Glib truism: > > Floating point arithmetic *is* exact (given a rounding mode), but > it's not exactly what you think. > > My pedant-gland throbs a bit when I see people write "floating point > numbers are approximate"... It's not just pedantic: the idea that fp can't be used for exact computation is simply wrong, and a superstitious belief in it can prevent a programmer from finding the best solutions to a problem. The 754 inexact flag was meant to make this easier: independent of rounding mode, inexact gets set if and only if an operation's fp result loses information; when it doesn't get set, you've got exactly the same result you would have gotten if you were able to retain infinite precision. There's nothing fuzzy about that; unfortunately, you can't get *at* the inexact flag in a portable way from any brand-name language yet. From ullrich at math.okstate.edu Sun Jun 3 11:13:36 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 03 Jun 2001 15:13:36 GMT Subject: random References: Message-ID: <3b1a4fe4.1344551@nntp.sprynet.com> On Sat, 2 Jun 2001 19:34:13 -0400, "Tim Peters" wrote: >[David C. Ullrich] >> ... >> Hanging out on sci.math the things that people said about Chaitin's >> work made him sound like a total crackpot. > >sci.math? Wow -- I thought Congress had voted to ban it. Wishful thinking, >I guess . > >> I was relieved when I saw a little bit of his stuff once - the >> ridiculous aspects of what people had said about what he'd done were >> not due to him, they were due to people misquoting and oversimplifying >> his stuff. > >Chaitan is a bit of a self-promoter, and his rhetoric is often colorful, but >by all indications his work is rock solid. The actual "work" is certainly solid - that is, the actual mathematical statements with proofs. Solid, also interesting, significant, probably useful. But the "bits" of self-promotion and rhetoric can be very, um, let's just say they can be a lot like self-promoting rhetoric. > A very nice high-level intro is >this transcript of a lecture he gave at CMU: > > http://www.cs.umaine.edu/~chaitin/cmu.html Very interesting stuff, without a doubt. He wants to say that his point of view makes incompleteness seems inevitable he may well be right. But when he gets into statements like "there is no reason that individual bits [of Omega] are 0 or 1!" it's just too... well I better omit the adjective and just say that "there is no reason that individual bits are 0 or 1" is not a mathematical statement amenable to proof. Preciate the reference - I definitely learned one thing, at least: "Now what is the reaction of the world to this work?! Well, I think it's fair to say that the only people who like what I'm doing are physicists!" Not having studied his stuff or people's reactions to it I thought it was just me (seriously). (Um: It's _not_ true that mathematicians don't like his work, I know of plenty of mathematicians who find it fascinating. What people don't like is his [adjective] claims about what his work _means_...) The (or in any case _a_) point being things like "I think there may be political reasons, but I think there are also legitimate conceptual reasons, because these are ideas that are so foreign, the idea of randomness or of things that are true by accident is so foreign to a mathematician or a logician, that it's a nightmare! This is their worst nightmare come true! I think they would prefer not to think about it." He insists that the world of mathematics is all upset over his well-defined but unknowable Omega. If that irritates people what irritates them is not the well-defined but unknowable character of those bits, it's the idea that the idea of something being well-defined but unknowable started with him. It's no big deal, people have been dealing with "unknowables" for a long time. David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From gmcm at hypernet.com Wed Jun 20 13:00:04 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 20 Jun 2001 17:00:04 GMT Subject: arguments to calldll.call_foreign_function() ? References: <8351bb33.0106200756.4776fed5@posting.google.com> Message-ID: <90C68291Bgmcmhypernetcom@199.171.54.154> Jon Nicoll wrote: >Hi there > I want to experiment with using calldll to access a win32 >function: QueryPerformanceCounter(), which has a prototype > >BOOL QueryPerformanceCounter( > LARGE_INTEGER *lpPerformanceCount // address of current counter >value > ); [snip] >>> from dynwin import windll >>> k = windll.module('kernel32') >>> b = windll.membuf(8) >>> k.QueryPerformanceCounter(b.address()) 1 >>> b.read() '\367[\363\211\246\000\000\000' >>> - Gordon From greg at cosc.canterbury.ac.nz Mon Jun 25 02:27:08 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Mon, 25 Jun 2001 18:27:08 +1200 Subject: Another Wart! string.find() [ was: namespace issue? ] References: Message-ID: <3B36D9BC.94FF8021@cosc.canterbury.ac.nz> "Steven D. Majewski" wrote: > > I know that *I* learned zero based sequences in High School math -- > N-sub-zero, N-sub-one, Mathematicians seem to use 0-based and 1-based indices with about equal frequency, in my experience. Although when doing *arithmetic* with the indices, 0-based often seems to be preferred -- probably for the same reason that Python prefers it! -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From sheila at spamcop.net Fri Jun 22 12:45:37 2001 From: sheila at spamcop.net (Sheila King) Date: Fri, 22 Jun 2001 16:45:37 GMT Subject: ANNOUNCE: The Neophyte Pythoneers List References: Message-ID: There is already a list that serves this purpose. See http://mail.python.org/mailman/listinfo/tutor -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ On Thu, 21 Jun 2001 12:51:34 -0700, "Jesse W" wrote in comp.lang.python in article : :Dear Pythoneers, (Exactly how should you spell "Pythoneers", :anyway?) : : I have just now created a mailing list via Yahoo for the sharing, :joint debugging and general discussion of Python programs. The :list is intended to be primarily for those who have not yet reached :expert level in Python programming, but experts are also very :welcome. : You can join by sending a blank email to: :neophyte_pythoneers-subscribe at yahoogroups.com : : Good luck to you all, : Jesse Weinstein : : From paulp at ActiveState.com Fri Jun 15 02:12:04 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Thu, 14 Jun 2001 23:12:04 -0700 Subject: Python 2.0.1c1 - GPL-compatible release candidate References: Message-ID: <3B29A734.41482D7B@ActiveState.com> Will Ware wrote: > >... > > But the GPL extends its coverage not only to derived works in the obvious > sense, but also to code which is statically linked with a GPL program. > If my extensions are statically linked to 2.0.1, then by that criterion > they would also be GPL-ware. It is important to understand that Python is not under the GPL. The Python license is no more restrictive than it has ever been. It has not changed in any substantive way. (but then a lawyer would probably claim that any change whatsoever is substantive) Python's license is now *GPL-compatible*. That means that you can distribute GPL'ed software with Python, if you want to. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From rnd at onego.ru Wed Jun 20 04:35:35 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 20 Jun 2001 12:35:35 +0400 (MSD) Subject: PEP 255: Simple Generators In-Reply-To: <3B305119.6A12DBC2@letterror.com> Message-ID: On Wed, 20 Jun 2001, Just van Rossum wrote: Hello! Let me express my view on this. I think, that in itself this scheme is good. However if we look at it broder, PEP255 is only half of the solution. Far better solution could be to built-in parallel programming. like, for example, in Occam, which is more general approach to build not only generators but arbitrary asynchronous object interactions _built-in_ into the language. yield is a pipe between two functions where one function stops to be started again when the other calls. It is narrow case. Pipes could be used wider than in the "yield" example! Even without parallel programming, pipes could be somehow registered and used with objects or functions in more general way, with iterator protocol worded explicitly, not built-into yield. Far better could be to allow arbitrary pipes between objects... But I guess Python internals aren't ready for parallel programming, so send/receive (with or without queues) could not supported transparently yet. These ideas are theoretical. In my work I do not use parallel programming inside the program level. So do not hesitate to call ideas above nonsense. But I feel that PEP255 could cover more general pipes than generator/consumer... Another question about yield is how do I have it with objects? Will there be __yield__ (similar to __add__ or __del__)? Could I yield from methods? (and why not?) > > If I understand correctly, this should work: > > > > def f(): > > for i in range(5): > > for x in g(i): > > yield x > > > > def g(i): > > for j in range(10): > > yield i,j > > Greg Ewing wrote: > > > Yes, I realised that shortly afterwards. But I think > > we're going to get a lot of questions from newcomers > > who have tried to implicitly nest iterators and are > > very confused about why it doesn't work and what needs > > to be done to make it work. > > Erm, "yield" by definition yields to its immediate caller, > so how could there be any confusion? > > I'm personally still not convinced that a generator keyword > would be a huge improvement. Here's how I see it: once you > see a "yield" statement it means the function returns not > one but an arbitrary amount of values, which you can iterate > over. > > The next two functions are more or less equivalent: > > def returnThreeValues(): > return 1, 2, 3 > > def generateThreeValues(): > yield 1 > yield 2 > yield 3 > > Just > Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From gmcm at hypernet.com Fri Jun 1 22:43:14 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 02 Jun 2001 02:43:14 GMT Subject: py2exe - too many Tk files References: <9er9j50uv7@enews1.newsguy.com> <9errhd01gl6@enews1.newsguy.com> <90B2C3EEBgmcmhypernetcom@199.171.54.194> Message-ID: <90B3E52D0gmcmhypernetcom@199.171.54.194> Nick Perkins wrote: >..I was also wondering about all those funky 'encoding' files, > >eg: > >macJapan.enc 48 kb >cp949.enc 130 kb >cp936.enc 132 kb > >..and many others > >They add up to quite a bit, and I sure don't need all of them. >I probably need at least one, I suppose, maybe ascii.enc (the smallest >one at about 1 kb ). > >On a related note, will having too many Tk files increase the run-time >memory usage of an app? I sent a 'compiled' Tk app to a friend who was >surprised that such a simple little program was using 5MB ram on his >Win2K. I doubt that it's the encoding files themselves. Both Python 2 and Tcl 8.3 grew Unicode support, which increases the size of (the cores of) each very considerably. Then there's the use of MSVC 6, which treats disk space and RAM as dirt cheap. I suppose one day I'll have to face the fact that those furriners who use those silly characters are people, too <0.9 wink>, but I still mostly use Python 1.5.2 for that reason (and speed). - Gordon From Attila.Feher at lmf.ericsson.se Wed Jun 6 12:45:41 2001 From: Attila.Feher at lmf.ericsson.se (Attila Feher) Date: Wed, 06 Jun 2001 19:45:41 +0300 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3b1cdc84.5514@bolder.com.co.za> <9fleid$3rp$1@oslo-nntp.eunet.no> <3B1E4951.7F36D4E4@alcyone.com> <3B1E50E1.35AE59C@lmf.ericsson.se> <3B1E52DA.BBC9FC32@alcyone.com> <3B1E580E.D3EE577B@lmf.ericsson.se> <3B1E59EC.2F19C2E0@alcyone.com> Message-ID: <3B1E5E35.620BB49F@lmf.ericsson.se> Erik Max Francis wrote: [SNIP] > If you know that your friends are an extremely atypical set, why did you > mention it at all, except as an attempt to generalize? I don't know and never said they are atypical!!! All I have said that they most probably don't form a large enough set to be representative for statistical purposes. Do you have a habbit to put words to other people's mouth they have never said??? > I'm "evil" because you made a blatantly sweeping overgeneralization and > I called it out? Yeah, that makes sense. No, I have not made _ANY_ generalization!!!! I wrote down: --- BTW some competents I know play games... really... although I have never seen an original box of any game they play :-))) So OK they do play. But do they buy? --- Where do you see here I say _everyone_ does it? Where do you see here that I state they don't buy? Do you know the meaning of this sign: '?' It means _I_have_asked_. No to make out from this words that I have meant that every programmers steals the gamkes they play is plain evil. A From boudewijn at tryllian.com Thu Jun 28 04:20:17 2001 From: boudewijn at tryllian.com (Boudewijn Rempt) Date: Thu, 28 Jun 2001 10:20:17 +0200 Subject: KDE and Windows References: <993660235.135465@seven.kulnet.kuleuven.ac.be> <1ax_6.13372$qJ4.526424@ozemail.com.au> Message-ID: <3b3ae99b$0$14016$e4fe514c@newszilla.xs4all.nl> Patrick Wray wrote: > > "D-Man" wrote in message > news:mailman.993663428.8908.python- > >> [...] However Qt is not free for Windows (as-is). > > There is now a "free beer" version of Qt for Windows (released yesterday). > Unlike it's X11 cousin, it's binary only, and not GLP'd. > > As I understand it, their licensing policy gives you these choices: > > If you want to write open-source software for Windows, you can use the BSD > or Artistic License, or something similar. You can't use the GPL because > that would require you to distribute the Qt source. (If you want to go > GPL, just use the X11 version). > > If you want to write closed-source freeware for Windows, you don't need to > buy a license. > I think you need to release source to your app, too, if you use the non-commercial license for Qt. > If you want to write commercial software for Windows, either for sale or > for in-house use in a commercial setting, you obviously need to buy a > commercial license. > > Perhaps someone who IAL can clarify how this affects PyQT. I'm not a lawyer, but I can't resist answering this question a bit. Phil plans releasing a free binary version of PyQt for Windows very soon, in addition to the existing free source version of PyQt. However, this will have to have the same license as the gratis version of Qt for Windows. This means that if you want to use what you develop in the course of your work, or sell it, you will still have to buy a copy of BlackAdder professional. The source for PyQt and sip is really Free, of course. And there's work going on with recreating PyKDE for KDE2, too. On a side note: on Linux Today Matthias Ettrich indicated that there will also be a gratis version of Qt for OS X. This means that a version of PyQt for OS X will be within reach, this autumn. -- Boudewijn | http://www.valdyas.org From nas at python.ca Mon Jun 18 21:24:56 2001 From: nas at python.ca (Neil Schemenauer) Date: Mon, 18 Jun 2001 18:24:56 -0700 Subject: fprintf(): Python Equivalent???? In-Reply-To: ; from prem@engr.uky.edu on Mon, Jun 18, 2001 at 05:58:19PM -0700 References: Message-ID: <20010618182456.B8604@glacier.fnational.com> Prem Rachakonda wrote: > HI, > Does python have some function which does a formatted file writing > functionality similar to C's > > fprintf(fp,"%s %s",string1, string2); fp.write("%s %s" % (string1, string2)) The '%' operator is more like sprintf though. Neil From gmcm at hypernet.com Thu Jun 28 15:26:37 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 28 Jun 2001 19:26:37 GMT Subject: PEP scepticism References: <9hfg1n$du33c$1@ID-89274.news.dfncis.de> <9hfpm9$dsllb$2@ID-89274.news.dfncis.de> Message-ID: <90CE9139Cgmcmhypernetcom@199.171.54.154> Bernhard Reiter wrote: [snip] >As I wrote in my post, I do not want to discuss the advantages or >disadvantages of single additions even though I have mentioned them. >I hope I can explain my cause without being specific. But features are added to Python on a case-by-case basis. There is no "let's do everything!" bonanza underway (PEPs get rejected, after all). So there's no general case to argue (except, maybe "I like my Python 1.5.2"). - Gordon From Gareth.McCaughan at pobox.com Sat Jun 16 20:53:43 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Sun, 17 Jun 2001 01:53:43 +0100 Subject: Two minor syntactic proposals Message-ID: Here are two things that would make Python feel a little nicer for me. (Which is not necessarily the same as "better", of course.) I'd be interested in comments. The proposals are extremely minor; they change the meaning of no valid Python program and add no new semantics. I conjecture that both would be easy to implement. * 1. Syntax for extending an existing class. Suppose you have a class and want to add a new method to it. (Why? It's someone else's, you aren't allowed to change the source, and subclassing won't do because these things are created by code you don't control.) You can do it, thus: def new_method(self, x): something_else() return x+1 Thing.new_method = new_method but that's rather ugly. I suggest that there be syntax which does the same thing as the existing "class", but updates an existing class instead of replacing it. Two possibilities that don't require new keywords: in class Thing: def new_method(self, x): something_else() return x+1 or class Thing continue: def new_method(self, x): something_else() return x+1 I like the first of these much better than the second. * 2. Syntax for defining methods. Every now and then we get people complaining because it's too easy for them to forget to include a "self" argument in a method definition. Every now and then, I suspect that most Pythonistas forget. (I certainly do.) Suppose there were an alternative syntax, thus: class Thing: def self.boring_method(): return 0 That has two advantages: (1) it looks more the way that the method will actually get used, and (2) it's harder not to notice if you miss the "self." out. I'm sure this one must have been proposed before, but I don't see a PEP for it and have no recollection of why (if it was proposed before) it was disliked. -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From amardeep at tct.hut.fi Sat Jun 16 05:47:23 2001 From: amardeep at tct.hut.fi (Amardeep Singh) Date: Sat, 16 Jun 2001 12:47:23 +0300 (EET DST) Subject: qt or gtk? In-Reply-To: Message-ID: I dont know about qt, i have never used it. But i have been using glade for designing interface, and gtk and libglade python bindings, and it works great. Python + gtk + libglade is great for rapid application development in linux. On Sat, 16 Jun 2001, Rainy wrote: > > I want to learn python gui programming in linux. I think tk looks too ugly, so > I narrowed down the choice to two main contenders, qt and gtk. Which of these > has more complete and up-to-date python bindings? Are there other reasons > to prefer one of these over another for python gui work? > > amardeep From robin at jessikat.fsnet.co.uk Wed Jun 6 11:12:18 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 6 Jun 2001 16:12:18 +0100 Subject: need help inverting DerivVar array (Numpy/Scientific Python Q uestion) In-Reply-To: References: Message-ID: <0w+s7XAShkH7EwIM@jessikat.demon.co.uk> In message , PoulsenL at capecon.com writes >Scientific provides a derivable object which can be operated upon. The >problem is that it does not implement an invert method and I was wondering >if there was a workaround. > ... well to avoid the inversion of formulaic matrices you could use the direct approach for the differential of the inverse of a matrix ie d inv(A(x))/dx = - inv(A(x)) d A(x)/dx inv(A(x)) which derives from A(x)inv(A(x)) = I that way you can find the pure numerical inverse and then just multiply out with the derivative of the individual differentials you need. It's unlikely that the inverse operation. A very long time ago I did in fact do symbolic differentials of matrices (up to order 20 or 30), but it was quite expensive in those days. In the above if x is in fact the elements of A then the inner term becomes trivial to compute and then you get a single non-zero element in it. Then the differential wrt aij is the rank 1 matrix column i(invA) * row j(invA); for an order 30 matrix it takes around 7Mb to store the numbers. -- Robin Becker From rnd at onego.ru Mon Jun 4 14:07:06 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 4 Jun 2001 22:07:06 +0400 (MSD) Subject: Has anyone used UML? In-Reply-To: <3B1BC755.65510E63@bt.com> Message-ID: On Mon, 4 Jun 2001, Alan Gauld wrote: >Grant Edwards wrote: >> I took a 3 day class on UML once. My impression: yet another >> "silver bullet" that doesn't work in real life. > >Like any design notation UML is there to communicate. If >the peer group is small enough the advantages are marginal. >If you are working in a distributed group of 20 or more >programmers something likev UML is near essential. Most >of my projects involve several hundreds of programmers >(250 on the current one) and there we simply couldn't >operate without UML. > >But a small team UML may be overkill. Frankly I think the >best bits of UML are the component/package diagrams and >the deployment diagrams for documenting the physical design. Then GnUML could be good idea for Freeware projects - they also need to communicate design ideas. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Monday, June 04, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Why am I asking all these things?" _/ From bbollenbach at homenospam.com Sat Jun 9 00:09:11 2001 From: bbollenbach at homenospam.com (Brad Bollenbach) Date: Sat, 09 Jun 2001 04:09:11 GMT Subject: Python Shareware? References: <9fr2jm$16v$1@brokaw.wa.com> Message-ID: "Jonathan Gardner" wrote in message news:9fr2jm$16v$1 at brokaw.wa.com... > Jian Chen wrote: > > I am considering writing some shareware in python. I got some > > questions about it: > > > 3. How can I lock/secure my python shareware? > > Okay, here's my opinion on shareware: Don't do it, it's too much hassle. > > If you are interested in making software, you should be interested in > making it good. So you GPL the code, allow everyone to use it, and modify > it, and thus the software will become good/the best/whatever. True enough. More eyes, and the passion that a lot of Free Software developers have for their craft is definitely a good way to turn good into excellent. > If you are interested in making _money_, you have to have a product or a > service to sell. Software is not a good product, but *support* for the > software is a tangible service that you can charge really good fees for. I'm not sure about software not being a good product. Considering that MS makes most of their money from the businesses that buy the licenses (rather than J. Random Warezdownloader), and NO business-owner in their right mind would fool around with licensing issues. Whether it's easy to copy or not, the most important share of the market is forking out a lot of money for the service of producing good software. > After all, you are the one who wrote it, so the people who use it will > naturally turn to you for support. If you target the software for large > organizations, you can charge quite a bit of money to give them insurance > and service. Possible, but not happening very often at all in the real world. For every one company that can be shown to be generating revenue only from their tech support, there's probably 200 that make their money from sales of software. > Let me address why software is not a good product: 1) It is too easy to > copy. There is no cost to reproducing it. Compare that to a book, a > computer, or a chair. 2) You are not the smartest guy on the planet, so any > method you think of in trying to make it difficult to reproduce is not > going to work. (Even the smartest guy on the planet doesn't stand a chance > to hundreds and thousands of crackers.) 3) And when someone DOES illegally > copy the software, how are you going to force them to pay? See previous points on why the "ease of copying" doesn't really matter in a lot of markets. Just like the fact that Napster existed as CD sales were /on the rise/, warez barely dents the sales figures of software. > 4) If your software isn't really that useful or good, someone else is going to make > something better, and leave your product in the dust. Or you will be forced > to constantly upgrade it rather than take a vacation. > > You have better hope of collecting money by saying, "This software is free. > If you like it, and want more of it, give me money." and let the people who > use it work on it. In a world where Linus would be king, this is a great statement to believe in. In this world however there aren't any companies that make money (at the very least, anywhere near comparable to competitors that sell proprietary code) by giving away the code, and living off the support fees. Feel free to look at how companies like Redhat and VA Linux are doing. It's pretty grim market-wise. > There is anexception to this rule: If you have mega-bucks behind you to > actually form a company complete with legal department, and if you can > recruit enough talent to make your software better than anything free out > there, then you have a chance of making software that you can sell, becuase > you can afford to put it on store shelves and get good advertising for it. > And in this case, the people that pay for it will far outnumber the people > who won't. Yes, imagine the very rare situation of those companies that make money off of selling proprietary software! :) "Mega-bucks" are hardly required. I worked for a company that had 3 programmers and yet our client-base numbered well over 400. Considering that our main product cost well over $3000 (with yearly support fees being about half that, IIRC), things were good. > There is another benefit to you of free software: If you are really good at > programming, you can show off with your GPL'ed code, and use that to get > into a company that is willing to pay you to code stuff for them. You can't > show off code that is closed-source, like code from, say, your previous > job. So, with your GPL'ed code (which has been tested and developed by > people who are actually interested in using it, so it will be much better > than anything you can write on your own) you can claim a lot of credit for > it, and demand $100,000 or more for salary. If they think you are crazy, > tell them to read the code and try the software. If they want to produce > software like that, then they have to hire you. Other than the really big names (a la Torvalds, GvR, Wall et al.) this rarely happens. At the very least, when good programmers get good jobs, it's because they are very bright people who have a lot to offer, not because of the license they choose for their software. Realistically, most PHB's have less than half-a-clue about what the GPL is (*hyuck* *hyuck* isn't that onnuh them globawl pawsitioning thingmahoots?) > I think a steady income of $100,000 or more a year will benefit more than > the meager sales of a shareware piece of software. Plus, you get the > comfort of knowing your check shows up every month, and it's the same > amount each time. > > Again, that is just my opinion. I have no experience with trying to make > money from shareware software, I have just observation on my side. After all this has been said, what experience do you have for becoming rich from writing a GPL'd program that's taken the world by storm? :) > I hope this starts an interesting thread. > > From aahz at panix.com Tue Jun 26 00:41:13 2001 From: aahz at panix.com (Aahz Maruch) Date: 25 Jun 2001 21:41:13 -0700 Subject: Should I use a dictionary? References: Message-ID: <9h93p9$4d8$1@panix2.panix.com> In article , Greg Jorgensen wrote: > >When you want to sort the messages, use your own sort function to compare >the message date/time: That's a Bad Idea if there are a lot of messages; such comparison functions are expensive. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Those who do not remember the past are condemned to repeat it." From john.thai at dspfactory.com Wed Jun 13 12:30:04 2001 From: john.thai at dspfactory.com (John) Date: Wed, 13 Jun 2001 12:30:04 -0400 Subject: PyArg_ParseTuple Message-ID: Hi, If I want to extract a list by using PyArg_ParseTuple with the format specifier "o!" , what do I pass in for the "address of a Python type object", as stated below? "O!" (object) [typeobject, PyObject *] Store a Python object in a C object pointer. This is similar to "O", but takes two C arguments: the first is the address of a Python type object, the second is the address of the C variable (of type PyObject *) into which the object pointer is stored. If the Python object does not have the required type, TypeError is raised. Thanks, John From rnd at onego.ru Mon Jun 4 06:35:22 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 4 Jun 2001 14:35:22 +0400 (MSD) Subject: Dynamically making lists? In-Reply-To: <3B1B5E80.A01DA188@senux.com.NOSPAM> Message-ID: On Mon, 4 Jun 2001, Brian Lee wrote: > Bill Witherspoon wrote: > > > > Hi all, > > > > If I have a list -> > > > > L = ['one', 'two', 'three',......,'one thousand'] > > > > and I want to split this into several lists with (say) two elements > > each -> > > > > m = ['one', 'two'] > > n = ['three', 'four'] > > o = ['five', 'six'} > > ...... > > zz = ['nine hundred ninety nine', 'one thousand'] > > > > How would I do this? I don't know how many elements are in L before > > I run the program. > > > > It seems like I have to generate variable names on the fly? > > Maybe there's something simple I'm missing here. > > > > Any pointers would be appreciated. > > > > TIA, > > Bill. > > How about to start from this code and edit for your own use. > > for x in range(len(L) / 2): > tmp[x] = [L[x * 2], L[x * 2+ 1]] The following solution creates list of lists: >>> L = [1, 2, 3, 4, 5] >>> [L[x:x+2] for x in range(0, len(L), 2) ] [[1, 2], [3, 4], [5]] Or for N: >>> N = 3 >>> [L[x:x+N] for x in range(0, len(L), N) ] [[1, 2, 3], [4, 5]] Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From gherron at islandtraining.com Wed Jun 20 14:28:19 2001 From: gherron at islandtraining.com (Gary Herron) Date: Wed, 20 Jun 2001 11:28:19 -0700 Subject: ANN: PythonCard mailing list In-Reply-To: References: Message-ID: <01062011281900.00884@whatsup.home> On Tuesday 19 June 2001 20:19, Kevin Altis wrote: > http://groups.yahoo.com/group/pythoncard > > I just created this group so we can take the discussion > out of comp.lang.python. Feel free to start posting. Could you please spare just one little sentence to describe what a pythoncard discussion is *about*? Just curious, Gary From qrczak at knm.org.pl Sat Jun 16 16:01:55 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 16 Jun 2001 20:01:55 GMT Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> Message-ID: Fri, 15 Jun 2001 04:39:05 GMT, Rainer Deyke pisze: > 'def', while not an assignment per se, has the same semantics as assignment, > i.e. a name bound with 'def' can be rebound with assignment and vice versa. Which has bitten me recently when I accidentally gave two methods the same name. The one written later silently replaced the other. Fortunately they had different numbers of parameters so the error was caught on a call to one of them. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From db3l at fitlinxx.com Fri Jun 1 20:17:33 2001 From: db3l at fitlinxx.com (David Bolen) Date: 01 Jun 2001 20:17:33 -0400 Subject: docstrings, invention there of References: Message-ID: Laura Creighton writes: > I still don't know how to tell emacs that when I want out > of a file, I want out of it immediately, usually BECAUSE there are > buffers that are unmodified and I don't have time to waste with > control shift underscore. When you say out of a file do you mean out of a file or out of Emacs entirely? For a current buffer I normally just use C-x C-k (kill-buffer). Yes, it'll prompt you if your current buffer is modified, but it won't ask about any other buffers, so it's minimal overhead to verify the modified delete. If you want to exit Emacs entirely, and are using C-x C-c (save-buffers-kill-emacs, which I typically use) then yes, you will be asked about each modified buffer in turn, since that's sort of the point of that function :-) But hitting RET or q at the first such prompt (use C-h or ? for help) will skip any such remaining questions and just exit. I find myself doing that rarely as it's usually nice to get some visibility into what changes I'm skipping, and it's easy enough to just keep hitting 'n'. Or you could just go straight to C-x C-z (kill-emacs) which just exits no questions asked. (This is GNU Emacs 20.6 under NT, but these sequences are pretty old - I can't speak authoritatively for XEmacs though) -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From phd at phd.fep.ru Thu Jun 14 04:19:30 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Thu, 14 Jun 2001 12:19:30 +0400 (MSD) Subject: VI In-Reply-To: <9g9f1v$7oqr5$1@ID-11957.news.dfncis.de> Message-ID: Hi! On Wed, 13 Jun 2001, Emile van Sebille wrote: > Actually, I use it daily. I'd just prefer something (oh, ok, _anything_) > else. This is a matter of taste and habits, nothing more. I came to UNIX from DOS, and at first I was frustrating by vi. So initially I used textedit (XWindows editor on Solaris), and later Emacs. But then came vim (twas 3.0.something)! And soon I found I can use it. And then I found I can use it pretty successfully! And happiliy!! And now I do not use anything else!!! :))) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From fredrik at pythonware.com Thu Jun 14 06:15:21 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 14 Jun 2001 10:15:21 GMT Subject: base converter References: Message-ID: Greg Jorgensen wrote: > Slightly modified to work with bases > 10: > > def BaseConvert(x, b): > "convert decimal number x to base b" > digits = "0123456789ABCDEF" > out = "" > if b <= len(digits): > while x: > x, d = divmod(x, b) > out = digits[d] + out > > return out slightly modified to work with bases up to 36 (or more), and return "0" for zero: import string def BaseConvert(x, b, digits=string.digits+string.uppercase): "convert decimal number x to base b" assert b < len(digits) out = "" while x: x, d = divmod(x, b) out = digits[d] + out return out or "0" (still waiting for someone to come up with a one-liner using list comprehensions ;-) From dsh8290 at rit.edu Mon Jun 18 14:49:34 2001 From: dsh8290 at rit.edu (D-Man) Date: Mon, 18 Jun 2001 14:49:34 -0400 Subject: Any other Python flaws? In-Reply-To: <3B2A5F6A.5A61183@destiny.com>; from mcherm@destiny.com on Fri, Jun 15, 2001 at 02:18:04PM -0500 References: <3B2A5F6A.5A61183@destiny.com> Message-ID: <20010618144933.D4516@harmony.cs.rit.edu> On Fri, Jun 15, 2001 at 02:18:04PM -0500, Michael Chermside wrote: | Martijn writes: | > Further things possibly wartlike, though this one never bit me, is | > the possibly to assign to None, definitely a weird idea when you | > first encounter it. [other questions/points already answered] | Oh well... at least people don't bump into this one much. And if you | accidently clobber it, you can restore things with: | | def __None(): | pass | None = __None() Well, that doesn't work. One of the key features of 'None' is that there only ever exists a single instance. This would create a new, unique, instance bound to (a more local) 'None'. IOW id( None ) != id( __builtins__.None ) and id( None ) != id( other_module.None ) which results in (if, for some reason, None was returned instead of raising an exception -- maybe it isn't always failure but only to this client) foo = other_module.func() if foo is None : print "failed" else : print "success" not working. Also, foo = other_module.func() if foo == None : print "failed" else : print "success" wouldn't work because the None's are instances of different classes and don't define a comparision function that makes them equal. -D From gbreed at cix.compulink.co.uk Tue Jun 12 11:34:16 2001 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: 12 Jun 2001 15:34:16 GMT Subject: a newbie question about gadfly References: Message-ID: <9g5cpo$62$1@plutonium.compulink.co.uk> In article , jm7potter at hotmail.com () wrote: > Why? is namex not a direct replacement for "donna" ???? Um, no, not the way you're doing it. Try replacing that magic line with cursor.execute( "insert into students (name, grade) values (%s, %s)" % (namex, gradex)) Or even cursor.execute("insert into students (name, grade) values (%(namex)s, %(gradex)s)" % vars()) (that's sure to wordwrap!) Graham From ullrich at math.okstate.edu Sat Jun 16 09:52:57 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sat, 16 Jun 2001 13:52:57 GMT Subject: call-by-reference (was Re: Any other Python flaws?) References: <9gcu9g$gm4$1@newshost.accu.uu.nl> <9gd4tq$odb$1@news.mathworks.com> <3b2a1aea.6118580@nntp.sprynet.com> <9gdn6l$61k$4@newshost.accu.uu.nl> Message-ID: <3b2b63fc.1180744@nntp.sprynet.com> On 15 Jun 2001 19:20:53 GMT, m.faassen at vet.uu.nl (Martijn Faassen) wrote: >David C. Ullrich wrote: >> On 15 Jun 2001 14:08:58 GMT, jcm wrote: > >>>Martijn Faassen wrote: >>> >>>> I agree that nobody agrees on whatever 'call-by-reference' means, or what >>>> 'call-by-value' means. I mean, I'm here confused why you'd say C++ doesn't >>>> support call-by-value while Python apparently does. :) >>> >>>In my experience, there's good agreement about what call-by-reference >>>means just about everywhere but in newsgroups. Python supports only >>>call-by-value -- you can't change the value of a variable in your >>>caller's scope (globals aside). > >> It's call-by-value all right. The confusion is caused >> by the fact that the values are references. But passing >> a reference "by value" is not a call by reference. > >I think the confusion makes it not worth saying things like "It's simple! >Python does call-by-value only!". :) Better be more specific about the >behavior. Me, I'd never say _anything_ was simple. Too dangerous. (Yes, it probably is better to be specific. But while some confusion may be reasonable I really don't think there's any _ambiguity_ - it really is call by value. For example cf recent questions about why there's no swap() function...) >Regards, > >Martijn >-- >History of the 20th Century: WW1, WW2, WW3? >No, WWW -- Could we be going in the right direction? David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From sandorlevi at yahoo.com Mon Jun 18 18:27:34 2001 From: sandorlevi at yahoo.com (Levente Sandor) Date: 18 Jun 2001 15:27:34 -0700 Subject: qt or gtk? References: Message-ID: <8b5e42a6.0106181427.3687373@posting.google.com> sill at optonline.net (Rainy) wrote in message news:... > I want to learn python gui programming in linux. I think tk looks too ugly, so > I narrowed down the choice to two main contenders, qt and gtk. Which of these > has more complete and up-to-date python bindings? Are there other reasons > to prefer one of these over another for python gui work? I personally prefer wxPython -- http://wxpython.org -- because it has a well-structured, easy to use documentation and an excellent demo suite. The Linux version is based on the GTK library. Levi From cfelling at iae.nl Mon Jun 25 18:56:49 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 26 Jun 2001 00:56:49 +0200 Subject: Newbie seeks help on case preserving substitutions References: <3B3767BB.A882F8@divalsim.it> Message-ID: <9h8fjh$cmk$1@animus.fel.iae.nl> Nicola Musatti wrote: ... > What I'm currently doing is search for the first string ignoring case, > and substitute the second character by character according to the first > string's case: that seems reasonable, but your code could be simplified, like: ### replace strings, preserving case import re class PreserveCase: def __init__(self, new): self.new = new def __call__(self, match_obj): old = match_obj.group() new = list(self.new) for i in range(len(old)): if old[i].isupper(): new[i] = new[i].upper() return "".join(new) oldFile = ''' ECBASE ECBase ecbase ''' newFile = ''' OWTEST OWTest owtest ''' substituter = re.compile(r"ecbase", re.IGNORECASE).sub assert newFile == substituter(PreserveCase("owtest"), oldFile) ### now you could do things like: # # oldFile = open("oldFile").read() # newFile = open("newFile", "w") # newFile.write(substituter(PreserveCase("owtest"), oldFile)) -- groetjes, carel From rnd at onego.ru Tue Jun 26 10:01:24 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 26 Jun 2001 18:01:24 +0400 (MSD) Subject: Adding unknown variables to time.mktime() In-Reply-To: Message-ID: On Tue, 26 Jun 2001, Steve Holden wrote: > "Gustaf Liljegren" wrote ... > > "Roman Suzi" wrote: > > > > > >to be able to give only the 6 first values, since I've never heard of > > > >Julian days, and week day is not significant in this case. > > > > > try with all 9 integers. > > > RTFM time module docs. > > > > Read before you post. I always check the library reference, but it doesn't > > give any hints on what I asked for. If mktime() can't do it, maybe there's > > anyother way that you could suggest? > > > > Gustaf > > > Gustaf: > > Use zeroes? > > >>> import time > >>> time.asctime( (1999, 2, 12, 1, 34, 12, 0, 0, -1) ) > 'Mon Feb 12 01:34:12 1999' > > Aargh. This is REALLY dumb: No problem: >>> from time import * >>> asctime(localtime(mktime((2001,6,26,18,0,23,-1,-1,-1)))) 'Tue Jun 26 18:00:23 2001' Just keep your time always in GMT (aka UTC) and represent to user in localtime when needed. > >>> time.asctime( (1999, 2, 12, 1, 34, 12, 1, 1, -1) ) > 'Tue Feb 12 01:34:12 1999' > > Have you looked at mxDateTime? Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From aleaxit at yahoo.com Wed Jun 6 10:08:13 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 6 Jun 2001 16:08:13 +0200 Subject: Can python clear two object cited each other? References: <3B1E2D99.8ED4DE6A@ccsr.cam.ac.uk> Message-ID: <9fldge01bst@enews2.newsguy.com> "XiaoQin Xia" wrote in message news:3B1E2D99.8ED4DE6A at ccsr.cam.ac.uk... > Hi, everybody, > Can python clear two object cited each other? Yes. This is called a "reference loop", and since Python 2.0 it can be cleared up by garbage collection ***IF*** (crucial!) the objects involved have no __del__ method. (The __del__ methods might have to be called at "funny" times to break up the refloop... so objects having them do get collected but not cleared up... see the gc module for more info). > for example: > > class A: > def __init__(self, obj=None): > self.mine=obj > if obj: > obj.mine=self > > a=A() # create a object instance, say OA, referenced by variable a > b=A(a) # create another instance, say OB. so OB is referenced by both variable b and instance OA > # and OA is referenced by a and OB > del a # this line is able to delete variable a, instead of the OA, which is still refereced by OB > del b # this line is able to delete b, instead of OB, which is still referenced by OA > > # so the OA and OB is still in memory, whether I have to write a method for class A if I want to clear its intances from memory? Just let gc do its job, or if you want to control deletion times import gc and call the gc functions appropriately. If you *DO* need __del__ methods on your types it's much harder -- but Python 2.1 eases it by letting you define *weak* references that go away rather than keeping the referred-object alive, so that's another option. But generally doing finalization explicitly (in try/finally, with .close() methods, etc) is preferable in Python. So, if you can, do away with the __del__ methods, and just let gc work (automatically in most cases, under your control if you have very special needs). Alex From mal at lemburg.com Fri Jun 8 11:06:14 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 08 Jun 2001 17:06:14 +0200 Subject: Compiling Python2.1 under HP-UX with threads ? References: <9foldr$65a$1@neon.noos.net> Message-ID: <3B20E9E6.66AA3F71@lemburg.com> Boyd Roberts wrote: > > "M.-A. Lemburg" a ?crit dans le message news: mailman.991937355.8710.python-list at python.org... > > ./configure --with-threads > > make > > rm python > > cd Modules > > gcc -Wl,-E -Wl,+s -Wl,+b/lib/python2.0/lib-dynload \ > > python.o ../libpython2.0.a -lnsl -ldld \ > > -lpthread -lm -o python > > mv python .. > > make install > > err, shouldn't you have blown away the respective .o's? i don't see > much recompilation talking place. Well, no. The above link is really a linker command, not a compiler one. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From qrczak at knm.org.pl Sat Jun 23 02:59:47 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 23 Jun 2001 06:59:47 GMT Subject: PEP 255: Simple Generators References: Message-ID: Sat, 23 Jun 2001 00:03:33 +0200 (CEST), Carsten Geckeler pisze: > I just wanted to point out that "calling a class" (i.e. creating an > instance by calling class(args)) also returns an object, but that this is > of course not a reason to define it with "def", because the way the > definition is evaluated and what is returned is completly different as how > a function definition is evaluated (as you pointed out). And the same > with generators. Actually it's the opposite side with generators: class: the body is executed immediately def: the body is executed when called generator: the body is executed when called twice (g().next()) -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From mcherm at destiny.com Fri Jun 15 15:18:04 2001 From: mcherm at destiny.com (Michael Chermside) Date: Fri, 15 Jun 2001 14:18:04 -0500 Subject: Any other Python flaws? Message-ID: <3B2A5F6A.5A61183@destiny.com> Martijn writes: > Further things possibly wartlike, though this one never bit me, is > the possibly to assign to None, definitely a weird idea when you > first encounter it. Gee... I had no idea this was possible. Surely it's a bad idea... right? Can anyone name any reason why it's good to be able to assign to None? Barring that, I figure there must be a good reason why this isn't a syntax error. None not being a reserved word may be part of it... it's just another value in __builtins__. This is a clean and elegent design, but there's something dangerous about being able to change None. Oh well... at least people don't bump into this one much. And if you accidently clobber it, you can restore things with: def __None(): pass None = __None() I guess I better start putting that at the top of all my modules as defensive programming <1.0 wink>. -- Michael Chermside From tim_one at email.msn.com Fri Jun 29 14:38:12 2001 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 29 Jun 2001 14:38:12 -0400 Subject: PEP 260: simplify xrange() In-Reply-To: <20010629.034219.889023311.911@watervalley.net> Message-ID: [Chris Lawrence] > You can try this code at the beginning of your program: > > import sys > try: > if sys.hexversion < 0x10502f0: # 1.5.2 final > print 'Get a new version of Python!' > except AttributeError: > print 'Get a new version of Python!' > > Dunno when sys.hexversion showed up, hence the try clause. You can make it a little simpler by combining those tests via 3-argument getattr: import sys if getattr(sys, "hexversion", 0) < 0x10502f0: # 1.5.2 final print "Get a new version of Python!" > With more recent versions, you could also play with sys.version_info. Same kind of trick applies, of course. The *problem* is that if you're relying on, for example, new syntax, you'll never execute this code under an older version of Python: Python compiles the entire module to bytecode before executing any of it, and if an old version thinks there's a syntax error during compilation, boom. Rather than play with version numbers, it's usually better to use exec or eval in a try/except block to determine *directly* whether the feature you need is there. In the case of new syntax, the outcome can be used to import either a "new style" or "old style" version of a module, thus sidestepping the "old version can't even compile some new forms of code" gotcha. From michael at trollope.org Fri Jun 22 01:55:30 2001 From: michael at trollope.org (Michael Powe) Date: 21 Jun 2001 22:55:30 -0700 Subject: namespace issue? References: <87k825ljrz.fsf@elbereth.ccraig.org> <3B32707A.F03344D5@pfortin.com> Message-ID: <87n1712h4d.fsf@cecilia.trollope.org> >>>>> "Pierre" == Pierre Fortin writes: >> So now the question is, 'why'? Am I misusing the string.find() >> function? Okay, string.find() returns -1 when the string is not >> found, which would seem to be what I expected, a false result. >> Maybe python doesn't treat -1 as false? Well, I'll try being >> explicit and testing for -1 return. I probably have just >> confused myself hopelessly. Pierre> Sometimes -1 is used for failure; BUT -1 is NOT false... Pierre> in those cases, you can simply add 1 to the return to Pierre> force a failure to return 0 (false)... Well, I just used a variable to catch the return value of the string.find() and checked it for -1, but I must admit that seems clumsy to me. OTOH, after doing a little research, I see that I was twice in error, for I was thinking that in C, TRUE was any POSITIVE nonzero value, whereas it turns out that's wrong, too. So, I would have gotten the same result in C. Error compounded by error. Yikes! Thanks for the help. mp -- Michael Powe Portland, Oregon USA 'Unless we approve your idea, it will not be permitted, it will not be allowed.' -- Hilary Rosen, President, Recording Industry Association of America From grante at visi.com Fri Jun 22 10:53:27 2001 From: grante at visi.com (Grant Edwards) Date: Fri, 22 Jun 2001 14:53:27 GMT Subject: File name from file descriptor? References: Message-ID: In article , Carlos Ribeiro wrote: >Just for information, on some OS's several file names can point to the same >file on the disk (on Unix, for instance). In some cases, I that it is >possible to have a pseudo file without a true name (I think standard input >is one example, but I'm not sure about the details). Under Unix/Linux, it's also possible to have a "real" file (as in an inode and disk space), with no name. -- Grant Edwards grante Yow! I'm reporting for at duty as a modern person. I visi.com want to do the Latin Hustle now! From rnd at onego.ru Fri Jun 1 11:24:36 2001 From: rnd at onego.ru (Roman Suzi) Date: Fri, 1 Jun 2001 19:24:36 +0400 (MSD) Subject: join does not call __str__ In-Reply-To: Message-ID: On Fri, 1 Jun 2001, Sasa Zivkov wrote: > >>> class A: > ... def __str__(self): > ... return "str-a" > ... > >>> a = A() > >>> print a > str-a > >>> b = ['c', 'd', a] > >>> "".join(b) > Traceback (most recent call last): > File "", line 1, in ? > TypeError: sequence item 2: expected string, instance found > > > Somehow I expected that join method would use __str__ method to convert > instance to string... for some applications this is indeed convenient, but one can easily get wanted behaviour by doing str explicitely: "".join(map(str, b)) > Your opinion ? So, it's not a big problem. And doesn't slow down join() > -- Sasa Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From sebrosa at artenumerica.com Fri Jun 1 15:10:43 2001 From: sebrosa at artenumerica.com (Jose' Sebrosa) Date: Fri, 01 Jun 2001 20:10:43 +0100 Subject: Obsolesence of <> References: <3B17787F.266644CB@student.gu.edu.au> <3B1707A3.86AB1789@artenumerica.com> Message-ID: <3B17E8B3.F64581DE@artenumerica.com> Grant Edwards wrote: > > On Fri, 01 Jun 2001 04:10:27 +0100, Jose' Sebrosa wrote: > > >As far as I remember from my first subject on Calculus or so, > >the set of Complex Numbers has *not* the property of being > >ordered. So, from the mathematical point of view, it makes no > >sense to ask questions like "which of two given complex numbers > >is smaller". > > Right. It makes equally as little sense to ask which of "foo" > and 3.98 is smaller, but that's allowed, and returns a > consistent (and often useful) value. I would not put these things in the same level of "nosense". To make a comparison like "smaller" (not like "equal") between two objects, I first need to put them in a one-dimentional structure. Having several types arranged in a way that anything from type X is allways bigger than anything from type Y does exactly that: the types are arranged in a unidimentional structure, then compared. The problem with complexes is to arrange them in a unidimentional structure. As we can map R to C (and vice-versa), it is possible: To each X in R corresponds one and only one Z in C, and the Z is built like this: First, write X in decimal notation. Lets say it is X = 123.456 Then put the powers of ten alternately in the real and imaginary parts of Z: the power N in X goes to power N/2 in the real part of Z if N is odd and to the N/2 in the imaginary part if N is even. What a confusion! An example makes it obvious: if X is 123.45678, C will be ( 13.57, 2.468 ) Thats the only way I can figure to invent a comparison between two complexes, and it seems preety absurd to me... > In 2.1, strings are larger than floats, in case you're curious. > > It was sometimes useful to know that you could always compare two > objects. Yeah, eventually you can save some if's and try's ! :-) Sebrosa From dsh8290 at rit.edu Fri Jun 8 18:24:58 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 8 Jun 2001 18:24:58 -0400 Subject: Jython's tutorial. Where? In-Reply-To: ; from byte1024@hotmail.com on Fri, Jun 08, 2001 at 07:22:21PM +0000 References: Message-ID: <20010608182458.C19076@harmony.cs.rit.edu> On Fri, Jun 08, 2001 at 07:22:21PM +0000, Luigi wrote: | Hello, | | Where I can find tutorial about Jython? It interprets normal Python source and has nearly all of the standard library with it (only missing OS specific stuff and C dependant stuff). Thus the standard Python documentation applies (http://www.python.org/docs). Also you can find Jython specific information at http://jython.sourceforge.net. It also includes information specific to interacting with Java libraries. -D From markus at kepler.ibp.de Fri Jun 29 09:37:35 2001 From: markus at kepler.ibp.de (markus at kepler.ibp.de) Date: 29 Jun 2001 15:37:35 +0200 Subject: the center of the world (was Re: Check out O'Reilly's Open Source Convention Highlights) References: <3B3AA82D.1A0FE860@seebelow.org> <3B3B2DED.5303198A@seebelow.org> <9hhri7019jd@enews2.newsguy.com> Message-ID: "Alex Martelli" writes: > Anyway, once I do have such a file, I can presumably find the > "center of the world" (approximate) -- the one point on the Earth's > surface that minimizes population-weighted sum of great-circle > distances to 'population centers'. Of course I could get different > centers by choosing different weighing factors (country GNP rather > than country population, for example). > > Hmmm, if the coordinates were on a plane, finding the weighed > center would be trivial, but offhand I can't think of how to > do it on a sphere's surface -- I guess there must be some way > more suitable than just solving a generalized extremization > problem -- can anybody suggest one...? Then find first the weighted average as a point in three-dimensional space, i.e. as (an approximation to) the center of gravity of the human population. This will be some point deep in the interior of the Earth, which you could the project back to the surface. Markus From alex at pad.zuken.de Mon Jun 11 04:11:20 2001 From: alex at pad.zuken.de (Alexander Loehr) Date: Mon, 11 Jun 2001 08:11:20 GMT Subject: Tkinter: Lifting window to top? Message-ID: <1103_992247080@merak> Hi! I create a toplevel window and display it on the screen. On Unix everthing works fine. But on WinNT my window is behind all other windows. How can I lift it? The function lift doesn't work. Any Ideas? Regards, Alex. From Eugene.Leitl at lrz.uni-muenchen.de Thu Jun 7 16:06:55 2001 From: Eugene.Leitl at lrz.uni-muenchen.de (Eugene.Leitl at lrz.uni-muenchen.de) Date: Thu, 07 Jun 2001 22:06:55 +0200 Subject: Windows editor? References: Message-ID: <3B1FDEDF.DAFFA582@lrz.uni-muenchen.de> Kemp Randy-W18971 wrote: > > Ultra Edit (www.ultra.com) with the macro extension developed for Python is > great, and only $30. You have to download the free Python, macro extension. http://www.xemacs.org runs on a variety of platforms, Winders included (drag and drop possible there). Does many languages, including Python. It's great, and only $0. Minus download dineros, if any. ______________________________________________________________ ICBMTO : N48 10'07'' E011 33'53'' http://www.lrz.de/~ui22204 57F9CFD3: ED90 0433 EB74 E4A9 537F CFF5 86E7 629B 57F9 CFD3 From quinn at yak.ugcs.caltech.edu Thu Jun 21 16:28:28 2001 From: quinn at yak.ugcs.caltech.edu (Quinn Dunkan) Date: 21 Jun 2001 20:28:28 GMT Subject: critic this please References: Message-ID: On Thu, 21 Jun 2001 10:09:00 -0500, NJM wrote: >I've just wrote this small program that calculates the length of a rafter >for you(I'm a carpenter), but I didn't write it "properly". I can't seem to >wrap my head around using classes. Does anyone have any input. > > > import Tkinter > >def fig5(): > a = float(Tkinter.Entry.get(feet)) > b = float(Tkinter.Entry.get(inch)) > Tkinter.Entry.delete(answer, 0, 20) > Tkinter.Entry.insert(answer, 0, (b/12 + a)*13) > >def fig6(): > a = float(Tkinter.Entry.get(feet)) > b = float(Tkinter.Entry.get(inch)) > Tkinter.Entry.delete(answer, 0, 20) > Tkinter.Entry.insert(answer, 0, (b/12 + a)*13.42) [ etc. ] Since these only differ by their multiplier, I'd say something like: fig_map = { 5 : 13, 6 : 13.42, 7 : 13.89, 8 : 14.42, ... } def fig(n): a = float(Tkinter.Entry.get(feet)) b = float(Tkinter.Entry.get(inch)) Tkinter.Entry.delete(answer, 0, 20) Tkinter.Entry.insert(answer, 0, (b/12 + a) * fig_map[n]) .. and then replace this >button=Tkinter.Button(frame2, text="'5-12'", command=fig5) >button.pack(side=Tkinter.LEFT) >button2=Tkinter.Button(frame2, text="'6-12'", command=fig6) >button2.pack(side=Tkinter.LEFT) [ etc. ] with: for n in range(5, 13): # note range() doesn't include the last number b = Tkinter.Button(frame2, text="'%d-12'" % n, command=lambda n=n: fig(n)) b.pack(side=Tkinter.LEFT) Note that 'lambda n=n: fig(n)' is a python idiom that makes a function that evaluates 'fig(n)' (where 'n' is whatever 'n' happened to be when the lambda was evaluated). In general, whenever you find yourself doing something repetitive, you're doing work that the computer could be doing for you. Your job is to capture the changing bits (such as the multiplier mapping), factor them out, and write code to do all the tedious work. How easy it is to factor bits out is a measure of the flexibility of a language. And if you find yourself with names like 'foo1', 'foo2', etc., chances are you're either doing something repetitive, or not giving very descriptive names. And it's perfectly possible to write lots of 'proper' python without any classes at all. From emile at fenx.com Fri Jun 29 21:47:54 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 29 Jun 2001 18:47:54 -0700 Subject: data from Acces to Excel References: <9hiie0$84o$1@news.tpi.pl> Message-ID: <9hjbcs$e9sq1$1@ID-11957.news.dfncis.de> Yes you can do it. Look into the odbc and win32 modules. -- Emile van Sebille emile at fenx.com --------- "baton" wrote in message news:9hiie0$84o$1 at news.tpi.pl... > Hi, > I wonder if there is a possibilyty to export table from Access database to > Excel using python language?? If yes, could you tell me how to do it or > where I can find info how to do it? > > Sorry for my English > > From just at letterror.com Wed Jun 27 05:16:00 2001 From: just at letterror.com (Just van Rossum) Date: Wed, 27 Jun 2001 11:16:00 +0200 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) References: <3B3950ED.8002AF8@cosc.canterbury.ac.nz> Message-ID: <3B39A44E.C6B94223@letterror.com> Robin Becker wrote: > it would have been so much nicer and easier if these generator functions > could be generalised to be resumable then all the nonsense about where > and when they could be used would vanish. This seems to be too late now. Eh? This *is* generalized: you can resume a generator "by hand": >>> def gen(x): ... i = 0 ... while i < x: ... yield i ... i += 1 ... >>> g = gen(4) >>> g.next() 0 >>> g.next() 1 >>> g.next() 2 >>> g.next() 3 >>> g.next() Traceback (most recent call last): File "", line 1, in ? StopIteration >>> The fact that this uses the iterator protocol is merely because it's practical: most often generators will be used in a for context. Just From tim.one at home.com Sat Jun 9 23:43:48 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 9 Jun 2001 23:43:48 -0400 Subject: floating point in 2.0 In-Reply-To: <3b20e8ea.134863833@wa.news.verio.net> Message-ID: [Tim] >> For most Python users, I expect decimal f.p. with user-settable >> precision is going to be much easier to use. [Bengt Richter] > Perhaps too easy? ;-) I am not sure "user-settable precision" will be > clear enough a concept for most. Will they understand exactly what is > guaranteed by a given setting? Will you be able to explain it to them? > ... > [followed by 1, 2, 3, 4, 5, 6, 7, ... at least 8 similarly open-ended > questions] The working model for decimal f.p. (which Aahz is implementing) is IBM's Decimal Arithmetic Proposal, at http://www2.hursley.ibm.com/decimal/ It's been used successfully in REXX for close to 20 years, so it's not that big a gamble. Brief replies to selected questions: > ... > Should interval arithmetic be used to track the bounds of possible > errors through computation, and an optional exception be thrown if > output formatting demands more figures than are accurately available? > Or if an intermediate result becomes too imprecise? No, interval arithmetic is an expert's tool; the error bounds mushroom out of usefulness in a non-expert's hands. > How many appreciate the difference between probable errors in data > itself and errors in representation of data, and how the two are > transformed and intertwingled in algorithms? Among newbies, virtually none. > Would (value,tolerance) be a more intuitive way to specify precision > (indirectly) than decimal precision in some cases? Sure, but not for newbies. Among experts, some will want tolerance to be in a +- absolute value sense, some in a +- relative error sense, others in a standard deviation sense. The goal of decimal f.p. is to make life easier for newbies -- experts can go fight with each other and leave the newbies in peace . > Perhaps it would be useful to look at the problem in terms of actual > assertions one might like to be able to write concerning values and > their representations? E.g., something that says that printing > "10.0" after computing the sum of 100 ".100" values is (barely) ok, > but warns you that "10.0000" is illusory. IBM's proposal incorporates a notion of "significant" trailing zeroes, in a related sense. > BTW, I had another little idea ;-) tying this into formatting of > objects: If class Quantity defined __str__ with an optional second > argument, then the % operator could pass the relevant slice of the > format string along with the object's "self" to the __str__ method > and you'd have open-ended formatting capability. E.g., > > "%20.3.7s" % ( x,) > > would make the effective call > > x.__str__('20.3.7') > > to get the formatted representation. This example might be radix-7 > printed 20 wide with 3 septimals(?). Or it could be 20 wide with > 3 decimals verifying 7-digit precision of the representation. Or > anything you might like to encode between the '%' and 's'. We're losing focus here, Bengt . May be an interesting PEP here, if you're motivated enough to pursue it! > If you wanted to be able to pass about any control string, you > could allow a quoting delimiter like "%'special stuff's ..." > or maybe bracketing delimiters: "%[special stuff]s ..." etc. > > (Please excuse if I am re-inventing a Python wheel. This seems > like one of those things you might already have done in some > form to handle formatting). No, on the few occassions I've seen "stuff like this" done, people use a plain %s format code and give explicitly-called format methods to their objects; e.g., "%s" % x.format(20, 3, 7) vs "%20.3.7s" % x Especially when format parameters can vary dynamically, it's more convenient and clearer to have a call-form than to paste together a format control string at runtime. For example, >>> from Rational import Rat, Format >>> x = Rat.Rat("1/7") >>> print x.str(base=7) 1/10_7 >>> print x.str(base=7, mode=Format.FIXED, prec=3) 0.100_7 >>> print x.str(base=10, mode=Format.FIXED, prec=40) 0.1428571428571428571428571428571428571429->> print x.str(base=32, mode=Format.FIXED, prec=10) 0.4i94i94i95_32->> print x.str(base=32, mode=Format.FIXED, prec=10, use_letters=0) 0.4(18)94(18)94(18)95_32->> Etc. There are other possible keyword arguments not shown above, and it would be take me a year just to *define* a control-string format I could remember how to use . Packaging common combinations for easy reuse can be done in different ways; e.g., continuing the last example, >>> f = Format.Format(base=32, mode=Format.FIXED, prec=10, use_letters=0) >>> print x.str(f) 0.4(18)94(18)94(18)95_32->> like-regexps-%-is-most-satisfying-in-simple-cases-ly y'rs - tim From romain.guy at jext.org Thu Jun 21 09:48:00 2001 From: romain.guy at jext.org (Romain Guy) Date: Thu, 21 Jun 2001 15:48:00 +0200 Subject: String --> int References: <9gsl08$gsl$1@wanadoo.fr> <3B31EF7F.2BFB3072@inf.ethz.ch> Message-ID: <9gstpl$16h$1@wanadoo.fr> thanks -- Romain "Java Swinguer !" Guy romain.guy at jext.org www.jext.org "Now, don't you worry. The saucers are up there. The graveyard is out there. But I'll be locked up safely in there." - Paula Trent, Plan 9 From Outer Space "Samuele Pedroni" a ?crit dans le message news: 3B31EF7F.2BFB3072 at inf.ethz.ch... > Romain Guy wrote: > > > Assuming fsock is a File objet, when I do: > > var = fsock.read(4) > > I get a String. I'd like to convert it into an integer. I haven't found any > > method for this so I built this one: > > > > def _buildInteger(bytes): > > if len(bytes) != 4: > > return -1 > > else: > > return ord(bytes[0]) | ord(bytes[1]) << 8 | ord(bytes[2]) << 16 | > > ord(bytes[3]) << 24 > > > > It works perfectly but I'd like to use one internal to Python if possible... > > > > -- > > Romain "Java Swinguer !" Guy > > romain.guy at jext.org > > www.jext.org > > > > "Now, don't you worry. The saucers are up there. The graveyard is out there. > > But I'll be locked up safely in there." > > - Paula Trent, Plan 9 From Outer Space > > struct.unpack should do what you are looking for. > > http://www.python.org/doc/current/lib/module-struct.html > > regards. > From tim at digicool.com Thu Jun 14 12:49:07 2001 From: tim at digicool.com (Tim Peters) Date: Thu, 14 Jun 2001 12:49:07 -0400 Subject: PEP 255: Simple Generators Message-ID: You can view an HTML version of PEP 255 here: http://python.sourceforge.net/peps/pep-0255.html Discussion should take place primarily on the Python Iterators list: mailto:python-iterators at lists.sourceforge.net If replying directly to this message, please remove (at least) Python-Dev and Python-Announce. PEP: 255 Title: Simple Generators Version: $Revision: 1.3 $ Author: nas at python.ca (Neil Schemenauer), tim.one at home.com (Tim Peters), magnus at hetland.org (Magnus Lie Hetland) Discussion-To: python-iterators at lists.sourceforge.net Status: Draft Type: Standards Track Requires: 234 Created: 18-May-2001 Python-Version: 2.2 Post-History: 14-Jun-2001 Abstract This PEP introduces the concept of generators to Python, as well as a new statement used in conjunction with them, the "yield" statement. Motivation When a producer function has a hard enough job that it requires maintaining state between values produced, most programming languages offer no pleasant and efficient solution beyond adding a callback function to the producer's argument list, to be called with each value produced. For example, tokenize.py in the standard library takes this approach: the caller must pass a "tokeneater" function to tokenize(), called whenever tokenize() finds the next token. This allows tokenize to be coded in a natural way, but programs calling tokenize are typically convoluted by the need to remember between callbacks which token(s) were seen last. The tokeneater function in tabnanny.py is a good example of that, maintaining a state machine in global variables, to remember across callbacks what it has already seen and what it hopes to see next. This was difficult to get working correctly, and is still difficult for people to understand. Unfortunately, that's typical of this approach. An alternative would have been for tokenize to produce an entire parse of the Python program at once, in a large list. Then tokenize clients could be written in a natural way, using local variables and local control flow (such as loops and nested if statements) to keep track of their state. But this isn't practical: programs can be very large, so no a priori bound can be placed on the memory needed to materialize the whole parse; and some tokenize clients only want to see whether something specific appears early in the program (e.g., a future statement, or, as is done in IDLE, just the first indented statement), and then parsing the whole program first is a severe waste of time. Another alternative would be to make tokenize an iterator[1], delivering the next token whenever its .next() method is invoked. This is pleasant for the caller in the same way a large list of results would be, but without the memory and "what if I want to get out early?" drawbacks. However, this shifts the burden on tokenize to remember *its* state between .next() invocations, and the reader need only glance at tokenize.tokenize_loop() to realize what a horrid chore that would be. Or picture a recursive algorithm for producing the nodes of a general tree structure: to cast that into an iterator framework requires removing the recursion manually and maintaining the state of the traversal by hand. A fourth option is to run the producer and consumer in separate threads. This allows both to maintain their states in natural ways, and so is pleasant for both. Indeed, Demo/threads/Generator.py in the Python source distribution provides a usable synchronized-communication class for doing that in a general way. This doesn't work on platforms without threads, though, and is very slow on platforms that do (compared to what is achievable without threads). A final option is to use the Stackless[2][3] variant implementation of Python instead, which supports lightweight coroutines. This has much the same programmatic benefits as the thread option, but is much more efficient. However, Stackless is a controversial rethinking of the Python core, and it may not be possible for Jython to implement the same semantics. This PEP isn't the place to debate that, so suffice it to say here that generators provide a useful subset of Stackless functionality in a way that fits easily into the current CPython implementation, and is believed to be relatively straightforward for other Python implementations. That exhausts the current alternatives. Some other high-level languages provide pleasant solutions, notably iterators in Sather[4], which were inspired by iterators in CLU; and generators in Icon[5], a novel language where every expression "is a generator". There are differences among these, but the basic idea is the same: provide a kind of function that can return an intermediate result ("the next value") to its caller, but maintaining the function's local state so that the function can be resumed again right where it left off. A very simple example: def fib(): a, b = 0, 1 while 1: yield b a, b = b, a+b When fib() is first invoked, it sets a to 0 and b to 1, then yields b back to its caller. The caller sees 1. When fib is resumed, from its point of view the yield statement is really the same as, say, a print statement: fib continues after the yield with all local state intact. a and b then become 1 and 1, and fib loops back to the yield, yielding 1 to its invoker. And so on. From fib's point of view it's just delivering a sequence of results, as if via callback. But from its caller's point of view, the fib invocation is an iterable object that can be resumed at will. As in the thread approach, this allows both sides to be coded in the most natural ways; but unlike the thread approach, this can be done efficiently and on all platforms. Indeed, resuming a generator should be no more expensive than a function call. The same kind of approach applies to many producer/consumer functions. For example, tokenize.py could yield the next token instead of invoking a callback function with it as argument, and tokenize clients could iterate over the tokens in a natural way: a Python generator is a kind of Python iterator[1], but of an especially powerful kind. Specification A new statement is introduced: yield_stmt: "yield" expression_list "yield" is a new keyword, so a future statement[8] is needed to phase this in. [XXX spell this out] The yield statement may only be used inside functions. A function that contains a yield statement is called a generator function. When a generator function is called, the actual arguments are bound to function-local formal argument names in the usual way, but no code in the body of the function is executed. Instead a generator-iterator object is returned; this conforms to the iterator protocol[6], so in particular can be used in for-loops in a natural way. Note that when the intent is clear from context, the unqualified name "generator" may be used to refer either to a generator-function or a generator- iterator. Each time the .next() method of a generator-iterator is invoked, the code in the body of the generator-function is executed until a yield or return statement (see below) is encountered, or until the end of the body is reached. If a yield statement is encountered, the state of the function is frozen, and the value of expression_list is returned to .next()'s caller. By "frozen" we mean that all local state is retained, including the current bindings of local variables, the instruction pointer, and the internal evaluation stack: enough information is saved so that the next time .next() is invoked, the function can proceed exactly as if the yield statement were just another external call. A generator function can also contain return statements of the form: "return" Note that an expression_list is not allowed on return statements in the body of a generator (although, of course, they may appear in the bodies of non-generator functions nested within the generator). When a return statement is encountered, nothing is returned, but a StopIteration exception is raised, signalling that the iterator is exhausted. The same is true if control flows off the end of the function. Note that return means "I'm done, and have nothing interesting to return", for both generator functions and non-generator functions. Example # A binary tree class. class Tree: def __init__(self, label, left=None, right=None): self.label = label self.left = left self.right = right def __repr__(self, level=0, indent=" "): s = level*indent + `self.label` if self.left: s = s + "\n" + self.left.__repr__(level+1, indent) if self.right: s = s + "\n" + self.right.__repr__(level+1, indent) return s def __iter__(self): return inorder(self) # Create a Tree from a list. def tree(list): n = len(list) if n == 0: return [] i = n / 2 return Tree(list[i], tree(list[:i]), tree(list[i+1:])) # A recursive generator that generates Tree leaves in in-order. def inorder(t): if t: for x in inorder(t.left): yield x yield t.label for x in inorder(t.right): yield x # Show it off: create a tree. t = tree("ABCDEFGHIJKLMNOPQRSTUVWXYZ") # Print the nodes of the tree in in-order. for x in t: print x, print # A non-recursive generator. def inorder(node): stack = [] while node: while node.left: stack.append(node) node = node.left yield node.label while not node.right: try: node = stack.pop() except IndexError: return yield node.label node = node.right # Exercise the non-recursive generator. for x in t: print x, print Q & A Q. Why a new keyword? Why not a builtin function instead? A. Control flow is much better expressed via keyword in Python, and yield is a control construct. It's also believed that efficient implementation in Jython requires that the compiler be able to determine potential suspension points at compile-time, and a new keyword makes that easy. Reference Implementation A preliminary patch against the CVS Python source is available[7]. Footnotes and References [1] PEP 234, http://python.sf.net/peps/pep-0234.html [2] http://www.stackless.com/ [3] PEP 219, http://python.sf.net/peps/pep-0219.html [4] "Iteration Abstraction in Sather" Murer , Omohundro, Stoutamire and Szyperski http://www.icsi.berkeley.edu/~sather/Publications/toplas.html [5] http://www.cs.arizona.edu/icon/ [6] The concept of iterators is described in PEP 234 http://python.sf.net/peps/pep-0234.html [7] http://python.ca/nas/python/generator.diff [8] http://python.sf.net/peps/pep-0236.html Copyright This document has been placed in the public domain. From loewis at informatik.hu-berlin.de Sun Jun 17 07:27:19 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 17 Jun 2001 13:27:19 +0200 Subject: os.statvfs on FreeBSD References: Message-ID: t_messmer at yahoo.com (Tom Messmer) writes: > Thanks for looking at this, I took some time and noticed that there > was really no statvfs system call in FreeBSD (stable) and thought it > might be possible to use the statfs call and map it to the same tuple > returned by python's os.statvfs routine. Er, but thats as far as I got > with it so far because I'm new at Python and not much of a programmer > anyway. I looked at the os module itself and saw that it calls posix > for unix-like systems, but from there I couldnt tell how it accesses > system calls. If someone would care to explain this I'd love to hear > about it It's really not that difficult: os.py gets most functions from the posix module on your system. This, in turn, is implemented in Modules/posixmodule.c. It provides statvfs if the configure had detected the system call in the C library, and had thus defined HAVE_STATVFS. If you look at posix_statvfs, you see that it really only calls the OS statvfs, and then builds a Python tuple from the results. If the system provides statfs, I think it would be better to support this in addition to statvfs. The fields of the calls vary slightly in their semantics, and an application might need to know whether it got the real values from the system, or emulated values. If you want to provide statfs in posixmodule, just model it after statvfs. Search the entire Python source code for all occurrences of statvfs (take particular notice of those in configure.in). If you succeed, please post your patch to sf.net/projects/python. Regards, Martin From christian at rocketnetwork.com Fri Jun 22 19:16:50 2001 From: christian at rocketnetwork.com (Christian Reyes) Date: Fri, 22 Jun 2001 16:16:50 -0700 Subject: How do I close a specific application via python (windows) References: <9gvva4$i4v$1@bob.news.rcn.net> Message-ID: <9h0jl5$ose$1@bob.news.rcn.net> I've been looking at the win32api.openprocess method and that seems to give me hooks to killing an app. But my problem is that openprocess needs a processID. How do i get the process id of an application? "Christian Reyes" wrote in message news:9gvva4$i4v$1 at bob.news.rcn.net... > Is there a way to explicity kill a specific application in windows? > > tia, > christian > > > From daniel.dittmar at sap.com Wed Jun 27 06:14:46 2001 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Wed, 27 Jun 2001 12:14:46 +0200 Subject: Escaping SQL in python References: <3B39A1B8.A7FCE4C7@kvarteret.uib.no> Message-ID: <9hcbml$j70$1@news1.wdf.sap-ag.de> > Is there a method to escape ' " \ and the like in python auto-magiacaly > ? It is probably best to use triple quoted strings. This allows single quotes of either variety and SQL statements tend to spread over multiple lines anyway. Daniel -- Daniel Dittmar daniel.dittmar at sap.com SAP DB, SAP Labs Berlin http://www.sapdb.org/ From pmoscatt at bigpond.net.au Fri Jun 1 11:01:01 2001 From: pmoscatt at bigpond.net.au (Peter Moscatt) Date: Fri, 01 Jun 2001 15:01:01 GMT Subject: Problem installing Python2.1 on RH 7.1 References: <991402384.98784@nntp01.uskonet.com> Message-ID: Hanna.... is this the Python 2.1 your talking about as I am after it myself so that I can install TIX. Pete Hanna Joo wrote: > Hello > > I've been trying to install the newest version on RH 7.1. After millions > of dependency errors finally it is installed. > > Problem is, although it seems to have been installed correctly (all the > libraries are there, files have been copied etc), I cannot find python in > the path. I thought the -U option in rpm removed the older version - > which did not happen. All I can find in my path is 1.5.2. > > Any help will be appreciated > > TIA > > Hanna > > > From lac at cd.chalmers.se Wed Jun 6 10:26:54 2001 From: lac at cd.chalmers.se (Laura Creighton) Date: Wed, 6 Jun 2001 16:26:54 +0200 (MET DST) Subject: creating new Tkinter widget classes Message-ID: <200106061426.QAA10840@boris.cd.chalmers.se> class CapsButton(CommonWidgetMixin, Tkinter.Button): gets me at the Tkinter.Button methods. Now I want to get at the grid geometry method. How? Laura From dsh8290 at rit.edu Fri Jun 8 18:16:44 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 8 Jun 2001 18:16:44 -0400 Subject: Why no 'elif' in try/except? In-Reply-To: ; from qrczak@knm.org.pl on Fri, Jun 08, 2001 at 04:12:56PM +0000 References: <3B1A06EE.F484930A@snakefarm.org> <3B1A29DE.9876770D@accessforall.nl> <3B203458.835AE30F@cosc.canterbury.ac.nz> Message-ID: <20010608181644.A19076@harmony.cs.rit.edu> On Fri, Jun 08, 2001 at 04:12:56PM +0000, Marcin 'Qrczak' Kowalczyk wrote: | Fri, 08 Jun 2001 14:11:36 +1200, Greg Ewing pisze: | Neither do I. What about consistency? In that case, what about else on 'for' and 'while'? Just being pedantic.. | (I would still prefer 'else if' to 'elif'. Some languages use 'elsif' | and I can't remember which is where.) if 0 : print "pigs can fly" elsif [whoa, why is this white?] ^H^H^Hif [ahh, yellow, much better] Who says syntax highlighting isn't useful? -D From steven at haryan.to Thu Jun 7 08:34:32 2001 From: steven at haryan.to (Steven Haryanto) Date: Thu, 07 Jun 2001 19:34:32 +0700 Subject: WHY is python slow? In-Reply-To: References: Message-ID: <4.3.2.7.2.20010607193225.021c1d90@bdg.centrin.net.id> On 07/06/2001 18:11, Martin von Loewis wrote: >Steven Haryanto writes: > > > Although it is generally accepted that Python is slower than > > Java/Perl/Ruby > >I don't believe this is "generally" accepted; I don't accept it. In Well, that is the impression I get from this list, and what most people say when some poster asks for a comparison with those languages. Btw, I believe, for one thing, Python's (I last tried with 1.5.2) startup time is significantly higher than that of Perl. >fact, there are numerous examples where Python has been shown to work >faster than Java or Perl; I don't know about that many performance >comparisons between Ruby and Python to know which of these languages >is faster for what algorithms. Steve From Marcin.Kasperski at softax.com.pl Tue Jun 19 14:13:59 2001 From: Marcin.Kasperski at softax.com.pl (Marcin Kasperski) Date: Tue, 19 Jun 2001 20:13:59 +0200 Subject: Problems with omniORB and omniORBpy on Tru64 - with solution Message-ID: <3B2F9667.8C213AD4@softax.com.pl> { I post this letter to comp.lang.python as some people could be interested in building omniORBPython on Tru64 and to omniorb at uk.research.att.com as bugreport. } I am currently trying to compile Python/OmniORB/OmniORBpython suite on Tru64 Unix (new name for Digital Unix/OSF) with DEC CXX 6.2. I got some problems and solved it, below there are some interesting details. The tests described below used Python 2.1 and omniORB 3.0.3. 1) There is one major flaw in omniORB makefiles for Tru64: in many places they use 'ld' to link C++ code. This leads to things like ld: Warning: Unresolved: __nwa__XUl __dla__XPv __stdnw__XUl __vtbl_3std9type_info__3std __vec_new_eh __vec_delete (the symbols change from place to place). The 'so' files are created but are useless (can not be run with or - in case of python extension modules - can not be imported - due to unresolved symbols). To correct the problem I edited the following files: omni/mk/platforms/alpha_osf1_5.0.mk (under 'define MakeCXXSharedLibrary') omni/src/tool/omniidl/cxx/dir.mk (under 'OSF1') omni/src/lib/omniORB2/orbcore/sharedlib/dir.mk (under 'OSF1') omni/src/lib/omniORB2/dynamic/sharedlib/dir.mk (under 'OSF1') omni/src/lib/omniORB2/orbcore/gatekeepers/tcpwrapper/sharedlib/dir.mk (under 'OSF1') and (the file from omniORBpy): omni/src/lib/omniORBpy/modules/dir.mk (under 'OSF1'). In all those placed I: - changed 'ld' to 'cxx' - removed '-lcxxstd -lcxx -lexc -lots -lc' (no longer needed) For instance, the last of the files mentioned contain after my change (look forward for PYLIBDIR and -lm which were added by me too): $(lib): $(OBJS) (set -x; \ $(RM) $@; \ cxx -shared -soname $(soname) -set_version $(soname) -o $@ $(IMPORT_LIBRARY_FLAGS) \ $(filter-out $(LibSuffixPattern),$^) $(OMNIORB_LIB_NODYN) \ -L$(PYLIBDIR) -l$(PYLIBFILE) \ -lm \ ) 2) Lack of linkage with Python {The thing which proves nobody attempted the compilation ;-)} While compiling in directories omni/src/tool/omniidl/cxx/ and (the dir from omniORBpy): omni/src/lib/omniORBpy/modules/ I got Warning: Unresolved: PyType_Type _Py_NoneStruct PyTuple_Type PyList_Type (... many more ...) The reason is simple: rules for Tru64 (and maybe other platforms too) does not link with libpython! To correct it I edited the files omni/src/tool/omniidl/cxx/dir.mk and omni/src/lib/omniORBpy/modules/dir.mk and in both cases: a) I added the lines PYLIBDIR := $(PYPREFIX)/lib/python$(PYVERSION)/config PYLIBFILE := python$(PYVERSION) within 'ifdef UnixPlatform', just below PYINCFILE := ... b) I added -L$(PYLIBDIR) -l$(PYLIBFILE) -lm to the linking rule under OSF1 (look 20 lines up to see the example). -lm seems to be required by python libraries, without it I got unresolved frexp, modf, fabs etc. 3) DEC CXX complained for incorrect syntax on #if NeedVarargsPrototypes (I observed numerous warning and got errors in omni/src/tool/omkdepend/main.c). To correct, I grepped for this and changed to #ifdef NeedVarargsPrototypes and got correct compilation. Instead one probably could edit omni/src/tool/omkdepend/def.h and change from #if defined(__osf1__) #define NeedVarargsPrototypes #endif to #if defined(__osf1__) #define NeedVarargsPrototypes 1 #endif but the first solution seems to me to be better for other platforms. 4) This problem is probably independent from omniORB but very important. The default compilation results in Traceback (innermost last): File "", line 1, in ? ImportError: dlopen: Unresolved symbols during the first call to omniidl. The reason? There are no symbols from libcxx.so. It is probably some 'dynaload' python problem. To correct it I recompiled python itself with cxx instead of cc. The very details I describe in the separate letter which should come together with this one. 5) After everything described above I got running omniORB and omniORBpython on Tru64. At least the first samples I tried worked as expected. From tim.one at home.com Sun Jun 24 05:56:17 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 24 Jun 2001 05:56:17 -0400 Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: [Tim] > ... A good user's intro to Python generators doesn't exist yet (AFAIK). [Michael Hudson] > And writing one's going to be tricky, 'cause a generator is only a big > win when there's lots of state that has to be maintained across yields > and such an example is necessarily hairy. Same deal for weak refs - > a simple example is necessarily contrived. Well, it depends on the audience and the author. Generators don't have to be terribly fancy to be useful, and in some contexts they're screamingly natural. For example, "how do I generate the elements of a list taken k at a time?" is almost a c.l.py FAQ, and generators are ideal for that kind of thing: def gcomb(x, k): "Generate all combinations of k elements from list x." if k > len(x): return if k == 0: yield [] else: first, rest = x[0], x[1:] # A combination does or doesn't contain first. # If it does, the remainder is a k-1 comb of rest. for c in gcomb(rest, k-1): c.insert(0, first) yield c # If it doesn't contain first, it's a k comb of rest. for c in gcomb(rest, k): yield c seq = range(1, 5) for k in range(len(seq) + 2): print "%d-combs of %s:\n " % (k, seq), for c in gcomb(seq, k): print c, " ", print Which prints: 0-combs of [1, 2, 3, 4]: [] 1-combs of [1, 2, 3, 4]: [1] [2] [3] [4] 2-combs of [1, 2, 3, 4]: [1, 2] [1, 3] [1, 4] [2, 3] [2, 4] [3, 4] 3-combs of [1, 2, 3, 4]: [1, 2, 3] [1, 2, 4] [1, 3, 4] [2, 3, 4] 4-combs of [1, 2, 3, 4]: [1, 2, 3, 4] 5-combs of [1, 2, 3, 4]: This *kind* of example doesn't appeal to everyone, of course, but I already covered my butt by saying it depends on the audience and the author . i-write-best-when-the-audience-is-me-ly y'rs - tim From tim.one at home.com Sat Jun 30 23:24:44 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 30 Jun 2001 23:24:44 -0400 Subject: PEP scepticism In-Reply-To: <5.0.2.1.0.20010630110830.0269b170@mail.inet.com.br> Message-ID: [Carlos Ribeiro] > ... > So I believe that PythonLabs should at least consider doing three > things: A problem is that nobody at PythonLabs has any spare cycles. People can suggest any number of things we should do for them, but we're already overloaded -- it simply won't happen. > - Define clearly what goes and what does not go into the standard > library. This is the province of PEP 2: http://python.sourceforge.net/peps/pep-0002.html While what's there is fine so far as it goes, it would help if someone added a second sentence . > - Help track the module development process. > ... > - Compile the standard modules for all supported platforms. Good goal, but no way to get there from here: PythonLabs has access to only a tiny percentage of all the platforms Python runs on. This *has* to come from the community. There are a few people who contribute outstanding work here (like Mark Favas for various 64-bit boxes), but to judge from the initial crush of platform-specific bugs whenever we release an alpha version, far too few people on "minority" platforms try to build from the CVS tree. And this despite that compiling Python is more rewarding than your work and more fun than sex . If anyone out there is a knowledgeable fan of some non-Linux non-Windows platform, they could help a lot just by scouring SourceForge for platform-specific bug reports and lending a hand. Like, does *anyone* know how to make threads work on HP-UX? There are always half a dozen bugs open on that. > ... > One advantage of having such a well defined process to elect the > standard modules is that it will encourage people to improve the > standard modules, instead of re-inventing the wheel. PEP 2 is indeed important. From phd at phd.fep.ru Tue Jun 26 15:36:05 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Tue, 26 Jun 2001 23:36:05 +0400 (MSD) Subject: OS-specific modules to OS-specific packages In-Reply-To: Message-ID: On Tue, 26 Jun 2001, Alexander Gavrilov wrote: > Would it be nice to keep all OS-specific modules of the standard library > in OS-specific packages? For example, Mac modules "macdnr", "mactty" and so > on could be become "mac.dnr", "mac.tty". Windows-specific modules could > become the part of win32 package: win32._winreg, win32.winsound and so on. > Unix modules can be separated further to distinguish various flavor of UNIX: > unix.syslog, unix.fcntl but unix.irix.fl, unix.sunos.sunaudiodev and so on. Good idea. Installer may even skip "alien" modules, unless it is shared installation. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From altis at semi-retired.com Wed Jun 6 16:06:27 2001 From: altis at semi-retired.com (Kevin Altis) Date: Wed, 6 Jun 2001 13:06:27 -0700 Subject: print foo, adds a space to beginning of next line? References: <3B1E7D78.53A5BE30@ll.mit.edu> Message-ID: I noticed this too when doing some CGIs. Seems like a bug to me. ka "George Young" wrote in message news:3B1E7D78.53A5BE30 at ll.mit.edu... > [python 2.1, intel linux] > def f(): > print 'what is your name: ', > x=sys.stdin.readline() > print 'what is your age: ', > y=sys.stdin.readline() > > f() > what is your name: mememe > what is your age: 48 > > Why does it print a space at the beginning of the second line? > > If I use sys.stdout.write('what is your name: ') instead, it > works fine. > > -- > Your mouse has moved. > Windows NT must be restarted for the change to take effect. > Reboot now? [OK] From michael+gnus at trollope.org Fri Jun 22 10:20:28 2001 From: michael+gnus at trollope.org (Michael Powe) Date: 22 Jun 2001 07:20:28 -0700 Subject: Another Wart! string.find() [ was: namespace issue? ] References: Message-ID: >>>>> "Steven" == Steven D Majewski writes: Steven> On 21 Jun 2001, Michael Powe wrote: >> So now the question is, 'why'? Am I misusing the string.find() >> function? Okay, string.find() returns -1 when the string is not >> found, which would seem to be what I expected, a false result. >> Maybe python doesn't treat -1 as false? Well, I'll try being >> explicit and testing for -1 return. I probably have just >> confused myself hopelessly. Steven> You got it! Steven> 0, 0.0, "", [], (), and None, as well as classes that Steven> return 0 from methods __nonzero__ or __len__ are false. Steven> everything else (unless I missed one ;-) is true. Steven> -1 is true. Steven> But find can't return 0 because it is a valid offset Steven> that signifies the beginning of a string, so it returns Steven> -1. Yeah, I shoulda thunk. I would have realized this. ;-( mp From matt at mondoinfo.com Mon Jun 11 16:28:23 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Mon, 11 Jun 2001 20:28:23 GMT Subject: Disabling a Pmw.ComboBox References: Message-ID: On Mon, 11 Jun 2001 13:55:17 +0100, Martyn Quick wrote: >I'm trying to work out how to `disable' a Pmw.ComboBox (in a similar >manner to setting state='disabled' for a Tkinter.Button). One way I >thought of doing it was to try setting state='disabled' for the >'arrowbutton' component of the ComboBox. However, this arrowbutton is a >Tkinter.Canvas, so doesn't have state as a valid configuration option. > >Does anybody have a decent way of doing this? (My goal is to be able to >allow it be available for use or disabled according to other information.) Martyn, You might want to do a couple of things to disable the widget. You'd probably want to disable the entry: c.component("entryfield").component("entry").configure(state=DISABLED) You might want to gray-out the arrow: c.component("arrowbutton").itemconfigure(ALL,fill="gray50") (All seems safe here since the canvas only has one thing on it.) And you'd want to disable mouse-clicks on the button: c.component("arrowbutton").unbind("") Actually, there are a bunch of events bound to the button. A look through PmwComboBox.py should tell you which you'd want to mess around with. The only non-trivial part of re-enabling things is to rebind the mouse button: c.component("arrowbutton").bind("",c._postList) Of course, I'm advocating messing around with private class attributes so there's a decent chance that the code will break under a future release of Pmw but I'm not aware of another way to do what you want. Regards, Matt From not.this at seebelow.org Fri Jun 29 11:45:27 2001 From: not.this at seebelow.org (Grant Griffin) Date: 29 Jun 2001 08:45:27 -0700 Subject: the center of the world (was Re: Check out O'Reilly's Open Source Convention Highlights) References: <3B3AA82D.1A0FE860@seebelow.org> <3B3B2DED.5303198A@seebelow.org> <9hhri7019jd@enews2.newsguy.com> Message-ID: <9hi7qn02dh1@drn.newsguy.com> In article , Konrad says... > >markus at kepler.ibp.de writes: > >> Then find first the weighted average as a point in three-dimensional >> space, i.e. as (an approximation to) the center of gravity of the >> human population. This will be some point deep in the interior of the >> Earth, which you could the project back to the surface. > >But that doesn't minimize the distance on the surface. Actually, we should >minimize something even more pragmatic, such as travel cost, travel time, >or some weighted combination. I'm betting that will lead everybody right back here to the US Midwest . ugly-american-ly y'rs, =g2 _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From drew.csillag at starmedia.net Fri Jun 22 09:13:40 2001 From: drew.csillag at starmedia.net (Drew Csillag) Date: Fri, 22 Jun 2001 09:13:40 -0400 Subject: Codeobjects of Modules? In-Reply-To: <9gs7ou+ro76@eGroups.com>; from gbgbgb@gmx.de on Thu, Jun 21, 2001 at 07:29:34AM -0000 References: <9gs7ou+ro76@eGroups.com> Message-ID: <20010622091340.H7962@naxos.skunk.org> On Thu, Jun 21, 2001 at 07:29:34AM -0000, gbgbgb at gmx.de wrote: > Hi! > I am writing an experimental virtual machine for Python-Byte-Code > in Python. It works fine for Functions (I am using the > f.func_code.co_code Bytecode.) > > Now I want to run entire pyc-Files and/or modules. How do I get the > bytecode from modules and what is the format of the pyc-files. I could > not find any documentation. > > After finishing the PVM in Python I want to port it to - please do not > kill me - JAVASCRIPT. I think this could be interesting to be able to > execute python-byte-code on NS and IE without JAVA. > > Any help is welcome! To get the code object: import marshal f = open(filename) f.seek(8) code_obj = marshal.load(f) That's it! Cheers, Drew -- print(lambda(m,d,y):['Tues','Wednes','Thurs','Fri','Satur','Sun','Mon'][ ((d-((0,3,7,7,4,9,6,4,8,5,3,7,5)[m]+(m<3and(y%4==0)and y%100!=0or y%400 ==0)))+(lambda(q,r),y:(q+r+r/4+(-2*(y%4))))(divmod(y%100,12),y/100))%7]+ 'day')(map(int,raw_input('mm/dd/yyyy>').split('/'))) From aahz at panix.com Fri Jun 8 10:16:48 2001 From: aahz at panix.com (Aahz Maruch) Date: 8 Jun 2001 07:16:48 -0700 Subject: random References: <9fo9k50gl6@enews2.newsguy.com> <87snhblcx4.fsf@litterbox.meowing.net> Message-ID: <9fqmog$m7a$1@panix3.panix.com> In article <87snhblcx4.fsf at litterbox.meowing.net>, A Meowbot wrote: >scarblac at pino.selwerd.nl (Remco Gerlich) wrote: >> >> No matter how long you let it run, there will always be a finite amount of >> non-blank squares. The number may grow larger than any N you want to name, >> but it'll never be infinite (I wonder what the last step would look like, >> right before it becomes infinite). > >It would look really, really big. Does it go to eleven? -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "NRE is a lot like cocaine. Feels great while you're on it, makes you feel very special and talented, and you become highly annoying to those who aren't on it." --Stef From mal at lemburg.com Sun Jun 17 08:15:54 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Sun, 17 Jun 2001 14:15:54 +0200 Subject: Writing new codecs References: <002901c0f6bd$6e3bf990$445d4540@D1XYVL01> Message-ID: <3B2C9F7A.82D18F6B@lemburg.com> Brian Quinlan wrote: > > M.-A.Lemburg wrote: > > Only the most important codecs will be placed into unicodeobject.c. > > > I think that UTF-7 would be a good candidate, since it is > > a native Unicode encoding. UTF-32 would be another candidate. > > What about UTF-7, modified to be used in IMAP, as described in RFC2060 > (I could also modify it slightly for vanilla UTF-7 [RFC1642])? I ask you > directly since you are likely going to be assigned the patch :-) I wasn't aware of the fact that there are UTF-7 modifications out there... for unicodeobject.c we'd need the standard one of course; would it be possible to add the modification to the standard codec and have it use a flag to signal which one to use ? We could then use one code base and have two interfaces for it in codecs. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From teyc at bigfoot.com Sat Jun 16 19:16:52 2001 From: teyc at bigfoot.com (Chui Tey) Date: Sun, 17 Jun 2001 09:16:52 +1000 Subject: tuples and lists in XML-RPC References: <3b25d1d5@nntp.server.uni-frankfurt.de> Message-ID: <9ggp7n$6c7$1@bunyip.cc.uq.edu.au> If you know you are proxying through xmlrpc, then you can always cast the return value .. s=Server(http://..blah) result = tuple(s.getTupleResult()) I don't recall the xmlrpc spec saying you can't include something in the header..., perhaps you can include hints on type casting. It's a slippery slope. What about None, and all the unmarshallable class instances? The best approach is to limit the functions you expose via xmlrpc to the basic types provided. If a bridge says "max 1 tonne" I wouldn't drive a 2 tonner over it. > > Currently I only see the option of extending XML-RPC to differentiate > Python tuples and Python lists - and beeing no longer compatible to other > XML-RPC servers which is very bad and a therefore no-no. > > Do you see other options or workarounds ? > > Yours, > -- > :M: > -- > |--------------------------------------------------------------------------- -| > | Dipl.-Inf. Michael 'Mickey' Lauer mickey at tm.informatik.uni-frankfurt.de | > | Raum 10b - ++49 69 798 28358 Fachbereich Informatik und Biologie | > |--------------------------------------------------------------------------- -| From owen at astrono.junkwashington.emu Thu Jun 7 14:17:54 2001 From: owen at astrono.junkwashington.emu (Russell E. Owen) Date: Thu, 07 Jun 2001 11:17:54 -0700 Subject: How to get a unicode degrees symbol? References: <9fj0j6$e7m$1@nntp6.u.washington.edu> <9flnr5$bag$1@nntp6.u.washington.edu> Message-ID: <9foggj$k24$1@nntp6.u.washington.edu> >> OK, but surely there must be some simple way to do this that doesn't >> require a big case statement (if platform x then use encoding y...) >> and knowing the name of the most appropriate encoding for each >> platform? > >Indeed there is, the code > >>>> import Tkinter >>>> l=Tkinter.Label(text=u"\N{DEGREE SIGN}") >>>> l.pack() > >should work on every system (provided a Tk port and proper fonts are >available). Thank! I'll try it! The interpreter shows it as u'\xb0' and str() raises an exception, so I didn't even try it in Tk, assuming I'd get a similar mess. I would prefer an entity that would work in more instances (such as printing to the log window), but Tk is by far the most important thing. If it works, as I assume it will, I'll switch from my current messy case satetement. -- Russell From grante at visi.com Mon Jun 4 14:43:24 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 04 Jun 2001 18:43:24 GMT Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> <3B1BC755.65510E63@bt.com> Message-ID: In article <3B1BC755.65510E63 at bt.com>, Alan Gauld wrote: > >> I took a 3 day class on UML once. My impression: yet another >> "silver bullet" that doesn't work in real life. > >Like any design notation UML is there to communicate. If >the peer group is small enough the advantages are marginal. Agreed. All of the projects I've worked on have been small (1-2 people typically, 4-5 max). Resources are always scarce and when schedule and budget gets tight, maintining the system and design description always seems to be the first thing to fall off the bottom of the priority list. "Just get the fix released to production, and we'll worry about updating the documents later..." >If you are working in a distributed group of 20 or more >programmers something likev UML is near essential. Most >of my projects involve several hundreds of programmers >(250 on the current one) and there we simply couldn't >operate without UML. One of the problems I've run into consistently over the past 10 years is when management insists on using "big project" methodologies on tiny projects. Their reasoning seems to go something along the lines of: If one person can do a project like this in nine months using the "seat of the pants" method, then if we make him use Flowcharts/SASD/UML/whatever, then it should only take half as long! >> thought it was marginally useful, but like any other form of >> documentation, if it's not maintained (and it never is, AFAICT) >> it becomes worse than useless. > >It depends on the level that you work at. Architectures don't >vary that much and are useful for maintainers. But code varies >a lot so if you try to use UML for documenting code without >tool support for reverse engineering changes then I agree it >quickly becomes out of date. > >But How else do we communicate design to a new start - it takes >a long time to read a million lines of code.... UML and similar >tools cut that time down by an order of magnitude. I agree that you certainly need something for documenting large systems. The fashion in what that "something" is has varied over the years, and UML seemed as good as anything (certainly better than some). -- Grant Edwards grante Yow! -- In 1962, you could at buy a pair of SHARKSKIN visi.com SLACKS, with a "Continental Belt," for $10.99!! From dsh8290 at rit.edu Thu Jun 7 12:38:30 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 7 Jun 2001 12:38:30 -0400 Subject: WHY is python slow? In-Reply-To: ; from mitchell.morris@cingular.com on Thu, Jun 07, 2001 at 12:34:09PM +0000 References: Message-ID: <20010607123830.F14752@connecticut.cs.rit.edu> On Thu, Jun 07, 2001 at 12:34:09PM +0000, Mitchell Morris wrote: | As a single point of data, may I present the language-specific pages from ... | if-you'd-only-claimed-Jython-was-slow-ly y'rs, Check the list archives from the jython-users list. Not too long ago Finn Bock posted a message that someone sent him. The other person had a beta release of jdk1.4 and using pystong Jython came out well ahead of CPython. A hypothesis thinks that the hotspot JIT is getting better. -D From thomas.hansenNOSPAMORILLSUEYOURASS at entermatch.com Wed Jun 6 10:34:50 2001 From: thomas.hansenNOSPAMORILLSUEYOURASS at entermatch.com (Thomas Hansen) Date: Wed, 6 Jun 2001 16:34:50 +0200 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3b1cdc84.5514@bolder.com.co.za> Message-ID: <9fleid$3rp$1@oslo-nntp.eunet.no> [...snip...] I am not going to comment on all since it was very long and I don't have time... But fact is : -If you have a computer and you play games, you probably (80% or something) have bought it as a "package" from some kind of hoover-salesman... -If you buy from a hoover-salesman you WILL have windows installed default... -If you play alot of games, you're probably having a lot of spare time. -If you have alot of spare time you probably don't know much computer. -If you don't know much computer, STAY AWAY FROM *nix... I have a friend of me which has been spending 3 weeks on getting X to work on Linux since he's got a PS/2 mouse it's conflicting with some other hardware (very common in the latest core), and since he "doesn't have a mouse" he can't start X... And my friend has got a Masters Degree in Programming!!! That would NEVER happen on a preinstalled hoover delivered version of windows as long as you don't press delete on you windows/system directory, or open a mail named "I am a virus and I'll crash your BIOS, CMOS, OS, HARDDISC and nerval-system"!! From MarkH at ActiveState.com Thu Jun 14 02:16:22 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 14 Jun 2001 06:16:22 GMT Subject: Python win32all installation warning dialogs. References: Message-ID: <3B2856EE.4070109@ActiveState.com> infobot wrote: > Installing Python win32all from ActiveState > (win32all.exe, build 140 (3.5 Mb) for use with PythonLabs Python 2.1) > for Python2.1 running on Windows NT 4. Following warnings appeared > at the end of installation procedure : ... > I've never had problems with Win32all before so I figure the above > are out-of-the-ordinary. May I ask how I should register these items ? You can register them manually by executing: python win32comext\axscript\client\pyscript.py python win32com\servers\interp.py python win32com\servers\dictionary.py I suspect you will get the same errors tho. I have no idea how this could just start happening recently. My guess is that some other software updated some COM dlls. See http://starship.python.net/crew/mhammond/win32/InstallationProblems.html - but this specifically mentions Windows 98. I suggest you try and find a COM update from microsoft.com. > Thank you very much, > > chas > > ps. if it makes any difference, I used to have Python1.52 and the > respective win32all installed but uninstalled both of them before > installing Python2.1 > From rnd at onego.ru Tue Jun 26 08:23:14 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 26 Jun 2001 16:23:14 +0400 (MSD) Subject: Adding unknown variables to time.mktime() In-Reply-To: <9h9rii$n5v$1@cubacola.tninet.se> Message-ID: On Tue, 26 Jun 2001, Gustaf Liljegren wrote: > "Roman Suzi" wrote: > > > >to be able to give only the 6 first values, since I've never heard of > > >Julian days, and week day is not significant in this case. > > > try with all 9 integers. > > RTFM time module docs. > > Read before you post. I always check the library reference, but it doesn't > give any hints on what I asked for. If mktime() can't do it, maybe there's > anyother way that you could suggest? In the docs it is said what those 3 last parameters are about and how you can specify them if you do not know their values. Index Field Values 0 year (e.g. 1993) 1 month range [1,12] 2 day range [1,31] 3 hour range [0,23] 4 minute range [0,59] 5 second range [0,61]; see (1) in strftime() description 6 weekday range [0,6], Monday is 0 7 Julian day range [1,366] 8 daylight savings flag 0, 1 or -1; see below Note that unlike the C structure, the month value is a range of 1-12, not 0-11. A year value will be handled as described under ``Year 2000 (Y2K) issues'' above. A -1 argument as daylight savings flag, passed to mktime() will usually result in the correct daylight savings state to be filled in. ... mktime(tuple) This is the inverse function of localtime(). Its argument is the full 9-tuple (since the dst flag is needed; use -1 as the dst flag if it is unknown) which expresses the time in local time, not UTC. It returns a floating point number, for compatibility with time(). If the input value cannot be represented as a valid time, OverflowError is raised. time.mktime((2001,6,23, 18,0,23, -1, -1, -1)) Works just fine in absolutely most cases (except that 1 hour in the year, when time makes loops due to daytime savings ;-) and it is not possible to know DST flag for sure. At those moments system must rely on UTC time. It's very important to read manual when dealing with such delicate topic as time. Maybe you also want to use mxDateTime (not in the standard Python distribution) > Gustaf Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From aahz at panix.com Wed Jun 13 12:08:55 2001 From: aahz at panix.com (Aahz Maruch) Date: 13 Jun 2001 09:08:55 -0700 Subject: VI References: <9g7pch$7dr3g$1@ID-11957.news.dfncis.de> Message-ID: <9g836n$nga$1@panix6.panix.com> In article <9g7pch$7dr3g$1 at ID-11957.news.dfncis.de>, Emile van Sebille wrote: > >If you're not working with unix, you probably don't want to know. There's some truth to that statement, but not that much. vim works extremely well on Windoze. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Just because I'm selling you into slavery doesn't mean we can't be friends." B-movie cliche Hall of Fame (_Bounty Hunter: 2002_) From m.hadfield at niwa.cri.nz Tue Jun 5 20:51:58 2001 From: m.hadfield at niwa.cri.nz (Mark Hadfield) Date: Wed, 6 Jun 2001 00:51:58 +0000 (UTC) Subject: Python Equivalent of Matlab's size() References: Message-ID: <005501c0ee22$e4d580b0$d938a8c0@Hadfield> From: "Prem Rachakonda" > Hi, > What is the Python equivalent of Matlab's size() function. I need > to find the confirm the size of an reshaped array. Since this a Python list, not a Matlab one, perhaps you could tell us what Matlab's size function does. --- Mark Hadfield m.hadfield at niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield National Institute for Water and Atmospheric Research -- Posted from clam.niwa.cri.nz [202.36.29.1] via Mailgate.ORG Server - http://www.Mailgate.ORG From jschauma at netmeister.org Fri Jun 15 09:34:58 2001 From: jschauma at netmeister.org (Jan Schaumann) Date: Fri, 15 Jun 2001 13:34:58 -0000 Subject: Parrot-0.2.6 released References: Message-ID: * phil hunt wrote: > > I have just released Parrot version 0.2.6. http://use.perl.org/article.pl?sid=01/03/31/206248 Any connection or a coincidence? -Jan -- Jan Schaumann This Message has been modified to fit your IQ. As a result, the content might be contradictory to "known facts" and/or offend you. Sorry. From whisper at oz.nospamnet Thu Jun 14 11:10:36 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 14 Jun 2001 15:10:36 GMT Subject: Python grammar.. References: <3B28458C.F171FDB0@my.signature> <9ga2bu02i71@enews1.newsguy.com> Message-ID: <9gak5c$8ft$4@216.39.170.247> In article <9ga2bu02i71 at enews1.newsguy.com>, aleaxit at yahoo.com says... > Maybe this is the reason behind the incompatible change > in the move VB.6 -> VB.NET (one of many): all calls to > function and subroutines *DO* now require parentheses -- > the parentheses in the call are not optional any more. > > > total dog's breakfast from a language point of view. > > It looks like VB.NET is marginally better (since all of > the incompatible changes move it closer to Python: it > now has a return statement, which can take a value -- > mandatory parentheses on calls, as I mentioned -- no > more "default value" on objects -- no more distinction > between LET and SET assignments -- etc, etc). > > > Alex Moving a bit off to the side, I wonder if VB's "simplification" could be due to the fact that in the VBScript vs. Javascript arena, VBScript is the hands down loser - something like 80% of _all_ server scripting is done with javascript even on IIS. While I never liked or thought much of BASIC ("Fortran with a thyroid condition"), Gates has managed to raise it to the status of loathsome. Of course, in all language usage surveys since about 1960, BASIC has been the most used language of all by wide margins... I'd rather be condemned to using Perl! Dave LeBlanc From gs at styrax.com Fri Jun 22 11:27:04 2001 From: gs at styrax.com (Garry Steedman) Date: Fri, 22 Jun 2001 15:27:04 +0000 Subject: Jython for Servlets In-Reply-To: <3B3227DC.B3D2DD5D@destiny.com> Message-ID: <3B3363C8.6732.4D7C2E7@localhost> Michael, you will find an example at: http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/54158 cheers, Garry On 21 Jun 2001, at 11:59, Michael Chermside wrote: From: Michael Chermside To: python-list at python.org Subject: Jython for Servlets Date sent: Thu, 21 Jun 2001 11:59:08 -0500 > I would like to use Jython to write servlets in python and run them on > a java application server (WebLogic or one if its ilk). Seem like this > should be pretty easy to do... does anyone have a "hello world" > example I can work from? > > -- Michael Chermside > > > > -- > http://mail.python.org/mailman/listinfo/python-list +-------------------------------------------+ Garry Steedman mailto:gs at styrax.com Styrax Associates http://www.styrax.com/ "The Good Man has no shape." +-------------------------------------------+ From duncan at NOSPAMrcp.co.uk Fri Jun 8 09:16:27 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Fri, 8 Jun 2001 13:16:27 +0000 (UTC) Subject: integers References: Message-ID: piet at cs.uu.nl wrote in news:u1yowtnoi.fsf at cs.uu.nl: >>>>>> "Bjorn Pettersen" (BP) writes: > > BP> And introducing them now would change the meaning of: > > BP> x--1 > > It wouldn't because there is only one way to parse this, but it would > make the parser more difficult. It would, however, change the meaning of: x---1 -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From shredwheat at mediaone.net Wed Jun 27 12:36:16 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Wed, 27 Jun 2001 16:36:16 GMT Subject: Python for Commercial Games? References: <9haoiv$jnv$1@mtc1.mtcnet.net> Message-ID: <4Yn_6.18$79.51844@typhoon.we.rr.com> "Kevin Riggle" wrote > I *do* realize that I'm posting to comp.lang.python , so please humor me > anyway... > > I am in process of designing a computer game; problem is, I want to at > least have a snowball's chance in Hades of selling the game. My question: > Would it be possible to write the dang thing in Python (PyWin), or is C/C++ > the better option in the Windows-centric world of game development right > now? Thanks in advance, hello kevin. i think it would be a smart idea to have your game objects be done in python code. at some point, you'll likely need some sort of C extension to do some of the cpu-intensive stuff. how much C code depends on how complex the display and interactions will be. two libraries of interest to you will be Pygame and PyOpenGL. Pygame provides a great way to do 2D graphics, as well as handle sound and input. PyOpenGL is obviously a python wrapper for opengl. Both are fast enough to do a complete game without needing extra C extensions. if you want to do more of a first-person shooter with all the goodies, you'll need a much bigger chunk of C code. stuff like managing the BSP trees, collision detection, raycasting and all that jazz will be much more suited to C. Think of something like Quake3 or UnrealTounament, where the game "engine" is written in C, but the actual game is run from a bytecompiled scripting language. take a look at my solarwolf game. http://shredwheat.zopesite.com/solarwolf it should give you a decent idea of what is possible and what type of code it involves. all the source is available for the game, so take a peek under the hood. writing games is actually a lot trickier than you'd think. if you are planning your first game project, i can't stress enough that you should start with something basic. (don't bother going commercial on your first run) :] trust me on that, just do something simple and fun. by the time you finish it up (actually long before that) you'll realize that there's a lot more to manage than what you first think. you get to the point where you say "well i designed this completely wrong". but with a simple game you can just rough it out and finish things. with a bigger game you end up getting bogged in bad design and are forced to rewrite most of it. From nickatvideosystemdotcodotuk Fri Jun 29 12:05:11 2001 From: nickatvideosystemdotcodotuk (Nick Trout) Date: Fri, 29 Jun 2001 17:05:11 +0100 Subject: Python VC++ integration / COM question References: <3b3ca1e3@news.xtml.co.uk> Message-ID: <3b3ca73f@news.xtml.co.uk> Wahay! Got it working :-) I just couldnt find anywhere that "MSDev.Application" is your application object. > Any help/pointers very gratefully received. Does anyone know of a project that does this kind of thing already? ie. Python scripting in VisC using an Addin? N From george at cc.gatech.edu Wed Jun 27 18:05:21 2001 From: george at cc.gatech.edu (George Thomas) Date: Wed, 27 Jun 2001 18:05:21 -0400 Subject: list of dictionaries References: <3B3A4B97.5F4EB1F1@cc.gatech.edu> <9hdjmt$dk0ki$1@ID-11957.news.dfncis.de> Message-ID: <3B3A58A1.AE09529@cc.gatech.edu> Hi, I wanted to avoid the creation of a new dict per entry. What I haven't been able to understand is why the "updated" dict is not appended. ------------- Emile van Sebille wrote: > > Note changes below > > -- > > Emile van Sebille > emile at fenx.com > > #This creates a single dict that gets appended each time > #by creating a new dict for each entry as per below > #you don't really need this anymore. > regards ------------------------------------------------------------ George Thomas ------------------------------------------------------------ reduce (lambda c,d:chr(ord(d)-2)+c, 'ofcpqkekhhC"zwpkN"fgtgyqR/pqjv{R') ------------------------------------------------------------ From topmind at technologist.com Fri Jun 1 18:37:28 2001 From: topmind at technologist.com (Topmind) Date: Fri, 01 Jun 2001 22:37:28 GMT Subject: New language References: <9dse3h$7s5$1@wanadoo.fr> <9er0s9$9i2$2@newshost.accu.uu.nl> <9err9a$aq0$1@newshost.accu.uu.nl> <9f10ta$eua$1@newshost.accu.uu.nl> <9f7fep$hb8$1@newshost.accu.uu.nl> Message-ID: > In comp.object Topmind wrote: > [snip] > >> >> Another good example is for > >> >> instance x, y coordinates you want to pass around, without going to the > >> >> trouble of dealing with anything more complicated. > >> > >> > What keeps a dictionary from satisfying this role? > >> > >> They're too heavy, again. :) > > > Please clarify "heavy". > > I think I did elsewhere. Too heavy in syntax, The difference is minor between arrays and tables for a well-tuned table API. I will usually take the slightly-more up-front syntax in order to get longer-term adaptability any day. I already gave an example of where I was burned by dictionaries about 5 or so messages ago. > ..... > However, as I said before, it's mostly a syntax issue to me > [not just speed]. There is > a case to be made for a kind of tuple-like dictionary, though the > advantages of that are minimal in my opinion; for anything more complex > I'd be inclined to use a full-fledged object anyway. But an object does not give you a full-fledge collection still. I can view a table while the program is running, for example. All an object gives you above a basic array is more columns. http://www.geocities.com/tablizer/collrght.htm > > [snip] > >> > I think that was my case, more or less. Touples, dictionaries, and > >> > classes have too much *overlap* in Python. It just seems to me that > >> > they could have factored the 3 into *one* thing. It keeps the > >> > language cleaner and the learning curve shorter that way. > >> > >> I disagree; I think a distinction like this can help sometimes. Look at > >> Perl and their scalars, which merges things like integers, floats and > >> strings into 'one thing'. > > > I like that approach. It makes the code leaner and cleaner IMO. > > Less casting, converting, and declaration clutter. It allows > > you to look at raw business logic instead of diddling with > > conversions, casting, and bloated declarations. > > You're confusing things here; you're confusing the effect of static > type checking (declarations and casting) with that of having different > datatypes. In Python, you don't need to declare or cast integers, only > convert when necessary. You need to convert an integer to a string if you > want to use integers in a string, for instance. > > Because of this, the program stops when you do something silly, instead of > going on blindly and making a mishmash of your data. > I prefer that the "conversion" be done when comparing. IOW, having an API that says "compare as numbers" or "compare as strings". In my pet language, a comparison might look like: if x %cta> y ..... end if The "c" means compare as character and the t means trim and the "a" means compare case-sensative. Most languages require one to do this: if trim(uppercase(toString(x))) > trim(uppercase(y)) then ..... I factor these operations into the middle. > This is *not* the same argument as that for static type checking however; > it is important to see the distinction. It's an argument for a light-weight > dynamically checked type (or interface/protocol) system. > > What you seem to be describing as the benefits of the Perl scalar may > instead be the benefits of the absence of statically checked types. > Perhaps. I still have not got the hang of Python's typing system approach yet. I don't like types anymore. Types create "hard to disect binary blobs" in my view. I have grown toward the Unix philosophy of "every interface between systems should be ASCII" (Or UNICODE, perhaps) if possible. I now apply this at a smaller level than just "between systems and applications". (Accept I evolved it up to tables also. The ultimate xfer protocol: text and tables.) > ..... > > A jillion messages > > are already devoted to that topic, with no "killer proof" > > on either side. It may be subjective which is the "best". > > I grew up on strong typing, but have gravitated toward > > prefering dynamic typing over the years. > > Me too. > I should change that to "type-free". I grew up on strong and explicit typing, but have completely reversed and wish my language of use was completely type free. My pet language has only one type: a dictionary array. It is used for *everything* including scalers. scalers are simply a shortcut for something like: x = 5 x.__value__ = 5 // same (It does not use underscores, but something equivalent.) Well, I should say everything except for internal structures. It is not like Python that way. I see no real need for that. I would probably use tables to pull off what others would use the Python meta language tools for. My pet language in many ways is similar to Python, but much more minimalist WRT types and collections. Python has too many syntax variation IMO. > >> It's funny you should compare tuples with dictionaries and say they > >> should be conflated; most people complaining about tuples say they're > >> too much like *lists* (arrays). They're right that they're very much > >> like lists, > > > That too. Roll 'em all up. Requirements change. I hate recoding > > from lists to touples to dictionaries to tables, etc. > > Make the interfaces the *same*, and only swap the engine, NOT > > the interface. > > Oh, I'd say make the interfaces different, use the same engine where > possible. Why make the interface different? Then you have to overhaul everything if your collection needs change. (A Meyerian Continuity sin.) It is not just "minimalism", but anti-sub-typing also. > I changed my mind a little about dictionaries; in practice > they're often used to store lots of homogenous values, not as a kind > of datatype (in Python, class instances (objects) are used for that). > > I think it's a myth that having a universal rolled-into-one collection > type helps your program deal with change more easily. Well, I am pushing that "myth" and have no reason to back down. > In my Python > programs, I use lists and tuples and dictionaries and tables in > rather different places in different idioms. But do they STAY different? I find that collections often need more than what they started out needing. IS-A collections cannot hop IS-A fences very well. Perhaps an example would help. > While it is possible I > change one into the other on occasion, this is the exception, not the rule. For what I do, rule. At least frequent enuf to want to prevent it up front. > When such changes do happen so many other changes tend to happen it > doesn't really matter anymore anyway; the change in collection type is > probably caused by such a larger change. > I disagree. It might simply be another view of the *same* data, another new column, etc. One thing about custom business programming is that many different parts often need the same data, but with a different view, lookup, join, sort, etc. IOW, you never know what or who will need data from your collection(s). > With a universal collection type you lose some of the benefit of these > separate idioms (which can help with the readability of the program). I disagree about readability. When collection needs change, trying to force a linked list or dictionary into something else makes for a much larger readibility problem. Like I said, array syntax may give you a SLIGHT benefit up front, but the loss down it road more than makes up for this. > You > also may increase errors, as due to the absence of different interfaces > and idioms you run a higher risk the program will continue after an error > and mangle your data in unpredictable and hard to track down ways. > I would have to see some examples of this. The "protection" needs often don't align along the collection type's boundaries or features. Not allowing dictionaries to be sorted (in place) is an *arbitrary* limit in my book. > Anyway, as I said before, you're in the minimalist camp here, along with > Smalltalkers (everything's an object with messages) and Lispers (everything's > a list). WRT to collections, yes, but not control structures (IF, loops, etc.) > I take the position that syntactic sugar can help with idioms, > which can help with clarity, readability and error detection. > Well, we will just have to agree to disagree. I have used both approaches, and don't like collection type proliferation the least bit. > >> except that they're immutable (like integers and strings > >> in Python, but unlike lists and dictionaries and instances). Your > >> desire to conflate them with dictionaries is in my opinion wrong as well, > >> but you're more right than those who want to merge them with lists; > > > Show me "wrong". > > Wrong as in "I think there are arguments against this which you are missing > and I disagree with your evaluation of the tradeoffs". This is a > subjective issue. I imagine you can do empirical research about programming > language effectiveness and these issues, but I'm not going to do it. > Are you? Nope. I won't challenge any agreement that it is subjective. I should be happy enough that you agree it is likely subjective. This is a lot more than I often get out of the pro-OO camp. I just wish the industry would realize this and knock it off with the one-paradigm/language-fits all scenario, such as the Java-tization of everything. > If not, you'll have to accept that my efforts in trying to show > you 'wrong' are as valid as your efforts to show me wrong and yourself right, > here. The alternative is saying you're doing no such thing, in which > case I wonder what we're doing. :) > > >> tuples are generally used as 'records' (heterogenous objects) and not > >> as lists of homogenous objects. > > > Doesn't matter. Needs change. See above. Homo today, hetero tomorrow. > > Micheal Jackson Collections, you could say. > > Heterogenous collections are not going to change into homogenous collection > and vice versa in by far the most circumstances. If you disagree, you > should name some cases; I can't think of any. > You would have to leave an actual example because "heterogenous" may depend on how one classifies the world in their head. > By 'homogenous collection' I mean a collection of 'like' objects > (English words, files, animals, records with address data, etc). > By 'heterogenous collection' I mean a collection of significantly > different objects ("an integer, a string and a list", "a first name, > a middle name and a last name", "a word and the frequency of its > occurance in a text", "an x coordinate and an y coordinate"). > > >> Anyway, you're in the LISP and Smalltalk camp here; do a lot with just > >> a few syntactic (surface semantic) concepts. > > > As far as collections, yes you can say that. (Although Smalltalk's > > collection API's are still too taxonomy-happy for my tastes.) > > >> A language like Python > >> adds more syntactic sugar, and my theory is that this syntactic > >> sugar *helps* programmers write and read programs. > > > Perhaps it depends on the programmer. Also, there is maintainability. > > Having dedicated syntax for certain (false) categorizations of > > collections may make *some* code easier to read, but still makes > > it harder to change when collection needs grow, morph, or change. > > Yes, there are definitely tradeoffs there and I recognize those > tradeoffs. I think the tradeoffs for collections weigh into a different > direction, however. That's not to say I want a huge forest of collections > that you can see in some statically typed languages, where they have > arrays for integers, arrays for strings, arrays for floats, and so on > ad infinitum. While arrays are usually for homogenous collections I think > the strict specification and checking of such can bog down the programmer > too much. It's also fine with me if collections share an underlying > implementation in some cases, if this is easier or more efficient. > But for me, the balance of the tradeoffs still leans towards more > collection interfaces than just a single one. > It would be interesting to see some of your designs. > Anyway, is that the only response you had to my example? I showed you how > Python was already doing more or less what you said it should be doing. > An 'oh, cool' or 'huh?' or 'that's not what I mean' would've been worth > my troubles. > I guess I would have to see it applied. I might do it another way than you. > > [snip] > >> >> > Besides, what is wrong > >> >> > with regular by-reference parameters? > >> >> > >> >> Nothing at all, except that returning multiple values is far more clear > >> >> by just about any measure you can come up with. :) > >> > >> > Which would be? > >> > >> > I suppose you could argue that under the old approach > >> > one could not tell what was being changed and what was > >> > not by looking at the caller. However, you might have to check > >> > the bottom or middle instead of the top of a routine to > >> > figure out the result parameter interface in Python. > >> > >> Usually the bottom, yes, unless you document it at the top in > >> a docstring. Looking for 'return' statements isn't terribly > >> difficult, either. > > > But harder than looking at the top. > > Yes, but the problem already exists in any dynamically typed language > where any kind of heterogenous collection can be returned, and you said > you prefer dynamic typing. It doesn't add to the problem therefore; > it's just as hard if you're returning a record or dictionary. The > advantage of tuples is that they can be instantly unpacked after the > function call. > Another point where a specific example might be helpful. You argument has "when X happens..." arguments in them, and the way I code/design, X may not happen very often. > >> > IOW, it might trade caller readability for callee > >> > readability. At the most it is a wash IMO. > >> > >> I disagree; caller readability is not significantly effected and > >> callee readability (in multiple places) is improved. A clear win, > >> therefore. > > > I am not sure how you are doing your math here. I figure one > > always has to go [to] the function definition and parameter > > list *anyhow* to understand the function's interface. > > Thus, having it defined in the heading is a one-stop deal. > > Without declarations, that's just a name in an argument, and the > 'changeable reference' indicator. It's true that is a bit more > explicit. > I am not sure what your point is here. > > Having to also check return statements is a two-stop deal. > > (I don't end up looking at return statements very often.) > > The other deal is that I don't have to go look up the function definition > each time I see a function call I don't know about, just in case this may > involve reference parameters! That's a huge deal in my opinion. :) > I guess the naming conventions I use for routines is the primary indicator as to whether it is mostly changing or using info. I tend to use prefixes like "put" or "change" or "move" to indicate that a lot of changing is going on. > >> > Having the entire interface defined at the top is > >> > a good thing IMO. (Although "return" is rarely > >> > at the top, but it is a single item if it > >> > exists.) > >> > >> A single item of any kind of complexity, anyway, and a serious tradeoff > >> in readability for the callee as there are now two different ways you can > >> return values, one of which (reference parameters) is a hack. > > > Define "hack". > > Mathematical functions, which inspired functions in programming languages, > don't have 'reference parameters'. They just have inputs. It can therefore > be presumed originally computer language functions didn't have them > either, and someone added them to languages in an early hack in order to support > multiple output values. The hack makes sense if your language is statically > typed, as you can then define the types of all the output values in the > same way as you already defined the types of the input values. You don't have > to think about extra syntax. It doesn't make a lot of sense in a > dynamically typed language, though. > To say that "math didn't do it" is misleading IMO. What is good for math may not be good for programming. > (and of course in Python you can mutate mutable objects passed to a function and > *any* variable in Python is a reference. But it's better style to avoid > mutating input if possible, in my opinion. It encourages more independent > functions which makes for easier to maintain and debug code). > Yip. Complex things passed in are alterable anyhow. For example, it makes more sense to change a large array *in place* rather than make a copy and pass it back out. Thus, you have *two* param changing conventions floating around in Python. > > [snip] > >> > Because I am not convinced it is significantly better. As a rule of > >> > thumb, I say something has to be at least 15 to 30 percent better to > >> > deviate from tradition. Perhaps if I saw more actual uses for > >> > it besides foo-bar examples, but I have not. > >> > >> '15 to 30 percent better': failure to grok error. > > > Perhaps you grok differently than me. > > >> If you mean the amount > >> of typing, I can see it's far more than 30 percent better. But you > >> probably don't mean that, and it's fairly meaningless beyond that. > > So, how *do* you arrive at these 15 to 30 percent better figures? > It implies somekind of objectively measured thing, did you? > Probably. What is "better" is often highly subjective, often because our different habits and design philosophies use different features at different frequencies, etc. > >> > Most "data structures" I deal with are more than 2 positions. > >> > Thus, I use tables, and perhaps a dictionary-like thing to > >> > interface to such records. (I prefer to use tables to store > >> > data instead of dictionaries themselves, other than an interface > >> > mechanism to specific records.) Perhaps some niches have lots of > >> > "skinney collections" where touples may help, but not mine. > >> > >> Well, I tried to describe such a niche; returning multiple things from > >> a function. Another niche is indeed the very light weight record > >> niche; x, y coordinates for instance. Yet another niche, harder to > >> describe is the 'make a new immutable object from other immutable > >> objects' niche. > > > I meant industry domains, like business versus embedded systems versus > > scientific computing, etc. I don't do a lot of X, Y coordinate work, BTW. > > European example for the industry domain is a 'year/weeknumber' tuple. > In Europe industry often works with (ISO) weeknumbers. To calculate > weeknumers back to a date (beginning of the week), you need the year as well, > so it can make sense to pass these around as pairs in ones application. > I prefer to pass dates around as single strings. Formatting it for different countries is a formatting (output) issue and not an internal issue. IOW, the internal representation and the external do not have to be the same. > [swapping two values with tuples] > >> But it *is* obvious what is going on as you already understand both > >> tuple unpacking and tuple construction. > > > But it is just Yet Another Silly Trick To Understand. > > It's not a 'silly trick' like many Perl 'silly tricks' where the trick > is merely in syntax and not the *consequence* of an orthogonal syntax. > If your syntax is orthogonal you can reason about it, so it's not > a silly trick you need to remember in isolation. That's a very different > thing when you're learning a language. > I guess I don't see a significant net value of touples. They just complicate the syntax and are often used for stuff that can be done other ways. > >> We're just doing both in a > >> single line. There's nothing special case about this. It's not *hard* > >> to understand tuple construction and unpacking. You're clinging to > >> your traditions here just for argument's sake. :) > > > Nope! I am weighing utility versus complexity, and it flunks > > in my book. Save the syntax complexity for the *common* > > stuff. > > I tried to show you how this *is* common stuff. Not swapping variables, > but collecting a bunch of things together and passing them around as > a whole, and returning them as a whole, and easily separating them into > pieces again. It happens frequently in software. > Not in a way that makes much use in touples. Perhaps you use touples the way that I use relational tables, and that is why my approach has less use for them. > When the amount of heterogenous objects you're packing together into > a bundle is large or the situation is complicated (need to do many > operations on them), it makes sense to use a record or a class. > > In many circumstances it is however not a complicated bunch and it's > easier not to use such a thing and use the syntactically and semantically > minimal tuple instead. > Well, I would have to see more examples than your date example, which I disagreed with. > Yes, a small record can grow into a large one, and you will have to adapt > some code when it does (in a dynamically typed language, not a lot). > There are many cases when this just doesn't happen, though; x, y coordinates > are an example, so are year/weeknumbers, or 'year/month/day' pairs, or > 'amount/currency_type' pairs, and so on. > Well, I don't use much X and Y coordinates, and would probably use tables if I did, since such an app probably has lots of them. Often in table-land you pass around a record ID or record reference instead of the record contents. Such a record reference is similar in concept to a touple of X and Y. > > >> > Don't get me wrong, there are languages a lot worse than Python, > >> > but the poor consolidation of the similar things I mentioned > >> > kind of bug me. > >> > >> I see these syntactic issues in a somewhat different philosophil light, > >> something which I tried to describe above. While I'm all in favor of > >> semantic minimalism, I'm not a syntactic minimalist. If you're a > >> syntactic minimalist these subtle differences make no sense, indeed. > >> > >> Anyway, if I were designing a new language I would indeed attempt to > >> bring dictionaries and tuples closer together, so we're in agreement > >> in that sense as well. I'm just defending the special syntax for tuples, though > >> I also wonder about performance (but we'd just have to profile it) if > >> all tuples were dictionaries. > > > Performance often only becomes an issue when stupid programmers play with > > too many features. Thus, reduce the syntax features and you have less > > playing around with wasteful things and cryptic tricks. > > The tradeoff here is that one thing often doesn't fit all. But most :-) That is the prestine beauty of tables. They flex like nothing else I have ever seen in programming. I am trying to spread the Table Godspel. Mabye we will get our own common language and widely used buzzwords just like everybody else. -T- From kamikaze at kuoi.asui.uidaho.edu Tue Jun 19 17:33:18 2001 From: kamikaze at kuoi.asui.uidaho.edu (Mark 'Kamikaze' Hughes) Date: 19 Jun 2001 21:33:18 GMT Subject: [Python-Dev] Feedback on new floating point info in tutorial References: <#PLCPMv8AHA.291@cpmsnbbsa07> Message-ID: 12 Jun 2001 10:39:29 -0500 in , Skip Montanaro spake: > Steve> Tim Peters wrote: > >> god-created-the-integers-from-1-through-3-inclusive-and-that's-it-ly > >> y'rs - tim > Steve> I thought "many" came after two ... > Only for rabbits... No, no. One, two, three, four, "five" (meaning anything more than four). Of course, Real Programmers know that there are only two numbers: 0 and 1. VLSI designers know them as "high electrical state" and "low electrical state", but let's not go there. -- Mark Hughes "I will tell you things that will make you laugh and uncomfortable and really fucking angry and that no one else is telling you. What I won't do is bullshit you. I'm here for the same thing you are. The Truth." -Transmetropolitan #39 From rnd at onego.ru Sun Jun 24 13:12:02 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 24 Jun 2001 21:12:02 +0400 (MSD) Subject: shelve ( or bsddb ) problem In-Reply-To: <9h53ss$3799s$1@sky.inp.nsk.su> Message-ID: On 24 Jun 2001, Alex A. Nikiforov wrote: > >That is priogram: > >$ cat b.py >import bsddb >import shelve > >s = shelve.BsdDbShelf(bsddb.hashopen('qqqqa','c')) >s['a'] = [3,2,1] >print s['a'] >s['a'] = [1,2,3] >print s['a'] >s['a'] = range(1000) >print s['a'][500] >s['a'] = [1,2,3] >print s['a'] > >That is result: > >$ python b.py >[3, 2, 1] >[1, 2, 3] >500 >Traceback (innermost last): > File "b.py", line 12, in ? > print s['a'] > File "/usr/lib/python1.5/shelve.py", line 64, in __getitem__ > f = StringIO(self.dict[key]) >KeyError: a >$ > >? ? ? ? ? > >python-1.5.2-30 from RedHat > >(python-1.5.2-27 has the same problem too) $ rpm -q python python-1.5.2-13 - No problem here: [3, 2, 1] [1, 2, 3] 500 [1, 2, 3] Run: rpm -Vf /usr/lib/python1.5/shelve.py to check Python installation. >Alexei Nikiforov > Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, June 24, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Ok, I pulled the pin. Now what? Where are you going?" _/ From danielk at aracnet.com Sun Jun 10 11:22:51 2001 From: danielk at aracnet.com (Daniel Klein) Date: Sun, 10 Jun 2001 08:22:51 -0700 Subject: Learning OOP... References: Message-ID: On 6 Jun 2001 10:42:48 -0700, rod_weston at yahoo.com (Rod Weston) wrote: >Trying to decide which language to learn first. I have programming >experience in PICKBASIC and now want to learn OOP.At this point, I am >leaning toward learning Ada and then Python. Any ideas on why I >should or should not use these languages in this sequence? If you are looking to hold on to your existing familiarity with the best database in the world :-) and still want to use Python, I have written a program in Python that connects to a 'pick' (actually it's jBASE http://www.jbase.com) database. The Python client code consists of 9 classes that represent all of the necessary entities. The Python client 'connects' to the database via pipes; it fires up a jBASE process (a native executable) that interperates the Python requests (like 'open', 'read', 'write', 'execute', 'call', etc, etc...). You can find free source code and installation instructions and sample code at http://www.jbase.com/knowledgebase/howto/Python/Jukebox.htm There is no 'formal' documentation other than what is supplied in the doc strings in the Python code. You can download a free developer's version of jBASE for Windows (1-user license) or Linux (3-user license) at http://www.jbase.com/products/jbase_download.html. HTH, but if not, it was certainly fun for me to write it! Daniel Klein From aleaxit at yahoo.com Mon Jun 18 11:45:49 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 18 Jun 2001 17:45:49 +0200 Subject: getting a reference to a class inside its definition References: <9noX6.14930$uR5.1138042@news20.bellglobal.com> Message-ID: <9gl7nd088i@enews2.newsguy.com> "dan" wrote in message news:9noX6.14930$uR5.1138042 at news20.bellglobal.com... ... > Still, I want to be able to reference a class inside it's own definition. The class object does not *EXIST* until its classbody has *FINISHED* executing, I believe. That makes it rather hard to reference it. You can reference the *dictionary* that will become the namespace for the class's object -- it's what locals() returns in class-body scope. > Is this possible or am I going to have to do > > class SomeClass: > pass > SomeClass.clsref = SomeClass > > because that's what I'm doing now... I think this is the correct way (well it DOES create a reference-cycle of course, which may well make for some garbage-collection work, but I guess you know that). Alex From skip at pobox.com Fri Jun 1 11:46:28 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 1 Jun 2001 10:46:28 -0500 Subject: 2.1 strangness In-Reply-To: References: <9f5s61$t89$1@slb5.atl.mindspring.net> Message-ID: <15127.47316.194434.987634@beluga.mojam.com> Remco> On the other hand, it's irritating that things that used to be Remco> imported with a 'from import *' aren't anymore. The old mechanism Remco> was that names that shouldn't be imported had prefix _; there are Remco> a few of those in httplib. Why does it suddenly have an __all__ Remco> that contains only HTTP? There are plenty of modules that don't adhere to the "'_' makes it private" convention. Before __all__ appeared, they would pollute the namespace of whoever imported them using "from ... *". In priciple, __all__ is an okay mechanism to avoid this problem, but in practice it's difficult to get right, particularly because it must be maintained manually. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From loewis at informatik.hu-berlin.de Sat Jun 16 14:04:46 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 16 Jun 2001 20:04:46 +0200 Subject: Python, Unicode, l8n and i18n References: <9gajd9$8ft$3@216.39.170.247> Message-ID: David LeBlanc writes: > I'd like to propose (or at least enquire when/if) Unicode become the > default character encoding for Python. By this, I mean that an otherwise > unadorned string is implicitly Unicode, not ascii as I believe it is now. Python currently offers the -U option, which makes all strings Unicode strings. It turns out doing so has many problems, and I doubt ICU has anything to offer to reduce these problems. BTW, the "normal" Python strings are byte strings, not ASCII strings. I.e. whatever byte sequence is in the .py file will end up in the string. Regards, Martin From pedroni at inf.ethz.ch Thu Jun 21 08:58:39 2001 From: pedroni at inf.ethz.ch (Samuele Pedroni) Date: Thu, 21 Jun 2001 14:58:39 +0200 Subject: String --> int References: <9gsl08$gsl$1@wanadoo.fr> Message-ID: <3B31EF7F.2BFB3072@inf.ethz.ch> Romain Guy wrote: > Assuming fsock is a File objet, when I do: > var = fsock.read(4) > I get a String. I'd like to convert it into an integer. I haven't found any > method for this so I built this one: > > def _buildInteger(bytes): > if len(bytes) != 4: > return -1 > else: > return ord(bytes[0]) | ord(bytes[1]) << 8 | ord(bytes[2]) << 16 | > ord(bytes[3]) << 24 > > It works perfectly but I'd like to use one internal to Python if possible... > > -- > Romain "Java Swinguer !" Guy > romain.guy at jext.org > www.jext.org > > "Now, don't you worry. The saucers are up there. The graveyard is out there. > But I'll be locked up safely in there." > - Paula Trent, Plan 9 From Outer Space struct.unpack should do what you are looking for. http://www.python.org/doc/current/lib/module-struct.html regards. From chris at dc.zdev.org Wed Jun 20 16:05:04 2001 From: chris at dc.zdev.org (Chris Abraham) Date: Wed, 20 Jun 2001 16:05:04 -0400 Subject: Washington, DC, Zope Python User Group Meeting Tonight! Message-ID: Python Gurus on the Metro Washington Area: First of all, here's where we need to be: This first meeting takes place at the National Institute of Health campus in Bethesda, Maryland, in the Lippsett auditorium located in the main hospital building (Bldg. 10). This is the time line: Our meetings normally start at 7 pm, with loose banter and issues of the day; by 7:20 we are ready to go into the talks. We normally take 1-1.5hr for the talk, and allow questions from the audience, or not, at speaker's discretion. This is the web site you can refer to: http://www.zpug.org And further directions are here: http://www.nih.gov/about/index.html#visitor Who, What, When, Where, Why, How: Our presenters will be the gang from Digital Creations. This charter meeting will be straight from the horse's mouth and will be a valuable opportunity for both Zope and Python lovers to dote as well as turning on a load of Linux Users to the unique powers, strengths, and flexibility of Zope and Python. We have Guido Van Rossum, Jim Fulton, and Ken Manheimer at least! Cheers, Chris -- Chris Abraham +1 202 452 7442 vm [MemeSpace:VirtualCommunity:ConsiderYourselfInfected!] From bs1535 at sbc.com Wed Jun 13 16:29:42 2001 From: bs1535 at sbc.com (SNYDER, BARRON F. (AIT)) Date: Wed, 13 Jun 2001 16:29:42 -0400 Subject: [wxPython] Help with wxChoice! Message-ID: <35BD410BA148D411A7ED00508BCFFBDA05CB29D5@msgil65170u05.nbk2305.il.ameritech.com> wxPython version 2.2.5 Python version 2.0 I tried your suggestion of using FindString and it appears as though the string is appended because FindString finds it. I then thought about what you said about that if that works, then some other overriding processing may happen down the line... Mystery solved! It turns out that wxDesigner puts a default entry called "ChoiceItem" in the widget so that the user can see that it is working. Apparently this replaces any items that had been appended in the __init__ method. Once I deleted the default entry from the properties screen in wxDesigner my code worked fine. Thank you very much for your help and suggestions and that "little bit extra" to get my brain thinking in a new direction! Barron -----Original Message----- From: David Bolen [mailto:db3l at fitlinxx.com] Sent: Wednesday, June 13, 2001 2:31 PM To: python-list at python.org Subject: Re: [wxPython] Help with wxChoice! "SNYDER, BARRON F. (AIT)" writes: > But since you ask , I'm actually trying to append to a wxChoice control > that was laid out using wxDesigner. Since the widget code is automatically > generated from wxDesigner, I have to get the handle of the specific widget I > want by using wxPyTypeCast. Hmm, I just tried that as well (not with wxDesigner, but using FindWindowById on my own created wxChoice window) and it's working for me, so at first glance I would think that the code you're using ought to work. You didn't mention which wxPython release you're using - I suppose it could be a bug somewhere. Or could there be anything in the auto-generated code by wxDesigner that is perhaps clearly out the choice box at some point in time after you add the information? You might adding some debugging print's or something just after you append to the choice, using something like the FindString or GetString methods to try to determine if the choice thinks the new information has been added at that point in time. If so, then it would be an indication that something later on during processing (which could still be before the control is actually displayed to the screen) is removing information. You might also try directing this to the wxPython mailing list (wxpython-users at lists.wxwindows.org) and see if anyone there has any other suggestions. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ -- From glen at enabledventures.com Fri Jun 15 15:32:49 2001 From: glen at enabledventures.com (Glen Starchman) Date: Fri, 15 Jun 2001 12:32:49 -0700 Subject: Inner classes References: <3b27a1aa.6747983@news.laplaza.org> <3B2A34EE.FEF14DBC@enabledventures.com> <3B2A5B01.1B60057A@inf.ethz.ch> Message-ID: <3B2A62E1.E65A51FC@enabledventures.com> Samuele Pedroni wrote: > > I hope you know that you can do the following in jython: > > class StupidExample: > > def butAAction(self,e): > .... > > def butBAction(sel,e): > ... > > def __init__(self): > self.butA = JButton("A",actionPerformed=self.butAAction); > self.butB = JButton("B",actionPerformed=self.butBAction); > > or even lambdas instead of bounded methods if your code is short enough Sure. But I specifically did not show that because I see using the actionPerformed= to be: 1) a dirty, dirty hack 2) counter-intuitive since the JButton in Java does not have a constructor that takes a method (obviously) 3) I *try* to keep my Jython code as Java-like (without filthy inner classes) as possible, so if, god forbid, I need to recode in Java it is an easier process. > > Samuele Pedroni. *2 From tim.one at home.com Mon Jun 25 04:06:54 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 25 Jun 2001 04:06:54 -0400 Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: [Greg Copeland] > So what happens when you have two threads calling a generator. I > guess they are distinct... That depends on whether you created a distinct generator for each thread, or shared a common one. If Threads A and B both do for x in g(): yadda(x) it may or may not be thread-safe, depending on how g was implemented; if it sticks to using local vrbls, it probably will be; if it mucks around mutating globals without benefit of synchronization constructs, probably not. If thread A alone instead does: iter = g() and iter is visible to both A and B, and then they both do while 1: x = iter.next() yadda(x) then they're sharing a single iterator object, and an exception is the most likely outcome: while an instance of a generator-function is running, it's a detected error to try to invoke it again before it yields (hmm! I should add that to the PEP). If the threads manage to avoid that, they'll see disjoint subsequences of g()'s full sequence (which may well be a *feature* if synchronized properly: "thread safe" is relative to what an app is trying to accomplish, it's not an absolute thing). If you stick to the for-loop spelling, it's easy to write thread-safe generators. For example, the tree-traversal generators in the PEP can be used simultaneously by multiple for-loops in multiple threads without problems. Despite persistent rumors to the contrary , generators *are* functions, and each invocation gets its own local variables and local instruction pointer and local stack space etc. From philh at comuno.freeserve.co.uk Wed Jun 20 14:51:56 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Wed, 20 Jun 2001 19:51:56 +0100 Subject: Any other Python flaws? References: <3b296534.514160393@wa.news.verio.net> <3b2a94a6.591842855@wa.news.verio.net> <636fd38f.0106200145.337888a3@posting.google.com> Message-ID: On 20 Jun 2001 15:15:48 GMT, Remco Gerlich wrote: >Tiago Henriques wrote in comp.lang.python: >> Another annoying missing feature is the absence of command line editing in the >> python shell. Perhaps now that the license has been made gnu-compatible it will >> be possible to ship python pre-compiled with the readline library, instead of >> having to compile python yourself. I have compiled python with readline support >> myself, and it's pretty easy, but for the average user who is afraid of makefiless >> and compilations, it would be extra-nice if python were a bit more user-friendly >> out-of-the-box. > >This isn't good, because readline is under the GPL. The only thing that the >GPL compatibility means is that people are allowed to distribute a version >of Python with readline compiled in - *under the GPL*. > >Python licensed under the GPL would be bad - it couldn't be embedded in >non-GPL projects anymore. Yes it could. It just couldn't be embedded in projects whose license was more restrictive than the GPL. -- ## Philip Hunt ## ## philh at comuno.freeserve.co.uk ## From scarblac at pino.selwerd.nl Thu Jun 14 03:00:09 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 14 Jun 2001 07:00:09 GMT Subject: Python grammar.. References: <9g7nrv$nnb$1@news.mathworks.com> Message-ID: Joshua Marshall wrote in comp.lang.python: > John Roth wrote: > > > So what you're saying is that if I have a function "Spam(eggs, ham) and a > > function > > scramble(, size = small), then I'd have to write > > Spam(scramble(eggs), ham) as > > Spam scramble eggs ham. > > > How do I tell that "ham" is an operand of Spam, and not the second operand > > of scramble? The > > only way this could possibly work is if the parser could tell, at compile > > time, exactly how many > > operands each function had. There are languages where this is possible, but > > Python isn't one of them. > > Choose a parsing rule and use parens to group things differently. > Python (and many other languages) already need parens to do this for > binary operators ("1-2-3" parses as "(1-2)-3"). > > So you'd probably have to write "Spam(scramble(eggs), ham)" as > "Spam (scramble eggs) ham". Why wouldn't that parse as (Spam (scramble eggs)) (ham) ? If you're going to make the parentheses mandatory everywhere you've just taken a step back to Lisp... -- Remco Gerlich From max at alcyone.com Sun Jun 3 13:51:55 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 03 Jun 2001 10:51:55 -0700 Subject: CGI : getting selected values in a select-object References: <6LrS6.4732$vu4.493136@news3.oke.nextra.no> Message-ID: <3B1A793B.5DF7AACD@alcyone.com> Thomas Weholt wrote: > I got a form in a web-page that uses a select-multiple box. I need to > pass > several selected items to the server. I'm using mod_python and when I > look > at the posted data I only see the latest selected item. Where did the > rest > go? How can I get them? All should be present, but they should have the same key. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Only the winners decide what were war crimes. \__/ Gary Wills Polly Wanna Cracka? / http://www.pollywannacracka.com/ The Internet resource for interracial relationships. From boyd at insultant.net Wed Jun 6 17:48:01 2001 From: boyd at insultant.net (Boyd Roberts) Date: Wed, 6 Jun 2001 23:48:01 +0200 Subject: best language for 3D manipulation over web ? References: <3b1cdc84.5514@bolder.com.co.za> <9fleid$3rp$1@oslo-nntp.eunet.no> <3B1E4951.7F36D4E4@alcyone.com> <3B1E50E1.35AE59C@lmf.ericsson.se> <3B1E52DA.BBC9FC32@alcyone.com> <3b1e5601.3970@bolder.com.co.za> <3B1E5836.E7F1D88F@lmf.ericsson.se> <3b1e5b50.3adb@bolder.com.co.za> <3B1E5D5C.7878FC9E@lmf.ericsson.se> <9flpu8$br12@mercury.adc.com> Message-ID: <9fm8gs$je$1@quark.noos.net> "Mike Tietel" a ?crit dans le message news: 9flpu8$br12 at mercury.adc.com... > You need French cuisine knowledge. Quiche is "egg pie"... peut ?tre pas. From rnd at onego.ru Wed Jun 27 13:47:23 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 27 Jun 2001 21:47:23 +0400 (MSD) Subject: PEP 260: simplify xrange() In-Reply-To: Message-ID: On Wed, 27 Jun 2001, Guido van Rossum wrote: >I haven't heard any real objections here, so I'm going to go ahead and >make this change (ripping the fancy stuff from xrange()) later this >week. Boy does that feel good. ;-) Yes, no objections from me too. Though I would like PyChecker to score programs on the basis the features they use and warn if some features are being phased out soon ;-) Like: -------------------------- $ checker.py myprogram.py ... Hmmm... I estimate yourprogram.py will not run with Python 2 years from now. -------------------------- Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Wednesday, June 27, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "No sense being pessimistic. It wouldn't work anyway." _/ From bawolk at ucdavis.edu Sat Jun 16 19:45:46 2001 From: bawolk at ucdavis.edu (Bruce Wolk) Date: Sat, 16 Jun 2001 16:45:46 -0700 Subject: qt or gtk? References: Message-ID: <3B2BEFA9.AFF98906@ucdavis.edu> I would like to put my two-cents in for Qt. As a newbie to gui I tried gtk and found it a little cryptic and cumbersome. Then I got PyQt and was blown away by how crisp and simple the coding is. The Qt documentation is really excellent. For rapid gui development you can use Qt Designer, which operates pretty much like glade. D-Man wrote: > On Sat, Jun 16, 2001 at 05:52:12AM +0000, Rainy wrote: > | > | I want to learn python gui programming in linux. I think tk looks too ugly, so > | I narrowed down the choice to two main contenders, qt and gtk. Which of these > | has more complete and up-to-date python bindings? Are there other reasons > | to prefer one of these over another for python gui work? > > Personally I like GTK better. I don't like the way Qt tries to look > like MS Windows. Glade+libglade make a great combination for rapid > coding. Use glade (a gui) to build the static parts of the interface, > then load them at runtime with libglade. You simply write the event > handlers and connect them to the events in your code. You can > completely change the look of the UI without changing any code as long > as the names of widgets and their type match (ie you don't change from > a tree to a list). > > wxWindows and wxPython look nice, though I haven't worked with them > enough to know if I like the style of the interface. > > -D -- Bruce Wolk From akhar at videotron.ca Sat Jun 2 05:27:19 2001 From: akhar at videotron.ca (akhar) Date: Sat, 2 Jun 2001 02:27:19 -0700 Subject: QuickCam and python? Message-ID: Is it possible to read direcltly from a quickcam or any other video camera from python, and use pil(for example) to stream it? I am still shopping for a camera to use for my project if there is one that is better ... Akhar From grey at despair.dmiyu.org Thu Jun 28 15:23:57 2001 From: grey at despair.dmiyu.org (Steve Lamb) Date: Thu, 28 Jun 2001 19:23:57 -0000 Subject: exec "global" problem References: Message-ID: On Thu, 28 Jun 2001 00:24:09 -0400, Tim Peters wrote: >You should really say something about what you're trying to accomplish in >the *end*, so c.l.py can help. Think of this as the c.l.py Suicide >Prevention Line . What if they are trying to commit suicide with Python? Would you help them solve it then? :) -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. To email: Don't despair! | -- Lenny Nero, Strange Days -------------------------------+--------------------------------------------- From db3l at fitlinxx.com Thu Jun 28 20:45:49 2001 From: db3l at fitlinxx.com (David Bolen) Date: 28 Jun 2001 20:45:49 -0400 Subject: Augmented Assignment (was: Re: PEP scepticism) References: Message-ID: Paul Prescod writes: > Bruce Sass wrote: > > > > > > ...what was a wart becomes a feature. > > That was a lot of effort to understand a typing shortcut. It's somewhat > unpythonic to trade a long explanation for a bit less typing. I think that if the operation is phrased from the start as an action undertaken by the source object itself and that the source object's mutability can affect behavior, that it's not too big of a hurdle. After all, part of the reason to permit the mutable objects to behave differently is that augmented assignment isn't just for less typing, but it can enable far more efficient operations (e.g., array *= 2 rather than array = array * 2 not having to create new large objects). I think that ability is worth a few extra phrases of description. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From volucris at hotmail.com Sat Jun 30 17:12:18 2001 From: volucris at hotmail.com (Volucris) Date: Sat, 30 Jun 2001 16:12:18 -0500 Subject: File-like objects for reading zip files? References: <9hks27$549$1@slb2.atl.mindspring.net> Message-ID: <3b3e4042$0$329$6e49188b@news.goldengate.net> I haven't heard of anything like that. You might want to check out the zlib module. It's got some compression stuff in there. Zips can have multiple files in them so your code would have to have a way to choose which file you want to access. -- Volucris (a) hotmail.com "Eu n?o falo uma ?nica palavra do portugu?s." "Greg Landrum" wrote in message news:9hks27$549$1 at slb2.atl.mindspring.net... > Hi, > > I have a .zip archive containing a very large text file (~2.3 MB compressed, > ~520MB uncompressed). I'd like to have a file-like object for working with > this file so that I never need to uncompress it. In case this isn't clear > enough, I'd like to be able to do something like this: > > import magiczipthing > f = magiczipthing.FileLikeObject('bigfile.zip','r') > l = f.readline() > while l: > process_line(l) > l = f.readline() > > From my perusal of the docs, it doesn't look like the zipfile module > supports this type of interaction. > > Is there any way to accomplish this task? > > Thanks, > -greg > > From sholden at holdenweb.com Fri Jun 29 09:11:09 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 29 Jun 2001 09:11:09 -0400 Subject: Terminating a local process COM server References: Message-ID: "Duncan Booth" wrote ... > "Steve Holden" wrote: > > > For efficiency reasons I am implementing a credit-card checking > > algorithm as a COM LocalServer object. > > [ questions about stopping a COM LocalServer started automatically] > > > In principle you could query the registry to work out the name of the EXE > file and then find the relevant process and kill it. In practice this gets > difficult if you find more than one matching EXE file: this is especially a > problem with COM objects written in Python, as there are quite likely to be > other Python or PythonW processes lying around. > > Another option would be to put the COM object into an NT service. That way > you can simply stop and start the service at will. I recently wrote a > service containing a COM object, let me know if you want a copy of the > code. The downside to this is that it makes it harder to debug the service > when things go wrong. > Hmmm. It's not as simple as I at first believed. I thought running a service might be a good way to go, but of course this begs the question of how to communicate with the service! The reason I wanted to go for a COM server was vecause COM is integrated into all the Windows-based architecture (ASP, VB, etc) that my client currently uses, so it's easy to use COM to create onjects which perform useful services. So, if anyone knows the secret of terminating a LocalServer process I'm still listening... regards STeve -- http://www.holdenweb.com/ From jamwt at jamwt.com Wed Jun 13 21:03:23 2001 From: jamwt at jamwt.com (James Turner) Date: Thu, 14 Jun 2001 01:03:23 GMT Subject: Embedding: Problem with CallObject References: <20010613.174914.1793282088.6934@bender.nowhere.non> Message-ID: <20010613.180336.1303781742.6934@bender.nowhere.non> Sorry to reply to self.. Incase these details are important: Python 2.0c1 gcc 2.95.2 FreeBSD 4.1 Anything else? James From thomas at xs4all.net Fri Jun 1 03:44:49 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 1 Jun 2001 09:44:49 +0200 Subject: No swap function in Python? In-Reply-To: <3B15FD21.42CA2660@europem01.nt.com>; from boltong@europem01.nt.com on Thu, May 31, 2001 at 10:13:21AM +0200 References: <3B150A65.5D4986FC@europem01.nt.com><20010530173327.C690@xs4all.nl> <3B15FD21.42CA2660@europem01.nt.com> Message-ID: <20010601094449.L690@xs4all.nl> On Thu, May 31, 2001 at 10:13:21AM +0200, Bolton, Gawain [ADC:4808:EXCH] wrote: > pretend humans understand words more readily than symbolic notation - a swap > function could generate the optimized code without any need for peephole > optimization. Except that a function call is *way* more expensive than tuple packing/unpacking, even if only because a function call consists of a tuple pack/unpack, among several other things. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From not.this at seebelow.org Thu Jun 28 23:37:42 2001 From: not.this at seebelow.org (Grant Griffin) Date: Thu, 28 Jun 2001 22:37:42 -0500 Subject: not about Google (was: Check out O'Reilly's Open Source Convention Highlights) References: <3B3AA82D.1A0FE860@seebelow.org> <3B3B2DED.5303198A@seebelow.org> <3dk81w1y8t.fsf@ute.cnri.reston.va.us> Message-ID: <3B3BF806.8D420199@seebelow.org> Andrew Kuchling wrote: > > Grant Griffin writes: > > But now that you mention it, the US Midwest *is* pretty centrally > > located on a "world" basis. > > From a quiz for mad scientists I once saw: > > Complete the following sentence: "Unless I receive a billion dollars > by midnight, I will destroy a world-famous centre of culture and > history, _______" > > A. New York > B. London > C. Spooner, Wisconsin. > D. that little pancake place, remember, where you once had the > mushroom omelet? Lemme guess--the pancake menu said "...our famous mushroom omlet..." fifteen-minutes-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From wade at lightlink.com Sat Jun 2 17:33:56 2001 From: wade at lightlink.com (Wade Leftwich) Date: 2 Jun 2001 14:33:56 -0700 Subject: Zope questions and comments (&Tkinter???) References: <3B158C50.887E3D59@earthlink.net> <3B17DFEE.C102004D@yahoo.com> Message-ID: <5b4785ee.0106021333.34e21172@posting.google.com> I made several attempts at Zope beginning at the beginning, in fall 1998. I never got much traction until recently, with the release of Zope Page Templates. No more DTML! I now have a pretty good-sized project moving forward nicely. All the code is in Python Scripts, and all the presentation is in ZPT. As most of the previous posters have observed, Zope is big and complex. The key for me was to find a workable subset so I could start making progress. The Zope Book, available at www.zope.org and coming out in print this summer, is quite good. I believe that Beehive.de, a German company that does Zope development and training, has one or two books coming out also. They have recently opened a U.S. office in DC. -- Wade Leftwich Ithaca, NY From jkraska1 at san.rr.com Sat Jun 30 18:08:33 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 30 Jun 2001 22:08:33 GMT Subject: Augmented Assignment (was: Re: PEP scepticism) References: Message-ID: >> My point is that it is hard for a new user to "believe me" (or at least >> understand me) when I say that tuples are not mutable but they see them >> changing right in front of their eyes: >> >> >>> a=(1,2,3) >> >>> a+=(8,3) They would believe you better if you gave a better example: >>> tpl1 = (1,2,3) >>> tpl2 = tpl1 >>> tpl2 (1, 2, 3) >>> tpl2+=(4,5) >>> tpl2 (1, 2, 3, 4, 5) >>> tpl1 (1, 2, 3) >>> list1 = [1,2,3] >>> list2 = list1 >>> list2 [1, 2, 3] >>> list2 += [4,5] >>> list2 [1, 2, 3, 4, 5] >>> list1 [1, 2, 3, 4, 5] >>> From guido at digicool.com Thu Jun 21 10:32:40 2001 From: guido at digicool.com (Guido van Rossum) Date: Thu, 21 Jun 2001 10:32:40 -0400 Subject: PEP 255 - BDFL Pronouncement: 'def' it stays Message-ID: <200106211432.f5LEWeA03163@odiug.digicool.com> I've thought long and hard and tried to read almost all the mail on this topic, and I cannot get myself to change my mind. No argument on either side is totally convincing, so I have consulted my language designer's intuition. It tells me that the syntax proposed in the PEP is exactly right - not too hot, not too cold. But, like the Oracle at Delphi in Greek mythology, it doesn't tell me why, so I don't have a rebuttal for the arguments against the PEP syntax. The best I can come up with (apart from agreeing with the rebuttals that Tim and others have already made) is "FUD". If this had been part of the language from day one, I very much doubt it would have made Andrew Kuchling's "Python Warts" page. So I propose that Tim and others defending 'def' save their remaining breath, and I propose that Paul and others in favor of 'gen[erator]' start diverting their energy towards thinking about how to best teach generators the PEP syntax. Tim, please add a BDFL pronouncement to the PEP to end the argument. You can also summarize the arguments on either side, for posterity -- without trying to counter them. I found one useful comment on the PEP that isn't addressed and is orthogonal to the whole discussion: try/finally. When you have a try/finally around a yield statement, it is possible that the finally clause is not executed at all when the iterator is never resumed. I find this disturbing, and am tempted to propose that yield inside try/finally be disallowed (but yield inside try/except is still allowed). Another idea might be to somehow continue the frame with an exception at this point -- but I don't have a clue what exception would be appropriate (StopIteration isn't because it goes in the other direction) and I don't know what to do if the generator catches exception and tries to yield again (maybe the exception should be raised again?). The continued execution of the frame would be part of the destructor for the generator-iterator object, so, like a __del__ method, any unhandled exceptions wouldn't be able to propagate out of it. PS I lost my personal archive of the last 18 hours of the iter mailing list, and the web archive is down, alas, so I'm writing this from memory. I *did* read most of the messages in my archive before I accidentally deleted it, though. ;-) --Guido van Rossum (home page: http://www.python.org/~guido/) From matt at mondoinfo.com Wed Jun 13 22:00:53 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Thu, 14 Jun 2001 02:00:53 GMT Subject: DNSlib issues? References: Message-ID: On Wed, 13 Jun 2001 23:50:33 GMT, Benjamin Schollnick wrote: Benjamin, >If I give an invalid DNS server address in the DNSLIB demo, the App >waits for keyboard manual entry....(i.e. instead of failing with a >socket error, the socket seems to be connecting to stdin)... I don't think that the problem is that the socket is connected weirdly. It's that the socket is waiting forever for a reply that's never going to arrive. There's no default timeout on a recv(). Since the code is a demo, it's pretty reasonable that it doesn't try to check for lots of error conditions. > Is there anyway for me to catch this? Yes, there is. You can use select() from the select module to decide how long to wait. The thing to do is to change the code that does the sending and receiving to something like this: if protocol == 'udp': s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect((server, port)) s.send(request) # New r,w,e=select.select([s],[],[],10) # Timeout 10 seconds if len(r)==0: print "Too long, I'm bored" sys.exit(1) # end of new code reply = s.recv(1024) Regards, Matt From snowrichard at earthlink.net Sun Jun 24 06:06:00 2001 From: snowrichard at earthlink.net (Richard Snow) Date: Sun, 24 Jun 2001 10:06:00 GMT Subject: New library software development project. Message-ID: <3B3601BE.3C84E49A@earthlink.net> I'm looking for 2 types of people who might be interested in this project: School librarians/staff Python coders and also possibly: junior or senior high school students who like to program hence the cross post. A brief description of the project: An open source library circulation system written in Python and running on Linux. Handles patron records, book records, and checkouts currently. We might add other types of records such as videos, audio tapes, and so on later. The web page at http://richardsnow.bizland.com/opendev describes the project, and has source code in Python 1.5.2 for an initial version. I need some real users/testers who know about libraries to help guide further development. The project will eventually be released under the GPL. Initially I'm targeting Linux as it will run on inexpensive equipment however most schools may already have Windows so a windows port is not out of the question and Python is also available for Windows so it should be fairly easily done. However the first version uses the Unix Curses library for its user interface, and runs on a linux console rather than the X windowing system. The initial version has been developed/tested on Red Hat Linux 7.1 but should also run on other Linux systems that have Python, namely Debian, which some of the early work was done on and I still have available for testing purposes. If you are interest in helping out or in using the code, please see the web page and email me from there. -- Richard Snow http://richardsnow.bizland.com From bh at intevation.de Fri Jun 29 05:24:14 2001 From: bh at intevation.de (Bernhard Herzog) Date: 29 Jun 2001 11:24:14 +0200 Subject: Augmented Assignement (was: Re: PEP scepticism) References: Message-ID: <6qn16r7i69.fsf@abnoba.intevation.de> Carsten Geckeler writes: > As mentioned above, for tuples the "+=" is completely natural, but not for > lists. Funny, I mostly see it exactly the other way round. += modifies the left hand side in place, so it's natural for a list, but not for a tuple. I think the main problem (in as much as there actually is a problem) is that whether augmented assignment rebinds the left hand side depends on the type of object, i.e. whether the object implements the appropriate methods, which is very different from normal assignment which always rebinds. Bernhard -- Intevation GmbH http://intevation.de/ Sketch http://sketch.sourceforge.net/ MapIt! http://mapit.de/ From thomas_barket at yahoo.com Fri Jun 29 04:24:40 2001 From: thomas_barket at yahoo.com (tom barket) Date: 29 Jun 2001 01:24:40 -0700 Subject: changes to PyTypeObject in object.h over time -> probs with CXX? Message-ID: <758d4715.0106290024.38b82390@posting.google.com> hello, i am trying to install the CXX-5.0b Demo with the new version 2.1 of python, and in spite of the completely simple installation process ("python setup.py install"), I came across some errors. Specifically, the compiler complained that PyTypeObject is missing 4 data members: tp_xxx5, tp_xxx6, tp_xxx7, and tp_xxx8 (see below). So I looked up the definition of PyTypeObject in object.h and found that these data members are indeed absent. However, when i inspected object.h for python version 2.01, I found that tp_xxx7 and tp_xxx8 are there, and in python version 1.6, all four are there. So it seems that these data members have been replaced over time (it looks like by tp_traverse, tp_clear, tp_richcompare, and tp_weaklistoffset), which is causing CXX (apparently orignally written for python 1.6) to fail. If all this is correct, what changes do i need to make to CXX-5.0b work with python 2.1? If this is available somewhere, I apologize in advance. I am fairly new to python, but i have looked around quite a bit and have come up with no answers yet. TIA. Tom thomas_barket at yahoo.com C:\Python21\etc\CXX\cxx_extensions.cxx(292) : error C2039: 'tp_xxx5' : is not a member of '_typeobject' C:\Python21\etc\CXX\cxx_extensions.cxx(293) : error C2039: 'tp_xxx6' : is not a member of '_typeobject' C:\Python21\etc\CXX\cxx_extensions.cxx(294) : error C2039: 'tp_xxx7' : is not a member of '_typeobject' C:\Python21\etc\CXX\cxx_extensions.cxx(295) : error C2039: 'tp_xxx8' : is not a member of '_typeobject' From phrxy at csv.warwick.ac.uk Fri Jun 8 17:11:15 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Fri, 8 Jun 2001 22:11:15 +0100 Subject: WHY is python slow? In-Reply-To: References: Message-ID: On Fri, 8 Jun 2001, Niklas Frykholm wrote: > >now, if we accept the postulate that premature programme optimisation > >is an evil and that python has been around much longer than ruby, has > >much better documentation and that in Bruce Eckel's words: > > >"...For some reason, the creator of the language saw Python and > >decided to do a clone, and people who had never used Python thought > >it was a good idea. Harsh, maybe, but that's my impression: if you've > >used Python at all, you wouldn't give Ruby a second glance. > > Sad to see someone like Bruce Eckel engage in language bashing. The [...] I think you're misreading what he wrote -- I think he just meant by 'you wouldn't give it a second glance' that it was not sufficiently original to justify learning it if you already know Python. That does seem to be the case, from what I can see (unless there's something written in it that you want to use). I guess he's also saying that it's a shame to divide people who could be working together, for no particularly good reason, and I think he's right to say that, too. I don't think he's 'bashing' the language at all. In fact, if he likes Python, presumably he likes Ruby too, from your quote. John From aleaxit at yahoo.com Wed Jun 6 17:56:52 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 6 Jun 2001 23:56:52 +0200 Subject: Why should i use python if i can use java References: <9flu5i$c61$1@news.tudelft.nl> Message-ID: <9fm97b05cl@enews1.newsguy.com> "D-Man" wrote in message news:mailman.991858449.8927.python-list at python.org... > On Wed, Jun 06, 2001 at 08:52:34PM +0200, mik wrote: > | i' m a python newbie but I've this prob. i have seen Jython .. > | > | what has python dat java does not????????? > > Modules. Function objects. _Completely_ OO (int, boolean, modules, > classes, and functions are all objects, not just class instances). > Easier syntax. High level of design in the language and runtime > libraries. No casting when using containers. Edit-run as opposed to > edit-compile-run cycle. And higher productivity. I thought I had posted a huge treatise on that just a few hours ago to a heavily crossposted thread with a funny subject about 3D, but it doesn't seem to have shown up, I'll have to look into that... it mentioned Prechelt's empirical study, quoted Eckel extensively, etc, etc. > In short, Python has a _lot_ that Java doesn't have. Jython is an > implementation of Python written in Java so that it runs in a JVM and > provides nice integration between Python and Java similar to what > CPython does for C and Python. Far better! Jython's total integration with Java's libraries is astonishing. You don't need to 'wrap' anything, like you do in CPython with a typical C library... just USE it -- any Java library is right there, ready for your Jython use. I can't get over the detail of how SMOOTHLY it works...!-) Caveat: it takes an *up-to-date* JVM, so, just like anything else added to Java after 1.0, it's *NO* good for applets that must run on any comer's browsers (most browser out there use VERY old and/or quirky JVMs and you can't expect a site's visitors to download many megabytes of plugin from javasoft's site just to be able to enjoy your site:-). Alex From deltapigz at telocity.com Sat Jun 9 13:07:03 2001 From: deltapigz at telocity.com (Adonis) Date: Sat, 09 Jun 2001 13:07:03 -0400 Subject: Tkinter Qs Message-ID: <3B2257B6.D4390F7D@telocity.com> question 1: what form of measurement does Tkinter use? Pixels or DIB? question 2: why doesnt this work? (text not being colored) t = Text(frame, width=50, height=15) t.pack() t.tag_config("test", foreground="red") t.insert(END, "test") * have looked into Tkinter documentation and am using examples directly as-is, textbox is bein drawna nd text is present but color not being shown. thanks in advance, Adonis From urner at alumni.princeton.edu Thu Jun 7 01:18:12 2001 From: urner at alumni.princeton.edu (Kirby Urner) Date: Wed, 06 Jun 2001 22:18:12 -0700 Subject: Recursive algorithms anyone? Message-ID: <1f0uhtgmhb0vlud6pof6i4mctqjdq8l2eu@4ax.com> How to implement in Python the classic thing of adding k to every item in a list. Except a list may contain other lists to arbitary depth? I say classic because it's the kind of thing you do in computer science 101. E.g. >>> additem(1,[1,2,[3,4,[5,6]],7]) [2,3,[4,5,[6,7]],8] Here's the Scheme solution: (define (additem items k) (cond ((null? items) null) ((not (pair? items)) (+ items k)) (else (cons (additem (car items) k) (additem (cdr items) k))))) My best Python attempt so far: >>> def additem(items, k): if not type(items) == type([]): return items + k if len(items)==0: return [] return [additem(items[0],k)] + additem(items[1:],k) >>> additem([[9,8],1,2,3,4,[1,2, [5,6]]],1) [[10, 9], 2, 3, 4, 5, [2, 3, [6, 7]]] But maybe there's a better solution? Kirby CC pdx4d at teleport.com por favor From sill at optonline.net Tue Jun 5 15:59:45 2001 From: sill at optonline.net (Rainy) Date: Tue, 05 Jun 2001 19:59:45 GMT Subject: Why doesn't this work as expected? References: <9fi5j5$pk6$0@216.39.170.247> Message-ID: On 5 Jun 2001 08:34:45 GMT, David LeBlanc wrote: > I'm trying to build a directory walker, doing some work on each actual > file found in each directory. However, when I run the below code snippet > on a directory containing both sub-directories and files, it says that > all are not dirs. > > What is not right? > > TIA, > > Dave LeBlanc > > import sys > import os > import dircache > import re > > > def getDirs(): > print dircache.listdir("l:/languages/python") > > for dir in dircache.listdir("l:/languages/C"): > if os.path.isdir(dir): > print dir, "is a dir" > else: > print dir, "is not a dir" > > getDirs() Did you try os.path.walk? -- Delay not, Caesar. Read it instantly. -- Shakespeare, "Julius Caesar" 3,1 Here is a letter, read it at your leisure. -- Shakespeare, "Merchant of Venice" 5,1 [Quoted in "VMS Internals and Data Structures", V4.4, when referring to I/O system services.] From serdars at ixir.com Sat Jun 2 08:41:23 2001 From: serdars at ixir.com (Serdar Soydemir) Date: Sat, 2 Jun 2001 15:41:23 +0300 Subject: SocketServer Problem References: <004501c0eb5a$4ec91980$0101a8c0@nemesis> Message-ID: <006b01c0eb61$563876f0$0101a8c0@nemesis> Sorry for my inattention, i found the answer, changing simply TCPServer to ThreadingTCPServer solved the problem. -- Serdar Soydemir ----- Original Message ----- From: "Serdar Soydemir" To: Sent: Saturday, June 02, 2001 2:51 PM Subject: SocketServer Problem > Hello, > > I am working on a little socket server application to learn and practice how > Python socketserver works. It works great for now, but it can accept only > one connection , when i try to open another conn while first one is still From nhodgson at bigpond.net.au Tue Jun 19 22:23:05 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Wed, 20 Jun 2001 02:23:05 GMT Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: <3B2EADB0.9DBC6FC8@earthlink.net> Message-ID: Ron Stephens: > Of course, each person undoubtedly has a different set of concepts in mind > when he thinks of "PythonCard"..still, an intriguing amount of interest in 24 > hours... I'd like, at least initially, a fairly straight clone of HyperCard but with true colour graphics. While my other open-source activities don't leave much time for contributing, I'd be able to do a script editor / debugger. Is it time to have the toolkit war? How suitable would ZODB be as the persistence back end? Neil From tim.one at home.com Thu Jun 7 19:33:45 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 7 Jun 2001 19:33:45 -0400 Subject: WHY is python slow? In-Reply-To: <4.3.2.7.2.20010607144657.042f8328@bdg.centrin.net.id> Message-ID: [Steven Haryanto] > Although it is generally accepted that Python is slower than > Java/Perl/Ruby, a layman like me would be curious to know why > exactly this is so. Me too, although philosophers and historians have been puzzling for centuries over how it can be that generally accepted beliefs are often divorced from reality. I guess it's for the same reasons that Python has significant whitespace just like Fortran's, Lisp is slower than Visual Basic, C++ adds nothing to C that can't be done just as well with preprocessor macros, functional languages can't be used for real work, and that at least one of {Linux, NT} is a great operating system . there's-no-accounting-for-mass-delusion-ly y'rs - tim From kbk at shore.net Wed Jun 6 17:17:38 2001 From: kbk at shore.net (Kurt B. Kaiser) Date: Wed, 06 Jun 2001 21:17:38 GMT Subject: floating point in 2.0 References: Message-ID: <3B1E9CE7.6C6A5BE1@shore.net> "Michael P. Soulier" wrote: > > Greetings people. > Tim, Thanks for the correction (always copy/paste "working" code!!), the enhancement, and the explanation of why it isn't enough to solve the problem. Food for thought. I-knew-I'd-get-T/botted-but-not-quite-so-thoroughly'ly yrs, KBK From phd at phd.fep.ru Mon Jun 25 07:35:35 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Mon, 25 Jun 2001 15:35:35 +0400 (MSD) Subject: any idea how i could test if a variable is a floating point number? In-Reply-To: <9h76io$ht3$1@neptunium.btinternet.com> Message-ID: On Mon, 25 Jun 2001, Gaz wrote: > any idea how i could test if a variable is a floating point number? 1. Why do you need it at all? Just test if you can opertae it: try: x += 2.1 except TypeError: print "Error!" 2. Well, if you still things you need to test: if type(x) == type(1.1): print "Yes, float" Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From greg at cosc.canterbury.ac.nz Mon Jun 25 02:06:31 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Mon, 25 Jun 2001 18:06:31 +1200 Subject: critic this please References: Message-ID: <3B36D4E7.2D5826E3@cosc.canterbury.ac.nz> NJM wrote: > > a = float(Tkinter.Entry.get(feet)) > b = float(Tkinter.Entry.get(inch)) > Tkinter.Entry.delete(answer, 0, 20) > Tkinter.Entry.insert(answer, 0, (b/12 + a)*13) Although it works in this case, that's not the way objects are intended to be used! You should be doing this: a = float(feet.get()) b = float(inch.get()) answer.delete(0, 20) answer.insert(0, (b/12 + a)*13) -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From hajaansh at hotmail.com Fri Jun 8 03:21:23 2001 From: hajaansh at hotmail.com (Jam) Date: 8 Jun 2001 00:21:23 -0700 Subject: Learning OOP... References: <9fm8ti$d92$1@newshost.accu.uu.nl> Message-ID: Why not take a look at SmallTalk? I have been and it does seem to look very interesting!! And IMHO (and i have only been looking at it 4 half a year) it seems to fulfil all the wishes you describe! Why not look at there discusion board to find out more. Cheers, Jam rod_weston at yahoo.com (Rod Weston) wrote in message news:... > The reasons I feel a need to learn OOP languages are as follows: > 1. I feel that OOP offers the best conceptual fit for my programming > projects which are primarily business oriented. > 2. Career choices - any programmer in today's market needs to be OOP > conversant and productive, preferably with a language that will be > recognized and used 'a lot', thereby generating profitable > opportunities. > 3. I want to reuse code as much as possible. > 4. I want to reduce errors and take advantage of advanced debugging > tools. > 5. I want strong and flexible data typing - I know it sounds like an > oxymoron. I want the typing to be especially powerful (restrictive) > but I want to be able to define the constraints of the types myself. > 6. I want something relatively easy to use and to learn. > 7. I want reduced development times and enhanced maintenance tools. > 8. I want portability and scalability. > 9. I want a lot of open source code available. > 10. I want source code that is easily read. > 11. I want good quality but free or inexpensive tools - especially a > validated compiler to properly optimize my code for the task at hand > and catch as many errors as possible at compile time. > > Not all the objectives relate to OOP, but most do. From what I've > seen so far, Ada best meets my criteria but I have not done enough > research yet to be willing to gamble my future on it. From root at rainerdeyke.com Mon Jun 11 11:01:21 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 11 Jun 2001 15:01:21 GMT Subject: Learning OOP... References: Message-ID: <535V6.147522$oc7.8844949@news2.rdc2.tx.home.com> "Alex Martelli" wrote in message news:mailman.992248937.25086.python-list at python.org... > The > problem is the entanglement, NOT inheritance, which, in Python, > is just a neat and powerful reuse-mechanism -- no more, no less. Counterexample: the exception hierarchy. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From menscher+python at uiuc.edu Wed Jun 13 14:35:38 2001 From: menscher+python at uiuc.edu (Damian Menscher) Date: Wed, 13 Jun 2001 18:35:38 GMT Subject: Need help with threads Message-ID: <_nOV6.9330$ki5.130125@vixen.cso.uiuc.edu> I'm trying to use threads to run various processes that require some I/O. This is apparently broken. Here's a simple program: ================================================= #!/usr/bin/python import time import thread import popen2 def b(n): print "running b(%s)"%n r,w = popen2.popen2('cat') w.write("test %s"%n) w.close() print "process %s read %s"%(n,r.readline()) for n in range(10): thread.start_new_thread(b, (n,)) ### with threads #b(n) ### without threads time.sleep(1) ## Allow some time for threads to finish ================================================= So this should start up, fork off 10 threads that just do basic stuff, then wait a second for everything to finish. Running *without* threads (by uncommenting the b(n) line) shows typical (correct) execution: [menscher at qcdhome t2]$ ./threads.py running b(0) process 0 read test 0 running b(1) process 1 read test 1 running b(2) process 2 read test 2 running b(3) process 3 read test 3 running b(4) process 4 read test 4 running b(5) process 5 read test 5 running b(6) process 6 read test 6 running b(7) process 7 read test 7 running b(8) process 8 read test 8 running b(9) process 9 read test 9 But running *with* threads gives me: [menscher at qcdhome t2]$ ./threads.py running b(6) running b(2) running b(4) running b(0) running b(5) running b(1) Killed Where the job hogged 99% of CPU and had to be killed (even a ^C didn't stop it). I'm guessing there might be a namespace conflict in the I/O, but I'm new to python in general and can't develop a workaround. While I'm posting... is there an elegant way to wait till all threads have finished? I can't count on things finishing in a fixed time for my application. Ideas? Please?? Damian Menscher -- --==## Grad. student & Sys. Admin. @ U. Illinois at Urbana-Champaign ##==-- --==## www.uiuc.edu/~menscher/ Ofc:(217)333-0038 ##==-- --==## Physics Dept, 1110 W Green, Urbana IL 61801 Fax:(217)333-9819 ##==-- From aleaxit at yahoo.com Thu Jun 7 15:56:36 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 7 Jun 2001 21:56:36 +0200 Subject: Why should i use python if i can use java References: <9fngvl011jg@enews2.newsguy.com> Message-ID: <006d01c0ef8c$01af4ee0$0300a8c0@arthur> "Don Dwiggins" writes: ... > Alex Martelli quotes Glyph Lefkowitz: > >> > an elegant way of implementing singletons (or does it? anyone?) > >> > >> Aah, the singleton. Global variables for the new millennium. First of > >> all, the singleton "pattern" is usually a bad idea. If you have a class > > > *AMEN, HALLELUJAH*! This makes two of us sharing this dislike > > for the Singleton Design Pattern, so I'm not a Singleton any > > more -- see, that's one typical issue with Singleton DP, what > > starts out as a singleton often becomes not one:-). > > According to the GOF "Applicability" section on Singleton: > Use the Singleton pattern when > - there must be exactly one instance of a class, and it must be > accessible to clients from a well-known access point. > - when the sole instance should be extensible by subclassing, and > clients should be able to use an extended instance without modifying > their code. > > If you take the whole description of the Singleton pattern seriously, to say > that you "hate" the pattern would seem to mean that you don't believe that > programs should ever need something that satisfies these criteria. Is that First of all, I said not 'hate' but 'dislike', and Glyph said "it's usually a bad idea". But the crucial thing is: I opine the SDP does *NOT* tend to optimally resolve the forces thus identified! > true for both of you? Whether it is or not, I'd like to hear a bit more > explanation for the strong emotional reaction to the pattern. I've posted very extensively about it, and how I prefer 'lightweight proxies' instead -- instances that have no state (but rather delegate all state, and possibly all behavior, to a singly-instanced object not exposed directly to client code) but are freely instantiable at need -- and specifically what different advantages this brings in different contexts, such as Python, COM, and so on. Of all the issues, the key one is that LWP is more change-proof than SDP in my experience -- "there must be only one" is, out of all design constraints, one of those that most tend to change in an iteration. Refactoring LWP's is trivial, refactoring SDP typically isn't. But take the subclassing. Why should different client parts need the same subclassing? They may want to use different mixins, decorators, and so on. How do they do that on SDP? They don't. How do they do that on LWP? Trivial. Of course, the in-one-single-instance obj (not exposed to normal client code) may be subclassed at will (and variously played with in Python) if something is needed that all clients will 'see' at once -- as LWP's delegate state & behavior. Alex _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From uioziaremwpl at spammotel.com Sun Jun 17 03:53:45 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Sun, 17 Jun 2001 09:53:45 +0200 (CEST) Subject: Any other Python flaws? In-Reply-To: <9gbe4e$gla$2@newshost.accu.uu.nl> Message-ID: On 14 Jun 2001, Martijn Faassen wrote: > Andrew Kuchling wrote: > > I was updating my page of possible Python design flaws > > (http://www.amk.ca/python/writing/warts.html) last night to take 2.1 > > into account. 2.1's nested scoping fixes one major wart, and the > > other major one, the type/class dichotomy, might get fixed in 2.2 if > > the descr-branch in CVS turns out well. (It's neat that the two > > largest ones may both get fixed before 2001 is out.) > > > That leaves the remaining warts as minor wibbling about 'do' > > statements, print >>, and the like. Are there any other flaws that > > should be added? > > This may be considered a minor quibble; the mandatory use of () in > case of multiple arguments to the % string interpolation operator: > > "%s" % "foo" > > "%s %s" % "foo", "bar" # doesn't work right > > "%s %s" % ("foo", "bar") This has nothing to do with "mandatory" or optional. This is a question of operator precedence. The "%" operator has higher precedence as the "," operator, so grouping with (..) is necessary. Cheers, Carsten -- Carsten Geckeler From nightowl at uk2.net Wed Jun 27 12:43:10 2001 From: nightowl at uk2.net (NightOwl) Date: Wed, 27 Jun 2001 18:43:10 +0200 Subject: KDE and Windows Message-ID: <993660235.135465@seven.kulnet.kuleuven.ac.be> Is it possible to develop a GUI which runs in Windows aswell as in KDE with the same code ? I don't want to have to re-write all code just because I use an other OS ... ? (Not using the COM-functions of Windows). From sill at optonline.net Wed Jun 13 21:38:01 2001 From: sill at optonline.net (Rainy) Date: Thu, 14 Jun 2001 01:38:01 GMT Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> <3b27823b.19626140@news.btinternet.com> <9g8q8v0uns@drn.newsguy.com> Message-ID: On 13 Jun 2001 15:42:39 -0700, thinkit wrote: > In article <3b27823b.19626140 at news.btinternet.com>, > danny.ayers_nospam at btinternet.com says... >> >>On 12 Jun 2001 08:39:37 -0700, thinkit wrote: >> >>>humans should use a power of 2 as a base. this is more logical because it >>>synchs with binary, which is at the very heart of logic--true and false. it is >>>more natural perhaps, to use decimal--but logic should, and will, win out. >> >>the main use of numbers is in numerical operations such as counting, >>not logical ones >> >>what would tbe he advantage in using powers of 2 be anyway? isn't the >>idea of computers for them to do this kind of work for us? > > well we can have computers do our work easier since we'll be speaking on > hexadecimal. > It's easier to make computers speak dec than make humans speak hex. How many computers were taught to convert their results to dec? Almost all. How many humans were taught hex? Probably less than a thousandth of a percent. Besides, computers are *already* taught, so going back now and saying 'hey, lets now teach people and computers can forget the dec stuff' - that's pretty illogical, eh? ;-) -- Shine on you crazy diamond - Roger From hamish_lawson at yahoo.co.uk Mon Jun 4 12:25:24 2001 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: 4 Jun 2001 09:25:24 -0700 Subject: Suggestions for recipes we could write for Python Cookbook Message-ID: <915a998f.0106040825.64991b57@posting.google.com> Frank Willison of O'Reilly has appealled [1] to the Python community to rate and submit recipes for the Python Cookbook [2]. My impression is that what is wanted is how to do certain things in Python, rather than a book of algorithms that happens to use Python as its demonstration language. I think O'Reilly's own Perl Cookbook [3] might be a good source of ideas for the sorts of tasks that the recipes could address. I'll try to tackle a few myself, probably in the areas of string processing and web programming. Do others want to tackle other areas? [1] http://www.oreilly.com/frank/ [2] http://aspn.activestate.com/ASPN/Python/Cookbook/ [3] http://www.oreilly.com/catalog/cookbook/toc.html Hamish Lawson From reageer.in at de.nieuwsgroep Wed Jun 13 08:16:19 2001 From: reageer.in at de.nieuwsgroep (Rene Pijlman) Date: Wed, 13 Jun 2001 14:16:19 +0200 Subject: VI References: Message-ID: "Pilgrim" schreef: >Can someone tell me what "vi" is for a text editor to work with python? Its primitive, but very powerful :-) >Where can I get this? http://www.thomer.com/thomer/vi/vi.html -- Vriendelijke groet, Ren? Pijlman Wat wil jij leren? http://www.leren.nl/ From ullrich at math.okstate.edu Thu Jun 7 10:55:40 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Thu, 07 Jun 2001 14:55:40 GMT Subject: random References: <3b1cf00f.5441109@nntp.sprynet.com> <3b1e43f4.1661099@nntp.sprynet.com> Message-ID: <3b1f921f.3078704@nntp.sprynet.com> On 6 Jun 2001 18:58:55 GMT, urpala at ampeeri.ee.tut.fi (Uoti Urpala) wrote: >In article <3b1e43f4.1661099 at nntp.sprynet.com>, David C. Ullrich wrote: >>>requirements of the results. The encoding must allow "arbitrary binary >>>data" to be included. > >>consisting of all 0's terminated by a 1. Assunming that >>"arbitrary binary data" means only finitely much binary >>data that's no problem. > >I meant that more literally: the encoding must allow binary data to be >included "as is", so that a constant of x bits takes no more than x >bits of program space. > >>What I'm trying to track down is what does make the proof work. >>In particular what I'm curious about is whether the requirments >>that make the proof of the randomness work are really all that >>natural, or whether they were just chosen to make the randomness >>come out right in the end... > >The requirements aren't all that strong. Basically, "self-delimited >turing-complete program with binary data" is enough. You first read >the program (with whatever self-delimited computable encoding, one >where the first 1 bit terminates as in your example above is OK). The >program can then read the following bits. "A random program >terminating" can then be defined as "select an infinite stream of >random bits; take the (if any) prefix that is a self-delimited >encoding; whenever the program reads a bit, give it the next one from >the stream; does the program ever halt?". Ok. The other day defining the silly syntax I was forgetting about the "input stream" to the "program". There's no problem modifying what I said to have one of those, exactly as you say here: The first 1 marks the end of the "program" and the rest of the tape is input to the program. Satisfies everything you've said except for the requirement that arbitrary binary data be included in the program with a minimial number of bits. >To work with finite programs-with-data in the above scenario, you can >define that a program trying to read more data than there is or trying >to halt before reading all the data fails (doesn't halt) - it wasn't >self-delimiting, as it didn't know the total length. This makes a lot more sense (to me, today) than a certain sentence of Chaitin's that was intended to say the same thing. Thanks. >he >must-read-all-data part allows simple calculation of lower bounds for >Omega, as it fixes the problem of the total being greater than 1 (no >halting program can be a prefix of another). No halting program can be a prefix of another is exactly the first thing I realized about what must be required to make the thing work at all. Now the programs are the leaves of a certain binary tree, and any infinite binary tree can be taken as the encoding (as long as there are infinitely many leaves and the branches of infinite length form a set of measure zero). Then I realize that there is a simple binary tree that makes this scheme reduce to the one where the n-th bit of Omega is 1 iff the n-th TM halts. Leading to the question of just what the rules are to get Chaitin's magical results... Preciate the clarification. When we have statements about how "the probability that a random program terminates has certain properties" and it turns out that this depends very strongly on which definition of "random program" we're using one wonders exactly what the "rules" are. (If it were true just of one particular encoding that would be silly. If it were true of _any_ encoding, which is what I thought for a day, that would be not silly at all. When one finds that it is _not_ true for just _any_ encoding but one sees credible people saying it is then one _really_ wonders what the rules are. If the requirements are reallt just as above then I suppose I agree the requirements are not that strong.) >Uoti Urpala David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From skip at pobox.com Fri Jun 1 11:43:52 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 1 Jun 2001 10:43:52 -0500 Subject: docstrings, invention there of In-Reply-To: <200106010601.IAA08860@boris.cd.chalmers.se> References: <200106010601.IAA08860@boris.cd.chalmers.se> Message-ID: <15127.47160.602225.351685@beluga.mojam.com> Laura> We think we were the first people to ever a) put the doc in the Laura> code b) make the interpreter extract them. Hmmm... Emacs Lisp has had doc strings for ages and ages. I'm fairly certain it was before 1990. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From phd at phd.fep.ru Wed Jun 27 09:38:32 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Wed, 27 Jun 2001 17:38:32 +0400 (MSD) Subject: Python embebbed with Oracle SQL*Plus In-Reply-To: Message-ID: On 27 Jun 2001, Olav wrote: > Generally, what is the best way to script Oracle with > Python DCOracle or cxOracle. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From aleaxit at yahoo.com Thu Jun 28 08:34:57 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 28 Jun 2001 14:34:57 +0200 Subject: Embedding References: <3b305ce7@news.actrix.gen.nz> <9gq7lq0lvl@enews1.newsguy.com> <3b32f3fe@news.actrix.gen.nz> Message-ID: <9hf89i02ovd@enews1.newsguy.com> [posted and mailed, since a few days have passed] "Mark Rowe" wrote in message news:3b32f3fe at news.actrix.gen.nz...: > Thanks for the reply. I was actually most interested in implementing it in > C. I still cant seem to find the methods to call :) ... > > > has me stuck. I would like the user to be able to enter some python > code > > > containing functions, then at a later point execute one of these > functions > > > by name. I'm not really sure what i need to do for this to work > > > > You don't have to do much. Collect the source code that the user > > enters (e.g. in a text-entry window in a GUI?), into one big Python > > string (make sure there's a '\n' at the end:-), This part you're presumably doing in C, then? Anyway, if you have a C string and want to make a Python one, that's what various Python C API functions such as PyString_FromStringAndSize are for. But you don't need to do this, since PyObject* Py_CompileStringFlags(char* string, char* filename, int start, PyCompilerFlags* flags) already does exactly what you need for the next step, and, as you see, as its first argument, the string to be compiled, it takes a char* already (a C-kind of string). Of course the "filename", just like for callable-from-Python builtin 'compile', is used just to build error messages, 'start' is Py_file_input for the 'exec' kind of compilation, and as for 'flags' you can pass it as 0 (that is what builtin compile does, unless nested-scopes are an issue). So, we've taken care of the next step: > > feed it to builtin > > function compile() and make sure to catch a SyntaxError that will > > be raised if the code has syntax errors, and let the user know. If except for the "catching errors" part which is done by checking the returned PyObject* -- if 0 some exception was raised, and you can find out which one, &c, with the usual PyErr_* family of functions. OK so far? Well then: > > there are no errors, compile() returns a code-object. Stash it away, > > and at any later time you can pass it to statement 'exec' (you may > > want to pass specific dictionaries to control execution namespaces). > > Again, be sure to catch and report any exceptions that may arise. PyObject * PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals) is the C-API equivalent of eval() and exec. > > This is all at the Python-level, where it's easiest, but of course there > > is equivalent functionality accessible from the C API, too -- it's just > > more work (as usual for C vs Python:-) so, the more you can do in > > Python, the merrier, no?-) There's also the little detail that Py_Compile* and PyEval_* are among the not-well-documented-if-at-all parts of the Python/C API, but fortunately the sources of Python itself are very clear, so it should be no big problem with some experimentation to get where you want to be. But still, of course, it holds that doing it in Python, as usual, is *MUCH* less work:-). Alex From paulp at ActiveState.com Sun Jun 17 19:02:41 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sun, 17 Jun 2001 16:02:41 -0700 Subject: graceful version detection? References: <3B2D2F44.50007@red-bean.com> Message-ID: <3B2D3711.91190F4B@ActiveState.com> Ben Collins-Sussman wrote: > > Please excuse me if this is a common newbie question; I didn't find it > in the FAQ or tutorial. > > If I write a python script that uses 2.X features, and then run it with > a 1.X interpreter, I get a bunch of exceptions. Presumably this happens > during the initial byte-compilation. > > I'd like the script to instead gracefully print: > > "Sorry, this program requires Python 2.0 or higher." I don't have a 1.x parser around to try this but I'm pretty confident of it. If it works, maybe you could submit it to the Python cookbook. Move your real code to a module ("let's call it 'main'") Then make a "driver" program that users invoke: try: import main except SyntaxError: print "This program requires Python 2.0" -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From tim.one at home.com Fri Jun 29 15:56:21 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 29 Jun 2001 15:56:21 -0400 Subject: PEP scepticism In-Reply-To: <3dbsn71iac.fsf@ute.cnri.reston.va.us> Message-ID: [Tim] > So what do you do about the curious disconnect between supply > and demand in Open Source projects? [Andrew Kuchling] > Beats me. This is nothing new, in that interesting tasks get worked > on, and boring ones don't. It's too glib: the canonical example is CPAN, and is there some reason CPAN is *not* "boring" in the Perl world but is in the Python world? Doubt it. People have different interests, and Python just doesn't seem to attract those with really boring interests . > I haven't updated the bookstore in a while, or tried to kick the > catalog-sig into life, or released various bits of software sitting > on my disk, because such tasks would be pretty boring, and I have > more entertaining possibilities open to me. The real question is why someone else hasn't popped up to do these things. This isn't a question about you (or me, or any of the rest of the usual masochists), it's about why Python hasn't attracted hundreds of Andrews. > Greg Ward moved back to Montreal, and now does practically no hacking > or writing in his spare time at all. Well, of course -- there's also an automatic IQ shift of 50 points whenever crossing the US-Canadian border . although-i-won't-say-in-which-direction-ly y'rs - tim From philh at comuno.freeserve.co.uk Fri Jun 29 09:34:51 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 29 Jun 2001 14:34:51 +0100 Subject: PEP scepticism References: <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> Message-ID: On 28 Jun 2001 14:23:17 -0400, Andrew Kuchling wrote: > >I've noticed that in online forums, people now rarely beat up on >Python for the language itself, except for the old reliable >indentation knee-jerk reaction. Instead people write about how >convenient CPAN makes it to find modules, or how useful the XML >modules are, or how EJB lets them write elaborate business systems. I >don't think improving Python the language will win new converts at >this point; improving the standard library, development environments, >or the documentation is more likely to bear fruit. Good point. -- ==== Philip Hunt == philh at comuno.freeserve.co.uk ==== Want to stop global warming? Do you support the Kyoto Treaty? Then boycott Esso (ExxonMobil in the USA). See www.stopesso.com for details. From the_cpu_fan at yahoo.com Thu Jun 21 23:59:22 2001 From: the_cpu_fan at yahoo.com (Alex M) Date: Fri, 22 Jun 2001 11:59:22 +0800 Subject: curses webbrowser modules Message-ID: <3B32C29A.67E099F5@yahoo.com> Somewhere within my curses app I have this bit of code: session.myprofile.browser.open(session.url, 1) The above line of code works great but Netscape ruins my windows when it decides to output some error message. eg error messages with regards to fonts. Rewriting/refreshing the damaged windows doesn't help. I have worked around this problem by modifying my .Xdefaults file, adding the following lines to it: .netscape*useStderrDialog:False .netscape*useStdoutDialog:False But is there any other way of suppressing browser error messages so it doesn't ruin my curses windows? Thanks. Alex Mercader the_cpu_fan at yahoo.com From root at rainerdeyke.com Sun Jun 24 19:33:24 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Sun, 24 Jun 2001 23:33:24 GMT Subject: Is this a true statement? References: Message-ID: <8NuZ6.362378$oc7.42924874@news2.rdc2.tx.home.com> "Steven D. Majewski" wrote in message news:mailman.993411997.2625.python-list at python.org... > I don't retract the statement that the fact that you can compute > any computable function in any Turing complete does not mean that > you can *DO* the same thing in any language. I agree here. To a program, "doing something" means "interacting with the outer world". It is a given that, if a program can receive the proper input from the world, it can calculate (but not necessarily perform) the proper output. Python includes many ways of interacting with the outer world in its standard library, but C++ usually includes more. Python can sometimes get around this by outputting machine code, but only if the problem is defined in a way that allows this. To a programmer, however, "doing something" generally means structuring code in a certain way. Programming is about putting all information in only one place. Variables are one tool for doing this: print 117 print 117 # vs. a = 117 print a print a Functions are another: print 117 print 117 # vs. def f(): print 117 f() f() >From this perspective, there are a couple of areas where C++ is more powerful, but they are eclipsed by the many areas where Python is more powerful. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From chrishbarker at home.net Mon Jun 18 15:52:27 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 18 Jun 2001 12:52:27 -0700 Subject: csv-0.3 released References: Message-ID: <3B2E5BFB.F0EAB859@home.net> Dave Cole wrote: > So for all of you NT heads who OK, I'm confused: A) why NT-heads? on the web page it staes: The installation has been tested on NT and Linux. B) > were just hanging out for a fast CSV > parser in Python - here it is: on your page: "On my Athlon 700, the string split takes 1.451s and the CSV parser takes 1.671s. " This appears to mean that the CSV parser is slower that string.split, and as far as I can tell, does pretty much the same thing. What am I missing? -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From whisper at oz.nospamnet Wed Jun 13 19:45:50 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 13 Jun 2001 23:45:50 GMT Subject: PEP 259: Revise to remove context-driven magic from print References: <486de2.0106131406.5c0cbef9@posting.google.com> Message-ID: <9g8tve$8ft$0@216.39.170.247> In article <486de2.0106131406.5c0cbef9 at posting.google.com>, robin900 at yahoo.com says... > Feedback, please. If you all are positive about the proposal below, > I'll work it up into a new PEP. > > Summary: > > PEP 259 should be reworked to remove contextual magic from print > statement, which was the main demand made by the Python community when > *rejecting* the PEP. Then it could be resurrected from rejection. > > Opinions: > > 0) We don't need another built-in function that echoes what print > does. Please. > > 1) We can't get rid of "print". It is a very common idiom in many > languages. > > 2) Python coders learn to avoid print because a print statement's > behavior changes with a run-time context that the coder cannot > necessarily control. To rehabilitate print, remove the context magic. > > 3) Whenever I have a string of bytes that I wish to write to > sys.stdout, without any formatting magic such as space characters or > newlines, I cannot use the print statement, because it offers me no > way to "turn off" all the formatting magic. Thus I am required to > absorb the conceptual overhead of the sys module, sys.stdout and > "standard output", file objects, and the write() method, just so that > I can avoid having Python prepend a space character to my output in > certain cases. For a novice Python coder, that sucks. > > 4) "softspace" has always seemed to me quite a lame thing to be part > of the official file object API. What should file objects care about > some cheesy report-printing operation like "print"? > > 5) The "am i at the start of a line context" only helps me when I want > > print 1,2, > print 3,4, > print 5 > > to be equivalent to > > print 1,2,3,4,5 > > ...and I have never exploited that feature of Python print, even in > lazy report scripting, the application for which the feature seems to > be intended. > > 6) print-users and write-users operate at two different conceptual > levels. print is a novice feature, for coders who may not yet know of > sys, let alone "stdout" or even the concept of standard output. print > is also a pretty formatting feature, so that the coder does not have > to understand string concatenation, string format strings, string > conversion, or even the newline escape sequence. Thus I think that it > is OK for print and write() to have feature overlap, without violating > the Pythonic principle of "there should be only one way to do it". > > Proposed "new" PEP 259 > --------------------------------- > > 1) softspace attribute of file objects now ignored by print statement > (and rest of Python core, if applicable). print statement no longer > cares about "am i at the start of a line" context. Instead, the print > statement writes the same bytes every time to the file object. If the > file object wants to play softspace-style games, it can track its own > context. Thus any write operation to the file object affects softspace > context if the file object wishes to implement softspace context. > However, Python core no longer cares about the softspace attribute, > and no longer bothers to read it nor call softspace API functions. > "softspace behavior" then becomes like any other encapsulated behavior > of a stream writer, such as zlib compression or similar. If the file > object wants to do that, fine, but callers to write() such as print > are appropriately ignorant of it. > > 2) When commas separate expressions as in "print 'a','b','c'", the > print statement writes a single space character " " for each comma. > > 3) Just to repeat from 1): softspace has no effect any longer. print > will never print a leading space character for any statement "print > foo". > > 3) If the print statement ends in a trailing comma as in "print > 'a','b','c',", the trailing comma means "do not print either a final > space character or a final newline character": "print 'a','b','c'," > prints "a b c". And "print 'a',; print 'b'" prints "ab\n", not "a > b\n". > > 4) If the print statement does not end in a trailing comma as in > "print a,b,c", the print statement will print a single newline > character after printing the result of all expressions: "print a,b,c" > prints "a b c\n". The statement "print", with no printing operands, > prints a single newline character. > > 5) It is suggested that the values for "space separator" and "newline" > be system-dependent, settable at run-time, and available in modules > sys or os. Your feedback is welcome on this issue. > > It is *not* suggested that file objects take on this aspect of print > behavior, such as by implementing a method print(self, items, > print_newline=1, softsep=' ', linesep='\n'), and if not implemented, > falling back to stream.write(string.join(' ', map(str, items)) + > "\n"). Again, print is not important enough to demand attention from > designers of file-like objects. > > Examples > ------------ > > 1) Just print a line with a newline at end, without messy newline > escape: > > print 1 > > 2) Print some stuff, and let commas put in nice separating spaces: > > print 1,2,3 > > 3a) Print some stuff with nice spaces, but don't print a newline. Then > continue with another print statement, making sure that nice spaces > separate all strings on the same line: > > print 1,2,3, > print "",4,5,6 > > (This is the workaround for code that exploits the current softspace > context feature for "lazy report printing", but does the print > statements in an order clear from the source code. This way, current > lazy scripts can avoid code breakage with minor edits.) > > 3b) Print some stuff with nice spaces, and always make sure that when > you print with a trailing comma, that there is always a nice space > separating your strings in case you issue another trailing-comma print > statement: > > print a,b,c,"", > > (Second workaround, for code that wants to print at will, without the > coder having to think about things previously printed since the last > newline. Only tradeoff: if the code wishes to end lines with an empty > "print", the output lines will have trailing spaces, which changes the > return value of split() on the line.) > > 4) Print a string of bytes, with no spaces or newlines added: > > print byte_string, > > 5) Print a series of objects with no space separators or newline, > accepting the fact that string formatting has a performance cost: > > print "%s%s%s" % (a,b,c), > > 6) Print a list of objects with no space separators or newline, > without string formatting cost, but with iteration cost: > > for i in a,b,c: print i, > # or, to echo a file to sys.stdout... > for x in open('foo').readlines(): print x, > > 7) Write bytes to a file object because you hate print: > > fileobject.write(str(object)) > > > Implementation Notes > ----------------------- > > - Something has to change in the bytecode to achieve the above. > PRINT_ITEM and PRINT_ITEM_TO could take an oparg indicating whether to > print a trailing space. Or new opcodes, PRINT_ITEMS and > PRINT_ITEMS_TO, take an oparg indicating number of items on the stack > to pop and print in sequence, printing a space between each. Or else > two new opcodes PRINT_ITEM_SPACE and PRINT_ITEM_TO_SPACE, which would > suck. > > - I don't see a problem in having an opcode like PRINT_ITEMS, which > requires that all of the expressions to print are evaluated and put on > the stack, and the print statement itself (minus the PRINT_NEWLINE) is > a single opcode printing *all* of the items. If this is a problem, > please enlighten me. (At the very least, it avoids all those > DUP_TOP/ROT_TWO combinations preceding every PRINT_ITEM_TO.) > > - In fact, it might be best to refactor all print operations into a > single opcode, PRINT_STMT, which takes an oparg indicating a vector of > (num_items_on_stack, output_stream_also_on_stack_boolean, > print_newline_at_end_boolean). You still get 14 bits to hold the > amount of objects to print; we perhaps could bring in EXTENDED_ARG if > we ever found the need to handle more than 2**14 expressions in a > print statement in source code. :) > > All existing print opcodes can stick around unchanged, even with the > softspace crap. PRINT_STMT will ignore all softspace crap. Or at > least, while softspace must still be supported, PRINT_STMT will ensure > that softspace is set to false after it completes printing. > > - "from __future__ import print_stmt" can handle the migration > process. > > - Two system values, represented by os.softsep and os.linesep, or > sys.softsep and sys.linesep, or whatever you think is good, could be > used as the run-time values of the "space character" to separate print > items and the "newline" character to terminate a line, respectively. > These values, if changed at runtime by assigning to sys.xx or os.xxx, > can be stored as system globals a la Py_None and others, for speed, to > avoid constant attr lookups on sys or os. > The usual nag applies: changing the expected behavior of print will break too much code. I suggest raw_print instead for "unhelped" printing. Examples: a = "foo" b = "bar" raw_print foo bar ->> foobar #no newline! raw_print foo,bar ->> foo bar #no newline! raw_print \n #newline! in quotes if needed. No reason at all that both print and raw_print couldn't be sugar for a single PRINT bytecode that took some arguments like (conceptually) PRINT -nonl "foobar" #or nl=0 if one prefers PRINT -nonl "foo bar" and PRINT "foo bar" #absence of -nonl implies add a newline For the current implementation I would guess that the current print already reduces it's arguments to a single string before calling PRINT. hmmmm.. come to think of it, the nl could be buried in the string passed to a relative dump PRINT that just prints the string given with spaces/nl/whatever already done. Regards, Dave LeBlanc From chemacortes at wanadoo.WIPE_ME.es Thu Jun 28 14:48:58 2001 From: chemacortes at wanadoo.WIPE_ME.es (Chema Cortes) Date: Thu, 28 Jun 2001 20:48:58 +0200 Subject: Mapping with unicode strings buggy the format operator % Message-ID: <1evqawi.p7ke9c1e51rkkN@[10.35.244.9]> Hi to all: I have a dictionary with unicode strings as keys. Formating it with the format operator % raise errors when the key cannot convert into a non-unicode string. I try to surround the error, but the only thing I can do is not to use unicode keys in dictionaries. I supose that bug is caused because the format operator use the re module, not the sre (with unicode support). Here is the buggy code: >>> d={ "a?o":2001 } >>> "%(a?o)4d" % d '2001' >>> d={ u"a?o":2001 } >>> "%(a?o)4d" % d # KeyError: a?o >>> u"%(a?o)4d" % d # KeyError: a??o But this code is ok: >>> d={ u"mes": 6} >>> "%(mes)2d" % d ' 6' >>> u"%(mes)2d" % d u' 6' Thanks, -- Chema Cortes (chemacortes at wanadoo.es) Linux User #142755 - SuSE Linux 7.1 ZARALINUX http://zaralinux.org/ From greg at cosc.canterbury.ac.nz Wed Jun 20 01:55:28 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 20 Jun 2001 17:55:28 +1200 Subject: Suggested amendment to PEP 255 References: Message-ID: <3B303AD0.1884E173@cosc.canterbury.ac.nz> Tim Peters wrote: > > Who would this help? Seriously. There's nothing special about a generator > to a caller, except that it returns an object that implements the iterator > interface. What matters to the caller is irrelevant here. We're talking about what matters to someone writing or reading the implementation. To those people, there is a VERY big difference between a regular function and a generator-function -- about as big as the difference between a class and a function! In fact, a generator-function is in many ways much more like a class than a function. Calling a generator-function doesn't execute any of the code in its body; instead, it creates an instance of the generator, much like calling a class creates an instance of the class. Calling them "generator classes" and "generator instances" would perhaps be more appropriate, and more suggestive of the way they actually behave. The more I think about this, the more I agree with those who say that overloading the function-definition syntax for defining generators is a bad idea. It seems to make about as much sense as saying that there shouldn't be any special syntax for defining a class -- the header of a class definition should look exactly like a function definition, and to tell the difference you have to look for some subtle clue further down. I suggest dropping the "def" altogether and using: generator foo(args): ... yield x ... Right from the word go, this says loudly and clearly that this thing is *not* a function, it's something else. If you haven't come across generators before, you go and look in the manual to find out what it means. There you're told something like Executing a generator statement creates a special callable object called a generator. Calling a generator creates a generator-instance, which is an iterator object... [...stuff about the "yield" statement...] I think this is going to be easier to document and lead to much less confusion than trying to explain the magic going on when you call something that looks for all the world like a function and it doesn't execute any of the code in it. Explicit is better than implicit! -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From bos at hack.org Sun Jun 17 15:50:20 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Sun, 17 Jun 2001 21:50:20 +0200 Subject: list.sort() References: <3B2CEBF1.CCF5377D@hack.org> <9givg3$lfd$2@s1.uklinux.net> Message-ID: <3B2D09FC.EAB8BDD2@hack.org> Charlie Dyson wrote: > It would be better if it sort **returned** the results, instead I have to > do: > keys = x.keys() > keys.sort() > > That's one extra line of code!!! Indeed. That's exactly my point. -- Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From simon at callan.demon.co.uk Fri Jun 1 03:06:58 2001 From: simon at callan.demon.co.uk (Simon Callan) Date: Fri, 01 Jun 2001 08:06:58 +0100 Subject: I had a thought ... (I know, call the newspapers). References: <3B172894.9B64F46F@my.signature> Message-ID: <2e0dae834a.simon@satin.callan.demon.co.uk> In message <3B172894.9B64F46F at my.signature> Greg Ewing wrote: > Roman Suzi wrote: > > > > my = 0.02$ > > No, no... for consistency with other numeric literals, it should be > > my = 0$0.02 > > :-) I suppose you should also allow for proper internationalization of applications, and support other currencies such as the Canadian dollar, UK pounds, etc, plus automatic conversion between the currencies using the appropriate exchange rates. At least things will be easier next year, when a lot of European countries dump their currency for the Euro. Simon -- http://www.callan.demon.co.uk/simon/ From dsh8290 at rit.edu Sat Jun 9 10:48:28 2001 From: dsh8290 at rit.edu (D-Man) Date: Sat, 9 Jun 2001 10:48:28 -0400 Subject: return from finally clause In-Reply-To: ; from sholden@holdenweb.com on Fri, Jun 08, 2001 at 09:16:43PM -0400 References: <9fr8u3$gj9$01$1@news.t-online.com> <9frdgk$pnd$1@news.mathworks.com> Message-ID: <20010609104828.A21215@harmony.cs.rit.edu> On Fri, Jun 08, 2001 at 09:16:43PM -0400, Steve Holden wrote: | "Joshua Marshall" wrote in message | news:9frdgk$pnd$1 at news.mathworks.com... | > "J?rgen Hermann" wrote: | > | > > That means that if you (accidently?) return within a finally clause, you | > > effectively eat the exception. This should be documented, or fixed. | > | > That's unpleasant. I hope it's a bug. | > | Well, I think we can agree that there's a certain inconsistency in | returning from a function with an exception active like that. So most of all | it's a programming error. What action would be best? Raise another exception | when the "return" is executed? There is no exception acvite -- you have handled it and now want to return a value instead of propagating the exception. -D From cjc26 at nospam.cornell.edu Tue Jun 19 23:37:09 2001 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Wed, 20 Jun 2001 03:37:09 GMT Subject: Partially evaluated functions References: Message-ID: * Neil Schemenauer menulis: | This works in 2.1 (a little more magic is needed for older | Pythons): | | >>> from __future__ import nested_scopes | >>> def conv(b, c): | ... return lambda a: (a + b) * c | ... | >>> faren2cel = conv(-32., 5./9) | >>> faren2cel | at 0x810f45c> | >>> faren2cel(10) | -12.222222222222223 | >>> faren2cel(-40) | -40.0 Or you could do faren2cel = lambda a: conv(a, -32.0, 5.0/9) if you didn't want to redefine conv(). Another way to do it would be to create a class which can keep track of which arguments have already been assigned to, something like this: import inspect class Schoenfinkelizer: def __init__(self, func, **kwargs): self.func = func self.args = {} # get list of argument names self.argnames = inspect.getargspec(func)[0] for arg in self.argnames: self.args[arg] = kwargs.get(arg, None) def __call__(self, *remainingargs): args = [] for arg in self.argnames: if self.args[arg]: args.append(self.args[arg]) else: args.append(remainingargs[0]) # hopefully the right number of args was passed! remainingargs = remainingargs[1:] return apply(self.func, args) faren2cel = Schoenfinkelizer(conv, b=-32.0, c=5.0/9) faren2cel(-40) But that would be overkill..:) -- Cliff Crawford http://www.sowrong.org/ "Cliff, you're a god. I want to bear your child." -- Ed From grante at visi.com Fri Jun 1 14:52:43 2001 From: grante at visi.com (Grant Edwards) Date: Fri, 01 Jun 2001 18:52:43 GMT Subject: docstrings References: Message-ID: <%vRR6.4813$Dd5.2142657@ruti.visi.com> In article , Laura Creighton wrote: >As far as I know we INVENTED the things, on Genesis an LPMUD >(they predate java at any rate who got from us). Actually, 2 >people in this company invented them with one more guy who >isn't part of this company (alas). I was on the other side, >actively opposing their adoption. I was wrong. So 2 people in >this company have already made their significant contribution >to the betterment of humanity. And I nearly became unknown >public enemy number one. You invented embedded documentation? Was this before Donald Knuth came up with his tangle/weave stuff in the early 80's? -- Grant Edwards grante Yow! Yow! I'm out of at work...I could go into visi.com shock absorbers...or SCUBA GEAR!! From sandysj at asme.org Fri Jun 1 15:48:23 2001 From: sandysj at asme.org (Jeff Sandys) Date: Fri, 01 Jun 2001 12:48:23 -0700 Subject: How to find the package a module belongs to ? References: Message-ID: <3B17F187.E11F748D@asme.org> I don't fully understand your question, could you give a code sample and show how it fails your expectation. Sasa Zivkov wrote: > > I have a package containing several modules. > Is is possible, within a module, > to say "give me the package I belong to" ? > We use a global variable in each module like this: modname="mymodule" And each function has a function name variable like this: def myfunction(): ftn="myfunction" Then we can use the module and function name for debug and fatal errors: def debug(ftn,txt): sys.stdout.write(string.join([modname,'.',ftn,':',txt,'\n'],'')) sys.stdout.flush() def fatal(ftn,txt): msg=string.join([modname,'.',ftn,':FATAL:',txt,'\n'],'') raise SystemExit, msg > Or, is there a way to access objects defined in __init__.py from > a module without explicitly referencing surounding package by name ? > > -- Sasa I think this is our solution to the problem that you raise. It would sure be nice to pull this information from some secret variable without having to explicitly name them. Thanks, Jeff Sandys From laurent.szyster at q-survey.be Sat Jun 23 19:08:43 2001 From: laurent.szyster at q-survey.be (Laurent Szyster) Date: Sun, 24 Jun 2001 01:08:43 +0200 Subject: stumbled on python iif() equivalent, at last References: <3B34B8DE.67D97C24@q-survey.be> Message-ID: <3B35217B.3F240C@q-survey.be> Robin Becker wrote: > > In article <3B34B8DE.67D97C24 at q-survey.be>, Laurent Szyster > writes > >so, there's an iif (condition, is_true, is_false) python equivalent: > > > > >>> 1 and 'c' or 'o' > > 'c' > > >>> 0 and 'c' or 'o' and of course, > > 'o' > >Laurent > yes, but what if the true value is actually a python false eg > >>> a='' > >>> b='B' > >>> c=1 > >>> c and a or b > 'B' > >>> > > to avoid this you need > >>> (c and (a,) or (b,))[0] > '' thanks Robin. From treaves at silverfields.com Mon Jun 18 13:18:04 2001 From: treaves at silverfields.com (Timothy Reaves) Date: Mon, 18 Jun 2001 13:18:04 -0400 Subject: Problem running python program? Message-ID: <3B2E37CC.9070004@silverfields.com> When I run a couple different programs, the following is what happens. Do I have python setup incorrectly? Thanks. [treaves at double treaves]$ export PYTHONHOME=/usr/lib/python2.1/ [treaves at double treaves]$ gnucash Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] 'import exceptions' failed; use -v for traceback Warning! Falling back to string-based exceptions 'import site' failed; use -v for traceback Fatal Python error: couldn't import os Aborted (core dumped) [treaves at double treaves]$ glimmer Loading font from preferences. Loading font from preferences. Loading font from preferences. Loading font from preferences. Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] 'import exceptions' failed; use -v for traceback Warning! Falling back to string-based exceptions 'import site' failed; use -v for traceback Fatal Python error: could not import _gtk Aborted (core dumped) From mlh at idi.ntnu.no Thu Jun 28 17:27:12 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Thu, 28 Jun 2001 23:27:12 +0200 Subject: New project: anygui Message-ID: <9hg7fg$dmg$1@tyfon.itea.ntnu.no> Hi! This is an attempt to revive the efforts of making a "standard" Python GUI. I realise that standardising one as preferable to others might not be desirable, and that is not the purpose of this project. The purpose is to build a pure Python package called anygui which will function in a manner similar to anydbm in that it will look for existing backends, and use what is available. A simple API must be decided on which will be compatible with all back-end candidates, somewhat in the spirit of Sping and Piddle. Therefore, this will not be mean as a replacement for these back-ends, merely a simple front-end. I suggest using Greg Ewing's Python GUI API as a starting-point: http://www.cosc.canterbury.ac.nz/~greg/python_gui/ For a first release, a subset may be usable. Backends that (at least) should be supported: - Tkinter - wxPython - Java (AWT and/or Swing) ... and hopefully many others. (Those of you out there who have a package you love may want to step up and make it compatible with anygui... :) Greg is himself working on an X-windows implementation of the API. The project is available at: http://sourceforge.net/projects/anygui A mailing-list called anygui-devel has been set up and should be activated within a matter of hours. All developers and other interested individuals are welcome. The GUI SIG is no more - but it is my opinion that Python needs a standard GUI package, even if it is a simple one (perhaps _especially_ if it is a simple one). -- Magnus Lie Hetland http://www.hetland.org "Reality is that which, when you stop believing in it, doesn't go away." -- Philip K. Dick From guido at digicool.com Wed Jun 20 23:51:45 2001 From: guido at digicool.com (Guido van Rossum) Date: Wed, 20 Jun 2001 23:51:45 -0400 Subject: [Python-iterators] RE: Meta: PEP discussion (was Re: PEP 255: Simple Generators) In-Reply-To: Your message of "Wed, 20 Jun 2001 22:09:37 EDT." References: Message-ID: <200106210351.XAA27769@cj20424-a.reston1.va.home.com> > Heh. If you had only finished *your* generator implementation 9 years ago > instead of getting sucked into the continuation pit, we could be using > > sdm f(i): > suspend i+1 > > today . Oh, I like it. We should be able to reward "honorary keywords" to certain individuals. My candidate would be to make "tabnanny" a keyword; it would be a directive to turn all inconsistent indentation errors into yield statements... --Guido van Rossum (home page: http://www.python.org/~guido/) From sholden at holdenweb.com Thu Jun 14 20:26:10 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 14 Jun 2001 20:26:10 -0400 Subject: Any other Python flaws? References: Message-ID: <#72#QIT9AHA.262@cpmsnbbsa09> "Andrew Kuchling" wrote in message news:mailman.992543370.22014.python-list at python.org... > I was updating my page of possible Python design flaws > (http://www.amk.ca/python/writing/warts.html) last night to take 2.1 > into account. 2.1's nested scoping fixes one major wart, and the > other major one, the type/class dichotomy, might get fixed in 2.2 if > the descr-branch in CVS turns out well. (It's neat that the two > largest ones may both get fixed before 2001 is out.) > > That leaves the remaining warts as minor wibbling about 'do' > statements, print >>, and the like. Are there any other flaws that > should be added? > Despite the fact that our Fearless Leader and BDFL has already revered himself once on this issue, I'd like to see strict syntactical equity between function definitions and class definitions, which is to say that a class with no superclasses should be declarable as: class myClass(): pass Surely this can be made an *optional* syntax. In that case, no existing code breaks and I can't see the harm .. except possibly to Guido's pride, and I can think of two reason why that wouldn't count. 1. Guido has shown a remarkable lack of ego in the development process (as far as I know of it) thus far, and probably wouldn't really care, and 2. If 1. is false, the time machine could be used to ensure that the interpreter had never done anything else. regards Steve From sill at optonline.net Tue Jun 12 17:56:07 2001 From: sill at optonline.net (Rainy) Date: Tue, 12 Jun 2001 21:56:07 GMT Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> <9g5h4c01rba@enews2.newsguy.com> <9g5ink015sb@drn.newsguy.com> Message-ID: On 12 Jun 2001 10:15:32 -0700, thinkit wrote: > In article <9g5h4c01rba at enews2.newsguy.com>, "Alex says... >> >>"thinkit" wrote in message >>news:9g5d3p0f0p at drn.newsguy.com... >>> humans should use a power of 2 as a base. this is more logical because it >>> synchs with binary, which is at the very heart of logic--true and false. >>it is >>> more natural perhaps, to use decimal-- >> >>Perhaps. It seems to have been used by most cultures throughout >>the world, though far from all. Octal was used by some American >>tribes, and some linguists believe they find decisive traces in >>Indo-European and Japanese to show that their common root (so- >>called Nostratic) used octal. Vigesimal was clearly popular >>recently enough that French still says "seventy" as "sixty and >>ten", "eighty" as "four twenties", "ninety" as "four twenties >>and ten". Sexagesimal, used by Sumer and Babylonian astronomers >>(they used decimal for most computation), has left indelible >>traces in our time-measurement (60 seconds to a minute, 60 >>minutes to an hour) and angle-measurement (ditto). >> >>> but logic should, and will, win out. >> >>Perhaps. It never did, so far, but it sure seemed to for LONG >>times. For example, Parmenides used logic to prove ZERO was >>unusable nonsense (his disciple Zeno, not to be confused with >>the founder of Stoicism of course, bult beautiful paradoxes to >>illustrate his master's thesis), and thus did logic manage to >>make arithmetic almost unusable for 1,500 years in the West. >> >>Fortunately, in the end, the Eastern mystics won out, putting >>logic in its place and celebrating the Abra Kad' Abra ("air void >>of air" -- aren't these Sanskrit words STILL the ones that >>come to mind most readily when thinking of a spell of mystical >>incantation?-), Non-Being, the Void at the Core of All, etc, >>etc. At long last, the illogic and absurd Zero got into the >>number system -- eventually, since Practicality Beats Purity, >>its use became universal. Nowadays, of course, the adorers >>of Logic try to sweep THIS little tidbit of the history of >>science and mathematics under the carpet...:-). >> >>I highly recommend in-depth study and comparison of the >>Tractatus Logico-Philosophicus (a genius in his twenties >>trying to fix precisely the conditions in which Logic will >>let us speak) and the Philosophical Investigations (the >>same genius, 30 years later, explaining WHY logic will >>never work as the One True Way of human discourse...). >> >>As eminently NON-logical William Blake had written, "If >>the fool would but persist in his folly, he would become >>wise" -- few logical fools have shown the same persistence >>and greatness as Ludwig von Wittgenstein, to enable them >>to reach the wisdom of mysticism by dint of inflexibly >>consistent application of Logic...:-). >> >> >>Alex > > um...? see, this is exactly what i'm talking about. binary is simple...this is > not. i don't really care about a bunch of old men who wanted to argue over the > number 0. maybe they just got tired of jerking off and decided to spew some > garbage to sound smart and score more chicks. just my guess. Well, since some of them were your fellow 'logic > *' philosophers, this guess is almost comically self-referential ;-) > and i suggest a look at lojban, a logical language. you can learn it without > referring to a bunch of old dead farts. http://www.lojban.org . I don't follow - as opposed to all other languages, which also can and are learned without referring to dead philosophers? If you're a partisan supporter, you're doing a bang up job ;_) -- True sailing is dead - Jim From tim.one at home.com Mon Jun 4 00:46:49 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 4 Jun 2001 00:46:49 -0400 Subject: random In-Reply-To: <3b1a4fe4.1344551@nntp.sprynet.com> Message-ID: [David C. Ullrich, on http://www.cs.umaine.edu/~chaitin/cmu.html] > ... > Very interesting stuff, without a doubt. He wants to say that > his point of view makes incompleteness seems inevitable he > may well be right. But when he gets into statements like > > "there is no reason that individual bits [of Omega] are 0 or 1!" > > it's just too... well I better omit the adjective and just say > that "there is no reason that individual bits are 0 or 1" is not > a mathematical statement amenable to proof. It *sounds* powerful, though . I don't really object, because it conveys *something* of the story in a way that would otherwise be over his audience's head. For example, over the last few weeks we've had several examples on c.l.py of printing the exact decimal value of a machine binary floating-point value with a non-zero fractional part. I don't know whether anyone noticed, but every such example ended, in decimal, with the digit 5. The natural inclination of anyone with even a slight bent toward mathematical thought is to ask "Hmm! Was that just luck, or is there 'a reason' that's so?". With a little thought, and even in the absence of a formal notion of axioms or proof, I expect many people could get close to proving that 5 is no accident -- it must be a 5, "it makes sense", "there's a reason for it". And, indeed, that's the only kind of problem most people get exposed to in school: "prove or disprove". It's at least a minor revelation then that some questions can't be answered that way (by appeal to principle or proof -- "a reason"), that brute force can be the only answer there is. But *phrasing* it as "no reason" is too close to "senseless" for my tastes, so I'm sure it misleads people too. > Preciate the reference - I definitely learned one thing, at least: > > "Now what is the reaction of the world to this work?! Well, I think > it's fair to say that the only people who like what I'm doing are > physicists!" > > Not having studied his stuff or people's reactions to it I thought > it was just me (seriously). (Um: It's _not_ true that mathematicians > don't like his work, I know of plenty of mathematicians who find it > fascinating. What people don't like is his [adjective] claims > about what his work _means_...) I agree: it's the popular presentation, not the work, that people object to. I read that G?del delayed presenting his incompleteness theorem (surely a much greater shock at the time!) because he feared nobody would believe him, so worried over every little detail of the arithmetic coding to make the proof unassailable first. But by all accounts I've read, the ideas behind the proof were compelling the instant logicians heard about them, and despite that it wasn't what they were hoping to hear, and most skipped over the laborious coding details as curious drudgery. Mathematicians are quite calm in the face of crisis . OTOH, G?del kept what he thought his result "meant" to himself. Take someone who learned it from the philosophy dept and another from the math dept, lock them in the same room, and see whether they have *anything* in common . But Rudy Rucker reported that in private conversation, G?del's beliefs were actually closer to the former, that the result had profound implications beyond just pointing out a limitation of formal proof systems. I wish he would have written more about that; at least I won't have the same regret with Chaitin. > The (or in any case _a_) point being things like > > "I think there may be political reasons, but I think there are also > legitimate conceptual reasons, because these are ideas that > are so foreign, the idea of randomness or of things that are true by > accident is so foreign to a mathematician or a logician, > that it's a nightmare! This is their worst nightmare come true! I > think they would prefer not to think about it." > > He insists that the world of mathematics is all upset over his > well-defined but unknowable Omega. If that irritates people what > irritates them is not the well-defined but unknowable character > of those bits, it's the idea that the idea of something being > well-defined but unknowable started with him. It's no big deal, > people have been dealing with "unknowables" for a long time. Wholly agreed. Some people were driven to despair and even suicide by G?del's results at the time. Everything since (and there's been a lot) has been greeted with "Wow -- here's yet *another* thing we can't know. Cool!". the-first-time-was-a-major-surprise-but-that-was-70-years- ago-ly y'rs - tim From danyelf at ics.uci.edu Wed Jun 27 02:39:48 2001 From: danyelf at ics.uci.edu (Danyel Fisher) Date: Tue, 26 Jun 2001 23:39:48 -0700 Subject: Should I use a dictionary? References: <9h91pb$e3k$1@panix6.panix.com> <9h9ckq$nf$1@apollo.csd.net> Message-ID: <9hc2m2$gtf$1@news.service.uci.edu> > >This method should able be very fast if you convert the data to a > >straight int first. > > Thanks. This suits me perfectly. I get the date in the format "2001-01-01 > 13:12", so that would be "200101011312" with no risk for confusion. True. But you may still wish to consider UNIX standard date/time: it will make your data interprable in other contexts, should you need to. (The worst case scenario is that someone, maintaining your code, sees numerical dates and tries to understand them as standard time integers). Any strong reason why you don't use time.strptime()? Danyel, who got caught by this once or twice From tdickenson at devmail.geminidataloggers.co.uk Fri Jun 15 08:04:56 2001 From: tdickenson at devmail.geminidataloggers.co.uk (Toby Dickenson) Date: Fri, 15 Jun 2001 13:04:56 +0100 Subject: Any other Python flaws? References: Message-ID: Andrew Kuchling wrote: >Are there any other flaws that >should be added? I have two: Firstly, the root namespace for 'import' is too big. What does a simple 'import foo' load... 1. a module from the standard library? 2. a module from the current directory? 3. a module from the current package? 4. a module from site-packages? And naturally the answer changes depending on what packages are installed, what files are in the current directory, and what new modules have recently been added to the standard library :-( Secondly, the irregularity when making comparisons between objects of very different types. Sometimes it is consistent but arbitrary, and sometimes it raises an exception. Is (u'a'>'\x80') really more deserving of an exception than ('a'>1)? Personally, I like the C++ solution: comparison operators only work when the order is sensible, and a separate function (in c++ the cmp template) provides a total (but possibly arbitrary) ordering suitable for indexing purposes. Toby Dickenson tdickenson at geminidataloggers.com From kmdr2001 at hotmail.com Fri Jun 1 14:19:59 2001 From: kmdr2001 at hotmail.com (kmdr) Date: 1 Jun 2001 11:19:59 -0700 Subject: Scrolling Multiple Listboxes Message-ID: <829ac386.0106011019.30ba7f6f@posting.google.com> Hi, Does anyone know how to bind multiple listboxes to one scrollbar? ie. how do I scroll multiple listboxes with one scrollbar?...I've tried apply(object, args) methods but have not been succesful. Thanks Kapil From alankarmisra at hotmail.com Wed Jun 6 08:38:44 2001 From: alankarmisra at hotmail.com (gods1child) Date: 6 Jun 2001 05:38:44 -0700 Subject: 2 language applications References: <9fk6ll$4ln39$1@ID-44371.news.dfncis.de> <9fkubv0i48@enews2.newsguy.com> Message-ID: <25b2e0d9.0106060438.1f590e3e@posting.google.com> Why not just have two different dictionaries like: en_messages = {'greetings':'Hello','farewell':'Goodbye','inquiry':'How are you?'} fr_messages = {'greetings':'Bonjour','farewell':'Au revoir','inquiry':'Comment allez-vous?'} then based on locale use the appropriate dictionary. To avoid namespace pollution, and to avoid creating all the dictionaries when all you need is one, you could create a class which could have something like Java does: MessageBundle.setLocale('en') MessageBundle.get('greetings') # returns Hello MessageBundle.setLocale('fr') MessageBundle.get('greetings') # returns Bonjour internally the class could use a dictionary created based on the locale (instead of creating all of them and then assigning) if the messages are few, or rely on a text file (with some caching mechanism) for its data. From phrxy at csv.warwick.ac.uk Thu Jun 21 21:03:48 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Fri, 22 Jun 2001 02:03:48 +0100 Subject: critic this please In-Reply-To: <5zsY6.310479$eK2.62294825@news4.rdc1.on.home.com> References: <5zsY6.310479$eK2.62294825@news4.rdc1.on.home.com> Message-ID: On Thu, 21 Jun 2001, Nick Perkins wrote: [...] > slope_factor = {5: 13.0, # use 13.0, not just 13, to ensure accuracy [...] Well, possibly. I didn't read the code to see what it does, but I guess you might want to read the new floating-point tutorial first (which I haven't read either). John From timr at probo.com Sun Jun 3 00:26:56 2001 From: timr at probo.com (Tim Roberts) Date: Sat, 02 Jun 2001 21:26:56 -0700 Subject: Win32 Debug API Message-ID: It has occurred to me that it would interesting to create a Win32 debugger in Python. The existing debuggers never do exactly what I want; with Python I could easily add extensions and scripting. The Win32 debugging API is not all that complicated. Has anyone created a Python wrapper for the APIs like WaitForDebugEvent, ContinueDebugEvent, DebugActiveProcess, and the symbol manipulation tools in IMAGEHLP.DLL? Barring that, I assume there are several automated tools for creating Win32 API/DLL wrappers. Suggestions? -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From senux at senux.com.NOSPAM Mon Jun 18 01:15:38 2001 From: senux at senux.com.NOSPAM (Brian Lee) Date: Mon, 18 Jun 2001 05:15:38 GMT Subject: Python 2.0 and wxPython 2.0 References: Message-ID: <3B2D8EC1.80202@senux.com.NOSPAM> Doug Farrell wrote: >Hi all, I have Mandrake 8.0 installed on my system and I'm a little >confused. I went to try and install wxPython (which I downloaded from the >website) and the system tells me it's already installed, which is great! >However, I downloaded the demo and I can't seem to run any thing there. Does >anyone know what's going on and how I might fix this? I'm a relative linux >newbie... > >Thanks in advance, >Doug Farrell > Try to import the module on Python prompt to check whether your wxPython is placed correctly or not. $ python Python 2.1 (#1, May 30 2001, 10:38:50) [GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-81)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import wxPython >>> - Brian,. From bobh at hslda.org Thu Jun 7 11:39:21 2001 From: bobh at hslda.org (Robert) Date: 7 Jun 2001 08:39:21 -0700 Subject: WHY is python slow? References: Message-ID: <4a249347.0106070739.3e9b46c7@posting.google.com> > Although it is generally accepted that Python is slower than > Java/Perl/Ruby, I do not accept this either. As a matter of fact there was a recent posting about a site that was comparing a whole slew of languages doing various types of things. Last I checked, Python was ahead of Ruby in almost all and ahead of Perl on a few. Bob From rob at ZOOstation.cc Thu Jun 28 00:57:16 2001 From: rob at ZOOstation.cc (Rob Brown-Bayliss) Date: 28 Jun 2001 16:57:16 +1200 Subject: getopts confusion Message-ID: <993704236.7730.0.camel@ZOOstation.cc> Hi, I have a problem with getopt on a linux system. I have two python progs, one works and one does not. Both import: string, sys, getopt This one WORKS: global verbose, log, upload, download, MasterServer try: opts, args = getopt.getopt(sys.argv[1:], "hvlud", ["help", "verbose", "log", "upload", "download"]) except getopt.error: # print help information and exit: usage() sys.exit(2) for o, a in opts: if o in ("-h", "--help"): usage() sys.exit() if o in ("-v", "--verbose"): verbose = 1 if o in ("-l", "--log"): log = 1 openlog("Syncro",LOG_NDELAY,LOG_DAEMON) syslog(LOG_NOTICE,"Starting Syncronisation run") if o in ("-u", "--upload"): upload = 1 if o in ("-d", "--download"): download = 1 This one FAILS with: Error on option -s: unknown option. Run './gearbox.py --help' to see a full list of available command line options. The code is: global wTree, GearBox, Status, showsum try: opts, args = getopt.getopt(sys.argv[1:], "hsz", ["help", "summary", "zoo"]) print getopt.getopt(sys.argv[1:], "hsz", ["help", "summary", "zoo"]) except Error, msg: # print help information and exit: usage() sys.exit(2) for o, a in opts: if o in ("-h", "--help"): usage() sys.exit() if o in ("-s", "--summary"): showsum = 1 print "ssss" if o in ("-z", "--zoo"): zoo = 1 The one that fails fais for all opts, but if I give args rather than options it passes ok (as in I can print the args out) Any one know whats going on? Any clues are welcome Thanks -- Rob Brown-Bayliss ---======o======--- From raskol at hushmail.com Thu Jun 14 20:27:52 2001 From: raskol at hushmail.com (raskol) Date: Thu, 14 Jun 2001 20:27:52 -0400 Subject: design patterns in python References: Message-ID: <3b2951f4_1@newsfeeds> "Max M?ller Rasmussen" wrote in message news:mailman.992510730.9236.python-list at python.org... > Well ... just don't worry about it. As Python grows the design patterns > that you will have to code by hand in other lower level languages will get > built into Pythons syntax. > > As I see it Python is an implementation of design patterns in a language. That's probably the best description I've heard yet of Python. It's so sweet I want to parse... an 'implementation' : 'realization' of 'design patterns' : 'a description of communicating objects and classes that are customized to solve a general design problem in a particular context' in a 'language': 'Python' (-: raskol @ hushmail.com -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From wware at world.std.com Fri Jun 15 00:51:21 2001 From: wware at world.std.com (Will Ware) Date: Fri, 15 Jun 2001 04:51:21 GMT Subject: Python 2.0.1c1 - GPL-compatible release candidate References: Message-ID: Guido van Rossum (guido at digicool.com) wrote: > With a sigh of relief I announce Python 2.0.1c1 -- the first Python > release in a long time whose license is fully compatible with the GPL Congratulations to you and to Moshe! I know this has been something you've wanted to do for a while. Just to make sure I understand the way GPL coverage extends to derived works, here is what I think is true. Python scripts and programs are not derived works, and are only GPL-ware if their author or copyright holder declares them to be so. C extensions (the kinds of things I get by cutting and pasting from xxmodule.c and xxobject.c) *are* derived works, and the GPL coverage of 2.0.1 would therefore cover them as well, should I choose to distribute them. One thing I don't know is whether *any* C extensions to 2.0.1 would be derived works. If I'm such a Python-extension-writing guru that I don't need to cut and paste from xxobject.c and xxmodule.c, then it seems unlikely my extensions would be derived works, especially if they are legacy things from one of the pre-GPL Python versions. The same would be true of SWIG-generated extensions, I would imagine. But the GPL extends its coverage not only to derived works in the obvious sense, but also to code which is statically linked with a GPL program. If my extensions are statically linked to 2.0.1, then by that criterion they would also be GPL-ware. I don't know if the same is true of dynamically-linked extensions. Have I got any of that right, or should I go back on my meds now? -- -----------------------------------+--------------------- 22nd century: Esperanto, geodesic | Will Ware domes, hovercrafts, metric system | wware at world.std.com From m.faassen at vet.uu.nl Thu Jun 14 18:33:50 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 14 Jun 2001 22:33:50 GMT Subject: Any other Python flaws? References: Message-ID: <9gbe4e$gla$2@newshost.accu.uu.nl> Andrew Kuchling wrote: > I was updating my page of possible Python design flaws > (http://www.amk.ca/python/writing/warts.html) last night to take 2.1 > into account. 2.1's nested scoping fixes one major wart, and the > other major one, the type/class dichotomy, might get fixed in 2.2 if > the descr-branch in CVS turns out well. (It's neat that the two > largest ones may both get fixed before 2001 is out.) > That leaves the remaining warts as minor wibbling about 'do' > statements, print >>, and the like. Are there any other flaws that > should be added? This may be considered a minor quibble; the mandatory use of () in case of multiple arguments to the % string interpolation operator: "%s" % "foo" "%s %s" % "foo", "bar" # doesn't work right "%s %s" % ("foo", "bar") You also don't seem to have listed the single element tuple wart, which trips me up sometimes in complicated structures (like the luckily now obsolete old Zope security declaration tuple): ("foo",) Another minor print wart/weirdness is the trailing ',' to prevent a newline. I don't find trailing commas very pretty. Further things possibly wartlike, though this one never bit me, is the possibly to assign to None, definitely a weird idea when you first encounter it. Um..indented triple quoted multiline docstrings keep their indentation? It's suprising sometimes, though I don't see how you could do it any better way. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From guido at python.org Fri Jun 29 08:26:22 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 29 Jun 2001 12:26:22 GMT Subject: PEP scepticism References: <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> Message-ID: Andrew Kuchling writes: > It's also a matter of where effort is expended for the most benefit. > The new features such as static scoping, list comprehensions, &c., are > nice to have and I'm pleased that the list of language shortcomings is > shrinking. But would I rather have had list comprehensions or a > catalog of all Python extensions similar to CPAN? I'd have much > preferred the latter, because it would make a greater improvement in > my programming life than, say, list comprehensions do. This doesn't > imply that list comprehensions don't improve my life at all (they do), > but > > I've noticed that in online forums, people now rarely beat up on > Python for the language itself, except for the old reliable > indentation knee-jerk reaction. Instead people write about how > convenient CPAN makes it to find modules, or how useful the XML > modules are, or how EJB lets them write elaborate business systems. I > don't think improving Python the language will win new converts at > this point; improving the standard library, development environments, > or the documentation is more likely to bear fruit. Thanks, Andrew. That was a very good point you made in an otherwise "same-old-same-old" thread. I'm guilty of this myself: by nature, I'm more interested in making the language better than in adding convenience to finding 3rd party modules. (I did once have an interest in creating a better IDE, but that interest has waned now there are so many commercial offerings.) How is the catalog-sig doing, by the way? --Guido van Rossum (home page: http://www.python.org/~guido/) From loewis at informatik.hu-berlin.de Sat Jun 16 12:57:52 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 16 Jun 2001 18:57:52 +0200 Subject: Build problem with unicode and 2.1 References: <3B264EE9.4010405@lbl.gov> Message-ID: Marcin 'Qrczak' Kowalczyk writes: > > The Py_UNICODE type is required to be a 16-bit long, unsigned int. > > BTW, why is this? In Unicode 3.1 characters have numbers in the range > U+0000..U+10FFFF. I think the main reason is that Guido considered it as a waste of space to use a larger type. Please see Misc/unicode.txt for further details, it says # Future implementations can extend the 32 bit restriction to the full # set of all UTF-16 addressable characters (around 1M characters). I don't really understand this sentence, but I read it to say "future implementations might widen Py_UNICODE to 32 bits". Regards, Martin From phd at phd.fep.ru Sat Jun 9 04:03:49 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Sat, 9 Jun 2001 12:03:49 +0400 (MSD) Subject: [digression] Re: DOS Extenders (was: RS232 support for DOS on 486?) In-Reply-To: <3B21697B.E933DE79@ActiveState.com> Message-ID: On Fri, 8 Jun 2001, Paul Prescod wrote: > Oleg Broytmann wrote: > >... > > The best known DOS Extender was PharLap, but it had the problem that it > > didn't support DPMI. Without support of proper standard it failed. > > The second best known was DOS/4G, created by Rational Systems. I asked > > Google where it is now - and hurray! - it is now at http://www.tenberry.com/. > > Its primary compiler was Watcom C: http://www.tenberry.com/dos4gw/. ^ > | > I worked at Watcom at the time and we thought of DOS/4GW as the DOS | > extender we licensed rather than our compiler as their "primary | > compiler". | | :))) | | > Remember that the compiler had to be a 32-bit compiler so you didn't | > really have a lot of choices. | | Hmm... At that ancient era I used Borland Pascal, and Borland created | 286-compatible DOS Extender. A bit later they created 386-only DOS Extender| for C/C++, but I never wrote in C - after Pascal for DOS I switched to | Python on UNIX. | | > It is also worth pointing out (though I'm sure you already know) that | > Rational Systems is unrelated to today's Rational -- the UML etc. guys. | v | | | \_____/ Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From ullrich at math.okstate.edu Sun Jun 3 10:47:58 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 03 Jun 2001 14:47:58 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> Message-ID: <3b1a4ce6.577431@nntp.sprynet.com> On Sat, 2 Jun 2001 17:28:22 +0200, "Alex Martelli" wrote: >"David C. Ullrich" wrote in message >news:3b18ea18.332276 at nntp.sprynet.com... > ... >> I said you cannot have complete information about >> a physical system. You can't. An algorithm is not > >Let's take your original sentence again, snipless: [...] Just to prevent any confusion - I posted a (long) reply to this yesterday. Foolishly posted it from the office; evidently the server is acting up again so there's no telling when it will appear. Will wait a bit before trying to reproduce the reply. But in the meantime I would _really_ appreciate clarification regarding exactly _when_ I refused to supply a definition on request. Twice you say something about me not "deigning" to give a definition, the second time you say that I do not deign to give definitions until pressed. If you can cite a place where I was asked for a definition and didn't give said definition I'll say oops, never mind excuse me. But I don't believe that that has happened. Accusing me of refusing to supply definitions when asked is egregiously insulting. David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From ullrich at math.okstate.edu Thu Jun 21 08:40:20 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Thu, 21 Jun 2001 12:40:20 GMT Subject: Aargh! Function takes exactly x arguments, y given.. References: <9gkrud$pru$1@news.inet.tele.dk> <3B2E1C02.109197B5@alcyone.com> <3b2f3759.467766@nntp.sprynet.com> <%AdY6.24501$Kq4.2305781@newsread2.prod.itd.earthlink.net> Message-ID: <3b31eac9.313002@nntp.sprynet.com> On Thu, 21 Jun 2001 03:10:51 GMT, "Chris Tavares" wrote: >"David C. Ullrich" wrote in message >news:3b2f3759.467766 at nntp.sprynet.com... >> On Mon, 18 Jun 2001 08:19:30 -0700, Erik Max Francis >> wrote: [...] >> > >> >Only thing I can think of is that you've got a confusion with bound and >> >unbound methods; if you call an unbound method (C.f where C is a class >> >and f is a method), then you need to provide an instance of C as the >> >first method (the implicit self method becomes explicit). >> >> Or he's not calling the function that he thinks he is, possibly >> because of an "import *". >> >> (I refrained from guessing at first cuz I didn't want to leave >> anything out. Is there a natural third possibility?) >> > >The problem I still hit quite often is this: > >class Foo: > def MyMethod( x, y ): > pass > > >foo = Foo() >foo.MyMethod(1, 2) > >Boom! Called with three args, expected two. Right. That's the "first" of the two possibilities mentioned. (It might be that always calling the first parameter "self" instead of "x" would remind you of its special status...) >-Chris > > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From roy at panix.com Mon Jun 18 21:25:36 2001 From: roy at panix.com (Roy Smith) Date: Mon, 18 Jun 2001 21:25:36 -0400 Subject: fprintf(): Python Equivalent???? References: Message-ID: prem at engr.uky.edu (Prem Rachakonda) wrote: > HI, > Does python have some function which does a formatted file writing > functionality similar to C's > > fprintf(fp,"%s %s",string1, string2); Sure. fp.write ("%s %s" % (string1, string2)) From chrishbarker at home.net Thu Jun 14 18:13:52 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 14 Jun 2001 15:13:52 -0700 Subject: Any other Python flaws? References: Message-ID: <3B293720.363510EE@home.net> The fact that you can not override boolean operators: and, or, not, others? I'm glad I can now write: a > b and have the result be determined by the classes of a and b, but I really want to also be able to write: (a > b) and (c > d) NumPy is the obvious case for using this, but I'm sure there are other uses as well. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From richard at NOstarfighterSPAM.freeuk.com Mon Jun 18 14:20:41 2001 From: richard at NOstarfighterSPAM.freeuk.com (Richard Townsend) Date: Mon, 18 Jun 2001 19:20:41 +0100 Subject: Building PIL 1.1.2 with Python 2.1 on HP-UX 11 Message-ID: Having previously built PIL 1.1.2 with Python 2.0 successfully on HP-UX 11, I have been trying to build it with Python 2.1. Building libImaging.a worked fine and 'make check' produces the expected result. In the Setup file I commented out line 21 (to build a statically linked interpreter). I also commented out lines 33 & 36 and modified lines 45 & 46 suitably for Tk & X. When I ran 'make -f Makefile.pre.in boot' it created a Makefile with references to 'PY_CFLAGS' which is not defined. I added a line to Makefile.pre.in: PY_CFLAGS= $(CFLAGS) and then the generated Makefile worked OK when I used the 'make python' command. I copied PIL.pth and the PIL directory to site_packages and set PYTHONPATH. I can now fire up the new interpreter OK. Importing standard modules such as os, sys & Tkinter is fine. However when I "import Image" the interpreter core dumps. [The same thing happens if I try to import Pmw (which is also in site_packages)]. If I fire up the original Python 2.1 interpreter, I can successfully import Pmw and Image without getting a core dump. (Obviously I can't import _imaging with that interpreter). If I don't comment out line 21 in Setup and then attempt to build a dynamically linked interpreter, it fails at link time with an error message about lib.a being truncated. Does anyone have any suggestions on how I can fix this problem? regards Richard Townsend From aleaxit at yahoo.com Tue Jun 12 04:23:00 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 12 Jun 2001 10:23:00 +0200 Subject: is c faster? References: <9ftlpv029hk@enews2.newsguy.com> <3B2550F5.ED7F54D@home.net> Message-ID: <9g4jh20712@enews2.newsguy.com> "Chris Barker" wrote in message news:3B2550F5.ED7F54D at home.net... > Alex Martelli wrote: > > a speed up as small as 20% > > That must have been disapointing! I didn't expect much more, actually -- it was just an experimental attempt to see what I could do to speedup some intricate re-based function. The bottlenecks, and I knew that, were in the re code, so I was just pruning away a tiny bit of loop overhead, method-lookup & whatnot. I think this is the kind of benefit one might expect from a simpleminded 'compiler':-). (Happy End: I rethought the whole approach in terms of string scanning rather than re's and the bottleneck went away:-). > > it's possible) and as big as 1,000%, i.e., 10 times faster (again, > > I haven't seen anything more than that on real code, although in > > I got an approx 100X speedup in my only substantial extension (still not > that big). I was already using NumPy arrays, but there was just no way > to "vectorize" the whole thing. I may have been able to get a 10X > speed-up or so keeping it in just Python if I put some time into it, but > I knew I wasn't going to get what I needed, so I went to C. So, the roughly-ten-times ratio (between speediest fine-tuned Python and C) might still apply here (maybe)... Alex From sill at optonline.net Sat Jun 2 11:34:32 2001 From: sill at optonline.net (Rainy) Date: Sat, 02 Jun 2001 15:34:32 GMT Subject: Syslog References: <2brhhtgvab8huis4avjhbc48912059nc8f@4ax.com> Message-ID: On Sat, 02 Jun 2001 15:40:57 +0100, Simon Faulkner wrote: > I have a firewall that sends a ling to syslog on my Linux box every 5 > mins with the number of bytes transferred in that time: > > Jun 2 14:52:37 192.168.146.100 NameOfFirewall: Stats filter 12: 1363 > (All out) > > I want to srtip this number out every 5 mins so I can feed it to MRTG. > > Any sugestions about the best way to achieve this? > > Simon > Simon Faulkner Well, I have this syslog-monitoring script I got somewhere and improved a bit, it colorizes and selectively prints out syslog as it grows (but doesn't handle log rotation yet). Use it like this: # pctail.py /var/log/syslog #!/usr/bin/env python import string, time import select import sys import getopt import re, os def colorize(color, text): """Return colorized text""" col = '\033[0;3' if not color: return text elif color == 'red': return col + str(1) + 'm' + text + col + str(7) + 'm' elif color == 'green': return col + str(2) + 'm' + text + col + str(7) + 'm' elif color == 'yellow': return col + str(3) + 'm' + text + col + str(7)+ 'm' elif color == 'blue': return col + str(4) + 'm' + text + col + str(7) + 'm' elif color == 'magenta': return col + str(5) + 'm' + text + col + str(7)+'m' elif color == 'cyan': return col + str(6) + 'm' + text + col + str(7) + 'm' elif color == 'white': return col + str(7) + 'm' + text + col + str(7) + 'm' elif color == 'gray': return col + str(8) + 'm' + text + col + str(7) + 'm' class pctail_file: def __init__(self, path='/var/log/syslog',num=10,showheaders=0): self.file=open('/var/log/syslog','r') self.text=self.file.readlines() textlen=len(self.text) start=textlen-num lines=self.text[start:textlen] self.printheader() self.prettyprint(lines) def printheader(self): if showheaders: print '['+self.file.name+']' def prettyprint(self, lines): for line in lines: if line: if line[-1] == '\n': line = line[:-1] list = string.split(line, ' ', 5) # skip these lines: if re.search('/USR/SBIN/CRON', list[4]): continue if re.search('RTL8139 Interrupt line blocked', list[5]): continue if re.search('[192.160.127.97] Successful lookup', list[5]): continue if re.search('Connection from Irc.mcs.net (192.160.127.97)', list[5]): continue if re.search('skipper.frogspace.net', list[5]): continue # if re.search(' if re.search('ERROR : NO-USER', list[5]): continue print colorize('green',list[0]+list[1]+' '+list[2])+' '+\ colorize('blue',list[4])+' '+colorize('yellow',list[5]) #' [' + colorize('green', list[3]) + '] ' + def fileno(self): return self.file.fileno() def founddata(self): s=self.file.read() if s != '': s2=string.split(s, '\n') self.printheader() self.prettyprint(s2) if __name__ == '__main__': os.system('clear') print '--- syslog:' slist=[] opt,args=getopt.getopt(sys.argv[1:],'qn:') showheaders=0 num=10 for x in opt: if x[0]=='-n': num=x[1] elif x[0]=='-q': showheaders=1 for x in args: s= pctail_file(x,num,showheaders) slist.append(s) while 1: time.sleep(1) try: wr,ww,we=select.select(slist,[],[]) except KeyboardInterrupt: print 'Exiting..' sys.exit() for x in wr: x.founddata() -- Lime and limpid green a second scene A fight between the blue you once knew - Syd From donn at drizzle.com Fri Jun 29 12:40:31 2001 From: donn at drizzle.com (Donn Cave) Date: Fri, 29 Jun 2001 16:40:31 -0000 Subject: Augmented Assignement (was: Re: PEP scepticism) References: <6qn16r7i69.fsf@abnoba.intevation.de> <9hhu6701d5j@enews2.newsguy.com> Message-ID: <993832830.751306@yabetcha.drizzle.com> Quoth "Alex Martelli" : | "Bernhard Herzog" wrote in message | news:6qn16r7i69.fsf at abnoba.intevation.de... ... |> I think the main problem (in as much as there actually is a problem) is |> that whether augmented assignment rebinds the left hand side depends on |> the type of object, i.e. whether the object implements the appropriate | | Right! I think the main advantage (in as much as there actually is an | advantage) is that whether augmented assignment rebids the left hand | side depends on the type of object. i.e. whether the object implements | the appropriate methods. This is called *polymorphism* and is a concept | of *HUGE* power. | |> methods, which is very different from normal assignment which always |> rebinds. | | Do you consider: | fee.fie = foo | and/or | fee[fie] = foo | examples of "normal assignment"? Neither "always rebinds" -- it all | depends on the type of object, i.e. whether the object (fee) implements | the appropriate methods (__setattr__, __setitem__). Augmented | assignment, like attribute assignment and item assignment, is | polymorphic. Plain assignment to an _unqualified_ LHS isn't, so | maybe *THAT* one is the "odd man out"?-) That sure isn't the way I see it. In an expression like x.a = b or x[i] = b, I see that the assignment is indeed a function of x's setattr or setitem, but it's an operation that clearly modifies x. In the present case, we're talking about an operation that may modify x ... or not, in which case it modifies the assignment namespace*. That doesn't sound like polymorphism of x as much as a language feature that varies the semantics of the operation depending on which choice of semantics is convenient for the object. Maybe the convenience is worth it, but the point was well taken, this has the potential to enhance confusion. * self.a += b, where a is a class attribute, doesn't replace the class attribute but rather adds an instance attribute. That's consistent, just defining my term "assignment namespace". Donn Cave, donn at drizzle.com From kvdwalt at csir.co.za Thu Jun 7 08:16:26 2001 From: kvdwalt at csir.co.za (Karel van der Walt) Date: Thu, 7 Jun 2001 14:16:26 +0200 Subject: Python for win32 development, GUI, Database, dlls Message-ID: <9fnrc8$lmp$1@newnews.mikom.csir.co.za> I have been approached in a 'time to market situation'. Python appears to me to be a strategic choice, however: this is a number crunching application most numeric stuff in existing (fortran) dll the new development will entail a lot of visualization, pseudo GIS like, animation (coloring of contours), plain media (digital picures, video) in a rich interactive GUI then all of this data in MS Access (what else?), with reports and graphs on top of it. OK the latter can be in a reportwriter as long as one can call an .exe with commandline parms from python) Integration with MS Office formats (not ole automation) would be important (thus MS Access for imports exports). Any grave misgivings? Any pointers? Commercial libraries? However the exchange rate doesn't favour that :( tx k From DavidLSpamNoNo at raqia.com Fri Jun 22 14:41:44 2001 From: DavidLSpamNoNo at raqia.com (David Lees) Date: Fri, 22 Jun 2001 14:41:44 -0400 Subject: cmdline.py not working in ActiveState Python 2.1 Message-ID: <3B339168.9D7A9094@raqia.com> I have the following simple testcode using cmdline.py (by Daniel Gindikin), which is parsing command lines: import os,sys,cmdline b=cmdline.receivedOption('-x') print b if b: print cmdline.getIntegerValueOf('-x') when called with command line 'testcmd.py -x 3' from a Linux version of Python 2.1 it works correctly. However, using the same build (ActiveState) under windows NT, the command line option is not recognized and 'b' has value zero. Any idea what is going on here? I think this command line parser used to work on older windows Python distributions. Thanks in advance, david lees From phd at phd.fep.ru Wed Jun 20 06:44:24 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Wed, 20 Jun 2001 14:44:24 +0400 (MSD) Subject: rexec works strange... In-Reply-To: Message-ID: (Ivan, please note - I am replying into the newsgroup, too) On Wed, 20 Jun 2001, Oleg Broytmann wrote: > On Wed, 20 Jun 2001, Ivan Ivanov wrote: > > Thank you for the help, I'll try to figure out how > > to do the first suggestion - disallow importing sys. > > This seems to be a good idea, I just don't know > > how to do it. Do you have better insight? Found it: it is the code ok_sys_names = ('ps1', 'ps2', 'copyright', 'version', 'platform', 'exit', 'maxint') To disallow sys.exit remove exit from the list. To do it in Python way: 1. Create a class like def MyRExec(rexec.RExec): ... 2. In this class define your list: def MyRExec(rexec.RExec): ok_sys_names = ('ps1', 'ps2', 'copyright', 'version', 'platform', 'maxint') Use the class instead of standard RExec. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From rnd at onego.ru Sun Jun 10 22:45:51 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 11 Jun 2001 06:45:51 +0400 (MSD) Subject: Global in multiple files In-Reply-To: Message-ID: On 10 Jun 2001, Artur Skura wrote: >On Sun, 10 Jun 2001 21:55:17 +0400 (MSD), Roman Suzi wrote: >>On 10 Jun 2001, Artur Skura wrote: >> >>>>Why do you need global variable in the OOP design anyway? >>> >>>I knew you would say that! ;) >> >>Yes, of course. Because in True Object Design there is no place for >>anything global. that was an irony... >You have to make some class instance of which will manage >>userlist. >Mhm. It seems a little too much overhed for a simple list of users. What if one day you decide to use threads and userlist is to be shared. How do you manage your list without breaking it then? But if some object will be in charge of this resource, it will be much-much easier. You will need blocking written only once. >The problem is I need it in many places. So even if I create class >ManageUsers, set userlist=ManageUsers(), then userlist.add(user), >it will not solve my problem - it might solve for one class only, Why? You can have userlist static, if you want to: --- user_manager.py class UserManager: userlist = [] def __init__(): ... def add(): ... def poll(self, func ...): def get(self): ... def iterate(self): ... --- other module import user_manager class TS: userlist = user_manager.UserManager() ... >so probably I need to rearange everything. Not much. As a bonus you will get proper defined operations on userlist. >>>I just want to keep this one little global, userlist, in order >>>not to do some strange acrobatics later. It's clean, simple, >>>keeps the number of arguments to pass to ther functions small etc. >>After seven years of trial and error I could say that I begin to >>understand OOP ;-) >> >>I thought that way about arguments too. It only says that your object >>design is not done right way. (It usually happens when it's first try >>anyway). > >The problem is how to do it in this case? It seems this is not >exactly within the scope of this group. But the necessity of >having userlist available from (almost) everywhere seems still >obvious to me. Then let every class to have it (as I show above, for example). It is also probably that places it is used "everywhere" are natural to be included in UserManager class. OOP is about regrouping code according to entities. For example, userlist is IMHO natural container for TS_User's. But it seems you need more than just contain list of users: you do other operations on the list: poll users, add users (more complex than just list.append()). >>>In this case it fits perfectly. I need to acces userlist from any place, >>>any moment. >> >>Maybe some object could be used to represent the functionality with a >>proper method. For example, AuthoriseUser(). It's a singleton in your >>situation. But if later you decide to have more userlists, you could add >>it to authorisation chain. > >No, that part of the code (authorisation etc.) is not important now. >It all will be rewritten, anyway. But I need to be able to know >the value of userlist from within instances of TS_Command.Handle(), >also from my main module, and - because the project is a little >specific - from TS_System and maybe some other classes. >So some solution would be to pass userlist as an argument of TS_Command >instance, but somehow it won't work. >>>OK, suppose I want to do away with global userlist. >>>I want to pass it to TS_Command instance. Will it work? No. Why? >> >>You still think in terms of structural design. Even modular design already >>has some precautions against globals. Objects are here to completely >>eliminate the problem. Only environment (may also be seen as special object) could be global. Everything else under the sun isn't ;-) >Tell me how :) I think maybe I', stuck against some exception >- I really need this list everywhere... It's interesting, that everywhere could suffer some drastical rearrangements if you do it in objects. Small script could bloat. OOP is a code-compressor only when the complexity is large enough. just like file compressors necessary enlarge little files (and most of other files too), to be able to compress some of the files. >>>I have no idea... You see, I don't want to stick fanatically to my >>>global, any solution is fine, provided that I can split my code >>>and see it working as before, when it was all in one file. >>>This 'userlist' is my last obstacle. >> >>It's not. It's just first iteration of object analysis/design/programming >>you did. (In fact, your classes has hard-coded many things. Probably you >>will want to change this in the future.) > >For sure - I'm jus experimeting, it will al be rewritten, maybe >in another language, I just want to check out different ways >(Ruby seems elegant, also I spare some finger-gimnastics when >I have to change indentation of a whole function only because I >added one condition etc.) It's not a problem: you can use Python-aware text editor or editor with python mode. For code to be readable indentation is usually a must. So, you indent anyway. >>It's real fun to return to the same design after some time >>and look at it critically. >> >>Thus, I do not critisize you here. I am trying to express what I myself >>felt when I tried to reimplement something with objects. At first try >>you have objects wrong. (This is seen from the amount of cross-usages). >> >>It's a painful process which decreeses quality of the code at first. But >>then it starts to pay off. Bad object design is worse than bad structural >>one, someone said, but good OD is better than good structural. >> >>Try to rethink your design. Maybe your code will have other >>classes than you have now, and will be less lines. > >Could you suggest some good books about OO? >I want to make things easy for someone who might want to add >functionality to that code, so it must not be ugly. Try "OOP tutorial" on google.com >(BTW I would like to thank other people for pointing out the >possibility of having global.py module etc. Yes, it solves my >problem for now, but maybe I should really redesign it as Roman >suggest to eliminate the need. No, I still don't know how :)) Some hints: TS_Command could be rearranged to provide generic way to add new commands. For example, class TS_Command: ... class TS_ls(TS_Command): name = "ls" def __init__(self...): def do(self, args): # ls implementation class TS_pwd(TS_Command): name = "pwd" def __init__(self...): def do(self, args): # ls implementation ... Or at least make if cond1: ... elif cond2: ... to make your code more effective. I have not understood what for do you have TS_fs class. It's just two utilities which could be fine in separate module, without making a class. * I think that probably it's simpler to start from structural version again. Your example is not large enough to bother with classes/ objects unless you plan to make it a module for many developers or plan to grow it into more elaborate system. Of course, this is good as exercise in OOA/D/P. I hope my hints help to refine the code. >Regards, >Artur Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Monday, June 11, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Useless Invention: Fur sink." _/ From rnd at onego.ru Tue Jun 26 15:42:35 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 26 Jun 2001 23:42:35 +0400 (MSD) Subject: regex scanner question In-Reply-To: <3B38DC9F.C3DC34FC@ActiveState.com> Message-ID: hi! (After the PEP 260 I am not sure I can use anything less common than things with established use practice... So I better ask.) I've found SRE_Scanner object which gets birth from scanner() method of SRE_Pattern object. It is very convenient to use for finding sequential matches in loops or otherwise: >>> import re >>> r = re.compile("\d+") >>> s = r.scanner("1 2 33 4 54 56 jkjlkj 445") >>> print s.search() >>> print s.search().group() 2 >>> print s.search().group() 33 >>> print s.search().group() 4 >>> Is it standard Python feature I could safely use or will it be dropped soon as it happened to xrange as a sequence type? Could use of .scanner be recommended or not recommended? BTW, generators could be very useful if applied inside regex routines. They will make it easy to hop from ane finding to another without taking too much memory. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, June 26, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "It is better to be brief than boring." _/ From just at letterror.com Mon Jun 4 10:29:50 2001 From: just at letterror.com (Just van Rossum) Date: Mon, 04 Jun 2001 16:29:50 +0200 Subject: How to unpack data to unicode string? References: <3b1b7e04.5677574@news.muenster.de> Message-ID: <3B1B9B5E.7E4D8F88@letterror.com> Fredrik Lundh wrote: > > Martin Bless wrote: > > > I'm doing a bit of analyzing TrueType files. (BTW, there's some good > > information at www.microsoft.com/typography). There can be chunks of > > unicode data inside truetype files which I can extract via slicing: > > > > rawText = data[start:end] > > > > Now, how do I do the transformation of rawText > > '\x00N\x00o\x00r\x00m\x00a\x00l' -> u'Normal' ? > > try this: > > u = unicode(s, "utf-16-be") > > also take a look at TTX/TTLib: > > http://www.letterror.com/code/ttx/index.html Which is actually mondo out of date. However, a fresh source archive can be found here: http://www.petr.nl/just/FontTools.tar.gz It doesn't yet use Python's Unicode facilities for the 'name' table: it's still completely compatible with 1.5.x. Just From charlie at charliedyson.net Sun Jun 17 16:13:24 2001 From: charlie at charliedyson.net (Charlie Dyson) Date: Sun, 17 Jun 2001 20:13:24 +0000 Subject: list.sort() References: <3B2CEBF1.CCF5377D@hack.org> Message-ID: <9givg3$lfd$2@s1.uklinux.net> William Park - opengeometry at yahoo.ca wrote on Sunday 17 June 2001 17:58: > On Sun, Jun 17, 2001 at 07:42:09PM +0200, Rikard Bosnjakovic wrote: >> >>> l = l.sort() >> >>> l >> >>> print l >> None >> >> If we split the problem into parts, "l.sort()" sorts l and it becomes >> [2,3,4]. I expected it to be [2,3,4] after assigning it to itself (after >> it got sorted), but the list seem to got deleted instead. I don't like >> this behaviour, at all. > > 'l.sort()' returns 'None', and you are assigning this 'None' back to > 'l'. Instead, try > >>> l.sort() > >>> print l > >> Why does Python behave like this? Why does sort() change lists >> _in-place_, instead of returning a list? > > Efficiency. > Hmm, I actually think that this behaviour is not very logical. Concider: x = {'Python' : 'Cool', 'Linux' : 'Cool'} print x.keys().sort() # Prints None It would be better if it sort **returned** the results, instead I have to do: keys = x.keys() keys.sort() That's one extra line of code!!! Anyway, I get on with Python better than I get on with other languages I must not mention in order to avert a flame-war. Charlie Dyson - charlie at charliedyson.net From dnew at san.rr.com Sun Jun 3 21:53:04 2001 From: dnew at san.rr.com (Darren New) Date: Mon, 04 Jun 2001 01:53:04 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3B183CFF.A90213BA@san.rr.com> <9fa54s0fkb@enews2.newsguy.com> <3B1A7FEB.E466824E@san.rr.com> <9fe5q302hbg@enews2.newsguy.com> Message-ID: <3B1AE9FF.E5FFD92@san.rr.com> Nick Perkins wrote: > I thought I might try to pin down exactly what people here > agree on, and what they dont. sci.crypt is the usual place for such things. > 0. 'Perfect Randomness' is a well-defined concept. Yes, but there's more than one definition in use. Chaitin's and others. > 1. 'Perfect Randomness' is attainable with a suitable physical RNG, eg. one > that measures some quantum-level effect, such as radioactive decay. Some would argue that 100% perfection isn't possible because you can't eliminate all sources of bias. In theory, the decay is perfectly random. In practice, you can't measure it perfectly. > 2. There is a continuum of 'degrees of randomness', ranging from the > trivially predictable to the very hard to predict. (and up to infinity?) I would think "infinite randomness" would be "complete unpredictability." I've never heard of "infinite randomness". Just "infinite strings of random values." > 3. For any useful, practical purpose, there is a degree of randomness that > is sufficiently random, even if it is not 'perfectly random'. One would think. > 4. The result of rolling dice is determined not by any random behaviour of > the cubes themselves, but by the unpredictability of the exact muscle > movements of the thrower, which are determined by nerve impulses which are > controlled by the brain. Predicting the roll of a dice thus requires > knowlege about the state of the throwers mind and body, which can be thought > of as a huge program.( or perhaps, even unknowable?) Nah. Cubes and nerves are both influenced by quantum effects, as well as brownian motion of air molecules, etc. > 5. Quantum random effects can be amplified to produce a 'macroscopic > physical RNG' which exhibits 'perfect randomness'. Agreed, with the restraints of (1)'s answer. > 5 1/2. A multitude of random quantum effects tend to cancel each other out > in a mocroscopic system, resulting in a very close approximation to > Newtonian physics, and thereby losing the original randomness of each > individual quantum effect. No. All that happens is that the probability for something happening becomes greater. Just like if you throw 2 dice, the probability of a 7 is much greater than a probability of a 2. You haven't lost the randomness. It's just that the probabilities aren't equal any more. In a macroscopic system, the probability of (say) an airplane suddenly disappearing in Philadelpha and appearing in LA is there. It doesn't cancel or get lost. It's just very small. Just like if you throw 10,000 dice, the chance of rolling "10,000" as the sum is exceedingly small. But it'll happen just as often as you expect it to. You can very reliably predict it won't happen, but if the dice are fair, you'll be wrong just as often as chance says you'll be wrong. > 6. 'Perfect Randomness' can not be produced by an algorithm, or.. > > 7. 'Perfect Randomness' can be produced by an algorithm, but the algorithm > a) would have to be infinitely large > b) would never halt Depends on whether an infinitely large non-halting somethign is considered an algorithm. It sounds like what you're really asking is "can something 100% unpredictable be generated by something deterministic about which we know everything." I think the answer is trivially "no" there. > 8. The phrase "state of sin" means beleiving that a RNG is perfect, when it > is not, and says nothing about the usefullness of a RNG which is > sufficiently random for one's purpose. I interpret JVN's quote as "anyone expecting to get unpredictable numbers from a fully disclosed deterministic system is fooling themself." Chaitin's work doesn't seem to contradict this. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. This is top-quality raw fish, the Rolls-Rice of Sushi! From junkster at rochester.rr.com Thu Jun 14 20:54:09 2001 From: junkster at rochester.rr.com (Benjamin Schollnick) Date: Fri, 15 Jun 2001 00:54:09 GMT Subject: SMNP Interface(s)? Message-ID: I just checked over at the Vaults & couldn't find any, does anyone know of any SMNP modules for python? And of course, where to find them? - benjamin From geoff at homegain.com Sat Jun 2 06:51:44 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Sat, 2 Jun 2001 03:51:44 -0700 Subject: Why isn't Python king of the hill? Message-ID: <393D961EA4FCD311B03F00D0B746D65803275E5E@HQSXCH01> Martijn writes, sometimes quoting me: > Ah, a powerful query system, then. Difficult, too. Could you give > a real life example of an actual arbitrary retrieval system? It's > not full-text-search search, right? (the ZCatalog I believe already > can do something like that, on multiple attributes). Arbitrary and full-text are more or less identical. I can't speak competently about ZCatalog. If it's got it, that's great -- but I'm not sure what it is exactly, or how effective or efficient it is to use that on a collection of large text. :) > > I can't speak to how easy it is to move from one app server to > > another. I /can/ speak for how much of the "hard work" is done > > for you by some of these enterprise containers -- a whole lot! > > Could you go into some more detail on this? I've heard this > more often, > but I'm still not entirely clear on *what* work is done. :) I think the meat of the response lies in answering this question. I'm going to try to answer it first in regards to JSP and servlets, and I'm going to mix in some of the J2EE stuff near the end. I'm nowhere near as proficient with J2EE as I am with the other two. Meanwhile, others will I'm sure jump in and correct me where I'm wrong. Or I /hope/ they will, because I'm sure to be wrong. :) First, one framing quote: > I'm not interested in promoting a standard, I'm just interested in > stealing ideas for Python-based APIs. I'm not interested in > standardizing these APIs. :) That frames my first issue. ----- STANDARDIZATION ----- I think that's a big part of what's great about these API's. They're standard! It's not just a question of whether you can find a Java programmer or whether you can find a Python programmer. The languages are not really a significant factor, so much as the toolsets. Finding Zope programmers is /hard/. Finding someone who's had experience with WebSphere or WebLogic or one of the other servlet containers is /easy/. The APIs are standard. Maybe they won't develop their app in exactly the same way you developed yours, but the odds are pretty good they'll be similar -- they're based on the same APIs, making use of the same mechanisms. Is it harder to cull the grain from the chaff when selecting these programmers? Maybe. But it's easier to let go of someone you have, than to hold on to someone you don't. I hafta grant that standardization is in some ways problematic. Bad standards can bestow ruin as easily as good ones can bestow greatness. (Just look at C++! ) The Java servlet and JSP standards are pretty good, and I think the J2EE stuff is pretty good, too. The standards are evolving in a fairly nondestructive manner, and addressing some of the issues left outstanding. ----- REQUEST-CENTERED FRAMEWORK ----- When I'm developing under Zope, I start with a page and work back from that. It's possible to determine from the request which bit of content to serve up -- you either make a conditional page, or you stick a bit of code at the top of the page that does redirection based on the contents of the request object. That's reasonable, and it makes sense to people who have done lots of server-side scripting. I think PHP and ASP kinda encourage this sort of coding. You can do it with the Java products too -- you just use JSP to develop your page content, and bang-presto, you've got a page-centered application. I don't want a page-centered application; in fact, I would go so far as to say that page centering breaks the MVC (model / view / controller) paradigm that I aspire toward in my software designs. The way Zope is set up, it seems to me that it encourages a design that embeds controller elements in the view. You can hack around that; that's true. But it's a hack, and it's not the "natural" way to program. Zope is set up to support (and support well!) content with dynamic elements. With a pure JSP site, you're still going to be hacking. You can do some things to clean up the hack and make it less crude, but JSP is like PHP or Zope: it's page-centered. When you add servlets to the mix, though, you start eking your way into deeper potential. Instead of requests being aimed at your view components, requests are aimed at a servlet. The servlet is invoked via routines that are designed to handle a request. The objects associated with the request are a little more "primitive" than the objects you pull out of Zope, but they are handled in a fairly elegant fashion. Having the servlet in charge of processing the request puts the control into the controller, if you will. It makes it easy for the app to center around the controller logic, without relying on the view logic to hand over the reins. Model/View/Controller separation is a topic of some discussion in servlet circles. I think the jury's still out on the best way to do it. I think that one of the more common solutions uses JSP as the view components, servlets as the controller components, and beans as the model components, with various and sundry utilities, factories, and other classes thrown in to stitch it all together. Do I need to define these? JSP is a lot like PHP or DTML -- you write Java code in the page. Servlets have access to the request directly, as well as repositories for session, request, and application state. Beans are basically just any old object, but with properly-named accessors and mutators for all public attributes. When you move from a simple servlet container to an enterprise servlet app, Enterprise Java Beans effectively take the place of the Beans (though you can still use simple beans locally). Let's talk about these components and their features in a little more depth. ----- JSP FEATURES ----- Like I said, JSP is much like DTML or PHP in appearance. JSP has a few "directives" that you can use to apply general processing rules to your page. Of particular interest: Your JSP pages get compiled into a servlet. I think that makes them pretty fast when compared with something that does page interpretation at request time. Your JSP pages have access to at least four levels of state (there might be another I'm forgetting): application, session, request, and page. The first three correspond to the same state repositories managed by the servlet. The 'page' context is for local objects. You can forward control to other servlets or JSP pages, and you can also include pages. I believe (though I'm not sure I've tested this) that a page you forward to gets a fresh "page" context, while an include uses the current page context. Also, forward is terminal, while an include will return control after processing the child. Not too revolutionary here, but the features are present. You can embed Java. In fact, that's the way you do your conditional display, and almost everything else interesting. This can look kinda goofy in practice, but it does increase ease of use. You can associate a bean with an object, and map form properties onto the bean's attributes. I think that this is most useful when you're programming pure JSP, but it's pretty useful when you're not. You can create "custom tag libraries" for a more abstract and less "page-centered" approach to reusable page content. Custom tag libraries are more Java-centric than markup-centric. ----- SERVLET FEATURES ----- Most of what you get out of servlets is also available indirectly in JSP if you jump through the right hoops. For pieces of the application that don't need to display, though, there's not much sense in hopping through the hoops -- it can be downright annoying to need to. That's what makes servlets "natural" for the controller component. I've discussed session management before. Sounds like they're doing some of that in newer Zope? That's good. It's a very hard thing to do well. I would be concerned about ZEO and ZODB being used in their unadulterated form to handle session management for a high traffic site. It just seems like there'd be too much I/O for ZODB/ZEO to handle it efficiently. Servlet containers implement session management for you. The servlet containers are presently not obliged to make these sessions either persistent or distributable, but some of them do, including at least one of the freely-available containers. Persistent, distributable sessions provide good load balancing and good failover. Servlets get a request and a response object passed to them. Generally you manipulate both. The request object has a list of parameters and also a list of attributes. The former are generally the form values while the latter is where you might store state to pass it between servlets or between a servlet and a JSP page. Servlets can dispatch a request using either a forward or an include, just like in JSP. The container's handling of a servlet (or entire web app, which is generally a bunch of servlets and lots of supporting pages) is controlled by the "deployment descriptor", a file called web.xml. This file has a standard, mandated format. It gives the developer a great deal of control over how his or her servlet will be instantiated, and how it will be managed once in memory. Once written, a web application can be packed up into a .war file (analogous to a .jar file) for easy deployment. The first time the app is accessed, the .war file is unpacked. That makes deployment remarkably (almost disgustingly) simple. ----- ENTERPRISE JAVA BEANS ----- The 'enterprise' in the J2EE stuff basically means "designed for large and diverse environments" I think. When the word was first used in the phrase "enterprise networking" it usually referred to the challenges involved in getting Macs, PCs, and other hardware all talking on the same LAN. These days, that's a non-problem. Now enterprise generally seems to refer to anything of large scope, and particularly applications distributed across multiple pieces of hardware. But I think the "what the hell does that mean" camp may have a point here. :) Adding EJB entails a few sacrifices and a few big gains. Sticking your servlets into the J2EE "framework" means that you hafta put your "application" level state into an EJB or a database (or at least knowing that anything you stick into the application storage can't be counted on to persist any longer than the request). You really need to make anything you put into the session area serializable (though there are a couple exceptions to that rule). There are a couple other rules that go along with that, I can't put fingers on them off the top of my head. All the sacrifices are really pretty minimal. The big gains: you get the distribution and persistence of sessions. That's a hard thing to do well. Your servlets load balance across all the servers that are running them. That's a pretty big win, too -- that's also pretty hard to do in a reliable fashion. And you get the EJB stuff, which means your backend model objects pretty much distribute themselves with no real additional design effort -- the binding mechanism is all there, the publication mechanism, the lookup mechanism. It's all there. The J2EE stuff makes deployment still one more step simpler, too. It pushes parameters that might change during runtime out one notch further, so that deployment configuration can be separated from the details of servlet instantiation, URI mappings, and other miscellany concerning the interaction of the app and the app server. There's lots more to the J2EE stuff than what I've identified here. For where I'm at and the kinds of projects I'm thinking about, it's enough to use a servlets + JSP + simple beans architecture. The kinds of projects I'm thinking about and drafting start small -- start out living on a single server. But by following a half-dozen simple design principles (most of which you'd pretty much follow anyway), moving a web app from servlets and JSPs into a full J2EE app is a (fairly) straightforward affair. I suspect (though I haven't had the chance to put it to the test yet) that an app set up to use beans heavily could pieces of the model re-written to capitalize on the J2EE features without touching any of the controller or view code. ----- JAVA DATA OBJECTS ----- JDO is still in development, so it's maybe not fair of me to talk about it. But since a good proportion of the Python/Zope technologies that we're trotting out for comparison are still in development, I figure I might as well. Like I said once before, maybe we can beat Java to the punch here. JDO is a way of mapping an object graph onto a database. I haven't read the draft of the standard nearly as closely as I should -- I'm the sort that waits for an implementation to play with before learning the technology, because that's the way I learn best. However, I'm told that it bears an uncanny resemblance to the Enterprise Objects Framework from Apple (and NeXT before that). The EOF I've used, and the EOF I can comment on with a fair amount of accuracy . The way EOF works, in its most potent form, is thus: you develop a class with all its accessors and mutators, plus all the business logic you might want to include. You map some or all of its data fields to columns in your database in what's called an entity description. You include things like relationships to other entities -- does my Employee entity have a one-to-one relationship with a Boss entity? Model it. Does my Boss entity have a one-to-many relationship with Employee entities? Model it. Fetches can be performed by key, or by selector. Selectors can pick out individual objects based on the properties of the objects, or through elaborate path constructions that might trace through a long series of relationships. An example: you might fetch all Bosses who have an employee who has a spouse who has a birthday this month. The selector might look something like: employees.spouse.birthday.month == now.month When you fetch these objects from the database, the EOF puts "Faults" in the place of relationships. When you first try to read from a fault object, it runs off and fetches the object from the database. But that's not all! EOF also provides sophisticated caching and data source controls. EOF also provides multiple 'editing contexts' with undo capabilities and the ability to nest editing contexts so that changes can be made within the context of other changes, and committed incrementally, or abandoned en masse. EOF is a powerful tool for management of object graphs and mapping the object graph onto the database. If even a fraction of the power EOF offers developers comes through in JDO, that will be a huge boon to anyone who works with a sophisticated dynamic data model. ----- AND HERE IT IS AGAIN... ----- The best part of it all is that all the things outlined above are STANDARD. They're part of the API. When programmers learn WebLogic or WebSphere or Tomcat or Enhydra or whatever else, they learn to develop to the servlet API. JSP is an extension of the servlet API; it's a five-minute lesson taught to a servlet programmer, or a gentle introduction to an HTML hacker. Sure, your webapp may do some funky things with the technology, and the way you do MVC might be different, and maybe you've got a toolkit or two that you've integrated or a different templating engine. But the core of the architecture is the same, and the application is as simple or as complex as you make it from there. I choose to keep it simple, and I choose to write the code so that it's easily extended toward J2EE in case I need that kind of robustness. For now, a single server running a servlet container is good enough, and in the immediate future, that breaks out quite nicely into a database server and maybe Enhydra on the front end running on a couple boxes. If the load continues to grow, though, I may need to go to a full-fledged J2EE model, and pull the backend objects out onto their own machines so that the servlet machines only hafta worry about processing requests. I've got lots of room to grow, and the upgrade path is very clear. Meanwhile, the API's required are standardized and well-known. I'm pretty confident that someone who's developed web apps under the servlet API could grasp my architecture and start contributing within a day, two at the worst. I'm pretty confident that someone who knows a bit of Java could climb on board inside a week and be adding significant features. What's more, I'm pretty confident that if I was on another project when the customer needed work done, my attentions might not even be necessary. I will note, in closing, that recent days have been something of a reawakening of faith in the darkened halls of my soul. Sunlight has begun to break through the clouds as I consider Python all over again. I have enjoyed this discussion a great deal, and enjoyed most of all that it has stirred my humility some -- I haven't seen all there is to see in the Python world, and much of what I haven't seen is quite promising. Thanks! :) --G. From fdrake at beowolf.digicool.com Fri Jun 22 16:52:48 2001 From: fdrake at beowolf.digicool.com (Fred Drake) Date: Fri, 22 Jun 2001 16:52:48 -0400 (EDT) Subject: [development doc updates] Message-ID: <20010622205248.6290128927@beowolf.digicool.com> The development version of the documentation has been updated: http://python.sourceforge.net/devel-docs/ Changed the revised cmath documentation to use "j" as a suffix for complex literals instead of using "i" as a prefix; this is more similar to Python. Changed the font of the suffix to match that used elsewhere in the documentation. This should be a little more readable, but does not change any potential browser compatibility issues, so I still need reports of compatibility or non-compatibility. See my prelimiary report on the topic at: http://mail.python.org/pipermail/doc-sig/2001-June/001940.html From aleaxit at yahoo.com Tue Jun 12 05:33:14 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 12 Jun 2001 11:33:14 +0200 Subject: Help for Python newbie References: Message-ID: <9g4nkp0d0u@enews2.newsguy.com> "Bob Hibberdine" wrote in message news:zSkV6.18764$m4.73107 at news6-win.server.ntlworld.com... ... > >>> import string > >>> mylist = ['1','2','3'] > >>> mystring = '' > >>> mystring = mystring.join(mylist) > >>> print mystring > 123 > > note there is no space between the items. Right: the separator is mystring, and mystring is empty, so the separator is empty. To use tab as the separator: >>> mystring = '\t' >>> mystring = mystring.join(mylist) >>> print mystring 1 2 3 or, more simply, just: >>> mystring = '\t'.join(mylist) Alex From philh at comuno.freeserve.co.uk Fri Jun 29 15:35:33 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 29 Jun 2001 20:35:33 +0100 Subject: Not enough Python library development [was PEP scepticism] References: Message-ID: On Fri, 29 Jun 2001 16:18:10 GMT, Guido van Rossum wrote: >Roman Suzi writes: > >> Is there a formal TODO list of the libraries and respective priorities? > >No, although there's a PEP for small feature requests (PEP 42). > >If you want to start making a list of missing libraries and submit a >PEP, please do! I'm sure many people will want to contribute. > >> For example, I think that some sort of standard GUI could help Python to >> fight Java with it's Swing/AWT... > >This was tried many times -- there was even a GUI-sig with this goal. I thought Tkinter was the standard GUI??? >Nothing ever came to fruition. The problem is that designing and >implementing a standard GUI that can compete with the existing >offerings it an enormous amount of work, Just a random idea: would it be possible to create a GUI with the same python interface as Tkinter, but which talks to the KDE or GNOME libraries instead? Or are their object models and internal concepts too different -- e.g. in packing functionality? > and folks always ran out of >steam before they were even done with the requirements gathering. My Parrot project has as one of its goals the ability to define a gui (in a gui definition language) which can then be compiled into source code for whatever language/library combination the user desires. So there could be a python/tkinter output module, a python/KDE one and a python/GNOME one. These would not be fully compatible; a parrot class for output to Python/Tkinter would require different functionality code than one for Python/KDE. But it could be written in such a way that required changes are minimal. (see for details) Parrot's not my top priority right now, but I expect I'll be making more changes to it later this year to bring it up to a workable state, >> It could be also interesting to have time module as powerful as mxDateTime >> in standard library. And so on. > >Well, propose one. But what exactly is the point of adding it to the >standard library when you can get mxDateTime if you need it? Because Python should be "Batteries included". I wasn't aware mxDateTime existed, and was semi-seriously thinking of writing a high-level date/time library, with stuff like: d1 = dateToday() d2 = Date("1 Jan 1975") daysDifferent = d1 - d2 (you'd also be able to add/subtract time values, differences would be expressed in seconds, etc) >I'd say >your energy is better spent on reviving the catalog-sig (Python's >CPAN-like effort, which needs new energy!) I thought Vaults of Parnassus was for that? -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From mmueller at dgfz.de Mon Jun 11 01:35:43 2001 From: mmueller at dgfz.de (=?ISO-8859-1?Q?Mike_M=FCller?=) Date: 10 Jun 2001 22:35:43 -0700 Subject: Error connecting to COMServer References: <7049ba55.0106080434.1bcbc8d2@posting.google.com> <3B21C08F.8080905@ActiveState.com> Message-ID: <7049ba55.0106102135.51a2ef0@posting.google.com> Mark Hammond wrote in message news:<3B21C08F.8080905 at ActiveState.com>... thanks for your answer > Mike M?ller wrote: > > > > > Dim Adder As New AddingMachine > > > > > It appears the ProgID of the object is simply "AddingMachine" The wizard that took me through the creation process says Adder.AddingMachine is the ProgID and AddingMachine is the short name. > > > >>>>from win32com.client import Dispatch > >>>>a = Dispatch("Adder.AddingMachine") > > > Try just using "AddingMachine". This results in: >>> from win32com.client import Dispatch >>> Dispatch("AddingMachine") Traceback (innermost last): File "", line 1, in ? File "c:\code\python20\win32com\client\__init__.py", line 94, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "c:\code\python20\win32com\client\dynamic.py", line 80, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "c:\code\python20\win32com\client\dynamic.py", line 71, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147221005, 'Ung\374ltige Klassenzeichenfolge', None, None) According to MSDN ... passing an invalid object name ... > > > Can I conclude anything if I look into at the file generated by COM > > Makepy? > > > Why not open it and see :) You should find some generated comments > telling you the correct Prog ID to use for all the objects in the library. from the generated file: # This CoClass is known by the name 'Adder.AddingMachine.1.0' But this gives the same result as without the 1.0 # The following 3 lines may need tweaking for the particular server # Candidates are pythoncom.Missing and pythoncom.Empty defaultNamedOptArg=pythoncom.Empty defaultNamedNotOptArg=pythoncom.Empty defaultUnnamedArg=pythoncom.Empty Empty and Missing give the same error messages (Adder.AddingMachine or just AddingMachine as ProgID). Since the file is not long I just appended it (see below). Mike # Created by makepy.py version 0.3.6 # By python version 2.0 (#8, Oct 19 2000, 11:30:05) [MSC 32 bit (Intel)] # From type library '1' # On Fri Jun 08 23:15:41 2001 """AddingMachine 1.0 Type Library""" makepy_version = '0.3.6' python_version = 0x20000f1 import win32com.client.CLSIDToClass, pythoncom # The following 3 lines may need tweaking for the particular server # Candidates are pythoncom.Missing and pythoncom.Empty defaultNamedOptArg=pythoncom.Missing defaultNamedNotOptArg=pythoncom.Missing defaultUnnamedArg=pythoncom.Missing CLSID = pythoncom.MakeIID('{904245FB-DD6D-11D3-9835-0000F875E193}') MajorVersion = 1 MinorVersion = 0 LibraryFlags = 8 LCID = 0x0 class CoClassBaseClass: def __init__(self, oobj=None): if oobj is None: oobj = pythoncom.new(self.CLSID) self.__dict__["_dispobj_"] = self.default_interface(oobj) def __repr__(self): return "" % (__doc__, self.__class__.__name__) def __getattr__(self, attr): d=self.__dict__["_dispobj_"] if d is not None: return getattr(d, attr) raise AttributeError, attr def __setattr__(self, attr, value): if self.__dict__.has_key(attr): self.__dict__[attr] = value; return try: d=self.__dict__["_dispobj_"] if d is not None: d.__setattr__(attr, value) return except AttributeError: pass self.__dict__[attr] = value # This CoClass is known by the name 'Adder.AddingMachine.1.0' class AddingMachine(CoClassBaseClass): # A CoClass CLSID = pythoncom.MakeIID("{904245FC-DD6D-11D3-9835-0000F875E193}") coclass_sources = [ ] coclass_interfaces = [ ] RecordMap = { } CLSIDToClassMap = { '{904245FC-DD6D-11D3-9835-0000F875E193}' : AddingMachine, } CLSIDToPackageMap = {} win32com.client.CLSIDToClass.RegisterCLSIDsFromDict( CLSIDToClassMap ) From worm at gdp-group.com Thu Jun 28 10:57:07 2001 From: worm at gdp-group.com (Thomas Volkmar Worm) Date: Thu, 28 Jun 2001 16:57:07 +0200 Subject: WIN32: How to control another windows application Message-ID: <3B3B45C3.59825716@gdp-group.com> Hi, I want to control another application from a python script by sending key events and mouseclicks to it. The script should do what I normally do when I work with this application interactively. Is this possible and how do I do this. Does anybody has example scripts or can give me some hints where I can find further information? Thomas -------------- next part -------------- A non-text attachment was scrubbed... Name: worm.vcf Type: text/x-vcard Size: 366 bytes Desc: Visitenkarte f?r Thomas Volkmar Worm URL: From ChuckEsterbrook at yahoo.com Thu Jun 21 21:43:42 2001 From: ChuckEsterbrook at yahoo.com (Chuck Esterbrook) Date: 21 Jun 2001 18:43:42 -0700 Subject: Another Wart! string.find() [ was: namespace issue? ] References: Message-ID: <112e9d13.0106211743.39215b91@posting.google.com> "Steven D. Majewski" wrote in message news:... [snip] > This is an illogical convention, however it would be very difficult > to root out, because, as you have noted, everyones code is FULL > of explicit checks that string.find does not return -1. > > > I'ld love to see it fixed, however, I suspect that in this case, > many lines of installed code trumps Computer Programming for Everybody! > > > -- Steve Majewski So is it a flaw, relative to CP4E, that sequences start at index 0 instead of 1? An 'everybody' kind of person would think of the "first" element as e[1]. Only someone familiar with pointer arithmetic from C or assembly would think that "first" is 0. Sorry if that already made the "list of flaws". -Chuck From chris.gonnerman at newcenturycomputers.net Wed Jun 13 08:53:54 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Wed, 13 Jun 2001 07:53:54 -0500 Subject: VI References: <20010613123505.88702.qmail@web14506.mail.yahoo.com> Message-ID: <006501c0f407$e8906720$0101010a@local> ----- Original Message ----- From: "F. Tourigny" > VI is fun in its own special way, and portable, > and I'm using it all the time but, personnaly, > I definitely wouldn't promote its use for regular > python programming, expecially for large scripts. > Relatively powerful, but too basic. > > Greetings, > Frederic "Too basic?" How so? I've got hundreds of thousands of lines of C and probably several more thousands of lines of Python written using vi, vim, etc. I find most everything other than emacs "too basic" (and emacs is a religion I've never converted to). From BPettersen at NAREX.com Wed Jun 20 14:31:59 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Wed, 20 Jun 2001 12:31:59 -0600 Subject: raw_input Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D4A1@admin56.narex.com> > From: Brendhan Horne [mailto:brendhanhorne at bellsouth.net] > > >>> raw_input ("Enter your name:") > Enter your name:Brendhan > 'Brendhan' > >>> print name > Traceback (innermost last): > File "", line 1, in ? > print name > NameError: There is no variable named 'name' > > Okay What did I do wrong it should have printed my name after > the print name > command. you need to assign the result of the call to raw_input to a variable called name (otherwise Python has no way of knowing what you think it should do... ;-) >>> name = raw_input("Name: ") Name: Bjorn >>> print name Bjorn -- bjorn From nhodgson at bigpond.net.au Wed Jun 27 03:12:52 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Wed, 27 Jun 2001 07:12:52 GMT Subject: zodb install problem on Windows References: Message-ID: Andy Todd: > A-ha, I almost suspected as much ;-) Thanks very much for the info. > > I think I've got an old version of DJGPP knocking about somewhere, would > that be up to the job? I'm presuming if I get it installed I will also need > to tell distutils where it is? It may be up to the job. distutils found my copy of Microsoft Visual C++ and ignored the available gcc and Borland compilers even though gcc is earlier on the path. There is now a package available at: http://scintilla.sourceforge.net/zodbwin.zip This includes 4 setup programs that should each be run. There may be an installation order required and the README says to install in this order (the 5th step for ZEO is omitted because I don't have it installed): 1) zodb-basic 2) ExtensionClass 3) ZODB 4) BTrees Neil From gerhard.nospam at bigfoot.de Sun Jun 3 00:01:23 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sun, 3 Jun 2001 06:01:23 +0200 Subject: Controlling CDR drives using Python in Windows References: Message-ID: On Sat, 02 Jun 2001 22:04:03 -0300, Carlos Ribeiro wrote: >I'm looking for information on how to control a CDR drive from Windows, >using Python scripts, of course. I'm planning to automate my home backups >using Python scripts. If someone has any information on how to make it >work, I'll be glad to know. If you want to burn CDR on Windows, I think your best bet is to try to get the command line tools cdrecord, mkisofs and friends to compile on Windows. You could then use os.system or popen2 to control them. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://highqualdev.com public key at homepage public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From gbgbgb at gmx.de Thu Jun 21 03:29:34 2001 From: gbgbgb at gmx.de (gbgbgb at gmx.de) Date: Thu, 21 Jun 2001 07:29:34 -0000 Subject: Codeobjects of Modules? Message-ID: <9gs7ou+ro76@eGroups.com> Hi! I am writing an experimental virtual machine for Python-Byte-Code in Python. It works fine for Functions (I am using the f.func_code.co_code Bytecode.) Now I want to run entire pyc-Files and/or modules. How do I get the bytecode from modules and what is the format of the pyc-files. I could not find any documentation. After finishing the PVM in Python I want to port it to - please do not kill me - JAVASCRIPT. I think this could be interesting to be able to execute python-byte-code on NS and IE without JAVA. Any help is welcome! gunter From nightowl at uk2.net Mon Jun 18 14:50:16 2001 From: nightowl at uk2.net (NightOwl) Date: Mon, 18 Jun 2001 20:50:16 +0200 Subject: Best solution ? Message-ID: <992890276.155845@seven.kulnet.kuleuven.ac.be> I am planning (hoping to) write a database-GUI which would mostly run in Windows but connect to a Postgressql database on a central linux-server. If I can write the GUI so that it can also run in Linux, that would be a big advantage. I was thinking about Python, since that runs on both platforms. An other option is PHP (which I have used extensively in webpages but never stand-alone). A couple of questions remain : 1) Is Python capable of easily accessing a Postgres db? (like PHP?) (if not, would it work with MySql) ? 2) would it be possible to design code which would (the same code) run on Linux X-windows as on Microsoft Windows ? 3) Would these thing (if anybody knows) be possible with PHP ? 4) If 3? is yes, what would you prefer ? Any other suggestions are welcome, as long as I am able to build a GUI for a central database which would easily print documents too (Python has Windows COM-support, doesn't it ?) From edcjones at erols.com Thu Jun 14 16:04:17 2001 From: edcjones at erols.com (Edward C. Jones) Date: Thu, 14 Jun 2001 16:04:17 -0400 Subject: Any other Python flaws? References: Message-ID: <3B2918C1.8060906@erols.com> Andrew Kuchling wrote: > Are there any other flaws that should be added? Something like SWIG should be built into Python for wrapping code written in other languages, especially C, C++, and FORTRAN. Perhaps the output of some program-transformation code can be fed into Boost.Python. Here are some urls: http://www.swig.org/, http://www.txl.ca, http://www.boost.org, http://www.program-transformation.org/, and http://www.compilers.net/Coco.htm. Thanks for the wonderful language, Ed Jones From sill at optonline.net Fri Jun 22 04:00:52 2001 From: sill at optonline.net (Rainy) Date: Fri, 22 Jun 2001 08:00:52 GMT Subject: A recommendation on programming tutorials? References: <7417e9e.0106212115.20f3fafe@posting.google.com> Message-ID: On 21 Jun 2001 22:15:23 -0700, James wrote: > I've just started studying the Python programming language 3 days ago. > Though I've already found a tutorial on Python programming and am > fully aware of the tutorial published with the Python Compiler, I > would appreciate further recommendation on online reading regarding > Python Programming. Thanks in advance. There's 'How to think like a computer scientist' - very good, I tried it and liked it. Then there's 'alan gauld's tutorial' I didn't try it but many people seem to like it. Google for both. -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: http://silmarill.org/cymbaline From ffp_randjohnson at yahoo.com Sun Jun 17 12:03:38 2001 From: ffp_randjohnson at yahoo.com (Mike Johnson) Date: Sun, 17 Jun 2001 09:03:38 -0700 Subject: Data Structure Question Message-ID: <20010617.090337.1987231011.7258@behemoth.miketec.com> Hello, I searched for a day to answer this question on my own, but I didn't come up with anything. (But I did learn some great things about Python :-) I've been looking for the Python equivalent of a Perl hashed array. I learned about dictionaries from the help, but they don't work in quite the same way since my keys are not always unique. I was hoping to do something like: diction['thekey']=value in a loop. The key and the value are not always unique, so 'diction' ends up dropping some information. On thing that did work was to embed a nested dictionary into a list. list=[] diction={} diction['key']='somedata' list.append(diction) diction={} (repeat) But... This makes it a terrible pain to search and count keys.... I've no doubt been searching the help using the wrong terminology. Even if you can point me to the right structure or module, it would be a big help. (Nothing needs to be mutable.) Thank you! - Mike Johnson -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From grumble at usa.net Mon Jun 25 07:01:05 2001 From: grumble at usa.net (jcm) Date: 25 Jun 2001 11:01:05 GMT Subject: Pythoin MUD (PyMUD?) References: <9gqq3t$hvs$1@brokaw.wa.com> Message-ID: <9h75lh$o89$1@news.mathworks.com> Remco Gerlich wrote: ... > you need only one drunken wizard to code an infinite loop, and your > driver locks up. We get around this by using two threads. The main thread executes the untrusted code while a second thread keeps watch. If the main thread takes too long executing a given event, the second thread kills it by sending a signal to the process (only works on unix). From kamikaze at kuoi.asui.uidaho.edu Thu Jun 21 18:27:35 2001 From: kamikaze at kuoi.asui.uidaho.edu (Mark 'Kamikaze' Hughes) Date: 21 Jun 2001 22:27:35 GMT Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: <3B2EACF5.1D10252D@earthlink.net> Message-ID: Wed, 20 Jun 2001 01:27:49 GMT in <3B2EACF5.1D10252D at earthlink.net>, Ron Stephens spake: > Anyway, by my count 7 people have expressed some sort of interest in a > HyperCard-like gui creator, since it was first mentioned yesterday by Roman > Suzi... > Roman Suzi > Heil Hodgson > Jerry Spicklemire > Kevin Altis > Chris Barker > Phil Hunt > and myself... I'm quite interested, too. Even simple as it is, Tkinter still requires a lot of "manual wiring". It should be possible to design something simpler. Even just dropping GUI bits into place, binding some primitives like "switch to card X" and "call Python method Y" to each, would be nifty. I have some notes and a bit of prototyping for a web-based hypercardish project, with a "GUI builder" that makes spec-compliant HTML, a server-side application to respond to events, and a database to store information persistently. Unfortunately, it's in Java, I do that enough at work that I don't want to do it for fun, and there's already Zope and a few others sort of covering that space. A Pythoncard would be a nice substitute project. -- Mark Hughes "I will tell you things that will make you laugh and uncomfortable and really fucking angry and that no one else is telling you. What I won't do is bullshit you. I'm here for the same thing you are. The Truth." -Transmetropolitan #39 From see at my.signature Fri Jun 1 01:31:00 2001 From: see at my.signature (Greg Ewing) Date: Fri, 01 Jun 2001 17:31:00 +1200 Subject: I had a thought ... (I know, call the newspapers). References: Message-ID: <3B172894.9B64F46F@my.signature> Roman Suzi wrote: > > my = 0.02$ No, no... for consistency with other numeric literals, it should be my = 0$0.02 :-) -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From clpy at snakefarm.org Fri Jun 15 04:03:52 2001 From: clpy at snakefarm.org (Carsten Gaebler) Date: Fri, 15 Jun 2001 10:03:52 +0200 Subject: statically linking the entire runtime (HPUX Python2.1) References: <3b091a1c.0106140736.29d55695@posting.google.com> Message-ID: <3B29C168.2F929D8F@snakefarm.org> cmkl wrote: > freeze.py is your friend! It lives in the source-code distribution > directory: ./Tools/freeze > Unfortunately python2.1 comes with 'setup.py', which will install > alot of C-modules as shared library. Yes, but you can override this. Uncomment all the modules in Modules/Setup and put a "*static*" in front of them. Now you will still end up having things like strop or regex compiled as shared libs. Have a look at how they're configrued in setup.py and take that over to Modules/Setup. This way I finally managed to build an interpreter that only depends on shared versions of libdl, libm, libc and libutil. I noticed that you can't build the curses module statically. The linker then complains about duplicate definitions of 'tputs' in libncurses and libtermcap. Is there a way to get around this? cg. From kalath at lycos.com Wed Jun 27 06:43:07 2001 From: kalath at lycos.com (Mark Brady) Date: 27 Jun 2001 03:43:07 -0700 Subject: zodb install problem on Windows References: Message-ID: Hi, I have a compiled python 2.1 win32 ZODB (no ZEO yet), mail me if you want it. It's in nice installer format. I was planning to have a crack at ZEO on win32 using the Python on win32 book (it has loads of stuff on setting up services, etc.). I have been busy and am working on a Jython app at the moment but I might have ZEO working on win32 by next week with a bit of luck. Mark. atodd at spam.free.email.com (Andy Todd) wrote in message news:... > "Neil Hodgson" wrote in > : > > >Andy Todd: > >> Hi all, I'm failing terribly here. I've commented out that section of > >> the setup.py file for the ZEO module and everything seems to have > >> installed correctly. But now I am getting an error; > >> ... > >> cl.exe /c /nologo /Ox /MD /W3 /GX -IC:\PROGRAMMING\PYTHON21\Include > >> /Tcsrc/ExtensionClass.c > >> /Fobuild\temp.win32-2.1\Release\ExtensionClass.obj error: command > >> 'cl.exe' failed: No such file or directory > > > > It is failing because it requires a C compiler to build some binary > >libraries and Microsoft operating systems do not come with a C compiler. > >If noone else fixes this first and I can find some time I'll try and > >produce a package that includes binaries for Windows. > > > > Neil > > > > A-ha, I almost suspected as much ;-) Thanks very much for the info. > > I think I've got an old version of DJGPP knocking about somewhere, would > that be up to the job? I'm presuming if I get it installed I will also need > to tell distutils where it is? > > Regards, > Andy From brian at rk-speed-rugby.dk Thu Jun 14 02:38:53 2001 From: brian at rk-speed-rugby.dk (Brian Elmegaard) Date: Thu, 14 Jun 2001 08:38:53 +0200 Subject: Telling python where to look for a script Message-ID: <3B285BFD.D2AC7E26@rk-speed-rugby.dk> Hi, I would like to make python aware of where my scripts are located. I have set pythonpath to \python20\scripts, but I can imagine how this could be filled up by numerous scripts over time, so can python search it recursively? I also tried to copy the way it is done by pmw, which is found, but is not in any pythonpath? Can I do it the same way and how is it done? -- Brian (remove the sport for mail) http://www.et.dtu.dk http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug \TeX, tak From tim at digicool.com Tue Jun 19 15:30:14 2001 From: tim at digicool.com (Tim Peters) Date: Tue, 19 Jun 2001 15:30:14 -0400 Subject: New statement proposal for Python In-Reply-To: <3B2EE589.91065ED5@my.signature> Message-ID: [Greg Ewing] > ... I think there's another issue related to this: sometimes > I'm discouraged from using named values like this because of > the relative inefficiency of looking up globals as opposed to > locals. > > Having a "const" syntax would be one way of addressing > this, since the compiler would have opportunities to > optimise. I'm afraid "making opportunities" isn't that helpful unless they come with working code to exploit them. > Instead of introducing a new syntax, however, I'd rather > see some work done on the implementation of module > namespaces to make them more like local namespaces > are now -- i.e. so that names the compiler knows about > are accessed by indexing into an array instead of > looking up a dictionary. > > I think this would be a much more worthwhile investment > of effort, since it would benefit *all* accesses to > globals, not just "constant" ones! I agree. Jeremy was looking into this seriously, but the month he intended to work on it got lost when paternity leave came a month earlier than planned. So, blame God or not, but there's no bandwidth at PythonLabs to look into this now. Would still make a good PEP. From fbakker at psy.uva.nl Fri Jun 8 09:14:56 2001 From: fbakker at psy.uva.nl (Flores Bakker) Date: Fri, 8 Jun 2001 15:14:56 +0200 Subject: HappyDoc formatting docstring Message-ID: <9fqj2n$bvk$1@bs19.bs.uva.nl> I have a problem using HappyDoc: example code lines in docstrings are appended after each other in HappyDoc generated HTML text.for example: class Jantje: ''' ExampleCode: >>> aBankAccount=BankAccount() >>> aBankAccount.deposit(30) >>> aBankAccount.withdrawal(10) >>> aBankAccount.balance==20 1 ''' This becomes in HappyDoc generated HTML text: ''' ExampleCode: >>> aBankAccount=BankAccount>>>aBankAccount.deposit(30)>>>aBankAccount.withdrawa l>>>aBankAccount.balance==20 1 ''' As one can see, the code lines do not begin each time on a new line, but are appended to te last line. How can one force HappyDoc to verbatim take the example code (propably using something like '::') so that code lines in docstrings each will end up on a new line in HappyDoc generated HTML-text? How can one force HappyDoc to put a line of a docstring **after** another line without using blank lines between them in the docstring? Flores Bakker fbakker at psy.uva.nl From matt at mondoinfo.com Wed Jun 20 14:15:50 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Wed, 20 Jun 2001 18:15:50 GMT Subject: raw_input References: <_x5Y6.18111$9r1.1628947@e3500-atl1.usenetserver.com> Message-ID: On Wed, 20 Jun 2001 14:07:11 -0400, Brendhan Horne wrote: >>> raw_input ("Enter your name:") Enter your name:Brendhan 'Brendhan' >>> print name Traceback (innermost last): File "", line 1, in ? print name NameError: There is no variable named 'name' >Okay What did I do wrong it should have printed my name after the >print name command. Brendhan, You didn't tell Python that you wanted the value that you entered to be associated with the name "name". >>> name=raw_input("Enter your name:") Enter your name:Matt >>> name 'Matt' Regards, Matt From boyd at insultant.net Thu Jun 7 15:40:16 2001 From: boyd at insultant.net (Boyd Roberts) Date: Thu, 7 Jun 2001 21:40:16 +0200 Subject: Compiling Python2.1 under HP-UX with threads ? References: Message-ID: <9foldr$65a$1@neon.noos.net> "M.-A. Lemburg" a ?crit dans le message news: mailman.991937355.8710.python-list at python.org... > ./configure --with-threads > make > rm python > cd Modules > gcc -Wl,-E -Wl,+s -Wl,+b/lib/python2.0/lib-dynload \ > python.o ../libpython2.0.a -lnsl -ldld \ > -lpthread -lm -o python > mv python .. > make install err, shouldn't you have blown away the respective .o's? i don't see much recompilation talking place. From loewis at informatik.hu-berlin.de Sat Jun 16 15:02:23 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 16 Jun 2001 21:02:23 +0200 Subject: Writing new codecs References: Message-ID: "Brian Quinlan" writes: > My question is regarding form: should new codecs be written in C or > Python? It's really your choice. For rarely-used encodings, writing them in Python might make them more maintainable. But then, dealing with individual bytes in C is often easier than in Python. > AFAIK, Python does not currently include any codecs written in Python > (I'm not counting the character mapping ones or the trivial wrappers > around C code). Is this because the current codecs are all "important" > and future codecs should be implemented elsewhere to avoid adding too > much junk to codecmodule.c and unicodeobject.c? > > Or is the pattern of providing the actual implementation in > unicodeobject.c going to continue? I hope not. New codecs should certainly use their own modules, which still leaves the question whether these should be C or Python modules. Regards, Martin From gerson.kurz at t-online.de Thu Jun 7 12:19:13 2001 From: gerson.kurz at t-online.de (Gerson Kurz) Date: Thu, 07 Jun 2001 16:19:13 GMT Subject: Just a small quine Message-ID: <3b1fa942.11180453@news.t-online.de> import sys z,x,y= "}{|}A|k{|kA|}=BE1)|BF}))|$}:~pI~/;@Go{H%{&A?|if }:~pJ"\ "IJ-1~#>=0:GoAG at HG;o{G;%-I&{?|m,kJ,j=C?;/@~o{~D:Gl[c]("\ ")?","G$p:%~;%~;el!]':p%break~;![':p%#':c,'<':d,'-': b,'+':a,',':e,'.':f,'[':g,']':h} s=""" import sys z,x,y= "}{|}A|k{|kA|}=BE1)|BF}))|$}:~pI~/;@Go{H%{&A?|if }:~pJ"\\ "IJ-1~#>=0:GoAG at HG;o{G;%-I&{?|m,kJ,j=C?;/@~o{~D:Gl[c]("\\ ")?","G$p:%~;%~;el!]':p%break~;![':p%#':c,'<':d,'-': b,'+':a,',':e,'.':f,'[':g,']':h} u="" for c in s[:604]+'s='+3*'"'+s.replace(chr(92),chr(92)*2)+3*'"'+s[-118:]: u += '+'*ord(c)+'.'+'-'*ord(c) i() """ u="" for c in s[:604]+'s='+3*'"'+s.replace(chr(92),chr(92)*2)+3*'"'+s[-118:]: u += '+'*ord(c)+'.'+'-'*ord(c) i() From Eugene.Leitl at lrz.uni-muenchen.de Fri Jun 22 13:02:37 2001 From: Eugene.Leitl at lrz.uni-muenchen.de (Eugene Leitl) Date: Fri, 22 Jun 2001 19:02:37 +0200 (MET DST) Subject: [OT] MS EULA -- (will ActiveState become outlaws? ;-) In-Reply-To: References: <3B32F81F.259DBA46@chello.nl> Message-ID: On 22 Jun 2001, Samuel Schulenburg wrote: > I work for a company that has a license from Microsoft to use [...] > means that I have to write my own compression routines. WHAT A WAIST > OF TIME!!! Yes, you're wasting your time with that company. -- Eugen* Leitl leitl ______________________________________________________________ ICBMTO : N48 10'07'' E011 33'53'' http://www.lrz.de/~ui22204 57F9CFD3: ED90 0433 EB74 E4A9 537F CFF5 86E7 629B 57F9 CFD3 From loewis at informatik.hu-berlin.de Thu Jun 21 07:38:42 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 21 Jun 2001 13:38:42 +0200 Subject: Solaris 8/x86: Build problems References: <3b2a7fc2.5552674@news.laplaza.org> <3b2c215f.791227@news.laplaza.org> <3b30b96e.641352@news.laplaza.org> Message-ID: xyzmats at laplaza.org (Mats Wichmann) writes: > Curious (but no more than that, since I now have a working Python 2.1) > why that makes a difference? I had the "CC=gcc" set while I was doing > "configure" on a whole bunch of packages, Python happened to be just > one of them. I have no clue. Having CC set in the environment should still "work". Regards, Martin From malcolm at commsecure.com.au Sat Jun 2 12:59:50 2001 From: malcolm at commsecure.com.au (Malcolm Tredinnick) Date: Sun, 3 Jun 2001 00:59:50 +0800 Subject: iterating over lists In-Reply-To: <1rsnhinct5.fsf@video.bsd.uchicago.edu>; from jdhunter@nitace.bsd.uchicago.edu on Sat, Jun 02, 2001 at 10:04:06AM -0500 References: <1rsnhinct5.fsf@video.bsd.uchicago.edu> Message-ID: <20010603005950.A16329@Vetinari.home> On Sat, Jun 02, 2001 at 10:04:06AM -0500, John Hunter wrote: > I have three lists of equal size: list1, list2 and list3. > > What I want but doesn't work: > > for (x1, x2, x3) in (list1, list2, list3): > print x1, x2, x3 > > I know I can do it by keeping a index count variable: > > N = len(list1) > for i in range(1,N): > print list1[i], list2[i], list3[i] > > but am wondering if there is way to create a tuple of named variables > as in the (x1, x2, x3) example above. This does what you want: for x1, x2, x3 in map(None, list1, list2, list3): print x1, x2, x3 (a nice use of map to remember). > One final question: If I do: > > for i in range( 1, len(list1) ): > print list1[i], list2[i], list3[i] > > I assume the len(list1) call will only be evaluated once. Is this > correct? Yes, that's correct. You can check this by doing something like: l = [1, 2, 3] for i in range(len(l)): l.append(i) print i and notice that it only goes through 3 times, despite the growth in len(l). Cheers, Malcolm -- A day without sunshine is like, night. From michael at trollope.org Sat Jun 23 14:37:50 2001 From: michael at trollope.org (Michael Powe) Date: 23 Jun 2001 11:37:50 -0700 Subject: Another Wart! string.find() [ was: namespace issue? ] References: Message-ID: <8766dn2gap.fsf@cecilia.trollope.org> >>>>> "Tim" == Tim Peters writes: Tim> [Chris Barker] >> Returning -1 was an unfortunate choice for two reasons: >> it is not a false value >> it is a valid index into a string Tim> Historical note: at the time these functions were designed, Tim> negative indices were not allowed: sequence[negative_int] Tim> raised an exception. Allowing the latter was a later Tim> addition to the language, and was a mixed blessing (for this Tim> and other reasons; but I think it was a net win). >> This is all kind of useless discussion however as string.find >> is in far too much code as it is. Tim> Yup: learn to love it, or be killed . Well, IIRC, the introduction of ANSI C broke some old implementations, so precedent is there. Any such changes are simply likely to cause implementations to be brought into compliance on a 'need' basis. mp -- Michael Powe Portland, Oregon USA 'Unless we approve your idea, it will not be permitted, it will not be allowed.' -- Hilary Rosen, President, Recording Industry Association of America From tdelaney at avaya.com Tue Jun 12 20:34:01 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Wed, 13 Jun 2001 10:34:01 +1000 Subject: range and xrange Message-ID: Just a little bit of fun code ... which gets rid of range(len(list)) bits everywhere ... however, it is slightly slower as it has to trap an exception to work. If you wish to be more explicit, you can import __builtin__ and have the default value for the range/xrange functions be __builtin__.__dict__['range'] and __builtin__.__dict__['xrange'] respectively - you can also assign these to __builtin__ to make them work everywhere. def range (start, stop=None, step=1, range=range): """""" start2 = start stop2 = stop if stop is None: stop2 = start start2 = 0 try: return range(start2, stop2, step) except TypeError: assert stop is None return range(len(start)) def xrange (start, stop=None, step=1, xrange=xrange): """""" start2 = start stop2 = stop if stop is None: stop2 = start start2 = 0 try: return xrange(start2, stop2, step) except TypeError: assert stop is None return xrange(len(start)) a = [5, 'a', 'Hello, world!'] b = range(a) c = xrange(4, 6) d = xrange(b) e = range(c) print a print b print c print d print e print range(d, 2) Tim Delaney Avaya Australia +61 2 9352 9079 From jajvirta at cc.helsinki.fi Thu Jun 28 01:19:13 2001 From: jajvirta at cc.helsinki.fi (Jarno J Virtanen) Date: 28 Jun 2001 05:19:13 GMT Subject: Is this a true statement? References: <8NuZ6.362378$oc7.42924874@news2.rdc2.tx.home.com> <3B3788A2.3BD1D672@tundraware.com> Message-ID: 25 Jun 2001 18:54:02 GMT Tim Daneliuk wrote: > I still do not understand/agree with this line of reasoning entirely. > As I mentioned in a previous post, one has to define what we mean by > "do" or "program". It is a fundamental truth of Computer Science that > all Turing-Complete languages have *exactly* the same computational > abilities - i.e., They all handle the exact same set of algorithms - > in particular, those algorithms which are Turing Computable (which > excludes things like the Halting Problem). This *includes* all > "interactions with the outside world" because such interaction > is, by definition, algorithmic. I think it is still the fundamental _hypothesis_, although it has strong evidental support. :-) > (Fine Point: There is a debatable point here about whether adaptive > algorithms like those found in Genetic Programming are really formally > "algorithms" at all because they do not behave consistently when faced with > he same input conditions, but that's way outside the scope of this discussion.) I remember reading from a book titled "Mathematics: 2001 and beyond" (or something like that), that in theory a networked group of computers which all evolve independently is not restricted to "turing-completeness", but I honestly didn't grasp all the details. ;-) jarno - i think i shouldn't be nitpicking since i'm not a scientist anyway From ullrich at math.okstate.edu Sun Jun 3 12:13:34 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 03 Jun 2001 16:13:34 GMT Subject: random References: <3b1a5442.2461877@nntp.sprynet.com> Message-ID: <3b1a60f3.5711223@nntp.sprynet.com> On Sun, 03 Jun 2001 15:21:13 GMT, ullrich at math.okstate.edu (David C. Ullrich) wrote: >On Sun, 03 Jun 2001 05:51:12 GMT, "Nick Perkins" >wrote: > >> [...] >>I may be mangling this a tiny bit, not being a mathematician, but I can see >>where some of the confusion may have set in. It is easy to mis-understand >>Chaitan's work as giving an algorithm for producing a 'truly' random number. >>In fact, what I think he shows, is that there is a number that is 'truly >>random', but producing the Nth bit of that number requires a program that is >>at least N bits long. > >Read it again. There is _no_ algorithm to find the N-th bit. None >whatever. > >That's not quite accurate, or at least it's susceptible to >misinterpretation. Technically, the bits are recursively enumerable >but not recursive: There _is_ an algoorithm which will ouput >a sequence of reals, and those reals _will_ converge to Omega. >Hence (well, there are details here as well, but let's just say >"hence") the bits in the approximations _do_ converge to the bits >in Omaga. So there _is_ something which will eventually print >out the first 100 bits of Omega. But there is no way to know >_when_ it's got the first 100 bits right. > >Um, that's the way it seems to me, anyway, based on what I thought >that stuff was all about and what I read just now in that paper. >I could be misinterpteting something. Not that readers are likely to be reading carefully enough that it's going to matter, but just for the sake of telling no lies: I put my finger on what was bothering me about what I said here. It's not true that the sequence of bits of Omega is recursively enumerable. What's true (assuming that the N-th bit is 1 if the N-th program halts and 0 otherwise) is that the sequence of N for which the N-th bit is 1 is recursively enumerable. The set of N for which the N-th bit is 0 is _not_ recursively enumerable (and hence the sequence of bits of Omega is not recursively enumerable.) (No correction to my explanation of what I meant, just on the usage of the big words.) David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From aahz at panix.com Tue Jun 5 13:29:27 2001 From: aahz at panix.com (Aahz Maruch) Date: 5 Jun 2001 10:29:27 -0700 Subject: why huge speed difference btwn 1.52 and 2.1? References: <9f8fgs$ooo$1@knot.queensu.ca> <9fdjsc$pn4$1@panix2.panix.com> <3b1bcf7a.12528354@news.ccs.queensu.ca> Message-ID: <9fj4tn$nr0$1@panix6.panix.com> In article <3b1bcf7a.12528354 at news.ccs.queensu.ca>, Robin Senior wrote: > > for state in states.keys(): > #(STATENAME) OR (STATE ABBREVIATION) > if ( (re.search(' '+state+'( |,)', line, re.IGNORECASE)) or (re.search(' '+states[state]+'( |,)', line, re.IGNORECASE)) ): > filename = string.replace(state, ' ', '_') > g = open('states/'+filename+'/'+str(year)+'.TXT', "a") > g.write(line) > g.write("\n") > g.close() > f.close() In addition to the other comments you've received, you should probably move the g.open() outside this loop. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Do not taunt happy fun for loops. Do not change lists you are looping over." --Remco Gerlich, comp.lang.python From tdelaney at avaya.com Sun Jun 3 21:07:44 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Mon, 4 Jun 2001 11:07:44 +1000 Subject: I had a thought ... (I know, call the newspapers). Message-ID: > Rather then stick to a particular character to denote that > something is > currency, this would be an ideal opportunity to internationalize. > Further, by saving the unicode representation of the symbol used ($, > Euro, Pound, Franc, Lire, Yen etc.) one has the potential for doing > currency conversion with some to be specified __InfixOperator__. Hmm ... so does this mean that any currency manipulations would be dependent on a working internet connection, and a working and correct currency conversion site? ;) Tim Delaney From donod at home.com Mon Jun 4 12:16:53 2001 From: donod at home.com (Don O'Donnell) Date: Mon, 04 Jun 2001 16:16:53 GMT Subject: (no subject) Message-ID: <3B1BB4BD.DD70758D@home.com> Tim Peters wrote: > > [Don O'Donnell] > > ... > > If by "floating-point-decimal" you mean internal representation of > > both the mantissa and the exponent by some sort of a binary-coded > > decimal, let me point out that it is not necessary to go to full > > decimal in order to to achieve the `7.35` == "7.35" goal.> > > By letting the exponent represent powers of 10 rather than 2, the > > base (or mantissa) and exponent can both be represented in binary > > as an int or long. Thus, the internal calculations can use the > > fast integer hardware instructions, rather than decimal arithmetic > > which would have to be done by software. > > ... > > See > > nt.py> > > for a fixed-point version of that. For "typical" commercial use, the > problem is that converting between base-2 (internal) and base-10 (string) is > very expensive relative to the one or two arithmetic operations typically > performed on each input. For example, hook up to a database with a million > sales records, and report on the sum. The database probably delivers the > sale amounts as strings, like "25017.18". Even adding them into the total > *as* strings would be cheaper than converting them to a binary format first. > > In addition, once you're outside the range of a native platform integer, > you're doing multiprecision operations by hand anyway. Python's longs use > "digits" in base 2**15 internally, but *could* use, say, base 10**4 instead. > The code would be almost the same, except for using different low-level > tricks to find twodigits/base and twodigits%base efficiently. Thanks for your comments, Tim. I agree that in most commercial environments, input, moving, formatting and output of numbers exceeds the amount of actual calculations that are done with them. Hence the early business oriented computers did all their calculations in some form of decimal format, to save the costly dec-bin-dec conversion steps. The "revolutionary" IBM 360 of the '60s was the first to have both floating-point hardware for scientific processing as well as fixed-point "packed-decimal" hardware for business use. With today's fast processors however, the radix conversion steps are hardly noticeable. I've done a lot of COBOL (yuck) programming on Univac/Unisys mainframes, which, lacking hardware decimal instructions, did all their fixed-point processing in binary. I never encountered any performance problems. Quite the contrary, they were incredibly fast machines for commercial work. I took a look at your FixedPoint.py module. Very nice work, thanks. As it turns out I already had downloaded ver 0.0.3, but had forgotten about it. Thanks for the update. I notice that you are also using a long integer internally to store the base number and an int to store a power of 10, as I suggested in my original posting. I was thinking more along the lines of a floating-point type rather than your fixed-point. I.E., with your FixedPoint class: 5.12 * 4.22 == 21.61 (it's rounded to two decimal places) With my dfloat class: 5.12 * 4.22 == 21.6064 (result is exact) I think there is a real need for both types of numbers. Especially in view of the fact that with Python's built in types, what we get today is: >>> 5.12 * 4.22 21.606400000000001 Do you think it would be possible or desirable to extend/generalize your FixedPoint class to handle the "floating decimal" as an option? Or would it be better to make it a separate class or subclass? Any opinions? BTW, I also believe there is a place for a rational type for representing numbers like 1/3 which can't be represented exactly by a finite number of decimal or binary digits. still-learning-from-reading-your-code-ly y'rs -Don From sabren at manifestation.com Tue Jun 19 12:14:15 2001 From: sabren at manifestation.com (Michal Wallace) Date: Tue, 19 Jun 2001 11:14:15 -0500 (CDT) Subject: Indentation In-Reply-To: <9gnoom$cpn$1@bob.news.rcn.net> Message-ID: On Tue, 19 Jun 2001, GWYoder wrote: > I'm still trying here is what I'm getting... > > Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 > Type "copyright", "credits" or "license" for more information. > IDLE 0.8 -- press F1 for help > >>> y = 1900 > >>> leap = "no" > >>> if y % 400 == 0: > leap = "yes" > elif y % 100 == 0: how are you getting to the line starting with "leap"? it SHOULD look like this: >>> y=1900 >>> leap="no" >>> if y % 400==0: ... leap="yes" ... elif y % 100==0: ... pass # whatever the rest of the code is ... >>> you just press enter once after each line, until you're done with the entire if,elif..else construct Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.net www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From prem at engr.uky.edu Mon Jun 18 21:34:56 2001 From: prem at engr.uky.edu (Prem Rachakonda) Date: Mon, 18 Jun 2001 21:34:56 -0400 (EDT) Subject: fprintf(): Python Equivalent???? In-Reply-To: <20010618182456.B8604@glacier.fnational.com> Message-ID: Hi, That was real quick. Thanks a lot for the help, I really appreciate it. Regards, Prem. ____________________________________________________________ Prem Rachakonda ____________________________________________________________ Mailing Address: Work Address: 700 Woodland Ave., #E4 Teradyne Connection Systems, Lexington, Kentucky-40508 44 Simon St., Mail Stop#006, PH :859-323-2880(PP) Nashua, NewHampshire - 03060 eFax:253-323-9795 Work Phone No : 603-879-3442 Fax:603-879-3046 Res. Phone No.:603-247-2651 On Mon, 18 Jun 2001, Neil Schemenauer wrote: > Prem Rachakonda wrote: > > HI, > > Does python have some function which does a formatted file writing > > functionality similar to C's > > > > fprintf(fp,"%s %s",string1, string2); > > fp.write("%s %s" % (string1, string2)) > > The '%' operator is more like sprintf though. > > Neil > From m.faassen at vet.uu.nl Fri Jun 1 19:03:39 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 1 Jun 2001 23:03:39 GMT Subject: docstrings, invention there of References: Message-ID: <9f970b$g46$2@newshost.accu.uu.nl> Laura Creighton wrote: [snip] > I was working for Sun when Gosling was making Oak which became Java. (I > think. They were in a different building and I wasn't quite sure what > they were doing at the time ... so maybe this was _before_ Oak was > being made.) > I do not think that I showed him Genesis directly, but we were in the same > community at the same time --- and even if I left Sun before Genesis > got docstrings, I pretty well infected everybody I knew about Genesis > as soon as I found out about it, and the number of people Gosling and > I have in common fit comfortably in a large football stadium. Ah, so *that's* why Java is that much like LPC! I mean, it's an object oriented language with a C syntax, though of course LPC is mostly dynamically typed (with type checking hacked on sometimes), while Java is statically typed. I always wondered whether there was some connection. Oh, by the way, I've seen you posting here a lot and I Know Who You Are. That is, I know you through Jacob, who has visited us in Angalon on occasion for years. Send him regards from Maguest and he'll know. Nice to meet you; I've heard much about you and I am impressed! And log onto Angalon sometime if you want to chat. I already tried to get Jacob to get you there, and the same day I discovered you were posting here, so why not extend the invitation myself. Oh, yeah, for everybody who is wondering, this is a coded PSU message. It doesn't mean anything. It's not a personal note or anything. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From skip at pobox.com Mon Jun 11 16:20:33 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 11 Jun 2001 15:20:33 -0500 Subject: Feedback on new floating point info in tutorial In-Reply-To: <20010611191506.DC49F28923@cj42289-a.reston1.va.home.com> References: <20010611191506.DC49F28923@cj42289-a.reston1.va.home.com> Message-ID: <15141.10257.487549.196538@beluga.mojam.com> Fred> Substantial additional material on floating point arithmetic in Fred> the tutorial, written by Tim Peters to explain why FP can fail to Fred> reflect the decimal world presented to the user. I took a quick look at that appendix. One thing that confused me a bit was that if 0.1 is approximated by something ever-so-slightly larger than 0.1, how is it that if you add ten of them together you wind up with a result that is ever-so-slightly less than 1.0? I didn't expect it to be exactly 1.0. Other floating point naifs may be confused in the same way: >>> "%.55f" % 0.5 '0.5000000000000000000000000000000000000000000000000000000' >>> "%.55f" % 0.1 '0.1000000000000000055511151231257827021181583404541015625' >>> "%.55f" % (0.5+0.1) '0.5999999999999999777955395074968691915273666381835937500' I guess the explanation is that not only can't most decimals be represented exactly, but that summing the same approximation multiple times doesn't always skew the error in the same direction either: >>> "%.55f" % (0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1) '0.7999999999999999333866185224906075745820999145507812500' >>> "%.55f" % (0.8) '0.8000000000000000444089209850062616169452667236328125000' IEEE-754-is-full-of-traps-for-the-unwary-ly y'rs, Skip From see at my.signature Tue Jun 19 21:24:37 2001 From: see at my.signature (Greg Ewing) Date: Wed, 20 Jun 2001 13:24:37 +1200 Subject: Any other Python flaws? References: Message-ID: <3B2FFB55.F35720C3@my.signature> "Tony J Ibbs (Tibs)" wrote: > > every quilt should contain a deliberate mistake, since > only God can create something perfect). Yeek! We'd better be careful with these warts, then -- if we accidentally remove the last one, we may get smote with a thunderbolt! -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From senux at senux.com.NOSPAM Sat Jun 30 13:35:26 2001 From: senux at senux.com.NOSPAM (Brian Lee) Date: Sun, 01 Jul 2001 02:35:26 +0900 Subject: How to create Python executable References: <3b3d73cd.48834029@news-server.bigpond.net.au> Message-ID: <3B3E0DDE.9060305@senux.com.NOSPAM> Try py2exe and freeze. py2exe homepage is http://py2exe.sourceforge.net/ and freeze is in Python source tarball. I've ever test to build exe file from a Python source with wxPython and some other my own modules and it works pretty well. Visit their homepage for more. - Brian,. sorular wrote: > A simple question I should've learnt long ago! > > How to make an executable from a python program? > > The code is made up from several python scripts and files in a > directory. It requires ActiveState to run but I want to run it on any > machine as an executable (*.exe) that don't necessarily have python. > > thanks > > ~sor From sholden at holdenweb.com Fri Jun 29 09:21:54 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 29 Jun 2001 09:21:54 -0400 Subject: the center of the world (was Re: Check out O'Reilly's Open Source Convention Highlights) References: <3B3AA82D.1A0FE860@seebelow.org> <3B3B2DED.5303198A@seebelow.org> <9hhri7019jd@enews2.newsguy.com> Message-ID: "Alex Martelli" wrote ... > "Grant Griffin" wrote in ... > ... > > Hey, who said anything about "world"?... > > Kernighan and Ritchie did (they were greeting it, I believe). > > > > But now that you mention it, the US Midwest *is* pretty centrally > > located on a "world" basis. > > > > as-much-as-anything-else-on-this-sphere--ly y'rs, > > An interesting exercise might be to define a *meaningful* > "central location" -- one based on population distribution > (or other geographical distributions of interest). > Personally I'd like a routine to determine the "Pythonicity quotient" of any given location. Python users would all carry around transponder chips with GPS receivers (no point making this a static computation), and each would be allocated a score based on the value of their contributions to comp.lang.python (we can let Guido determine these, since he has little else to do :-). We could then drive a display which showed us when we were in areas of high Pythonicity. And avod or seek them according to our preference. > After all, since tunas are unlikely to attend a conference > on technical computer issues (given that you can tune a > filesystem, but you can't tuna fish), "weighting" the vast > aquaceous parts of the (approximate) "sphere" equally to > the populated landmass may be a fine exercise in geometry, > but doesn't make much sense otherwise. As soon as you want > to move from pure geometry to some kind of geography, I > think some demographic issues must arise. Even without > considering demographics, at least some account could be > taken of land vs ocean and maybe of land with/without > permanent ice covering. > But, of course, you must take Pythonicity into account. Or are you, at a first approximation, assuming equal distribution of Python users throughout the population, and giving each a score of one? Not like you to be so crude in your computational models... > Some data, ordered by-country, can easily be found for free > on the web, http://www.worldbank.org/data/wdi2001/worldview.htm > for example. Latitudes and longitudes of cities in various > countries are also easily available, e.g. at > http://www.realestate3d.com/gps/world-latlong.htm. We can > get a first approximation for a distribution of world human > population by assuming a country's population is divided > equally among its major cities. This will require some work > and supervision because of varying formats etc in the files > being used -- or is there somewhere on the net that already > gives me in a single readable file a lot of data boiled down > to triples (population, latitude, longitude)? Anyway, once > I do have such a file, I can presumably find the "center of > the world" (approximate) -- the one point on the Earth's surface > that minimizes population-weighted sum of great-circle distances > to 'population centers'. Of course I could get different > centers by choosing different weighing factors (country GNP > rather than country population, for example). > > Hmmm, if the coordinates were on a plane, finding the weighed > center would be trivial, but offhand I can't think of how to > do it on a sphere's surface -- I guess there must be some way > more suitable than just solving a generalized extremization > problem -- can anybody suggest one...? > > Of course, there are enough degrees of freedom in the outlined > procedure that it can probably be used for my real purpose, i.e., > proving that the relevant "center of the world" is within easy > walking distance from my home and thereby convincing the PS^H^H > O'Reilly to hold their next conference somewhere that's highly > convenient for me... > You might have guessed that the only reason I live in Fairfax, VA is its high Pythonicity quotient. Even scorint all Python users as one! keeps-the-pythonlabs-crew-looking-over-their-shoulders-ly y'rs - steve From emile at fenx.com Wed Jun 20 21:27:16 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 20 Jun 2001 18:27:16 -0700 Subject: locking dictionaries (was Re: New statement proposal for Python) References: <9gl1rg$p45$1@panix2.panix.com> <3B30203F.B158D356@my.signature> <9gre01$noi$1@panix2.panix.com> Message-ID: <9grion$aq7pc$1@ID-11957.news.dfncis.de> "Aahz Maruch" wrote in message news:9gre01$noi$1 at panix2.panix.com... > and then have the internals use the external API under the covers. > (You'd need a second "can't unlock this dict" variable for internal use, All together now.... duh-duh-duh-duh duh-duh duh-duh (ok... it's been a long week so far...) -- Emile van Sebille emile at fenx.com --------- From johnroth at ameritech.net Thu Jun 14 18:54:55 2001 From: johnroth at ameritech.net (John Roth) Date: Thu, 14 Jun 2001 15:54:55 -0700 Subject: entering password References: Message-ID: "Justyna Bia?a" wrote in message news:slrn9ii7jm.g8j.nell at localhost.localdomain... > > > Hi. > I want to ask, how can i create an entry field to input a password, what means > for me that the text won't be seen directly, but it will be masked by asterisks > e.g. > Thanks in advance > nell > > ps. I am using python 1.6.1 and Tkinter (and Pmw also is possible) Try the "show" option in the "Entry" widget. The operand is a string, and the first character (e.g. "*") will be used as the display value. John Roth From aleaxit at yahoo.com Tue Jun 12 08:40:04 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 12 Jun 2001 14:40:04 +0200 Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: Message-ID: <9g52j2013dc@enews2.newsguy.com> "Roman Suzi" wrote in message news:mailman.992345118.22375.python-list at python.org... ... > >That one is: print. A keyword statement that neither > > May be allow to call functions as statements then? > Then there will be no difference: There are languages that wipe out any difference between statements and expressions (including function calls). Python is definitely *NOT* one of those. Expressions can be used as statements (which occasionally causes a few problems, too:-), but not vice versa. It's highly unlikely that Python will ever change so deeply as to heal THIS 'split' -- particularly since it is not generally perceived as a problem:-). > write file, "this is line" > > Oh... It will be Tcl then... Visual Basic 6 used to have this idea (that you could do without the parentheses in a subroutine call), but VB is losing it in the move to VB .NET (one of many incompatible changes to VB in the 6->.NET migration -- ALL of the changes take VB slightly closer to Python, in syntax and/or semantics, as I mentioned in a post a few days ago). Would you really like to have to invent a new set of rules to distinguish whether pow(2,3),4 (a 2-element tuple (8,4)) or pow(2,3,4) (integer 0) is meant when one writes pow 2, 3, 4 ...?-) Perl has enough trouble with that one, I think. Simple, regular use of parentheses for any function call is one of the many aspects that make Python syntax simpler and more effective. Alex From tjg at hyperlinq.net Sat Jun 23 15:10:49 2001 From: tjg at hyperlinq.net (Timothy Grant) Date: Sat, 23 Jun 2001 12:10:49 -0700 Subject: VI In-Reply-To: <9h0kjj$h7f$1@brokaw.wa.com>; from gardner@cardomain.com on Fri, Jun 22, 2001 at 04:33:49PM -0700 References: <9g9f1v$7oqr5$1@ID-11957.news.dfncis.de> <9gaul7$mth$2@brokaw.wa.com> <52e5ab5f.0106182325.4d1fe0d0@posting.google.com> <9h0kjj$h7f$1@brokaw.wa.com> Message-ID: <20010623121049.B21921@trufflehunter.hyperlinq.net> On Fri, Jun 22, 2001 at 04:33:49PM -0700, Jonathan Gardner wrote: > If I could only figure out how to get it to indent the next line when I end > a line with ":"... set cinwords=class,def,elif,else,except,finally,for,if,try,while might do what you are looking for. -- Stand Fast, tjg. Timothy Grant www.hyperlinq.net Chief Technology Officer tjg at hyperlinq.net HyperLINq Technologies, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 18 days 19:09 hours ago<< From nperkins7 at home.com Thu Jun 28 03:43:58 2001 From: nperkins7 at home.com (Nick Perkins) Date: Thu, 28 Jun 2001 07:43:58 GMT Subject: Recursive functions References: Message-ID: <2fB_6.360994$eK2.73606174@news4.rdc1.on.home.com> non-recursive solutions are usually better in python, but... you can make a copy of a list by using: L2 = L1[:] if you post more of your code and say specifically what it does, you will get more help. "Tom Harris" wrote in message news:mailman.993709842.30168.python-list at python.org... > Hi, > > I am very new to Python, and I am trying to get a recursive function > working. The problem is that the function modifies one of its arguments, > which is not a local copy of a variable (local to this stack frame of the > function, like in call by value in C) but a reference to a variable owned by > the function namespace, so changes to the variable are inherited by other > calls to the same function. I tried copying the argument to a variable in > the function body, but of course this suffers from the same problem. > > This is the idea, but the list just keeps on growing. > > def f(aList): > ... > aList.append(stuff) > f(aList) > > What is the solution? > > Tom Harris, Software Engineer > Optiscan Imaging, 15-17 Normanby Rd, Notting Hill, Melbourne, Vic 3168, > Australia > email tomh at optiscan.com ph +61 3 9538 3333 fax +61 3 9562 7742 > > This email may contain confidential information. If you have received this > email in error, please delete it immediately,and inform us of the mistake by > return email. Any form of reproduction, or further dissemination of this > email is strictly prohibited. > Also, please note that opinions expressed in this email are those of the > author, and are not necessarily those of OptiScan Pty Ltd > > > > From dsh8290 at rit.edu Fri Jun 1 16:18:43 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 1 Jun 2001 16:18:43 -0400 Subject: Iteration index In-Reply-To: ; from tim.one@home.com on Fri, Jun 01, 2001 at 03:42:50PM -0400 References: <20010601153537.A7896@harmony.cs.rit.edu> Message-ID: <20010601161843.A8040@harmony.cs.rit.edu> On Fri, Jun 01, 2001 at 03:42:50PM -0400, Tim Peters wrote: | [D-Man] | > ... | > It is probably O(n) because it is a linked structure and indexing | > isn't a computed offset (like C arrays) | | Python lists are contiguous vectors, same as C arrays in that respect. | | see-listobject.c-ly y'rs - tim What is the difference between a "vector" and an "array" in this context? (Not as in void[] or void* vs. std::vector< void* > ) I took a look at listobject.c and liistobject.h and I see that the list itself is just a PyObject** -- a pointer to a C array on the heap. I also noticed in the 'ins1' function that inserting an element (not at the end) causes all others elements to be moved. Isn't this pretty inefficient or is it such an infrequent operation that it matters less than the O(1) PyList_GetItem? Thanks, -D From skip at pobox.com Fri Jun 22 10:41:30 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 22 Jun 2001 09:41:30 -0500 Subject: File name from file descriptor? In-Reply-To: <5.0.2.1.0.20010622094719.026fcec0@mail.inet.com.br> References: <3B3333FF.BB019208@snakefarm.org> <5.0.2.1.0.20010622094719.026fcec0@mail.inet.com.br> Message-ID: <15155.22810.111236.330182@beluga.mojam.com> Carlos> In some cases, I that it is possible to have a pseudo file Carlos> without a true name (I think standard input is one example, but Carlos> I'm not sure about the details). In addition, you can have an open file with no presence in the filesystem. This, for example, is valid: f = open("/tmp/trash", "w") os.unlink("/tmp/trash") f.write("foo") -- Skip Montanaro (skip at pobox.com) (847)971-7098 From gerrie at trispen.com Wed Jun 20 09:06:02 2001 From: gerrie at trispen.com (Gerrie Roos) Date: Wed, 20 Jun 2001 15:06:02 +0200 Subject: where's laura? References: <3B2EF0D5.BA50ABF0@trispen.com> <9gocsi$i4a$1@newshost.accu.uu.nl> Message-ID: <3B309FBA.F065F218@trispen.com> Good to know I'm not the only fan Martijn Faassen wrote: > Gerrie Roos wrote: > [nothing] > > Abducted by the PSU. The same thing happened to Moshe. > I miss her too. :) > > I-suspect-she's-just-busy-ly yours, > > Martijn > > P.S. I miss Moshe too. :) > -- > History of the 20th Century: WW1, WW2, WW3? > No, WWW -- Could we be going in the right direction? From kamikaze at kuoi.asui.uidaho.edu Tue Jun 26 17:42:36 2001 From: kamikaze at kuoi.asui.uidaho.edu (Mark 'Kamikaze' Hughes) Date: 26 Jun 2001 21:42:36 GMT Subject: PEP 260: simplify xrange() References: Message-ID: 26 Jun 2001 13:59:55 -0400 in , Guido van Rossum spake: > Here's another sweet and short PEP. What do folks think? Is > xrange()'s complexity really worth having? > PEP: 260 > Title: Simplify xrange() > I propose to strip the xrange() object to the bare minimum. The > only retained sequence behaviors are x[i], len(x), and repr(x). Looks reasonable - are there any uses of the advanced behaviors in the standard libraries? All of my uses are `for x in xrange(whatever):`, but it's possible that someone's doing something weird with it. Are people even using repr on xranges (pickling a repr seems really odd)? You know, this is one of the things that amazes me about Python - you actually *remove* features that aren't useful. (Just leave lambda alone, man, I like and use it...) -- Mark Hughes "I will tell you things that will make you laugh and uncomfortable and really fucking angry and that no one else is telling you. What I won't do is bullshit you. I'm here for the same thing you are. The Truth." -Transmetropolitan #39 From rnd at onego.ru Mon Jun 25 13:16:31 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 25 Jun 2001 21:16:31 +0400 (MSD) Subject: trying using Python to remotely control another Python App In-Reply-To: <9h7ol2+f5sh@eGroups.com> Message-ID: On Mon, 25 Jun 2001 ed_tsang at yahoo.com wrote: >Hi, I am windering if anyone know or tried using Python to remotely >display and/or control another Python App? >how to do that? > >Current situation: > >I am a Python App which has a GUI interface to user that displayand >allow user to control the next action to be performed. But whenever >this app need support, the supporting people need to go to the client >office and do it there? > >It will be nice if we can view what is displayed on the client screen >and control the app remotely. Do we need to add this funcitonality to >transmitt the state of the whole App? > >The app is running on Sun solaris, and we do not have sys admin >control on their side. > >Any ideas? I assume App is running under X window on Solaris? There are apps that could act like PCAnywhere in Windows world. One of such app: x2x I used to do such things some time ago. Of course, you need another X server running to use x2x . (It's very small and simple app, I am sure there are others) The other option is to telnet/ssh to that computer and repair the app. To see how it works you can allow it to show it's windows on your screen: $ xhost +clienthost $ ssh clienthost $ export DISPLAY=techsupporthost:0.0 $ app.py and it will appear before your eyes. (assuming you do not have firewalls to block connections) Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Monday, June 25, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Darth Vader sleeps with a Teddywookie." _/ From shalehperry at home.com Sat Jun 30 17:59:27 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Sat, 30 Jun 2001 14:59:27 -0700 (PDT) Subject: Q: newbie wants to eval() In-Reply-To: Message-ID: > > var, data = string.split(input) > oops (-: This should read: var, symbol, data = string.split(input) # duh! From whisper at oz.nospamnet Sat Jun 23 14:42:20 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 23 Jun 2001 18:42:20 GMT Subject: Is this a true statement? References: <3b34939b.410758@nntp.sprynet.com> Message-ID: <9h2nuc$g6g$0@216.39.170.247> In article <3b34939b.410758 at nntp.sprynet.com>, ullrich at math.okstate.edu says... > On Fri, 22 Jun 2001 12:47:23 -0400 (EDT), "Steven D. Majewski" > wrote: > > > > > > >On Fri, 22 Jun 2001, David Lees wrote: > > > >> Not necessarily. It might go faster if you were comparing a Python > >> built-in operation (coded in C) with something inefficiently coded in > >> C++. But the statement that "Python can do everything C++" is true, but > >> a tautology. You can substitute nearly any language; Basic, C, Algol, > >> Lisp,... and it is still a true statement. > >> > >> david lees > >> > >> > >> MDK wrote: > >> > > >> > Python can do everything C++ can do but just slower. > > > >Wrong, David. > >Turing completeness means that anything you can *COMPUTE* in one > >language you can computer in another. Python, Lisp, C++, etc. > >are all equivalent in that sense. > > > >But you can't *DO* all of the same things in all languages -- for > >example: you can write a device driver in a language if you can't > >specify interrupt vectors or hardware address pointers. > > ??? I thought a device driver was just a file, hence a finite > sequence of bytes. You can certainly use Python to write an > arbitrary sequence of bytes to a file. No doubt it's much easier > in C++ (or rather in typical implementations of C++?) to decide > _what_ sequence of bytes to write to that file, but if we're > talking about what's literally possible and impossible I don't > see how writing a device driver can be impossible in Python. > > Could well be that your distinction between what you can do > and what you can compute makes sense, but I don't see how > _writing_ a device driver is anything but "computation" > (given the appropriate documentation.) Maybe I'm missing > something. > > >-- Steve Majewski > > > > > > > > > > David C. Ullrich > ********************* > "Sometimes you can have access violations all the > time and the program still works." (Michael Caracena, > comp.lang.pascal.delphi.misc 5/1/01) > The reason why you can't write a device driver in pure Python is simple: a device driver requires the ability to read to and write from specific pre-determined locations in the processor's memory and/or I/O space. It would be possible, if best performance where not required, to extend Python with C or ASM (and possibly C++, but not without some dificulty: passing "this"pointers gets in the way when crossing memory management and/or procsss thresholds. This is why you can't write, for example, a multi-tasking OS in pure C++.) which would permit inserting driver start addresses into trap (interrupt) vectors, reading and writing device registers or calling device firmware entry points at specific locations etc. Such systems have been written and probably do continue to exist, particularly along the lines of the higher level parts of the device driver being written in an HL language (even BASIC) and the fast slippery parts written in LL language. I've done as much with Smalltalk on a PC. Of course, with enough glue and the right scaffold, one could glue up enough toothpicks to reach the moon. Dave LeBlanc From tim.one at home.com Thu Jun 21 22:44:23 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 21 Jun 2001 22:44:23 -0400 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) In-Reply-To: Message-ID: [Steven D. Majewski] > I think one of the bug missing pieces to make it fit smoothly into > Python was iterators. I sure hope the "bug" part there was a Freudian slip . Iterators are indeed the bee's knees: the existence of the wonderfully minimal two-method iterator protocol answered most of the endlessly vexing questions about how generators should act. "Well, for starters, they should conform to the iterator protocol. Hmm. There's really not much more to it than that, is there?!". So separating these concerns was one of those beautiful unplanned accidents, falling out of a mere decade of intensely focused preparation . > ... > Back in those ancient pre-PEP days, Guido was much more conservative. I'm not sure about that! I'd say more cautious in some ways, out of concern that a small misstep could kill off his creation. But after a decade of never being wrong (and now paying me to tell him that ), I think he has more *confidence* in predicting the consequences of language design decisions, so is less hesitant when he's sure he's right. But Python is still introducing new keywords at the rate of one per 5 years ... > And there were fewer people to bounce ideas off of --- I recall I > was soliciting ideas for a more pythonic syntax, but there wasn't > much interest. ( And the above hack was even too ugly for ME to > defend! ) Me too . From zoodoo at infantry.com Sun Jun 24 05:38:46 2001 From: zoodoo at infantry.com (zoodoo) Date: Sun, 24 Jun 2001 09:38:46 GMT Subject: What's object-oriented? Message-ID: What's the concept/logic behind object-orientation? What is it suppose to mean? From missive at frontiernet.net Mon Jun 25 17:48:03 2001 From: missive at frontiernet.net (Lee Harr) Date: Mon, 25 Jun 2001 21:48:03 +0000 (UTC) Subject: adding instance methods after instantiation References: <3B34C28A.23673.1E1CC8@localhost> Message-ID: <9h8bij$f9q$1@node21.cwnet.roc.gblx.net> On Sat, 23 Jun 2001 23:11:04 -0500, : > ----- Original Message ----- > From: "Bill Bell" >> "Chris Gonnerman" >> wrote, in part: >> > From: "Skip Montanaro" >> > > Lee> Is there some way to make m2 an instance method so that it >> > > will Lee> automatically get passed c1 as its first argument? >> > > >> > > Check out the instancemethod function of the new module. >> > This worked fine. Unfortunately, when I got around to trying to pickle these modified objects I ran in to a problem. I am now looking at maybe saving the text of the new method and re-evaluating it when I go to reload the instance in later invocations. Does anyone know if ZODB is any more versatile in the type of objects it can store? From sholden at holdenweb.com Tue Jun 26 08:50:27 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 26 Jun 2001 08:50:27 -0400 Subject: MS SQL Server References: <51dgjtsbuureuugfcubid11tldg7077sfa@4ax.com> Message-ID: "Ben" wrote in ... > Hi, > > Unfortunately I have to upload data to a MS SQL server ... Can anyone > recommend a tool for doing this or docs\examples :] ... is it ANSI > SQL compliant like MySQL and therefore can use the same commands? > > greatly appreciate any advice > Ben: The easiest way (assuming you have the ability to connect to both databases from Python, otherwise this would be an off-topic post, woudn't it ;-) is to do the whole thing in Python. You don't make it clear whether the data is coming from other relational sources or from somewhere else. THe principle is the same in either case, however. SQL Server is (like most relational systems) ANSI compliant at the lowest level. Fortunately, since all you need to use is the INSERT statement, this should be enough. ODBC is the easiest way to connect to SQL Server, but look at using mxODBC rather than the currently-disfunctional odbc module form the win32 extensions. Hope this helps. regards Steve -- http://www.holdenweb.com/ From shredwheat at mediaone.net Wed Jun 13 11:36:48 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Wed, 13 Jun 2001 15:36:48 GMT Subject: BIG problem if readline strips newlines References: <9g5urc$hrl$1@panix6.panix.com> Message-ID: "Aahz Maruch" wrote > >for line in file.readlines(chomp=1): > > pass > > Um. Think again? Why wouldn't this work? doh, right, my "C" brain took over here, i was thinking the other method wouldn't work and somehow both looping methods turned on in my brain... i guess there would just be a problem with the while 1 idiom while 1: line = file.readline(chomp=1) if not line: break not as big a problem as i originally thought. not with xreadlines and other new looping methods that get us away from the while 1 standard From aleaxit at yahoo.com Fri Jun 1 06:10:34 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 1 Jun 2001 12:10:34 +0200 Subject: Obsolesence of <> (fwd) References: <9f6el30dv5@enews2.newsguy.com> <3B16D681.E12A4554@Lugoj.Com> Message-ID: <9f7pmt029se@enews1.newsguy.com> "James Logajan" wrote in message news:3B16D681.E12A4554 at Lugoj.Com... > Alex Martelli wrote: > [ Shows that Python complex numbers do not support ">" or "<" but > do support "<>" and states: ] > > Here, I cannot write x>y, nor x > reasoning, I shouldn't be able to write x<>y either, right?-) > > Well, that could also be taken as evidence that someone forgot to implement > default ">" and "<" operations for complex numbers, not that they can't be "forgot" would clearly be a wrong inference: the error message when you try to use these operators on complex numbers shows that 'someone' very deliberately DECIDED not to guess at some arbitrary ordering of complex numbers. Given such hints as: http://mail.python.org/pipermail/python-dev/2001-January/011755.html I suspect the 'someone' may be one "van Rossum" guy, so you may want to take the fight up with him...? > against "<>" doesn't exactly endorse the horrible usage if "!=". At least > proponents of "<>" can point to some pseudo mathematical justification for > "<>". All the proponents of "!=" can point to for justification is the usage The "pseudo-mathematical" ideas being those based on < and > which Lulu just proposed? Well then, if those ideas have any worth, then, GIVEN (as decided by the BDFL) that < and > don't apply, neither must <>. The only "justification" needed for != is: SOME inequality operator is needed, and it must definitely not be <>, which WRONGLY suggests analogies to < and >. It was fine as long as < and > were universally applicable in Python. It's not fine now that they aren't. "not =" would be fine IMHO (just as "is not" and "not in" are fine operators today). Presumably Guido's justification for "!=" rather than "not =" is that making an operator by juxtaposing a keyword and a non-alpha symbol looks bad -- operators should be (one or) two keywords OR non-alpha. Whatever -- the exact surface looks don't matter all that much to me, anyway -- as long as whatever symbol IS chosen suggests "NOT - EQUAL", which is exactly the intended semantics, rather than "LESSER - GREATER", which ISN'T (not given the way < and > work today in Python). Besides, given the existence of "print >> blah", we're suffering from a serious surfeit of "order characters not meaning order" already:-). Let's abate it wherever we can...:-) > Or better yet: just accept that neither "<>" and "!=" should be obsoleted > and let this issue die a deserved death. Somebody should inform Guido. "There should be one, and ideally only one, obviously correct way to do something". Having two entirely synonymous operators is unPythonic. It's an ideal, of course, not a practical reality -- pow(x,y) vs x**y, apply(spam,args) vs spam(*args), etc, shows that multiple ways to "do something" can and will survive in Python (particularly for legacy/historical reasons). It's still a worthy ideal to aim at, in my humble opinion. Alex From boyd at insultant.net Thu Jun 7 17:53:19 2001 From: boyd at insultant.net (Boyd Roberts) Date: Thu, 7 Jun 2001 23:53:19 +0200 Subject: floating point in 2.0 References: <9fiptc$m9d$1@panix2.panix.com> <3B1D154B.81016685@home.net> <3B1DC3AE.6EA1F09D@accessone.com> <3B1FCBD8.C43504C1@home.net> <9fokct$o6q$1@hadron.noos.net> <3B1FDB85.E2A7D53A@home.net> Message-ID: <9fot7j$g5r$1@neon.noos.net> "Chris Barker" a ?crit dans le message news: 3B1FDB85.E2A7D53A at home.net... > ... later, when we checked the values, > we found that when you round a double representation of pi to a float, > and then back to a double, you get a bigger number, which we didn't > expect. Here is an example: well this is the sort of stuff i was referring to. float/double/float casts are fraught with peril. floating point is one thing i try and avoid -- i just don't know that much about it, except that it's a minefield. i'll stick with systems/network programming and IP security. From m.faassen at vet.uu.nl Fri Jun 15 15:57:45 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 15 Jun 2001 19:57:45 GMT Subject: Type/Class Distinction References: Message-ID: <9gdpbp$61k$6@newshost.accu.uu.nl> Glyph Lefkowitz wrote: > On Tue, 12 Jun 2001, Tim Peters wrote: > [lots of stuff about floating point] > You know, it never ceases to amaze me how fascinating, subtle, and fun Tim > & co. make floating point math sound. It always Just Works for me. ;) >> In the background Guido is reworking Python's type and class model. >> It should be possible after that's done to subclass from the builtin >> types. If so, then you should be able to subclass the complex type >> and override its coercion policies. > Could somebody please explain to me why removing the type/class > distinction is a good idea? I rather like the fact that it is readily > apparent which objects are implemented in Python and which in C (and my > code is rife with 'if type(xxx) is types.StringType'); if I can't > *implement* in Python I don't understand why it makes sense > to subtype it. It seems like an "OO purity" issue, and as we all know, > practicality beats purity; but if Guido is personally working on it, > there's surely something I'm missing. For a minor win (slightly less work > doing operator overloading to emulate dicts, lists, and floats) it seems > like an awful lot of work. Is there something about writing extension > modules which will be different and better? Right now we have to *treat* 'types' differently from 'classes'. For built-in objects you have to use the type() construct to check what you're dealing with, but for class instances you use isinstance(). Wouldn't it be nice if the language allowed something like this: if isinstance(foo, int): ... elif isinstance(foo, BarClass): ... (backwards compatibility issues aside) No more special casing seems good to me. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From mwh at python.net Sun Jun 3 17:16:55 2001 From: mwh at python.net (Michael Hudson) Date: 03 Jun 2001 22:16:55 +0100 Subject: Inexact representation cases (Re: Against PEP 240) References: Message-ID: "Tim Peters" writes: > It turns out that the closest you can get in IEEE double is > > 1.1 ~= 2476979795053773 / 2**51 > > which is, as a *decimal* number, *exactly* > > 1.100000000000000088817841970012523233890533447265625 How did you get these numbers? I'm sure you posted the routine a week or so back, but I can't dig it out of google. I want to write a sys.displayhook that prints floats exactly, just for extra geekiness value. Cheers, M. -- If you have too much free time and can't think of a better way to spend it than reading Slashdot, you need a hobby, a job, or both. -- http://www.cs.washington.edu/homes/klee/misc/slashdot.html#faq From jcopella at cfl.rr.com Wed Jun 13 04:33:58 2001 From: jcopella at cfl.rr.com (John Copella) Date: Wed, 13 Jun 2001 08:33:58 GMT Subject: How to tell if interpreter is in interactive mode Message-ID: I have some code in a module that I need to run only when the interpreter is running interactively. Is there any way to test for this at run time? I have looked at sys.stdin.isatty(), but this returns 1 when running non-interactively as well (unless you do something odd like redirect stdin to /dev/null). Thanks in advance, John From nperkins7 at home.com Sun Jun 3 01:58:32 2001 From: nperkins7 at home.com (Nick Perkins) Date: Sun, 03 Jun 2001 05:58:32 GMT Subject: why huge speed difference btwn 1.52 and 2.1? References: <9f8fgs$ooo$1@knot.queensu.ca> <3B18587D.11851C1B@earthlink.net> Message-ID: ..have you profiled the script under each version? (i have no other ideas, sorry) "Ron Stephens" wrote in message news:3B18587D.11851C1B at earthlink.net... > I'd like to hear an answer to this also. Have you come up with any ideas? Anyone else??? > > robin senior wrote: > > > I have a pretty simple script for processing a flat file db, running on > > Python 2.1; I tried running it under 1.52 for kicks, and to my surprise it > > ran almost 10 times as fast! Could someone let me know why 2.1 would be so > > much slower? > > > > Cheers, > > -robin > > > > ################## > > > > import re > > import string > > > > states = { > > 'ALABAMA':'AL', > > 'ALASKA':'AK', > > 'ARIZONA':'AZ', > > 'WISCONSIN':'WI', > > 'WYOMING':'WY'} > > > > for year in range(1994, 1998): > > > > f = open('states/USA'+str(year)+'.TXT') > > counter = 1 > > while(1): > > print str(year), counter > > counter = counter + 1 > > > > #convert city name to allcaps (change to string.strip(f.readline()) > > in 1.5.2) > > line = string.upper(f.readline().strip()) > > > > #check for EOF > > if not line: > > break > > > > for state in states.keys(): > > #(STATENAME) OR (STATE ABBREVIATION) > > if ( (re.search(' '+state+'( |,)', line, re.IGNORECASE)) or > > (re.search(' '+states[state]+'( |,)', line, re.IGNORECASE)) ): > > filename = string.replace(state, ' ', '_') > > g = open('states/'+filename+'/'+str(year)+'.TXT', "a") > > g.write(line) > > g.write("\n") > > g.close() > > f.close() > From robin at jessikat.fsnet.co.uk Thu Jun 28 14:38:11 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 28 Jun 2001 19:38:11 +0100 Subject: Using python interpreter over a network References: Message-ID: <0z3crJATm3O7EwQT@jessikat.fsnet.co.uk> In article , pj writes >Greetings. > >I am trying to run a python script in a networked windows NT >workstation. Python is not installed in this box. > >I have mapped another machine's (my win2k box) python (2.1) >installation to the PATH of this NT box. > >I have set PYTHONHOME to Q:\Python while Q: is mapped to >\\my_nt_box\cdrive. I also have Q:\winnt\system32 in the current path >(for python dll). > >Python seems to work under the circumstances. I can run the >interpreter and do simple stuff. But when I try to import some >modules, it says it cant find those. 'win32net' for example. I am not >sure how to make it aware of the fact that everything is under >q:\python. > >Is it a requirement that python should be installed in the local >machine? Or is there something (Env variable ? Registry ?) I can tweak >to make this work. > >Appreciate your time. > >cheers >pj try doing import sys sys.path on my home box this looks like ['', 'c:\\python\\pythonwin', 'c:\\python\\win32', 'c:\\python\\win32\\lib', 'c:\\python', 'c:\\python\\dlls', 'c:\\python\\lib', 'c:\\python\\lib\\plat-win', 'c:\\python\\lib\\lib- tk', 'c:\\python\\numeric', 'c:\\python\\rgbx', 'c:\\python\\devel\\vide ocapture\\python21'] (folded lines aside) and perhaps your python does the same. If that is so, you need to do a conversion and replace the c: with q: for your scripts to run. -- Robin Becker From aleaxit at yahoo.com Fri Jun 15 12:20:48 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 15 Jun 2001 18:20:48 +0200 Subject: VI References: <3B278900.5828FB59@Lugoj.Com> <9gaunm$mth$3@brokaw.wa.com> Message-ID: <9gdcl10oti@enews1.newsguy.com> "Jim Hill" wrote in message news:slrn9ik7rt.o2j.jimhill at meldrick.swcp.com... > In <9gaunm$mth$3 at brokaw.wa.com>, > Jonathan Gardner wrote: > >James Logajan wrote: > >> "vi" is the first and last word in visual editors. Every editor written > >> before or after it are irrelevant. ;-) > > > >Amen. > > And since the expected editor war hasn't broken out, I'll launch a > different offensive by proclaiming absolutely and without room for > disagreement that it is pronounced "vee eye" and those who say "vye" > are bloody peasants who should be repressed by the violence inherent > in the system. I thought _everybody_ knew it's pronounced "six" -- like in "Pope Paul VI", no?! Alex From rnd at onego.ru Tue Jun 12 10:17:25 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 12 Jun 2001 18:17:25 +0400 (MSD) Subject: Rejected Message In-Reply-To: <3B25FA2D.504AAA10@student.gu.edu.au> Message-ID: On Tue, 12 Jun 2001, Joal Heagney wrote: >*laughs* I get the feeling that this was an automated reject. I had to >use the find button on netscape to locate the word(s)/phrase(s). Do I >get a prize? >Shame on you Mark, you're one thoughtless signature among hundreds is >giving comp.lang.python a REALLY bad reputation. > >Administrator at crescere.co.uk wrote: >> >> The attached mail message has been rejected for the following reason: I was about to anounce my new program: ShIt (the executable is called shit) - its a Python progie which generates shell script. But now I have a second thought about it... ;-) OK. I am joking. (Though I really had similar program which I renamed to "doit") Once our university decided to have no sex in URLs. Java suffered as a result: .../classexample/... was visible no more ;-) Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, June 12, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "My cat likes to play Hide-And-Go-Poop." _/ From slinkp23 at yahoo.com Fri Jun 1 14:37:57 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Fri, 01 Jun 2001 18:37:57 GMT Subject: Zope questions and comments (&Tkinter???) References: <3B158C50.887E3D59@earthlink.net> Message-ID: <3B17DFEE.C102004D@yahoo.com> Ron Stephens wrote: > 1. Will Zope be too complex for me??? Specifically, if my primary > interest, in the short run, is to be able to run server side scripts > written in Python (or at least in a Python-like language) , will Zope > allow me to do this? Or will writing scripts in Zope be so complex that > it renders void my attraction for writing in Python because it is simple > and intuitive, i. e. , rather easy and enjoyable? Zope is very big and complex. I find myself looking things up in the docs all the time. I often end up grepping through the zope source as it's faster than finding the right doc. Zope is not nearly as intuitive and nice as just hacking away in Python. For me, the main reasons to use Zope are: 1) The large number of freely available extensions - Zope Products - written by other people. 2) Persistence. I was going to do my sites using CGI until I realized what a nightmare it would be to keep track of the current state of things for every concurrent user. Yuck. Having a long-running robust app server that's designed to keep track of everything is very nice. 3) Built-in user management and access restrictions. 4) Versions: you can start working in a new version, make as many changes as you like, and no-one else will see any changes to the site until you want them to. 5) Undo. The first thing to learn about zope is that *everything* in Zope goes in the Zope database, or at least hooks into it; you can browse the system's management interface through the web, and it *looks* like you're looking at a filesystem, but that's a metaphor. To write Python scripts in Zope, you either: 1) add a PythonScript object - this is code that lives in the zope database, has security restrictions on which modules can be imported, and is editable through the web. 2) add an External Method - this is python code that lives on the filesystem, is not editable through the web, and has no restrictions on what it can do. 3) Write a Product. This is suitable for bigger, more complex things, and it's more work; the best way to learn how to do it is to look up the Boring product on zope.org, download that, and customize it. The biggest problems with Zope for me: 1) Documentation is disorganized, and I haven't found a good overview from a python programmer's POV. It took me a couple months of playing with it before it "clicked" for me. The Zope Book (search for it on zope.org) helps a lot, it's a good intro. 2) DTML, the most common zope page template language, sucks. It's basically html with a few extra tags to let you access variables, loop over lists, etc. It's fine and easy for very simple things, but inevitably you need a bit of python logic in there and things quickly get ugly and very confusing: the interfaces between dtml, python, and the zope namespaces are a real snake farm. There is a project to improve this, based on XML, called Page Templates or something like that (search for TAL on python.org). I think it's included with the latest versions of zope. I haven't had time to learn it yet, docs and examples are still pretty sparse. > 2. I have already discovered that the gui type input/output functions of > my scripts are the hardest part for me. I am only interested in simple > input and output by end users, but I want it to look good and be user > friendly. I do not need fancy graphics nor multimedia, just well > designed attractive forms and user input followed by outputed results in > verbal and numerical form. Will this kind of input/output be a big > problem using Zope? I almost don't dare ask, but I assume Tkinter will > not be supported by Zope? Supported how? You want to run tkinter on the client side? They'd have to have tkinter installed - not likely. Will I really need to resort to other means, > such as JavaScript, to do such things ??? How straight forward is input > and output, in event driven programs, in server side scripting using > Zope??? Zope basically works in the CGI paradigm - you make forms using DTML, you click submit, it does something with the result. If you can't in principle do what you want with CGI, then it won't work with zope either. If you really want event-driven stuff, I suspect java (maybe with JPython) or javascript are the only options that will have any chance of working for most web browsers. > 3. Would I be better served by using CGI, once I find a host that allows > me to do so? If CGI scripts written in Python are just as easy and > flexible as using Zope, maybe that's the way for me to go in the > beginning. I will still need to find a Python CGI friendly host company. > > 4. Any suggestions on host companies for Python and/or Zope? I like hurrah. You can mix-and-match zope with any flavor of cgi and php and mysql and so forth. Very responsive to email, unlike the previous place I hosted, codeit.com. Cheaper too. > 5. I do have an always-on cable modem connection in my home. Should I > consider setting up a very simple web server on my own machine (rather > than finding a Zope Host?). If I could set up such a simple server, > allowing me to run server side Python scripts, or even CGI, I could link > to those pages from my other web site, on my non-Python non-CGI friendly > web host site. You could. But how reliable is your cable modem? How secure is your box? Does it matter to you? > 6. Is Zope simply so complex that I will soon forget about why I enjoy > Python, i. e., intuitive, easy to use fun coding? I often feel that way. It's all due to DTML. Yuck. But I have been able to do a lot with zope. --PW From brian at sweetapp.com Sun Jun 17 13:16:15 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Sun, 17 Jun 2001 10:16:15 -0700 Subject: Writing new codecs In-Reply-To: <3B2C9F7A.82D18F6B@lemburg.com> Message-ID: <002c01c0f751$37467570$445d4540@D1XYVL01> M.-A.Lemburg wrote: > I wasn't aware of the fact that there are UTF-7 modifications > out there... for unicodeobject.c we'd need the standard one of > course; would it be possible to add the modification to the > standard codec and have it use a flag to signal which one to use ? I haven't looked the RFC1642 description in detail yet but there are a fair number of differences between it and RFC2060 that might make using the same core code painful. I'll see how it does. Thanks for the help! From db3l at fitlinxx.com Mon Jun 18 22:56:57 2001 From: db3l at fitlinxx.com (David Bolen) Date: 18 Jun 2001 22:56:57 -0400 Subject: Python Idioms? References: <9gm9fk$pfm$1@news.chatlink.com> Message-ID: "David Stanek" writes: > In reading through the Python source code I came across some oddities. In > some modules, specifically threading, the instance objects are created using > a kind of factory method. > e.g. > class _X: > pass > > def X(*tupArgs, **dicArgs): > return apply(_X, tupArgs, dicArgs) > > When the class could just as easily been named X. Is there an advantage to > doing things this way? > > Also I noticed in the same module: > import sys > _sys = sys > del sys > > What does this do? You still have a reference to the module. What > difference does it make what the name is. Although it's rare, the threading module is one that has been designed to be friendly in a "from threading import *" mode. My guess at the rationale was a combination of the long module name, but also that the module provides a number of threading primitives that are likely to be heavily used within threading code. When you use "from import *" the import mechanism will automatically skip over any entries in the module dictionary that start with "_". So the threading module is conscientious about what names it leaves in its module dictionary that don't start with "_" to avoid polluting the importers namespace. I'm not entirely sure about how the choice between module-level factory functions and classes were made (for example, Thread is a straight class), but one guess I'd made is that this helps prevent subclassing of the basic primitives - at least not without violating the "private" nature of the "_" classes. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From new_name at mit.edu Thu Jun 28 14:17:36 2001 From: new_name at mit.edu (Alex) Date: 28 Jun 2001 14:17:36 -0400 Subject: [Mojonation-devel] need good entropy gathering under win32 (fwd) References: Message-ID: > An easy way to cheat on this is to use urllib or corba to download > hardware generated random numbers from www.random.org. Do they provide some sort of authentication mechanism (so that you know you're getting your numbers from the legitimate owners of random.org, rather than someone spoofing them?) Alex. From tdelaney at avaya.com Wed Jun 13 02:26:16 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Wed, 13 Jun 2001 16:26:16 +1000 Subject: PEP 257: Docstring Conventions Message-ID: > The docstring for a function or method should > 1. summarize its behavior > 2. document > 2.1. its arguments, > 2.2. return value(s), > 2.3. side effects > 2.4. exceptions raised > 2.5. restrictions on when it can be called (all if applicable). > ... Optional arguments should be indicated. > ... It should be documented whether keyword arguments are part of the > interface. > > That is, docstring has nothing to do with internals of the > function? That seems correct to me. The docstring should have enough information for you to be able to use the function/class/etc as a black box - you put things in one end, and something else (maybe) comes out the other. Internals documentation should be in the form of comments. After all (in theory), why should you need to worry about the internals unless you're looking at the source? Tim Delaney From jeff at ccvcorp.com Thu Jun 28 13:06:09 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Thu, 28 Jun 2001 10:06:09 -0700 Subject: win32com question References: <3B3AA1EF.DCC35D04@zebrasoft.co.nz> Message-ID: <3B3B6401.8F148AD0@ccvcorp.com> Matthew Miller wrote: > hi, > > i'm trying to figure out how to use the win32com interface. i haven't > yet figured out how to 'phrase' optional arguments within a python > expression. given something in vba like:- > > Workbooks.Open "spam.xls", ReadOnly:=true, Password:="password" > > how do you phrase this in python/win32. i got this far > > xlapp=win32com.client.Dispatch("Excel.Application") > xlapp.Workbooks.Open("spam.xls") > > but can't figure out how to pass in the named args for the required > functions . > any help would be great. > Thanks... Use keyword arguments: xlapp.Workbooks.Open("spam.xls", ReadOnly='True', Password='pass') Note that, particularly the ReadOnly option, may use COM constants rather than the string "true", so you might need to use from win32com.client import constants xlapp.Workbooks.Open("spam.xls", ReadOnly=constants.True, Password='pass') Of course, you'll have to check your COM server's docs to find what uses constants, and constants are only available if you use early binding (makepy/gencache)... Jeff Shannon Technician/Programmer Credit International From kalle at gnupung.net Mon Jun 11 19:42:17 2001 From: kalle at gnupung.net (Kalle Svensson) Date: Tue, 12 Jun 2001 01:42:17 +0200 Subject: Newbie In-Reply-To: ; from gustafl@algonet.se on Mon, Jun 11, 2001 at 09:15:53PM +0000 References: <20010611151900.11318.00004174@ng-mp1.aol.com> Message-ID: <20010612014217.A6473@father> Sez Gustaf Liljegren: > justsurfn2004 at aol.com (Justsurfn2004) wrote: > > > Hello, im a newbie to all this programming stuff and i just downloaded > > python and i want to know how to use it. Can anyone reccommend any > > websites for me to go to on how to use it? > > It takes some *reading*. > > Download the Python documentation in PDF and start reading the tutorial. PDF format? What format you prefer doesn't have much to do with it, has it? It's all the same content. I myself prefer HTML for reading by the computer, and PostScript for printing. Anyway, I don't particularily recommend the tutorial in the standard docs. Alan Gauld's "Learning to Program" is better for a beginner, IMO. It can be found on http://www.crosswinds.net/~agauld/ or as a dead-tree book by the name of "Learning to Program Using Python", published by Addison-Wesley. > And www.python.org have some other nice tutorials and "getting started" > papers. Read, or hire a private mentor. :-) Don't hire one mentor, get 1031 tutors for free! http://mail.python.org/mailman/listinfo/tutor Peace, Kalle -- Email: kalle at gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From john.thai at dspfactory.com Fri Jun 8 15:45:48 2001 From: john.thai at dspfactory.com (John) Date: Fri, 8 Jun 2001 15:45:48 -0400 Subject: py2exe -i list References: Message-ID: Fixed it.. there shouldn't be a space right after the comma.. "John" wrote in message news:hOMT6.246185$Z2.2812230 at nnrp1.uunet.ca... > Hi, > > What is the syntax for the -l option for py2exe? When I try : > > python setup.py py2exe -i "foo.lib.x" > > This works. But when I add another module like so: > > python setup.py py2exe -i "foo.lib.x, foo.lib.y" > > It complains that there is no module named foo.... > > > Thanks, > > John > > From m.faassen at vet.uu.nl Mon Jun 18 14:10:30 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 18 Jun 2001 18:10:30 GMT Subject: Any other Python flaws? References: Message-ID: <9glg6m$gp2$2@newshost.accu.uu.nl> Carsten Geckeler wrote: > On 14 Jun 2001, Martijn Faassen wrote: [snip] >> This may be considered a minor quibble; the mandatory use of () in >> case of multiple arguments to the % string interpolation operator: >> >> "%s" % "foo" >> >> "%s %s" % "foo", "bar" # doesn't work right >> >> "%s %s" % ("foo", "bar") > This has nothing to do with "mandatory" or optional. This is a question > of operator precedence. The "%" operator has higher precedence as the "," > operator, so grouping with (..) is necessary. Sure, so ( and ) is mandatory. :) I know it's due to operator precendence issues. Doesn't mean it's not something that doesn't bite people. The actually really weird case is the single element tuple, which you can instead write as '% foo'. But since single element tuples are a wart by themselves, this extra magic is necessary. Perhaps a language is possible where single element tuples actually are single elements, though that may introduce other warts. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From garry at sage.att.com Wed Jun 27 13:06:39 2001 From: garry at sage.att.com (Garry Hodgson) Date: Wed, 27 Jun 2001 17:06:39 GMT Subject: python2.1 and RedHat7.1 References: <6g8zieescg.fsf@goethe.klab.caltech.edu> Message-ID: <3B3A129F.73BC6767@sage.att.com> "Robert J. Peters" wrote: > > Michael Ackerman writes: > > > I tried to install the python2.1 rpm for RedHat7.0 on my 7.1 system > > but got a "failed dependency" message saying that it wants: > > libcrypto.so.0.9.6, libssl.so.0.9.6 > > But these files are present, in /usr/lib. So what's going on? > > Any help will be appreciated. > > This was my situation exactly yesterday, when I was trying to install > python2.1 from the rpm onto a RedHat 7.1 system, and got the same > error messages... yet searching in /usr/lib showed the libs were in > fact there: > > [hume 16:14 284]% ls /usr/lib | grep ssl > libssl.a > libssl.so@ > libssl.so.0.9.6* > libssl.so.1@ > [hume 16:14 285]% ls /usr/lib | grep crypto > libcrypto.a > libcrypto.so@ > libcrypto.so.0.9.6* > libcrypto.so.1@ > > So, I poked around with and "rpm --help" and decided to try the > install with the "--nodeps" option (i.e. > > rpm --nodeps --install .rpm > > ) to tell rpm ignore whatever failed dependencies it discovered, since > the necessary libraries were plainly present... that command worked > without error, and the installation seems to be working fine (at least > for the first 24 hours...). an alternate way that worked for me is to get the src rpm and do: rpm --rebuild to rebuild the rpms, then installed them. -- Garry Hodgson sometimes we ride on your horses Senior Hacker sometimes we walk alone Software Innovation Services sometimes the songs that we hear AT&T Labs are just songs of our own garry at sage.att.com From lac at cd.chalmers.se Mon Jun 4 08:57:15 2001 From: lac at cd.chalmers.se (Laura Creighton) Date: Mon, 4 Jun 2001 14:57:15 +0200 (MET DST) Subject: John Grayson wants me on drugs. Message-ID: <200106041257.OAA16775@boris.cd.chalmers.se> Either on general principals or because I know his dirty little secret as does any hacker as has read Python and Tkinter programming. John Grayson discusses PMW a lot. lots of the book. All of Appendix C of this book is called Pmw reference: where he says 'The information presented in this appendix has been largely generated, in a manner similar to appendix B, using python programs to walk the Pmw package and the Pmw HTML documentation which was then processed to generate a large ASCII file which contained headings, text, and tables ready for importing into FrameMaker, which was used to produce this book.' I say it more succinctly. ``This is not my work. It is the HTML written by the guy who wrote the PMW documentation''. It turns out that the guy who wrote the doc is the guy who mostly wrote PMW -- as his credits page which, surprise, surprise, is the only doc I could find Grayson did not steal mentions. That credits page which hands out a generous amount of glory to all the people who helped him as a rightous hacker should. if you download the software and put it' some place which Grayson did in order to do his `generation' you will end up with something like this: file:/u/lac/src/Pmw/Pmw_0_8_5/doc/starting.html which says this: Acknowledgements The initial ideas for Pmw were blatantly stolen from the itcl extensions [incr Tk] by Michael McLennan and [incr Widgets] by Mark Ulferts. Several of the megawidgets are direct translations from the itcl to python. The base classes and most megawidgets were written by Greg McFarlane and Peter Munnings. Contributed megawidgets include: Pmw.TimeCounter by Joe VanAndel, Pmw.Group and an early version of Pmw.NoteBook by Case Roole, Pmw.ScrolledCanvas, Pmw.ScrolledFrame and another early version of Pmw.NoteBook by Joe Saltiel and Pmw.OptionMenu by Roman Sulzhyk. A big thank you to the following people for their bug reports, fixes, enhancements and suggestions: David Ascher, Robin Becker, Siggy Brentrup, Mark Colclough, Jerome Gay, Clemens Hintze, Rob Hooft Jack Jansen, Jonathan Kelly, Magnus Kessler, Matthias Klose, Andreas Kostyrka, Fredrik Lundh, Magnus Lycka, Graham Matthews, Dieter Maurer, Michael McLay, Daniel Michelson, Georg Mischler, Rob Pearson, Case Roole, Joe Saltiel, Roman Sulzhyk, Shen Wang, Chris Wright, and Guido van Rossum. Special thanks to Case Roole and Michael McLay for help with getting Pmw to work with python 1.5 packages and many other nifty features. My deepest apologies if I have forgotten anyone. Please let me know. The Pmw home page and project site is made available courtesy of Sourceforge. The current maintainer is Greg McFarlane. If you have any comments, enhancements or new contributions, please contact me at gregm at iname.com. -------------------------------------------------------------- Actually there is another he left out. http://pmw.sourceforge.net/doc/copyright.html that was supposed to be there as well, you know John. Telstra said the above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. I'm not a lawyer, John but I might be a little worried. --------- Okay, this is where the fun starts. Why am I telling you all this? remember kindly Greg McFarlane, the man who sent me email every night for a week so I could get my poor lame brain around event driven programming and not bother him with any more fool questions. Remember My deepest apologies if I have forgotten anyone. Please let me know. ----------- But _who_ did John Grayson forget? 1 guess! Greg McFarlane! His name is not in the index, not in the front of Appendix C, not where he first mentions PMW, goodness it might be in one obscurte footnote of the terribly tacky sort he has all over the book, i haven't memorized the thing, but I am telling you that it is in none of the obvious places and I don't think its anywhere. And when full of righteous anger I send off an email to kindly Greg McFarlane, he says, 'don't worry. its not important. Do you need any more help with event driven programming or are you getting the hang of it now?' I let it go Greg, I really did, until the man attacked me publically. Then I just couldn't resist. I hope you do not mind too much. Laura From hinsen at cnrs-orleans.fr Fri Jun 29 13:08:05 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 29 Jun 2001 19:08:05 +0200 Subject: the center of the world (was Re: Check out O'Reilly's Open Source Convention Highlights) References: <3B3AA82D.1A0FE860@seebelow.org> <3B3B2DED.5303198A@seebelow.org> <9hhri7019jd@enews2.newsguy.com> <9hi42h01og2@enews2.newsguy.com> Message-ID: "Alex Martelli" writes: > > But that doesn't minimize the distance on the surface. > > Doesn't it (in terms of great-circle distance)? I can't prove > it in my head either way, but trying to visualize a few cases > does suggest the requested surfacepoint IS obtained this way. The surface distance is a monotonous function of the 3D (straight line through the eartch) distance, but not a linear one. So summing up one or the other gives different weights to the individual distances. > available on the net. But then for pragmatism one should > count frequent-flyer miles as a bonus, shouldn't one? Sure, to add some complexity. Konrad. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From mikeb at mitre.org Fri Jun 8 16:13:08 2001 From: mikeb at mitre.org (Mike Brenner) Date: Fri, 08 Jun 2001 16:13:08 -0400 Subject: RS232 support for DOS on 486? References: Message-ID: <3B2131D4.58DA7231@mitre.org> I agree with Anurag. I own and have access to more DOS machines than windows or linux or dual-boot linus/windows machines. And DOS is a faster way to get many pieces of work done than windows. If someone had the time to bring Python up to date on a DOS-extender (say without threads or wxwindows), especially djgpp, it would make a lot of old computers much more useful. DOS is not dead when Microsoft stops selling it. DOS is dead when people stop using it and throw away their old computers. Anurag said: > I have a strong point to make. The ONLY purpose of the Usenet, as I > see it, is to spread knowledge. Unfortunately, far too often too much > is made of "off topic" thingy. If a post in it's basic theme is > appropriate for a newsgroup (as this one is) then there is no reason > why any replies to that post, even if seen deviating a bit from the > main theme, should not be posted. > > In particular, comp.lang.python lurkers (like me) who have followed > this thread and are not as knowledgeable as Oleg would certainly like > to know what he did with the DOS Extender. From matt at mondoinfo.com Sun Jun 10 15:32:22 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Sun, 10 Jun 2001 19:32:22 GMT Subject: bind keys References: <1HPU6.12192$93.94140@zonnet-reader-1> Message-ID: Gorny, > That's not what I ment exactly because I did that already. > Example: In most editors you have an shortcut to > File --> Open file --> by pressing > Control -O you imediately open the fileselectionscreen. > > How do I set these Control-O events so if I press Conrtol-O > in my own program it'll open the fileselectionscreen? Ah yes, that's a little different. I don't think Tkinter supports doing that directly but it is possible to do. The trick is to have your main window accept the key event and act on it. Here's an example of that. There's more detail in Fredrik Lundh's excellent An Introduction to Tkinter. This page (wrapped for line length) may be a good start: http://www.pythonware.com/library/tkinter/ introduction/events-and-bindings.htm Regards, Matt from Tkinter import * import sys class mainWin: def __init__(self,root): root.bind("",self.doSomethingKey) root.bind("",self.quitKey) myMenubar=Menu(root) myMenu=Menu(myMenubar) myMenu.add_command(label="Do something", command=self.doSomething,underline=0) myMenu.add_command(label="Quit",command=self.quit,underline=0) root.config(menu=myMenubar) myMenubar.add_cascade(label="Foo",menu=myMenu,underline=0) return None def doSomethingKey(self,event): self.doSomething() return "break" # No further processing of this keystroke def quitKey(self,event): self.quit() def doSomething(self): print "foo" return None def quit(self): sys.exit(0) def main(): root=Tk() mainWin(root) root.mainloop() if __name__=="__main__": main() From rod_weston at yahoo.com Thu Jun 14 15:10:50 2001 From: rod_weston at yahoo.com (Rod Weston) Date: 14 Jun 2001 12:10:50 -0700 Subject: Upon reflection... Message-ID: Thanks everyone, for your assistance. I have posted messages on Ada, python and smalltalk groups for other perspectives and have arrived at the following conclusions. My objectives are to quickly learn and become productive in a language that properly supports Object Oriented Programming. I want to use free or inexpensive toolsets and I want to have a market for my efforts. I want strong typing because I believe, having worked in a language without typing, that it provides a strong deterrent to serious errors. I want a strong debugging tool, compile-time error trapping and very strong exception handling. I believe I have found the best language to satisfy those objectives in Ada. The real bonuses in Ada are the ability to generate code that is capable of communicating with JavaScript and Cobol (among others) and the speed of execution, provided I use the 'right' compiler **(I'm open to a lot more discussion of *that* topic)**. So I have begun to assemble my Win32 Ada95 environment with GNAT, EMACS, GRASP, AdaSQL, GLADE, AdaCGI, GNATCOM, Lovelace, Learn Ada on the Web (LAW), Ada in Action (online book), Dale Stanbrough's Introduction to Ada, and Introducing Ada95 (Barnes). I've also downloaded what seem to be the preeminent source code libraries so I can see how the best go about programming in Ada. I mention these to encourage suggestions on a suitable professional learning environment. What did I learn from the Python and Smalltalk groups? That they each love their environments, that Python is too slow for serious consideration and that Smalltalk would be worthy of future consideration as an additional language - if I were the type that 'collected' languages, which I am not. Also, that Eiffel seems to be an excellent pure OOP language, but no one seems to be using it for professional development and, other than the distinction of being 'pure OOP', has no powerful arguments for its use over Ada. Further discussion? From mwh at python.net Sat Jun 30 07:37:51 2001 From: mwh at python.net (Michael Hudson) Date: 30 Jun 2001 12:37:51 +0100 Subject: [Python-iterators] While we're at it... References: <9hkckn$lsr$00$1@news.t-online.com> Message-ID: "Eduard Hiti" writes: > | > | Anything else come to mind? The core language coverage is pretty broad > | already, so lots of stuff in the .py libraries should "just work by magic" > | with any iterable argument. OTOH, we all have blind spots, and, e.g., I > | never would have thought of the "right-hand side of a multiple-target > | assignment stmt" context on my own. > | > > Could iterators be made slicable? > > Then a 'fib()[3:6]' would give you the third to fifth fibonacci numbers. I'm not sure that's a good idea, but I would like to see an "iterators" module that provided various common iterator manipulations, so you could have eg: def slice(it, lo, hi): for i in range(lo): it.next() for i in range(hi - lo): yield it.next() Cheers, M. -- Very clever implementation techniques are required to implement this insanity correctly and usefully, not to mention that code written with this feature used and abused east and west is exceptionally exciting to debug. -- Erik Naggum on Algol-style "call-by-name" From aleaxit at yahoo.com Sun Jun 17 16:12:48 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 17 Jun 2001 22:12:48 +0200 Subject: Data Structure Question References: <20010617.090337.1987231011.7258@behemoth.miketec.com> Message-ID: <9gj34k02gv0@enews1.newsguy.com> "Mike Johnson" wrote in message news:20010617.090337.1987231011.7258 at behemoth.miketec.com... ... > I've been looking for the Python equivalent of a Perl hashed array. I > learned about dictionaries from the help, but they don't work in quite the > same way since my keys are not always unique. I may be confused, but surely Perl's hashes DO work identically -- if "a key is not unique", reassigning to the hash's entry for that key will rebind and forget the previous assignment. > I was hoping to do something like: > > diction['thekey']=value > > in a loop. The key and the value are not always unique, so 'diction' ends > up dropping some information. But a Perl hash would behave identically! What am I missing? > On thing that did work was to embed a nested dictionary into a list. > > list=[] > diction={} > > diction['key']='somedata' > list.append(diction) > diction={} > (repeat) > > But... This makes it a terrible pain to search and count keys.... This looks like a complicated way to prepare a list of pairs (two-element tuples) -- if that's what you want, it's simpler to do: list.append(('key', 'somedata')) (repeat) although searching and counting keys, while anything but 'a terrible pain', will be slow: def searchakey(thelist, akey): return [(key,value) for key,value in thelist if key==akey] def countakey(thelist, akey): result = 0 for key, value in thelist: if key==akey: result += 1 return result # or the slower but niftier: return len(searchakey(thelist, akey)) Anyway, a dictionary of lists seems more suited for your needs than a list of pairs: dict = {} dict.setdefault('key',[]).append('somedata') (repeat) and now: def searchakey(dict, akey): return dict[akey] def countakey(dict, akey): return len(searchakey(dict,akey)) # now also quite cheap:-) Alex From donn at drizzle.com Fri Jun 29 12:12:47 2001 From: donn at drizzle.com (Donn Cave) Date: Fri, 29 Jun 2001 16:12:47 -0000 Subject: Setitimer? References: None <9hhcs8$dk56r$1@ID-91520.news.dfncis.de> Message-ID: <993831167.324973@yabetcha.drizzle.com> Quoth "Drop Anchor!!" : | I wish to use the setitimer c call , specifically to set off a SIGALRM every | 1 second. How would i do this in python, how do i access the setitimer call | ? You will have to write a C module. The alarm() function in the signal module will do that, though, if that's all you want. But if there's any way to do what you want without catching signals, that would be worth some effort, since it isn't nearly as much fun in Python as it is in C. Donn Cave, donn at drizzle.com From aahz at panix.com Fri Jun 8 10:49:54 2001 From: aahz at panix.com (Aahz Maruch) Date: 8 Jun 2001 07:49:54 -0700 Subject: Catching Errors References: <3B20E042.DA0AF3C1@usa.net> Message-ID: <9fqomi$9gh$1@panix6.panix.com> In article <3B20E042.DA0AF3C1 at usa.net>, mixo wrote: > >How can I catch errors that I are usually written to standard output? That's what try/except is for. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista gfarber: Thank God, or the belief system of your choice. pddb: Does human perversity count as a belief system? From root at rainerdeyke.com Fri Jun 15 00:39:05 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 15 Jun 2001 04:39:05 GMT Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> Message-ID: "David LeBlanc" wrote in message news:9gbsdv$8ft$9 at 216.39.170.247... > In article , > skip at pobox.com says... > > > > David> My proposal: > > > > David> alias httpport : 80 > > ... > > > > Interesting idea. Why do you prefer ":" over "="? > > > > > I prefer : to = because this isn't an assignment per se. It is not, imho, > a departure from python usage: > > def fn(a,b,c): 'def', while not an assignment per se, has the same semantics as assignment, i.e. a name bound with 'def' can be rebound with assignment and vice versa. The following two statements are basically identical: def f(x): return x f = lambda x: x I consider this a wart in the language. Binding a function to a name is logically and physically the same operation as binding any other value to a name; it should therefore use the same syntax. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From syver at NOSPAMcyberwatcher.com Thu Jun 21 21:10:58 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Fri, 22 Jun 2001 03:10:58 +0200 Subject: Stop/Start Service in Win2k References: <%4vY6.9705$Up.285700@sea-read.news.verio.net> Message-ID: <9gu62r$56l$1@troll.powertech.no> Have you tried to test the names by using net start/stop on the command line? It looks as you've got the wrong names to me. "Robin Siebler" wrote in message news:%4vY6.9705$Up.285700 at sea-read.news.verio.net... > I got a script off the ActiveState site that will stop and start a service > (the script is at the bottom of this post) . It works fine on NT4 and it > works for some services on Win2k, but for most services, I get the below > error: > > > Traceback (most recent call last): > File "", line 1, in ? > File "c:\python21\scripts\winsvc.py", line 37, in service_info > if win32serviceutil.QueryServiceStatus(service, machine)[1] == 4: > File "c:\python21\win32\lib\win32serviceutil.py", line 359, in > QueryServiceStatus > hs = win32service.OpenService(hscm, serviceName, > win32service.SERVICE_QUERY_STATUS) > api_error: (1060, 'OpenService', 'The specified service does not exist as an > installed service.') > > > Could someone tell me why this happens and how to fix it? > > Thanks! > > import win32serviceutil > > def service_info(action, machine, service): > if action == 'stop': > win32serviceutil.StopService(service, machine) > print '%s stopped successfully' % service > elif action == 'start': > win32serviceutil.StartService(service, machine) > print '%s started successfully' % service > elif action == 'restart': > win32serviceutil.RestartService(service, machine) > print '%s restarted successfully' % service > elif action == 'status': > if win32serviceutil.QueryServiceStatus(service, machine)[1] == 4: > print "%s is running normally" % service > else: > print "%s is *not* running" % service > > if __name__ == '__main__': > machine = 'cr582427-a' > service = 'Zope23' > action = 'start' > service_info(action, machine, service) > > > > From jp at ulgo.koti.com.pl Sun Jun 10 17:38:58 2001 From: jp at ulgo.koti.com.pl (Jacek =?iso-8859-2?Q?Pop=B3awski?=) Date: Sun, 10 Jun 2001 21:38:58 +0000 (UTC) Subject: return from class? References: Message-ID: Matthew Dixon Cowles wrote: > I think that the easiest way to solve it is to look at the problem the > other way round. That is, instead of having an entry that is trying to > pull a value from your new window, let the new window push the value > into the entry. yes, that is the solution however, as I told before - I installed Pmw and now I can use ComboBox inside my window, so I don't need another class, but probably soon I will have the same problem again, and now I have idea how to solve it - thanks a lot! -- >From the book the word is spoken Whispers from forgotten psalms Gather all around the young ones "Sign of the Southern Cross" They will make us strong - Ronnie James Dio From Cayce at actzero.com Mon Jun 4 15:21:46 2001 From: Cayce at actzero.com (Cayce Ullman) Date: Mon, 4 Jun 2001 12:21:46 -0700 Subject: Struct question (SOAPpy095) Message-ID: Tom wrote: > I am using Python 2.1, with SOAPpy095, with the Radio Userland SOAP > server. Here is some code I have: > > ################ > import SOAP > import urlparse > import string > import types > import pprint > > soapServer = SOAP.SOAPProxy(urlparse.urljoin(baseServerURL, > examplesDir)) > quote = soapServer.getStockPrice(symbol="AAPL") > print quote > > ################ > > This results in: > > > > My question is, what is this and how do I access it? Forgive me, but > I'm new to Python. > > Tom. SOAP.py attempts to guess when to bubble up a value. For instance, this response : 114.25 will just retrun the float : 114.25 But this response : AAPL 114.25 Will return the getQuoteResponse struct, because the response contains multiple values and must give you a way to get all of them. I'm not sure what the service you are calling returns as you have not provided the endpoint info, but my guess is you are getting more than just the price back. Add this line to the end of your code : print dir(quote) I suspect the actual price will be an attribute of the struct. There is ways to force SOAP.py calls to return you everything and make no guesses for consistent behavior, but it has been our experience that running the default way is more convenient. Cayce From tim.one at home.com Fri Jun 8 17:31:46 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 8 Jun 2001 17:31:46 -0400 Subject: return from finally clause In-Reply-To: <9fr8u3$gj9$01$1@news.t-online.com> Message-ID: [J?rgen Hermann] > Consider this script: > > def spam(ret): > try: > print 1 > try: > print 2 > raise RuntimeError > finally: > print 3 > if ret: return > finally: > print 4 > print 5 > > spam(1) > spam(0) > > and its output > > 1 > 2 > 3 > 4 > 1 > 2 > 3 > 4 > Traceback (most recent call last): > File "exp.py", line 15, in ? > spam(0) > File "exp.py", line 6, in spam > raise RuntimeError > RuntimeError > > That means that if you (accidently?) return within a finally clause, you > effectively eat the exception. It also means that if you deliberately return within a finally clause, you deliberately eat the exception. This is like saying that if you add one to a number accidentally, the number's value increases anyway . > This should be documented, or fixed. Aren't the docs already clear?: http://www.python.org/doc/current/ref/try.html ... If the finally clause raises another exception or executes a return or break statement, the saved exception is lost. ... When use a finally block, you're explictly saying "NO MATTER WHAT-- exception or no exception --do the stuff in this block". If that stuff includes a return, Python returns. You'll find the same behavior in Java (among others). From paul at svensson.org Tue Jun 12 11:53:49 2001 From: paul at svensson.org (Paul Svensson) Date: 12 Jun 2001 15:53:49 GMT Subject: Playing with the grammar: part 2, reserved words as identifiers Message-ID: <9g5dud$q1o$1@newsy.ifm.liu.se> Someone was lamenting that they couldn't do ``foo.from = 17'' or somesuch, and curious as I am, I set out to figure a way that this could safely be allowed. To understand what I was doing, I classified all Python reserved words into four groups: -------------------------------------------------------------------------- Keywords (only appears as the first word in a statement): def print del pass break continue return raise import from global exec assert if elif else while for try except finally class Guidewords (the grammar can be parsed without them): as import Infix operators (sortof): or and is in for if Prefix operators (sortof): not lambda -------------------------------------------------------------------------- Guidewords are not a problem; they are not recognized in the grammar, but in a later stage in the parser, so they can already be used as identifiers. For keywords, I initially figured it would be fairly straightforward to provide some feedback from the lexer, letting the parser know when to recognize keywords or not, based on wether it was the first token on a line or not. After inspecting the source, I found this easier said than done, but I also found a different approach. The suggestion was made by someone on c.l.p, to simply catch where a reserved word causes a syntax error, and retry it as an identifier. This solves the problem for both keywords and infix operators, and half ways for the prefix operators. That means ``(from) = 17'' and ``foo.not = 0'' works, but ``(not) = 0'' still breaks. To allow also the infix operators to be used as all kinds of identifiers, requires the parser to look ahead on the next token, before deciding how to classify the word; in fact, for ``lambda'', it might have to look ahead an arbitrarily long distance. Consider the use of ``'lambda'' in a dictionary key: we can't tell for sure if interpreting it as a keyword will cause a syntax error or not untill we know if there are an even or odd number of ``:''s before the closeing ``}''. I only added one token of lookahead, defaulting ambigous cases to be interpreted as keywords; it's always possible to force them to identifiers by wrapping parens around. In addition to these changes, I also decided to not do the retry if the word is the first word of a statement, as I found such usage slightly confusing to read. The bottom line: apply this patch, and you can use all of Python's ``reserved words'' as identifiers; in most cases right away, in all other cases by wrapping parens around them. /Paul -------------------------------------------------------------------------- diff -r -c Python-2.1/Parser/parser.c Python-2.1-UNRESERVED/Parser/parser.c *** Python-2.1/Parser/parser.c Mon Oct 2 06:21:59 2000 --- Python-2.1-UNRESERVED/Parser/parser.c Fri Jun 8 12:56:39 2001 *************** *** 131,141 **** /* PARSER PROPER */ static int ! classify(grammar *g, int type, char *str) { register int n = g->g_ll.ll_nlabels; ! if (type == NAME) { register char *s = str; register label *l = g->g_ll.ll_label; register int i; --- 131,141 ---- /* PARSER PROPER */ static int ! classify(grammar *g, int type, char *str, int use_keywords) { register int n = g->g_ll.ll_nlabels; ! if (use_keywords && type == NAME) { register char *s = str; register label *l = g->g_ll.ll_label; register int i; *************** *** 165,183 **** } int ! PyParser_AddToken(register parser_state *ps, register int type, char *str, ! int lineno, int *expected_ret) { register int ilabel; int err; D(printf("Token %s/'%s' ... ", _PyParser_TokenNames[type], str)); /* Find out which label this token is */ ! ilabel = classify(ps->p_grammar, type, str); if (ilabel < 0) return E_SYNTAX; ! /* Loop until the token is shifted or an error occurred */ for (;;) { /* Fetch the current dfa and state */ --- 165,186 ---- } int ! PyParser_AddToken(register parser_state *ps, int atbol, int supressed, ! register int type, char *str, int lineno, int *expected_ret) { register int ilabel; + int can_retry; int err; D(printf("Token %s/'%s' ... ", _PyParser_TokenNames[type], str)); + can_retry = (type == NAME) && !atbol && !supressed; + retry: /* Find out which label this token is */ ! ilabel = classify(ps->p_grammar, type, str, atbol || can_retry); if (ilabel < 0) return E_SYNTAX; ! /* Loop until the token is shifted or an error occurred */ for (;;) { /* Fetch the current dfa and state */ *************** *** 191,196 **** --- 194,200 ---- if (s->s_lower <= ilabel && ilabel < s->s_upper) { register int x = s->s_accel[ilabel - s->s_lower]; if (x != -1) { + can_retry = 0; if (x & (1<<7)) { /* Push non-terminal */ int nt = (x >> 8) + NT_OFFSET; *************** *** 230,235 **** --- 234,240 ---- } if (s->s_accept) { + can_retry = 0; /* Pop this dfa and try again */ s_pop(&ps->p_stack); D(printf(" Pop ...\n")); *************** *** 238,243 **** --- 243,254 ---- return E_SYNTAX; } continue; + } + + if (can_retry) { + can_retry = 0; + D(printf("Retry as identfier.\n")); + goto retry; } /* Stuck, report syntax error */ diff -r -c Python-2.1/Parser/parser.h Python-2.1-UNRESERVED/Parser/parser.h *** Python-2.1/Parser/parser.h Fri Sep 1 19:29:28 2000 --- Python-2.1-UNRESERVED/Parser/parser.h Fri Jun 8 09:04:18 2001 *************** *** 29,36 **** parser_state *PyParser_New(grammar *g, int start); void PyParser_Delete(parser_state *ps); ! int PyParser_AddToken(parser_state *ps, int type, char *str, int lineno, ! int *expected_ret); void PyGrammar_AddAccelerators(grammar *g); #ifdef __cplusplus --- 29,36 ---- parser_state *PyParser_New(grammar *g, int start); void PyParser_Delete(parser_state *ps); ! int PyParser_AddToken(parser_state *ps, int atbol, int supressed, ! int type, char *str, int lineno, int *expected_ret); void PyGrammar_AddAccelerators(grammar *g); #ifdef __cplusplus diff -r -c Python-2.1/Parser/parsetok.c Python-2.1-UNRESERVED/Parser/parsetok.c *** Python-2.1/Parser/parsetok.c Fri Sep 1 19:29:28 2000 --- Python-2.1-UNRESERVED/Parser/parsetok.c Fri Jun 8 14:34:37 2001 *************** *** 84,89 **** --- 84,92 ---- parser_state *ps; node *n; int started = 0; + int atbol = 1; + int lookahead = -1; + char *ah, *bh; if ((ps = PyParser_New(g, start)) == NULL) { fprintf(stderr, "no mem for new parser\n"); *************** *** 96,103 **** int type; size_t len; char *str; ! type = PyTokenizer_Get(tok, &a, &b); if (type == ERRORTOKEN) { err_ret->error = tok->done; break; --- 99,115 ---- int type; size_t len; char *str; + int supressed; ! if (lookahead != -1) { ! a = ah; ! b = bh; ! type = lookahead; ! lookahead = -1; ! } ! else ! type = PyTokenizer_Get(tok, &a, &b); ! if (type == ERRORTOKEN) { err_ret->error = tok->done; break; *************** *** 118,130 **** if (len > 0) strncpy(str, a, len); str[len] = '\0'; ! if ((err_ret->error = ! PyParser_AddToken(ps, (int)type, str, tok->lineno, ! &(err_ret->expected))) != E_OK) { if (err_ret->error != E_DONE) PyMem_DEL(str); break; } } if (err_ret->error == E_DONE) { --- 130,176 ---- if (len > 0) strncpy(str, a, len); str[len] = '\0'; ! ! supressed = 0; ! if (type == NAME) { ! int *tokens = NULL, *tp; ! if (len == 3 && strcmp(str, "not") == 0) { ! static int next[] = { ! NAME, NUMBER, STRING, ! LPAR, LBRACE, LSQB, BACKQUOTE, ! TILDE, MINUS, PLUS, ! -1 ! }; ! tokens = next; ! } ! if (len == 6 && strcmp(str, "lambda") == 0) { ! static int next[] = { ! NAME, COLON, LPAR, STAR, DOUBLESTAR, ! -1 ! }; ! tokens = next; ! } ! if (tokens) { ! lookahead = PyTokenizer_Get(tok, &ah, &bh); ! for (tp = tokens; *tp != -1; tp++) { ! supressed = 1; ! if (lookahead == *tp) { ! supressed = 0; ! break; ! } ! } ! } ! } ! err_ret->error = PyParser_AddToken(ps, atbol, supressed, ! type, str, tok->lineno, ! &(err_ret->expected)); ! if (err_ret->error != E_OK) { if (err_ret->error != E_DONE) PyMem_DEL(str); break; } + if (type != INDENT && type != DEDENT) + atbol = (type == NEWLINE || type == SEMI); } if (err_ret->error == E_DONE) { diff -r -c Python-2.1/Python/compile.c Python-2.1-UNRESERVED/Python/compile.c *** Python-2.1/Python/compile.c Sat Apr 14 13:51:48 2001 --- Python-2.1-UNRESERVED/Python/compile.c Thu Jun 7 14:00:39 2001 *************** *** 2813,2825 **** static void com_if_stmt(struct compiling *c, node *n) { ! int i; int anchor = 0; REQ(n, if_stmt); ! /*'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] */ for (i = 0; i+3 < NCH(n); i+=4) { ! int a = 0; ! node *ch = CHILD(n, i+1); if (is_constant_false(c, ch)) continue; if (i > 0) --- 2812,2830 ---- static void com_if_stmt(struct compiling *c, node *n) { ! int i, a; int anchor = 0; + node *ch; REQ(n, if_stmt); ! /*'if' test ':' suite (('elif' | 'else' 'if') test ':' suite)* ['else' ':' suite] */ for (i = 0; i+3 < NCH(n); i+=4) { ! a = 0; ! if (TYPE(CHILD(n, i+3)) == COLON) { ! i++; ! if (i+3 >= NCH(n)) ! break; ! } ! ch = CHILD(n, i+1); if (is_constant_false(c, ch)) continue; if (i > 0) From jeremy at alum.mit.edu Sat Jun 23 16:29:18 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Sat, 23 Jun 2001 16:29:18 -0400 Subject: PEP 255: Simple Generators, Revised Posting Message-ID: > That didn't yield "the expected" UnboundLocalError for the same reason: the > affected blocks are actually removed by the *parser*, and "the compiler" proper > never knows they were there -- the "if 0" blocks aren't even in the parse tree. Actually, they are in the parse tree. The compiler ignores "if 0" blocks by explicitly calling is_constant_false() in com_if_stmt and in the if_stmt case of symtable_node(). So it's easy enough to examine that part of the tree. > That makes it difficult to repair, and since nobody writes "if 0" in real life, > that in turn makes the cost/benefit ratio very high. If you disagree, submit a > patch . This would be easy to fix in the case of yield for generators, except that I'm not sure it's easy to fix for names in general. There are lots of other strange possibilities: def f(): if 0: exec foo def g(y): return x + y Should this get a SyntaxError about the bare exec making resolution of free variable x ambiguous? def g(x): if 0: global x Should this get a SyntaxError about an argument being declared global? I'm inclined not to worry about them, because they'd be a PITA to deal with and the "right" choice is far from obvious -- unless Guido wants to offer some pronouncements on just what the heck they mean. Jeremy From rmlecompte at hotmail.com Sun Jun 24 17:14:41 2001 From: rmlecompte at hotmail.com (Ryan LeCompte) Date: Sun, 24 Jun 2001 16:14:41 -0500 Subject: Nested Scopes Question (exec) Message-ID: Hello all, I have been reading PEP 227 concerning statically nested scopes, and I have read that the from module import * and exec statements are not allowed in functions that contain nested function definitions which reference a free variable defined outside of the outer namespace. Wow, that sounds confusing. Here is exactly what I'm playing with: Python 2.1 (#1, May 22 2001, 18:23:10) [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 Type "copyright", "credits" or "license" for more information. >>>from __future__ import nested_scopes >>>y = 1 >>>def f(): ... exec "print 'hello'" ... def g(): ... return y ... File "", line 2 SyntaxError: unqualified exec is not allowed in function 'f' it contains a nested function with free variables >>>def f(): ... exec "print 'hello'" in globals(), locals() ... def g(): ... return y ... >>>f() hello >>>def f(): ... exec "print 'hello'" ... def g(): pass ... >>>f() hello >>> Now, it states in the PEP 227 that the exec and from module import * statements are not allowed in the above cases due to the fact that the compiler would not be able to determine if the value of y that the function g() would return should be from the free variable y in the global namespace, or the local variable y defined in the namespace for f(), because the exec statement could in fact introduce a new local variable that shadows the outer global variable y. Now, it appears that when you utilize the full syntax for the exec statement: exec 'expression' in globals(), locals() or exec 'expression in locals()', etc... the SyntaxError exception will not be raised and the code works as intended. The PEP states that the SyntaxError exception will be raised for "bare execs" which don't utilize the full syntax as given above, but why does the exception disappear when the full syntax is used? How does the compiler know that the exec statement won't introduce a new local variable in the local namespace, and if it does, how does it know at compile time if it should use the global value or the possibly newly defined local value? P.S. --- Aren't the following two calls the same: exec "print 'hello'" exec "print 'hello'" in globals(), locals() So why the different behavior for these two calls when using the above examples with from __future__ import nested_scopes ?? Thanks, Ryan LeCompte rmlecompte at hotmail.com _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com From helend at accessone.com Wed Jun 6 01:43:50 2001 From: helend at accessone.com (Helen Dawson) Date: Wed, 06 Jun 2001 05:43:50 GMT Subject: floating point in 2.0 References: <9fiptc$m9d$1@panix2.panix.com> <3B1D154B.81016685@home.net> Message-ID: <3B1DC3AE.6EA1F09D@accessone.com> Remember that floating point has a mantissa and an *exponent*. So, if I have a binary floating point format with a one bit mantissa and an eight bit exponent I can represent numbers like 1 / 2^16, alternately written as 2^-16. The precise value of this number is: 0.000015258789062500000 and still with that one bit mantissa, giving us less than one decimal digit of accuracy, we can perfectly represent: 0.000000000931322574615478520000 For numbers of this form (2^-n), the number of decimal digits will be n. If you strip off the leading zeroes then it will be roughly n * (1 - base 2 log(10)). Confusing, but perfectly logical. With the mammoth exponents available in a 64-bit double it can take literally hundreds of decimal digits to precisely record the value of a small binary floating point number. Chris Barker wrote: > Aahz Maruch wrote: > > Actually, 2.0 *still* lies: > > > > >>> 0.1 > > 0.10000000000000001 > > >>> '%.55f' % 0.1 > > '0.1000000000000000055511151231257827021181583404541015625' > > > > It just lies less than it used to. > > What the heck are all those digits at the end? Talk about lies, you can > be sure all those digits aren't being stored (at least not in an IEEE > 754 64bit double, which stores approx. 16 decimal digits. Approx. > because it is really a given number of binary digits. I don't have the > exact number off of the top of my head). > > interestingly enough, If you try to diplay more, you get: > >>> '%.70f' % 0.1 > '0.1000000000000000055511151231257827021181583404541015625000000000000000' > > now the extra is all zeros. Also, I get the same 55 digtits, so theya re > not random garbage. Does anyone know what they are? Perhaps the Intel > extra precision FPU bits? > > -Chris > > -- > Christopher Barker, > Ph.D. > ChrisHBarker at home.net --- --- --- > http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ > ------@@@ ------@@@ ------@@@ > Oil Spill Modeling ------ @ ------ @ ------ @ > Water Resources Engineering ------- --------- -------- > Coastal and Fluvial Hydrodynamics -------------------------------------- > ------------------------------------------------------------------------ From paulp at ActiveState.com Wed Jun 6 18:28:24 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Wed, 06 Jun 2001 15:28:24 -0700 Subject: Generating Multiple Class Instances References: Message-ID: <3B1EAE88.9F2730E4@ActiveState.com> Julie Torborg wrote: > >... > > I don't want to change the list, I want to do the same thing as typing > > i_top=Quark(top) > i_bottom=Quark(bottom) Okay, that would require defining variables in your local scope which is weird and probably not a good idea in the long term. A better solution, as you mentioned later, is to use a dictionary. Then you access stuff with i["top"], i["bottom"] etc. >... > This just creates a new ordered array. If I want to access the mass of > top, I still have to know where in the array the top instance lives. > > What I want to do, is starting with my original list, is to make another > list (which is composed of a simple variation on the original list, like > adding the i_ above). You say that you don't want another "ordered array" but then you say you want to make another list. Lists in Python are ordered arrays. If you want random access to things, you need a dictionary. >... > Eventually, all of this will be going into a GUI, and access to all these > parameters will be very non-linear. The big idea here is to keep all the > "attributes" associated with their "objects." It seems to be so well > described by the OOP jargon I can't believe I'm having trouble. I don't think you're having any trouble with the OO stuff at all. >... > But, to be fair, the solution you've provided here is better than what > I've come up with. Maybe there's a way to automatically build a > dictionary that will associate a "name" with each instance. That still > seems like a lot of keystrokes, not to mention CPU load during lookup > (like I said, there are hundreds of list items, I fictionalized this one > for simplicity), especially when I have a gut feeling that with a little > finesse, there's a much more elegant solution. Or there should be. If you want random access lookup based on names, there is no faster way than a dictionary. Even if you set up a bunch of global variables like i_this and i_that, those variables would still go in a Python dictionary behind the scenes. Python has no problem with looking through thousands of items in milliseconds. Until you get into hundreds of thousands of items, I wouldn't worry about performance much. flavors = [] for each in flavornames: flavors[each] = Quark(each) -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From writeson at earthlink.net Sat Jun 2 11:17:45 2001 From: writeson at earthlink.net (Doug Farrell) Date: Sat, 02 Jun 2001 15:17:45 GMT Subject: GUI suggestions References: <_HTP6.34744$BN6.2065334@newsread1.prod.itd.earthlink.net> <9ep8p601h3k@enews2.newsguy.com> <9eu916$g24$1@news1.xs4all.nl> Message-ID: Boudewijn, Thanks for the feedback, I will also look at PyQt and Qt Designer. Can you tell me what I might need to run this on a Sun Solaris with OS 2.5.1? No problem if you don't know. Doug "Boudewijn Rempt" wrote in message news:9eu916$g24$1 at news1.xs4all.nl... > Doug Farrell wrote: > > Alex, > > > Thank you very much for the great feedback on GUI's with Pyton. I probably > > should have mentioned the utility program I write in C++ that is getting the > > GUI frontend run on Sun Solaris, so I'm not to concerned with cross platform > > development, at least for this application. I'm kind of baised towards using > > wxPython as I've done some reading and downloaded the system and tried the > > demos. I will look at Tkinker as well since I have no knowledge of that on > > which to base a decision, as of yet anyway. > > > This last year I jumped ship from MS windows development and joined an > > online group doing CGI on the Sun platform. After getting up to speed a > > little bit on Unix/Linux I honestly can say I don't know why I waited so > > long!! Windows falls short in many areas that Unix has in spades. Though I > > liked developing VC6, I didn't like all of the holes and 'guru only' > > knowledge that was necessary to get a program to run well under Windows and > > MFC. > > If you're working on Unix then your choice is probably widest. For > instance, PyQt, Qt and Qt Designer are absolutely free on Unix. In > fact, someone with a developers license for Qt for Windows can > distribute a compiled version of Qt Designer together with the > source - it's GPL, after all. If you come from a C++ background I'd > go with either wxPython or PyQt, since both translate nicely back and > forth. You can even design the GUI in Qt Designer and generate both > Python and C++ source code. > > -- > > Boudewijn Rempt | http://www.valdyas.org > From me at mikerobin.com Tue Jun 19 15:07:12 2001 From: me at mikerobin.com (Michael Robin) Date: 19 Jun 2001 12:07:12 -0700 Subject: Any other Python flaws? References: Message-ID: <52e5ab5f.0106191107.656d0a6a@posting.google.com> "Tony J Ibbs (Tibs)" wrote in message news:... > Duncan Booth wrote: > > BCPL Octal constants use '#', e.g. #177 and hex constants > > are '#X', e.g. #X7F, so like the dangling else, the leading > > 0 was an 'improvement' brought in post BCPL. According to my "The Programming Language B" (Johnson and Kernighan, 1973) report, the leading 0 for octal seems to have been introduced here, square between BCBL and C. m From menscher+usenet at uiuc.edu Fri Jun 15 02:39:50 2001 From: menscher+usenet at uiuc.edu (Damian Menscher) Date: Fri, 15 Jun 2001 06:39:50 GMT Subject: VI References: <9g9f1v$7oqr5$1@ID-11957.news.dfncis.de> <9gaul7$mth$2@brokaw.wa.com> Message-ID: Jonathan Gardner wrote: > Emile van Sebille wrote: >> I always liked the description that vi has two modes: one beeps at you, >> and the other destroys your file. ;-) > When I was first learning vi, I found the beeps quite common. What was even > more mystical is the way it would mangle your text with ease. Ahh, yes. Who hasn't accidentally bumped the caps lock key and then attempted to scroll down? ;) > A great way > to learn how to use vi is to go to normal mode, and type a random letter. > That's how I learned about and . Cool feature. Yes, I've learned a fair bit from random banging and watching what happened. One of these days I should actually read the docs and learn all the features.... Damian Menscher -- --==## Grad. student & Sys. Admin. @ U. Illinois at Urbana-Champaign ##==-- --==## www.uiuc.edu/~menscher/ Ofc:(217)333-0038 ##==-- --==## Physics Dept, 1110 W Green, Urbana IL 61801 Fax:(217)333-9819 ##==-- From nperkins7 at home.com Sun Jun 3 01:51:12 2001 From: nperkins7 at home.com (Nick Perkins) Date: Sun, 03 Jun 2001 05:51:12 GMT Subject: random References: Message-ID: "Tim Peters" wrote in message > Chaitan is a bit of a self-promoter, and his rhetoric is often colorful, but > by all indications his work is rock solid. A very nice high-level intro is > this transcript of a lecture he gave at CMU: > > http://www.cs.umaine.edu/~chaitin/cmu.html > > I just read (almost all of) that page. Very mind-blowing stuff. I am not sure, but think I managed to find the answer to this question: >"David C. Ullrich" wrote in message >news:3b17a2f1.411766 at nntp.sprynet.com... > ... >> Could you give us a hint regarding exactly what work >> of Chaitin's shows we can get "truly random" numbers from >> arithmetic algorithms? Chaitan's work seems to imply that no algorithm (of finite size) can possibly produce 'perfectly random' numbers. Chaitan says "..something is random if the smallest program that calculates it is the same size as it is..". He defines the randomness of data as the inverse of it's 'structure', where structure is defined as the length of the smallest program that produces the data. So it would seem to me that any algorithm (or program) can not produce can not produce numbers of 'infinite randomness'. The very idea of 'infinite randomness', in all it's unattainable glory, is somehow very pure and clear in everyone's mind. It is, after all, the first concept of randomness that we all learned as children: that something is simply unpredictable, period. Strange that it takes centuries of advanced math to try to pin down exactly what randomness means. Chaitan gives an example of a 'truly' random number, based on the 'Halting Problem'. He shows that the probablity of a program halting is fundamentally unknowable. It is an actual number between zero and one, but where it is in that range is not only unknown, but 'unknowable'. In binary representation, we can not even get the slightest idea of what the first digit is, no matter how long of a program we write to figure it out. I may be mangling this a tiny bit, not being a mathematician, but I can see where some of the confusion may have set in. It is easy to mis-understand Chaitan's work as giving an algorithm for producing a 'truly' random number. In fact, what I think he shows, is that there is a number that is 'truly random', but producing the Nth bit of that number requires a program that is at least N bits long. ...anyway, my brain is going all loopy at this point, and I may have min-understood Chaitan, but I think I understood that Chaitan's ideas support (or conclude, or rely on) the idea that no finite algorithm can produce 'truly random' numbers. Have I mis-understood anything? Did anyone else read that page? What did you think? No? ..here it is again: (thanks, Tim) > http://www.cs.umaine.edu/~chaitin/cmu.html From gmcm at hypernet.com Thu Jun 21 10:44:05 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 21 Jun 2001 14:44:05 GMT Subject: Standalone .exe's using installer/builder question References: <9gsld3$5n6$1@plutonium.btinternet.com> Message-ID: <90C76054Egmcmhypernetcom@199.171.54.155> [posted and mailed] Gaz wrote: > I've recently downloaded the Installer pkg. from mcmillan inc ( >http://www.mcmillan-inc.com/builder.html ) and i wondered if anybody could >give me a little guide to using it. This is the test.py script i am using: [snip] >and this is the command line i use from the RUN promt: > >C:\WINDOWS\Desktop\temp\Standalone.py test.py -tk > >anyideas??? Yes. Due to a Windows problem, you have to say: python C:\WINDOWS\Desktop\temp\Standalone.py test.py -tk ^^^^^^ or the command line args don't make it to Standalone.py. - Gordon From graham at coms.com Mon Jun 18 08:37:50 2001 From: graham at coms.com (Graham Ashton) Date: Mon, 18 Jun 2001 13:37:50 +0100 Subject: Loading select queries into objects Message-ID: Hi. I've just started playing with database access from Python and have stumbled across yet another hole in my knowledge of Python idioms. I've got a class that has an attribute for each column in a database table, and an accessor method that sets the value of each attribute. I then populate the attributes with the result of a database query. Here's an example: query = """ SELECT column1, column2, some_column FROM a_table """ cursor = self.db.cursor() cursor.execute(query) tup = cursor.fetchone() self.column1(tup[0]) # this could be better! self.column2(tup[1]) self.some_column(tup[2]) What I'm wondering is; is there an idiomatic way of applying the values in a tuple to a list of functions? In Perl I'd use map(), but I'm not sure if there's a "cleaner" way in Python. When the number of columns grows large the above is not only ugly, but a nightmare to maintain. Thanks. From christian at rocketnetwork.com Wed Jun 20 18:10:02 2001 From: christian at rocketnetwork.com (Christian Reyes) Date: Wed, 20 Jun 2001 15:10:02 -0700 Subject: launching a file with its associated application on windows Message-ID: <9gr70q$bac$1@bob.news.rcn.net> Is there a method that takes a file as an argument and then opens that file with the its associated viewer? Thanks, christian From tim.one at home.com Fri Jun 1 16:46:31 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 1 Jun 2001 16:46:31 -0400 Subject: Iteration index In-Reply-To: <20010601161843.A8040@harmony.cs.rit.edu> Message-ID: [D-Man] > What is the difference between a "vector" and an "array" in this > context? (Not as in void[] or void* vs. std::vector< void* > ) Beats me -- what do those words mean to *you*? Then you can explain the difference yourself . I usually use them as synonyms. > I took a look at listobject.c and liistobject.h and I see that the > list itself is just a PyObject** -- a pointer to a C array on the > heap. I also noticed in the 'ins1' function that inserting an element > (not at the end) causes all others elements to be moved. Isn't this > pretty inefficient or is it such an infrequent operation that it > matters less than the O(1) PyList_GetItem? Dozens and dozens of Kbs of discussions about this were posted to c.l.py over the last 7 days. "insert in the middle" on *long* Python lists is indeed infrequent in well-written Python code, but hard to say whether that's because it's a relatively rare desire, or just because people know it's inefficient so avoid it (I suspect more the former). For reasonably short lists it's fine; e.g., using bisect.insort() to maintain a priority queue of no more than a few hundred elements is generally faster than any other way of doing it in Python. Dumb data structures have very low overhead, and that often covers differences in O(N) behavior until N grows "large". From thomas.heller at ion-tof.com Thu Jun 7 07:27:23 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 7 Jun 2001 13:27:23 +0200 Subject: Creating Typeinfo for Python COM servers? Message-ID: <9fnocb$550f3$1@ID-59885.news.dfncis.de> Is it possible to (let python) create type-information for a COM server written in python? Thomas From ullrich at math.okstate.edu Sun Jun 24 09:54:13 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 24 Jun 2001 13:54:13 GMT Subject: Is this a true statement? (fwd) References: Message-ID: <3b35eec8.1798329@nntp.sprynet.com> On Sat, 23 Jun 2001 12:45:26 -0400, Lulu of the Lotus-Eaters wrote: >>But you can't *DO* all of the same things in all languages -- for >>example: you can write a device driver in a language if you can't >>specify interrupt vectors or hardware address pointers. > >David C. Ullrich wrote: >|I thought a device driver was just a file, hence a finite >|sequence of bytes. You can certainly use Python to write an >|arbitrary sequence of bytes to a file. No doubt it's much easier >|in C++ (or rather in typical implementations of C++?) to decide >|_what_ sequence of bytes to write to that file > >One particular program would could write in Python is called a "C++ >compiler". While this would not be a particularly *easy* program to >write, you *could* write a script called 'gcc.py' that took all the same >arguments and input *data* files as a program called 'gcc', and produced >as a result bit-identical outputs. This may be a somewhat cumbersome >approach to writing a device driver in Python, but... Indeed. We don't need all of the compiler. Clearly it _is_ much _easier_ to write a device driver in C, or people would not say that it's impossible to do it in Python. But there's nothing about _C_ that writes device drivers, if it's easier there it's because the _implementation_ has inside information. >Yours, Lulu... It's been suggested that I'm making a silly point here. Could be a point with essentially no practical significance. Or it could be that while there's essentially no importance here regarding device drivers per se, there _is_ a serious point to it all. For example, I've seen it stated several times that if you're writing Windows programs you have to be writing C or C++ because the API is written in C. This is simply not true, you can write Windows programs in any language you like, and with no silliness involved. I doubt that the people who wrote the things I read actually think that for some reason you cannot use Delphi to write Windows programs, but someone reading a flat statement "You have to write Windows in C" might think it was true. (The _documentation_ is in C. And C compilers from Microsoft just happen to know a lot about the Windows API. But the documentation contains a language- independent specification of what a Windows program is supposed to do. Although the word "specification" might be a little strong, that has nothing to do with C versus some other language.) David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From ullrich at math.okstate.edu Fri Jun 8 11:19:47 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Fri, 08 Jun 2001 15:19:47 GMT Subject: random References: <3b1cf00f.5441109@nntp.sprynet.com> <3b1e4957.3040319@nntp.sprynet.com> <3b1f9604.4075981@nntp.sprynet.com> Message-ID: <3b20e1d1.479265@nntp.sprynet.com> On Thu, 07 Jun 2001 21:28:35 GMT, wtanksle at dolphin.openprojects.net (William Tanksley) wrote: >On Thu, 07 Jun 2001 15:02:33 GMT, David C. Ullrich wrote: >>(William Tanksley) wrote: >>>On Wed, 06 Jun 2001 15:19:36 GMT, David C. Ullrich wrote: >>>>(William Tanksley) wrote: >>>>>On Tue, 05 Jun 2001 15:09:25 GMT, David C. Ullrich wrote: >>>>>>But this question is not meant to be rhetorical: We have a syntax where >>>>>>the valid programs are exactly finite sequences of 0's terminated by a 1. >>>>>>Does this count as "self-delimiting"? > >>>Hmm... I'm pretty sure that programs for an UTM could be infinite length; >>>however, let's suppose that for the purposes of omega they couldn't be >>>(IMO a reasonable supposition). Then my proof is clearly invalid. > >This turns out to be a reasonable assumption; I've done some research, and >sure enough, TM programs are "defined" to be countable (it's actually an >unavoidable result). > >>>However, your machine still isn't a UTM, because in order to process an >>>indefinite number of possible programs it has to have an indefinite number >>>of states. It has to be able to count up to little-omega (otherwise it >>>won't know what program it's executing), but the only way to do that is >>>with an infinite number of states. And an UTM has a finite number of >>>states. > >>??? It seems to follow from statements in this paragraph that a UTM does >>not exist. It would require an "indefinite number" of states, but a UTM >>has a finite number of states. So there are no UTM's. Huh. > >It would have been polite of you to continue talking -- either explain how >you reached that rather bizzare and obviously unintended conclusion, or go >on assuming that I meant something else (if you could figure out what that >something else was). Keep in mind that I'm trying to figure this out, >too. Bringing ego into it won't help. Huh??? I _did_ explain how I reached that conclusion! And then instead of saying "so there" I acknowledged that that was presumably not what you meant to say. This is not "bringing ego into it", this is _saying_ that what you appear to have said is clearly not what you meant to say, wondering what you _did_ mean to say. Here's how I reached that conclusion. _As_ I pointed out yesterday, (as you _quote_ me pointing out), you _said_ (i) A UTM has to have an "indefinite number" of states - it has to be able to count to [omega - let's call it aleph_0 instead to avoid confusion] and that requires an infinite number of states. (ii) A UTM has a finite number of states. Both (i) and (ii) are things you _said_ directly above. It is extremely easy to deduce from (i) and (ii) that there is no UTM: If there _were_ a UTM then it would have infinitley many states, by (i), and it would also have finitely many states, by (ii). So it _does_ follow, (and it follows very easily, and I _did_ say how it follows) from what you said that there are no UTM's. I can't believe that you _meant_ to imply that there are no UTM's, hence my [snipped] statement that presumably this is not what you meant to say. "It would have been polite to continue talking"??? You _snipped_ the "presumably this is not what you meant". When you appear to have said that there are no UTM's how _should_ I reply in order to be polite? And what the heck does anything I said have to do with "ego"? >I think you're questioning why you'd need an infinite number of states to >run your 'programs'. No, it's clear that I need infinitely much storage to be able to emulate an arbitrary TM. This is true of _any_ UTM - hence _any_ UTM must use the tape itself in the "emulation", so as to be able to achieve infinitely many (external) states. What I was questioning was the conjunction of your two assertions that (i) any UTM needs infinitely many states while (ii) a UTM has only finitely many states. Looking back at what I wrote I can't see how I could have made it any more clear that this is what I was questioning. > The reason is that your programs aren't programs; >they're only data. They have to be processed, converted into programs >somehow. I'm not certain that this is computable; but if it is, it >requires some record of all the programs, since writing programs is >definitely not computable. Oh, so there's the misunderstanding. No, "writing programs" is not computable, in the sense that there is no algorithm exlaining how to write a program that will perform a given task. But that's not required here; the things my UTM needs to do are all definitely computable (by a finite-state machine with unbounded storage space). It _is_ easy to give a computable enumeration of all the Turing machines. Ie it is very easy to write a function TM(n) which returns the nth Turing machine on request. If you don't believe that say so and I'll supply a proof. It's true - not only are the TM's countable they are effectively countable. [In fact it's easy to write a NextTM(T) function with this property: If you start with an "empty" TM T_0 and then let T_1 = NextTM(T_0), T_2 = NextTM(T_1), etc, then each TM occurs exactly once in the sequence T_0, T_1, etc. I added a sketch below, with Python programs in place of TM's.) So the semantics for my UTM is like so: Read the 0's until you get to a 1. Say there were n zeroes. Construct the n-th Turing machine, and then execute it. [Or to describe it at a little lower level: Find or create some blank space on the tape. Write a specification for the empty TM there. Now start reading the input. Each time you read a 0 replace the current virtual TM with NextTM(the current TM). When you read a 1 stop that. Now execute the current TM.) And now when you want to use the UTM to emulate a given TM T you just figure out the n such that T = T_n and then pass n 0's and a 1 to the UTM. There are all sorts of subtleties here, I suppose. For examnple looking at T_42 there's no way to tell what it does. And if we have something we want to do there's no way to say exactly what TM is going to do that, hence no way to say what T_n we want. But all this is irrelevant - my UTM is not required to do a programmer's job for him, any more than any other UTM is required to do this. All that's required is that _given_ a TM T there exists a program to make the UTM emulate T. (I'm not certain whether the rules say that there has to be a computable way to get from the TM to the program that emulates it - I imagine so, else the UTM would not be useful. But that's moot, because for my UTM the program that emulates the TM T _is_ computable.) >And /that/ is countably infinite. Not sure exactly what set is being asserted to be infinite here, but no, my UTM requires only finitely many (internal) states - it also requires an infinite tape, like any UTM does. >>David C. Ullrich Ok. Here's how to write a NextPythonProgram in Python. With the property that if s is a string representing a syntactically valid Python program then NextPythonProgram(s) is another string representing a valid Python program, and if you start with s_0 = '' and then s_1 = NextPythonProgram(s_0), etc, then s_0, s_1, ... is an enumeration of all the valid Python programs: First write a function IsValidPythonProgram(s) which returns 1 or 0 depending on whether the string s is a syntactically valid Python program. (Whether something is syntactically valid _is_ computable, even though it may not be computable whether a string will terminate with a syntax error. Eg bad_code = 'this is not a valid program' exec(bad_code) _is_ a syntactically valid Python program.) You also need a NextString function so that if s is a string then NextString(s) is the next string in some enumeration of finite strings - this is easy. Now: def NextPythonPrograms): next = NextString(s) while not IsValidPythonProgram(next): next = NextString(next) return next And there you are. Note these are actual real Python programs I'm talking about, nothing abstract or hypothetical about any of it. (The IsValidPythonProgram would be a little complicated. But if it's not theoretically trivial then there would be big problems with Python, like when the compiler can't quite make up its mind whether some bit of code is valid...) >-William "Billy" Tanksley David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From aleaxit at yahoo.com Tue Jun 12 18:01:04 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 13 Jun 2001 00:01:04 +0200 Subject: Newbie question - zipfile module syntax References: <3B267B95.9BDA676@damaru.com> Message-ID: <9g63cj0fqa@enews1.newsguy.com> "Michael Davis" wrote in message news:3B267B95.9BDA676 at damaru.com... ... > This creates the zipfile, but doesn't compress it. The spec says that > you can add a third argument, either ZIP_DEFLATED or ZIP_STORED as a 3rd > argument to the constructor. > > I assume these are meant to be strings. When I try to write the second Wrong! Look: >>> import zipfile >>> dir(zipfile) ['BadZipfile', 'PyZipFile', 'ZIP_DEFLATED', 'ZIP_STORED', 'ZipFile', 'ZipInfo', [snip snip] >>> print zipfile.ZIP_DEFLATED 8 >>> See? ZIP_DEFLATED is an attribute of the module zipfile and its value happens to be the number 8. Alex From db3l at fitlinxx.com Thu Jun 7 21:15:34 2001 From: db3l at fitlinxx.com (David Bolen) Date: 07 Jun 2001 21:15:34 -0400 Subject: Why should i use python if i can use java References: <9fngvl011jg@enews2.newsguy.com> <9foms801hod@enews1.newsguy.com> Message-ID: "Alex Martelli" writes: > > 6.0 is nearly finished and has some really cool new features including > > "folding" (the ability to collapse a block of text into a single line > > on the display). > > Cool indeed (I'm sure the EMACSers are laughing at us of course:-). Nah, we don't mind seeing others play catch-up, so we just give a small knowing smile :-) -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From mark21rowe at yahoo.com Fri Jun 22 02:56:32 2001 From: mark21rowe at yahoo.com (Mark Rowe) Date: Fri, 22 Jun 2001 18:56:32 +1200 Subject: Embedding References: <3b305ce7@news.actrix.gen.nz> <9gq7lq0lvl@enews1.newsguy.com> Message-ID: <3b32f3fe@news.actrix.gen.nz> Thanks for the reply. I was actually most interested in implementing it in C. I still cant seem to find the methods to call :) Mark "Alex Martelli" wrote in message news:9gq7lq0lvl at enews1.newsguy.com... > "Mark Rowe" wrote in message > news:3b305ce7 at news.actrix.gen.nz... > > Hey all, > > > > Just been fiddling round with embedding Python in a C program, and one > thing > > has me stuck. I would like the user to be able to enter some python code > > containing functions, then at a later point execute one of these functions > > by name. I'm not really sure what i need to do for this to work > > You don't have to do much. Collect the source code that the user > enters (e.g. in a text-entry window in a GUI?), into one big Python > string (make sure there's a '\n' at the end:-), feed it to builtin > function compile() and make sure to catch a SyntaxError that will > be raised if the code has syntax errors, and let the user know. If > there are no errors, compile() returns a code-object. Stash it away, > and at any later time you can pass it to statement 'exec' (you may > want to pass specific dictionaries to control execution namespaces). > Again, be sure to catch and report any exceptions that may arise. > > This is all at the Python-level, where it's easiest, but of course there > is equivalent functionality accessible from the C API, too -- it's just > more work (as usual for C vs Python:-) so, the more you can do in > Python, the merrier, no?-) > > > Alex > > > From just at letterror.com Wed Jun 20 03:30:35 2001 From: just at letterror.com (Just van Rossum) Date: Wed, 20 Jun 2001 09:30:35 +0200 Subject: PEP 255: Simple Generators References: <3B2EEF5A.8FF0DAFB@cosc.canterbury.ac.nz> <3B30427D.5A90DDE7@cosc.canterbury.ac.nz> Message-ID: <3B305119.6A12DBC2@letterror.com> Olaf Delgado Friedrichs wrote: > If I understand correctly, this should work: > > def f(): > for i in range(5): > for x in g(i): > yield x > > def g(i): > for j in range(10): > yield i,j Greg Ewing wrote: > Yes, I realised that shortly afterwards. But I think > we're going to get a lot of questions from newcomers > who have tried to implicitly nest iterators and are > very confused about why it doesn't work and what needs > to be done to make it work. Erm, "yield" by definition yields to its immediate caller, so how could there be any confusion? I'm personally still not convinced that a generator keyword would be a huge improvement. Here's how I see it: once you see a "yield" statement it means the function returns not one but an arbitrary amount of values, which you can iterate over. The next two functions are more or less equivalent: def returnThreeValues(): return 1, 2, 3 def generateThreeValues(): yield 1 yield 2 yield 3 Just From whisper at oz.nospamnet Sat Jun 16 15:42:57 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 16 Jun 2001 19:42:57 GMT Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> <9gclvm02tte@enews1.newsguy.com> <9gelk3$324$2@216.39.170.247> <9gf434089d@enews1.newsguy.com> Message-ID: <9ggcs1$lfg$0@216.39.170.247> [This followup was posted to comp.lang.python and a copy was sent to the cited author.] In article <9gf434089d at enews1.newsguy.com>, aleaxit at yahoo.com says... > "Novum Regimen Britanniae Dream On. > But note that channeling > Guido is NOT my specialty -- gotta ask the timbot for that. No, it's pretty clear what your speciality is... > > (As for "yield" - whatever > > does a generator need yield for? My understanding of generators is that > > they produce a new value based on retained state, not actually generate a > > huge sequence - oops, there I go digressing again.) > > Yes, and? Every yield "suspends" or "freezes" the state, ready for > the _next_ "new value" when it will be requested. Why would you need to yield something that gets called upon to produce the next value in a sequence and then is dormant until the next time it's called upon? Most people I know who are programmers associate "yield" with something that one does in order to relinquish execution to another process or thread. > I said "years", not "decades". Python's inception dates back to 1990, > after all. I said neither "years" or "decades" - BTW, 1990 - 2000 is a decade last time I checked: has the OED a different definition? > And if you want to go into flames and ad hominem attacks, > dear fellow, I think you've met your match. Oh goodness no! If you want the title of "Best Flamer", you're quite welcome to it! You seem to do it so well too! (Are you by any chance Quentin Crisp's sister?) > > > Alex When a brisk (actually pretty enjoyable - not often I get to have an exchange with someone who appears to have something interesting to say and also says it in an interesting way), somewhat snippy (on both sides) discussion suddenly turns into preemptive projectile diarrhea of the mouth, one has to wonder if there was any real substance behind the dialog in the first place. Thank goodness I didn't mention the "p" word! Dave From ssthapa at classes.cs.uchicago.edu Thu Jun 7 09:12:35 2001 From: ssthapa at classes.cs.uchicago.edu (Suchandra Thapa) Date: Thu, 07 Jun 2001 13:12:35 GMT Subject: best language for 3D manipulation over web ? References: <9fl1k2$avh$1@neon.noos.net> Message-ID: Boyd Roberts wrote: > >the problem with windows is that the original model was totally >flawed and it has inhereted that right down the line. NT is >a ghastly mess. it's security is laughably complex, therefore >unusable. Window's ACL system is being integrated into Linux systems. It has several advantages over the traditional unix system since the it has a finer granularity. >someone should teach those kids at redmond how to do virtual >memory and someone should teach dave cutler that VMS sucked. Mr. Cutler can be forgiven his VMS leanings since he designed a large portion of it. Plus, I think VMS systems have amazing longest uptimes and advanced features. There really isn't much in the unix world that can give the same features as the VMS clustering and parallel sysplex. As for uptimes, I've heard of a VMS system with something like a 19 year uptime. -- ---------------------------------------------------------------------------- | Suchandra Thapa | "There are only two kinds of math . s-thapa-11 at NOSPAMalumni.uchicago.edu | books. Those you cannot read beyond | the first sentence, and those you | can not read beyond the first page." | -C.N. Yang ---------------------------------------------------------------------------- From emile at fenx.com Thu Jun 28 19:51:53 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 28 Jun 2001 16:51:53 -0700 Subject: Using python interpreter over a network References: <0z3crJATm3O7EwQT@jessikat.fsnet.co.uk> Message-ID: <9hgg75$e6rqh$1@ID-11957.news.dfncis.de> I think it gets more involved than that. I was trying to get it to work this morning before I took off, and got to the point of being able to import some win32 stuff, but not win32net. That gave an error loading the dll - A device attached to the system is not functioning. I was able to get regsetup.py to work, thinking perhaps Marks stuff was looking for that. By now I've probably got things pretty well scrambled on that system. ;-) But I thought it could be convenient to have, so maybe I'll try again when I get another hour or so. -- Emile van Sebille emile at fenx.com --------- "Robin Becker" wrote in message news:0z3crJATm3O7EwQT at jessikat.fsnet.co.uk... > In article , pj > writes > >Greetings. > > > >I am trying to run a python script in a networked windows NT > >workstation. Python is not installed in this box. > > > >I have mapped another machine's (my win2k box) python (2.1) > >installation to the PATH of this NT box. > > > >I have set PYTHONHOME to Q:\Python while Q: is mapped to > >\\my_nt_box\cdrive. I also have Q:\winnt\system32 in the current path > >(for python dll). > > > >Python seems to work under the circumstances. I can run the > >interpreter and do simple stuff. But when I try to import some > >modules, it says it cant find those. 'win32net' for example. I am not > >sure how to make it aware of the fact that everything is under > >q:\python. > > > >Is it a requirement that python should be installed in the local > >machine? Or is there something (Env variable ? Registry ?) I can tweak > >to make this work. > > > >Appreciate your time. > > > >cheers > >pj > try doing > > import sys > > sys.path > > on my home box this looks like > ['', 'c:\\python\\pythonwin', 'c:\\python\\win32', > 'c:\\python\\win32\\lib', 'c:\\python', 'c:\\python\\dlls', > 'c:\\python\\lib', 'c:\\python\\lib\\plat-win', 'c:\\python\\lib\\lib- > tk', 'c:\\python\\numeric', 'c:\\python\\rgbx', 'c:\\python\\devel\\vide > ocapture\\python21'] > > (folded lines aside) and perhaps your python does the same. If that is > so, you need to do a conversion and replace the c: with q: for your > scripts to run. > -- > Robin Becker From shredwheat at mediaone.net Fri Jun 1 12:00:56 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Fri, 01 Jun 2001 16:00:56 GMT Subject: crossing boundaries into Tcl References: Message-ID: "David Gravereaux" wrote > % $i eval {_} > python0: Traceback (most recent call last): > File "", line 1, in ? > NameError: name '_' is not defined hey david. welcome to python. the problem here is that the magic "_" underscore variable is not part of the actual python language, it is just a little shortcut the interactive interpreter adds to represent the last result. unfortunately i know not enough about python in tcl to know how to handle the situation, good luck From ajwms at visto.com Mon Jun 4 09:04:34 2001 From: ajwms at visto.com (Andrew) Date: 4 Jun 2001 06:04:34 -0700 Subject: xmlrpc Server References: <2f14b602.0106030721.441faa31@posting.google.com> <3b1a674e$1_1@news5.uncensored-news.com> Message-ID: <2f14b602.0106040504.3a8997d7@posting.google.com> Doug Fort wrote in message news:<3b1a674e$1_1 at news5.uncensored-news.com>... > Andrew wrote: > > > > > > > def add(self, method, params): > > self.x = self.x + int(params[0]) > > return "Sum = %s" % str(self.x) > > > > > I believe the add method should have the prototype 'def add(self, params)'. > I don't think params[0] contains what you think it cpontains. > Doug: I tried changing 'def add(self, method, params)' to what you suggested; unfortunately that didn't work. In the 'call' method, I had to change 'return server_method(method,params)' to 'return server_method(method)' and it still doesn't keep a running total. It looks like to me that the TestRequestHandler object is being created and destroyed whenever someone requests/connects to the xmlrpc server. So... How in the world do I keep a persistent object as the request handler? For example, what if I wanted to use xmlrpc as a front-end to a db; I would want the connection to the db to be persistent so I wouldn't incur a speed penalty for connecting/disconnecting whenever the request handler was called. Any suggestions?? Please??? TIA, Andrew Williams From James_Althoff at i2.com Fri Jun 15 14:46:36 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Fri, 15 Jun 2001 11:46:36 -0700 Subject: Any other Python flaws? Message-ID: Mattias wrote: >That anonymous (lambda) functions can only contain an expression, not >statements? Less of a problem, but still ugly and feels like an arbitrary >decision, perhaps because it was too hard to make it fit with python's >unusual indentation-based syntax. I agree. I think this is a big one. The (tedious, less-readable, and ugly, IMHO) "workaround" of using named functions defined "ahead of use" -- as an alternative to using unnamed code blocks "in place" -- seems to discourage reasonable use of many nice design idioms that are seen frequently in Smalltalk and Ruby -- (reasonably) similar languages (to Python) that do support "unrestricted, unnamed, in-place" code blocks. Jim From aleaxit at yahoo.com Fri Jun 29 08:15:52 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 29 Jun 2001 14:15:52 +0200 Subject: the center of the world (was Re: Check out O'Reilly's Open Source Convention Highlights) References: <3B3AA82D.1A0FE860@seebelow.org> <3B3B2DED.5303198A@seebelow.org> Message-ID: <9hhri7019jd@enews2.newsguy.com> "Grant Griffin" wrote in message news:3B3B2DED.5303198A at seebelow.org... ... > Hey, who said anything about "world"?... Kernighan and Ritchie did (they were greeting it, I believe). > But now that you mention it, the US Midwest *is* pretty centrally > located on a "world" basis. > > as-much-as-anything-else-on-this-sphere--ly y'rs, An interesting exercise might be to define a *meaningful* "central location" -- one based on population distribution (or other geographical distributions of interest). After all, since tunas are unlikely to attend a conference on technical computer issues (given that you can tune a filesystem, but you can't tuna fish), "weighting" the vast aquaceous parts of the (approximate) "sphere" equally to the populated landmass may be a fine exercise in geometry, but doesn't make much sense otherwise. As soon as you want to move from pure geometry to some kind of geography, I think some demographic issues must arise. Even without considering demographics, at least some account could be taken of land vs ocean and maybe of land with/without permanent ice covering. Some data, ordered by-country, can easily be found for free on the web, http://www.worldbank.org/data/wdi2001/worldview.htm for example. Latitudes and longitudes of cities in various countries are also easily available, e.g. at http://www.realestate3d.com/gps/world-latlong.htm. We can get a first approximation for a distribution of world human population by assuming a country's population is divided equally among its major cities. This will require some work and supervision because of varying formats etc in the files being used -- or is there somewhere on the net that already gives me in a single readable file a lot of data boiled down to triples (population, latitude, longitude)? Anyway, once I do have such a file, I can presumably find the "center of the world" (approximate) -- the one point on the Earth's surface that minimizes population-weighted sum of great-circle distances to 'population centers'. Of course I could get different centers by choosing different weighing factors (country GNP rather than country population, for example). Hmmm, if the coordinates were on a plane, finding the weighed center would be trivial, but offhand I can't think of how to do it on a sphere's surface -- I guess there must be some way more suitable than just solving a generalized extremization problem -- can anybody suggest one...? Of course, there are enough degrees of freedom in the outlined procedure that it can probably be used for my real purpose, i.e., proving that the relevant "center of the world" is within easy walking distance from my home and thereby convincing the PS^H^H O'Reilly to hold their next conference somewhere that's highly convenient for me... Alex From chris at dc.zdev.org Tue Jun 19 16:57:36 2001 From: chris at dc.zdev.org (Chris Abraham) Date: Tue, 19 Jun 2001 16:57:36 -0400 Subject: RFD comp.lang.python.zope & ZPugDC Meeting Tomorrow Message-ID: Hi Folks: I have two sort notes. First one is I would like to test the waters before I take the initiative to put a proposal together for a newsgroup for Zope. I envision this to be a subgroup of comp.lang.python, comp.lang.python.zope. As Zope is really an application made of python, just as Mason is of Perl and Midgard is of PHP and Enhydra is of Java, methinks this is appropriate. Secondly, I would like to let all the DC Metro folks know that there is a Zope-Python user group here in DC tomorrow, and here is the official announcement: << The presenters for the June 20th meeting will be the gang from Digital Creations, the company that supports the development of Zope and Python. Zope is a Python-based Open Source web application server for dynamic web-based business applications such as intranets and portals. Zope makes it easy to build features such as site search, news, personalization, and e-commerce into your web applications. This meeting is co-sponsored by Zope and Python User Group and DCLUG. It will be a valuable opportunity for both Zope and Python lovers to dote, as well as turning on a load of Linux Users to the unique powers, strengths, and flexibility of Zope and Python -- a couple of swell Open Source tools. >> Thanks, Chris -- Chris Abraham +1 202 452 7442 vm [MemeSpace:VirtualCommunity:ConsiderYourselfInfected!] From aahz at panix.com Wed Jun 27 08:59:45 2001 From: aahz at panix.com (Aahz Maruch) Date: 27 Jun 2001 05:59:45 -0700 Subject: PEP 260: simplify xrange() References: <3B398BBE.A2D455C9@darwin.in-berlin.de> Message-ID: <9hclc1$qv5$1@panix2.panix.com> In article <3B398BBE.A2D455C9 at darwin.in-berlin.de>, Dinu Gherman wrote: > >PS: BTW, why not *add* something useful and make float > increments work "as expected" in range/xrange...? And how do you expect floating point increments to work? (Have you paid any attention to the extensive threads on FP over the past few months?) -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Those who do not remember the past are condemned to repeat it." From skip at pobox.com Thu Jun 14 16:10:29 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 14 Jun 2001 15:10:29 -0500 Subject: New statement proposal for Python In-Reply-To: <9gao5s$8ft$7@216.39.170.247> References: <9gao5s$8ft$7@216.39.170.247> Message-ID: <15145.6709.841656.275850@beluga.mojam.com> David> My proposal: David> alias httpport : 80 ... Interesting idea. Why do you prefer ":" over "="? -- Skip Montanaro (skip at pobox.com) (847)971-7098 From chrishbarker at home.net Thu Jun 7 15:06:46 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 07 Jun 2001 12:06:46 -0700 Subject: integers References: <9fjd8q$qb6$1@charm.magnus.acs.ohio-state.edu> <9fjgqf$rp0$2@brokaw.wa.com> Message-ID: <3B1FD0C6.AB148906@home.net> > Of course, if you add var++, do you add ++var? That would be silly, as neither ++i nor i++ returns a value anyway. They eouls be indentical. -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From SBrunning at trisystems.co.uk Thu Jun 7 04:16:18 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Thu, 7 Jun 2001 09:16:18 +0100 Subject: How to get a unicode degrees symbol? Message-ID: <31575A892FF6D1118F5800600846864D78BCF6@intrepid> > From: Russell E. Owen [SMTP:owen at astrono.junkwashington.emu] > As to how I managed to miss the documentation link. I don't mean to > sound ungrateful to anybody involved with Python, but in fact that was > quite a battle when I first tried to figure it out... > (snip tale-of-woe) Well, it's in the Python Quick Reference, too. See . Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From phawkins at connact.com Fri Jun 29 22:25:31 2001 From: phawkins at connact.com (phawkins at connact.com) Date: 29 Jun 2001 22:25:31 -0400 Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: <3B2EADB0.9DBC6FC8@earthlink.net> <3dlmmndzpc.fsf@ute.cnri.reston.va.us> Message-ID: But Berkeley db3 plus bsddb3 is very nice, and very convenient. -- Patricia J. Hawkins Hawkins Internet Applications, LLC From foo at ix.netcom.com Thu Jun 7 03:52:49 2001 From: foo at ix.netcom.com (Matt Butler) Date: 7 Jun 2001 00:52:49 -0700 Subject: Win32 Installer on 2.1? References: <50be6f7c.0105220115.612c9912@posting.google.com> Message-ID: <50be6f7c.0106062352.a6f2670@posting.google.com> Is it true that "still" no one has tried to get it working with 2.1 yet??? foo at ix.netcom.com (Matt Butler) wrote in message news:<50be6f7c.0105220115.612c9912 at posting.google.com>... > The following quote appears in the Announcements for Gordon McMillan's > Installer, "Version 4 handles all Python versions from 1.5 onward > (it's been tested with 1.5 and 2.0).". > > Has anyone out there actually tested on 2.1? From dsh8290 at rit.edu Wed Jun 13 23:18:26 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 13 Jun 2001 23:18:26 -0400 Subject: Python grammar.. In-Reply-To: ; from tdelaney@avaya.com on Thu, Jun 14, 2001 at 10:05:21AM +1000 References: Message-ID: <20010613231826.C27947@harmony.cs.rit.edu> On Thu, Jun 14, 2001 at 10:05:21AM +1000, Delaney, Timothy wrote: | > "Delaney, Timothy" wrote in message | > news:mailman.992393599.3573.python-list at python.org... | > ... | > > way to do it - a subroutine may or may not return a value, at its | > > discretion, and I should be able to ignore any returned value. | > | > Yes, but if I were designing a language today, I think I would | > request you to be EXPLICIT about "ignoring the return value" -- | > explicit is better than implicit. It IS an occasional cause of | > errors in Python (particularly with newbies) that an expression | > statement's value is silently and implicitly ignored... | > | > | > Alex | | So you would prefer that functions whose return value is ignored must be | called with a keyword ... such as in VB | | call aFunction() or (void) aFunction() ; | Personally, I absolutely hate this. Not any better ;-). -D From idot at vt.edu Tue Jun 19 23:57:13 2001 From: idot at vt.edu (Carl Banks) Date: Tue, 19 Jun 2001 23:57:13 -0400 Subject: OOP design question References: <9gor4b$3jv$1@fafnir.dyndns.org> Message-ID: Anthony Veale' wrote: > > Hello, > > I'm a newbie to OOP and Python at the same time and I'm having a bit > of a design problem. I can see at least one way out of my problem > that isn't really OO, ... We'll see.... > but since I'm writing this program to learn > some OO programming, that's a bit of a cheat. However, it might > turn out to be the most appropriate solution. I just don't know. > > Let me be concrete here. I'm writing a program to edit the Opera 5 > for Linux bookmarks file. I designed some classes for Urls and > Folders and one for the bookmark file as a whole. The BookmarkFile > class contains instances of Folders and Urls. I would say you need to be more concrete yet. The level of detail that you've supplied is not congruent with the level of detail that concerns your problem of whether to subclass or augment Folder. I'll have to make some assumptions. I assume what you're doing is reading in an Opera bookmark file, building a internal data stucture of Folders and Urls, manipuating the Folders and Urls in your program, and then outputting a new file. I assume that the bookmarks are organized into a heirarchy, much like a filesystem. That is, Folders can contain Urls and other Folders. You say that BookmarkFile contains instances of Urls ans Folders--it seems to me that BookmarkFile could or should be a subclass of Folder. It seems that it does everything a Folder does (i.e. contains Urls and other Folders, maybe has a name and description), but also has additional input/output facilities. In fact, if I we're doing this, I don't think I would even have a separate BookmarkFile class; I'd just use a Folder for it. > Then when I started to design the editing program, I found that > there are some features that I wanted to add to Folders, that are > really only applicable to Folders when editing the bookmark file. Well, what's confusing here is that you said you're writing a program to edit bookmarks. When, then, are you not editing the bookmark file? It would be helpful to know exactly what these operations are. I'll assume that you have "editable" and "non-editable" Folders. What you have to ask yourself is this: Is editabilty a temporal property or a spatial property? In other words, can a single folder be both editable and non-editable depending on where and when it's used? Or are certain folders permanently non-editable while others are permenantly editable? In the former (temporal) case, you almost certianly want to just add features to the class. In the latter (spatial) case, you might want to subclass Folder. (Or, better, extract a common parent class.) > So I'd like to subclass Folders and make sure that the BookmarkFile > class creates Folders using the new subclass. > > The questions: > Should I try to redesign the BookmarkFile class to use a > parameter to control the actual class of Folder instance? (Can > you actually pass a class as a parameter?) This question makes me think it's a spatial property. Yes, classes are regular Python objects. You can do something like this: def add_folder (folder_class, name): self.folder_list.append (folder_class(name)) And call it like this: bookmarkfile.add_folder (EditableFolder, "Anthony's Bookmarks") But, even if you couldn't, you could use still use if ... elseif ... else ... endif logic to choose the class. > Or: > Should I try to redesign the BookmarkFile class to be easier > to subclass and use subclassing to control the class of Folder > instances? This question make me think it's a temporal property. It seems that editability of folders is a property not of the folders themselves, but of the BookmarkFile. It also seems like you're accessing your folders through the BookmarkFile class. > Or: > Should I try to isolate these "editing" functions into something > that gets mixed with the Folder class? That sounds terrible. I'd run away screaming. > Or: > Is there some other approach that I simply haven't thought of? One point of confusion I've often experienced in containment relationships (one object contains another) is whether an opertation that involves both container and containee (or, if you will, parent and child) should be part of the parent class or the child class? Based on my experience, these functions should always be part of the parent. So, if these "editing" functions of which you speak are of that sort (like, "move_to_another_folder"), then you should think about whether these functions properly belong to BookmarkFile. > The cheat would be to just add the features to the Folder class > itself without subclassing. It would work, but doesn't really seem to > be the appropriate OO action to take. ... Given my best guess of exactly what your problem is, I'd say this is in fact the best thing to do, and it's not really counter to OO.... > If I were writing this program > in order to get something functional, I'd probably just do it. But > I'm trying to learn the "right way" here. This could be your problem, too. Sometimes the Right Way (TM) isn't the right way. CARL From whisper at oz.nospamnet Thu Jun 7 00:52:28 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 7 Jun 2001 04:52:28 GMT Subject: GROUP TAKEOVER IN PROGRESS References: <3A29743F.CAA91142@my-Deja.com> <92dtj6$5dh$1@bob.news.rcn.net> <69cl4tk6bitr0oi376ngtjp0m1bs7ucnk4@4ax.com> <902430AC4moondustapexnet@209.99.56.9> <93hn81$l4m$1@nnrp1.deja.com> <9025628F7moondustapexnet@209.99.56.9> <3a5c8520_1@news.foxinternet.com> <902581E21moondustapexnet@209.99.56.9> <3a5ce21b_1@news.foxinternet.com> <4A982771F09.psskvxvn@vluxxijwai.net> Message-ID: <9fn1ac$9d3$2@216.39.170.247> Don' you just hate it when they don't get their lithium? From pfortin at pfortin.com Fri Jun 22 11:29:17 2001 From: pfortin at pfortin.com (Pierre Fortin) Date: Fri, 22 Jun 2001 11:29:17 -0400 Subject: [OT] MS EULA -- (will ActiveState become outlaws? ;-) References: <3B32F81F.259DBA46@chello.nl> Message-ID: <3B33644D.E32B4215@pfortin.com> Roeland Rengelink wrote: > > "Steven D. Majewski" wrote: > > > > Is this the next stage of Microsoft's war against Open Source ? > > > > Discussion of this on SlashDot : > > > > ( Right before the article on the Monty Python Action Figures! ) > > > > If this spreads to all of Microsoft's EULA's, will this make > > ActiveState illegal ? They don't specifically mention Python's > > license, but they do mention Perl's ( and the "similar to any > > of the following" clause would seem to include Python's. ) > > > > Does anyone know if this should be taken seriously ? > > > > -- Steve Majewski > > > > > > Ironically, NS under Linux refuses to display that ;) This page was visible with NS4.77/Linux yesterday; now, it stalls for a few seconds, then presents a "page not found" screen... either they are shutting out NS and/or Linux, or they've removed it... > Well, as I see it the GPL licence is morally equivalent to > > 1. This is raging commie stuff > 2. You can't use raging commie stuff in conjunction with evil empire > stuff > > and this microsoft licence is morally equivalent to > > 1. This is evil empire stuff > 2. You can't use evil empire stuff in conjunction with raging commie > stuff > > For once the free software movement and microsoft seem to agree on > something > > More seriously, the lack of a definition of ''use'' under (ii), and the > misleading definition of Potentially Viral Software gives the impression > that this was written by their PR department, rather than their lawyers. > > But then, I know as little about law as I do about PR. > > Roeland > -- > r.b.rigilink at chello.nl > > "Half of what I say is nonsense. Unfortunately I don't know which half" The first half... :^) Pierre From michael at trollope.org Fri Jun 22 22:06:18 2001 From: michael at trollope.org (Michael Powe) Date: 22 Jun 2001 19:06:18 -0700 Subject: Another Wart! string.find() [ was: namespace issue? ] References: <3B33B0E2.867053FE@ccvcorp.com> Message-ID: <87itho2bmt.fsf@cecilia.trollope.org> >>>>> "John" == John J Lee writes: John> On Fri, 22 Jun 2001, Jeff Shannon wrote: [...] >> Except that, even if string.find() returned None (false), it >> still wouldn't work: >> s = "spam" sub = "sp" if string.find(s, sub): dospam() >> In this case, dospam() never executes, even though our >> substring *is* found. >> While you *could* explicitly test >> if string.find(s, sub) is not None: >> I don't see this as being really any better than >> if string.find(s, sub) >= 0: >> or >> if string.find(s, sub) == -1 John> [...] John> In fact, I think you've just demonstrated why -1 is actually John> *better* than None. If it did return None, people would John> forever be testing John> if string.find(s, sub): foo() John> and forgetting about the 0 case. At least, I would be, I'm John> sure. Why? You already assume that 0 is not false. That would not be changed. mp -- Michael Powe Portland, Oregon USA 'Unless we approve your idea, it will not be permitted, it will not be allowed.' -- Hilary Rosen, President, Recording Industry Association of America From see at my.signature Fri Jun 1 01:41:24 2001 From: see at my.signature (Greg Ewing) Date: Fri, 01 Jun 2001 17:41:24 +1200 Subject: Oleg Broytmann doesn't understand my problem References: Message-ID: <3B172B04.BE15CFCD@my.signature> Laura Creighton wrote: > > I don't just have a dictionary, I have arguments and a dictionary. > I need to be able to pass both a=b parameters AND a dictionary. You can supply explicit arguments along with the * and/or ** argument in 2.0: foo(1, 2, "buckle", x="my shoe", *a_list, **a_dict) It's exactly what you need for passing arguments to an inherited __init__ method. (This is not a coincidence -- that's what the syntax was mainly designed for!) -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From whisper at oz.nospamnet Wed Jun 13 21:18:01 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 14 Jun 2001 01:18:01 GMT Subject: msvcrt.getch() overly receptive in idle? References: <9g5m7k$gu8$1@nntp6.u.washington.edu> Message-ID: <9g93c9$8ft$1@216.39.170.247> In article , db3l at fitlinxx.com says... > fpm at u.washington.edu (Frank Miles) writes: > > > I'm trying to get getch() working in Windows (Python 2.0). It seems to > > work fine outside of Idle, but inside Idle it immediately returns a > > character with the value 255. > > > > Can anyone point me to the obvious solution? Thanks! > > I expect that getch() requires a working "console" window, and when > you run Idle you don't get one as its set to use pythonw.exe. Thus, > it's technically not able to process any keystrokes and returns > immediately. > > You could try to verify that by starting Idle from the command line > with the standard python. (But you may have to be in that console > window to trigger the getch() to return). > > A GUI doesn't really have individual keystrokes sent as console > characters, but instead receives events upon keypresses. So a getch() > call in a GUI application is sort of non-sensical (within the GUI > framework). > > To do the equivalent in a GUI, you'd need to wait for a keypress > event. I'm not sure how easy or not it would be to tie into Idle's > event loop to notice such a thing. > > -- > -- David > One could certainly put in an "any key" event at the bottom of the list of other interesting keys (or all keys and no other key events and dispatch manually for "interesting" keystrokes and pass on the ones not interesting to this level of the app (ctrl-c for example)). The default action would be to pass the event on down the event chain. Alternatively, the event is enabled and "interesting" keys are processed. Sounds right about like a key-configurable editor would do it... This could be added to Idle's or Pythonw's event loop easily enough, although the pythonw route would have to be approved for inclusion by the snake wranglers imho. getch() only makes sense in a procedurally driven interface where the program controls the interaction with the user. In an event driven system where the program waits for events to be generated by the user, it doesn't - but if needed, could be emulated in a texteditor control. Regards, Dave LeBlanc From jdf at pobox.com Sun Jun 3 13:01:01 2001 From: jdf at pobox.com (Jonathan Feinberg) Date: 03 Jun 2001 13:01:01 -0400 Subject: Higher level abstraction on select() References: <9f2gfo$k1$1@oravannahka.helsinki.fi> <8zje8xom.fsf@pobox.com> <9f52h2$m1k$2@oravannahka.helsinki.fi> Message-ID: Panu A Kalliokoski writes: > Jonathan Feinberg wrote: > > Panu A Kalliokoski writes: > >> http://sange.fi/~atehwa-u/selecting-0.8.tar.gz > > I'm eager to try it, but the file above is not there. > > Hm? Interesting. Works all right for me. Of course, it could be that you > tried just at the moment when I rebuilt the .tar.gz. Does the directory > (http://sange.fi/~atehwa-u/selecting-0.8/) work? No. However, the tar files are there now. I have just downloads 0.85, assuming that to be more recent. -- Jonathan Feinberg jdf at pobox.com Sunny Brooklyn, NY http://pobox.com/~jdf From jessw at loop.com Fri Jun 22 15:08:04 2001 From: jessw at loop.com (Jesse W) Date: Fri, 22 Jun 2001 12:08:04 -0700 Subject: ANNOUNCE: The Neophyte Pythoneers List In-Reply-To: Message-ID: <3B333524.29602.133D69CC@localhost> Sheila King wrote: > There is already a list that serves this purpose. > See http://mail.python.org/mailman/listinfo/tutor I have just subscribed to tutor. I will see if my list is really just an unnecessary split. Thank you for bringing the tutor list to my attention. Thank you for your time, Jesse W > > -- > Sheila King > http://www.thinkspot.net/sheila/ > http://www.k12groups.org/ > > > On Thu, 21 Jun 2001 12:51:34 -0700, "Jesse W" wrote > in comp.lang.python in article > : > > :Dear Pythoneers, (Exactly how should you spell "Pythoneers", > :anyway?) > : > : I have just now created a mailing list via Yahoo for the sharing, > :joint debugging and general discussion of Python programs. The :list > is intended to be primarily for those who have not yet reached :expert > level in Python programming, but experts are also very :welcome. : You > can join by sending a blank email to: > :neophyte_pythoneers-subscribe at yahoogroups.com : : Good luck to > you all, : Jesse Weinstein : : > > -- > http://mail.python.org/mailman/listinfo/python-list > From raskol at hushmail.com Tue Jun 12 10:12:15 2001 From: raskol at hushmail.com (raskol) Date: Tue, 12 Jun 2001 10:12:15 -0400 Subject: New to python References: <9g53qh$qhl$1@news.kodak.com> Message-ID: <3b261eb9$1_2@newsfeeds> "Karim" wrote in message news:9g53qh$qhl$1 at news.kodak.com... > I'm a new beginner to python. > In fact, I'll have to use it for a next project. Glad to hear that some of us are 'forced' to use python! > Can someone write me in few lines why Python has been created ? > What for ? > For what kind of applications ? You'll find all of these questions answered here: http://python.org/help.html Enjoy! raskol -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From hs at cybertec.at Wed Jun 13 10:18:57 2001 From: hs at cybertec.at (=?iso-8859-1?Q?Hans=2DJ=FCrgen=20Sch=F6nig?=) Date: Wed, 13 Jun 2001 14:18:57 GMT Subject: PostgreSQL, Python and BLOBs Message-ID: <3B2775C0.D2460A6C@cybertec.at> Does anybody have a working example that uses BLOBs in combination with Python and PostgreSQL. I can't find information I can work with on the net. Hans From dsh8290 at rit.edu Tue Jun 19 14:37:07 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 19 Jun 2001 14:37:07 -0400 Subject: Any other Python flaws? In-Reply-To: ; from mwh@python.net on Mon, Jun 18, 2001 at 11:28:50PM +0100 References: <3B2A5F6A.5A61183@destiny.com> Message-ID: <20010619143707.A7032@harmony.cs.rit.edu> On Mon, Jun 18, 2001 at 11:28:50PM +0100, Michael Hudson wrote: | D-Man writes: | | > On Mon, Jun 18, 2001 at 08:10:12PM +0100, Michael Hudson wrote: | > | I agree that what Michael posted doesn't really do what he wanted; but | > | it doesn't do what you said, either. | > | > It seems to, with some cursory tests in the interactive interpreter. | | Yeah, it looks the same, but None is being found in the global | namespace, not the builtin one like normal. I can't think of any | remotely sane situation where this would make a difference, but the | difference is there. Eg. consider assigning to __builins__.None (I | don't recommend actually doing this!). Oh, that's why you meant there was a difference. Like you said, it is basically the same, except the lookup finds the result sooner. | > I would have to look at the source to see _how_ the function | > implicitly returns 'None' to understand why it doesn't behave as | > intended. | | Because falling off the end of a function compiles into a LOAD_CONST Yeah, I knew the functions implicitly returned None, but I didn't know (until now) why you said it didn't work. I thought maybe there was some special case where it wouldn't find None or would find a different one. -D From akuchlin at mems-exchange.org Tue Jun 26 15:03:13 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 26 Jun 2001 15:03:13 -0400 Subject: readline, python 2.1 and LFS References: <3B35B57F.1E0F956B@nospam.de> <3dpubr1ek8.fsf@ute.cnri.reston.va.us> Message-ID: <3dn16v12tq.fsf@ute.cnri.reston.va.us> Timothy Grant writes: > It appears that tputs is an ncurses function though, so that it > what is really stumping me. According to 'man tputs', it's part of the terminfo library, which is usually provided by ncurses. > New Topic: I read a few posts back that you are doing stuff > with the ZODB on a stand-alone basis. Do you have a paper, > README, instructions or anything that detail the procedure of > using it by itself? Closest thing is the programming guide at http://www.amk.ca/zodb/guide/ . --amk From nhodgson at bigpond.net.au Thu Jun 14 19:21:37 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Thu, 14 Jun 2001 23:21:37 GMT Subject: Parsing C code with Python References: Message-ID: <5GbW6.132440$ff.993374@news-server.bigpond.net.au> St?phane BAUSSON: > I am interested by examples of program parsing C code. > The C code generates raw data, and these raw data I > want to parse them after with python to display the > data in something meaning full for human. > > The problem is how to analyze the C code, with the > struct, union, etc .... I have a partial line-oriented C++ lexer which I have been trying to avoid turning into a parser. The code can be found in the CxxTokens.py file available in http://scintilla.sourceforge.net/SinkWorld.zip There is a demonstration quality (that is, don't use this for-real) C++ pretty printer in CxxPP.py but the main point is a translator from a subset of C++ to C#/Java in XLang.py which is part of my SinkWorld project. It depends on the details of your analysis whether you will need a token stream or a parse tree. Many problems can be solved with iterating over a token stream and maintaining some parse level state (nesting level, scope stack, ...). Neil From tim.one at home.com Wed Jun 20 22:04:15 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 20 Jun 2001 22:04:15 -0400 Subject: locking dictionaries (was Re: New statement proposal for Python) In-Reply-To: <9gre01$noi$1@panix2.panix.com> Message-ID: [Aahz] > OTOH, there's been some discussion of locking dicts during certain > operations to prevent some ugly bugs and crashes. [Greg Ewing] > I'm given to understand that, in the case of lists, this is achieved > by temporarily changing the type pointer. If a similar thing were done > for dicts, presumably it wouldn't have any effect on the performance of > non-locked dicts. No rational effect, anyway. For example, if you wanted a dict that refused to delete items, give it a type object almost exactly like a regular dict's, except redirect its tp_as_mapping slot to a PyMappingMethods struct with a custom mp_ass_subscript slot (that makes more sense if you look at the code ). They can share the rest of the dict implementation, and modulo "cache effects" this should have no effect at all on regular dict speed. But note that there's really no way to do this without editing dictobject.c: unlike *most* of the Python types, the representation of dicts can't be gotten from an #include file. They're one of Python's few true "black box" types at the C level, and that's deliberate (the internal representation of dicts has changed frequently, and has changed again for 2.2 -- but since it was never available outside dictobject.c, nothing will break). From ocschwar at mit.edu Sun Jun 10 01:23:42 2001 From: ocschwar at mit.edu (Omri Schwarz) Date: 10 Jun 2001 01:23:42 -0400 Subject: Grail Python2.1 References: <9flevu$495$1@wanadoo.fr> Message-ID: "Salvatore DI DIO" writes: > I'm running Python2.1 on Solaris2.6 with Tkinter. I can't launch Grail. > I have a socket error in MyHTTP module > > Did anybody experienced the same problem Same here, on a Linux box. Also stumped. But then, I'm a newbie. > Thank you very much. > > BTW : All is fine with Python 1.52 > > > > -- Omri Schwarz --- ocscwar at mit.edu ('h' before war) Timeless wisdom of biomedical engineering: "Noise is principally due to the presence of the patient." -- R.F. Farr From scarblac at pino.selwerd.nl Wed Jun 13 04:00:58 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 13 Jun 2001 08:00:58 GMT Subject: BIG problem if readline strips newlines References: Message-ID: William Dandreta wrote in comp.lang.python: > Hi Pete, > >i've seen frequent mention of an option for readline() > >to strip out newlines as each string is read. this sounds > >like a great idea, but i realized its gonna be very > >difficult to loop through a text file. the standard > >python idioms will no longer work... > > > I don't think it means it changes the file, just the string(s) that are > returned by readline(s)(). Blank lines will be empty strings. And so is the end of file, as returned by readline(). How to see the difference? -- Remco Gerlich From rjroy at takingcontrol.com Fri Jun 8 17:14:19 2001 From: rjroy at takingcontrol.com (Robert Roy) Date: Fri, 08 Jun 2001 21:14:19 GMT Subject: Win32 binaries for PIL 1.1.2 on Python 2.1 ? Message-ID: <3b213f4c.1245895343@news1.on.sympatico.ca> I am looking for a Win32 binary for PIL 1.1.2 / Python 2.1. If anyone has built it I would appreciate the dll Thanks Bob From pecora at anvil.nrl.navy.mil Tue Jun 5 15:16:09 2001 From: pecora at anvil.nrl.navy.mil (Lou Pecora) Date: Tue, 05 Jun 2001 15:16:09 -0400 Subject: How do you develop in Python? Message-ID: <050620011516094693%pecora@anvil.nrl.navy.mil> I program in Python occassionally and would like to do more of it. But here's a development conundrum I run into a lot (there are more complex examples, but I'll give an easy one). I am developing module A.py which imports B.py in the IDE. I am running test code which is also in A.py as I incrementally develop A.py. Then I need to change B.py and, of course, the import does not import the new changes since import only works once. Hence, to "refresh" B.py I have to quit the IDE and restart, open A.py and run. This is clumsy. However, the above scenario is not uncommon and more complex interdependencies of modules appear to make it unavoidable. Anyone know a way to get around this "import" problem? I know there is a "reload", but then I have to import and change my modules' code to "reload" or something each time I work with them. Any help appreciated. I use Python on a Macintosh. Nice IDE, otherwise. From robin at jessikat.fsnet.co.uk Sat Jun 9 14:07:46 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sat, 9 Jun 2001 19:07:46 +0100 Subject: SV: HTTPSHandler ??? (where is it) References: Message-ID: In article , Alex writes >Thank you for the tip! > >Regarding the patching of the python socket, does it involve a lot of >research/work (I'm basically new to sockets)? > >Regards, >Rolf C Stadheim ... NO I think you need to ensure that the right #defines are set when the socket extension (or python) is built. You also need the latest openssl libraries available. For 2.1 I have win32 dlls available already. -- Robin Becker From hgg9140 at cola.ca.boeing.com Mon Jun 25 14:39:19 2001 From: hgg9140 at cola.ca.boeing.com (Harry George) Date: Mon, 25 Jun 2001 18:39:19 GMT Subject: trying using Python to remotely control another Python App References: Message-ID: This probably isn't a pure python question. If I understand correctly, you need the app to be visible to (and controllable by) both the user (at the remote machine) and the maintainer (at a central site). This can be done with VNC: http://www.uk.research.att.com/vnc/ ed_tsang at yahoo.com writes: > Hi, I am windering if anyone know or tried using Python to remotely > display and/or control another Python App? > how to do that? > > Current situation: > > I am a Python App which has a GUI interface to user that displayand > allow user to control the next action to be performed. But whenever > this app need support, the supporting people need to go to the client > office and do it there? > > It will be nice if we can view what is displayed on the client screen > and control the app remotely. Do we need to add this funcitonality to > transmitt the state of the whole App? > > The app is running on Sun solaris, and we do not have sys admin > control on their side. > > Any ideas? > > > -- Harry George E-mail: harry.g.george at boeing.com The Boeing Company Renton: (425) 237-6915 P. O. Box 3707 02-CA Everett: (425) 266-3868 Seattle, WA 98124-2207 Page: (425) 631-8803 From rnd at onego.ru Mon Jun 18 09:37:04 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 18 Jun 2001 17:37:04 +0400 (MSD) Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? In-Reply-To: <9gkio3$9jcft$5@ID-89274.news.dfncis.de> Message-ID: On 18 Jun 2001, Bernhard Reiter wrote: >In article <3B2B60AD.942719AE at earthlink.net>, > Ron Stephens writes: > >> I have not been successful heretonow in gui or event driven programming > >Event driven GUI programming is not really easy and the tools >available are complicated. I still remember HyperCard with warm feelings. It had very comfortable look&feel both from developer's and user's perspective. Every object had it's own script, which contained event handlers. Events were forwarded automatically from contained objects to containers and if not handled, Hypercard was the last who intercepted them. (Much like exceptions). Very nice scheme, which allowed to concentrate on the GUI and application logic, and not on the message propagation details. What I wanted to say, is that GUI programming is really easy when tools are like HyperCard: conceptually simple and powerful. Because all that complication comes from not hiding unnecessary details. Tk is like Assembly of GUI, while higher level is needed. After HyperCard (and SuperCard, HyperStudio to some extent) I have not seen anything near the quality and simplicity, unfortunately... Well, probably Squeak (sp?) is near, but it is thing in itself. Sy, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Monday, June 18, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Nostalgia isn't what it used to be." _/ From boud at rempt.xs4all.nl Sat Jun 23 11:14:10 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 23 Jun 2001 15:14:10 GMT Subject: emacs speedbar for python mode? References: <9h24tq$f7b$1@news1.xs4all.nl> Message-ID: <9h2bo2$335$1@news1.xs4all.nl> Fran?ois Pinard wrote: > [Boudewijn Rempt] >> Wonderful! Is there perhaps also a way to automatically >> open the speedbar? > I use the following. Only the last line really matters to you. :-) > ;;;; `Speedbar' mode. > (eval-after-load "speedbar" > '(push '(background-color . "floral white") speedbar-frame-parameters)) > (when (and window-system > (load "speedbar" t)) > (setq speedbar-verbosity-level 0) > ;; REVOIR: Le curseur reste dans le speedbar, malgr? le save-excursion. > (save-excursion > (speedbar-frame-mode 1))) Thank! I've only just bit the bullet and started to use emacs - after I found out there really isn't an alternative for writing docbook. I do wish I hadn't put it off for so long, though. I've used vi and nedit for more than half a decade... -- Boudewijn Rempt | http://www.valdyas.org From aleaxit at yahoo.com Tue Jun 12 04:07:31 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 12 Jun 2001 10:07:31 +0200 Subject: New guy question References: <3B255439.DFD33F59@home.net> Message-ID: <9g4ik305pa@enews2.newsguy.com> "Chris Barker" wrote in message news:3B255439.DFD33F59 at home.net... > Glen Mettler wrote: > > I forgot to ask - what is the purpose of the Python window and the Python > > Shell window? > > > > Can I NOT run a series of scripts from these windows? Must I go to the DOS > > window to check my program? > > You've gotten your answer, but I'll add one more comment. I mostly use > Linux, and run Python from a shell all the time. Windows does not give > you a decent shell by default, so you will be a lot happier using an > IDE, like IDLE or PythonWin (check out PythonWin, it's pretty nice). Some of us old crufties actually stick with consoles, but I guess we're dinosaurs. You're surely right that the default shell is sub-decent (on Win/95, /98, /ME; it's semi-decent on /NT & /2000), but... > By the way, I havn't used windows much since 3.1, Does it really still > have all that "add it to your PATH in autoexec.bat" stuff? Isn't there /95 and /98 do. /ME, I think not, but am not sure. /NT and /2000 have a more decent way to organize default environments (per-system and per-user). Hopefully /XP will stay true to its /NT roots there. There are MANY Windows, you know...! > any kind of standard directories for executables, and some way to put a > symbolic link in for your application? It makes for a Much cleaner > system! (I suppose the above file association stuff is why they havn't > bothered) There are system-directories, and 'shell shortcuts' that have some properties similar to a symbolic link (with extras, such as setting current-directory &c as possibilities) but also some limitations. But there is no *per-user* directory that gets automatically on the path, and dirtying the *per-system* directory is a bad idea. There IS some sort of a 'home' (per-user) these days, but it's not consistently used IMHO -- and the text-mode shells appear to be particularly indifferent to it (I guess they don't get maintained much these days, those text-mode shells... "it's a GUI world after all", innit?-). Anyway, nothing from the 'home' is implicitly on the PATH (presumably, specific users don't normally install their own executables intended for text-mode use:-). So, yeah, it IS a mess:-). Alex From cfelling at iae.nl Fri Jun 8 21:44:17 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 9 Jun 2001 03:44:17 +0200 Subject: Mutable class attributes are shared among all instances, is it normal ? References: <27vvht4uslv2ibq2q8ee4tovg86e7qempb@4ax.com> Message-ID: <9frv1h$hqt$1@animus.fel.iae.nl> Alain TESIO wrote: > Hi, sometimes class attributes added just after > "class ...:" outside a functions interfere among > instances, more precisely mutable objects are That's why they are called *class* attributes:) ... > Is it a bug or did I miss something ? Others already replied, but I think they too missed that you were using class attributes as if they were instance attributes. Let me explain. >>> class SomeClass: ... someClassAttribute = "spam" ... def someMethod(self): ... print self.someClassAttribute here we have a class and a class attribute. This class attribute exists in the namespace of SomeClass as can be seen with the dir function: >>> dir(SomeClass) ['__doc__', '__module__', 'someClassAttribute', 'someMethod'] and can be accessed as follows: >>> print SomeClass.someClassAttribute spam >>> SomeClass.someClassAttribute = "spam and spam" >>> print SomeClass.someClassAttribute spam and spam When we create an instance of this class, the use of dir will learn us that someClassAttribute is not automagically transformed into an instance attribute: >>> someInstance = SomeClass() >>> dir(someInstance) [] yet, like the methods defined in the class, it can be accessed as if it where an attribute of the instance, like: >>> print someInstance.someClassAttribute spam and spam >>> someInstance.someMethod() spam and spam So far all is fine, you change a class attribute through the class namespace and you can use it through the instance namespace as well. BUT when you try to change the class attribute through the instance namespace you're in for a small surprise. Assignment in Python is actually (re)binding a name in a name space to an object. And in this case a new name with binding is created in the instance namespace: >>> someInstance.someClassAttribute = "no more spam" >>> dir(someInstance) ['someClassAttribute'] >>> someInstance.someMethod() no more spam Mind you that the name of this newly bound name is highly misleading as it actually is an instance attribute now, that hides the true class attribute that still exists, as the following shows: >>> print SomeClass.someClassAttribute spam and spam >>> anOtherInstance = SomeClass() >>> dir(anOtherInstance) [] >>> anOtherInstance.someMethod() spam and spam To top this off we now should consider the behaviour of mutable versus non mutable objects. This has been dealt with in other replies, so let it suffice to say that changing the state of a mutable object doesn't involve any name rebinding, so all names keep refering to the same (although internally changed) object. > ============ start of file 'cl.py' > import random > class X: > val=None ^^^ here val is a class attribute > def __init__(self): > for i in range(3): > self.val=random.random() ^^^^^^^^ self.val is now an instance attribute > class Y: > val=[None] > def __init__(self): > self.val[0]=random.random() ^^^^^^^^^^^ val is not rebound, (though val[0] is) so it remains a class attribute To summarize class attributes can be inspected and changed within the class realm with: someClass.someClassAttribute class attributes can be inspected through instances with: anyInstance.someClassAttribute but assignment to it in an instance will instead create an instance attribute and hide the still existing true class attribute. So if you really need class attributes, that's fine, but pay attention that you only try to rebind them within the class and not within instances of that class and look out for "someInstance.someClassAttribute = ..." If on the other hand, you need instance attributes and want to use a class attribute to provide a default initial value for that instance attribute, that's fine too, but pay attention that you really rebind them within the instance name space turning them into true instance attributes upon change and look out for the sticky behaviour of mutable objects. -- groetjes, carel From jkraska1 at san.rr.com Wed Jun 20 22:05:33 2001 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 21 Jun 2001 02:05:33 GMT Subject: Pythoin MUD (PyMUD?) References: <9gqq3t$hvs$1@brokaw.wa.com> <9gqt0r$1q$1@news.mathworks.com> Message-ID: >I've been working on one for a bit. Python's an ideal language to >use--it's dynamicness allows easy updating of areas and such while the >mud is running. You'll also find that if you use Stackless Python (with continuations) that you can support a truly awesome level of threads. C// From tim.one at home.com Mon Jun 4 21:25:48 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 4 Jun 2001 21:25:48 -0400 Subject: random In-Reply-To: <3b1b9dd5.5603777@nntp.sprynet.com> Message-ID: [David C. Ullrich] > Um, actually I'm pretty sure that Omega _is_ what I said it is, and > is also what you say it is. I'm not . > ... > The first thing you need to note is that "probability that a random > program halts" is _meaningless_ until we have specified how we are > _choosing_ our "random program". Sure. > ... > Ok. So Omega is the probability that a "random program" > halts. This is one of those things I mentioned earlier: > you read people talking about Chaitin's stuff and you > say "what??", then you read what Chaitin actually wrote > and you're relieved to see he included the details: > > Yesterday I looked at that link you provided and I > saw Chaitin define Omega as the probability that a > random program halts. My first reaction was that > of course that's meaningless until you specify > how you _select_ your "random program" (more > precisely but less intuitively, until you specify > what distribution on the space of all programs > you are referring to.) But I read on: > > Chaitin is very well aware of everything I just > said. Although he did not explain why he needed > to do so, he _did_ "specify" what distribution > he had in mind. Even though it was just a survey > article - he knew I was going to be reading it > someday. He says something like this (um, I may > not get the details the same because I just skimmed > it, I'm pretty sure he says something like this): > > There are countably many Turing machines. Enumerate > them as T1, T2, ... . Now perform an experiment: > Flip a coin. If it's heads then let T = T1. > If it's tails flip again and if it's heads let T = T2. > If it's tails flip again and if it's heads let T = T3. > etc. With probability one we eventually get a head, > so we have in fact chosen a random Turing machine T, > with a well-defined distribution. Now Omega is the > probability that T halts. Chaitin's construction is actually based on the bit-length p of programs P. A specific program P of bit-length p that halts contributes (additively) 1/2**p to Omega -- all programs of length p carry the same weight. You may object that there are 2**p programs of length p alone, so that this isn't well-defined (i.e., that the programs of length p alone *may* contribute 2**p*(1/2**p) = 1 to the total, and that the sum over all P may be unbounded). Indeed, that was a long-standing hang-up! "The trick" is that Chaitin's twist on universal Turing machines requires "self-delimiting" programs: A key technical point that must be stipulated in order for Omega to make sense is that an input program must be self-delimiting: its total length (in bits) must be given within the program itself. (This seemingly minor point, which paralyzed progress in the field for nearly a decade, is what entailed the redefinition of algorithmic randomness.) ... If programs were not self-delimiting, they could not be constructed from subprograms, and summing the halting probabilities for all programs would yield an infinite number. If one considers only self- delimiting programs, not only is Omega limited to the range between 0 to 1 but also it can be explicitly calculated ``in the limit from below.'' IOW, there are slippery subtleties here (subtle enough to trip up serious researchers for years) -- if you want to pursue this, it's better to stop guessing at the gaps in popular overviews and go to the sources. The way he actually approximates Omega from below is to compute the values of omega_n() for increasing n, where for a fixed n omega_n() looks at all programs P of bitlength <= n, and for each one that halts within n seconds, adds 1/2**len(P) to a running total (where len(P) is my spontaneous notation for the bitlength of P). This gives, for increasing n, a non-decreasing sequence of rationals that converge to Omega (but with a non-computable convergence rate). The relation to coin-tossing is this: *each* time he flips a coin he appends a 0 or 1 bit (depending on whether heads or tails comes up). The coin-tossing stops when the program is complete; the "self-delimiting" business is crucial here, else you couldn't know when to stop; then there are technical details about strings that aren't well-formed programs, etc. But the finer a point you want to draw the more the details become important, and I think we're already beyond what Usenet is any good for. > ... > The previous paragraph is a precise/rigorous > specification of "Omega is the probability that > a random program halts" It's some sort of probability measure, yes, but not Chaitin's. > (except it doesn't quite pin down what Omega _is_ since it does > not specify exactly what order we put the Turing machines in at > the start. To actually _define_ the sequence T1, T2,... we'd need > to get into details of the syntax we were using to define TM's.) Yes, and "Chaitin's constant" too is really a function of the specific universal Turing machine in question. Without qualification, it usually refers to the Omega of a specific UTM he coded in Lisp and published. However, Chaitin's defn doesn't involve a bijection between natural numbers and machines, except in the incidental sense that programs are viewed as bitstrings which *could* be viewed as integers -- but the defn makes no use of that, only of the *lengths* of programs, and those are independent of arbitrary orderings. > ... > I don't think so. And in any case if you _do_ choose your program > by flipping a coin as above that specifies a distribution, and with > that distribution the probability that a random program halts _is_ > a number with n-th bit = 1 if and only if the n-th TM halts. Can only repeat that it's a classic example, and, again, IIRC it doesn't meet the criteria for randomness. Could be I'm wrong about that, but this is far enough removed from what I'm supposed to be doing right now that I'm not going to go searching one way or the other. If you do, let me know what you find out. > ... > (And in fact when I think about how to do that > and I think about how one would "naturally" > order the TM's it's not clear to me that such > non-randomness does not creep into Omega > defined using a "natural" ordering...) As above, Chaitin's defn. is independent of ordering. > If I have the "definition" straight (and > note that nothing I've said contradicts > what you said about the definition!) then > the bits of Omega are not going to be much > use for an RNG. > ... I agree with the conclusion regardless. > But it turns out that Omega _does_ solve a > _different_ practical problem! What's the > other pressing problem? Determining which > reals have exact floating-point representations. > > Thm1. Omega does not have an exact representation > in finite-but-unbounded-precision floating point. > > Thm2. Thm1 is all you can say about Omega, given > the definition above: If x is any real (between > 0 and 1) and x does not have an exact representation > in finite-but-unbounded-precision floating point > then there is an ordering T1, T2,... of our > Turing machines that makes Omega = x. Since it's not a computable ordering, I'm not sure "solves" was the right word . Note that recent results have shown that every non-computable *random* real (in (0, 1)) is the (Chaitin-style) Omega for some self-delimiting UTM. That's a paraphrase. A precise statement requires pages of defns, and again people interested enough should go the sources (I gave a good link earlier in this thread). > ... > (Devil's advocate: But if Omega can be 0.10101010... > then how can it be incompressible? You're not actually > saying Chatin's wrong about that, are you? No. I believe instead that there's no self-delimiting UTM (etc -- insert paragraphs of defns here) s.t. 0.1010... is its Omega. All Omegas are known to be random. >> Perhaps the easiest gimmick for programmers to grok is that the set of >> rationals less than omega is recursively enumerable: Chaitin gives you >> a generator object g such that the loop >> >> while 1: >> r = g.next() >> >> eventually generates every rational number r less than omega. Then the >> generated sequence of values r_0, r_1, .. approximates omega from below >> (although only the biggest-so-far-seen are interesting), and for any >> real >epsilon greater than 0 there's *some* i s.t. omega - r_i < epsilon >> (since>every rational less than omega is eventually generated). So >> a subsequence of the r_i converges to omega. > Yup. Doesn't contradict the statement that the n-th bit is 1 if and > only if the n-th program halts. Right: that part wasn't for your benefit , it was for others who may not have known what "recursively enumerable" means. What I said in that part applies to *any* "computably enumerable (c.e.) real" == any real number such that the set of all rationals less than it can be generated. Your number and Omega are both c.e., so that part applied equally to both. For that matter, the real number 6.0 is also c.e.. The later points about the convergence rate being non-computable and that there's no "fundamentally better" way to compute the limit don't follow from that much alone. That's why I called them "two results of the theory" (referring (too) obliquely to Chaitin's theory). From rsiebler at ibeam.com Thu Jun 21 19:05:31 2001 From: rsiebler at ibeam.com (Robin Siebler) Date: Thu, 21 Jun 2001 23:05:31 GMT Subject: Stop/Start Service in Win2k Message-ID: <%4vY6.9705$Up.285700@sea-read.news.verio.net> I got a script off the ActiveState site that will stop and start a service (the script is at the bottom of this post) . It works fine on NT4 and it works for some services on Win2k, but for most services, I get the below error: Traceback (most recent call last): File "", line 1, in ? File "c:\python21\scripts\winsvc.py", line 37, in service_info if win32serviceutil.QueryServiceStatus(service, machine)[1] == 4: File "c:\python21\win32\lib\win32serviceutil.py", line 359, in QueryServiceStatus hs = win32service.OpenService(hscm, serviceName, win32service.SERVICE_QUERY_STATUS) api_error: (1060, 'OpenService', 'The specified service does not exist as an installed service.') Could someone tell me why this happens and how to fix it? Thanks! import win32serviceutil def service_info(action, machine, service): if action == 'stop': win32serviceutil.StopService(service, machine) print '%s stopped successfully' % service elif action == 'start': win32serviceutil.StartService(service, machine) print '%s started successfully' % service elif action == 'restart': win32serviceutil.RestartService(service, machine) print '%s restarted successfully' % service elif action == 'status': if win32serviceutil.QueryServiceStatus(service, machine)[1] == 4: print "%s is running normally" % service else: print "%s is *not* running" % service if __name__ == '__main__': machine = 'cr582427-a' service = 'Zope23' action = 'start' service_info(action, machine, service) From whisper at oz.nospamnet Thu Jun 7 00:42:43 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 7 Jun 2001 04:42:43 GMT Subject: Working with paths with spaces in NT Message-ID: <9fn0o3$9d3$0@216.39.170.247> import os import dircache import re def getDirs(path, tabs): dirlist = [] os.chdir(path) for dir in dircache.listdir("."): if os.path.isdir(dir): dirlist.append(dir) print dirlist for dir in dirlist: print dir getDirs(dir, tabs + 1) getDirs("L:/languages/python", 1) This will report: [k:/Python21/Projects]% python FileList.py ['Apps', 'CVS', 'Database', 'Distributions', 'Docs', 'Tools', 'libs'] Apps ['ThoughtStream', 'XML', 'moop'] ThoughtStream ["A Gentle Introduction to Ted Nelson's ZigZag Structure_files", 'ThoughtStream Design notes_fil es', "ThoughtStream User's Guide_files", 'XML Topic Maps (XTM) 1_0 errata_files', 'XML Topic Map s (XTM) 1_0_files', 'XML Topic Maps (XTM) Processing Model 1_0_files'] A Gentle Introduction to Ted Nelson's ZigZag Structure_files [] ThoughtStream Design notes_files Traceback (most recent call last): File "k:\python21\projects\FileList.py", line 17, in ? getDirs("L:/languages/python", 1) File "k:\python21\projects\FileList.py", line 15, in getDirs getDirs(dir, tabs + 1) File "k:\python21\projects\FileList.py", line 15, in getDirs getDirs(dir, tabs + 1) File "k:\python21\projects\FileList.py", line 15, in getDirs getDirs(dir, tabs + 1) File "k:\python21\projects\FileList.py", line 8, in getDirs os.chdir(path) OSError: [Errno 2] No such file or directory: 'ThoughtStream Design notes_files' How do I process directory names with spaces? I looked through the python doc, but didn't see anything. TIA Dave LeBlanc From MarkH at ActiveState.com Thu Jun 7 18:52:14 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 07 Jun 2001 22:52:14 GMT Subject: Creating Typeinfo for Python COM servers? References: <9fnocb$550f3$1@ID-59885.news.dfncis.de> <3B1F69CD.5000704@ActiveState.com> <9fofhe$5c8p0$1@ID-59885.news.dfncis.de> Message-ID: <3B2005BE.5060802@ActiveState.com> Thomas Heller wrote: > Next question: > Assuming a tlb file is available, how can I plug it > into the server, so that GetTypeInfoCount() and GetTypeInfo() > return something useful? You would need to change PyGatewayBase.cpp, and have it delegate the calls into the "policy" object - just like "Invoke" does now. > BTW: Where is actaully the _implementation_ of the COM server > object? PyGatewayBase.cpp? Kind-of - that is the raw implementation of IDispatch. The logic is all contained in win32com\server\policy.py Thus, policy.py would hold the actual implementation of the 2 functions. Mark. From emmanuel.astier at winwise.fr Fri Jun 22 13:41:49 2001 From: emmanuel.astier at winwise.fr (Emmanuel Astier) Date: 22 Jun 2001 10:41:49 -0700 Subject: How to reload a module in embedded C Message-ID: Hi, I would like to reload a module, AND the module that are used in this module. If there's a "import Camera" in my first module, I would like to reimport the Camera module also. I first tried : modTemp = PyImport_ReloadModule( Module ); // Initialisation et verification de Python : if ( modTemp ) { Module = modTemp; Py_XDECREF ( modTemp ); mdict = PyModule_GetDict( Module ); EntryPoint = PyDict_GetItemString(mdict, "Tick"); /* borrowed reference */ if ( EntryPoint ) { if ( PyCallable_Check( EntryPoint ) ) { IsCompileOk = true; } } else { Py_XDECREF ( Module ); } } else { CompileErrorPrint(); LoadModule(); } But that doesn't reload the dependent modules. So I tried to 'del' my first module, but it crashes ( Python thinks the module is still there ) with : IsCompileOk = false; PyObject_Del( Module ); Module = NULL; // Initialisation et verification de Python : LoadModule(); So I don't know how to do... Any idea ?? Thanks by advance, Emmanuel From gmcm at hypernet.com Thu Jun 21 17:46:53 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 21 Jun 2001 17:46:53 -0400 Subject: [Python-iterators] RE: Meta: PEP discussion (was Re: PEP 255: Simple Generators) In-Reply-To: References: Message-ID: <3B32330D.21495.29EA4013@localhost> Steven D. Majewski wrote: > My 'suspend value' actually got transformed into returning the > tuple > (value, suspended-frame), so to use it in a loop required > something > like: > > iterf = function # don't mung up the global name > while 1: > value, iterf = iterf( args... ) > ... # first time, call the function > # all others, call the suspended activation frame Actually, that's almost exactly what a lot of my Stackless code looks like. While not exactly pretty, it has the advantage that you can return/suspend/yield (value, None) to signal you're done. I acquired the habit way back when Stackless had a leak in the presence of exceptions crossing continuation boundaries, but grew to like it. - Gordon From idivanov at hotmail.com Thu Jun 21 11:25:05 2001 From: idivanov at hotmail.com (Ivan) Date: 21 Jun 2001 08:25:05 -0700 Subject: How to convert an object ref to string and the reverse Message-ID: <9dab6033.0106210725.935e7c4@posting.google.com> Hello, this is a basic question: how is it possible to convert an instance to string and how to do the reverse - convert the resulting string in a valid object reference. Example: Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> class C: ... def __init__(self): ... self.msg = "hello" ... def show(self): ... print self.msg ... >>> c_i = C() >>> c_i.show() hello >>> c_i <__main__.C instance at 007DE0FC> >>> >>> d = <__main__.C instance at 007DE0FC> <====??? How to do this? File "", line 1 d = <__main__.C instance at 007DE0FC> ^ SyntaxError: invalid syntax >>> d.show() From gb at cs.unc.edu Tue Jun 12 10:15:02 2001 From: gb at cs.unc.edu (gb at cs.unc.edu) Date: 12 Jun 2001 10:15:02 -0400 Subject: Emacs python-mode in execute-buffer? Message-ID: This is on Win2k running Emacs 20.7.1 and python-mode 3.105. When I execute my python program with Cc-Cc it works fine but if I try to execute it asynchronously with Cu-Cc-Cc I get Traceback (most recent call last): File "c:/tmp/python-14087TM", line 19, in ? import config ImportError: No module named config I'm thinking the difference must be that with synchronous execution the python process is running in the current directory but with asynchronous execution it is running in the c:/tmp directory. Is this a bug? Or am I doing something wrong? Thanks gb From rnd at onego.ru Thu Jun 21 02:43:56 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 21 Jun 2001 10:43:56 +0400 (MSD) Subject: PEP 255: Simple Generators Message-ID: I've not been heard or commented. It seems that everybody is happy with simple generators (and discuss syntax) while I am not. I dare think that proposed gen/generator/def-yield thing is doomed to be phased out in some future Python version, because it creates frozen context for very narrow task of providing generators and in the future (I hope) there will be normal parallel programming in Python, which will solve the problem simply and efficiently. I am not against PEP 255. The feature is cool. But it is a feature which requires new keyword, new function class, etc. In one way or another, it modifies function and it implicitely lead to the same syntax beasts as in C++/Java/Pascal. PEP 255 is not Pythonish enough. Let's better think about more general things like: * co-routines (which "generator" is an example, if I understand it correctly) * adding parallel programming paradigm (which is even better for long term), where objects live their lifes and could serve other objects as generators, gatherers, services, etc. OOP was made easy by python. I hope parallel programming to be added and made equally easy, without all those modifiers and zillion of new keywords and modifiers. Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From fredrik at pythonware.com Wed Jun 6 13:37:09 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 06 Jun 2001 17:37:09 GMT Subject: why huge speed difference btwn 1.52 and 2.1? References: <9f8fgs$ooo$1@knot.queensu.ca> <9fdjsc$pn4$1@panix2.panix.com> <3b1bcf7a.12528354@news.ccs.queensu.ca> Message-ID: <9TtT6.2225$G4.351713@newsc.telia.net> Neil Schemenauer wrote: > Your problem is likely that you are re.search() in a loop. In > Python 1.5.2 re.search() was a C function. In 2.1 it is a Python > function. not really true: re.search is a Python function in both versions, re.compile().search is a Python method in 1.5.2 and a C method in 2.1. the 2.1 engine has a slower compiler, though. > Using the pcre.search() function should get your program up > to speed that's pre.search(), not pcre.search(). From bill-bell at bill-bell.hamilton.on.ca Mon Jun 25 11:07:54 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Mon, 25 Jun 2001 11:07:54 -0400 Subject: ActiveX Controls in Python In-Reply-To: <993456530.653.11377.l6@yahoogroups.com> Message-ID: <3B371B8A.28790.348B2B4@localhost> davidw at weblink.com.au (David White) wrote: > I'm a C++ programmer whose considering using Python to prototype an > ActiveX control. However, I can't seem to find any samples or > resources on implementing ActiveX controls in Python. Would anyone be > able to give me any pointers on how to do it? > > Also, the control will have to make heavy use of a grid control, what > grid controls are available that have Python interfaces? David, your message reminded me that Mark Hammond, one of the main, if not the main expert on this topic wrote, "Python's COM support does not support fully-fledged controls. The win32comext/axcontrol directory is the start of work in this direction, and supports many of the interfaces needed." I googled to find that he wrote that about 6 May (and you might want to read the rest of that thread). I'm curious about what your control will do. Would it be possible to say? - Bill Bill Bell, Software Developer From fschaef at ces.clemson.edu Mon Jun 25 15:05:45 2001 From: fschaef at ces.clemson.edu (Schaefer, F.) Date: Mon, 25 Jun 2001 12:05:45 -0700 Subject: Tkinter and TkTable Message-ID: <3B378B89.6D235698@ces.clemson.edu> Hi Guys, I'm in need of a table widget to display some query data. There is this popular TkTable Widget, which I would like to use. Does anybody have any idea howto include it into Tkinter (and why it isn't already included). Did somebody perhaps write a wrapper for it ? Thanks, Frank From aleaxit at yahoo.com Thu Jun 14 07:56:43 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 13:56:43 +0200 Subject: Need Help building COM server in python References: <844df35f.0106140116.5f706fcf@posting.google.com> Message-ID: <9ga8q702oe3@enews1.newsguy.com> "michiel" wrote in message news:844df35f.0106140116.5f706fcf at posting.google.com... ... > class HelloWorld: > _reg_clsid_ = "{D4FF29AD-BCDE-4FE2-9896-892D2EBB5180}" > _reg_desc_ = "Python Test COM Server" > _reg_progid_ = "Python.TestServer" > > _public_methods_ = ['Hello'] > _public_attrs_ = ['softspace', 'noCalls'] > _readonly_attrs_ = ['noCalls'] > > def __init__(self): > self.softspace = 1 > self.noCalls = 0 > def Hello(self, who): > self.noCalls = self.noCalls + 1 > return "Hello" + " " * self.softspace + str(who) This looks misaligned to me (if you're using tabs, it could be the tabs-eating behavior many MS newsreaders show -- one more reason to *ONLY USE SPACES*!-). Make sure the def keywords are aligned with the rest of HelloWorld's classbody, and the methods' bodies indented further. > PROBLEM: > > Registration of the object works. > Creation of the object works (x=createobject("python.object")), This cannot be creating the object you just described! Its ProgID: > _reg_progid_ = "Python.TestServer" is as you see Python.TestServer, ***NOT*** python.object. So you may be creating something completely different. > Can someone help me out or send me an example of a useable COM server > object written in python? Your works just fine, once the def's & bodies thereof are indented 4 spaces rightwards, and when instantiated with the actual ProgID it's registering with. Alex From volucris at hotmail.com Wed Jun 20 20:09:51 2001 From: volucris at hotmail.com (Volucris) Date: Wed, 20 Jun 2001 19:09:51 -0500 Subject: launching a file with its associated application on windows References: Message-ID: <3b313ae6$0$327$6e49188b@news.goldengate.net> If it's pre 2.0, I think you can prefix a popen() command with 'start ' to do the same thing. import os os.popen('start %s' % r'C:\sish\MyPic.bmp') -- Volucris (a) hotmail.com "Eu n?o falo uma ?nica palavra do portugu?s." "Tim Peters" wrote in message news:mailman.993076625.9823.python-list at python.org... > [Christian Reyes] > > Is there a method that takes a file as an argument and then opens > > that file with the its associated viewer? > > This must be a Windows question, right? If so, in Python 2.0 or later, the > Windows-specific os.startfile() does exactly that. > > From paulp at ActiveState.com Tue Jun 19 14:11:28 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Tue, 19 Jun 2001 11:11:28 -0700 Subject: PEP 255: Simple Generators References: <9glhg7$dlk$1@nntp6.u.washington.edu> <4DLX6.320220$oc7.29444949@news2.rdc2.tx.home.com> <20010619105635.B14229@glacier.fnational.com> Message-ID: <3B2F95D0.1FA2AA2@ActiveState.com> Neil Schemenauer wrote: > >... > > def f(): > return x > x = 1 > > Is "x" a local variable? Most of your arguments apply to local > variables as well. Yes, but lets not compound our mistakes. :) -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From new_name at mit.edu Wed Jun 13 13:00:10 2001 From: new_name at mit.edu (Alex) Date: 13 Jun 2001 13:00:10 -0400 Subject: PyArg_ParseTuple References: Message-ID: > what do I pass in for the "address of a Python type object", as stated > below? Pass a reference to the type. So, for instance, if it's to be a list, you do something like this: if (!PyArg_ParseTuple (args, "sO!", &sequence, &PyList_Type, &offsets)) The different type arguments are in the C API manual. E.g., PyList_Type is in http://python.org/doc/current/api/listObjects.html HTH Alex. From tgos at spamcop.net Wed Jun 6 23:57:04 2001 From: tgos at spamcop.net (TGOS) Date: 6 Jun 2001 22:57:04 -0500 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3b1cdc84.5514@bolder.com.co.za> <9fleid$3rp$1@oslo-nntp.eunet.no> <3B1E4951.7F36D4E4@alcyone.com> <3B1E50E1.35AE59C@lmf.ericsson.se> <3B1E52DA.BBC9FC32@alcyone.com> <3b1e5601.3970@bolder.com.co.za> <3B1E5836.E7F1D88F@lmf.ericsson.se> Message-ID: On Wed, 06 Jun 2001 19:20:06 +0300, Attila Feher wrote: > And they don't program in Pascal! :-))) Why not? -- TGOS From phd at phd.fep.ru Sat Jun 23 10:09:26 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Sat, 23 Jun 2001 18:09:26 +0400 (MSD) Subject: Legitimate to raise SyntaxError for non-Python syntax errors? In-Reply-To: Message-ID: Hello! I made a patch for Zope (was incorporated into Zope 2.4.0a1), and the code raise SynaxError on - yes, syntax errors in the input streams my code parses. It is in the dtml-in sort attribute; my code requires sort order to be either ASC or DESC (case-insensitive). If not it raises SyntaxError. On Sat, 23 Jun 2001, Tim Peters wrote: > [Hamish Lawson] > > Is it legitimate to use the SyntaxError exception for non-Python > > syntax errors, say by a parser when it encounters violations in the > > syntax of the data format or mini-language it is parsing? I'd always > > assumed that SyntaxError was meant for just Python syntax errors, ... > > I doubt anyone will object. Thousands of programs reuse Python's ValueError and > TypeError, and while SyntaxError reuse is less common, it seems like it's much > the same thing. Just because Guido took all the good exception names first > doesn't mean he gets to keep them to himself . Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From jkraska1 at san.rr.com Thu Jun 14 21:11:00 2001 From: jkraska1 at san.rr.com (Courageous) Date: Fri, 15 Jun 2001 01:11:00 GMT Subject: sorting values in dict References: Message-ID: <4doiitsrkn6npivhs2l1qs9ns844uu6msu@4ax.com> On Thu, 14 Jun 2001 23:24:11 +0200, Jeroen Wolff wrote: >I want to display a dict sorted by value. >But i would like to have is sorted (on screen) by value.... I don't know what you really want here. Since others have already posted some suggestions, I'll simply observe that when a programmer wants "fast look up, ordered entries," a tree structure of some time is generally used. The use of the appropriate tree eliminates the need to sort the container at any given time, as the tree is kept in order; you'll find an entry in O(log N) time. Look in the Vaults for an implementation. C// From gardner at cardomain.com Sat Jun 9 23:58:06 2001 From: gardner at cardomain.com (Jonathan Gardner) Date: Sat, 9 Jun 2001 20:58:06 -0700 Subject: Just a small quine References: <3b1fa942.11180453@news.t-online.de> <3b21046b.12594390@news.t-online.de> Message-ID: <9fur39$rep$3@brokaw.wa.com> Gerson Kurz wrote: > On Fri, 8 Jun 2001 18:27:58 +0200, Pieter Nagel > wrote: > >>Small? Here's a one-line quine: >> >>s="s=%c%s%c; print s%%(34,s,34)"; print s%(34,s,34) >> > > note about my first one: the stuff at the top defines a brainf*ck > interpreter, the stuff at the bottom creates sourcecode for the > interpreter and then calls it... but its still python ;) > > here are two other quines I wrote while brewing up that one: > > def r(x):x=list(x);x.reverse();return "".join(x) > s=""" > s tnirp;]:05[)s(r+)01(rhc+'"'*3+s+'"'*3+]25:[)s(r=s > )x(nioj."" nruter;)(esrever.x;)x(tsil=x:)x(r fed > """ > s=r(s)[:52]+3*'"'+s+3*'"'+chr(10)+r(s)[50:];print s > > and > > s="""s="s="+3*'"'+s+3*'"'+chr(59)+s > print s""";s="s="+3*'"'+s+3*'"'+chr(59)+s > print s > > both use the same basic idea so its kind of a downer once you see > whats happening. Are we going to start signing our posts with quines, the same way that the Perl people sign their posts with JAPH? From tim.one at home.com Tue Jun 26 00:22:40 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 26 Jun 2001 00:22:40 -0400 Subject: PEP 255: Simple Generators, Revised Posting In-Reply-To: <6qk8203myt.fsf@abnoba.intevation.de> Message-ID: FYI, Python 2.2 will recognize that this is a generator after all: def f(): if 0: yield 1 A change to enable that was just checked in. Other varieties of "if 0:" glitchlets weren't helped, though -- just yield. Just van Rossum suggested a prettier way to spell this: def f(): while 0: yield 1 I think that's especially nice because, where you're prototyping code and need a generator stub (placeholder), you can flip between "0" and "1" to get either an empty or unbounded iterator, two extremes that are good for testing. From bh at intevation.de Thu Jun 28 08:43:22 2001 From: bh at intevation.de (Bernhard Herzog) Date: 28 Jun 2001 14:43:22 +0200 Subject: PEP 260: simplify xrange() References: <3B39480C.F4808C1F@Lugoj.Com> <9hc97q$rpt$1@slb6.atl.mindspring.net> <3B3A9C39.64C3E1C6@seebelow.org> <9hef08$urt$1@slb3.atl.mindspring.net> <9hf5ru$5el$1@animus.fel.iae.nl> Message-ID: <6qg0ckydud.fsf@abnoba.intevation.de> Michael Hudson writes: > Carel Fellinger writes: > > > Michael Hudson wrote: > > ... > > > Google confuses me; if you search for "michael hudson" my page is the > > > third hit - but my name doesn't actually appear anywhere on the linked > > > page! What was your exact query (I guess you omitted the quotes)? If I query for "michael hudson" (including the quotes!) your CV is the first entry in the result list. > > probably it's in a hidden field, like > > Nope. These are my web pages we're talking about here! My name > appears on various bits of my pages (my CV, the python-dev summaries), > but definitely not on the page google points you to. Google also looks at text of the links pointing to a website. E.g. if there's a link Michael Hudson on a website, google takes that as a hint that the page pointed to is about "Michael Hudson". Bernhard -- Intevation GmbH http://intevation.de/ Sketch http://sketch.sourceforge.net/ MapIt! http://mapit.de/ From see at my.signature Fri Jun 1 01:20:46 2001 From: see at my.signature (Greg Ewing) Date: Fri, 01 Jun 2001 17:20:46 +1200 Subject: parse-time optimizations References: <9f61od$aic$1@news.mathworks.com> <3B16B548.32986D7@chello.nl> <9f6cs4$hjc$1@news.mathworks.com> Message-ID: <3B17262E.B56A8E56@my.signature> jcm wrote: > > Another > poster implied that in Python you can redefine plus so that it is > right-associative for a custom type. No, he said "not associative", meaning that (a+b)+c is not necessarily equal to a+(b+c). That's a different issue from whether an operator is left- or right-associative, which is a syntactic issue concerning how to interpret a+b+c when there is no explicit grouping. In that sense, the +-*/ operators are all left- associative in Python (this is determined by the Python grammar, and can't be changed). -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From dsh8290 at rit.edu Thu Jun 7 14:27:30 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 7 Jun 2001 14:27:30 -0400 Subject: RS232 support for DOS on 486? In-Reply-To: ; from luthi@vaw.baug.pleasedontspamme.ethz.ch on Thu, Jun 07, 2001 at 09:57:29PM +0200 References: Message-ID: <20010607142730.B17494@harmony.cs.rit.edu> On Thu, Jun 07, 2001 at 09:57:29PM +0200, luthi at vaw.baug.pleasedontspamme.ethz.ch wrote: | | I wonder if someone has managed to use the serial port (RS232) with | Python on a 486 with MS-DOS. I have to use a (old, rugged) 486 for | data recording of a TEK-Scope and would like to customize the | communication. Does Python even run under MS-DOS? | I am grateful for any advice Install an advanced OS, such as Debian ;-), then using the serial port becomes rather simple. You would only need to use the termios module to set the properties of the RS232 protocol (7bit, 8bit, parity, non-partiy, stop bit, etc) then use reguler file IO to read/write to the serial port (/dev/ttyS0). -D From dcohen at users.sourceforge.net Wed Jun 6 09:46:23 2001 From: dcohen at users.sourceforge.net (David Cohen) Date: Wed, 06 Jun 2001 13:46:23 GMT Subject: ANNOUNCE: pyagent Version 1.00 Message-ID: Downright Software (http://www.downright.com) announces pyagent version 1.00. pyagent provides a simple, open infrastructure for intelligent agents. pyagent is based on Frederik Lundh's implementation of XML-RPC. See http://www.pythonware.com/products/xmlrpc/index.htm. Version 1.00 is now being used in the production system of StressMy.com, our web-based website load testing application (see www.stressmy.com). In addition to minor bug fixes, this version includes two new sample apps: * slackerChat: a fullscreen chat window app built on feebchat. Thanks to Joe Griffin, our President, for whipping this one up... * Meerkatbot: a bot that posts O'Reilly's Meerkat news headlines to a chat session. This is the kind of pseudo-erudition that impresses the refined intellectuals at Downright Software. Thanks to Doug Fort, our Senior Meat Manager, for this one. We think you should try pyagent out because it's easy to use, it's robust, and we have a strong incentive to keep improving and supporting it. We're hosted at http://pyagent.sourceforge.net. Enjoy! The pyagent team - David Cohen (dcohen at users.sourceforge.net) - Doug Fort (dougfort at users.sourceforge.net) - Joe Griffin (jgriffin716 at users.sourceforge.net) From donod at home.com Fri Jun 1 18:49:08 2001 From: donod at home.com (Don O'Donnell) Date: Fri, 01 Jun 2001 22:49:08 GMT Subject: decimal or rational (was Re: Against PEP 240) Message-ID: <3B181C51.9AA8C2AC@home.com> Alex Martelli wrote: > >"Laura Creighton" wrote in message >news:mailman.991303187.29241.python-list at python.org... > ... > > > is decimal, not rational that is the way to go, somebody try to talk us > > out of it> is exactly what Burke was talking about. > > I'm not a candidate for "talking (anybody) out of it", where > "it" is having (e.g.) 7.35 mean a floating-point-decimal 7.35 > rather than a rational 7.35, because I'm _deeply_ undecided > myself. My criterion: what *WOULD* be harder to explain to (and > have accepted by) an intelligent beginner? Potentially *VERY > SLOW* (and memory-consuming) behavior for computation, or the > risk of unexpected (to said beginner) 'strange' results? And > I'm not talking about a vacuum -- I'm talking about a real-world > where people's expectations ARE very much shaped by the > calculators they've dealt with for years, and those ARE FP > decimal (at least typically). A computation doesn't slow > down as it proceeds, but it does often lose precision... If by "floating-point-decimal" you mean internal representation of both the mantissa and the exponent by some sort of a binary-coded decimal, let me point out that it is not necessary to go to full decimal in order to to achieve the `7.35` == "7.35" goal. By letting the exponent represent powers of 10 rather than 2, the base or mantissa can be represented in binary as an int or long. Thus, the internal calculations can use the fast integer hardware instructions, rather than decimal arithmetic which would have to be done by software. Scaling would require a multiply or divide by 10 every time the exponent is incremented/decremented by one, not as fast as a left or right bit shift; but it can be done pretty fast considering that a multiply by 10 is equivalent to a left shift by 3 (*8) followed by two adds (10*x == (8+2)*x == 8*x + 2*x == 8*x + x + x): >>> x = 42 >>> (x<<3) + x + x # multiply by 10 without using * op 420 I'm not sure that this is any faster than x*10; in Python, probably not, but in C it may be. (Haven't looked at any CPU timing charts lately, so I may be all wet here; it used to be that mult & div were very expensive.) (A quick timing check shows that the above shift and add calculation takes about 3 times longer in Python than a straight *10, as expected.) Obviously, this binary-based decimal-powered floating-point would not be as fast as using the hardware FPU, but it wouldn't be as bad as doing all calculations in decimal as with a full decimal implementation. I'm in the process of writing an "efloat" class which implements these ideas as a proof of concept. "efloat" for expected float, i.e., one that meets your expectations, no surprises, as with: >>> 7.35 7.3499999999999996 If someone can think of a better name please let me know. I didn't want to call it dfloat since that should be reserved for a full decimal implementation. Come to think of it, efloat may not be such a good name since it can be confused with the "e" in the binary float literal display (0.735e1). I'll post the source code when I'm done, in case anyone is interested in checking it out. As far as decimal vs rational for a built-in Python type, couldn't we have both? And if we do get both, I think: 7.35 or 735d-2 should be the literal for the decimal-float 7.35e0 or 735e-2 should be the literal for binary float 735/100 or 735r-2 should be the literal for rationals -Don From aleaxit at yahoo.com Wed Jun 6 12:12:59 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 6 Jun 2001 18:12:59 +0200 Subject: random References: <3b1cf00f.5441109@nntp.sprynet.com> <3b1e4957.3040319@nntp.sprynet.com> Message-ID: <9flkqc01nfp@enews2.newsguy.com> "David C. Ullrich" wrote in message news:3b1e4957.3040319 at nntp.sprynet.com... > On Tue, 05 Jun 2001 20:42:47 GMT, wtanksle at dolphin.openprojects.net > (William Tanksley) wrote: > > >On Tue, 05 Jun 2001 15:09:25 GMT, David C. Ullrich wrote: > >>But this question is not meant to be rhetorical: We have a syntax where > >>the valid programs are exactly finite sequences of 0's terminated by a 1. > >>Does this count as "self-delimiting"? > > > >Yes, but I don't think it counts as a UTM program. There are only > >countably many possible programs for this machine, while a UTM can run > >uncountably many. > > Um. Some of these "programs" have infinite length, then? If they I think a Universal Turing Machine should by definition accept programs of infinite length. It has an infinite length tape and the program is written there; is there any clause I'm forgetting which says the tape cannot have an infinite number of symbols on it when the run starts? > all have finite length then there's only countably many - that's > even if the length is unbounded. If a UTM actually runs programs > of infinite length then fine, but I can't imagine what it means > to run such a program. Some of those runs will in fact halt (not all of the program steps that are on the tape need be reachable, surely?), other won't, some of those that don't halt will reach all steps on the tape. I don't see what is strange about that, so I may be missing something. Let's take an example to fix ideas. We won't even take a Universal TM, just a plain TM. Symbols on the tape mean (summarizing a little): 0 print a 0, overwrite the 0 with NOP, get to state A 1 print a 1, overwrite the 1 with NOP, get to state A X get to state B, move right NOP if state B move right, if state A move left H halt A typical program is an X followed by a sequence of 0 and 1 (there may be NOP's there, but they have no effect -- there may be X's, which also have no effect on the output -- there may be H's, of course, to halt the program). If the program is finite, this non-universal Turing Machine prints a finite sequence of 0's and 1's then halts. If the program is infinite but contains a H somewhere, ditto -- nothing right from the H is even considered. If the program is infinite and contains no 'H', we have a non-halting program, which just keeps printing 0's and 1's as its original "source code" (:-) specifies. It seems clear to me that this IS a pretty ordinary Turing Machine. Am I missing something? The sets of programs for this TM seems to be in a natural correspondence with all reals between 0 and 1. Many programs output the same real, of course, since we have the ability to place NOP's, but by a typical Cantor diagonal argument the cardinality of the set of programs would seem to be that of the reals (am I missing something here?) as we can easily encode each program into a real (between 0 and 1, say) by using 3 bits to encode each symbol and just catenating them. By definition of Universal, a UTM should be able to execute these programs (as well as many others). So, the set of programs a UTM can execute has a cardinality of at least that of the reals. Since a UTM's program is an enumerable sequence from a finite alphabet, the cardinality of the set of programs seems to be EXACTLY that of the reals (same construction as above). It's been a LONG, LONG time since I had to wrestle with such stuff, so please DO let me know what subtle clauses in the various relevant definitions I'm missing, if any... (Ah, to be 20 again...!-) Alex From noone at nowhere.net Sat Jun 30 19:40:04 2001 From: noone at nowhere.net (lynx) Date: Sat, 30 Jun 2001 19:40:04 -0400 Subject: Q: newbie wants to eval() References: Message-ID: <3b3e645e$0$88190$2c3e98f8@news.voyager.net> "Sean 'Shaleh' Perry" , in : [...] > exec(input) # eval takes an expression, assignment is not yes, so i found out. boy do i have egg on my face... i guess i'm still thinking too Perl-ish, i couldn't get it out of my head that "eval" is the way to execute arbitrary code. thanks to everybody for their help, i've got it pretty much working now. -- PGP/GnuPG key (ID 1024D/BFE0D6D0) available from keyservers everywhere Key fingerprint = 3EBC 97FC 68AA 65F1 65E6 3D36 35F6 4213 BFE0 D6D0 "...life goes on long after the thrill of living is gone..." From gregj at pobox.com Fri Jun 1 00:16:44 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Fri, 01 Jun 2001 04:16:44 GMT Subject: I had a thought ... (I know, call the newspapers). References: Message-ID: The general case of the "currency" or "money" type is called fixed point or fixed decimal. As opposed to floating point, fixed decimal numbers always have the same number of digits to the right of the decimal point. This means the decimal point can be implicit, and it also means that integer match can be used. If you count in pennies instead of fractional dollars you get the idea. A good fixed-point math package is more sophisticated than I'm describing (mainly to deal with computational precision beyond the fixed number of digits), but you get the idea. Fixed decimal is the norm in COBOL and Oracle and many other languages and tools. Fixed decimal math can be much faster than floating-point math, though the performance gap closed in the late '80s. I can't comment on Microsoft's claims regarding Visual Basic's currency type, but they certainly could have implemented fixed-point math without a floating-point processor. That was done back in the 1950s. Greg Jorgensen PDXperts LLC Portland, Oregon, USA gregj at pobox.com From ykingma at accessforall.nl Thu Jun 21 14:50:18 2001 From: ykingma at accessforall.nl (Ype Kingma) Date: Thu, 21 Jun 2001 19:50:18 +0100 Subject: beginner ques: dir( ) does'nt list my instance methods? References: Message-ID: <3B3241E8.EEE070A1@accessforall.nl> karthik_guru at rediffmail.com wrote: > > class test: > def __init__(self): > print 'hello test' > self.foo = 100 > self.bar = 900 > > def func(self): > print 'hello' > > if __name__ == '__main__': > t = test() > print dir(t) > print t.__dict__ > > Both dir(t) and t.__dict__ print only foo and bar. > They don't print the func which is also a instance attribute (method > reference)? > You are probably looking for: print dir(test) # the class has the methods or, equivalently: print dir(t.__class__) This shows the attributes of the instance t of class test: print dir(t) Regards, Ype -- email at xs4all.nl From geoff at homegain.com Mon Jun 4 16:31:08 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Mon, 4 Jun 2001 13:31:08 -0700 Subject: Why isn't Python king of the hill? Message-ID: <393D961EA4FCD311B03F00D0B746D65803275E61@HQSXCH01> A further episode in the discussion between Martijn and myself: > Or you can do evil and cool stuff with AccessRules (the whole > SiteRoot stuff). > [ ... quotes from me about controller-centered models ... ] > What exactly do you mean by embedding controller elements in the > view? I'm not entirely sure what you'd refer to as the > controller here. I'm not sure how to manipulate AccessRules; I think this might be one of the Zope features that we currently hafta do without. I think maybe I'm running along here under the assumption that everyone more or less understands Model/View/Controller, and understands it in the same way that I do. Let me try to define my terms. The "View" element of an application is exclusively responsible for presentation. Your forms and your reports, basically; in a web application, this is your HTML and the code that generates your HTML. The "Controller" element responds to user input and interfaces it with the business objects of the model. The controller is in some ways like glue code, but this is (or can be) where you might have form validation logic, or where you translate your form fields into the attributes of a data object. The controller element is typically the center of your application; it might be compared to the main() function in a C program. It presents various views when required, retrieves model objects, and glues them all together. The "Model" refers to your business objects and your business logic. The model should describe the data elements in your problem domain, and should include methods for manipulating them and performing calculations upon them. Again, this is my understanding of the MVC super-architecture; others may have a different take on pieces of it. I know a lot of people try very hard to push everything down to the model; I tend to want to keep the logic and data that describes the problem domain in the model, the stuff that describes the current application in the controller, and the stuff that implements the current deployment medium in the view. This promotes maximum reuse, and makes it easier to re-target your application. Going to client/server with an applet or even an application written in SWING isn't exactly trivial, but it's an exercise in rewriting the view and some of your controller, not a start-from-scratch. > Hm, yes, I think this makes sense (though it could lead to horrible > URLs). Of course you don't give the details here so I'm not > entirely sure I get the entire picture right. The URLs need not be any more "terrible" than in any other web application, including any Zope application. If your main servlet responds to all URLs that begin with '/myapp', any sub-path is something that the servlet can switch on. The difference here is that /myapp doesn't map to a folder object either on the filesystem or in some content repository. It's mapped in the application server to mean "invoke this servlet"; additional path information is passed on to the servlet. So if http://myhost/myapp points at my main controller servlet, then the "myapp" servlet needs to know what to do when you access the URL http://myhost/myapp/login. In some cases, it will directly invoke some action, which will in turn decide whether this is an initial request or a post of form-values, and then perform the appropriate processing. That processing may entail the include of or forward to a JSP page. In other cases, the main controller servlet may defer handling to another servlet. This is where your local architecture can grow baroque, especially if you don't make the decisions about how things will be done up front. Meanwhile, your controller has the request before anything else. That means the controller can take action based on form values or other request parameters. As far as I know, Zope provides a solution for the most common application of this (user authentication), but does not provide much in the way of a toolkit for other similar problems. An example might be a look-and-feel switch -- if you have a cobranded application, you might serve from a different batch of pages, or use decorations and stylesheets from a different directory hierarchy. You /can/ do these things in Zope, it just requires hacking around the way Zope is set up to serve pages, not invoke processing logic. > [Model/View/Controller as JSP/Servlets/Beans] I think Model/View/Controller as Beans/JSP/Servlets is more accurate, but yes. :) > [JSP pages get compiled, not interpreted] > > We're not going to accomplish this in Python, though of course > you could still write (possibly with C extensions) a fast > interpreter for web pages in Python. Anyway, we're generally > not using Python because insane speeds are the issue, so while > this isn't a major bottleneck for me I'm not going to bother > too much with this. Or you could take your Zope objects and turn them into actual python code objects that generate HTML and perform some actions when called. It's not going to suddenly challenge C for near-hardware speeds, but it's a significant step ahead of doing the lexical parsing at runtime -- at least the Python interpreter is written in C. I don't think it's a huge priority, but it's one of the things the Java stuff does to reduce runtime load, which in turn promotes better scaling and better overall peformance. > > Your JSP pages have access to at least four levels of state > > (there might be another I'm forgetting): application, session, > > request, and page. The first three correspond to the same state > > repositories managed by the servlet. The 'page' context is for > > local objects. > > Right, in Zope you'd have 'acquired things', session object (if you > have Core Session Tracking or something similar installed), REQUEST > object and folder context, for these. I'm just trying to translate > the concepts. Almost. I think the acquired things don't map onto application state quite like you suggest. There's one repository, shared by all the sessions running inside a single process. This isn't initialized with web-content properties. It's a place to stick objects at runtime. I don't know what the session object gets you, or how it gets it for you, but I assume that's correct. The REQUEST object does map to the request context. The page context maps more closely to the namespace of a DTML document. > > You can forward control to other servlets or JSP pages, and you > > can also include pages. > > What do you mean by 'forwarding control'? Control of what? > > [ snip my explanations ] > > Ah, I think I more or less understand. I'm not sure what the use of > forward is compared to include, though. Why'd you ever want to forward > control and never come back? Generate half a page with one JSP page, > and the other with another? and RESPONSE.redirect() provide more-or-less similar functionality in DTML, as compared with the use of to include a method. My typical page processing paradigm is to submit form data to the page that renders the form. If all the data are acceptable and no processing errors arise, I forward on to another page. If all the data are not acceptable, I redisplay the current page with error messages. Others do it other ways. > > You can associate a bean with an object, and map form properties > > onto the bean's attributes. I think that this is most useful when > > you're programming pure JSP, but it's pretty useful when you're > > not. > > Right, Zope's REQUEST object does this automatically (the > 'form' subobject). Except that your "form" subobject is one standard object, not an object customized for your particular form. The servlet API allows you to pick the attributes off the REQUEST object, too; it's just somewhat more convenient to load up a bean. > > I've discussed session management before. Sounds like they're > > doing some of that in newer Zope? That's good. It's a very hard > > thing to do well. I would be concerned about ZEO and ZODB being > > used in their unadulterated form to handle session management for > > a high traffic site. It just seems like there'd be too much I/O > > for ZODB/ZEO to handle it efficiently. > > They're working on various improvements to that too, of course. > ZODB without undo for sessions for instance. ZODB layered on > top of various stuff, like the berkely database. By default > Core Session Tracking just keeps the sessions in RAM and they > expire after a customizable time. > > > Servlet containers implement session management for you. The > > servlet containers are presently not obliged to make these > > sessions either persistent or distributable, but some of them do, > > including at least one of the freely-available containers. > > Persistent, distributable sessions provide good load balancing > > and good failover. > > Right, the intention in Zope is to do this with ZEO and Core Session > Tracking. The current solution is a reasonable solution, but it doesn't scale well. Your front-end load balancing hasta be session-aware, so it can redirect to the right instance of Zope. Using ZEO and Core Session Tracking could be The Right Thing. It certainly seems like the two technologies could be combined reasonably. Until it's arrived, though, you're still rolling your own sessions if you deploy on more than one box. > > Servlets get a request and a response object passed to them. > > Like Zope's DTML pages, and of course you can pass those along > to Python Scripts or other python code. Yes, but the servlets ARE Java code, which means that you don't NEED to stick a block of code at the top of every page, designed to invoke them. > Neat. With Zope exporting subfolders or simply copying > Data.fs is relatively > painless, but you need to copy over any external methods and special > Python products manually, which isn't hard but an extra step. Yeah, Zope isn't all that hard to roll out, as long as you do everything in Zope. You can still get sync problems with the external dependencies, though. If you use a lot of those (and I suspect that you will in a logic-intensive app), then you're likely going to hafta come up with some other deployment mechanism. > > Adding EJB entails a few sacrifices and a few big gains. Sticking > > your servlets into the J2EE "framework" means that you hafta put > > your "application" level state into an EJB or a database (or at > > least knowing that anything you stick into the application > > storage can't be counted on to persist any longer than the > > request). You really need to make anything you put into the > > session area serializable (though there are a couple exceptions > > to that rule). There are a couple other rules that go along with > > that, I can't put fingers on them off the top of my head. All the > > sacrifices are really pretty minimal. > > Okay, parts of this is a small problem with ZODB as well, of course. > I suspect ZODB makes this even easier, as it exploits Python's > flexibility. Well, except that we're not talking about just ZODB or ZEO here, we're talking about distributing dynamic (by which I mean run-time) state. That includes things like concurrent access issues and synchronization of access, RMI techniques, and whatever else it takes to implement these things. It's also not just Session stuff. If you could publish arbitrary objects to the ZEO store and retrieve them by key -- something I'm sure is possible, but not sure how difficult -- you'd be close. > Sort of like ZEO with Core Session Tracking. :) Of course this > is still being heavily developed, but it seems to be getting > near offering equivalent features. I can't speak to that, because I haven't used (and can't really, at the moment) Core Session Tracking, let alone using it with ZEO. > > > The J2EE stuff makes deployment still one more step simpler, too. > > It pushes parameters that might change during runtime out one > > notch further, so that deployment configuration can be separated > > from the details of servlet instantiation, URI mappings, and > > other miscellany concerning the interaction of the app and the > > app server. > > Hm, I'm not sure what this part means, exactly. I can't > translate it to any Zope terms, which is how I tend to think > about things, myself. I might argue that trying to put everything into Zope terms is part of what's limiting your comprehension. :) Zope is really a very different animal. Still, if you were to take your Zope application, and all its external methods, and all the little mini-servers that helped distribute your backend processing job, and stuck them all in a big tar file, then had one configuration file that detailled ALL the configuration details that would vary from machine to machine within an installation, and all the details that would vary from installation to installation -- if you assembled that tarball and that config file, you'd have the deployment mechanism used by the Enterprise stuff. > Yes, I'm not trotting them out so much to do 'see, we have that > too!', though there is a component in that, but to learn more > about both by comparing the two, and to see if there are > interesting directions which Zope is missing. I think Java's > system works better for model/view/controller type situations > right now; Zope's framework for that is currently still in > design phases. Java also has clear (standardized) interfaces > for it, something which Zope needs a lot more of. All of which I'll agree with. And I'm not trying to suggest that Zope is a poor product, either. I just don't feel like it's a good choice for a web-based application -- a website with some dynamic elements, maybe, and I could even see it being used for an online store. And I confess that the more we talk about these things, the more optomistic I am about the future. Java's solutions and toolkits are great (or at least pretty good), but I would like a good, solid alternative to all that wordy Java. > I don't know how to compare ZEO with the scalability features > you sketched out. I would guess it's a question of tradeoffs; > which is better probably depends on your requirements and > development style. I think ZEO is really cool. I like it a lot, but it seems like it only answers about half my concerns. That's also true about the enterprise java beans -- the Java Data Objects are really more interesting to me from the standpoint of my dynamic data model, but both ZEO and EJB do really well for providing keyed access to persistent objects. I think ZEO is a little more light-weight than EJB? I'm not sure how effectively you can "synchronize" the ZEO stuff against multiple threads / processes contending for the same data. > > Like I said once before, > > maybe we can beat Java to the punch here. > > Python certainly has a lot of flexibility to work in its favor here, > though I don't know if we have the development resources in the > Python/Zope world to go fast on this. These discussions often seem to > devolve into feature wishlists and pie-in-the-sky designing. That's maybe true, but like I said, I started work on it at one point, and probably put a few solid days of effort into it. What I've arrived at might be less than perfect -- in fact, it IS less than perfect -- but it was a running start at something that would marshal a database table into an object. Even at that level of utility, it's a very, very useful tool. > [ snip lots, including a description of EOF's qualifiers ] > Would this get translated into a query into a relational database? Yes. EOF provides a couple different ways to do things -- you can build up these qualifiers piecewise, or you can write out the query string. But then EOF goes and traces it through its internal mapping of entities to database elements, and produces a SQL query that retrieves the appropriate object. > > When you fetch these objects from the database, the EOF puts > > "Faults" in the place of relationships. When you first try to > > read from a fault object, it runs off and fetches the object from > > the database. > > A proxy pattern. Yes, and very effective in reducing the strain on the database while still preserving the whole notion of composed objects. There's also a means by which you can pre-fetch some of the relationships -- that way, if you're planning an operation that will iterate over all the eggs in a spam_and_eggs_breakfast, you don't need to go back to the database multiple times. > > But that's not all! EOF also provides sophisticated caching and > > data source controls. EOF also provides multiple 'editing > > contexts' with undo capabilities and the ability to nest editing > > contexts so that changes can be made within the context of other > > changes, and committed incrementally, or abandoned en masse. > > Does this use relational database transaction features? > (with subtransactions?) It doesn't require relational database transaction features, and I believe that it provides access to transactions at a more direct level. EOF's "editing contexts" are in-memory representations. Basically, every time you create an editing context, any object modified in that context is first copied from its parent context, then modified. If you abandon the changes, the context closes and you never write the changes back onto the parent context. Commit them, and all your changed objects are promoted back into the parent context. This is especially handy when you're building sequences of web pages several pages deep before the final commit. You can nest your editing contexts, and when the user hops back four pages, you can either make the hop with him and toss the deeper changes, or even just hop around with him and wait for him to commit the whole lot of them. > *part* of the good effects you attribute to standard APIs can > be dealt with by good API *documentation* instead. Another part > deals with user interface; I do think Zope's web UI helps > people who have little programming experience tremendously; > I've seen this happen several time. A hot topic in the Zope > world has to do with explicit interfaces, and clear > documentation for them. This inspired PEP 245, currently under > consideration for 2.2. While I don't agree with some of the > details of that PEP, I do think the ability to have a form of > explicit interfaces (run time checked if checked for at all! > ability to lie about implementing an interface! this is Python :) > is very important to the future health of Zope and similar large > Python systems. I think I agree with you here. I've worked around the interface issue in the past (subclass empty classes, then test to see if my instance is a subclass of a particular empty class), but it seems like being able to unambiguously promise to implement a certain interface is much /clearer/. I think Zope's web UI is a mixed blessing. It cuts down on the learning curve to get in and start making changes, but in the end, it becomes an impediment to being able to work smoothly -- a simple CVS archive of the DTML would be more practical later in the game. And yeah, documentation could correct a lot, especially if the documentation addressed best practices and common problems experienced when developing larger and more complicated sites. But I can't comment extensively on Zope -- like I said, I'm stuck on an old version. That means all the docs that I've read point people at ways of doing things that don't work for me, and even most of the advice on the mailing list refers to features I can't access. Many of my issues with Zope may be that Zope as I know it isn't nearly as sophisticated as Zope as it could be. :) Always a pleasure, --G. From xyzmats at laplaza.org Thu Jun 21 10:45:07 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Thu, 21 Jun 2001 14:45:07 GMT Subject: Interfacing GUI applications..? References: <3B18032E.21AF631E@pfortin.com> <16074dce.0106200912.7b9bc793@posting.google.com> Message-ID: <3b3204c6.2422543@news.laplaza.org> On 20 Jun 2001 10:12:18 -0700, jeff at ccvcorp.com (Jeff Shannon) wrote: : :> Incidentally, ReportLab might interest you. 'Any- :> one out there have any user reports on ReportLab? :> I've cobbled together some of my own PDF manipula- :> tions, but I'll happily discard all of them for a :> well-done package. : :I'd be interested in hearing reviews/testimonials on ReportLab as well. :Somewhere down near the bottom of my list of projects, I'm looking to :create PDF docs automatically. At first glance, ReportLab looks ideal, :but reports of firsthand experiences are always good.... I've had limited experience with what's currently classified as a "demo" application of ReportLab, PythonPoint. It produces PDF from a presentation language (which is just XML), and seems to do so correctly. So far I'm happy with the quality... [[there was a problem that cropped up with ReportLab 1.07 caused by Python 2.1's changing to outputting literals in hex instead of octal, but there's a patch for that or it may be fxed in the 1.08 release that was just announced]] So... thumbs up from me. Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From scarblac at pino.selwerd.nl Wed Jun 20 03:04:25 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 20 Jun 2001 07:04:25 GMT Subject: How can I format the string according to its length at runtime? References: Message-ID: ed_tsang at yahoo.com wrote in comp.lang.python: > I am trying to supply the precision formating at run time: > > s = 123 > print '(0x%-6X -)'%s > > where I try to dynamically supply the number 6 from (6- length of s), > I can't find a way to dynamically supply that. > > Anyone hav any idea? s = 123 spacing = 6 print '(0x%*X -)' % (spacing, s) Ie, use '*'. -- Remco Gerlich From thinkit8 at lycos.com Tue Jun 12 19:29:31 2001 From: thinkit8 at lycos.com (thinkit) Date: 12 Jun 2001 16:29:31 -0700 Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> Message-ID: <9g68kr0bog@drn.newsguy.com> In article , sill at optonline.net says... > >On 12 Jun 2001 08:39:37 -0700, thinkit wrote: >> humans should use a power of 2 as a base. this is more logical because it >>synchs with binary, which is at the very heart of logic--true and false. it is >> more natural perhaps, to use decimal--but logic should, and will, win out. >> > >It's actually illogical to use binary for everything - it's simply too hard to >write a large number in it. Try writing 1,388,034,093 in binary on a piece of >paper >then come back :-). > > >-- >Jupiter and Saturn Oberon Miranda >And Titania Neptune Titan >Stars can frighten > - Syd i said powers of two, not two. this would probably be octal or hexadecimal...i like hexadecimal a lot more. From mwh at python.net Fri Jun 1 08:50:14 2001 From: mwh at python.net (Michael Hudson) Date: 01 Jun 2001 13:50:14 +0100 Subject: Why can't slice use non-int. indices? References: <3B168CF7.F44777F9@yahoo.com> <20010531.201603.771151432.2277@bur-jud-175-024.rh.uchicago.edu> Message-ID: "Ben Wolfson" writes: > In article <3B168CF7.F44777F9 at yahoo.com>, "Paul Winkler" > wrote: > > > This is on python 2.1. > > > >>>> a = [] > >>>> a[3:4] > > [] > >>>> a[3.2: 4] > > Traceback (most recent call last): > > File "", line 1, in ? > > TypeError: slice indices must be integers > > For that matter, why doesn't this work? Because the sq_item & sq_slice methods in the PySequenceMethod struct in object.h is declared as taking ints rather than PyObject*s. This is probably wrong, but it's hard to see how to fix it without breaking backwards compatibility. Cheers, M. -- GAG: I think this is perfectly normal behaviour for a Vogon. ... VOGON: That is exactly what you always say. GAG: Well, I think that is probably perfectly normal behaviour for a psychiatrist. -- The Hitch-Hikers Guide to the Galaxy, Episode 9 From phd at phd.fep.ru Fri Jun 8 15:45:16 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Fri, 8 Jun 2001 23:45:16 +0400 (MSD) Subject: Newby question - Trimming spaces from a string In-Reply-To: Message-ID: On Fri, 8 Jun 2001, Glen Mettler wrote: > I found it! It is String.Strip() No, it is not. It is string.strip() - Python is case sensitive langauage! Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From geoff at homegain.com Tue Jun 26 16:10:14 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Tue, 26 Jun 2001 13:10:14 -0700 Subject: Windows Printing using win32print Message-ID: <393D961EA4FCD311B03F00D0B746D65803275EE4@HQSXCH01> It's funny, I was asking a question about printing thru a different mechanism prior to this discussion coming up. I'm using the Windows GDI calls to paint text on printer device context. I've been writing code to dump a simple text file to the printer. I think that I've seen a half-dozen people talking about ways to do it, but none of them are very simple or straightforward. The solution I arrived at is below -- it's pretty easy to change the file.readlines() call to a string.split() call and make this print multiline strings for you. It's not elegant code, or even something I particularly want my name associated with just yet, but it does do the trick. The big "issue" right now is that it seems to underrun its pages somewhat, and nobody seems able to tell me how to retrieve the page dimensions from the device context. Anyone who can help with /that/, I'd appreciate greatly. :) (code follows .sig) Thanks, --G. --- Geoff Gerrietts Software Engineer, HomeGain.com 510-655-0800 x4320 import win32ui, win32con import math, string, sys # 20 TWIPS per point # 72 points per inch # 1440 TWIPS per inch INCH = 1440 MAXW = int(INCH * 8.5) BUFW = INCH / 4 MAXH = int(INCH * 11) BUFH = INCH / 4 fonts = {} metrics = {} files = [] def createFonts(): global fonts normal = { 'name': 'Courier New', 'size': 12, 'weight': 400 } bold = { 'name': 'Courier New', 'size': 12, 'weight': 700 } italic = { 'name': 'Courier New', 'size': 12, 'weight': 400, 'italic': 1 } for i in ['normal', 'bold', 'italic']: d = locals().get(i) f = win32ui.CreateFont(d) fonts[i] = f def prepareDevice(): global metrics fonts['orig'] = dc.SelectObject(fonts['normal']) m = dc.GetTextMetrics() metrics['width'] = w = m['tmMaxCharWidth'] metrics['height'] = h = m['tmHeight'] lines = int((MAXH - (2 * BUFH))/ (h * 1.5)) lines = lines - 4 cols = (MAXW - (2 * BUFW)) / w metrics['lines'] = lines metrics['cols'] = cols def processFile(file): global pages, metrics col = metrics['cols'] lin = metrics['lines'] # in a real app we wouldn't use bigtext # we'd use readlines here lines = file.readlines() formlines = [] # here we break our input into page-oriented lines. # if we were going to do line numbering and such, this would be the # place to do it. for line in lines: line = line[:-1] # snip the end of line while len(line) > col: try: idx = string.rindex(line," ",0,col-1) except ValueError: idx = col-1 formlines.append(line[:idx]) line = line[idx:] # repeat shortening line until it fits on one line formlines.append(line) # do this for all lines in the input # clean up our memory del lines # now paginate totlines = len(formlines) pagecount = int(math.ceil(totlines/float(lin))) pages = [] for i in range(0,pagecount*lin,lin): page = formlines[i:i+lin] pages.append(page) # subtract 'height' increments, and textout at BUFW. def setup(): global dc, fn, oldfn dc = win32ui.CreateDC() dc.CreatePrinterDC() dc.SetMapMode(win32con.MM_TWIPS) createFonts() prepareDevice() def printPage(page, header): dc.StartPage() # would do the page header & footer here ordinarily... h = metrics['height'] hpos = int((BUFH + (h * 1.5)) * -1) f = dc.SelectObject(fonts['bold']) dc.TextOut(BUFW, hpos, header) dc.SelectObject(f) # body starts 2 lines + bufh + h down the page pos = ((h * 3) + BUFH + h) * -1 for line in page: # print in bufw chars dc.TextOut(BUFW, pos, line) pos = pos - int(h * 1.5) dc.EndPage() def printDocument(name): global pages dc.StartDoc(name) # calculate the length (in chars) of the page info s = "%d" % len(pages) plen = (2 * len(s)) + 4 # make a dict: space reserved for name, and for page info d = {'name': metrics['cols'] - plen, 'page': plen } # create a header template based on that hdrtmpl = "%%-%(name)d.%(name)ds %%%(page)d.%(page)ds" % d pp = "%d of " + str(len(pages)) for pageno in range(len(pages)): page = pages[pageno] p = pp % (pageno + 1) hdr = hdrtmpl % (name, p) printPage(page, hdr) dc.EndDoc() def openFiles(): global files flist = sys.argv[1:] for file in flist: try: f = open(file) files.append(f) except: print "Could not open %s" % f # setup opens the dc, creates the fonts, calculates the metrics # processFile reads file, handles linebreaks, and paginates # printDocument prints a parsed document setup() openFiles() for file in files: processFile(file) printDocument(file.name) From mertz at gnosis.cx Sat Jun 2 16:10:53 2001 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Sat, 02 Jun 2001 16:10:53 -0400 Subject: random Message-ID: "Alex Martelli" writes: > Moreover, we can now > derive an infinite number of new theorems of Peano+_I_ that utilize _I_ > in their derivation and that are independent of Peano arithmetic. |Oh, I didn't know the 'new' theorems will always be infinitely many -- |interesting indeed (is it anything deep or just a trivial by-product of |considering "_I_ AND (old theorem)" &c as a new theorem and there |being infinitely many old theorems in arithmetic?). But definitely My observation is of the trivial sort you observe. Probably a lot of those theorems will have forms other than "_I_ AND (old theorem)"... it depends on how "good" of an axiom _I_ is in terms of plugging into proofs. But being infinite isn't particularly profound. Then again, it is quite difficult to distinguish, in a general way, interesting from uninteresting theorems. Maybe I went too far with the modelling thing. Inasmuch as any system we might create would be written in an finite alphabet, and each statement would be of finite length, it is trivial to map every statement to a unique number (it's a little harder to make sure it's onto, not just into). And every theorem of the system can thereby be treated as a fact about numbers. If that's all you want with a model... arithmetic is plenty. Actually, Lowenheim-Skolem even buys you a bit more than this (not that much more, but it sure is a neat fact that every every system with a model has a countable model... in the integers, if you like) |The assertion NOT( IMPLIES ) |can never hold, if is an impossibility, because |in that case ( IMPLIES X) is true for any X, |so its negation is false. NOT(X IMPLIES Y) *does* imply X is possible. I don't read the conditional that way. Doing a quick web search, I find this URL discussing different types of conditionals: http://www.icsi.berkeley.edu/~kay/bcg/lec07.html The basic point is that conditionals in English (or other natural languages) are not always material conditionals... I suppose not even usually. The sense of the limitation imposed by the randomness in quantum states is much more like a epistemic conditional than a material one. However one reads it, many counterfactuals should meaningfully be considered true... even ones where the antecedents are "impossible" in various ways (there are lots of ways to be impossible too). So my example: NOT ( IMPLIES ) is perfectly fine. A normal speaker considers this statement TRUE (one she knows that my car weighs more than 1000lbs). The fact: NOT holds too. I suppose that number is just on the border of possiblility. But 2000 lbs is more than any weigh-lifter does, but still less than my car weighs, so work from there. So is in a very real sense *impossible*. But if you are not happy with mere physical/empirical impossibility, it works equally well for mathematical impossibles: <2+2=5> IMPLIES <2+3=6> works fine by application of Peano arithmetic. Using the successor operator ' and some permitted reasoning: Premise: 2+2 = 5 (1): 2+2'= 5' # successor of equals maintains equality (2): 2+3 = 6 # rewriting terms in conventional manner The reasoning is valid, so the conditional holds. The antecedent is in extremely bad shape--mathematically impossible--on its own. But so what? Yours, Lulu... From root at rainerdeyke.com Fri Jun 15 11:38:12 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 15 Jun 2001 15:38:12 GMT Subject: profile.run won't run! References: <24gW6.284794$oc7.18522490@news2.rdc2.tx.home.com> Message-ID: "Nick Perkins" wrote in message news:Y_gW6.238366$eK2.50840616 at news4.rdc1.on.home.com... > > "Rainer Deyke" wrote in message > news:24gW6.284794$oc7.18522490 at news2.rdc2.tx.home.com... > > ... > > import __main__ > > __main__.solve_problem = solve_problem > > profile.run('solve_problem') My mistake; this should be: profile.run('solve_problem()') Somehow I forgot the parentheses. > print 'profiled:' > profile.run('solve_problem') Same problem here. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From mlh at idi.ntnu.no Thu Jun 21 22:48:49 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Fri, 22 Jun 2001 04:48:49 +0200 Subject: Odd behaviour from re Message-ID: <9gubmh$6cd$1@tyfon.itea.ntnu.no> I'm looping through a string with match - thinking that if I specify a starting position beyond the end of the string, no match would be returned... But the darn thing still matches, and gives me both a start and an end at position len(string)... Is this intentional? To me it seems rather counterintuitive... Of course, when I ask it to match where there is no string, it may be reasonable to return a position in the same non-string area, but that's not how it is with the string-method find... I know matching and searching are different things etc. but I still think this is a bit... Odd. Oh, well... -- Magnus Lie Hetland http://www.hetland.org "Reality is that which, when you stop believing in it, doesn't go away." -- Philip K. Dick From ullrich at math.okstate.edu Mon Jun 25 10:04:13 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 25 Jun 2001 14:04:13 GMT Subject: Is this a true statement? References: <3b34939b.410758@nntp.sprynet.com> <3b35ebc3.1024709@nntp.sprynet.com> <9h516e$c2a4d$1@ID-11957.news.dfncis.de> <3b3611b0.10735139@nntp.sprynet.com> <9h5926$c7bg6$1@ID-11957.news.dfncis.de> Message-ID: <3b3743a2.1678895@nntp.sprynet.com> On Sun, 24 Jun 2001 10:42:39 -0700, "Emile van Sebille" wrote: > >"David C. Ullrich" wrote in message >news:3b3611b0.10735139 at nntp.sprynet.com... >> On Sun, 24 Jun 2001 08:28:25 -0700, "Emile van Sebille" >> wrote: >> >[...]The difference is the distinction of using >python to create a device driver vs a python program that _is_ a device >driver. Precisely. I finally realized this last night, as I explain at greater length elsewhere. Believe it or not, the reason that this did not occur to me is that I did not realize that when we said "write a device driver in C" we actually meant "write a program that _is_ a device driver", I assumed we meant "write a program that writes a device driver". Simple ignorance. David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From montagne at boora.com Tue Jun 26 13:38:22 2001 From: montagne at boora.com (michael montagne) Date: Tue, 26 Jun 2001 17:38:22 GMT Subject: MSAccess databse from Linux box References: Message-ID: I must keep the Access databases because they are used by many other windows programs. -mjm "Michal Wallace" wrote in message news:mailman.993572740.21841.python-list at python.org... > On Tue, 26 Jun 2001, michael montagne wrote: > > > In my effort to rebuild our intranet on a Linux box with Python I > > need to retrieve information from several MSAccess databases. Is > > there a way to do that with Python? Or Zope? > > Your best bet is probably to migrate the MSAccess data to something > like MySQL. I believe there are tools that automate this process. (As > a bonus, you can keep the MSAccess frontend and just talk to MySQL via > MyODBC) > > Cheers, > > - Michal > ------------------------------------------------------------------------ > www.manifestation.com www.sabren.net www.linkwatcher.com www.zike.net > ------------------------------------------------------------------------ > > From bj.pitre at pnl.gov Thu Jun 14 22:55:02 2001 From: bj.pitre at pnl.gov (Pitre, Bill J) Date: Thu, 14 Jun 2001 19:55:02 -0700 Subject: Help for Python newbie References: <9g4nkp0d0u@enews2.newsguy.com> Message-ID: <34CF5F553A87D41198D200508B959770026A3FD9@pnlmse0.pnl.gov> To preserve "mylist" as is, but print out it values, you could do this: >>> import string >>> mylist = ['1', '2', '3'] >>> print '\t'.join(mylist) 1 2 3 >>> print mylist ['1', '2', '3'] >>> -----Original Message----- From: Alex Martelli [mailto:aleaxit at yahoo.com] Posted At: Tuesday, June 12, 2001 2:33 AM Posted To: python Conversation: Help for Python newbie Subject: Re: Help for Python newbie "Bob Hibberdine" wrote in message news:zSkV6.18764$m4.73107 at news6-win.server.ntlworld.com... ... > >>> import string > >>> mylist = ['1','2','3'] > >>> mystring = '' > >>> mystring = mystring.join(mylist) > >>> print mystring > 123 > > note there is no space between the items. Right: the separator is mystring, and mystring is empty, so the separator is empty. To use tab as the separator: >>> mystring = '\t' >>> mystring = mystring.join(mylist) >>> print mystring 1 2 3 or, more simply, just: >>> mystring = '\t'.join(mylist) Alex -------------- next part -------------- An HTML attachment was scrubbed... URL: From sill at optonline.net Tue Jun 12 23:45:40 2001 From: sill at optonline.net (Rainy) Date: Wed, 13 Jun 2001 03:45:40 GMT Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> <9g68kr0bog@drn.newsguy.com> Message-ID: On 12 Jun 2001 16:29:31 -0700, thinkit wrote: > In article , sill at optonline.net says... >> >>On 12 Jun 2001 08:39:37 -0700, thinkit wrote: >>> humans should use a power of 2 as a base. this is more logical because it >>>synchs with binary, which is at the very heart of logic--true and false. it is >>> more natural perhaps, to use decimal--but logic should, and will, win out. >>> >> >>It's actually illogical to use binary for everything - it's simply too hard to >>write a large number in it. Try writing 1,388,034,093 in binary on a piece of >>paper >>then come back :-). >> >> >>-- >>Jupiter and Saturn Oberon Miranda >>And Titania Neptune Titan >>Stars can frighten >> - Syd > > > i said powers of two, not two. this would probably be octal or hexadecimal...i > like hexadecimal a lot more. > Oh, sorry. I misread. Now it makes *very slightly* more sense :-) -- I'll give you anything, everything if you want things - Syd From cliechti at nospam.mails.ch Fri Jun 29 20:00:01 2001 From: cliechti at nospam.mails.ch (chris liechti) Date: 30 Jun 2001 02:00:01 +0200 Subject: ANN: Win32 Screensaver that uses Python (extending/embedding Python/C) Message-ID: i have done a screensaver for windows that executes a python script which then draws on the screen. Its easy to write your own screensavers (in python) and you don't even have to touch the windows SDK or a C compiler... The drawing functions are limited, but should suffice for some nice screensavers. i've done it to gain some experiences with python and C extending and embedding - not to create an useful application but its fun playing around with it. the sources show how python can be embedded. an extension is used to talk back from python to C - to call the native windows drawing functions. you can download the executable with sources from: http://www.geocities.com/chrisliechti/en/python/index.html chris -- import re email = 'cliechti at nospam.mails.ch' print re.sub('nospam\.','',email) From gerhard.nospam at bigfoot.de Wed Jun 20 06:20:09 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Wed, 20 Jun 2001 12:20:09 +0200 Subject: sendmail References: Message-ID: On Mon, 18 Jun 2001 13:37:39 -0500, Nik Goodey wrote: >I am trying to get a form on my page email me some info. I can;t figure >out how to get sendmail to get the form info and email it. You get the form info with the cgi module. I use the smtplib module for sending mail instead of sendmail. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://highqualdev.com public key at homepage public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From dsh8290 at rit.edu Sat Jun 16 17:33:32 2001 From: dsh8290 at rit.edu (D-Man) Date: Sat, 16 Jun 2001 17:33:32 -0400 Subject: qt or gtk? In-Reply-To: ; from sill@optonline.net on Sat, Jun 16, 2001 at 05:52:12AM +0000 References: Message-ID: <20010616173332.B3479@harmony.cs.rit.edu> On Sat, Jun 16, 2001 at 05:52:12AM +0000, Rainy wrote: | | I want to learn python gui programming in linux. I think tk looks too ugly, so | I narrowed down the choice to two main contenders, qt and gtk. Which of these | has more complete and up-to-date python bindings? Are there other reasons | to prefer one of these over another for python gui work? Personally I like GTK better. I don't like the way Qt tries to look like MS Windows. Glade+libglade make a great combination for rapid coding. Use glade (a gui) to build the static parts of the interface, then load them at runtime with libglade. You simply write the event handlers and connect them to the events in your code. You can completely change the look of the UI without changing any code as long as the names of widgets and their type match (ie you don't change from a tree to a list). wxWindows and wxPython look nice, though I haven't worked with them enough to know if I like the style of the interface. -D From sdm7g at Virginia.EDU Sun Jun 24 15:45:37 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Sun, 24 Jun 2001 15:45:37 -0400 (EDT) Subject: Is this a true statement? In-Reply-To: <3B362FA3.F3A01482@tundraware.com> Message-ID: On 24 Jun 2001, Tim Daneliuk wrote: > "Steven D. Majewski" wrote: > > > > Wrong, David. > > Turing completeness means that anything you can *COMPUTE* in one > > language you can computer in another. Python, Lisp, C++, etc. > > are all equivalent in that sense. > > > > But you can't *DO* all of the same things in all languages -- for > > example: you can write a device driver in a language if you can't > > specify interrupt vectors or hardware address pointers. > > > > Not so, Steve. If something is Turing-Complete you CAN do everything ^^^^^^^^^^^^^^^^^ > in that language - it just may be ugly. All Turing-Complete languages > (like C, BASIC, Assembler, C++, Python...) can compute *exactly* everything > which is computable and therefore exactly what each of the other T-C > languages can compute. They will do so with different degrees of effectiveness > (which corresponds to their suitability for the problem at hand) and efficiency > (which corresponds to Turing machines of different computational complexity) but > they are all *equivalent* in functionality. Be careful, Tim! David was very precise in his wording and we were talking about a specific example with no precise requirements. ( Somebody one said that vague requirements are easy to fill -- for a *perfectly* vague specification, any program will suffice! ) [ See my other posts for my concession. ] I don't retract the statement that the fact that you can compute any computable function in any Turing complete does not mean that you can *DO* the same thing in any language. The one is a theoretical statement that has a formal proof. The other is a practical statement that requires a empirical proof. ( "DO" means to perform. ) If you disagree, I'll be happy to provide a challenge task for you to perform that will leave you mired in the "Turing Tar-pit" ! -- Steve Majewski From sill at optonline.net Tue Jun 12 19:44:12 2001 From: sill at optonline.net (Rainy) Date: Tue, 12 Jun 2001 23:44:12 GMT Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> Message-ID: On Wed, 13 Jun 2001 00:00:07 +0100, Jan Dries wrote: > Rainy wrote: >> Try writing 1,388,034,093 in binary on a piece of paper >> then come back :-). > > 101,0010,1011,1011,1011,1000,0010,1101-ly y'rs -- Jan > That's much more unweildy, isn't it? -- I'll give you anything, everything if you want things - Syd From tim.one at home.com Sun Jun 24 22:23:45 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 24 Jun 2001 22:23:45 -0400 Subject: PEP 255: Simple Generators, Revised Posting In-Reply-To: Message-ID: [Bernhard Herzog] > I wasn't aware of that! For that matter, I wasn't even aware that the > compiler removed "if 0" blocks. When was that introduced. It even > "works" with 1.5.2. It was introduced along with "assert": under the covers, assert gets changed into if __debug__: do the assert code __debug__ is a compile-time constant, and it was thought important that asserts leave no trace (not even bytecode) under -O. The mechanism for getting rid of if __debug__: at compile-time just happens to recognize literal numeric zeroes and empty strings as meaning "false" too. > ... > you need to introduce a yield statement and make sure that it's never > executed. The following works: > > >>> def g(): > .. if (): > .. yield 0 > .. > >>> for i in g(): > .. print i > .. > >>> > > The compiler apparently isn't smart enough to think of () as a constant > (the bytecode confirms that). Right, it only knows about numbers, strings and the specific name "__debug__". > Being able to easily write a function that does nothing (in fact it's > the most trivial function one can write) is very useful in practice, so > as a generalization being able to write empty generators might be > useful, too. I'm not sure about that, though, because I don't have > enough experience with them. Can't say I see much use for it. If I did, I'd probably write what everybody hates: def emptyg(): return yield None # never reached Stick that in a utility module and you'll never have to think about it again. haven't-needed-an-always-empty-generator-yet-ly y'rs - tim From lenny.self at qsent.com Mon Jun 18 18:55:53 2001 From: lenny.self at qsent.com (Lenny) Date: 18 Jun 2001 15:55:53 -0700 Subject: Sorting Apache Log Files Message-ID: Hey, all. I have a problem I was hoping someone might be able to help me with. I have to different apache log files for the same same site and month that need to be merged. Unfortuanlty, my web log reporting software requires that the log entires be in order, if not it freaks out and discards some of the enties. So, I'm thinking I'll just write a little python scritpt to go though the logs and sorth them before writing them out to a new file. Well, I must say for the the idea of what to do is coming easier than actually doing it. I was planning on loading each of the log files into a list and then sorting the list. Unfortualy, I am unaware of how to do that when the value I wish to search on isn't at the beginning of the line. I need to search on Apache's date string. Can anyone help me out? Thanks. From ullrich at math.okstate.edu Wed Jun 13 11:29:03 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Wed, 13 Jun 2001 15:29:03 GMT Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: Message-ID: <3b278675.9042942@nntp.sprynet.com> On Wed, 13 Jun 2001 15:22:11 +0100, Simon Brunning wrote: >> From: ullrich at math.okstate.edu [SMTP:ullrich at math.okstate.edu] >> [...] >> >> So just out of curiosity: Roughly what do you >> mean by "orthogonality" above? > >See >>. More or less what I thought, seems like the obvious meaning. Thanks. David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From getinfo at cmmail.com Tue Jun 5 05:56:29 2001 From: getinfo at cmmail.com (lawman) Date: 5 Jun 2001 02:56:29 -0700 Subject: looking for the best jython IDE Message-ID: <385e0bf0.0106050156.4e11e170@posting.google.com> i want to use jython to build prototype for java application. I heard about wxpython but don't know much about it. can i use it to finish my job? or i still need a good jython IDE? many thanks From aleaxit at yahoo.com Fri Jun 15 03:48:55 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 15 Jun 2001 09:48:55 +0200 Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> Message-ID: <9gceld02n4c@enews1.newsguy.com> "Rainer Deyke" wrote in message news:JjgW6.284889$oc7.18565826 at news2.rdc2.tx.home.com... ... > The following two statements are basically identical: > > def f(x): return x > f = lambda x: x They're close, with one obvious difference: D:\py21>python Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. Alternative ReadLine 1.4 -- Copyright 2001, Chris Gonnerman >>> def f(x): return x ... >>> f.__name__ 'f' >>> f = lambda x: x >>> f.__name__ '' >>> > I consider this a wart in the language. Binding a function to a name is > logically and physically the same operation as binding any other value to a > name; it should therefore use the same syntax. You consider it a wart that more than one statement can bind variables? It's not just assignment and def -- class, import and from behave the same way. Notice one pattern: all kinds of non-assignment binding-statements deal with objects whose *NAMES* are significant *BOTH* in deciding the variable-name to bind *AND* to locating or initializing the object that is being bound. The f.__name__ issue above is not a "it just so happens". It's similar to, say: import mynicemodule vs mynicemodule = __import__('mynicemodule') Thanks to import, def, and class, I do not need to type a LOT of names twice, in the _extremely_ common case in which I do want the variablename being bound to be the same as the name of the object that is being bound (which is normally also the object that is contextually being *created*, although the semantics of sys.modules make creation a once-only occurrence for module-objects specifically). If _only_ assignment could ever possibly bind a variable, we would need *expressions* (similar to today's __import__, but syntactically much more complicated, since needing to hold arbitrary amounts of code) that would also require us to type each name twice -- or they would have to use black magic to learn the name they're being bound to. Moreover, we'd then have to deal with that precious built-in function, setattr. Binding a value to a named attribute is logically and physically the same operation as binding that value to that same named attribute (since it's EXACTLY the same operation...); by your logic, "it should therefore use the same syntax". So how comes: fee.fie = foo.fum and setattr(fee, 'fie', foo.fum) and fee.fie = getattr(foo, 'fum') and setattr(fee, 'fie', getattr(foo, 'fum')) use four widely divergent syntax forms for the same op?-) (operator.setitem has obvious similarities, too). The answer, from my POV, is that names are reasonably-serious matters. In the case of attribute-reference-syntax versus setattr/getattr, the reason for the difference is that the attribute reference is the obviously right way to do it for an attribute name that is an overt constant, the built-in function is just as obviously right when the attribute name is anything *BUT* an overt constant (in identifier-syntax). In the case of import, the specific advantage of the statement is avoiding having to type the same name twice in 99.44% of cases. In the case of def and class, I have that same advantage, plus, no need for any syntax which lets an expression contain and coordinate statements. Practicality beats purity, and this set of language design choices strikes me as something that Python got just right. A pretty deep, widespread, and precious "something", too. Alex From rnd at onego.ru Tue Jun 26 00:58:10 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 26 Jun 2001 08:58:10 +0400 (MSD) Subject: Defining accessor methods In-Reply-To: <3B37FED8.2DBA3AC2@cosc.canterbury.ac.nz> Message-ID: On Tue, 26 Jun 2001, Greg Ewing wrote: >Since getting attributes tends to be more common than >setting them, this isn't unbearably verbose, and I find >that having 'set' in the setting method's name helps to >make the code read more explicitly. > >> I've not noticed any use of accessor methods in sample Python code >> (i.e. in books/tutorials); do people use them much in Python? > >I make extensive use of them in the API of my Python GUI >project (http://www.cosc.canterbury.ac.nz/~greg/python_gui/). >I want the API to be as future-proof as possible, so all >publically-visible attributes of my GUI objects are accessed >through methods. I use the convention I recommended above, >plus a couple of others. One is that the constructors of >my objects allow initial values to be given for all its >attributes using keyword arguments, so that e.g. > > b = Button(width = 42, height = 17, text = "Boo!") > >is equivalent to > > b = Button() > b.set_width(42) > b.set_height(17) > b.set_text("Boo!") Greg, I am not convinced that set_* methods are good. In Python standard library (/usr/lib/python2.1/*.py part of it): set_* is used 54 times in 18 files. WHile there are ~ 343 classes in 101 file. set_* deviates slightly from being Python idiom. In Python [=] ... b.width # is get b.width = # is set del b.width # is del Of course, there is no need to define self.width by hand, __setattr__ could catch _both_ forms and do set_attr as well as attr. >My objects also have a set() method which takes keyword >arguments in the same way, so if you want to change a >bunch of attributes you can set them all in one go with >a statement like > > b.set(width = 200, text = "Start Spanish Inquisition") This is better. Then no individual set_ are needed, because they aren't syntactically scalable, while set() is: b.set( width = 200, text = "Start Spanish Inquisition", ) could be later extended by adding only essentials: b.set( width = 200, height = 40, text = "Start Spanish Inquisition", ) (please not ',' after each parameter) >These two things help to cut down a lot on the verbosity >of using set_xxx methods. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, June 26, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "It is better to be brief than boring." _/ From phd at phd.fep.ru Fri Jun 29 08:58:24 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Fri, 29 Jun 2001 16:58:24 +0400 (MSD) Subject: Setitimer In-Reply-To: <9hhr0k$e0k9m$1@ID-91520.news.dfncis.de> Message-ID: On Fri, 29 Jun 2001, Drop Anchor!! wrote: > How do i use calls like setitimer in Python? i.e how would i set a timer > without using alarm which works only for seconds, say i want for > milliseconds? For millisecond resolution you can use select. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From aahz at panix.com Fri Jun 1 09:20:59 2001 From: aahz at panix.com (Aahz Maruch) Date: 1 Jun 2001 06:20:59 -0700 Subject: Why isn't Python king of the hill? References: <9f7ai7$b4e$1@newshost.accu.uu.nl> Message-ID: <9f84rr$95m$1@panix2.panix.com> In article <9f7ai7$b4e$1 at newshost.accu.uu.nl>, Martijn Faassen wrote: > >I believe there's a PEP about introducing decimal math into the Python >core as the default behavior eventually; there's a thread elsewhere on >the newsgroup. Not quite. There's currently a PEP for making the default *rational* arithmetic; I'm currently working on a module based on the ANSI standard for decimal floating-point arithmetic. There's already Tim Peters's FixedPoint for fixed-point decimal arithmetic. I'm staying out of the politics on this one and leaving it to the experts; I don't even really know enough to implement decimal arithmetic, but I'm doing it anyway. ;-) -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Characters exist to suffer, you know. An author needs a little sadism in her makeup." --Brenda Clough From greg at cosc.canterbury.ac.nz Thu Jun 21 02:24:30 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 21 Jun 2001 18:24:30 +1200 Subject: My PyGUI (Re: ANN: PythonCard mailing list) References: Message-ID: <3B31931E.D2F54D78@cosc.canterbury.ac.nz> You might be interested in looking at a project I started on a while ago to create an almost-pure-python GUI library: http://www.cosc.canterbury.ac.nz/~greg/python_gui/ I haven't worked on it for a while, but there's actually a more recent version of the implementation available than the one for downloading from that page. If anyone is interested I can update the download links. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From Bill.Scherer at VerizonWireless.com Tue Jun 19 14:04:32 2001 From: Bill.Scherer at VerizonWireless.com (Scherer, Bill) Date: Tue, 19 Jun 2001 14:04:32 -0400 (EDT) Subject: disable line wrap in xterm?? In-Reply-To: Message-ID: On 19 Jun 2001, Michael Hudson wrote: > "Scherer, Bill" writes: > > > Can anyone tell me how I can disable line wrap in an xterm (or > > equiv, eg: rxvt, Eterm, etc) from Python? > > To turn auto-wrap off: > > print "\033[?7l" > > to turn it on: > > print "\033[?7h" That does it. Thanks! > > Do you have the ctlseqs.TXT document? It's handy for this sort of > thing. Never heard of it. > > These are probably grossly xterm specific - AFAIK there's no > corresponding terminfo/termcap code (but my termcap & terminfo book > seems to have vanished into the depths of my room, so I'm not sure). > > Cheers, > M. > > William K. Scherer Sr. Member of Applications Staff - Verizon Wireless Bill.Scherer_at_VerizonWireless.com From duncan at NOSPAMrcp.co.uk Mon Jun 25 03:37:06 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Mon, 25 Jun 2001 07:37:06 +0000 (UTC) Subject: NT Service and COM References: <9gu4nf$553$1@troll.powertech.no> <87elsb2hbw.fsf@cecilia.trollope.org> Message-ID: Michael Powe wrote in news:87elsb2hbw.fsf at cecilia.trollope.org: >>>>>> "Duncan" == Duncan Booth writes: > Duncan> I'm not sure how to get round this. I can use DCOMCNFG to > Duncan> give access, but I feel I should be able to set the > Duncan> security from inside the process. Unfortunately I cannot > > This would be a horrible security weakness if it is allowed. What's > to stop somebody from cracking a process and having it reset its own > security to, say, 'administrator' and having fun with the system? > Perhaps I wasn't clear enough. I don't want the service to have special privileges: it is publishing the COM object, not attempting to use it. My own userid, which is in the 'Power Users' group doesn't have sufficient privileges to use the COM object by default. So far I can get around this by giving my userid (or a group) access to all DCOM objects on the machine, but it would seem reasonable for the COM server to be able to selectively grant other users access to itself. This doesn't require the process to be able to give itself any additional privileges, so the problem you are worrying about doesn't arise. -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From msoulier at storm.ca Wed Jun 6 22:34:32 2001 From: msoulier at storm.ca (Michael P. Soulier) Date: Thu, 07 Jun 2001 02:34:32 GMT Subject: integers References: <9fjd8q$qb6$1@charm.magnus.acs.ohio-state.edu> <9fjgqf$rp0$2@brokaw.wa.com> Message-ID: On Tue, 05 Jun 2001 18:39:26 -0700, Doug Landauer wrote: > IMHO, it is 100 [*] times more important to make your code readable > than it is to make it writeable. So in order for a feature to > pull its weight, it has to improve writeability by 100 times more > than it impairs readability and maintainability. > > IMHO, "++" does not fare well in this tradeoff. I'd agree that keeping side-effects separate is important if you want that as a feature of the language, and that it would be confusing for former C coders in the similarity. I can't buy the readability argument though. Personally, I find var++ infinitely more readable than var += 1. Although Pascal's incr() function is probably moreso. Anyway, if you're going to add a feature, += makes more sense since you can increment by variable amounts, but it's still less readable, IMHO. Of course, if you add var++, do you add ++var? Mike -- Michael P. Soulier "With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead." -- RFC 1925 From paulp at ActiveState.com Thu Jun 28 14:32:34 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Thu, 28 Jun 2001 11:32:34 -0700 Subject: Augmented Assignement (was: Re: PEP scepticism) References: Message-ID: <3B3B7842.E2DA92DB@ActiveState.com> I think Python has been getting better and better as time goes on. But I do have a concern about augmented assignment. How can a newbie understand that tuples are "immutable" if this works: mytuple += (foo,bar) Worse, once they've learned that this does NOT affect other references to mytuple they are bound to be confused by mylist += [foo, bar] which does! I've seen this confusion already -- in a draft of a book no less. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From qrczak at knm.org.pl Fri Jun 1 16:18:49 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 1 Jun 2001 20:18:49 GMT Subject: parse-time optimizations References: <9f61od$aic$1@news.mathworks.com> <3B16B548.32986D7@chello.nl> <9f6cs4$hjc$1@news.mathworks.com> <3B16E310.290D0B77@chello.nl> <9f6ura$q1n$1@news.mathworks.com> Message-ID: 1 Jun 2001 02:32:10 GMT, jcm pisze: >> Python's evaluation is left to right, Hence > > The + operator has this behavior (left associativity). > The ** operator, on the other hand, is right-associative. Associativity of an operation (the property that a@(b at c) = (a at b)@c), syntactic associativity (is a at b@c interpreted as a@(b at c) or (a at b)@c) and the order of evaluation (is a or b evaluated earlier in a at b) are three different things. Don't confuse them. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From rgb at panix.com Sat Jun 9 19:45:17 2001 From: rgb at panix.com (Randolph Brown) Date: 9 Jun 2001 23:45:17 GMT Subject: floating point in 2.0 References: <9flkoi$ofu$1@panix2.panix.com> <3B1E6A67.2B33C197@shore.net> <9fm9kg05qs@enews1.newsguy.com> Message-ID: <9fuced$out$1@news.panix.com> In article <9fm9kg05qs at enews1.newsguy.com>, Alex Martelli wrote: >I recall those darned globals that >broke my routines when used in somebody else's workspaces as >the worst blights on an otherwise interesting language Certainly relatively obscure globals changing the behavior of ==, < and the like are very dangerous, but comparing floats correctly is non-obvious, so putting some operations in the default library and pointing to them in the documentation for floats might be a good way of preventing beginners from shooting themselves in the foot: # warning! not terribly tested code follows: import math def tolerates(x, y, tol): """ are the floating point values x and y within a reasonable tolerance tol of each other? The tolerance scales with the two numbers (a tolerance of 1E-9 is pretty large around 1, but you need to scale that for numbers in the millions.) See Kuth TAoCP v.2 4.2.2 """ _, ex = math.frexp(x) _, ey = math.frexp(y) return math.fabs(x - y) < tol * math.ldexp(1, max(ex, ey)) # really, though, it may make more sense in some cases to specify your # tolerance as an exponent in base 2, and then you can do some more stuff as # integer arithmetic: # # Warning! no performance checks yet done! def tolBase2(x, y, tol): "e.g. tolBase2(x, y, -5) == tolerance(x, y, 2**-5)" _, ex = math.frexp(x) _, ey = math.frexp(y) return math.fabs(x - y) < math.ldexp(1, max(ex+tol, ey+tol)) # maybe also a tolerance that uses ULPs too? Then we get : >>> e=1E-9 >>> tolerates(1.0, 1.0, e) 1 >>> tolerates(1.0, 1.1, e) 0 >>> tolerates(1E-10, 1.1e-10, e) 0 >>> tolerates(1e-20, 1.1e-20, e) 0 >>> 1e-20 == 1e-10*1e-10 0 >>> 1e-20 9.9999999999999995e-21 >>> 1e-10*1e-10 1.0000000000000001e-20 >>> tolerates(1e-20, 1e-10*1e-10, e) 1 >>> tolerates(1e-20, 0, e) 1 # note that the reason that last part worked is the encoding of 0: >>> import math >>> math.frexp(0) (0.0, 0) -Randy From rsenior at hotmail.com Wed Jun 6 10:32:26 2001 From: rsenior at hotmail.com (robin senior) Date: Wed, 6 Jun 2001 10:32:26 -0400 Subject: why huge speed difference btwn 1.52 and 2.1? References: <9f8fgs$ooo$1@knot.queensu.ca> <9fdjsc$pn4$1@panix2.panix.com> <3b1bcf7a.12528354@news.ccs.queensu.ca> Message-ID: <9flf0i$l9n$1@knot.queensu.ca> "Neil Schemenauer" wrote in message news:mailman.991759333.17998.python-list at python.org... > Your problem is likely that you are re.search() in a loop. In > Python 1.5.2 re.search() was a C function. In 2.1 it is a Python > function. Using the pcre.search() function should get your > program up to speed. Alternatively, you could revise your > program. It is quite inefficient. This (untested) version > should be faster: Thanks, that was exactly what I was wondering about. I fired off the script in a couple minutes, didn't check it for efficiency (I usually use perl for regex's, so I'm not used to all these different ways to do them). The script only had to execute once, and is long done, I was just wondering why the difference in speed. It was working on a large dataset, and the 1.5.2 machines finished hours before the 2.1 machines. Cheers, -robin From brakedon at hotmail.com Fri Jun 1 21:30:48 2001 From: brakedon at hotmail.com (eric_brake) Date: 1 Jun 2001 18:30:48 -0700 Subject: create backup script in python Message-ID: <7b515e0f.0106011730.6b1aa82d@posting.google.com> What is the easiest way to write a file copy script in python? I want to use the script as a way to backup any file I choose on my hard drive. Binary mode is best while handling this range of file types, Correct? thank you From paulp at ActiveState.com Wed Jun 20 22:54:45 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Wed, 20 Jun 2001 19:54:45 -0700 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) References: Message-ID: <3B3161F5.89146EB@ActiveState.com> "Steven D. Majewski" wrote: > >... > > Also, as another former Icon-er, I tend to lean with Tim > on the syntax issue. Did icon switch from eager evaluation of the function to lazy evaluation based on the occurrence of a keyword somewhere in the function? -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From lac at cd.chalmers.se Fri Jun 1 17:16:43 2001 From: lac at cd.chalmers.se (Laura Creighton) Date: Fri, 1 Jun 2001 23:16:43 +0200 (MET DST) Subject: Sourceforge break-in and Python 2.1 security Message-ID: <200106012116.XAA14986@boris.cd.chalmers.se> I'm running 2.1 and I am not worried. I am not worried because statistically speaking, people who break into things and then talk about it are majorly interested in making people worried, which is why the most shallow of them just make the talk wihtout the breaking. Getting you to make postings like you did is the point. Now they can tell all their friends that they made Tim Peters say something, which the rest of us implement by saying `hi Tim'. The next class of people change your software by globally changing all instances of FooMaker into fooMaker. Unless they are lame and forget a file, or you are lame and have a FooMaker and a fooMaker (which you might not be lame for, given certain types of coding standardization which indeed requires you to have fooMaker objects in the FooMaker class) they are no problem. They are a bloody annoyance as you change the code back, but not a real problem for anybody who doesn't have to work on the code. (Unless you are teaching some hard coding standardization of variable names and they break your convention so your teaching goes to hell. Be careful with your changes, gang.) These people need some really hard unsolved algorithms in the more mathematical disciplines or math itself to occupy their bored little minds. But those of us who have _got_ some unsolved algorithms don't waste our time on pond scum, so we are of absolute no use in keeping the word a safer place by giving them something more cool to do than be pests. Then there are the real problems. They are real rare, and generally get about because something is real popular (hey! lets do a denial of service attack on Ebay. wouldn't that be cool?) or because they hate you (Tim Peters is a total fool. He said something wrong about floating point _once_ in the last 10 years. Let us make his life hell.) If it turns out that Tim Peters is up against that war, and has chosen to not talk about it, then we need to immediately back him unconditionally by ignoring it totally especially because we do not understand what is going on. Whatever it is, Tim Peters has decided to not talk about it. Hush. (thus breaking the rule, Tim Peters gets one free crack at calling me pond scum, because I know better, redeemable any time he likes.) Laura From BPettersen at NAREX.com Mon Jun 11 14:26:26 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Mon, 11 Jun 2001 12:26:26 -0600 Subject: Python and SML Message-ID: <6957F6A694B49A4096F7CFD0D900042F27DB71@admin56.narex.com> > From: Andrew Koenig [mailto:ark at research.att.com] > > >> From: Andrew Koenig [mailto:ark at research.att.com] > >> > Daniel> I am new to Python and was struck by the similarity to > Daniel> a language I learned in a programming languages course, > Daniel> SML/NJ. It, like Python, is an interpreted language... > >> > >> SML/NJ interpreted? How's that again? > > Bjorn> Both interpreted and compiled (even has an interactive > shell :-) > > The implementations I've seen compile everything, even interactively > typed statements. Yes, everything is compiled into a "heap image", which is architecture dependent (which can be exported and transformed into an executable). I'm sure we can agree that makes it compiled, but then Python "compiles" to Python VM instructions ... -- bjorn From jmarshal at mathworks.com Thu Jun 14 10:34:54 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 14 Jun 2001 14:34:54 GMT Subject: Python grammar.. References: <9g7nrv$nnb$1@news.mathworks.com> Message-ID: <9gai2e$bun$1@news.mathworks.com> Remco Gerlich wrote: > Joshua Marshall wrote in comp.lang.python: > >> Choose a parsing rule and use parens to group things differently. >> Python (and many other languages) already need parens to do this for >> binary operators ("1-2-3" parses as "(1-2)-3"). >> >> So you'd probably have to write "Spam(scramble(eggs), ham)" as >> "Spam (scramble eggs) ham". > Why wouldn't that parse as (Spam (scramble eggs)) (ham) ? It parses however you define the parsing rule. Since Python functions can take multiple arguments, I think it's more useful to include as many arguments as you can when parsing function applications. > If you're going to make the parentheses mandatory everywhere you've just > taken a step back to Lisp... Well, first of all Python _does_ currently require parens for every function call. This alternate syntax would remove the need for some of those. And given the parsing rule you imply with: "Spam (scramble eggs) ham" => "(Spam (scramble eggs)) (ham)" no amount of parens would yield an application with more than one argument. All this said, there are probably other problems that would come up if you tried to graft syntax like this onto the language. From robin at stop.spam.alldunn.com Thu Jun 7 02:10:14 2001 From: robin at stop.spam.alldunn.com (Robin Dunn) Date: Thu, 07 Jun 2001 06:10:14 GMT Subject: py2exe References: <9flfi1$4r3ap$1@ID-59885.news.dfncis.de> Message-ID: <9VET6.24$OCi.24445191@news.randori.com> > > > > warning: py2exe: * The following modules were not fo > > warning: py2exe: * win32api > > warning: py2exe: * miscc > > warning: py2exe: * printfwc > > warning: py2exe: * misc2c > > ... > Ignore them (and make sure to thoroughly test the built > executable). Most of them are symbols coming from wxPython... They're not found because they are statically linked with the code wxPython extension. So they are found just fine at runtime, just not on the filesystem. -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! From sholden at holdenweb.com Thu Jun 14 08:15:12 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 14 Jun 2001 08:15:12 -0400 Subject: HREF to same server, different port References: <9ga8h3$1cs$1@norfair.nerim.net> Message-ID: Unfortunately I am looking for a client-side solution - otherwise it wouldn't have been an off-topic post would it? Thanks for your input. regards Steve -- http://www.holdenweb.com/ "Loft'sHorrible" wrote in message news:9ga8h3$1cs$1 at norfair.nerim.net... > Have a look to the "urlparse" module. It will be helpful for your problem. > The solution will be obvious after you read this... > > http://www.python.org/doc/current/lib/module-urlparse.html > > --Gilles > > "Steve Holden" a ?crit dans le message news: > OWi6PtJ9AHA.281 at cpmsnbbsa07... > > Sorry this is off-topic, but I'm trying to create a relative url to a > > different port on the same server (inheriting the server name or address > > from the current URL). I've tried //:8081/ and :8081/ and neither works. > > > > ANyone tell me how? > > > > regards > > Steve > > -- > > > > http://www.holdenweb.com/ > > > > From nospam at nospam.de Sun Jun 10 14:50:44 2001 From: nospam at nospam.de (Uwe Hoffmann) Date: Sun, 10 Jun 2001 20:50:44 +0200 Subject: list-display semantics? References: <9g0dhl$if1$1@news.nsysu.edu.tw> Message-ID: <3B23C184.C558DCCC@nospam.de> jainweiwu wrote: > > Hi all: > I tried the one-line command in a interaction mode: > [x for x in [1, 2, 3], y for y in [4, 5, 6]] actually is: [ x for x in [[1, 2, 3], y] for y in [4, 5, 6] ] > and the result surprised me, that is: > [[1,2,3],[1,2,3],[1,2,3],9,9,9] > Who can explain the behavior? > Since I expected the result should be: > [[1,4],[1,5],[1,6],[2,4],...] [ [x,y] for x in [1, 2, 3] for y in [4, 5, 6] ] > -- > Pary All Rough Yet. > parywu at seed.net.tw regards uwe From MarkH at ActiveState.com Mon Jun 18 22:40:34 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 19 Jun 2001 02:40:34 GMT Subject: Win32com Item method does not return object References: Message-ID: <3B2EBBE7.8050803@ActiveState.com> Mark_Pryor wrote: > Hi, > > New to Python, using Version 2.1 on Win95. > I have a COM object that has been registered into > the gen_py folder. As I drill down through the object, I > issue the Item method of a collection, which should return > another collection, but fails returning a " tuple ". PythonCOM returns a tuple when there are multiple return values from the function - typically byref params. >>>>c = om.Tags.Item(1) My guess is that for some reason, the Item method takes the int param byref. But without seeing that C actually is, it is hard to speculate, but your best bet may be to write it as: c, ignored = om.Tags.Item(1) Mark. From dalke at acm.org Fri Jun 22 17:14:45 2001 From: dalke at acm.org (Andrew Dalke) Date: Fri, 22 Jun 2001 15:14:45 -0600 Subject: PEP 255: Simple Generators References: Message-ID: <9h0crt$rq6$1@slb1.atl.mindspring.net> Carsten Geckeler: >So Test is called like a function and returns an instance. But why make a >different syntax ("class") for defining it? Just because it returns an >instance instead an integer or another object? According to your >argument, "def" would be fine. There isn't quite enough information to distinguish between at least some class definitions and function definitions without the use of a keyword. Consider >>> class SuperTest: ... pass ... >>> def Test(SuperTest): ... def __init__(self, spam): ... self.spam = spam ... def __str__(self): ... return str(self.spam) >>> t = Test("eggs") >>> str(t) 'None' >>> Changing the 'def Test' to 'class Test' changes the entire meaning of the code. Andrew dalke at acm.org From mwh at python.net Tue Jun 19 13:12:34 2001 From: mwh at python.net (Michael Hudson) Date: 19 Jun 2001 18:12:34 +0100 Subject: disable line wrap in xterm?? References: Message-ID: "Scherer, Bill" writes: > Can anyone tell me how I can disable line wrap in an xterm (or > equiv, eg: rxvt, Eterm, etc) from Python? To turn auto-wrap off: print "\033[?7l" to turn it on: print "\033[?7h" Do you have the ctlseqs.TXT document? It's handy for this sort of thing. These are probably grossly xterm specific - AFAIK there's no corresponding terminfo/termcap code (but my termcap & terminfo book seems to have vanished into the depths of my room, so I'm not sure). Cheers, M. -- 58. Fools ignore complexity. Pragmatists suffer it. Some can avoid it. Geniuses remove it. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From sandorlevi at yahoo.com Wed Jun 20 22:14:16 2001 From: sandorlevi at yahoo.com (Levente Sandor) Date: 20 Jun 2001 19:14:16 -0700 Subject: COM method with pointer args References: <8b5e42a6.0106171630.43a3303a@posting.google.com> <9gkek6024kl@enews2.newsguy.com> Message-ID: <8b5e42a6.0106201814.4d4ee44e@posting.google.com> There is a BASIC-like language for OLE automation shipped with the Corel products, named CorelScript. There are some examples too. Maybe I will try it some time... Sorry, but I tend to believe that CORELDRW.TLB is intentionally left incorrect, to be useless for the "outer world". Thanks, Levi From guido at digicool.com Thu Jun 14 13:30:42 2001 From: guido at digicool.com (Guido van Rossum) Date: Thu, 14 Jun 2001 13:30:42 -0400 Subject: Python 2.0.1c1 - GPL-compatible release candidate Message-ID: <200106141730.f5EHUgX03621@odiug.digicool.com> With a sigh of relief I announce Python 2.0.1c1 -- the first Python release in a long time whose license is fully compatible with the GPL: http://www.python.org/2.0.1/ I thank Moshe Zadka who did almost all of the work to make this a useful bugfix release, and then went incommunicado for several weeks. (I hope you're OK, Moshe!) Note that this is a release candidate. We don't expect any problems, but we're being careful nevertheless. We're planning to do the final release of 2.0.1 a week from now; expect it to be identical to the release candidate except for some dotted i's and crossed t's. Python 2.0 users should be able to replace their 2.0 installation with the 2.0.1 release without any ill effects; apart from the license change, we've only fixed bugs that didn't require us to make feature changes. The SRE package (regular expression matching, used by the "re" module) was brought in line with the version distributed with Python 2.1; this is stable feature-wise but much improved bug-wise. For the full scoop, see the release notes on SourceForge: http://sourceforge.net/project/shownotes.php?release_id=39267 Python 2.1 users can ignore this release, unless they have an urgent need for a GPL-compatible Python version and are willing to downgrade. Rest assured that we're planning a bugfix release there too: I expect that Python 2.1.1 will be released within a month, with the same GPL-compatible license. (Right, Thomas?) We don't intend to build RPMs for 2.0.1. If someone else is interested in doing so, we can link to them. --Guido van Rossum (home page: http://www.python.org/~guido/) From jeff at ccvcorp.com Wed Jun 20 19:12:44 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: 20 Jun 2001 16:12:44 -0700 Subject: PEP 255: Simple Generators References: <3B303FE5.735A5FDC@cosc.canterbury.ac.nz> <90C65699Dgmcmhypernetcom@199.171.54.194> Message-ID: <16074dce.0106201512.5459e720@posting.google.com> David Eppstein wrote in message news:... > I'm wondering if it wouldn't make sense to allow a non-empty return > statement in a generator, with the semantics that the object being returned > is itself some kind of iterator that is used to continue the sequence. > > i.e. > def integers(i): > yield i > return integers(i+1) > > ...thus allowing a more functional-programming-like lazy iteration. > There would thus also be very little difference between a function that > returns an iterator, and a generator that does some yields before returning > an iterator. It seems to me that this would be better written as def integers(i): while 1: yield i i += 1 but I confess that I don't see offhand how either case generalizes to a less-contrived example. It doesn't *seem* to me that your proposal adds significant functionality... but I'm not so familiar with functional programming, so I'm likely missing something. :) Jeff Shannon Technician/Programmer Credit International From vj$ri^gg#guess#l55e at mt$*guess#&cn1e#t.! Sat Jun 16 21:35:06 2001 From: vj$ri^gg#guess#l55e at mt$*guess#&cn1e#t.! (Kevin Riggle) Date: Sat, 16 Jun 2001 20:35:06 -0500 Subject: Suggestions for a Strange Project? References: <3b2abb77_1@news3> <9gekf2$ocd$1@mtc1.mtcnet.net> <3b2b7745_2@news3> Message-ID: <9gh18i$1dm$1@mtc1.mtcnet.net> > Is [a time server] a Python-based solution, or did you have other > apps in mind? If you don't mind the hassle of changing your gateway machine over to Linux (and it can be *quite* a chore, although the security is much better than Windows), your distribution should come with ntpd, the network time protocol daemon, and the corresponding server application, which you can use to update the clocks in conjunction with the US Naval Observatory's time servers. This is definately the way to go for a 'large cluster of Linux machines,' as they should have everything you need on the disk if not preinstalled. Basic ntpd info: http://www.eecis.udel.edu/~ntp/ntp_spool/html/ntpd.htm USN Naval Observatory NTP Servers: http://tycho.usno.navy.mil/ntp.html There are some apps for Windows that use ntp. A How-To at GeodSoft has info on that, plus a lot on *nix systems and NTP in general. http://geodsoft.com/howto/timesync/wininstall.htm Python would probably work, but it's a lot easier just to install and configure a piece of software than to "roll your own." :) > I have always wanted more flexible features than the > clipboard Windows offers. It would be best if you could set up a central 'clipboard server' and query the machine every time you copy or paste -- much easier on Linux, as you can directly modify the code. For Windows, a set polling interval might work best; some order of precedence would have to be established (ie. if machine A has one thing in the clipboard and machine B has another, which do I send to the central server). Time stamps might be needed. > Probably the biggest challenge is going to be sharing the > graphics pad mouse-cursor messages. Also, the Wacom tablet transmits intensity as well -- you won't just be able to tap the Windows API. Speed is another consideration. I don't know if there are USB switches out there, but it might be something to look into. Hope that helps. - Kevin "Mega Hurts" wrote in message news:3b2b7745_2 at news3... > > > I believe that a 'time server' may solve the clock problem. Security may > be > > an issue -- I've never tried to set one up myself. > > Is this a Python-based solution, or did you have other > apps in mind? > > I'm hoping to handle this with a Python applet. My > four personal machines would benefit from a daily auto- > mated clock correction, but I would ventually be applying > the solution to a large Linux cluster. > > Hopefully, security would be no more an issue for this > than for any other scripted tasks either cluster would > handle. > > > The others may require a > > bit more coding. You might be able to run a modification of the > > Python-based chat program at > > http://strout.net/python/server.py > > and have each computer post the clipboard contents periodically. > Just a > thought. > > > > - Kevin > > Thanks for the link! Looks like a good starting point > for the communications need. > > I have always wanted more flexible features than the > clipboard Windows offers. The ability to hold multiple > items comes to mind, especially when I'm pasting > chunks of boilerplate in standard responses to email > inquiries. I believe there are clipboard apps for > Windows, but I've not taken the time to test any. > Making a shared-clipboard app for a cluster would seem > a natural for multiple items. > > Probably the biggest challenge is going to be sharing the > graphics pad mouse-cursor messages. Sensing and trans- > mission of actions may be less of a challenge than > INTERCEPTION, so a tap or movement does not effect the > machine to which the hardware is actually connected unless > the software is 'switched' to that machine. > > At best, sounds like Windows API issues. The pad is > a USB unit, and I'd be surprised if there was any way > to communicate more directly with it- but maybe there > is a hardware abstraction layer in software for these, > and a way to tap into it. > > I can dream, can't I? !-) > From nospam at nospam.de Sun Jun 24 05:40:15 2001 From: nospam at nospam.de (Uwe Hoffmann) Date: Sun, 24 Jun 2001 11:40:15 +0200 Subject: readline, python 2.1 and LFS References: Message-ID: <3B35B57F.1E0F956B@nospam.de> Timothy Grant wrote: > > .... > then recompiled Python. This time it built readline support. > > However, when I try and import readline, I get the following > error. > > ImportError: /usr/local/lib/python2.1/lib-dynload/readline.so: > undefined symbol: tputs > I think you need to link the readline module with either ncurses or termcap regards uwe From aleaxit at yahoo.com Thu Jun 7 12:40:23 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 7 Jun 2001 18:40:23 +0200 Subject: getting current call stack References: Message-ID: <9foapl0hpt@enews2.newsguy.com> "Olaf Meyer" wrote in message news:yuk98zj45ljw.fsf at manta.europe.nokia.com... > Is there any way to determine the current call stack from a method/function? In Python 2.1, sys._getframe([depth]): Return a frame object from the call stack. If optional integer depth is given, return the frame object that many calls below the top of the stack. If that is deeper than the call stack, ValueError is raised. The default for depth is zero, returning the frame at the top of the call stack. This function should be used for internal and specialized purposes only. In older versions, a try/catch and lot of play with the traceback object lets you do similar things, but it's even more obviously 'black magic':-) Alex From bs1535 at sbc.com Tue Jun 12 11:35:34 2001 From: bs1535 at sbc.com (SNYDER, BARRON F. (AIT)) Date: Tue, 12 Jun 2001 11:35:34 -0400 Subject: [wxPython] Help with wxChoice! Message-ID: <35BD410BA148D411A7ED00508BCFFBDA05CB29D0@msgil65170u05.nbk2305.il.ameritech.com> I need help in understanding how to add an additional entry to a wxChoice dropdown list box. The wxWindows doc shows: void Append(const wxString& item) Adds the item to the end of the choice control. So in python, would I use something like: wxchoicename.Append("ABC123") That is what I'm doing and I don't get an error but the new value isn't being appended either. Any help is appreciated! Barron (a bear of very little brain) From piet at cs.uu.nl Mon Jun 25 07:56:10 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 25 Jun 2001 13:56:10 +0200 Subject: (no subject) References: Message-ID: >>>>> crombie (c) writes: c> newbie question: c> trying to type this in: c> >>> a, b = 0, 1 c> >>> while b < 1000: c> ... print b, c> ... a, b = b, a+b c> ... c> 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 c> but result is this: c> >>> while b< 10 c> SyntaxError: invalid syntax c> >>> while b < 10: c> ... print b c> IndentationError: expected an indented block (line 2) c> >>> while b < 10: c> print b c> a, b = b, a+b ... Something was wrong here, as the interpreter didn't give the ... prompt. Did you copy and paste this or enter it with some weird method? Maybe you should have restarted the interpreter. c> SyntaxError: invalid syntax c> >>> while b < 1000: c> ... print b, c> IndentationError: expected an indented block (line 2) c> >>> while b < 1000: c> ... print b, c> SyntaxError: invalid syntax c> >>> c> anyone know why? Did you type the ... yourself? -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From nperkins7 at home.com Thu Jun 21 16:12:49 2001 From: nperkins7 at home.com (Nick Perkins) Date: Thu, 21 Jun 2001 20:12:49 GMT Subject: critic this please References: Message-ID: <5zsY6.310479$eK2.62294825@news4.rdc1.on.home.com> You probably want to write some functions with parameters to avoid typing many functions with similar code. It is also a good idea to try to separate the actual calculations from the code that accesses and manipulates the GUI.] Perhaps something like this will give you some ideas: (untested) slope_factor = {5: 13.0, # use 13.0, not just 13, to ensure accuracy 6: 13.42, 7: 13.89, 8: 20.0, 9: 15.0, 10: 15.62, 11: 16.28, 12: 16.67 } # calcualte rafter length, and return the result # def rafter_length( run_feet, run_inches, slope_type): factor = slope_factor[slope_type] exact_run_feet = run_feet + (run_inches/12.0) exact_rafter_feet = exact_run_feet * factor return exact_rafter_feet # get the input from the text fields, and display the answer # def display_rafter_length(slope_type) a = float(Tkinter.Entry.get(feet)) b = float(Tkinter.Entry.get(inch)) Tkinter.Entry.delete(answer, 0, 20) Tkinter.Entry.insert(answer, 0, rafter_length(a,b,slope_type)) def fig5(): display_rafter_length(5) def fig6(): display_rafter_length(6) ..etc. "NJM" wrote in message news:tj4360hohgdk2c at corp.supernews.com... > I've just wrote this small program that calculates the length of a rafter > for you(I'm a carpenter), but I didn't write it "properly". I can't seem to > wrap my head around using classes. Does anyone have any input. > > > import Tkinter > > def fig5(): > a = float(Tkinter.Entry.get(feet)) > b = float(Tkinter.Entry.get(inch)) > Tkinter.Entry.delete(answer, 0, 20) > Tkinter.Entry.insert(answer, 0, (b/12 + a)*13) > > def fig6(): > a = float(Tkinter.Entry.get(feet)) > b = float(Tkinter.Entry.get(inch)) > Tkinter.Entry.delete(answer, 0, 20) > Tkinter.Entry.insert(answer, 0, (b/12 + a)*13.42) > def fig7(): > a = float(Tkinter.Entry.get(feet)) > b = float(Tkinter.Entry.get(inch)) > Tkinter.Entry.delete(answer, 0, 20) > Tkinter.Entry.insert(answer, 0, (b/12 + a)*13.89) > > def fig8(): > a = float(Tkinter.Entry.get(feet)) > b = float(Tkinter.Entry.get(inch)) > Tkinter.Entry.delete(answer, 0, 20) > Tkinter.Entry.insert(answer, 0, (b/12 + a)*14.42) > > def fig9(): > a = float(Tkinter.Entry.get(feet)) > b = float(Tkinter.Entry.get(inch)) > Tkinter.Entry.delete(answer, 0, 20) > Tkinter.Entry.insert(answer, 0, (b/12 + a)*15) > > def fig10(): > a = float(Tkinter.Entry.get(feet)) > b = float(Tkinter.Entry.get(inch)) > Tkinter.Entry.delete(answer, 0, 20) > Tkinter.Entry.insert(answer, 0, (b/12 + a)*15.62) > def fig11(): > a = float(Tkinter.Entry.get(feet)) > b = float(Tkinter.Entry.get(inch)) > Tkinter.Entry.delete(answer, 0, 20) > Tkinter.Entry.insert(answer, 0, (b/12 + a)*16.28) > def fig12(): > a = float(Tkinter.Entry.get(feet)) > b = float(Tkinter.Entry.get(inch)) > Tkinter.Entry.delete(answer, 0, 20) > Tkinter.Entry.insert(answer, 0, (b/12 + a)*16.97) > > > root=Tkinter.Tk(className="/Rafter Lengths") > frame=Tkinter.Frame(root, relief=Tkinter.RIDGE, borderwidth=2) > frame.pack() > label=Tkinter.Label(frame, text="This is a program that will calculate the > rafter lengths for you") > label.pack() > > frame2=Tkinter.Frame(root, borderwidth=0) > frame2.pack() > > button=Tkinter.Button(frame2, text="'5-12'", command=fig5) > button.pack(side=Tkinter.LEFT) > button2=Tkinter.Button(frame2, text="'6-12'", command=fig6) > button2.pack(side=Tkinter.LEFT) > button3=Tkinter.Button(frame2, text="'7-12'", command=fig7) > button3.pack(side=Tkinter.LEFT) > button4=Tkinter.Button(frame2, text="'8-12'", command=fig8) > button4.pack(side=Tkinter.LEFT) > button5=Tkinter.Button(frame2, text="'9-12'", command=fig9) > button5.pack(side=Tkinter.LEFT) > button6=Tkinter.Button(frame2, text="'10-12'", command=fig10) > button6.pack(side=Tkinter.LEFT) > button7=Tkinter.Button(frame2, text="'11-12'", command=fig11) > button7.pack(side=Tkinter.LEFT) > button8=Tkinter.Button(frame2, text="'12-12'", command=fig12) > button8.pack(side=Tkinter.LEFT) > button9=Tkinter.Button(frame2, text="Quit", command=root.quit) > button9.pack(side=Tkinter.LEFT) > > frame3=Tkinter.Frame(root, borderwidth=5) > frame3.pack() > > labe=Tkinter.Label(frame3, text="Rafter Run to be calculated") > labe.pack(side=Tkinter.LEFT) > > space=Tkinter.Label(frame3, width=5) > space.pack(side=Tkinter.LEFT) > > label2=Tkinter.Label(frame3, text="Feet") > label2.pack(side=Tkinter.LEFT) > feet=Tkinter.Entry(frame3, width=5) > feet.pack(side=Tkinter.LEFT) > > label3=Tkinter.Label(frame3, text="Inches", width=5) > label3.pack(side=Tkinter.LEFT) > inch=Tkinter.Entry(frame3, width=5) > inch.pack(side=Tkinter.LEFT) > > frame4=Tkinter.Frame(root, relief=Tkinter.RIDGE, borderwidth=2) > frame4.pack() > > label4=Tkinter.Label(frame4, text="Rafter Length in Inches") > label4.pack(side=Tkinter.LEFT) > answer=Tkinter.Entry(frame4) > answer.pack(side=Tkinter.LEFT) > > frame5=Tkinter.Frame(root) > frame5.pack() > > label5=Tkinter.Label(frame5, text="This length does not allow for \n the > thickness of the ridge.") > label5.pack() > > root.mainloop() > > From thinkit8 at lycos.com Sat Jun 16 02:31:59 2001 From: thinkit8 at lycos.com (thinkit) Date: 15 Jun 2001 23:31:59 -0700 Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> <3b266270$1_7@news5.uncensored-news.com> <9g68os0cd9@drn.newsguy.com> <3B26CD62.F89E5FA0@my.signature> Message-ID: <9geugv0b50@drn.newsguy.com> In article , "Nick says... > > >"Greg Ewing" wrote in message >news:3B26CD62.F89E5FA0 at my.signature... > >[ moving humans to hexadecimal..] >> >> We need six more digit symbols, though. Borrowing >> letters was okay as an interim measure, but we need >> to move on. Any proposed designs? >> > >We could use the four symbols from that led zeppelin album, then maybe a >happy-face, and the symbol formery known as the symbol representing the >artist formerly known as prince. > >..but i guess they would need pronouncable names, too? as my other reply says, lojban already has it. how does dau fei gai jau rei vai sound? From new_name at mit.edu Fri Jun 29 17:12:35 2001 From: new_name at mit.edu (Alex) Date: 29 Jun 2001 17:12:35 -0400 Subject: Python 2.1 docs in GNU info format References: Message-ID: > Milan Zamazal has contributed Python 2.1 documentation in GNU info > format. It is available on python.org: Woohoo! I've been missing this for ages! Alex. From dwig at advancedmp.net Fri Jun 1 19:48:32 2001 From: dwig at advancedmp.net (Don Dwiggins) Date: 01 Jun 2001 16:48:32 -0700 Subject: Why isn't Python king of the hill? In-Reply-To: D-Man's message of "Fri, 1 Jun 2001 15:55:31 -0400" References: <9f7ai7$b4e$1@newshost.accu.uu.nl> <20010601155530.C7896@harmony.cs.rit.edu> Message-ID: D-Man writes: > My question for you is : What about J2EE makes it so great? What > are the features that you really need/want? Why not start an > "Enterprise Python" spec, or something, to provide those features in > Python? If J2EE is the main reason to use Java (excluding the reason > in your next section), then let's take all the good ideas from it and > make them part of Python too. If Python had "PyEE" then it might be > easier to sell to management . How about "EnterPy"? Easy to say, and fits nicely with Starship Python... -- Don Dwiggins "Solvitur Ambulando" Advanced MP Technology dwig at advancedmp.net From gmuller at worldonline.nl Tue Jun 5 16:24:58 2001 From: gmuller at worldonline.nl (Gerrit Muller) Date: Tue, 5 Jun 2001 22:24:58 +0200 Subject: How do you develop in Python? References: <050620011516094693%pecora@anvil.nrl.navy.mil> Message-ID: <9fjfer$gt0$1@nereid.worldonline.nl> "Lou Pecora" schreef in bericht news:050620011516094693%pecora at anvil.nrl.navy.mil... > I program in Python occassionally and would like to do more of it. But > here's a development conundrum I run into a lot (there are more complex > examples, but I'll give an easy one). I am developing module A.py > which imports B.py in the IDE. I am running test code which is also in > A.py as I incrementally develop A.py. Then I need to change B.py and, > of course, the import does not import the new changes since import only > works once. Hence, to "refresh" B.py I have to quit the IDE and > restart, open A.py and run. This is clumsy. However, the above > scenario is not uncommon and more complex interdependencies of modules > appear to make it unavoidable. Anyone know a way to get around this > "import" problem? I know there is a "reload", but then I have to > import and change my modules' code to "reload" or something each time I > work with them. Any help appreciated. > > I use Python on a Macintosh. Nice IDE, otherwise. I certainly recognize your problem. Occasionaly I have used reload() to "solve" this behavior. However for more "naive" programmers (CP4E-like) this behavior can give many unexpected results. I do recognize the power of the current dynamic loader behavior, but I think that a more "cold" runscript command in IDLE, which imports/reloads anything again (and maybe clears the rest of the environment as well) would make IDLE even more accessible for this type of programmers. Regards Gerrit From noselasd at frisurf.no Wed Jun 20 02:54:38 2001 From: noselasd at frisurf.no (Nils O. Selåsdal) Date: Wed, 20 Jun 2001 08:54:38 +0200 Subject: Which IDE ? References: Message-ID: "VanPopering" wrote in message news:dHvX6.10207$DW1.418937 at iad-read.news.verio.net... > Which IDE would you recommend for someone *just starting out* with Python? > > -I'm not a professional programmer but Im interested in learning Python > -I want to use opensource whenever possible > -For now I'm just here for the basics; some scripting etc. > > I'd LOVE to use idle since its part of it and free, but I have heard that it freezes upand > has other problems...is this really a problem that it happens a lot? Are there things I can > do to avoid this - does it happen with larger more complex programs only? If it froze while > running the script and that was the only potential problem, then I'd just save it first... > > I am wondering if these were copmplaints by professional programmers who > needed and expected more... > > Komodo looks interesting, but I do admit it looks like a bit much for my purposes: > I want to write, edit, debug, and run simple python thingys > > I hope I misunderstood what I had heard about Idle's short comings - > > *I dont know yet and thats why Im asking* emacs/xemacs is fine.. > (I wonder what Guido uses...) probably emacs or vi From fredrik at pythonware.com Wed Jun 6 02:28:52 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 06 Jun 2001 06:28:52 GMT Subject: how much does Python model my Compsci course? References: Message-ID: Roy Katz wrote: > But Python looks as if it has invented a new form to (perhaps a > variation on pass-by-ref) param passing, based on whether or > not the object passed in is mutable (from what I understand...?) no, you don't understand ;-) the *only* difference between mutable and immutable objects is that the former have methods that let *you* modify them. Python doesn't care. From scarblac at pino.selwerd.nl Tue Jun 12 06:23:01 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 12 Jun 2001 10:23:01 GMT Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: <200106112007.f5BK7eW22506@odiug.digicool.com> <3B253031.AB1954CB@lemburg.com> Message-ID: Chris Gonnerman wrote in comp.lang.python: > I have to say, I'm strongly against this PEP... does anyone else agree with > me? I agree. It's special casing, and it breaks much of the code out there that prints header style things (CGI, mail, other http things...), and I don't see a lot of benefit. -- Remco Gerlich From thinkit8 at lycos.com Wed Jun 13 08:07:40 2001 From: thinkit8 at lycos.com (thinkit) Date: 13 Jun 2001 05:07:40 -0700 Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> <9g7dii$4lr$06$1@news.t-online.com> Message-ID: <9g7l2c021aq@drn.newsguy.com> In article <9g7dii$4lr$06$1 at news.t-online.com>, Georg says... > >thinkit wrote: > >> humans should use a power of 2 as a base. this is more logical because it >> synchs with binary, which is at the very heart of logic--true and false. >> it is more natural perhaps, to use decimal--but logic should, and will, >> win out. > >I don't feel like arguing on the locical level, my brain is >absorbed with more important matter for the moment. > >But there are also practical aspects. If you want to make >mental arithmetic as easy as possible, then you should go >with a base of 12. As far as I know, this is the (small) >base where the round figures can be divided by the largest >amount of other numbers. It's really a pity that humans >have only ten fingers, or we'd probably be doing it this >way right now... > > >Have fun! > >-schorsch > >-- >Georg Mischler -- simulations developer -- schorsch at schorsch.com >+schorsch.com+ -- Lighting Design Tools -- http://www.schorsch.com/ no, that would be 6...Ch has an extra 2 in its prime factorization. From phd at phd.fep.ru Sat Jun 30 06:00:35 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Sat, 30 Jun 2001 14:00:35 +0400 (MSD) Subject: Why Not Translate Perl to C Message-ID: Hello! This is about Perl, but it applies to Python as well. And of course not only to C, but to native code too. http://www.perl.com/pub/a/2001/06/27/ctoperl.html "A C program to do what your Perl program does would have to do most of the same things that the Perl interpreter does when it runs your Perl program. There is no reason to think that the C program could do those things faster than the Perl interpreter does them, because the Perl interpreter itself is written in very fast C." Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From tdelaney at avaya.com Wed Jun 13 20:05:21 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Thu, 14 Jun 2001 10:05:21 +1000 Subject: Python grammar.. Message-ID: > "Delaney, Timothy" wrote in message > news:mailman.992393599.3573.python-list at python.org... > ... > > way to do it - a subroutine may or may not return a value, at its > > discretion, and I should be able to ignore any returned value. > > Yes, but if I were designing a language today, I think I would > request you to be EXPLICIT about "ignoring the return value" -- > explicit is better than implicit. It IS an occasional cause of > errors in Python (particularly with newbies) that an expression > statement's value is silently and implicitly ignored... > > > Alex So you would prefer that functions whose return value is ignored must be called with a keyword ... such as in VB call aFunction() ? Personally, I absolutely hate this. Tim Delaney From scarblac at pino.selwerd.nl Fri Jun 8 13:10:08 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 8 Jun 2001 17:10:08 GMT Subject: spell method chaining? References: <19l8IVAAgJI7EwAk@jessikat.demon.co.uk> Message-ID: Robin Becker wrote in comp.lang.python: > I wish to create wrapped classes dynamically and have the wrapper class > refer to the base wrapee class methods. > > def gen(B): > class W(B): > def __init__(self): > B.__init__(self) > return W > > this works if nested scopes is on so that the reference to B in the > __init__ refers to the argument of gen, but it fails without it unless B > happens to be a global. I thought of using self.__class__.__bases__[0] > to refer to the dynamic base B, but then that fails if I use the > resultant class as a base class. > > ie if I try > > def gen(B): > class W(B): > def __init__(self): > self.__class__bases__.__init__(self) > return W > > I get trouble (infinite looping) with gen(gen(B))() > > What is the correct way for dynamic classes to refer to their immediate > base class methods to allow method chaining etc. Usually you know that the base class is called eg Klass, and you simply call that. In this case I think you have to store it inside the class manually, like this: def gen(B): class W(B): def __init__(self): self.__base.__init__(self) W._W__base = B return W (not the automatic 'name munging' the self.__base does, this way the attribute is somewhat protected from classes inheriting it) This is a bit of a hack, but then what you're doing isn't all that common and it's fixed with nested scopes anyway. -- Remco Gerlich From m.faassen at vet.uu.nl Thu Jun 14 09:47:25 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 14 Jun 2001 13:47:25 GMT Subject: Why should i use python if i can use java References: <9fngvl011jg@enews2.newsguy.com> Message-ID: <9gaf9d$fsa$1@newshost.accu.uu.nl> Alex Martelli wrote: > "Glyph Lefkowitz" wrote in message > news:mailman.991892413.1443.python-list at python.org... >> >> On 6 Jun 2001, Chris Goringe wrote: >> >> !snip! >> >> > python doesn't [have ...] >> > strong typing (love it or hate it...) >> >> Hate it :) > What _I_ hate is the confusion between weak vs strong typing > AND static vs dynamic typechecks, though it's a classic one:-). > Weak typing, properly, is what (e.g.) Perl has, where you can > use any scalar wherever, and it will try to guess what you > mean, freely treating strings as numbers, viceversa, etc. > What Python has (like, say, Scheme) I'd call strong typing > that is dynamically enforced. I always see this but I'm a bit skeptical about it. Python doesn't really do any type checking for class instances; it checks whether there is a method that is of the right name and has the right amount of arguments somewhere on the instance or its superclasses, and calls it if so. There is no 'is this the expected class?' check anywhere, not even at runtime. You can make the same case for built-in types. *Some* methods of types and classes do a class/type check, of course. Strings and integers decide to give up if they're __add__-ed to each other, but that could be considered a feature of the extension module (okay, they're important ones), not of the language. It certainly doesn't have to be that way. Python itself doesn't care one way or the other. I think saying "Python is strongly typed" can be misleading and confusing. "Strongly typed" and "Dynamically typed" combined doesn't seem to make much sense, if that language allows users to create their own types/classes. > E.g.: > D:\py21>python > Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 > Type "copyright", "credits" or "license" for more information. > Alternative ReadLine 1.4 -- Copyright 2001, Chris Gonnerman >>>> "ciao"[1.0] > Traceback (most recent call last): > File "", line 1, in ? > TypeError: sequence index must be integer >>>> > That's *WEAK* typing?! I call it pretty strong indeed -- > and love it! (Java works similarly here -- it's an > error to use a non-integer as array index -- although > C and C++ happily accept the float and truncate it...). > It's *DYNAMICALLY* checked and enforced, not statically. But only in a few places, mostly for built-in types. Those happen to be the *important* places but any other checking you'll have to come up with yourself. I don't think 'call this method can see whether you succeed' strongly typed. > I think it's more precise and useful to draw the > distinction as static vs dynamic than as strong > vs weak, no matter which way one wants to argue > for or against it. That is true; strong versus weak is more a feature of the actual classes (types) you're using in a dynamically typed language than a feature of the language itself. Anyway, I've done my bit to counter the 'Python is strongly typed' meme. I suspect that meme is around because there are lingering ideas that strong type checking is a Good Thing. I think some run-time type or interface checking can be a good thing. But I'd hardly call what Python is doing 'strong'. Python has a TypeError exception that methods can raise, and many methods of built-in objects do this because guessing would be 'magic'. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From gmcm at hypernet.com Sat Jun 23 12:19:16 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 23 Jun 2001 16:19:16 GMT Subject: PEP 255: Simple Generators References: Message-ID: <90C9756ECgmcmhypernetcom@199.171.54.194> Carsten Geckeler wrote: >Since we now have "def"/"yield" for generators, the discussion goes more >or less the same way. You just realizes that generators seem to be to >complicated for first time Python users. So you decide not to mention >them at the beginning, but later with the other advanced features. > >So some days later, another friend comes to you. You explain him all >the basic programming features, but not generators. A week later, the >friend comes to you again. > >Friend: Well, I programmed a little bit with Python. It really >seems to > be very simple. I have just one problem: I've found a code > example somewhere on the web and there is a function in it, which > seems to behave a little bit strange. Perhaps you can help me. >Me: OK, let me see. Oh, right, this is a generator, not a function! >Friend: A what? It seems to be like a function but it has some >yield > statements in it. What does yield do? Someone: Well, it's kind of like __getitem__ in a class. Friend: Huh? Someone: But sometimes you also need __len__, too. Friend: Someone: Gee, maybe I'm not explaining this well... The point being that if you start from the iterator protocol, (and with these changes, ALL "for" loops involve the iterator protocol), and then explain "yield", it will almost certainly appear no more magical to your friend than what currently goes on with making an object sequence-like. "yield" is a control flow statement, so explaining the control flow context (rather than focusing on a non-existent definition of "def") seems a wise idea. - Gordon From sholden at holdenweb.com Wed Jun 13 07:12:47 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 13 Jun 2001 07:12:47 -0400 Subject: How to tell if interpreter is in interactive mode References: Message-ID: "John Copella" wrote ... > I have some code in a module that I need to run only when the interpreter is > running interactively. Is there any way to test for this at run time? I > have looked at sys.stdin.isatty(), but this returns 1 when running > non-interactively as well (unless you do something odd like redirect stdin > to /dev/null). > > Thanks in advance, > > John > >From the 2.0 manual: """2.2.3 The Interactive Startup File When you use Python interactively, it is frequently handy to have some standard commands executed every time the interpreter is started. You can do this by setting an environment variable named $PYTHONSTARTUP to the name of a file containing your start-up commands. This is similar to the .profile feature of the Unix shells. This file is only read in interactive sessions, not when Python reads commands from a script, and not when /dev/tty is given as the explicit source of commands (which otherwise behaves like an interactive session). It is executed in the same namespace where interactive commands are executed, so that objects that it defines or imports can be used without qualification in the interactive session. You can also change the prompts sys.ps1 and sys.ps2 in this file. """ This might be usable, though I don't exploit it myself. regards Steve -- http://www.holdenweb.com/ From colin at meeks.ca Mon Jun 4 08:28:58 2001 From: colin at meeks.ca (Colin Meeks) Date: Mon, 04 Jun 2001 12:28:58 GMT Subject: php alternatives in python References: Message-ID: We wanted something with lots of functionality, but wanted total control, so we designed our own system in Python. http://www.programmedintegration.com/ Our website is written totally in Python. Specific areas that will stand out are things like our "Best of the Net" sections and any of the "What's New" sections for our products. Our whole site is editable via the web and also has a dynamic search engine that automatically indexes any changes or additions you make to pages. Our site should show you what's possible. If you have any specific questions, please feel free to email me. Colin "Scott Hathaway" wrote in message news:i3iR6.16653$aA5.86550 at news1.rdc1.tx.home.com... > I am trying to evaluate various php alternatives in python. I have looked > at webware, psp, mod_python, PyHP, using Python with ASP pages, and > mod_snake. All of these seem fairly straight forward, but what I don't know > is what really works. I would need a solution that is: > > 1) As stable as PHP > 2) Close to as fast as PHP > 3) Cross platform > 4) Can access all the python modules (not just the ones that jython can > access) > > Can anyone tell me what your experiences are and make a recommendation? > > Thanks, > Scott > > From jkraska1 at san.rr.com Sat Jun 16 15:00:07 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 16 Jun 2001 19:00:07 GMT Subject: Reference Counts & Extensions.. References: <6fvV6.248430$Z2.2868464@nnrp1.uunet.ca> Message-ID: >No, you must Py_INCREF(pyObj). You cannot return borrowed references; >the interpreter will decref your result when it is not longer needed, >releasing your object. This will make pyObj an invalid pointer. To the OP: BTW, it can be somewhat helpful to print the refcnt of an object when you return it from one of your modules as you are learning this stuff. Keep in mind that the number is always one higher than you'd expect, as Python has to hold an additional reference to it in order to print it. IOW, when you expect a refcnt of 1, look for 2, and so forth. After doing this a bit, you should grok the refcnt mechanism properly. C// From deltapigz at telocity.com Mon Jun 4 20:17:07 2001 From: deltapigz at telocity.com (Adonis) Date: Mon, 04 Jun 2001 20:17:07 -0400 Subject: input() is a security problem? (more) References: <9fh09b$bdp$1@news.service.uci.edu> Message-ID: <3B1C2502.6DED8EAD@telocity.com> *im a newbie so go easy on me if you know etc. or have better ways; just want to comment* found another problem with input() user can force listing of variables/modules: >>> test = input('Command ') Command dir() >>> test ['__builtins__', '__doc__', '__name__', 'myinput', 'mypass', 'n', 'p', 'x'] then as Dan pointed out before, this the user can now use input() to view variables such as passwords/usernames etc. as well as execute module commands: >>> test = input('Command ') Command sys.platform >>> test 'win32' raw_input() on the other hand is not afected by this; which couldbe an alternate or use the sys.stdin.readline() as stated by Dan Adonis Dan Stromberg wrote: > In the following program: > > #!/dcs/packages/python-2.1/bin/python > > var=12345 > > n=input('enter a number, or a variable name like "var": ') > > print n > > If one enters "var" at the prompt, one sees 12345. > > This seems to be a problem for setuid python scripts that may have > access to data, stored in variables, that the user isn't supposed to > be able to see. > > Yes, I know, use sys.stdin.readline() instead. I do. But... is > there really a good reason for input to access variables this way? It > seems an unnecessary pitfall. > -- > Dan Stromberg UCI/NACS/DCS From ChuckEsterbrook at yahoo.com Fri Jun 22 14:58:12 2001 From: ChuckEsterbrook at yahoo.com (Chuck Esterbrook) Date: Fri, 22 Jun 2001 14:58:12 -0400 Subject: Another Wart! string.find() [ was: namespace issue? ] Message-ID: <5.0.2.1.0.20010622145446.034b0e40@mail.mindspring.com> "Tim Peters" wrote in message news:... >[Chris Barker] > > Returning -1 was an unfortunate choice for two reasons: > > > > it is not a false value > > > > it is a valid index into a string >Historical note: at the time these functions were designed, negative >indices were not allowed: sequence[negative_int] raised an exception. >Allowing the latter was a later addition to the language, and was a mixed >blessing (for this and other reasons; but I think it was a net win). I would be interested to know what other things besides the -1 from find() were a minus for negative indices...? > > This is all kind of useless discussion however as string.find is > > in far too much code as it is. >Yup: learn to love it, or be killed . > > Besides, it really isn't all that bad anyway. >Indeed, *most* endless threads are about things that don't matter . That's because they are easy to talk about. ;-) I discuss such things because I'm interested in language design and Python is closest to what I would consider ideal. -Chuck From theservo at bellsouth.net Wed Jun 13 18:19:04 2001 From: theservo at bellsouth.net (Michael Davis) Date: Wed, 13 Jun 2001 17:19:04 -0500 Subject: Tkinter GUI Designer Message-ID: <8yRV6.2345$9r1.347361@e3500-atl1.usenetserver.com> I've found several GUI Designers for wxPython, but where are the TK Interface builders? From BPettersen at NAREX.com Sat Jun 16 17:02:10 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Sat, 16 Jun 2001 15:02:10 -0600 Subject: in statement and namespace type ideas Message-ID: <6957F6A694B49A4096F7CFD0D900042F27DB78@admin56.narex.com> > From: Roman Suzi [mailto:rnd at onego.ru] > > Hello, > > right now namespace handling in Python uses dicts, > however, docs say it could change. > > I can't be sure that my code which uses globals() to merge, > for example, > cgi-form variables with globals namespace will work with future Python I think this is a Perl'ism which we shouldn't repeat here (it only works if the cgi vars are valid Python vars, otherwise it will blow up rather ungracefully). > versions. There are other examples where I need to transfer some > variables from one namespace to another. Dict is good type > for namespace, > but maybe it's time to propose new mapping type - namespace - > to do things I described? > > I also thought about absent "with" operator and how it could be used > in Python. Maybe it is beneficial to have "with" syntax like in the > followin example: [snip example] > Are these ideas worth serious consideration? Perhaps, although I didn't find anything particularly compelling in your argument. Moving values from one namespace to another is easily handled by return values and assignment -- or if you're returning a large number of variables, by wrapping them in an object or a dictionary. The "with" keyword leads to a lot of implied context (especially when nested). While it may make code easier to write for a "lazy" programmer, readability and maintainability suffers. I think "explicit is better than implicit" is the better alternative here. -- bjorn From ljohnson at resgen.com Tue Jun 19 15:24:36 2001 From: ljohnson at resgen.com (Lyle Johnson) Date: Tue, 19 Jun 2001 14:24:36 -0500 Subject: Refrence Counting References: Message-ID: > Do I need to decrement the > reference count for the second dictionary below (grades)? When I use > PyStringFromString() it creates the object with a reference count of > one, then it is added to my dictionary with PyDict_SetItem() does this > increment it again? Should I create it in a seperate step then use > PyDict_SetItem() and then decrement it? A call to PyDict_SetItem(dict, key, value) increments the reference count for both the "key" and the "value", so yes, you should decrement the reference count for the "grades" object. Similarly, when you create the new string keys using PyString_FromString() I think you're probably ending up with one-too-many references for each of those, but I'm not sure how Python 2.0's new garbage collector plays into this. The online Python/C API documentation is very good about letting you know which functions return new references versus borrowed references and so on, but when in doubt I usually end up going straight to the source. In this case, the file of interest is Objects/dictobject.c. As others will tell you, the source code is extremely readable even if you're not familiar with Python's internals. Hope this helps, Lyle From mickey at aldebaran.tm.informatik.uni-frankfurt.de Tue Jun 12 04:24:53 2001 From: mickey at aldebaran.tm.informatik.uni-frankfurt.de (Michael Lauer) Date: 12 Jun 2001 10:24:53 +0200 Subject: tuples and lists in XML-RPC Message-ID: <3b25d1d5@nntp.server.uni-frankfurt.de> Good morning, I'm currently working on an OO wrapper for the great xmlrpclib from PythonWare, which allows me to instantiate classes and call methods transparently through client side proxy classes (Noone ever did this or at least I haven't found something - should I post the code to the group if I'm ready with the first version?) All seems to work great except one thing... Python tuples are converted to Python lists. I understand that this is a limitation of the xmlrpc specification which does not differentiate sequence types, but for a transparent class proxy communicating with a remote class which does not now about this, umm... feature, it is questionable behaviour. It really can make a difference returning a tuple or a list :) Currently I only see the option of extending XML-RPC to differentiate Python tuples and Python lists - and beeing no longer compatible to other XML-RPC servers which is very bad and a therefore no-no. Do you see other options or workarounds ? Yours, -- :M: -- |----------------------------------------------------------------------------| | Dipl.-Inf. Michael 'Mickey' Lauer mickey at tm.informatik.uni-frankfurt.de | | Raum 10b - ++49 69 798 28358 Fachbereich Informatik und Biologie | |----------------------------------------------------------------------------| From aleaxit at yahoo.com Thu Jun 7 04:39:42 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 7 Jun 2001 10:39:42 +0200 Subject: Why should i use python if i can use java References: <9flu5i$c61$1@news.tudelft.nl> <9fm97b05cl@enews1.newsguy.com> Message-ID: <9fnelg0t2p@enews2.newsguy.com> "Alex Martelli" wrote in message news:9fm97b05cl at enews1.newsguy.com... ... > And higher productivity. I thought I had posted a huge treatise > on that just a few hours ago to a heavily crossposted thread > with a funny subject about 3D, but it doesn't seem to have > shown up, I'll have to look into that... it mentioned Prechelt's > empirical study, quoted Eckel extensively, etc, etc. ... Seems to have disappeared, so, here we go again: > I admit, often Java is slower than C++, but whether your keystroke > will get displayed after 10ms or 20ms within a text editor doesn't > play any role, does it? It doesn't -- which is why one should use highly-productive Python (or Jython, if you prefer to have a JVM underneath -- it's the same language either way, in one case you use fine tuned C-coded libraries, in the other any Java library) for as much as possible of one's applications (typically around 90%, depending on the kind of things you do -- the other 10% [may vary from 0% to 30% on different classes of apps] is too speed-critical). > Cross-platform development and the ability to have a running BETA > program before C++ programmers even have a concept. Have a look at (a preview of) Bruce Eckel's forthcoming "Thinking in Patterns" chapter 9, e.g. at http://www.cis.ohio-state.edu/~cguo/books/ThinkingInPatterns/html/Chapter09. html (there may be better-updated versions). Eckel, of course, is quite a Java enthusiast, best-selling author of "Thinking in Java", etc, etc. He writes as the chapter's conclusion: """ To me, Python and Java present a very potent combination for program development because of Java?s architecture and tool set, and Python?s extremely rapid development (generally considered to be 5-10 times faster than C++ or Java). Python is usually slower, however, but even if you end up re-coding parts of your program for speed, the initial fast development will allow you to more quickly flesh out the system and uncover and solve the critical sections. And often, the execution speed of Python is not a problem ? in those cases it?s an even bigger win. A number of commercial products already use Java and JPython, and because of the terrific productivity leverage I expect to see this happen more in the future. """ I fully concur with his evaluation of a 5-10 times productivity advantage for Python vs C++ (speaking as a C++ expert here) -- in my (more limited) experience with Java the productivity advantage wrt C++ was about 20% to 30%, so (if this holds on a wider field of applications) the Python/Java ratio would be more like "just" 3 to 8 times the programmer's productivity. The ratio in terms of *numbers of line of code* (a VERY rough measure, but known to hold surprisingly well as a measure of "language level" -- lines of code per Function Point -- and thus, indirectly, productivity in both development _and_ maintenance phases) tends to be on the order of 5/6 times as many lines of Java (or C++, assuming one IS using rich libraries, such as those at www.boost.org, wxWindows, &c) per line of Python -- and note that Python does NOT come from a "one-liner culture" a la APL or Perl:-). Very roughly, this would seem to confirm the order of magnitude of productivity advantage (assuming speed concerns do not interfere and need re-coding of some parts, which would push development times closer together). Prechelt's empirical study (there should be more of those in this field...!-) gives more nuanced results. He grouped several language into two groups, and he only was able to observe smaller differences. http://www.ubka.uni-karlsruhe.de/cgi-bin/psview?document=ira/2000/5 is one URL where you can find the full article in several formats. Summarizing conclusions: He noticed a programmer-productivity advantage of about a factor of 2 for "scripting" (Python, Perl, Rexx, Tcl) vs "compiled" (C, C++, Java). Typical memory consumption for script about twice that of c/c++, for Java another factor of two higher than script. Initialization-phase performance, C/C++ about 3/4 times faster runtime than Java, about 5/10 compared to scripts. Main-phase performance, C/C++ about 2 times faster than Java, Scripting also faster than Java. Python and Perl always faster than Rexx and Tcl. Variation in all performance measures is larger between programmers in the same language, than between groups of programs in different languages (man still counts for more than machine:-). One little detail -- 80 programs in all were examined, all solving the same problem -- 5 in Rexx, 8 in C, ... up to 26 in Java (Java most popular). Totally unusable programs were as high as 3 in 8 submitted in C (so all the rest of the study including the above conclusion only studies the other 5:-), 3 of 14 in C++, 2 of 26 in Java. Python (0 unusable programs out of 13 that were submitted) was the ONLY language in which *NO* unusable programs were submitted. Statistical fluke, no doubt, but...:-). For performance, see in particular: http://www.ubka.uni-karlsruhe.de/cgi-bin/psview?document=ira/2000/5&format=1 &page=14 You'll see the Rexx horrid-performance is dragging down the "Script" group all by itself. Examining language by language, one can get an idea...:-). Alex (Brainbench MVP for C++, but Python enthusiast:-) From rnd at onego.ru Wed Jun 20 09:59:28 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 20 Jun 2001 17:59:28 +0400 (MSD) Subject: smtplib security risk In-Reply-To: <31575A892FF6D1118F5800600846864D78BD6E@intrepid> Message-ID: On Wed, 20 Jun 2001, Simon Brunning wrote: > > From: Roman Suzi [SMTP:rnd at onego.ru] > > No. It's a security risk. Just ALWAYS check user inputs on > > CGI or other places. Strip "../" and other things, depeding > > on what you do with your data. Etc. > > > > Even if you are the only user of your CGI, make it a habit to > > check input. It's a good habit. > > > > And your mail template is exploitable, I guess, to spam the World, > > because you direct user input into it, checking nothing. > > > Eeek! Thanks for pointing this out! > > What can be smuggled into the message parameter of a smtplib.SMTP's sendmail > method that I want to protect against? I'm not sure. Probably EndOfLine + some other field, broken <, >, ",, too lenghty field. But mostly ENDOFLINE and length. Other errors, I think, smtplib will catch. My advice was not based on certain knowledge. It's just my experience that raw input in some cases could do harm. > Cheers, > Simon Brunning > TriSystems Ltd. > sbrunning at trisystems.co.uk Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From jparlar at home.com Mon Jun 18 22:49:51 2001 From: jparlar at home.com (Jay Parlar) Date: Mon, 18 Jun 2001 22:49:51 -0400 Subject: Simple example that won't work! Message-ID: <20010619025531.YGZG4537.femail16.sdc1.sfba.home.com@jparlar> I posted this to the Python Tutor list, but wasn't really satisfied with my result. I'll just repaste it here, and hope for better luck ;-) I've been told that this list can be quite astounding, so let's see what happens :) Hello to all my fellow Python lovers. I'm only learning Python right now (after a few years working with the comparatively terrible C/C++) and I am absolutely loving it. To learn the language, I am using Wesley Chun's "Core Python Programming". It's a very good book with some really good examples, but it's with one of the examples that I'm having difficulty. The example is a simple web-based example. All it does is retrieve an HTML document, and print out the first and last non- blank lines of the page. The error, though, occurs with the urlretrieve( ) call. When I call it, I get the following exception message: Traceback (most recent call last): File "C:\Program Files\Python20\Pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript exec codeObject in __main__.__dict__ File "C:\Program Files\Python20\scripts\grabweb.py", line 37, in ? download() File "C:\Program Files\Python20\scripts\grabweb.py", line 23, in download retval= urlretrieve(url)[0] File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 68, in urlretrieve return _urlopener.retrieve(url, filename, reporthook, data) File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 198, in retrieve fp = self.open(url, data) File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 166, in open return getattr(self, name)(url) File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 267, in open_http h = httplib.HTTP(host) File "c:\program files\python20\lib\httplib.py", line 640, in __init__ self._conn = self._connection_class(host, port) File "c:\program files\python20\lib\httplib.py", line 330, in __init__ self._set_hostport(host, port) File "c:\program files\python20\lib\httplib.py", line 336, in _set_hostport port = int(host[i+1:]) ValueError: invalid literal for int(): My exact call was retval = urlretrieve(url)[0], where url is any web address. Now, the interesting thing is the code works fine on another computer it's been tried on, but no luck on mine. I'm running Win95b, with Python2.1 in the PythonWin environment. Any help would be GREATLY appreciated, Jay P. From akuchlin at mems-exchange.org Tue Jun 26 10:46:55 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 26 Jun 2001 10:46:55 -0400 Subject: zodb install problem on Windows References: Message-ID: <3dsngn1eow.fsf@ute.cnri.reston.va.us> "Neil Hodgson" writes: > Which is caused by the Unix specific: > > data_files = [("etc", ["zeo.conf"]), > ("/etc/rc.d/init.d", ["misc/zeo"]), > ("/usr/local/bin", ["misc/zeod"]), > ] > > Any ideas on how to install on Windows? I have no idea how to set up ZEO to run as a service on Windows. While that bit of code could be conditionalized to only try to install them on Unix, I haven't done so in the hopes that some Windows person will contribute patches to make it work. --amk From phd at phd.fep.ru Sat Jun 2 16:02:54 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Sun, 3 Jun 2001 00:02:54 +0400 (MSD) Subject: Sockets In-Reply-To: <3B193770.30999EAC@telocity.com> Message-ID: On Sat, 2 Jun 2001, Adonis wrote: > *newbie question* > > how can i check for errors when using the socket module? In Python, most errors reported through exceptions. Read tutorial, especially on raising and catching exceptions. > errors like: unable to connect; insufficient memory etc. But sockets (in Python) have one specially ugly feature - sometimes they hang without timeout. Use select(), or non-blocking sockets, or download timeoutsocket from http://www.timo-tasi.org/python/ Again, this module raise Timeout exception on timeout. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From Marcin.Kasperski at softax.com.pl Wed Jun 20 11:45:59 2001 From: Marcin.Kasperski at softax.com.pl (Marcin Kasperski) Date: Wed, 20 Jun 2001 17:45:59 +0200 Subject: Extremely strange problem with httplib/urllib References: Message-ID: <3B30C537.FC949A75@softax.com.pl> Gustaf Liljegren wrote: > > Python 2.1 on Win98SE: > > I have got some experience with httplib and urllib by now, but suddenly > both are causing "invalid page fault" errors in Windows. Here's all I need > to do: > > import urllib > f = urllib.urlopen('http://www.google.com') > > And the nasty error looks like this: > > PYTHON caused an invalid page fault in > module KERNEL32.DLL at 017f:bff7b992. > (...) > > Also, if I write the above script in Idle or on the command line, this > error don't appear. It's no first time problem -- I have used these modules > extensively before. Any ideas? Surely the page fault happens while some object is being destructed (idle probably keeps some objects longer, so does command line). What about taking a look at the httplib sources with special attention to cleanup procedures? Nevertheless, I would vote for some incompatibility between python and Windows libraries (like strange winsock dll) or just physical memory or disk error. But thats just an idea, I have never used python on Windows 9*... From geoff at homegain.com Wed Jun 27 15:11:39 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Wed, 27 Jun 2001 12:11:39 -0700 Subject: Windows Printing using win32print Message-ID: <393D961EA4FCD311B03F00D0B746D65803275EE6@HQSXCH01> Yes, what's being talked about in this thread is win32print. The original question, though, asked about printing using win32print, when in fact his output was not printer-ready -- it was a simple text string he was trying to write to the printer. Consequently, even though he's asking about win32print, win32print is not the most effective way to manage his output -- unless he speaks PostScript or HPL (isn't that what HP printers speak? I forget...) more fluently than he speaks Python, which I'm doubting. Hence my answer. I don't think I was misconstruing the issue; I think that the question was not closely read. Maybe I'm wrong, but the information is out there. Thanks for the pointer to the device caps stuff -- that's definitely worth looking deeper into. -----Original Message----- From: Alan Miller To: python-list at python.org Sent: 6/26/01 3:52 PM Subject: RE: Windows Printing using win32print Geoffrey Gerrietts (geoff at homegain.com) wrote: >It's funny, I was asking a question about printing thru a different >mechanism prior to this discussion coming up. I'm using the Windows GDI >calls to paint text on printer device context. > >I've been writing code to dump a simple text file to the printer. I think >that I've seen a half-dozen people talking about ways to do it, but none of >them are very simple or straightforward. Actually, I think we're talking about different things - the techniques in this thread have focused on how to dump a file (text or not, doesn't really matter) to a specified print queue without changing it in any way (as in the case where you have something generating PCL or PS and want to send it to a print queue without having to do it from a command line). What you're talking about is how to take a file, format and wrap the text, and send the resulting output to the printer - really a completely different beast. For the question of sizing, I'm not noticing any calls to GetDeviceCaps or DeviceCapabilities in your code. GetDeviceCaps can provide information on paper size and non-printable area size (at least for the top and left - not sure about ways to get similar values for the bottom and right), though it presumably works from the default tray selected in the driver. DeviceCapabilities doesn't seem to provide the info you're looking for directly, though it does return some information in a DEVMODE structure that might be useful (items like paper size). I didn't notice anything about offsets in those docs. DocumentProperties looks like a way to modify the properties for a specific print job, but doesn't have any additional information. ajm -- http://mail.python.org/mailman/listinfo/python-list From chrishbarker at home.net Fri Jun 22 12:28:17 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 22 Jun 2001 09:28:17 -0700 Subject: namespace issue? References: <87k825ljrz.fsf@elbereth.ccraig.org> Message-ID: <3B337221.B9B45DA2@home.net> Michael Powe wrote: > So now the question is, 'why'? Am I misusing the string.find() > function? Okay, string.find() returns -1 when the string is not found, > which would seem to be what I expected, a false result. Maybe python > doesn't treat -1 as false? Even if it did, you wouldn't want to do : if not s.find(): because find() returns a zero if the sting you are looking for is at the beginning of the string. Zero is definitely a false value. >>> s = "abc" >>> s.find('a') 0 so you need to test for the -1 in any case. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From amardeep at tct.hut.fi Tue Jun 5 13:07:17 2001 From: amardeep at tct.hut.fi (Amardeep Singh) Date: Tue, 5 Jun 2001 20:07:17 +0300 (EET DST) Subject: best language for 3D manipulation over web ? In-Reply-To: <3B1C9E65.B73A4FE@lmf.ericsson.se> Message-ID: On Tue, 5 Jun 2001, Attila Feher wrote: > > > Creating a perfectly secured Unix system is equally extremely hard. not if you know what you are doing > Yep, w/o the latest SP (was it 5??) for NT4 it was possible. _If_ you > were sitting next to it. Still, it is _very_ rare that a simple user > can sit next to an NT Domain Controller and start whatever he wants. > And if you can crack into an NT workstation... It is still possible > that the IT guys on the wire get alarm about every admin login :-))) and winnt is the only platform where you can get an alarm > > So the quality of this "code viewing" depends a lot on "who MS chooses" and how > > many. I still say that more people see UNIX code than MS code (I won't even > > mention LINUX here, what is seen even by normal users). And the people who are > > really interesting (hackers and crackers) will not be able to inspect the code > > of Micro$oft and point out possible problems. > > Maybe, maybe not good that many can see the source. You _never_ know > that a guy seeing it and finding something (which has about 1E-10 chance > w/o the soruces) will turn to you or start dialing and make some > money... http://www.tuxedo.org/~esr/writings/quake-cheats.html http://www-106.ibm.com/developerworks/linux/library/l-oss.html http://www.counterpane.com/crypto-gram-9909.html#OpenSourceandSecurity i cannot convince you otherwise, but perhaps you may rethink open source is not a guarantee of security, but security through obscurity idea is dumb in my regard. "...The reason the closed source model doesn't work is that security - breakers are a lot more motivated and persistent than good guys (who have lots of other things to worry about). The bad guys will find the holes whether source is open or closed. Closed sources do three bad things. One: they create a false sense of security. Two: they mean that the good guys will not find holes and fix them. Three: they make it harder to distribute trustworthy fixes when a hole is revealed." - Eric Raymond of opensource.org and quoting from "Unix System Security Tools" "At best, security through obscurity can provide temporary protection. But never be lulled by it -- with modest effort and time, secrets can be discovered. As Deep Throat points out on X-Files: "There's always someone watching."" > Blue Screen cannot come from user SW. That NT runs on a faulty or > non-supported HW or uses a badly written driver. Do any of this with a > UNIX and will get the same, but called kernel panic. and also when some part of the kernel code is badly written. and you seem to be so sure that nt kernel is so good, that it cannot cause these problems. and i wonder what happened in between, that microsoft promised that win2000 is going to be much more stable, it it actually turned out so (for my case, and several others whom i know). hardware and drivers shipped with them were same. but i admit drivers shipped by microsoft with their os did change and strangely enough, i always thought windows has much better hardware support than linux. but those machines which use to crash a lot with nt did not give any problems with linux and 2000. (i know 2000 is nt, but here i am referring to nt4 ) > > One of my friends is working in a computer company, which are offering and they > > run a WinNT web server and he told me that it crashes at least once a month, > > usually more often. The Solaris server at our university is now running for > > years and it never crashed even once. It only was rebooted to add new hardware. > > Than you must have a real good luck. I use Solaris here and I know what > I am talking about :-))) Reboot is once per day on a test machine where > "badly behaving" SW can run. i would say that you have real bad luck > Yep. First I gave up trying to use Java when I have installed the the > JRE and it crashed my whole Windows 95. I had to reinstall. interesting. but so sad that such software only exists for windows which could bring the whole machine down with it. > > China, one billion people. Computer shops in China sell Linux 200 times more > > often than Windows. The Chinese government plans to increase the usage of Linux > > even more (they don't trust Micro$oft, open source rules, as they can make sure > > there's no spyware inside). BTW downloaded distributions aren't counted here. > > Why don't they trust MS? :-))) I cannot imagine... Why should i trust M$ :-))) I cannot imagine... > > Why should 3d access "over web" to a database be limited to x86 or Windows > > users? Why can't it be for everyone? Why aren't people in China allowed to use > > it? Because you believe that you can save 5 minutes through a win-only solution > > (what is not even true)? > > Windows NT is not limited to x86... and which other platforms are supported? and finally, is this python-list or what From mal at egenix.com Fri Jun 29 10:51:04 2001 From: mal at egenix.com (M.-A. Lemburg) Date: Fri, 29 Jun 2001 16:51:04 +0200 Subject: [Python-Dev] Support for "wide" Unicode characters References: <3B3BEF21.63411C4C@ActiveState.com> Message-ID: <3B3C95D8.518E5175@egenix.com> Paul Prescod wrote: > > Slow python-dev day...consider this exiting new proposal to allow deal > with important new characters like the Japanese dentristy symbols and > ecological symbols (but not Klingon) More comments... > -------- Original Message -------- > Subject: PEP: Support for "wide" Unicode characters > Date: Thu, 28 Jun 2001 15:33:00 -0700 > From: Paul Prescod > Organization: ActiveState > To: "python-list at python.org" > > PEP: 261 > Title: Support for "wide" Unicode characters > Version: $Revision: 1.3 $ > Author: paulp at activestate.com (Paul Prescod) > Status: Draft > Type: Standards Track > Created: 27-Jun-2001 > Python-Version: 2.2 > Post-History: 27-Jun-2001, 28-Jun-2001 > > Abstract > > Python 2.1 unicode characters can have ordinals only up to 2**16-1. > These characters are known as Basic Multilinual Plane characters. > There are now characters in Unicode that live on other "planes". > The largest addressable character in Unicode has the ordinal 17 * > 2**16 - 1 (0x10ffff). For readability, we will call this TOPCHAR > and call characters in this range "wide characters". > > Glossary > > Character > > Used by itself, means the addressable units of a Python > Unicode string. > > Code point > > If you imagine Unicode as a mapping from integers to > characters, each integer represents a code point. Some are > really used for characters. Some will someday be used for > characters. Some are guaranteed never to be used for > characters. > > Unicode character > > A code point defined in the Unicode standard whether it is > already assigned or not. Identified by an integer. You're mixing terms here: being a character in Unicode is a property which is defined by the Unicode specs; not all code points are characters ! I'd suggest not to use the term character in this PEP at all; this is also what Mark Davis recommends in his paper on Unicode. That way people reading the PEP won't even start to confuse things since they will most likely have to read this glossary to understand what code point and code units are. Also, a link to the Unicode glossary would be a good thing. > Code unit > > An integer representing a character in some encoding. A code unit is the basic storage unit used by Unicode strings, e.g. u[0], not necessarily a character. > Surrogate pair > > Two code units that represnt a single Unicode character. Please add Unicode string A sequence of code units. and a note that on wide builds: code unit == code point. > Proposed Solution > > One solution would be to merely increase the maximum ordinal to a > larger value. Unfortunately the only straightforward > implementation of this idea is to increase the character code unit > to 4 bytes. This has the effect of doubling the size of most > Unicode strings. In order to avoid imposing this cost on every > user, Python 2.2 will allow 4-byte Unicode characters as a > build-time option. Users can choose whether they care about > wide characters or prefer to preserve memory. > > The 4-byte option is called "wide Py_UNICODE". The 2-byte option > is called "narrow Py_UNICODE". > > Most things will behave identically in the wide and narrow worlds. > > * unichr(i) for 0 <= i < 2**16 (0x10000) always returns a > length-one string. > > * unichr(i) for 2**16 <= i <= TOPCHAR will return a > length-one string representing the character on wide Python > builds. On narrow builds it will return ValueError. > > ISSUE: Python currently allows \U literals that cannot be > represented as a single character. It generates two > characters known as a "surrogate pair". Should this be > disallowed on future narrow Python builds? Why not make the codec used by Python to convert Unicode literals to Unicode strings an option just like the default encoding ? That way we could have a version of the unicode-escape codec which supports surrogates and one which doesn't. > ISSUE: Should Python allow the construction of characters > that do not correspond to Unicode characters? > Unassigned Unicode characters should obviously be legal > (because they could be assigned at any time). But > code points above TOPCHAR are guaranteed never to > be used by Unicode. Should we allow access to them > anyhow? I wouldn't count on that last point ;-) Please note that you are mixing terms: you don't construct characters, you construct code points. Whether the concatenation of these code points makes a valid Unicode character string is an issue which applications and codecs have to decide. > * ord() is always the inverse of unichr() > > * There is an integer value in the sys module that describes the > largest ordinal for a Unicode character on the current > interpreter. sys.maxunicode is 2**16-1 (0xffff) on narrow builds > of Python and TOPCHAR on wide builds. > > ISSUE: Should there be distinct constants for accessing > TOPCHAR and the real upper bound for the domain of > unichr (if they differ)? There has also been a > suggestion of sys.unicodewith which can take the > values 'wide' and 'narrow'. > > * codecs will be upgraded to support "wide characters" > (represented directly in UCS-4, as surrogate pairs in UTF-16 and > as multi-byte sequences in UTF-8). On narrow Python builds, the > codecs will generate surrogate pairs, on wide Python builds they > will generate a single character. This is the main part of the > implementation left to be done. > > * there are no restrictions on constructing strings that use > code points "reserved for surrogates" improperly. These are > called "isolated surrogates". The codecs should disallow reading > these but you could construct them using string literals or > unichr(). unichr() is not restricted to values less than either > TOPCHAR nor sys.maxunicode. > > Implementation > > There is a new (experimental) define: > > #define PY_UNICODE_SIZE 2 > > There is a new configure options: > > --enable-unicode=ucs2 configures a narrow Py_UNICODE, and uses > wchar_t if it fits > --enable-unicode=ucs4 configures a wide Py_UNICODE, and uses > whchar_t if it fits > --enable-unicode same as "=ucs2" > > The intention is that --disable-unicode, or --enable-unicode=no > removes the Unicode type altogether; this is not yet implemented. > > Notes > > This PEP does NOT imply that people using Unicode need to use a > 4-byte encoding. It only allows them to do so. For example, > ASCII is still a legitimate (7-bit) Unicode-encoding. > > Rationale for Surrogate Creation Behaviour > > Python currently supports the construction of a surrogate pair > for a large unicode literal character escape sequence. This is > basically designed as a simple way to construct "wide characters" > even in a narrow Python build. > > ISSUE: surrogates can be created this way but the user still > needs to be careful about slicing, indexing, printing > etc. Another option is to remove knowledge of > surrogates from everything other than the codecs. +1 on removing knowledge about surrogates from the Unicode implementation core (it's also the easiest: there is none :-) We should provide a new module which provides a few handy utilities though: functions which provide code point-, character-, word- and line- based indexing into Unicode strings. > Rejected Suggestions > > There were two primary solutions that were rejected. The first was > more or less the status-quo. We could officially say that Python > characters represent UTF-16 code units and require programmers to > implement wide characters in their application logic. This is a > heavy burden because emulating 32-bit characters is likely to be > very inefficient if it is coded entirely in Python. Plus these > abstracted pseudo-strings would not be legal as input to the > regular expression engine. > > The other class of solution is to use some efficient storage > internally but present an abstraction of wide characters > to the programmer. Any of these would require a much more complex > implementation than the accepted solution. For instance consider > the impact on the regular expression engine. In theory, we could > move to this implementation in the future without breaking Python > code. A future Python could "emulate" wide Python semantics on > narrow Python. > > Copyright > > This document has been placed in the public domain. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From robin at stop.spam.alldunn.com Wed Jun 27 01:27:02 2001 From: robin at stop.spam.alldunn.com (Robin Dunn) Date: Wed, 27 Jun 2001 05:27:02 GMT Subject: ActiveX Controls in Python References: <4dfd15be.0106261849.27d2a80d@posting.google.com> Message-ID: > I'm not very familiar with wxWindows, but I understand it's > interface is very different from that of MFC, and that it can't do > some things MFC can do, as it is a portable library, and can only > supply the common subset of functionality that is available on various > platforms. Is this correct? Yes and no. wxWindows may not have all the classes/controls/widgets that MFC does, but it is not because of common subset issues. (Although all the commonly used things are there.) MSW is the reference platform for wxWindows, meaning that most things are implemented there first, and that the MSW way of doing things is often reflected in the API. Where certain features are not available in other platforms then they are usually implemented genericly for the other platforms using wxWindows. Overall a MFC programmer will probably find wxWindows to feel very familiar, but in general easier to use. -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! From donn at u.washington.edu Fri Jun 22 12:31:02 2001 From: donn at u.washington.edu (Donn Cave) Date: 22 Jun 2001 16:31:02 GMT Subject: File name from file descriptor? References: <3B335A1E.809B3FF7@snakefarm.org> Message-ID: <9gvrs6$hn0$1@nntp6.u.washington.edu> Quoth Carsten Gaebler : | The problem is this: I have a script that is called like | | ./myscript.py < somefile | | where somefile is a text file which may or may not be gzipped. To | determine whether or not the data is gzipped I read in one byte via the | gzip module. If that raises an exception I know the data is not gzipped. | But I'd miss the first byte if it is gzipped. Yes, I could store this byte | somewhere and then pass it around somehow, but ... you know? :-) So I'd | like to open a second 'instance' of the file for reading but I only have | sys.stdin's file descriptor. The only decent way to do this is with a buffered input stream, If you could honestly say it will will always be a disk file, you could seek back to where you started after reading the header. Python's built in file object is a buffered input stream, but it's based on C library stdio and doesn't have the features you need. It would be kind of a big job to write a replacement, just for the present application, but a full replacement for the file object with more access to the buffer would be a nice addition to the standard library. Not only for "peeking" at input, but also for things like select (you want to know if there's input, but you can't tell if you have input already buffered.) Donn Cave, donn at u.washington.edu From rdsteph at earthlink.net Mon Jun 18 19:02:57 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Mon, 18 Jun 2001 23:02:57 GMT Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? References: <3B2B60AD.942719AE@earthlink.net> <9gkio3$9jcft$5@ID-89274.news.dfncis.de> Message-ID: <3B2D3975.31BF1984@earthlink.net> Is there an extensive tutorial or good documentation of wxPython on the web that one can learn from? The wxPython tutorial on the wxPython web site is quite short and is insufficient for a klutz like me. Unfortunately, the same tutorial is duplicated word for word in the Programming Python book and no more is offfered. The Tkinter chapters of various books (including Programming Python, as mentioned by Dave, thanks Dave!) are really detailed and good. That alone may help me make my decision between Tkinter and wxPython, although wxPython does seem to be well liked by those who use it. Ron Stephens Bernhard Reiter wrote: > In article <3B2B60AD.942719AE at earthlink.net>, > Ron Stephens writes: > > > I have not been successful heretonow in gui or event driven programming > > Event driven GUI programming is not really easy and the tools > available are complicated. > > > 1. Tkinter and wxPython. I have not been too successful with Tkinter, > > but I do not rule it out. I have just begun to look at wxPython. Does > > anyone think wxPython is easier to learn and use than Tkinter, or about > > the same? > > WxPython is IMO harder to learn, but offers more. > GUI kits which are conceptually easy to understand > and therefore easy to learn > are not suitable for real-life GUIs as a rule of thumb. > > WxPython also is more difficult to learn, because it is based > on a C++ class library (wxWindows). > > Having said this, I still thinkg wxPython is your best choice given > the circumstances I know. > > > 2. Boa Constructor and wxPython. I have downloaded Boa and it looks > > complicated, but I like the idea of a VisualBasic like gui designer. Is > > Boa far enough along to be used? Any comments on Boa? > > Boa is a nice piece of software but it is overly complicated. > You can use it when you know what you are doing. > So I do not recomment it for you as you are in the leaning stage. > > > 3. PythonWorks. I just downloaded the evaluation copy. OK, it costs $395, > > I stick to Free Software exclusively. > Bernhard > -- > Professional Service around Free Software (intevation.net) > The FreeGIS Project (freegis.org) > Association for a Free Informational Infrastructure (ffii.org) > FSF Europe (fsfeurope.org) From yodersc at erols.com Tue Jun 19 10:50:43 2001 From: yodersc at erols.com (GWYoder) Date: Tue, 19 Jun 2001 10:50:43 -0400 Subject: Indentation References: Message-ID: <9gnoom$cpn$1@bob.news.rcn.net> I'm still trying here is what I'm getting... Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. IDLE 0.8 -- press F1 for help >>> y = 1900 >>> leap = "no" >>> if y % 400 == 0: leap = "yes" elif y % 100 == 0: SyntaxError: invalid syntax "Chris Gonnerman" wrote in message news:mailman.992955149.25097.python-list at python.org... > ----- Original Message ----- > From: "Pilgrim" > > > > I'm new to programming so take it easy on me :-) > > > > I'm going through a book by Ivan Van Laningham and have gotten to > > indentations. In the example I'm trying duplicate he as written three > lines > > from the command prompt. After the third line is a new indentation and > then > > the next line starts back at the beginning without the command prompt >>> > > and starts with an "elif" statement. According to his tip to start a new > > line you just hit return twice when you are done with the indentation. OK > > that works fine and starts me at a new prompt >>> but when I type the next > > line starting with a "elif" statement it gives me a SyntaxError: invalid > > syntax. What I'm I missing? > > You've got it *almost* right. When you are typing a control-flow > structure at the interactive prompt, you *don't* press enter twice > before the next control-flow keyword. To wit: > > Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 > Type "copyright", "credits" or "license" for more information. > Alternative ReadLine 1.4 -- Copyright 2001, Chris Gonnerman > >>> t = 1 > >>> if t == 1: > ... print "one" > ... elif t == 2: > ... print "two" > ... else: > ... print "something else" > ... > one > >>> > > What you are doing is this: > > >>> if t == 1: > ... print "one" > ... > one > >>> elif t == 2: > File "", line 1 > elif t == 2: > ^ > SyntaxError: invalid syntax > >>> > > Pressing Enter twice ends the code block, but the if ... elif ... else > structure must not be broken up this way. > > From paulp at ActiveState.com Fri Jun 8 20:10:35 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 08 Jun 2001 17:10:35 -0700 Subject: [digression] Re: DOS Extenders (was: RS232 support for DOS on 486?) References: Message-ID: <3B21697B.E933DE79@ActiveState.com> Oleg Broytmann wrote: > >... > The best known DOS Extender was PharLap, but it had the problem that it > didn't support DPMI. Without support of proper standard it failed. > The second best known was DOS/4G, created by Rational Systems. I asked > Google where it is now - and hurray! - it is now at http://www.tenberry.com/. > Its primary compiler was Watcom C: http://www.tenberry.com/dos4gw/. I worked at Watcom at the time and we thought of DOS/4GW as the DOS extender we licensed rather than our compiler as their "primary compiler". Remember that the compiler had to be a 32-bit compiler so you didn't really have a lot of choices. It is also worth pointing out (though I'm sure you already know) that Rational Systems is unrelated to today's Rational -- the UML etc. guys. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From nas at python.ca Tue Jun 5 12:41:35 2001 From: nas at python.ca (Neil Schemenauer) Date: Tue, 5 Jun 2001 09:41:35 -0700 Subject: why huge speed difference btwn 1.52 and 2.1? In-Reply-To: <3b1bcf7a.12528354@news.ccs.queensu.ca>; from rsenior@hotmail.com on Mon, Jun 04, 2001 at 06:22:00PM +0000 References: <9f8fgs$ooo$1@knot.queensu.ca> <9fdjsc$pn4$1@panix2.panix.com> <3b1bcf7a.12528354@news.ccs.queensu.ca> Message-ID: <20010605094135.A3896@glacier.fnational.com> Your problem is likely that you are re.search() in a loop. In Python 1.5.2 re.search() was a C function. In 2.1 it is a Python function. Using the pcre.search() function should get your program up to speed. Alternatively, you could revise your program. It is quite inefficient. This (untested) version should be faster: import re states = { 'ALABAMA':'AL', 'ALASKA':'AK', 'ARIZONA':'AZ', 'WISCONSIN':'WI', 'WYOMING':'WY'} def main(): state_pat = "|".join(states.keys() + states.values()) # not sure about the characters separating states, guessing state_re = re.compile(r"\b(%s)\b" % state_pat) for year in range(1994, 1998): f = open('states/USA%s.TXT' % year) counter = 1 while 1: print year, counter counter = counter + 1 #convert city name to allcaps (db outputs in allcaps) line = f.readline().upper() #check for EOF if not line: break for state in state_re.findall(line): filename = states.get(state, state) # use abbrevation g = open('states/%s/%s.TXT' % (filename, year), "a") g.write(line) g.write("\n") g.close() f.close() main() From Randy.L.Kemp at motorola.com Thu Jun 7 09:12:11 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Thu, 7 Jun 2001 08:12:11 -0500 Subject: WHY is python slow? Message-ID: So many factors, they are too long to mention. Machine you are running on. Operating system. Other processes or programs running. Termites chewing on the computer circuits. Maybe your watch has stopped. The Zen nature of interpreters. -----Original Message----- From: Oleg Broytmann [mailto:phd at phd.fep.ru] Sent: Thursday, June 07, 2001 3:22 AM To: Python Mailing List Subject: Re: WHY is python slow? Q: Why is python slow? A: Why is the sky so green? Why is water so dry? Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From thomas at xs4all.net Sat Jun 9 18:04:52 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 10 Jun 2001 00:04:52 +0200 Subject: termios, Python 2.1 and 1.5.2, AIX and SCO In-Reply-To: ; from mkent@atlantic.net on Thu, Jun 07, 2001 at 12:04:16PM -0700 References: Message-ID: <20010610000452.C690@xs4all.nl> On Thu, Jun 07, 2001 at 12:04:16PM -0700, MikeK wrote: > Building Python 2.1 on aix-4.3-2.1, with termios turned on in Modules/Setup, > results in undefined symbol errors for 'VDISCARD' and 'VWERASE'. This problem is fixed in 2.1.1 and 2.2, neither of which are released yet. You can grab the working tree of 2.1.1 from the CVS tree (cvs co -rrelease21-maint) or fix the bug yourself; you have to change #ifndef VDISCARD to #ifdef VDISCARD in termiosmodule.c, and similar for VWERASE. The 2.1.1 CVS branch should be pretty stable (it contains only bugfixes) but it hasn't been tested yet, and it isn't ready to be released yet (still have a couple of bugfixes to backport, and I want to give people some more time to find bugs too, on platforms untested up to now :) > Building Python 1.5.2 on SCO Open Server 5, with termios turned on, yields > echoing passwords. Hmm. Upon further investingation (browsing the > getpass.py source code), we found that the configure script believes this > platform to be sco_sv3, and that the necessary file > Lib/plat_sco_sv3/TERMIOS.py was missing. Running the 'regen' script in > that directory created TERMIOS.py, which allowed a build of python with > termios turned on. However, when testing getpass, it would now generate > a termios.error exception. From investigating this (debugging termios.c), > we determined that a call to tcsetattr was returning an error code and > setting errno to 22 (Invalid argument). > We gave up at that point. Well, I had to work on SCO Open Server (3) once. I gave up way earlier, and I wasn't even trying to compile anything. > Wasn't one of the selling points of Python the ability to write code that > would run on multiple platforms? Yes, but you hit one of the least portable aspects of any program. I'm afraid you also hit the Open Source barrier: noone tested Python on a SCO Open Server 5, and none of the developers have access to such a box, and noone volunteered any information about SCO Open Server 5, so we don't know anything is wrong, let alone what is wrong or try to find out. > Does anyone have any suggestions on how we can overcome these problems, > the desired result being non-echoing passwords done in a portable manner? You can try to find out why the tcsetattr is returning an errorcode. Maybe the termios module calls it the wrong way ? The wrong arguments ? Maybe you need special privileges to set such a mode ? -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From gustafl at algonet.se Tue Jun 26 12:59:57 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 26 Jun 2001 16:59:57 GMT Subject: Adding unknown variables to time.mktime() References: Message-ID: gustafl at algonet.se (Gustaf Liljegren) wrote: Sorry all, I made a syntax error (left out the two extra parenteses), but it was good to see some examples. As Roman wrote, you only need the six first: >>> t = time.mktime((1999,1,1,1,1,1,-1,-1,-1)) >>> time.ctime(t) 'Fri Jan 01 01:01:01 1999' I figured that it would be nice if you could leave out as many as you wished, from right to left. Maybe mxDateTime can do handle that? Oviously mktime can't: >>> t = time.mktime((1999,-1,-1,-1,-1,-1,-1,-1,-1)) >>> time.ctime(t) 'Thu Oct 29 22:58:59 1998' Should have been 'Fri Jan 1 00:00:00 1999'. >>> t = time.mktime((1999,1,-1,-1,-1,-1,-1,-1,-1)) >>> time.ctime(t) 'Tue Dec 29 22:58:59 1998' Should have been 'Fri Jan 1 00:00:00 1999'. >>> t = time.mktime((1999,1,1,-1,-1,-1,-1,-1,-1)) >>> time.ctime(t) 'Thu Dec 31 22:58:59 1998' Should have been 'Fri Jan 1 00:00:00 1999'. >>> t = time.mktime((1999,1,1,1,-1,-1,-1,-1,-1)) >>> time.ctime(t) 'Fri Jan 01 00:58:59 1999' Should have been 'Fri Jan 1 01:00:00 1999'. >>> t = time.mktime((1999,1,1,1,1,-1,-1,-1,-1)) >>> time.ctime(t) 'Fri Jan 01 01:00:59 1999' Still a second from the thruth. :-) >>> t = time.mktime((1999,1,1,1,1,1,-1,-1,-1)) >>> time.ctime(t) 'Fri Jan 01 01:01:01 1999' Yes! Anyway, thanks again. This is what I need at the moment. Regards, Gustaf Liljegren From charlie at charliedyson.net Sun Jun 17 16:07:20 2001 From: charlie at charliedyson.net (Charlie Dyson) Date: Sun, 17 Jun 2001 20:07:20 +0000 Subject: Global Namespace References: <9gim6l$2in$1@s1.uklinux.net> <3B2CF3C5.A2E9F6A7@nospam.de> Message-ID: <9giv4m$lfd$1@s1.uklinux.net> Uwe Hoffmann - nospam at nospam.de wrote on Sunday 17 June 2001 18:15: > Charlie Dyson wrote: >> >> This question either has a simple answer, or there is no way to do this >> at the moment. I want to be able to set a variable in the global >> namespace to a given value. Easy? What if all you have is a string >> containing the name of the variable. I need a pointer to the global >> namespace. So >> >> class MyClass: >> def mymethod(self, varname, varvalue): >> setattr(pointer_to_global_namespace, varname, varvalue) > > i think you can use: > globals()[varname] = varvalue > instead of setattr(....) >> >> m = MyClass() >> m.mymethod('var', 'ASDF') >> print var # Should print 'ASDF' >> >> Any ideas? Is there a __builtins__ funtion that provides a >> reference/pointer/whatever you call it to the global namespace. >> >> Thanks in advance, >> >> Charlie Dyson - charlie at charliedyson.net > Thanks, that's exactly what I wanted to know - the existance of the globals() fuction. This should solve some problems for me. As you can probably tell, I haven't been using Python for very long. (Also, I recently discovered I can use nested functions PHP style - is this a new feature?) Thanks again, Charlie Dyson - charlie at charliedyson.net From mrm677 at yahoo.com Tue Jun 12 17:09:05 2001 From: mrm677 at yahoo.com (Mike) Date: 12 Jun 2001 14:09:05 -0700 Subject: Learning OOP... References: <9fm8ti$d92$1@newshost.accu.uu.nl> <503ca784.0106112030.3d434e08@posting.google.com> Message-ID: JAVA is *not* a very good general-purpose language IMHO. The Java Virtual Machine is just not efficient and is not integrated well enough into operating systems such as Windows. How many applications, besides Java IDE's, are actually in widespread use? I believe Corel actually tried to sell a Java-based Wordperfect Office, but it flopped. JAVA has its uses, but not for general-purpose development. It is also quite complex to learn and use. I'll admit that the language is very elegant, too elegant. Just to open a file and read strings, I need several classes (InputStream, FileBuffer, etc, etc, etc)!!! To write an application in Java requires nearly as much code as C++. It is just too low-level, yet tries to be high-level at the same time! Sure, C++ allows an incompetent programmer to make many mistakes that are fool-proof in Java such as memory leaks and bad pointer use. Java is attempting to make a low-level language fool-proof, which to me is an oxymoron. You claim that JAVA reduces development time through the use of garbage collection. This is true even for competent C++ coders. However, if you are that concerned about development time, then you are better off using a RAD tool such as Visual Basic or Python. Python is a wonderful language. If you are doing high-level work where speed is *not* important, than Python and equivalents are your best choice. Why use Python instead of Java for general-purpose development? How do you distribute your Java applications besides through the WWW? If the JVM where truly integrated into Windows, then this wouldn't be a problem and I wouldn't be making these claims. But it is not. If you are doing industrial-grade applications, or work where speed is crucial, then compiled languages such as C and C++ are your best bet. Java just can't compare in terms of speed and memory usage. The *only* place where JAVA fits in is for special circumstances such as the WWW and maybe for servlets. Regards, Mike C++/Python coder ex-Java Coder steven_shaw at users.sourceforge.net (Steven Shaw) wrote in message news:<503ca784.0106112030.3d434e08 at posting.google.com>... > Java is the language that best suits your requirements. > > 1. OOP and "business/enterprise oriented" > 2. A good career move! > 3. Code reuse - I guess so > 4. Debugging tools - free IDEs JBuilder and Forte > 5. Strong typing no generics - use GJ for generics in Java > 6. Java is pretty easy to learn - a no brainer. Perhaps > not quite as easy to earn as Python. > 7. Reduced development times could come from Java's > automated garbage collection. > 8. Java is portable and scalable? > 9. There's so much Java open source code available it's not funny. > http://jakarta.apache.org/ http://enhydra.org/ > http://exolab.org/ http://jacorb.org/ > 10. Source code is familiar (to C/C++ programmers, anyway) and > easy to read. > 11. Many Java tools are free - like the JDK. The compilers are > ok but you can't seem to get a free native compiler just yet. > gcj is on the way. JVMs are freely available for most platforms. > > You've not mentioned performance as a criteria - otherwise my > recommendation would have been made more difficult :-) > > Perhaps you are not elucidating some requirements that led you to > think of ADA? Perhaps that language is used widely in your industry? > > Java can be used effectively with Jython for the things you decide > it's best you don't have strong typing. Understand that the > edit/compile/run turnaround can sometimes slow down development when > using Java (compared to using Python/Jython). Using an IDE such as > JBuilder or Forte should help with this problem. From aleaxit at yahoo.com Fri Jun 15 08:15:38 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 15 Jun 2001 14:15:38 +0200 Subject: Python 2.0.1c1 - GPL-compatible release candidate References: Message-ID: <9gcu9u070s@enews1.newsguy.com> "Will Ware" wrote in message news:GEyxz9.A81 at world.std.com... ... > all that, but I think it's possible to release a program > simultaneously under multiple licenses, allowing a recipient Isn't this what Perl is doing, for example (GPL and Artistic License)? Alex From kvdwalt at csir.co.za Tue Jun 5 03:13:06 2001 From: kvdwalt at csir.co.za (Karel van der Walt) Date: Tue, 5 Jun 2001 09:13:06 +0200 Subject: Python for win32 development, GUI, Database, dlls Message-ID: <9fi0rm$hpv$1@newnews.mikom.csir.co.za> I have been approached in a 'time to market situation'. Python appears to me to be a strategic choice, however: this is a number crunching application most numeric stuff in existing (fortran) dll the new development will entail a lot of visualization, pseudo GIS like, animation (coloring of contours), plain media (digital picures, video) in a rich interactive GUI then all of this data in MS Access (what else?), with reports and graphs on top of it. OK the latter can be in a reportwriter as long as one can call an .exe with commandline parms from python) Integration with MS Office formats (not ole automation) would be important (thus MS Access for imports exports). Any grave misgivings? Any pointers? Commercial libraries? However the exchange rate doesn't favour that :( tx k From m.faassen at vet.uu.nl Fri Jun 15 15:22:49 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 15 Jun 2001 19:22:49 GMT Subject: Any other Python flaws? References: Message-ID: <9gdna9$61k$5@newshost.accu.uu.nl> "Tony J Ibbs (Tibs)" wrote: > Alex Martelli wrote: >> Nah, that's what print>>blah is for:-). > Ah, but (erm, you *are* in Italy[1], aren't you?) I quite like "print >>>"... > Tibs > [1] i.e., a long way away and thus not within reach (of course, you > *might* be in the PSU and then even distance wouldn't prevent me from > bein He's one of the PSU's 3 known bots, so I'd be careful. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From no at spam.com Thu Jun 28 08:13:23 2001 From: no at spam.com (MDK) Date: Thu, 28 Jun 2001 08:13:23 -0400 Subject: Simple question (launch a program) Message-ID: <9hf6v6$ps0$1@taliesin.netcom.net.uk> Hi, I'm on a Win2K platform. I'm sure that this has been asked before but when I do a search on the internet I get back too many irrelevant hits because of the keywords. Anyways, how do I launch a program that is in a directory with long file names? Thanks. From sandorlevi at yahoo.com Mon Jun 18 14:07:37 2001 From: sandorlevi at yahoo.com (Levente Sandor) Date: 18 Jun 2001 11:07:37 -0700 Subject: COM method with pointer args References: <8b5e42a6.0106171630.43a3303a@posting.google.com> <9gkek6024kl@enews2.newsguy.com> Message-ID: <8b5e42a6.0106181007.187e176d@posting.google.com> "Alex Martelli" wrote in message news:<9gkek6024kl at enews2.newsguy.com>... > > Is there a possibility to use a COM method which requires pointer > > arguments? > > Sure, as long as you have a type library that is correct. Make > sure your Python client IS using the type library, e.g. by using > win32all.client.gencache.EnsureDispatch(...) > rather than > win32all.client.Dispatch(...) Now I get the following error: "TypeError: This COM object can not automate the makepy process - please run makepy manually for this object" When I try to use a method (with args as values) listed in the COM browser, it works, but the class in the generated source contains no methods: # This CoClass is known by the name 'CorelDraw.Automation.7' class CDrawAutomate(CoClassBaseClass): # A CoClass CLSID = pythoncom.MakeIID("{F1ABEC21-2037-11CF-AB99-00C0F00683EB}") coclass_sources = [ ] coclass_interfaces = [ '{07D2C782-8802-11CF-AB9D-00C0F00683EB}', ] default_interface = '{07D2C782-8802-11CF-AB9D-00C0F00683EB}' Other suggestions? Thanks in advice, Levi From James_Althoff at i2.com Thu Jun 21 13:41:18 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Thu, 21 Jun 2001 10:41:18 -0700 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) Message-ID: Thanks, thanks, and thanks! Jim gmcm at hypernet.com (Gordon McMillan) To: python-list at python.org Sent by: cc: python-list-admin@ Subject: RE: Meta: PEP discussion (was Re: PEP 255: Simple python.org Generators) 06/20/01 07:48 PM [posted and mailed] James Althoff wrote: >.... Meanwhile, does anyone know where to find python-iterators and >how to read or subscribe? Is there an archive? Yes, yes and yes. - Gordon Oh, OK. http://sourceforge.net/mail/?group_id=5470 If you poke around, you can find a link on python.org. -- http://mail.python.org/mailman/listinfo/python-list From glenfant.nospam at bigfoot.com Wed Jun 20 12:05:13 2001 From: glenfant.nospam at bigfoot.com (Gilles Lenfant) Date: Wed, 20 Jun 2001 18:05:13 +0200 Subject: Help installing pygtk, libglade in Windows - please References: <9gqd28$j36$1@nntp6.u.washington.edu> Message-ID: <9gqhad$8so$1@norfair.nerim.net> Try "regsvr32.exe" from command line DOS shell. Without arguments, it shows the command line options. "Frank Miles" a ?crit dans le message news: 9gqd28$j36$1 at nntp6.u.washington.edu... > I'm trying to install pygtk and libglade on a Win9x system. The local > Windows guy advises me that it is necessary to edit the Windows registry > to install DLLs. Is this truly the case with the DLLs associated with > these? Unfortunatley I don't have the tools to build for Windows, so > was trying to use the binaries built for Windows; but these don't seem > to have any installers. I've tried editing a setup.py written for another > program so that I could use distutils, but this hasn't worked. > > Take pity on a Linux guy (it's _so_ much easier and simpler there)! > I'm developing my app on Linux, but (sigh) others in my organization > run Windows, and they have to be able to use it too... > > Thanks for your help! > > -frank > -- From samschul at pacbell.net Mon Jun 4 01:40:41 2001 From: samschul at pacbell.net (Samuel Schulenburg) Date: 3 Jun 2001 22:40:41 -0700 Subject: Controlling CDR drives using Python in Windows References: Message-ID: Carlos Ribeiro wrote in message news:... > I'm looking for information on how to control a CDR drive from Windows, > using Python scripts, of course. I'm planning to automate my home backups > using Python scripts. If someone has any information on how to make it > work, I'll be glad to know. > > JFYI, I tried to find information over the web on CDR API. Most of the > information that I found was either commercial, incomplete or it was vendor > specific. Even at http://www.cdrfaq.org/ - the wealth of information is > immense, but software list seems to cover only commercial or outdated > offerings (I'm still to check them all). That's why I'm asking on the group. > > > Carlos Ribeiro I sent you a long message discribing how you can use ASPIPython to execute write and read commands to a CDR. ASPIPython can be obtained at: http://starship.python.net/crew/samschul/ If anyone else wants a copy of the text I sent Carlos, email me at samschul at pacbell.net Samuel Schulenburg From bsass at freenet.edmonton.ab.ca Wed Jun 20 15:07:14 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Wed, 20 Jun 2001 13:07:14 -0600 (MDT) Subject: Any other Python flaws? In-Reply-To: Message-ID: On 20 Jun 2001, Remco Gerlich wrote: > Tiago Henriques wrote in comp.lang.python: > > Another annoying missing feature is the absence of command line editing in the > > python shell. Perhaps now that the license has been made gnu-compatible it will > > be possible to ship python pre-compiled with the readline library, instead of > > having to compile python yourself. I have compiled python with readline support > > myself, and it's pretty easy, but for the average user who is afraid of makefiless > > and compilations, it would be extra-nice if python were a bit more user-friendly > > out-of-the-box. > > This isn't good, because readline is under the GPL. The only thing that the > GPL compatibility means is that people are allowed to distribute a version > of Python with readline compiled in - *under the GPL*. > > Python licensed under the GPL would be bad - it couldn't be embedded in > non-GPL projects anymore. That is not true. The GPL can not infect your non-GPLed software just because you use GPLed software in your project -- even Debian (the pickiest group I know of) would reject the GPL as non-free if that was the case. You can not tweak GPLed code then re-license it, it should always be GPLed. You can ship someone elses GPLed code with your project, as long as you make the source (including the source of any tweaks you made) available. You can link your non-GPLed code to GPLed code without getting special permission from the copyright holder, but there is a grey area if the GPLed stuff was not originally intended to be linked to; this is where KDE was most recently having GPL troubles, RMS's opinion was that intent was important and the discussion pretty much ended. So... If you want to use someone's GPLed lib, or GPLed software that exposes its libs APIs so others can make use of it, in your proprietary project, make sure you release the source for the libs you used and for any tweaks you may have made to it. If you are thinking of *ripping* some pieces out of a GPLed program and hacking them into your program, then releasing _only_ the source for the GPLed stuff... hope you still got an asbestos suit kicking around. I'm no fan of the GPL, and IANAL, just a Debian user who has taken an interest in licensing issues (maybe it has something with me also being a Pine, KDE, and Python user ;)... but I don't see any reason to fear the GPL, keep it at arms length maybe, but not fear and avoidance. Have a look in the "non-free" section of one of the http://packages.debian.org archives, you will find non-GPLed stuff that depends on GPLed code (probably most of it!) - Bruce From bill-bell at bill-bell.hamilton.on.ca Thu Jun 21 17:29:58 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Thu, 21 Jun 2001 17:29:58 -0400 Subject: Python COM: Unable to create server-side object. In-Reply-To: <993150760.1809.21435.l10@yahoogroups.com> Message-ID: <3B322F16.16830.1D33EA5@localhost> arisen at start.no (Andr?) wrote: > Hi. Something strange is happening to in my Python / COM > recently (ActiveState Python 2.0 on Win2K). I have created > this small class in the file short.py: > > class Short: > _reg_clsid_ = "{74471ADF-9453-4135-87E6-22E1B9499B0D}" > _reg_progid_ = "Python.Short" > _reg_desc_ = "PythonCOM test" > _public_methods = ["isShort"] > > def __init__(self): > self.short = "yes" > > def isShort(self): > return self.short > > if __name__=="__main__": > import win32com.server.register > win32com.server.register.UseCommandLine(Short) > > And registered it succcessfully. ($ python short.py) > > When i try > >>> import win32com.client > >>> s = win32com.client.Dispatch("Python.Short") > > I get the following error: > (-2147221231, 'ClassFactory cannot supply requested class', None, > None) > > If i try it again i get another: > (-2147467259, 'Unspecified error', None, None) > > I have tried with diffeetn class names, prog ids and clsids. > > This used to work fine, and i have written several com servers > in python before which still work. Any ideas? Andr?, I added debugging to your code in the following way: debugging = 1 class Short: _reg_clsid_ = "{74471ADF-9453-4135-87E6-22E1B9499B0D}" _reg_progid_ = "Python.Short" _reg_desc_ = "PythonCOM test" _public_methods = ["isShort"] def __init__(self): self.short = "yes" def isShort(self): return self.short if __name__=="__main__": import win32com.server.register win32com.server.register.UseCommandLine(Short, debug=debugging) This gives the following diagnostic output in the "win32trace remote collector". Object with win32trace dispatcher created (object=None) Traceback (most recent call last): File "c:\python21\win32com\server\dispatcher.py", line 27, in _CreateInstance_ self.policy._CreateInstance_(clsid, reqIID) File "c:\python21\win32com\server\policy.py", line 200, in _CreateInstance_ self._wrap_(myob) File "c:\python21\win32com\server\policy.py", line 448, in _wrap_ raise error, "Object does not support DesignatedWrapPolicy" win32com.server.policy error: Object does not support DesignatedWrapPolicy Traceback (most recent call last): File "", line 1, in ? File "c:\python21\win32com\client\__init__.py", line 94, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "c:\python21\win32com\client\dynamic.py", line 81, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "c:\python21\win32com\client\dynamic.py", line 72, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147467259, 'Unspecified error', None, None) Any use to you? (Incidentally, I did this in Win95 with newly installed ActiveState distribution, installed this morning.) Bill From mcfletch at home.com Fri Jun 15 01:35:13 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Fri, 15 Jun 2001 01:35:13 -0400 Subject: Python 2.0.1c1 - GPL-compatible release candidate In-Reply-To: Message-ID: <000001c0f55c$f3e7e070$a9807018@cr706570a> To clarify (because I seem to be confused): This is a GPL-compatible release, not a GPL release. That is, you could include a copy of python with your GPL program, but Python itself is not GPL-d because it can be acquired without agreeing to the GPL (from Guido). So unless, for some reason, you need to use a modified version of the "xxobject.c and xxmodule.c" files, which are only available from a GPL-d derived work, your python extension would not be GPL tainted, as you could use the less restrictive python license for those files. You should be able to distribute your extension under whatever license you like. When building GPL applications, however, you would have to consider the license of the whole work. To distribute a GPL application (using python extensions) as GPL-ware, you would need to make sure all the extensions are GPL-compatible (i.e. that you can provide the source with the restrictions/permissions required by the GPL). From what I understand, you need either to have been merely be aggregated with the system, or be able to produce source etc. without further restrictions than those seen in GPL works. Forcing all extensions to be GPL-compatible is not something I think Guido (or anyone) is really looking to impose on extension writers. Enjoy, Mike -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Will Ware Sent: June 15, 2001 00:51 To: python-list at python.org Subject: Re: Python 2.0.1c1 - GPL-compatible release candidate Guido van Rossum (guido at digicool.com) wrote: > With a sigh of relief I announce Python 2.0.1c1 -- the first Python > release in a long time whose license is fully compatible with the GPL Congratulations to you and to Moshe! I know this has been something you've wanted to do for a while. Just to make sure I understand the way GPL coverage extends to derived works, here is what I think is true. Python scripts and programs are not derived works, and are only GPL-ware if their author or copyright holder declares them to be so. C extensions (the kinds of things I get by cutting and pasting from xxmodule.c and xxobject.c) *are* derived works, and the GPL coverage of 2.0.1 would therefore cover them as well, should I choose to distribute them. One thing I don't know is whether *any* C extensions to 2.0.1 would be derived works. If I'm such a Python-extension-writing guru that I don't need to cut and paste from xxobject.c and xxmodule.c, then it seems unlikely my extensions would be derived works, especially if they are legacy things from one of the pre-GPL Python versions. The same would be true of SWIG-generated extensions, I would imagine. But the GPL extends its coverage not only to derived works in the obvious sense, but also to code which is statically linked with a GPL program. If my extensions are statically linked to 2.0.1, then by that criterion they would also be GPL-ware. I don't know if the same is true of dynamically-linked extensions. Have I got any of that right, or should I go back on my meds now? -- -----------------------------------+--------------------- 22nd century: Esperanto, geodesic | Will Ware domes, hovercrafts, metric system | wware at world.std.com -- http://mail.python.org/mailman/listinfo/python-list From paula at merns.com Tue Jun 26 15:17:00 2001 From: paula at merns.com (paula at merns.com) Date: Tue, 26 Jun 2001 19:17:00 -0000 Subject: MySQLdb module & error capturing Message-ID: <9han3c+htuv@eGroups.com> I'm a little bit of a newbie so if this belongs on another list let me know. I am trying to capture a _mysql.OperationalError that is returned by the MySQLdb module so that I can process it through error handling. Or even just print out the one bit (the error number and the error text) with out having the 5 layered traceback message showing every layer of my program. Sample error at bottom. I have tried looking at the MySQLdb module and I have not noted direct error passing back to the calling program from the C API. Anyone else know the answer? I have been looking at the traceback module but I don't know enough about it to really figure this out. Thanks for your help, Paula ****Sample Code >>> causeerror=decur.execute("select everything from everywhere") Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.1/site-packages/MySQLdb.py", line 190, in execute return self._query(query) File "/usr/local/lib/python2.1/site-packages/MySQLdb.py", line 290, in _query rowcount = self._BaseCursor__do_query(q) File "/usr/local/lib/python2.1/site-packages/MySQLdb.py", line 235, in __do_query db.query(q) _mysql.OperationalError: (1146, "Table 'ZimbuT.everywhere' doesn't exist") From godofall at iwon.com Sat Jun 2 10:02:15 2001 From: godofall at iwon.com (Virtual Viki) Date: Sat, 02 Jun 2001 14:02:15 GMT Subject: best language for 3D manipulation over web ? References: Message-ID: An apllet by itself will render incredibly slow... Anyone who says differently hasn't really done it. JAVA awt and swing are very slow at drawing them selves. You best bet is to use the applet with the java 3D API's to use Open GL. The down side is the client will need some form of Open GL on the machine. Not usually a problem though. Most new machine have it. Oh... and all you anti Cross - Post fanatics out there chill out!!!!!!!!!!!!! e-commerce/Internet privacy and security is an illusion. Its all public whether we like it or not. "Jacqueline L. Spiegel" wrote in message news:PctR6.3$jC6.216 at typhoon.nyu.edu... > > Hi All, > > I will be writing a program that needs to be accessible over the web that > will seek to manipulate objects in three dimensions through the access of an > oracle database. I could be manipulating as much as 32 MB of memory (with > respect to data only) in space. I would also need to slice and > interpolate information on the fly. I am a Java programmer, but my fear is > that Java is not as fast as it should be in order to handle such > manipulation (assume users have at least a T1/cable modem connection, and > are not going in by 56K modem) > > What is the best language for this ( I will need to do GUI programming as > well). > > Although I am really comfortable with Java and prefer to go this route, I am > wondering if there is a better and faster way (I feel that Java is slow in > general, even for 2D). If you recommend another language, can you please > recommend which 3D library and GUI library that I would use, as well as > explaining how I (or the language's API) connects to the web browser ? I > am not experienced with "Applet" creation outside of the Java language. > > You attention is greatly appreciated with regard to this matter. > > CC-ing email to jackie at popmail.med.nyu.edu, would also > be greatly appreciated. > > Jacqueline > > > From bbollenbach at homenospam.com Sat Jun 30 10:37:57 2001 From: bbollenbach at homenospam.com (Brad Bollenbach) Date: Sat, 30 Jun 2001 14:37:57 GMT Subject: Python compiler References: Message-ID: <9vl%6.741$847.192645@news1.rdc1.mb.home.com> Python's newsgroups are known for being exceedingly newbie-friendly. However, the issue of compiling Python is brought up /far/ too often. Consider reading the FAQ. Had you done that, you'd not have asked this question. "Eric Merritt" wrote in message news:mailman.993870107.10231.python-list at python.org... > Hello All, > > I am new to python after having converted from java. > One of the problems I always had with java was the > lack of a native code compiler. Will python ever have > one of these? I have seen references to projects such > as py2c etc, but they all seem dead. Is there an > inherent problem in creating a compiler for python or > is it just very difficult. Unfortuanatly I am not a > big compiler guru though I would be willing to help if > I could. Just curious. > > > __________________________________________________ > Do You Yahoo!? > Get personalized email addresses from Yahoo! Mail > http://personal.mail.yahoo.com/ > From pehr at alum.mit.edu Thu Jun 28 01:07:32 2001 From: pehr at alum.mit.edu (pehr anderson) Date: Thu, 28 Jun 2001 05:07:32 GMT Subject: wxPython or Java References: Message-ID: <3B3ABB9A.916A1759@alum.mit.edu> There is a tool for wxPython called Boa Constructor. Boa provides cross-platform point-and-click GUI construction for applications written in python. I have heard very good things about it. Someone in my company http://eink.com held a class teaching people how to use Boa, jzalesky at eink.com. Read more and see the screenshots a the Boa webpage: http//boa-constructor.sourceforge.net/ -pehr Andrew Todd wrote: > > Quoting Patrick Kirk: > > >Is this point and click type GUI creation possible with > >wxPython? I have Visual C++ but want the application to > >be portable. Is there a web tutorial on how to do this? > > I don't know if it is possible in wxPython, but I do know > that it is tremendously easy in Java. Since you aren't bent > on using Python, you might want to consider Java. It would > provide the portability you are looking for. > > Normally I wouldn't recommend Java, but I wrote something > about a year ago that seems very similar in only a few > pages of code. If you're interested I can send you the > source. > > -Andrew at wm.edu From phd at phd.fep.ru Wed Jun 6 06:51:54 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Wed, 6 Jun 2001 14:51:54 +0400 (MSD) Subject: ExtensionClasses for Python 2.1? In-Reply-To: <6564c76c.0106060233.100516da@posting.google.com> Message-ID: On 6 Jun 2001, Wolfgang Lipp wrote: > Does anyone know whether Jim Fulton of Zope's ;-) > ExtensionClass module is available for Python 2.1 Yes. Zope 2.4 will require Python 2.1, hence EC will be updated. DC already released Zope 2.4.0 alpha1, so you can look there. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From XQ.Xia at ccsr.cam.ac.uk Wed Jun 6 09:18:17 2001 From: XQ.Xia at ccsr.cam.ac.uk (XiaoQin Xia) Date: Wed, 06 Jun 2001 14:18:17 +0100 Subject: Can python clear two object cited each other? Message-ID: <3B1E2D99.8ED4DE6A@ccsr.cam.ac.uk> An HTML attachment was scrubbed... URL: From James_Althoff at i2.com Mon Jun 18 17:19:29 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Mon, 18 Jun 2001 14:19:29 -0700 Subject: why is there no class (static) methods in Python ? Message-ID: Carel Fellinger wrote: >Alex Martelli wrote: >> "Richard Gruet" wrote in message >> news:3B2D114E.7B39D954 at intraware.com... >... >>> class C: >>> def staticFoo(x): print x >>> >>> C.staticFoo(1) > >> http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/52304 > >according to the faq there is an even shorter spelling of this idiom: > >class Callable: > def __init__(self, callable): > self.__call__ = callable > >this works as the magic method transformation only applies to >class-functions, not to instance-functions. > >To me this spelling of the idiom is a tad more readable, besides it >being more efficient as it saves one method call. Note that this "faq/recipe/trick" (ugly and awkward as it might be) -- though doing a reasonable job of emulating C++ and Java-style "static" class methods -- does not provide "complete-functionality" class methods (a la Smalltalk) in that it is missing the "override" mechanism (because there is no "self" -- meaning the class object -- argument in these "static" class methods). IOW, if one of these "static" class methods calls another "static" class method and you want to inherit/reuse the first and override the second, you have a problem (the same problem you have if you use a module function as a "poor man's" class method). Jim From tim.one at home.com Fri Jun 29 00:25:11 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 29 Jun 2001 00:25:11 -0400 Subject: PEP scepticism In-Reply-To: <9hfg1n$du33c$1@ID-89274.news.dfncis.de> Message-ID: [Bernhard Reiter] > This a general warning against the second system syndrom in Python. > > Maybe I am a hypocritical sceptic, but I have the impression that > some feeping creatureism is introduced into Python. These are different issues to me: while feature bloat is a symptom of Second System Syndrome, the latter goes much deeper than *just* the former. > This might reduce the main advantage of Python to be clear and easy > and mostly have one good formulation on how to express what you want > to program in a structured way. While I expect everyone would agree those are advantages of Python, I doubt there's consensus that those 4 advantages are "the main" advantage. Language design is more complex than that. > Examples are: > - augmented Assigments > - Lists comprehensions > - Simple Generators Two of those were widely debated over the course of a decade, and augmented assignments in particular were "approved" in the mid-90's, just awaiting someone to implement them. They aren't legitimate examples of Second System Syndrome, in part because of that: they aren't examples of the system designer taking large leaps of faith on untested and unreviewed ideas. They're features you may or may not like, but they're *just* features, and isolated features at that. If you want a SSS *prospect* to worry about, try PEPs 252 through 254 inclusive: rethinking the type/class system from scratch is a radical change affecting every corner of the language. I'm more uncomfortable about that than about all preceding changes combined, and real-life experience with "the metaclass hook/hack" is too spotty to make a case that we really know the ultimate effects of these changes. Push ahead anyway, and *that's* SSS material -- possibly. Nothing else even gets close to it. > ... > On the other the sum of language constructs is growing and harder to > understand as a complete system. Not even Scheme stayed *braindead* austere forever, you know . BTW, I agree with Paul that this has nothing to do with the PEP process. In fact, the decisions to add the three features you named were made before PEPs existed. What the PEPs did in these cases was gather and organize the (sometimes ancient) c.l.py threads in which they were first debated. python-today-is-still-guido's-first-python-design-ly y'rs - tim From GADGILP at INFOTECH.ICICI.com Tue Jun 19 02:03:49 2001 From: GADGILP at INFOTECH.ICICI.com (GADGIL PRASAD /INFRA/INFOTECH) Date: Tue, 19 Jun 2001 11:33:49 +0530 Subject: SNMP OIDs for Cisco 6509 & Cable Modems Message-ID: <718A0962DFC2D4119FF80008C7289E4701A0214A@ICICIBACK3> hi, r u sure, u have checked, cisco site has loads of mib files, few months back, when I needed to do something similar, I downloaded an MIB browser (I used demo version of mg-soft, it's good one), loaded the cisco mib downloaded from their site, and I could browse the mib tree visually, get, walk etc.. Once sure, which var u want to check, u can then use the numeric oid in your code. Also check www.snmplink.org for some of the very good related links. /prasad -----Original Message----- From: Benjamin Schollnick [mailto:junkster at rochester.rr.com] Sent: Tuesday, June 19, 2001 5:09 AM To: python-list at python.org Subject: SNMP OIDs for Cisco 6509 & Cable Modems Folks, I'm working with the PySNMP software, which doesn't yet handle MIB -> OID conversion.... So I'm a little stuck, I'm having difficultly tracking down the actual numeric OID's for a Cisco 6509 & Industry Standard Cable Modems. Does anyone know how to generate the numeric OID's or where I can look up the Numeric OID's? I found several lists on Cisco's web site, but the 6509 is returning that the OID's are not in it's MIB file.... I can do a SNMPwalk fine on the Cisco 6509, but I'm not positive that will corespond with the OID's I downloaded from Cisco... (I haven't had a chance to compare yet). Help? - Benjamin -- http://mail.python.org/mailman/listinfo/python-list . -------------- next part -------------- An HTML attachment was scrubbed... URL: From jkraska1 at san.rr.com Sat Jun 9 14:13:10 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 09 Jun 2001 18:13:10 GMT Subject: is c faster? References: <9ftlpv029hk@enews2.newsguy.com> Message-ID: <8up4itsoj32nj3kjhiipal0s09660c51k2@4ax.com> >Depending on several factors, recoding a good Pythonic design >into a finely tuned C extension can give you a speed up as small >as 20% (I've never seen anything less than that, though I guess >it's possible) and as big as 1,000%, i.e., 10 times faster (again, >I haven't seen anything more than that on real code, although in >this case it's easy to do even better for code that a C optimizer >can optimize down to nothing, as is true of many benchmarks:-). > >Does anybody have substantially different experiences...? Not really, no. I often get about a factor-of-6 speed up or so for the things that I choose to externalize. This does, of course, imply a certain amount selection bias on my part. On a more general level, one should generally only select to externalize functions which are "computationally intense". Frequently invoked functions with low computation time won't generally benefit much from externalization, because of the Python interpreter dispatch overhead. This often applies to simple O(n) operations where n == 2000 or more; for example, I would not expect a simple linked list to outperform a python "list" (i.e., vector) on insert until n >= 2000 or more. C// From aahz at panix.com Tue Jun 12 16:36:24 2001 From: aahz at panix.com (Aahz Maruch) Date: 12 Jun 2001 13:36:24 -0700 Subject: Future floating point directions? [was Re: floating point in 2.0] References: <9g5ks0$2q5h$1@agate.berkeley.edu> Message-ID: <9g5ug8$h78$1@panix6.panix.com> In article <9g5ks0$2q5h$1 at agate.berkeley.edu>, Edward Jason Riedy wrote: >And Tim Peters writes: > - > - IBM's Standard Decimal Arithmetic Proposal requires user-settable precision > - (akin to, e.g., x86's "precision control" fpu bits) as part of numeric > - context, and it's also a puzzle how to work that into Python smoothly. > >It's a puzzle how that proposal fits into anything other than >Rexx smoothly. Actually, it fits into Python *extremely* smoothly, thanks to the wonders of module-level namespaces. The tricky part is handling it under threading. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista gfarber: Thank God, or the belief system of your choice. pddb: Does human perversity count as a belief system? From oblivious at web.de Sat Jun 16 09:35:23 2001 From: oblivious at web.de (Dominic) Date: Sat, 16 Jun 2001 15:35:23 +0200 Subject: qt or gtk? References: Message-ID: <3B2B609B.285DCB06@web.de> Rainy wrote: > I want to learn python gui programming in linux. I think tk looks too ugly, so > I narrowed down the choice to two main contenders, qt and gtk. Which of these > has more complete and up-to-date python bindings? Are there other reasons > to prefer one of these over another for python gui work? > The QT toolkit is technically better (quality of code). So some time has passed since I had compared them. But I do not know how good or bad the bindings are. I suggest you should use the tk toolkit it seems to have a good binding and comes with the standard python distribution. And the TCL/TK toolkit has a high quality. So TK would be best in my humble opinion, and QT second. (QT is not completely free but that doesn't make it bad, actually it's the best X- Toolkit for C++ programming.) Ciao, Dominic > > -- > "Your password must be at least 18770 characters and cannot repeat any of your > previous 30689 passwords. Please type a different password. Type a password > that meets these requirements in both text boxes." > (Error message from Microsoft Windows 2000 SP1) From ajm at enteract.com Tue Jun 26 18:52:29 2001 From: ajm at enteract.com (Alan Miller) Date: Tue, 26 Jun 2001 17:52:29 -0500 Subject: Windows Printing using win32print References: Message-ID: Geoffrey Gerrietts (geoff at homegain.com) wrote: >It's funny, I was asking a question about printing thru a different >mechanism prior to this discussion coming up. I'm using the Windows GDI >calls to paint text on printer device context. > >I've been writing code to dump a simple text file to the printer. I think >that I've seen a half-dozen people talking about ways to do it, but none of >them are very simple or straightforward. Actually, I think we're talking about different things - the techniques in this thread have focused on how to dump a file (text or not, doesn't really matter) to a specified print queue without changing it in any way (as in the case where you have something generating PCL or PS and want to send it to a print queue without having to do it from a command line). What you're talking about is how to take a file, format and wrap the text, and send the resulting output to the printer - really a completely different beast. For the question of sizing, I'm not noticing any calls to GetDeviceCaps or DeviceCapabilities in your code. GetDeviceCaps can provide information on paper size and non-printable area size (at least for the top and left - not sure about ways to get similar values for the bottom and right), though it presumably works from the default tray selected in the driver. DeviceCapabilities doesn't seem to provide the info you're looking for directly, though it does return some information in a DEVMODE structure that might be useful (items like paper size). I didn't notice anything about offsets in those docs. DocumentProperties looks like a way to modify the properties for a specific print job, but doesn't have any additional information. ajm From kawakami at lead.dion.ne.jp Fri Jun 15 02:55:18 2001 From: kawakami at lead.dion.ne.jp (Toshiya Kawakami) Date: Fri, 15 Jun 2001 15:55:18 +0900 Subject: get class instance from C++ extension? Message-ID: <8kiW6.41$%3.2442@news3.dion.ne.jp> I am trying to call extension C++ modules from embedded python, and want to know how to return a class (instance) defined in python from C++ to caller in python. I know some examples that show C++ returns an integer to python, but they don't explain about returning a class. What I want to do is something like following codes. How can I return a same information with a python class from C++? ----begin of "test1.py" import myext1 class c1: a1 = 1 a2 = 2 def m1(): return a1 + a2 ### this is ordinary way to get instance of class c1 as x. x = c1() ### I want to call C++ extension and get calss c1 instance to y y = myext.meth1( 5, 6, 7.2 ) ### and want to print attributes of the got y. print y.a1, y.a2, y.m1() ----end of "test1.py" ----begin of ext1.cpp (fragment) #include "python.h" struct PyMethodDef ext1_methods[] = { { "meth1", meth1, METH_VARARGS }, { NULL, NULL } }; aaaa{ ::Py_Initialize(); ::PyImport_AddModule( "myext1" ); ::Py_InitModule( "myext1", ext1_methods ); char *filename1 = "test1.py"; if ( ( fp = fopen( filename1, "r" ) ) == NULL ) { ... } ::PyRun_SimpleFile( fp, filename1 ); } static PyObject * meth1( PyObject *self, PyObject *args ) { char *command; int sts; if ( !PyArg_ParseTuple( args, "iif", &i1, &i2, &f1 ) ) return NULL; // // do something here using i1, i2, f1. // // This example returns an integer to python. // I want to return not an integer but the same structure with // the class c1 defined in test1.py file. How can I do that? return Py_BuildValue( "i", 0 ); // <--- this is not what i want to do } ----end of ext1.cpp (fragment) From joonas.paalasmaa at nokia.com Tue Jun 19 04:22:51 2001 From: joonas.paalasmaa at nokia.com (Joonas Paalasmaa) Date: Tue, 19 Jun 2001 08:22:51 GMT Subject: Getting all client http headers Message-ID: <3B2F1A51.EC21BD1C@nokia.com> How can I get all client http headers in python. Can I use cgi-module? -Joonas From aahz at panix.com Mon Jun 11 09:43:40 2001 From: aahz at panix.com (Aahz Maruch) Date: 11 Jun 2001 06:43:40 -0700 Subject: What version of python is the right version? References: Message-ID: <9g2huc$qpe$1@panix2.panix.com> In article , Fredrik Steen wrote: > >What version of python should I use for new projects? >1.5.2, 2.0, 2.1? The only really good reason for using 1.5.2 or 2.0 is because you intend to distribute your project to people or machines that can't esily be upgraded. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista gfarber: Thank God, or the belief system of your choice. pddb: Does human perversity count as a belief system? From sholden at holdenweb.com Tue Jun 26 09:12:07 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 26 Jun 2001 09:12:07 -0400 Subject: FAQ Wizard more broken than I thought ... Message-ID: When I (eventually) got a reply to my web request for the python FAQ wizard, it was this: Proxy Error The proxy server received an invalid response from an upstream server. The proxy server could not handle the request GET /cgi-bin/faqw.py. Reason: Could not connect to remote machine: Connection timed out ---------------------------------------------------------------------------- ---- Apache/1.3.9 Server at www.python.org Port 80 I suspect something is broken, but it's beyond my reach to fix it. Sigh, another job for PythonLabs. Won't it be wonderful when everything is once more under sensible, central, control. regards Steve -- http://www.holdenweb.com/ From info at andreas-hollmann.de Fri Jun 1 13:31:15 2001 From: info at andreas-hollmann.de (Andreas Hollmann) Date: Fri, 1 Jun 2001 19:31:15 +0200 Subject: Comparison of Python with PHP and Perl? Message-ID: <1euc8he.1cjkokotbhi1wN%info@andreas-hollmann.de> I wrote some easy scripts in Perl and PHP4 and are interested in Python. OK, Perl works, but I for me it is too circumstancial. I like PHP4, but theres no port for my old Mac wich is not able to run the new OS X. I've seen that a Python-Binary for old Macs exists and this could make Python interesting for me. Question: Is Python able to integrate its code int HTML-Files like PHP does or must Python-Scripts be extra files like Perl-Scripts? Andreas From Randy.L.Kemp at motorola.com Thu Jun 7 16:38:32 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Thu, 7 Jun 2001 16:38:32 -0400 Subject: Windows editor? Message-ID: I will check it out. -----Original Message----- From: Eugene.Leitl at lrz.uni-muenchen.de [mailto:Eugene.Leitl at lrz.uni-muenchen.de] Sent: Thursday, June 07, 2001 3:07 PM To: Kemp Randy-W18971 Cc: python-list at python.org Subject: Re: Windows editor? Kemp Randy-W18971 wrote: > > Ultra Edit (www.ultra.com) with the macro extension developed for Python is > great, and only $30. You have to download the free Python, macro extension. http://www.xemacs.org runs on a variety of platforms, Winders included (drag and drop possible there). Does many languages, including Python. It's great, and only $0. Minus download dineros, if any. ______________________________________________________________ ICBMTO : N48 10'07'' E011 33'53'' http://www.lrz.de/~ui22204 57F9CFD3: ED90 0433 EB74 E4A9 537F CFF5 86E7 629B 57F9 CFD3 From cyberlync at yahoo.com Sat Jun 30 12:21:22 2001 From: cyberlync at yahoo.com (Eric Merritt) Date: Sat, 30 Jun 2001 09:21:22 -0700 (PDT) Subject: Discussions and developing In-Reply-To: Message-ID: <20010630162122.16760.qmail@web13005.mail.yahoo.com> Mr. Bollenbach your basic assumption here seems to be that python does not need to worry about newbies, or that this list is not the proper forum for their questions. The first case not really feasible in the long term. As you must realize Python needs new blood to grow and mature, that is, unless you want it to become stagnant like Common Lisp is now. The second case may be true, the solution there may be that there needs to be a python newbies list or some such, this seems to be a common solution. In any case, you cannot just decide that new users ask stupid questions and they need to go away. Are these types questions unproductive? it depends on how you are looking at it. If the list is dedicated to development of the python language, yes absolutely they are unproductive. If the lists are dedicated to python, then these questions, that help incubate new users, are very productive. They help newbies get familiar with python and get past the newbie stage to the point that these once-newbies can start contributing to the language. Ensuring pythons future developer base is not counter productive. --- Brad Bollenbach wrote: > Though I haven't really followed the PEP discussions > on c.l.p, realize that > the development of any large software project > involves spending most of > one's time figuring out: > > a.) What the problem /is/ that you're trying to > solve, making sure that > you're solving the right problem and not, in fact, > missing a potentially > deeper issue. > b.) An efficient, maintainable, solid and > hopefully "correct" solution > to the problem. > > If someone truly believes they have a strong > argument either for, or against > a PEP, they are being equally as productive in > voicing that to the core > developers as they would be hacking out their own > programs. > > OTOH, the unproductive posts are those that > continually ask things like: > > 1.) "Can Python be compiled?" (You mean, you > didn't realize that an FAQ > would probably answer this?) > 2.) "What's the best GUI development environment > for Python?" (The best > answer you could possibly get would be subjective > and again, this is > obviously FAQ'ish) > 3.) "Python vs. XYZ -- What should I chooose?" > (Remember...you're asking > that q to a /Python/ newsgroups, what do you THINK > you should choose?) > 4.) "Why use whitespace?" (Why use $'s, @'s, and > %'s? Why use {}'s? Why > use ;'s? Why not force functions to have prototypes? > Why is the default pass > by reference/value? Why is assignment a statement? > Why doesn't VB have > closures? Why use "."/"+" for string concatenation? > Why didn't you read the > FAQ before you asked?) > 5.) etc. > > The "average" Python hacker is supposedly smarter > than the "average" > Perl/Tcl/VB/Delphi/Powerbuilder/ > programmer. Yet I feel > every time one of those threads starts (as in, 2-3 > times/day) we're spinning > our wheels. The more I read this newsgroup, the more > I question the almost > overly newbie-friendly attitude it takes. > > Worry about fixing those types of problems first, > not about the PEP > discussions. > > "Roman Suzi" wrote in message > news:mailman.993850065.18441.python-list at python.org... > > Hello, > > > > you, like myself, read (and write) to this > mail-list/usenet group devoted > > to our beloved Python. > > > > We generate several megabytes per month. > > > > Python code (src) is 15-20 Mb. > > > > So, we could type one Python per 2 months. (Well, > if we count quoting, > > probably in 6 months, but still impressive > figure). > > > > Just why reacting to PEPs and accusations/opinions > in newsgroup is more > > attractive than writing good piece of code for > library, for some > > interesting Open Source project? (Am I alone or > others also experience > > this temptation?) > > > > Lets imagine that 1/3 of the letters to c.l.p is > converted to useful > > Python code. But no! It's far more interesting to > react to yet another > > PEP! > > > > And this happens because > reacting/disputing/flaming/... is a (small) fight > > between human beings and not between human being > and dumb machine which > > need to be coded. > > > > May be, with time some kind of > subject-against-subject programming > > technique will be invented, I dunno, and disputes > will create not > > only tryth but quality code. > > > > I do not know how to convert my recent c.l.p. > addiction into something > > useful for all. (if I only new how to be > productive after full-time > > work...) > > > > So, I personally decided to shut up and not to > participate in prolonged > > PEP discussions where no special protest must be > expressed. This will > > be better for everyone, including myself. > > > > Lets silence for 1 day in memory of Jim Ellis, one > of the Usenet > > creators, who died 28.6.2001. > > > > Sincerely yours, Roman Suzi > > -- > > _/ Russia _/ Karelia _/ Petrozavodsk _/ > rnd at onego.ru _/ > > _/ Friday, June 29, 2001 _/ Powered by Linux > RedHat 6.2 _/ > > _/ "I failed attitude in school." _/ > > > > > > > > > -- > http://mail.python.org/mailman/listinfo/python-list __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ From piet at cs.uu.nl Mon Jun 18 09:27:12 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 18 Jun 2001 15:27:12 +0200 Subject: pygimp on windows References: Message-ID: >>>>> bobnotbob at byu.edu (Bob Roberts) (BR) writes: BR> Well, it has been a while since anybody appears to have asked this BR> question. Has anybody out there gotten gimp-python working in any BR> form for windows? You can download it (for Python 2.0) from http://hans.breuer.org/ports/ -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From kirk at strauser.com Tue Jun 19 11:40:21 2001 From: kirk at strauser.com (Kirk Strauser) Date: 19 Jun 2001 10:40:21 -0500 Subject: Python version of IQ has been updates (IQ v0.34.python) References: <505.566T11T1243597threeseas@earthlink.net> <3B2A7F5E.MD-1.4.4.padf@ihug.com.nz> <3871.567T2214T9794928threeseas@earthlink.net> <87puc3ao42.fsf@pooh.honeypot> <2509.568T2823T9766233threeseas@earthlink.net> <9gkftm026v9@enews2.newsguy.com> <87k829ai6y.fsf@pooh.honeypot> <9gnkp00o7f@enews2.newsguy.com> Message-ID: <87g0cwqxzu.fsf@pooh.honeypot> At 2001-06-19T13:40:46Z, "Alex Martelli" writes: > "Kirk Strauser" wrote in message >> Perl's RE syntax is designed by and for people who have pretty much >> mastered the subject elsewhere. > And where would that "elsewhere" be? College, for starters. I had a solid grip on RE's before I ever met Perl. Note that I'm not asserting that *my* experience implies similar results for anyone else. >> Then again, I'm more experienced with C, C++, Java, and other similar >> languages. > More experienced than whom? You read that wrong - the proper question is "more experienced than at what?", to which the answer would be myself at Ada, FORTRAN, Lisp, ML, etc. Perl was comfortable to me because of my particular background. I picked it up because 1) it's what we use at the office, and 2) for whatever reason, it was an easy step for me. >> You can write C in Perl if you feel comfortable with it. > Not really, since for example in Perl all your variables need > a leading '$' which C does not require... I understand what you're saying, and I wouldn't hope to imply that Perl is exactly like C. However, the following (working) code snippet should be transparent to the casual C coder: $seconds = time(); printf("%d seconds since the epoch!\n", $seconds); Sure, there are fundamental differences, but a non-Perl coder could probably maintain the lines above if they had to. >> They are also similar to the `perlcc' command that ships with Perl 5.005 >> and higher. Specifically, perlcc generates C source that, when compiled, >> acts exactly like the original Perl. > Is the Perl 5.6 manual page wrong, then? It says: > """ > The whole compiler suite (`perlcc' included) should be considered very > experimental. Use for production purposes is strongly discouraged. I don't think our statements are contradictory. perlcc generates C code, and it is currently experimental; those states can co-exist. Note that I did not pass judgement on perlcc's usability. I merely stated that it currently exists and is shipped with the main Perl distribution. >> Same with Perl. Use the appropriate class, create a URL-fetch object, >> then execute it. Read the results just like any other filehandle. > It's not quite the same, if you need to do three steps in one case and one > in the other, although it's no doubt close. OK, skip the creation step and call the functions directly. Honestly, Alex, I never meant to disparage Python in any way. Although I haven't personally used it, people I trust claim that it's a great language. I just happened to have a lot of Perl experience, and someone asked a question for which my answer was "try Perl!". I respect that your answer is different, just as mine may very well be in the future. -- Kirk Strauser From slaytanic_killer at disinfo.net Sat Jun 23 20:58:18 2001 From: slaytanic_killer at disinfo.net (slaytanic killer) Date: 23 Jun 2001 17:58:18 -0700 Subject: How useful do you find the interactive interpreter? Message-ID: <4688f24b.0106231658.43d2c446@posting.google.com> Hi, I am looking at Python seriously, and I can see that the interpreter would be really good for testing out ideas. Getting small things to work and then switching over to a text editor to generalize what I've learned. Is this how people generally use it? Or is it an even deeper part of coding? Thanks. From whisper at oz.nospamnet Fri Jun 22 13:11:13 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 22 Jun 2001 17:11:13 GMT Subject: ANNOUNCE: The Neophyte Pythoneers List References: Message-ID: <9gvu7h$n2e$2@216.39.170.247> In article , michael+gnus at trollope.org says... > [posted and mailed] > >>>>> "Jesse" == Jesse W writes: > Jesse> I have just now created a mailing list via Yahoo for > Jesse> the sharing, joint debugging and general discussion of > Too bad, those people are idiots. You should try setting it up on > your own if you have the resources (like a DSL/cable connection). I The other thing about Yahoo mail lists is that i'm pretty sure you end up as spam bait per their usage policies, although i'm not sure. More to the point, something really smells when one has to register merely to read discussions that the offerer does not own. Dave LeBlanc From me at mikerobin.com Wed Jun 20 19:31:26 2001 From: me at mikerobin.com (Michael Robin) Date: 20 Jun 2001 16:31:26 -0700 Subject: Which IDE ? References: <3B308FE8.282BD41@bt.com> Message-ID: <52e5ab5f.0106201531.23013645@posting.google.com> I don't think there's anything wrong with wanting a powerful IDE - just because you are an experienced programmer doesn't mean you never progress beyond booting your system with toggle switches. I haven't found one py dev sol'n for all purposes. (Not that one exists - but I'd like to get to the 80% stage...) I use: - PythonWin for interactive prompts and debugger-assisted debugging. Good if you like the MDI interface. Also good to launch into the reference docs from your code. - Scite for editing. (Slightly prefer editor to PW's for some reason.) Scite is good for "printf" style debugging as it can launch your app and has an output window. It's also good for "detached" debugging, seeing it doesn't get in the way of GUI event loops, etc. Really fast. - Komodo. Until recently this was too slow to use, but on my new P-III, it's more usable. I've also had some stability problems, but if things keep getting better, this could be a contender for frequent use. I tried: - PythonWorks. It was slow as well, and personally I don't like the interface. I'll go w/*nix on the server side, but currently my preferred workstation platform is win2k, so I like a windowsy feel. PW's interface is just "weird" to me, and doesn't have good keyboard shortcut support and OS drag&drop, etc. As it's not politically correct to care about these features anyway, and it's a cool and capable product - you should see if you like it. (I reserve the right to change my mind on a whim anyway...) Things I haven't tried: - Wing IDE (on my list to try) - BoaConstructor (doesn't look quite ready yet) - BlackAdder (I don't have interest in Qt right now.) - VisualPython for Visual Studio.NET (don't have .NET tools) Some of the above also have GUI painters and are usually (always?) specific to one GUI. Some are free, some are $$, but all at least have free demos. Just my $.02 mike Alan Gauld wrote in message news:<3B308FE8.282BD41 at bt.com>... > D-Man wrote: > > On Tue, Jun 19, 2001 at 05:57:00PM +0100, phil hunt wrote: > > | I think professional programmers often prefer simple tools (i.e. > > | text editor and command line). > > > > Sounds like a reasonable guess to me (at least wrt Unix programmers, I > > think more MS Windows programmers use Visual Studio and other similar > > tools). > > Yeah, thats one of the big culture differences between the > two groups. When we get a "Windoze guy" on contract who is > freaked by the *nix approach I usually explain it by says > that the OS *is* the IDE. Its just because Windows doesn't > provide the basic tools built ij that you have to use an IDE > to make up the difference. Stop thinking of the Unix tools > as separate programs and see the whole system as a big > textual based IDE and it starts to make sense. > > Alan G From jm7potter at hotmail.com Wed Jun 13 18:49:55 2001 From: jm7potter at hotmail.com (jm7potter at hotmail.com) Date: Wed, 13 Jun 2001 18:49:55 -0400 Subject: a newbie question about gadfly References: <9g7ter$iqo$1@plutonium.compulink.co.uk> Message-ID: <6drfitothr5ialqrtl9uvn9453hkf7cv66@4ax.com> On Wed, 13 Jun 2001 17:53:29 -0400, "Steve Holden" wrote: > wrote in message >news:pn7fitoa7n6u47atng7tv0n9aroc1716ic at 4ax.com... >> On 13 Jun 2001 14:30:51 GMT, gbreed at cix.compulink.co.uk wrote: >> Is there a way to explicity kill a specific application in windows? tia, christian From sholden at holdenweb.com Mon Jun 11 23:56:59 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 11 Jun 2001 23:56:59 -0400 Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: <200106112007.f5BK7eW22506@odiug.digicool.com> Message-ID: "M.-A. Lemburg" wrote in ... > Guido van Rossum wrote: > > > > Please comment on the following. ... > > > > PEP: 259 > > Title: Omit printing newline after newline [ ... ] > > Wouldn't it make sense to only use this technique in inter- > active mode ? > Blerch! I'm agin differences between the behavior of the interpreter interactively and non-interactively. Reminds me of various Unixoid filters whose code is full of "am I reading from a pipe" questions. Also, since interactive mode is so useful for development of code which then gets grafted into programs it would be confusing to have different behaviors in two modes. Or am I missing the point? regards Steve From mwh at python.net Mon Jun 18 15:04:48 2001 From: mwh at python.net (Michael Hudson) Date: 18 Jun 2001 20:04:48 +0100 Subject: += overloading? References: <3b2e3554$0$331$8eec23a@newsreader.tycho.net> Message-ID: "Neil Macneale" writes: > I am using a list as the data holding element, then appending to it in > the __iadd__ function. Then I use ''.join(list) to make a string > when the __str__ function is called. I am doing this to minimize the > number of string objects created, and figure that append runs in > constant time. Is join optomized though? Yes. Well, fairly. > It would defeat the purpose if join worked by creating a new string > to join the first two, then added the third, etc. I am assumming > that join is implemented in C, and runs in 0(n) time, where n is the > number of total characters. Am I assuming incorrectly? No, you've got it about right. > I looked at string.py's join function, but that just called another > join method, and I don't know where that one is implemented. You should be looking in Objects/stringobject.c, the function called "string_join". It's significantly easier to read (and less buggy) in 2.1 than 2.0, and a little faster. Cheers, M. -- It's a measure of how much I love Python that I moved to VA, where if things don't work out Guido will buy a plantation and put us to work harvesting peanuts instead. -- Tim Peters, comp.lang.python From emile at fenx.com Fri Jun 29 21:10:43 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 29 Jun 2001 18:10:43 -0700 Subject: Not enough Python library development [was PEP scepticism] References: <3dy9qalxii.fsf@ute.cnri.reston.va.us> Message-ID: <9hj974$e6ant$1@ID-11957.news.dfncis.de> Paul, This is very cool! Thanks. What are the criteria for including a group in here? How often are they updated? In particular, it looks like you've got most of the Python, Zope and ActiveState groups, but I note several MIAs, eg: pybsddb, ZODB, wxPython, etc. I see you've even got the newly created PythonCard group in there. Google-search-without-the-dash-monty-with-the-mailling-lists-ly y'rs -- Emile van Sebille emile at fenx.com --------- "Paul Prescod" wrote in message news:mailman.993856425.27427.python-list at python.org... > > I agree. We've decided at ActiveState to try and push the penny ahead a > few inches by the O'Reilly Open Source conference. We're working on a > minimalist repository that can evolve into the repository of our dreams. > It isn't a trivial job but we can at least leverage some of our existing > security infrastructure, proficiency with Zope, etc. One good example of > what our web team has put together is here: > > http://aspn.activestate.com/ASPN/Python/Mail > > I find these archives to be better than other Python archives available > on the Web. Consider this feature: > > http://aspn.activestate.com/ASPN/Mail/Leaders/python-dev/ > > We hope to do the same thing with module repositories. We'd also like to > integrate some of the security, commenting, rating and reviewing > features from the Python cookbook: > > http://aspn.activestate.com/ASPN/Cookbook/Python > > But this is mostly a spare-time project because it is not product -- so > I don't want to lift expectations too high...we're doing what we can do > just like any other contributors to open source. Nevertheless, I have > high hopes that we can plant the seeds and the community will help us > harvest. > > I'm holding a BOF on the topic at the O'Reilly conference (just like at > the last Python conference) and we'll share our progress and see what > other people are up to. > -- > Take a recipe. Leave a recipe. > Python Cookbook! http://www.ActiveState.com/pythoncookbook > From see at my.signature Tue Jun 12 01:44:49 2001 From: see at my.signature (Greg Ewing) Date: Tue, 12 Jun 2001 17:44:49 +1200 Subject: Dictionary comprehension References: <9fog99$gis$1@tyfon.itea.ntnu.no> Message-ID: <3B25AC51.35310A2F@my.signature> Magnus Lie Hetland wrote: > > inverted = {dict[key]:key for key in dict} If the for key:value in dict syntax ever got approved, this would look really nice: tcid = {val:key for key:val in dict} Almost a palindrome... :-) -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From spam_kill.guse at hobbiton.org Wed Jun 6 12:54:38 2001 From: spam_kill.guse at hobbiton.org (goose) Date: Wed, 06 Jun 2001 16:54:38 GMT Subject: best language for 3D manipulation over web ? References: <3b1cdc84.5514@bolder.com.co.za> <9fleid$3rp$1@oslo-nntp.eunet.no> <3B1E4951.7F36D4E4@alcyone.com> <3B1E50E1.35AE59C@lmf.ericsson.se> <3B1E52DA.BBC9FC32@alcyone.com> <3b1e5601.3970@bolder.com.co.za> <3B1E5836.E7F1D88F@lmf.ericsson.se> <3b1e5b50.3adb@bolder.com.co.za> <3B1E5D5C.7878FC9E@lmf.ericsson.se> Message-ID: <3b1e604e.3c17@bolder.com.co.za> Attila Feher merely scratched his head and went: > goose wrote: >> LOL - neither do they eat quiche ... > > Opps. Here is one of the many points my English knowledge ends. What > is quiche? > if you do a search on the net for "real programmers don't use pascal", u'll find out ... it's very funny ... -- goose ----- " as a matter of fact, I don't find it very funny that this guy has posted the same joke twice in 2 days...... it's bad enough when other people steal jokes off each other but when you rip off your own jokes there's something wrong with you " --atj, cillian on about BretMS From jm7potter at hotmail.com Fri Jun 29 20:53:17 2001 From: jm7potter at hotmail.com (Joe Potter) Date: Fri, 29 Jun 2001 20:53:17 -0400 Subject: newbie with major "lambda" problem (perhaps a scope problem as well) References: <37hmjtk186jsm8k8j0tcq9rvae37mpjb3s@4ax.com> Message-ID: On Fri, 29 Jun 2001 16:44:19 -0700, "John Roth" wrote: >If I understand what you want to do, you want a scrolling panel at the >top, and three command buttons below (or above) the panel, right? >The issue here is that the buttons' action procedures need access to >the class instance, so they should go inside the class. That means the >buttons themselves should go inside the class. > >That means you need to build everything inside the class. In other words, >you can't build the pmw.ScrollingFrame (or whatever) outside it, and then >use the frame for the contents. You need to build it at the same level >as the buttons and the data fields, which means inside the class. > >There's nothing wrong with building two (or more) levels of widget in the >same class. You just need to insure that things nest neatly. > >John Roth > Ah so --- ah so --- ah so !!! Thanks John. I have 5 books on Python, including one on just Python and Tkinter and not a word on this fact! Well, unless I missed it, which is not unlikely at all. Since the buttons will scroll out of view if I use them in the pmw.ScrollingFrame --- heck I can use key bindings and just say to heck with the buttons. Problem solved! Thanks greatly for this tip. Perhaps you should think of doing a book. Warmest Regards, Joe From gerhard.nospam at bigfoot.de Fri Jun 22 17:11:53 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Fri, 22 Jun 2001 23:11:53 +0200 Subject: [OT] MS EULA -- (will ActiveState become outlaws? ;-) References: <3B32F81F.259DBA46@chello.nl> Message-ID: On 22 Jun 2001 08:50:31 -0700, Samuel Schulenburg wrote: >I work for a company that has a license from Microsoft to use >Windows2000 as the OS for one of our products. As a result of the >licenseing agreement, I can not use Python on any of these products, >even for internal testing, as the company is worried that their is a >slim chance that a copy may get shipped with a unit. I can not write >software that links in any public domain libraries, i.e Zlib. This >means that I have to write my own compression routines. WHAT A WAIST >OF TIME!!! If that was not irony, I'd say it's time to change the job. The responsible managers should also get legal advice instead of believing such sh*t. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://highqualdev.com public key at homepage public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From thomas.heller at ion-tof.com Wed Jun 6 10:44:32 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Wed, 6 Jun 2001 16:44:32 +0200 Subject: py2exe References: Message-ID: <9flfi1$4r3ap$1@ID-59885.news.dfncis.de> "John" wrote in message news:xarT6.245340$Z2.2800345 at nnrp1.uunet.ca... > Hi, > > I get the following messages when I try to use py2exe : > > warning: install: modules installed to > 'build\bdist.win32\winexe\lib\PROGRA~1\Py > thon21\', which is not in Python's module search path (sys.path) -- you'll > have > to change the search path yourself This bogus warning will not appear in the next version of py2exe, you should ignore it. > The win32api module is not available - modules listed > in the registry will not be found. Install the win32all extensions to get rid of this (if you care, you can also safely ignore it). > > ... > ... > ... > > warning: py2exe: * The following modules were not fo > warning: py2exe: * win32api > warning: py2exe: * miscc > warning: py2exe: * printfwc > warning: py2exe: * misc2c > ... Ignore them (and make sure to thoroughly test the built executable). Most of them are symbols coming from wxPython... Thomas From phawkins at spamnotconnact.com Sun Jun 24 22:19:29 2001 From: phawkins at spamnotconnact.com (phawkins at spamnotconnact.com) Date: 24 Jun 2001 22:19:29 -0400 Subject: Pmw: how to clear ScrolledListBox ? References: <3b2ccea6.477584718@news1.on.sympatico.ca> Message-ID: >>>>> "JP" == Jacek Pop?awski writes: JP> Robert Roy wrote: >>> I add items by .insert, what is correct way to remove all items? >>> >> setlist([]) should work. JP> what happen with old list? what happen in Python when I allocate memory for JP> something then use another value? Garbage collection. -- Patricia J. Hawkins Hawkins Internet Applications, LLC From cribeiro at mail.inet.com.br Sun Jun 3 15:24:37 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Sun, 03 Jun 2001 16:24:37 -0300 Subject: Controlling CDR drives using Python in Windows In-Reply-To: References: Message-ID: <5.0.2.1.0.20010603140900.025ac580@mail.inet.com.br> At 06:01 03/06/01 +0200, Gerhard H?ring wrote: >On Sat, 02 Jun 2001 22:04:03 -0300, Carlos Ribeiro wrote: > >I'm looking for information on how to control a CDR drive from Windows, > >using Python scripts, of course. I'm planning to automate my home backups > >using Python scripts. If someone has any information on how to make it > >work, I'll be glad to know. > >If you want to burn CDR on Windows, I think your best bet is to try to get the >command line tools cdrecord, mkisofs and friends to compile on Windows. That's not exactly what I want. There should be some way to directly control the CDR API. I've read some of the documentation, and it seems that the process of CDR writing is indeed very complex. It seems that it depends on the particular CDR driver interface, although an ASPI layer is available from most manufacturers. Anyway, I think that some 'generic', public API must be available somewhere. Encapsulating such API in Python must be relatively easy using SWIG or something similar. Anyway, I'll take a look at the projects you just cited. It can help, particularly on learning how to build the filesystem, and how to control the CDR driver (this may be completely different in Windows). Carlos Ribeiro From fgeiger at datec.at Thu Jun 28 08:37:02 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Thu, 28 Jun 2001 14:37:02 +0200 Subject: Simple question (launch a program) References: <9hf6v6$ps0$1@taliesin.netcom.net.uk> Message-ID: <9hf868$941$1@newsreaderg1.core.theplanet.net> Did you try os.system()? Regards Franz "MDK" wrote in message news:9hf6v6$ps0$1 at taliesin.netcom.net.uk... > Hi, > > I'm on a Win2K platform. I'm sure that this has been asked before but when > I do a search on the internet I get back too many irrelevant hits because of > the keywords. > > Anyways, how do I launch a program that is in a directory with long file > names? > > Thanks. > > From aahz at panix.com Fri Jun 22 16:40:29 2001 From: aahz at panix.com (Aahz Maruch) Date: 22 Jun 2001 13:40:29 -0700 Subject: Another Wart! string.find() [ was: namespace issue? ] References: <9gucf9$ruc$1@slb3.atl.mindspring.net> <3B337D2B.35F2FD47@home.net> Message-ID: <9h0aft$a83$1@panix2.panix.com> In article <3B337D2B.35F2FD47 at home.net>, Chris Barker wrote: > >YEECCHHH!!! > >Never raise an exception for a perfectly normal, it will happen all the >time event. I guess you'd better stop using for loops, then. (for loops get terminated by trapping the IndexError exception) -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Truth is stranger than fiction, but it is because Fiction is obliged to stick to possibilities; Truth isn't." --Samuel Clemens From emile at fenx.com Fri Jun 1 14:21:06 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 1 Jun 2001 11:21:06 -0700 Subject: Obsolesence of <> (fwd) References: <9f6el30dv5@enews2.newsguy.com> <3B16D681.E12A4554@Lugoj.Com> <9f7pmt029se@enews1.newsguy.com> <3B17D9B9.E3CA8EC8@Lugoj.Com> Message-ID: <9f8mlp$2unus$1@ID-11957.news.dfncis.de> "James Logajan" wrote in message news:3B17D9B9.E3CA8EC8 at Lugoj.Com... > Then we are agreed that "!=" should be obsolete? Whew! glad that is settled. Where's the problem? Use <> when you want it to read 'less than or greater than', and != when it should read 'not equal to'. ;-)) And-use-is-not-when-you-mean-is-not-ly y'rs -- Emile van Sebille emile at fenx.com --------- From Y.Benita at pharm.uu.nl Mon Jun 25 07:09:39 2001 From: Y.Benita at pharm.uu.nl (Yair Benita) Date: Mon, 25 Jun 2001 13:09:39 +0200 Subject: Exit command in Mac Message-ID: Does anyone knows how to exit nice and clean a python program on the Mac. sys.exit() gives an error. Alternatives? Yair From aleaxit at yahoo.com Mon Jun 18 04:44:14 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 18 Jun 2001 10:44:14 +0200 Subject: Using the Python license References: Message-ID: <9gkf0u0255m@enews2.newsguy.com> "Thomas" wrote in message news:njaX6.266341$eK2.55446223 at news4.rdc1.on.home.com... ... > And, does anyone have a link to some comparative information about the > different licenses? I'm interested in the main 'anything goes' licenses: > Python, BSD, and the LGPL. http://www.opensource.org/site_index.html lists about 20 Open Source licenses, with links. Alex From phd at phd.fep.ru Fri Jun 8 03:46:54 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Fri, 8 Jun 2001 11:46:54 +0400 (MSD) Subject: RS232 support for DOS on 486? In-Reply-To: <20010607161324.A17786@harmony.cs.rit.edu> Message-ID: On Thu, 7 Jun 2001, D-Man wrote: > On Fri, Jun 08, 2001 at 12:02:28AM +0400, Oleg Broytmann wrote: > | On Thu, 7 Jun 2001, D-Man wrote: > | > Does Python even run under MS-DOS? > | > | Under DOS Extender - no problem. I used Python 1.5.2 quite successfully! > > That's good to know. What is "DOS Extender" anyways? This is completely off-topic, and not of much interest to the newsgroup (DOS, after all, is completely dead, as well as Python for DOS), so I am going to write you private message to answer the question in more details. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From ahenshawatapowerdotcom Sat Jun 16 22:18:41 2001 From: ahenshawatapowerdotcom (Andrew Henshaw) Date: Sat, 16 Jun 2001 22:18:41 -0400 Subject: slice-alias (was Re: New statement proposal for Python) References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> <9gf6fk0b9l@enews1.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:9gf6fk0b9l at enews1.newsguy.com... ...snip > Takes some work, and is untested, but...: ...snipped code > As you see, it itsn't perfect -- the slice should no doubt > adjust its length in some more circumstances, the better > to mimic a built-in sequence, specifically when it's subject > to slice-assignment. But I hope it can get you started. > Many thanks and much awe... Andy From support at internetdiscovery.com Wed Jun 20 04:07:27 2001 From: support at internetdiscovery.com (Mike Clarkson) Date: Wed, 20 Jun 2001 08:07:27 GMT Subject: idle BUG References: Message-ID: <3b2fba2f.1443851@24.0.228.33> On Mon, 18 Jun 2001 20:09:11 -0400, "Tim Peters" wrote: >[Mike Clarkson] >> ... >> Tim, I know you're very busy these days (learning to sketch? :-), but >> could you examine the MSVC compile and link flags with a microscope >> for similarities and differences between _tkinter.c and tkappinit.c >> and tkAppinit.c for wish. > ... >My knowledge of Tcl + Tk is 0; IOW, if something's wrong there, I wouldn't >notice it if it stuffed a banana up my nose and gave me a dozen roses. It's the difference between the MSVC compile and link flags for the Python console application and the Tk console application (wish) that I think need double checking. The building of the tk.dll isn't the issue: it's whether the Python.exe is being built with the correct flags - wish.exe exits cleanly and Python.exe hangs, and I'm wondering if the console app defines and library link flags are the cause. >not-a-gui-guy-ly y'rs - tim I know you're not-a-gui-guy, but can you help with python.exe compile and link flags? Has anyone build Tkinter with Cygwin, and if so, does the same problem show up there? Mike. From m.faassen at vet.uu.nl Fri Jun 29 18:59:12 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 29 Jun 2001 22:59:12 GMT Subject: the center of the world (was Re: Check out O'Reilly's Open Source Convention Highlights) References: <3B3AA82D.1A0FE860@seebelow.org> <3B3B2DED.5303198A@seebelow.org> <9hhri7019jd@enews2.newsguy.com> <9hj0td$bdu$1@newshost.accu.uu.nl> Message-ID: <9hj180$bdu$2@newshost.accu.uu.nl> Martijn Faassen wrote: [snip] > attendees at IPC8 *including* the PythonLabs team to hold IPC9 in That's IPC9 and IPC10, sorry for the confusion. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From aleaxit at yahoo.com Fri Jun 15 08:10:13 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 15 Jun 2001 14:10:13 +0200 Subject: Any other Python flaws? References: <#72#QIT9AHA.262@cpmsnbbsa09> Message-ID: <9gctvm06lu@enews1.newsguy.com> "Steve Holden" wrote in message news:#72#QIT9AHA.262 at cpmsnbbsa09... ... > > That leaves the remaining warts as minor wibbling about 'do' > > statements, print >>, and the like. Are there any other flaws that > > should be added? > > > Despite the fact that our Fearless Leader and BDFL has already revered > himself once on this issue, I'd like to see strict syntactical equity > between function definitions and class definitions, which is to say that a > class with no superclasses should be declarable as: > > class myClass(): > pass Hear, hear!!! It IS a minor but definite wart that those parentheses are a syntax error in 'class' but mandatory in 'def'. Alex From robin at jessikat.fsnet.co.uk Sat Jun 9 05:25:05 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sat, 9 Jun 2001 10:25:05 +0100 Subject: spell method chaining? References: <19l8IVAAgJI7EwAk@jessikat.demon.co.uk> <3B2111FF.D998EEE4@letterror.com> <3B21D830.E823D70F@letterror.com> Message-ID: <$6JOJKAxteI7EwQC@jessikat.fsnet.co.uk> In article <3B21D830.E823D70F at letterror.com>, Just van Rossum writes Well what I'm really interested in is dynamically wrapping classes for a property collection. With a simple ion that's fairly easy, but when the collection is over a class then the wrapper __getitem__ has to try and chain getattr to either go through the wrapped class or if that fails to try the collection. the main code looks like _ItemWrapper={} class TypedPropertyCollection(PropHolder): def __init__(self, exampleClass): #give it same validation rules as what it holds self.__dict__['_value'] = exampleClass() self.__dict__['_children'] = {} def __getitem__(self, index): try: return self._children[index] except KeyError: Klass = self._value.__class__ if _ItemWrapper.has_key(Klass): WKlass = _ItemWrapper[Klass] else: class WKlass(Klass): def __getattr__(self,name): try: return self.__class__.__bases__[0].__getattr__(self,name) except: return getattr(self._parent,name) _ItemWrapper[Klass] = WKlass child = WKlass() child._parent = self for i in filter(lambda x,K=child.__dict__.keys(): x in K,child._attrMap.keys()): del child.__dict__[i] self._children[index] = child return child it currently uses the __bases__ trick for compatibility with earlier python, but that goes wrong under certain conditions the gen(gen(C)) recursion etc. The nested scopes version would work OK. -- Robin Becker From dougfort at dougfort.net Wed Jun 27 09:53:37 2001 From: dougfort at dougfort.net (Doug Fort) Date: 27 Jun 2001 14:53:37 +0100 Subject: HTML Content Rewriting References: Message-ID: <3b39e555_4@news5.uncensored-news.com> Content-Transfer-Encoding: 8Bit Merton Campbell Crockett wrote: > Several years ago, I developed a system for a customer that allowed their > employees and customers to securely access web content on servers inside > their firewall. Basically, I used Apache's mod_rewrite module to > implement what might be called a "dual reverse proxy". > > Unfortunately, times have changed. Several of the customer's > organizations have started playing with various web development tools that > create dynamic > content. Several of these embed information from the HTTP requests in the > documents that are generated. > > At a minimum this embedded information results in warnings about protocol > changes, i.e. hard-coded links that specify an http: method when the > remote > users are using the https: method. At worse, there are references to > internal names and IP addresses that are not accessible from the Internet. > > Both PHP and Python seem to provide capabilities that would allow "fix > ups" > to be applied to the content as it is delivered to the remote user. > Python looks like it might have a few more tools for manipulating HTML > content. > > What I would like to do is dynamically add a BASE tag to the document and > convert all absolute to relative references if they involve the current > web > site. For references to other web servers accessible through this > facility, I would like to ensure that the references are in the external > form and to disable the links to web servers that are not accessible by > remote users. > > What I would like from this group is some guidance. Can this be done with > Python? Are there existing Python tools that might perform some of the > functions that I would like performed? What pitfalls and "gotchas" should > one be aware? > > Merton Campbell Crockett > > > We have a similar situation in our website load testing application http://www.stressmy.com. We want to parse each page as the user accesses it and change the links to point to our app so we can build a test case. I've attached our parser which may be of some use to you. This does not address the affliction of javascript. That's a whole different problem, but there's dozens of ways to create links dynamically. We handle them in a different way. I'll post it if you're interested. -- Doug Fort http://www.dougfort.net -------------- next part -------------- A non-text attachment was scrubbed... Name: filteringparser.py Type: text/x-java Size: 40067 bytes Desc: not available URL: From tim.one at home.com Sun Jun 17 18:45:11 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 17 Jun 2001 18:45:11 -0400 Subject: New statement proposal for Python In-Reply-To: <9gfoia016rm@enews1.newsguy.com> Message-ID: [Tim] > That leaves the only post-1.0 addition, "assert". It took years to get > that in -- although it's hard now to remember exactly why. The > primary reason it's a keyword is so the compiler can eliminate it under > -O. [Alex Martelli] > Not sure I understand that motivation... the compiler under -O can > eliminate non-keyword stuff too: [via __debug__] Yes. But if assert were a builtin function instead, the compiler couldn't know by magic that the user *wanted* assert(x < y, "oops") wrapped in an "if __debug__:" block, because the compiler can't know that "assert" refers to the builtin function and not something else (btw, we have to fix that someday! it's irritating). __debug__ was an implementation mechanism created to *support* assert, and was-- in good Python fashion --exposed so that adventurers could dream up other uses for it too. __debug__ wasn't "the feature" here, though, "assert" was. > ... > A pure convention is weaker than an advisory mechanism. There is no > advisory mechanism for "constants" (except as attributes in a suitable > object) -- JUST the convention. Yes. > That may be a tad too weak in some cases (I'm neutral on that). It > sure discourages some people from learning enough Python to see it > doesn't matter. Oh, the list of reasons people have for rejecting Python is as long as the number of people who have bothered to report on it. There's too much to be done that would help actual Python users to worry too much about determined non-users. > The advisory __whatever mechanism, which supplemented the purely- > conventional _whatever one, did help to make a couple Python converts > in my experience already -- they'd walk away BUT, when they saw there > WAS a way to make stuff private-enough (C++'ists DO know that deep > down there's no real guarantee, just convention;-), they kept going for > long enough to see it's not a big issue either way. I suspect similarly > weak-but-not-totally-inexistent mechanisms for other kinds of advisory > protection would have similarly positive effect. This is one of the functions the newsgroup serves, is it not? If anyone had the determination to *search* first, they'd find these frameworks invented and reinvented over & over in "confused newbie" threads. I'm not sure it's the framework that wins them over in the end, though: often it appears more the discussion that goes along with it. From that view, I'm not sure that "canning" these frameworks would do as much good. If someone wants to try, though, register it with the Vaults of Parnassus and have at it. From sheila at spamcop.net Mon Jun 25 15:45:17 2001 From: sheila at spamcop.net (Sheila King) Date: Mon, 25 Jun 2001 19:45:17 GMT Subject: Is this a mimetools/rfc822 bug? References: Message-ID: On Tue, 26 Jun 2001 03:09:16 +0800, "Andy" wrote in comp.lang.python in article : :works fine. But when there are leading newlines in samplemsg, it can't read :the headers anymore. (Of course, you can always use lstrip... but it took :me a while before I found out - not a typical Python experience...) So far as I know, leading newline characters are not allowed in the header. A newline character indicates the end of the headers. If you have a continuation line (a header that wraps and continues onto a second line) the leading character should be either a single space, or a horizontal tab character. Each header is terminated by a newline character, which is followed either by the name of another header field (on the next line), or a space or tab, in the event of a continuation line. Else, if followed by another newline character, this indicates the end of the headers and the message body follows next. I studied the RFCs recently, and I think this is what it said? -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From chris.gonnerman at newcenturycomputers.net Sat Jun 23 10:36:13 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Sat, 23 Jun 2001 09:36:13 -0500 Subject: Is this a true statement? References: <3b34939b.410758@nntp.sprynet.com> Message-ID: <002b01c0fbf1$dd0423a0$0101010a@local> ----- Original Message ----- From: "David C. Ullrich" > ??? I thought a device driver was just a file, hence a finite > sequence of bytes. You can certainly use Python to write an > arbitrary sequence of bytes to a file. No doubt it's much easier > in C++ (or rather in typical implementations of C++?) to decide > _what_ sequence of bytes to write to that file, but if we're > talking about what's literally possible and impossible I don't > see how writing a device driver can be impossible in Python. Writing TO a device driver is easy enough... the previous poster was talking about writing the DRIVER in Python. No OS I'm aware of takes device drivers in any languages other than assembler, C, and/or C++. From emile at fenx.com Thu Jun 7 07:24:52 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 7 Jun 2001 04:24:52 -0700 Subject: avl module by Samual M. Rushing References: Message-ID: <9fnoi8$56h1o$1@ID-11957.news.dfncis.de> A quick look on groups.google finds ftp://ftp.gnu.org/pub/gnu/avl which has versions 1.2.9, 1.3.0 and 1.4.0 HTH -- Emile van Sebille emile at fenx.com --------- "Berthold H?llmann" wrote in message news:se4rtslfby.fsf at pc961225.GermanLloyd.de... > Hello, > > I'm trying to use the avl module done by Samual M. Rushing in one of > our projects. I got some strange segfaults and tracked them down to > avl.so. I did a fix to get over this segfault, but I'm not shure > whether the fix affects data integrety. Before I create more tests, is > there a newer version then the one from 101098? Or any alternative? > > Thanks > > Berthold > -- > email: hoel at GermanLloyd.org > ) tel. : +49 (40) 3 61 49 - 73 74 > ( > C[_] These opinions might be mine, but never those of my employer. From akuchlin at mems-exchange.org Tue Jun 12 15:28:24 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: Tue, 12 Jun 2001 15:28:24 -0400 Subject: Quixote 0.3 released In-Reply-To: ; from phd@phd.fep.ru on Tue, Jun 12, 2001 at 11:18:29PM +0400 References: Message-ID: <20010612152824.A24211@ute.cnri.reston.va.us> On Tue, Jun 12, 2001 at 11:18:29PM +0400, Oleg Broytmann wrote: >On Mon, 11 Jun 2001, Andrew Kuchling wrote: >> * Names of the form __*__ are reserved for Python, and 2.1 is >> beginning to enforce this rule. > Oops, I missed something. In what way is python enforcing the rule? Only in one particular case: assigning to __debug__ produces a warning in 2.1. In the ensuing discussion of this change, GvR made it clear that such symbols should be considered to be reserved for the interpreter, so we changed Quixote preemptively, even though it didn't cause any problems with 2.1. --amk From gmuller at worldonline.nl Fri Jun 8 16:22:04 2001 From: gmuller at worldonline.nl (Gerrit Muller) Date: Fri, 8 Jun 2001 22:22:04 +0200 Subject: How do you develop in Python? References: <050620011516094693%pecora@anvil.nrl.navy.mil> <9fjfer$gt0$1@nereid.worldonline.nl> <3B2129AC.90BA8650@home.net> Message-ID: <9frc6v$b20$1@nereid.worldonline.nl> "Chris Barker" schreef in bericht news:3B2129AC.90BA8650 at home.net... > Gerrit Muller wrote: > > but I think that a more "cold" runscript > > command in IDLE, which imports/reloads anything again (and maybe clears the > > rest of the environment as well) would make IDLE even more accessible for > > this type of programmers. > > Also the MacPython IDE, PythonWin, etc. I've been asking for this for a > while, but I think it's harder than it sounds for two reasons: > > 1) I don't think the Python Interpreter has any kind of "clear all" > facilities. > Worst case it might end up in automating what the initial poster did manually, stop and restart the interpreter :-(. > 2) All three of these IDEs (and others, I'm sure) use the same > interpreter to run the IDE as the program you are working on. If you > were to "clear all" you'de wipe out the IDE as well. I'd lke to see an > IDE that used a separate copy of the interpreter, but it would make > writting a debugger (and other introspective tools) a lot harder. > I understand the problem from implementers point of view. However from CP4E point of view I don't "want" to understand, I simply would like to have this "reset/clear" button. Hunting for the CP4E vision requires thinking from "naive" programmer point of view. Some brilliant idea appears to be necessary to satisfy this need, without making the IDE's too complex. Thinking out loudly: For many naive users the automated stop/restart might be fully acceptable, while it might also be simple to implement. Although, how much unexpected state needs to be persistent, like open files and windows; when would this same naive user start hating to see windows disappear and reappear? May-be it is already too complex ). > -Chris Regards Gerrit From tim.one at home.com Sun Jun 24 19:26:36 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 24 Jun 2001 19:26:36 -0400 Subject: Nested Scopes Question (exec) In-Reply-To: Message-ID: [Ryan LeCompte] > ... > The PEP states that the SyntaxError exception will be raised for "bare > execs" which don't utilize the full syntax as given above, but why does > the exception disappear when the full syntax is used? How does the > compiler know that the exec statement won't introduce a new local > variable in the local namespace, It can't introduce a new local variable, although you may have code that makes you believe that it does . Read on. > ... > P.S. --- Aren't the following two calls the same: > > exec "print 'hello'" > exec "print 'hello'" in globals(), locals() Those are the same, but neither one has well-defined behavior. Python should really gripe about the second version too, but it can't know at compile-time that "locals()" refers to the builtin function of that name, so it could at best be a warning. As the docs for locals() say, Warning: The contents of this dictionary should not be modified; changes may not affect the values of local variables used by the interpreter. That is, attempting to modify locals() has no defined behavior, so anything you see as a result of modifying locals() is use-at-your-own-risk stuff. The exact rules for when modifying locals() will and won't have an effect on the local namespace vary from release to release, and across implementations, and are all accidents. If Python ever grows an immutable dict type, it's a safe bet that locals() will return an instance of that type, so that attempts to mutate it will raise exceptions. I wouldn't be surpised if the "bare exec" syntax form got deprecated too (Guido has already said that he intends to ban it someday). In the meantime, best practice is: 1. Never use locals() in a mutating context. 2. Pass explicit dicts to exec (and related functions), amd not including locals() unless you're certain the exec'ed code won't mutate it. 3. globals() is safe to use (has guaranteed behavior) in all contexts. From sdm7g at Virginia.EDU Wed Jun 20 20:55:00 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Wed, 20 Jun 2001 20:55:00 -0400 (EDT) Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) In-Reply-To: Message-ID: On Wed, 20 Jun 2001 James_Althoff at i2.com wrote: > > Jeremy Hylton wrote: > >My problem isn't with learning how to subscribe to a new list; it's > managing > >the accounts for the dozens of lists I have to subscribe to and read just > to > >keep track of Python development. If I happen to be on vacation (or, say, > >paternity leave) when a new list is created, I may end up missing more of > >the discussion because I didn't subscribe in time. > > > >Jeremy > > I agree. [ ... ] I'm also an anti-list-splitter. I'ld rather filter than join or deal with cross postings! Also, as another former Icon-er, I tend to lean with Tim on the syntax issue. -- Steve Majewski From altis at semi-retired.com Mon Jun 18 17:43:31 2001 From: altis at semi-retired.com (Kevin Altis) Date: Mon, 18 Jun 2001 14:43:31 -0700 Subject: Teaching Pyhton on Wintel References: <1ev6xe3.15eskd91k2u1eaN%p.agapow@ic.ac.uk> Message-ID: ActivePython http://aspn.activestate.com/ASPN/Downloads/ActivePython/ might be best for your purposes if for no other reason than all the major Python documentation is included as windows help files (.chm) so you don't have to have web access to teach. The latest release even includes the HowTos, The Whole Python FAQ, Dive into Python, the Non-programmers tutorial for Python, etc. If your scientists are wanting to access some of their existing data sets, then going over some simple COM (data in Excel) and ODBC (data in Access...) examples with the Win32 extensions will be a big plus for showing how you can do useful stuff with a minimum of fuss. If they use web sites that support XML and/or XML-RPC or SOAP you can show how built-in web tools and common extensions in Python can allow them to access and automate data collection they may be doing by hand. Practial task-oriented teaching avoids the pitfalls of covering too many abstract language features without showing real results. ka "Paul-Michael Agapow" wrote in message news:1ev6xe3.15eskd91k2u1eaN%p.agapow at ic.ac.uk... > > Call me misguided, but I've decided to teach an introduction to > programming class using Python. The audience are the scientists in my > (evolution/ecology research centred biology) department and we'll be > using the local computer lab, which is kitted out out with a network of > modestly powered Wintel machines. So: > > 1. Any advice on which IDE etc. of Win Python to use? > 2. Anyone done a similar class, like to advise on approaches or books to > base it off? > > thanks > > > -- > Paul-Michael Agapow (p.agapow at ic.ac.uk), Biology, Imperial College > "Pikachu's special power is that he's monophyletic with lagomorphs ..." From barry at digicool.com Sun Jun 24 23:39:54 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Sun, 24 Jun 2001 23:39:54 -0400 Subject: PEP 255: Simple Generators References: <20010621134445.B20524@glacier.fnational.com> Message-ID: <15158.45706.973100.272298@anthem.wooz.org> >>>>> "GL" == Glyph Lefkowitz writes: GL> If python's answer to "what should we do with new feature X"? GL> is "add a keyword" it will turn into Perl before too long. I GL> think that most of us agree that print>> is a disturbing GL> symptom of this already :) Why? No keywords were added. :) -Barry From qrczak at knm.org.pl Mon Jun 18 12:59:41 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 18 Jun 2001 16:59:41 GMT Subject: Loading select queries into objects References: Message-ID: Mon, 18 Jun 2001 19:25:17 +0400 (MSD), Roman Suzi pisze: > [apply(f, (x,)) for (f, x) in map(None, funlist, tup)] Or even: [f(x) for f, x in zip(funlist, tup)] (if both lists have the same length). -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From kklzfan at yahoo.com Fri Jun 8 13:07:14 2001 From: kklzfan at yahoo.com (scott snider) Date: Fri, 8 Jun 2001 10:07:14 -0700 (PDT) Subject: newbe question Message-ID: <20010608170714.3515.qmail@web10803.mail.yahoo.com> is there a good book or web site that explanes and teaches python in a step by step way so that when you are finished with the book or site you have a fully functioning program? thank you scott __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/ From bob at this-is.invalid Fri Jun 15 20:44:33 2001 From: bob at this-is.invalid (Bob Hauck) Date: Sat, 16 Jun 2001 00:44:33 GMT Subject: bad python display References: <9gdie8$r2v$1@solaria.cc.gatech.edu> Message-ID: On 15 Jun 2001 17:59:36 GMT, Holland King wrote: > i have a python program using the tkinter module to create a gui. my > local system is running woody debian with kde. i am running the program > on a soloris box. on both my system and the solaris system i am using the > same version of ssh, python, and tkinter lib. the problem is when i try > to export the display from the solaris box to my local machine all i get > is the frame and half the boxes and buttons. Do you have KDE's "apply colors and fonts to other apps" button checked in the Control Center? That might have something to do with it. -- -| Bob Hauck -| To Whom You Are Speaking -| http://www.haucks.org/ From SBrunning at trisystems.co.uk Tue Jun 26 08:37:34 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Tue, 26 Jun 2001 13:37:34 +0100 Subject: Python and Functional Programming Message-ID: <31575A892FF6D1118F5800600846864D78BDAA@intrepid> > From: isabelle.todescato at libertysurf.fr > [SMTP:isabelle.todescato at libertysurf.fr] > I professionally use the functional programming language Clean to > write heavy-algorithmic applications, and am at the moment seeking a > flexible and powerful way to glue these applications together, along > with some GUI front-end. I read a few introductory articles about the > Python and JPython languages that seem to provide a tremendous > flexibility and a vast library panel. > > I have heard that the new versions of Python had integrated some > concepts taken from functional programming, and I would be interested > in having a few pointers to these topics. See . Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From thinkit8 at lycos.com Thu Jun 14 23:11:14 2001 From: thinkit8 at lycos.com (thinkit) Date: 14 Jun 2001 20:11:14 -0700 Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> <9g8q7t0uib@drn.newsguy.com> <9ga811013r@drn.newsguy.com> Message-ID: <9gbuci019gt@drn.newsguy.com> In article , sill at optonline.net says... > >On 14 Jun 2001 04:43:29 -0700, thinkit wrote: >> In article , "Steve says... >>> >>>"thinkit" wrote in message >>>news:9g8q7t0uib at drn.newsguy.com... >>>> In article , >>>> Tom_Good1 at excite.com says... >>>> > >>>> >thinkit wrote in message >>>> >news:<9g5d3p0f0p at drn.newsguy.com>... >>>> >> humans should use a power of 2 as a base. this is more logical because >>>it >>>> >>synchs with binary, which is at the very heart of logic--true and false. >>>it is >>>> >> more natural perhaps, to use decimal--but logic should, and will, win >>>out. >>>> > >>>> >I'm amused by the idea that "humans should [do something] because . . >>>> >. it is more logical." Ah yes, we humans are so extremely logical. >>>> >That's why advertisers -- whose livelihood depends on getting us to do >>>> >things -- inevitably appeal to our highly refined sense of logic, and >>>> >never play to our emotions or baser instincts ;-) >>>> >>>> some of us are...and those that are will easily dominate or destroy the >>>rest. >>>> >>>If you're bent on world domination, perhaps you should apply for a job at >>>Microsoft? >>> >>>regards >>> Steve >>>239 (decimal) >> >>microsoft caters to the dumb in the worst kind of ways. i know bill's a smart >> guy, so maybe he's building up money to unleash the forces...but i doubt it. >> > >To unleash the awesome powers of hexadecimal upon the world? Yeah, I somehow >doubt that also ;-). > > >-- >Jupiter and Saturn Oberon Miranda >And Titania Neptune Titan >Stars can frighten > - Syd hexadecimal, lojban (logical language), logic in general. a nation of a quarter the population the US with no psychics, astrologers, stupid people, etc. could control the world easily. From dalke at acm.org Wed Jun 27 05:24:30 2001 From: dalke at acm.org (Andrew Dalke) Date: Wed, 27 Jun 2001 03:24:30 -0600 Subject: PEP 260: simplify xrange() References: <3B39480C.F4808C1F@Lugoj.Com> Message-ID: <9hc97q$rpt$1@slb6.atl.mindspring.net> Uncle Tim: >> although-it-would-be-impolite-to-ask-we-why-still-ship-a-directory- >> full-of-crufty-old-irix5-demos-in-the-std-library-ly James Logajan: >Perhaps because the Irix community would be quite Irate if they were >removed? As an ex-member of the Irix community, I never used those modules because I knew my code needed to run under non-IRIX platforms. Let them be deprecated. As a double check, I did a google search for +"import al" +def The only hits related to Python were from Python itself (documentation or audiodev.py) No relevant hits from +"import fm" +def , except that there is a Mac Python module "import Fm". Search for "import imgfile" found nothing relevant. So, not really used. Andrew dalke at acm.org From smigowsky at dspace.de Mon Jun 18 04:32:51 2001 From: smigowsky at dspace.de (Stefan Migowsky) Date: Mon, 18 Jun 2001 09:32:51 +0100 Subject: AW: Python win32all installation warning dialogs. Message-ID: <84257D042AA7D411B3F700D0B7DB9B7C13AB48@newsintern.dspace.de> Hi, there is probably a mismatch in the comcat.dll. Mircosoft removed the interfaces to register COM categories from version 4.73 to version 5.0. So search for the file comcat.dll in the system directory and look for the version. If it is higher than 4.73 there is your problem. To fix it try to get version 4.73 and run regsvr32 c:\4.73\comcat.dll %PYTHON_ROOT%\python.exe %PYTHON_ROOT%\win32comext\axscript\client\pyscript.py %PYTHON_ROOT%\python.exe %PYTHON_ROOT%\win32com\servers\interp.py %PYTHON_ROOT%\python.exe %PYTHON_ROOT%\win32com\servers\dictionary.py regsvr32 -u c:\4.73\comcat.dll regsvr32 %SYSTEM32%\comcat.dll Stefan > -----Urspr?ngliche Nachricht----- > Von: infobot at skinnyhippo.com [mailto:infobot at skinnyhippo.com] > Gesendet: Donnerstag, 14. Juni 2001 02:11 > An: python-list at python.org > Betreff: Python win32all installation warning dialogs. > > > Installing Python win32all from ActiveState > (win32all.exe, build 140 (3.5 Mb) for use with PythonLabs Python 2.1) > for Python2.1 running on Windows NT 4. Following warnings appeared > at the end of installation procedure : > > "Registration of the AXScript Engine COM server failed. > Installation will continue but this server will require manual > registration before it will function. > Pywintypes.com_error:[-2147467262, 'No such > interface supported', None, None]" > > "Registration of the Python Interpreter COM server failed. > Installation will continue but this server will require manual > registration before it will function. > Pywintypes.com_error:[-2147467262, 'No such > interface supported', None, None]" > > "Registration of the Python Dictionary COM server failed. > Installation will continue but this server will require manual > registration before it will function. > Pywintypes.com_error:[-2147467262, 'No such > interface supported', None, None]" > > I've never had problems with Win32all before so I figure the above > are out-of-the-ordinary. May I ask how I should register these items ? > Thank you very much, > > chas > > ps. if it makes any difference, I used to have Python1.52 and the > respective win32all installed but uninstalled both of them before > installing Python2.1 > -- > http://mail.python.org/mailman/listinfo/python-list > From sholden at holdenweb.com Wed Jun 27 09:39:25 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 27 Jun 2001 09:39:25 -0400 Subject: HTML Content Rewriting References: Message-ID: "Merton Campbell Crockett" wrote ... > Several years ago, I developed a system for a customer that allowed their > employees and customers to securely access web content on servers inside > their firewall. Basically, I used Apache's mod_rewrite module to implement > what might be called a "dual reverse proxy". > > Unfortunately, times have changed. Several of the customer's organizations > have started playing with various web development tools that create dynamic > content. Several of these embed information from the HTTP requests in the > documents that are generated. > > At a minimum this embedded information results in warnings about protocol > changes, i.e. hard-coded links that specify an http: method when the remote > users are using the https: method. At worse, there are references to > internal names and IP addresses that are not accessible from the Internet. > > Both PHP and Python seem to provide capabilities that would allow "fix ups" > to be applied to the content as it is delivered to the remote user. Python > looks like it might have a few more tools for manipulating HTML content. > > What I would like to do is dynamically add a BASE tag to the document and > convert all absolute to relative references if they involve the current web > site. For references to other web servers accessible through this facility, > I would like to ensure that the references are in the external form and to > disable the links to web servers that are not accessible by remote users. > > What I would like from this group is some guidance. Can this be done with > Python? Are there existing Python tools that might perform some of the > functions that I would like performed? What pitfalls and "gotchas" should > one be aware? > Yes, Python can easily do this. You should look at htmllib (or, more generally, sgmllib) for parsing the HTML input, and think about httplib (or the newer httplib2, if you think its complexity might be required) for actually reading any pages you have to pull down from a server rather than reading from local files. To server web pages there are various *HTTPServer modules, choose your poison. Hope this helps. regards Steve -- http://www.holdenweb.com/ From ChuckEsterbrook at yahoo.com Fri Jun 22 14:20:27 2001 From: ChuckEsterbrook at yahoo.com (Chuck Esterbrook) Date: Fri, 22 Jun 2001 14:20:27 -0400 Subject: Unexpected import behavior Message-ID: <5.0.2.1.0.20010622135426.03413ec0@mail.mindspring.com> Under the old mxDateTime, I had: import DateTime from DateTime import now, RelativeDateTime The new one is inside a package. No problem, I thought: from mx import DateTime from DateTime import now, RelativeDateTime But that gives me this: Traceback (most recent call last): File "./DailyLinks21.py", line 24, in ? from DateTime import now, RelativeDateTime ImportError: No module named DateTime Obviously there is a DateTime variable by the time we get to the second statement and it points to a module. I printed the repr() and type() to make sure. An examination of sys.modules.keys() shows, however, that there is no 'DateTime', but only 'mx' and 'mx.DateTime'. Using a Python package containing a package containing a module, I created the same problem. I then created it with Python 2.0 and 1.5.2. The behavior seems rather non-intuitive (although easily fixed in this case). I guess the explanation from those familiar with Python internals will be something along these lines: - import uses sys.modules.keys() not the symbols where it is located - "from pkg import module" does not "unqualify" the module for future imports even in the module where this statement appears So at this point, I'm wondering if you think this behavior is intuitive/"correct" and whether or not it would make any sense to change it. For example, could import look at local symbols before sys.modules? -Chuck From tim.one at home.com Thu Jun 28 00:12:41 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 28 Jun 2001 00:12:41 -0400 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) In-Reply-To: <3B3A7BB8.F9BAE53B@cosc.canterbury.ac.nz> Message-ID: [Greg Ewing] > To behave totally like Icon, it would be necessary > that given > > def f(): > return 3 + g() > > where g is a generator, and f is called in an iteration > context, then f would be a generator too. Actually not! "return" does not supply a generative context in Icon, so return 3 + g() produces at most one result regardless of the context f() was called from and regardless of whether g "wants to" generate more than one result. The rules in Icon get subtle when crossing expression boundaries. You need suspend 3 + g() here instead to make that particular point stick; but then that's like the PEP 255 example def f(): for x in g(): yield 3 + x and then f is indeed a generator. > But then you would have turned Python into Icon. :-) Well, except for the really *interesting* parts . BTW, did you get your Windows install to work??? If so, what was the problem? From geoff at homegain.com Mon Jun 25 17:09:19 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Mon, 25 Jun 2001 14:09:19 -0700 Subject: printer under Win32 Message-ID: <393D961EA4FCD311B03F00D0B746D65803275EDE@HQSXCH01> I think in some ways this is actually more a Windows GDI question than a Python question, but I'm using the win32ui module so I'll ask it here (esp. since I don't have ready access to any Windows-centric forums....) The question is basically: what's the right way to determine page extents when writing to a printer DC? Detail follows (if it matters): I've managed to puzzle my way through font selection and font metrics, and between web resources and the wonderful Python Programming on Win32 book from ORA, I've managed to piece together a little program that prints a plain-text file in a very nice format -- no UI on the thing, just 'feed it a filename and it writes it to printer' -- it's a utility I've often wanted for printing from Vim, among other excuses. However, using raw TWIPS and calculating page length has resulted in some (pretty big) page underruns. So I'm trying to figure out if there's a way to actually ask the device context for its "printable area" boundaries, or at least for its 'recognized on the page' boundaries. In looking through the win32 docs on the ActiveState site (which reminds me -- am I one of the only ones whose pythonwin reference docs were mauled in the official distribution?) -- I spotted two likely candidates: dc.GetViewportExt() or dc.GetWindowExt(), but I'm not sure what each does; GetWindowExt() seems to provide more "reasonable" results, but I'm still wondering.... Thanks, --G. --- Geoff Gerrietts Software Engineer, HomeGain.com 510-655-0800 x4320 From xyzmats at laplaza.org Wed Jun 20 15:15:53 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Wed, 20 Jun 2001 19:15:53 GMT Subject: PythonCard mailing list References: Message-ID: <3b30f568.15994839@news.laplaza.org> On Wed, 20 Jun 2001 08:55:13 -0700, "Kevin Altis" wrote: >My apologies, I forgot that Yahoo Groups (eGroups) apparently >requires registration even to just read messages. At least one person >has already brought this up here on comp.lang.python. > >If anyone has a suggestion for a forum where we can discuss, either >your own listserv or a free listserv service where we can make >individual messages and/or the archives available I would like to >make the switch now rather than later. You could just go ahead and make a SourceForge project for this. That gets you the ability to provide mailing lists, and saves you the migration tasks should you decide to start coding. Bonus: the mailing list manager there is Mailman, a Python Project. That means Barry will fix anything that goes wrong :-) (ahem) Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From aleaxit at yahoo.com Thu Jun 28 11:57:12 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 28 Jun 2001 17:57:12 +0200 Subject: [ANN] the first Italian newsgroup on python language References: Message-ID: <9hfk4p06fo@enews1.newsguy.com> "Lello Mele" wrote in message news:Z0C_6.4027$z11.413723 at news.infostrada.it... > With great pleasure and after a difficulty pregnancy, > i am pleased to announce the creation of free.it.python, > the first Italian newsgroup on python language. > > We beg all the italian experts to support the newgroup . This specific Italian expert will be happy to support the newsgroup as soon as he can get his paws upon it, but so far it's not on news.iunet.it (it doesn't carry the free.* hierarchy) nor on Newsguy (ditto)... Alex From aahz at panix.com Tue Jun 5 00:53:39 2001 From: aahz at panix.com (Aahz Maruch) Date: 4 Jun 2001 21:53:39 -0700 Subject: Decimal can be Binary Too (was decimal or rational) References: Message-ID: <9fhokj$7pq$1@panix3.panix.com> In article , Tim Peters wrote: > >If, after (it's not done yet) people get to kick Decimal's tires, they're >happy (OK, I'll settle for happier ) with this approach, Aahz has been >writing in it such a way that the performance-critical parts can be migrated >to C easily. If not, hey -- it's Python! It's painless to throw away (and >especially if you're not Aahz ). Not only that, but the intent (and the reason I started this project in the first place) is to have the C code release the Global Interpreter Lock so that multi-CPU machines get a speedup in decimal arithmetic. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Do not taunt happy fun for loops. Do not change lists you are looping over." --Remco Gerlich, comp.lang.python From mertz at gnosis.cx Fri Jun 1 10:30:02 2001 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Fri, 01 Jun 2001 10:30:02 -0400 Subject: Obsolesence of <> Message-ID: tanzer at swing.co.at (Christian Tanzer) wrote: Just try: >>> "??b" == u"abc" Traceback (most recent call last): File "", line 1, in ? UnicodeError: ASCII decoding error: ordinal not in range(128) :( Hmmm... I don't see those funny characters with the dots on top *anywhere* on my keyboard :-). Unfortunately though, the characters 'c','h','r','(','1','2','8',')' all do appear on my keyboard, so I still have the problem in the manner Tim Peters observed. So the next obvious question: WHY is this error raised?! I actually -had- seen it before, but repressed my memory of it, since it seemed so ugly and unnecessary. Comparisons seem to be getting much poorer as Python version numbers increase, not richer :-(. Yours, Lulu... From phd at phd.fep.ru Tue Jun 12 15:18:29 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Tue, 12 Jun 2001 23:18:29 +0400 (MSD) Subject: Quixote 0.3 released In-Reply-To: Message-ID: Hi! On Mon, 11 Jun 2001, Andrew Kuchling wrote: > * Names of the form __*__ are reserved for Python, and 2.1 is > beginning to enforce this rule. Oops, I missed something. In what way is python enforcing the rule? Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From a-steinhoff at web.de Sat Jun 30 12:21:18 2001 From: a-steinhoff at web.de (a-steinhoff at web.de) Date: 30 Jun 2001 09:21:18 -0700 Subject: GUI Builder for Python ? References: Message-ID: <9hku9u0m92@drn.newsguy.com> In article , Lothar says... > >Is there something other then "Black Adder" which is behind an alpha >version ? Have a look to http://www.tilcon.com ... we have implemented the Python bindings for the TRTD library and QNX4/Photon. A MS-Windows version is not yet released. Armin http://www.steinhoff.de/PyDACHS_python-tilcon.htm From ullrich at math.okstate.edu Sun Jun 3 11:45:09 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 03 Jun 2001 15:45:09 GMT Subject: random (fwd) References: Message-ID: <3b1a5ac3.4127516@nntp.sprynet.com> On Sat, 02 Jun 2001 12:51:10 -0400, Lulu of the Lotus-Eaters wrote: >Coming, admittedly, a bit late to the conversation on this topic, I'm >surprised to find Alex a bit too dedicated to his point... and making a >few errors about which he knows better: > >Someone wrote: Those anonymous posters can be irritating. [...] > >The Incompleteness of Arithmetic simply says: > > ANY (finite axiomatic) system powerful enough to model arithmetic > must contain statements that are not derivable from the axioms of > that system. > >So, for example, ZF can model the Peano axioms, and therefore gets stung >by the incompleteness bug. But this much leaves open the possibility >that ZF is strictly more powerful than arithmetic. (question though: >is this actually true of ZF--can it be modelled with the Peano axioms?). No. (Um, don't ask me to prove that, but it seems clear.) David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From paulp at ActiveState.com Mon Jun 18 14:41:17 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Mon, 18 Jun 2001 11:41:17 -0700 Subject: Python version of IQ has been updates (IQ v0.34.python) References: <505.566T11T1243597threeseas@earthlink.net> <3B2A7F5E.MD-1.4.4.padf@ihug.com.nz> <3871.567T2214T9794928threeseas@earthlink.net> <87puc3ao42.fsf@pooh.honeypot> <2509.568T2823T9766233threeseas@earthlink.net> <87elshahyv.fsf@pooh.honeypot> Message-ID: <3B2E4B4D.45089F5A@ActiveState.com> Kirk Strauser wrote: > >... > > If you already know C or a similar language, then yes, Perl is easy > to read. Whatever Perl's virtues, it is a massive stretch to claim that it is C-like. I have done about a decade of C programming and probably about 4 years of Java and I don't see how that helps me with this: sub import { $^H |= $utf8::hint_bits; $enc{caller()} = $_[1] if $_[1]; } sub unimport { $^H &= ~$utf8::hint_bits; } sub AUTOLOAD { require "utf8_heavy.pl"; goto &$AUTOLOAD; } Just because it uses curly braces and semicolons???? This isn't some weird example I made up. I picked a random Perl file from the Perl distribution. I suspect that less than 1 in 20 Perl files looks substantially like C. > Or at least, it can be when written by someone who considers > "maintainability" to be an important goal. It's unfortunately easy to > create Perl that is totally, utterly, completely unreadable - do a Google > search for "obfuscated perl contest" and take a look at some of the winners. That's a separate issue. Perl's syntax is radically larger than and different than C or Java. My experience is that an understanding of those languages is of very limited help in understanding Perl. The code above isn't obfuscated. It is idiomatic. But the only C keywords I see above are "if" and "goto" and both are used in a manner that is not legal in C. Furthermore, Perl's semantics are even more radically different than C (if that's possible). C is strongly, statically typed. Perl is weakly, dynamically typed. C has no OO. Perl does. C++ and Perl's OO models are not even roughly similar. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From tdelaney at avaya.com Tue Jun 19 21:53:03 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Wed, 20 Jun 2001 11:53:03 +1000 Subject: Any other Python flaws? Message-ID: > "Tony J Ibbs (Tibs)" wrote: > > > > every quilt should contain a deliberate mistake, since > > only God can create something perfect). > > Yeek! We'd better be careful with these warts, then -- if > we accidentally remove the last one, we may get smote with > a thunderbolt! > > -- > Greg Ewing, Computer Science Dept, University of Canterbury, Not to worry ... I think (sadly) that print >> is here to stay ... Tim Delaney From anamax at earthlink.net Sat Jun 30 12:20:08 2001 From: anamax at earthlink.net (Andy Freeman) Date: 30 Jun 2001 09:20:08 -0700 Subject: Is this a true statement: Part II References: <9hiifr$sjs$1@taliesin.netcom.net.uk> Message-ID: <8bbd9ac3.0106300820.4fcd2a3c@posting.google.com> > "Python can do everything C++ can do but just slower." Speed is a virtue, so if that is the only meaningful difference, why would anyone use Python? But, if speed isn't the only possible meaningful difference, is the statement worthwhile? > that surprised me the most were the statements regarding C++. My impression > of C++ was that it was the end-all, be-all of languages and if you wanted to > write a serious program you wrote it in C++. If there was an end-all/be-all of languages, why would other languages exist? > a way that I can explain it to my boss. What makes you think that your boss cares about technical considerations? (Companies/products rarely succeed or fail based upon technical considerations.) -andy From pinard at iro.umontreal.ca Tue Jun 12 18:27:59 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 12 Jun 2001 18:27:59 -0400 Subject: Python for MS-DOS (was: Re: RS232 support for DOS on 486?) In-Reply-To: References: Message-ID: [Cyril Slobin] > So, weekend passes, and Python 2.1 is successfully compiled with DJGPP. > ftp://ftp.ice.ru/pub/slobin/python/ I tried downloading file: ftp://ftp.ice.ru/pub/slobin/python/pythonx.zip which may only be read by user 1010, is not downloable by anonymous FTP. Could this be adjusted? -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From davidw at weblink.com.au Mon Jun 25 00:17:52 2001 From: davidw at weblink.com.au (David White) Date: 24 Jun 2001 21:17:52 -0700 Subject: ActiveX Controls in Python Message-ID: <4dfd15be.0106242017.36042c10@posting.google.com> I'm a C++ programmer whose considering using Python to prototype an ActiveX control. However, I can't seem to find any samples or resources on implementing ActiveX controls in Python. Would anyone be able to give me any pointers on how to do it? Also, the control will have to make heavy use of a grid control, what grid controls are available that have Python interfaces? Help would be appreciated. David White Programmer WebLink Pty Ltd From andy_todd at nospam.yahoo.com Wed Jun 20 20:38:45 2001 From: andy_todd at nospam.yahoo.com (Andy Todd) Date: Thu, 21 Jun 2001 00:38:45 GMT Subject: PythonCard mailing list References: <3b30f568.15994839@news.laplaza.org> Message-ID: xyzmats at laplaza.org (Mats Wichmann) wrote in <3b30f568.15994839 at news.laplaza.org>: >On Wed, 20 Jun 2001 08:55:13 -0700, "Kevin Altis" > wrote: > >>My apologies, I forgot that Yahoo Groups (eGroups) apparently >>requires registration even to just read messages. At least one person >>has already brought this up here on comp.lang.python. >> >>If anyone has a suggestion for a forum where we can discuss, either >>your own listserv or a free listserv service where we can make >>individual messages and/or the archives available I would like to >>make the switch now rather than later. > > >You could just go ahead and make a SourceForge project for this. That >gets you the ability to provide mailing lists, and saves you the >migration tasks should you decide to start coding. > >Bonus: the mailing list manager there is Mailman, a Python Project. >That means Barry will fix anything that goes wrong :-) (ahem) > > >Mats Wichmann > >(Anti-spam stuff: to reply remove the "xyz" from the >address xyzmats at laplaza.org. Not that it helps much...) As someone pointed out yesterday, there is already a 'pythoncard' project on SourceForge which isn't quite the same as discussed here (and which seems to be inactive at the moment). As this discussion is still in its formative stages its probably best to refrain from creating a full blown project, at least for a few days. For starters, we would need to come up with a different project name and that should probably wait until we've actually figured out what it is that we want to do ;-) Follow ups to the mail list ... Andy -- Content free posts a speciality From sholden at holdenweb.com Sat Jun 9 11:52:00 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sat, 9 Jun 2001 11:52:00 -0400 Subject: How do I serve an image from a Python Script? References: <3B2134A2.EFE1736F@yahoo.com> Message-ID: <2BrU6.30719$n7.833807@e420r-atl2.usenetserver.com> Make sure you add the -u option to the #! line to run stdout in binary mode. regards Steve "haaserd" wrote in message news:3B2134A2.EFE1736F at yahoo.com... > Hi, > > I am trying to serve an image from a Python script using > Apache under > Windows. My simple HTML statement: > > a picture > > ...and my simple script: > > #!c:/Python20/python.exe > import sys > > def pix(): > n = 'c:/My Pictures/Sample.jpg' > p = open(n,'rb') > apix = p.read() > p.close() > sys.stdout.write("content-type: image/jpeg\n\n") > sys.stdout.write(apix) > sys.stdout.flush() > > if __name__ == '__main__': > pix() > > As you can see I am ignoring the CGI fields for the moment > and am just > trying > to serve up an image. Through debugging statements that I > have > removed, I > know the program crashes on the statement > sys.stdout.write(apix) > if the picture is over 200,000 bytes. > > On small images (10k), the script runs to completion, but no > image > appears. > What am I doing wrong? > > TIA, > > Roger Haase > > From m.faassen at vet.uu.nl Mon Jun 4 07:11:43 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 4 Jun 2001 11:11:43 GMT Subject: Python output for Glade References: <9fdprb$3hpec$2@ID-91520.news.dfncis.de> <9ffdos$3oliu$1@ID-91520.news.dfncis.de> Message-ID: <9ffqdf$cic$1@newshost.accu.uu.nl> Rajarshi Guha wrote: > Rajarshi Guha wrote in message > news:9fdprb$3hpec$2 at ID-91520.news.dfncis.de... >> Hi, >> does anybody know of patches etc that can give me Python source for a >> Glade project. I tried using glade.py but it gives a number of errors and > I follwowed up the pointers regarding using Glade and Python and it seems > pretty neat. However I have a question. There aree two ways to use a Glade > file to generate the UI. One is to use libglade and generate it on the fly > and the other involves converting the XML description to Python src. Which > is a better? Or rather when would I use on the fly generation or conversion > to Python source? I don't know which is better; the gladepyc homepage has the same question, obviously offering some advantages of the gladepyc approach ("By why on earth doesn't he use libglade?"): http://www.fcoutant.freesurf.fr/gladepyc.html I would think it depends on what you want to do. I doubt it matters that much for most applications, though. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From nas at python.ca Sun Jun 24 18:48:53 2001 From: nas at python.ca (Neil Schemenauer) Date: Sun, 24 Jun 2001 15:48:53 -0700 Subject: PEP 255: Simple Generators In-Reply-To: ; from rnd@onego.ru on Sun, Jun 24, 2001 at 08:59:06PM +0400 References: <20010624082350.A29837@glacier.fnational.com> Message-ID: <20010624154853.A30403@glacier.fnational.com> Roman Suzi wrote: > Could you try my comb version? I am sure it's faster! > (I used the same algorithms in it. Only implementation differs) Nope. For a sequence of 5 elements gcomb() is slighly faster. For 15 elements gcomb() is 27% faster than comb(). For 18 elements the difference is 31%. Neil From nperkins7 at home.com Thu Jun 14 22:18:14 2001 From: nperkins7 at home.com (Nick Perkins) Date: Fri, 15 Jun 2001 02:18:14 GMT Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gb41r0s6p@enews1.newsguy.com> Message-ID: ..nicely done, Alex! ..but what is your opinion as to whether this functionality belongs in the language itself? Those coming from other languages are likely to expect to have constant values of some sort. Your solution looks great, but still you have to type "const.foo" instead of just "foo". How much run-time overhead does this involve? I suppose only a tiny amount, and perhaps no more than even a 'language-level' implementation would have, but I think I would probably not use this in my most-inner loops. I suppose one could always bind a local name to the value.. width = const.width ..but then 'width' is no longer constant, and can be changed at will. From thomas at matrix3.ucd Tue Jun 26 01:29:14 2001 From: thomas at matrix3.ucd (Thomas Amsler) Date: Mon, 25 Jun 2001 22:29:14 -0700 Subject: Python-2.0.1 compile error Message-ID: I tried to build Python-2.0.1 but got compile errors. My environment: Linux RH7.1 gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-85) ------------------------------------------------------------------- cd Modules; make OPT="-g -O2 -Wall -Wstrict-prototypes -fPIC" VERSION="2.0" \ prefix="/usr/local" exec_prefix="/usr/local" \ sharedmods make[1]: Entering directory `/home/thomas/tmp/Python-2.0.1/Modules' gcc -fpic -g -O2 -Wall -Wstrict-prototypes -fPIC -I./../Include -I.. -DHAVE_CONFIG_H -c ./bsddbmodule.c ./bsddbmodule.c: In function `newdbhashobject': ./bsddbmodule.c:55: `HASHINFO' undeclared (first use in this function) ./bsddbmodule.c:55: (Each undeclared identifier is reported only once ./bsddbmodule.c:55: for each function it appears in.) ./bsddbmodule.c:55: parse error before `info' ./bsddbmodule.c:60: `info' undeclared (first use in this function) ./bsddbmodule.c:71: warning: implicit declaration of function `dbopen' ./bsddbmodule.c:71: warning: assignment makes pointer from integer without a cast ./bsddbmodule.c: In function `newdbbtobject': ./bsddbmodule.c:100: `BTREEINFO' undeclared (first use in this function) ./bsddbmodule.c:100: parse error before `info' ./bsddbmodule.c:105: `info' undeclared (first use in this function) ./bsddbmodule.c:118: warning: assignment makes pointer from integer without a cast ./bsddbmodule.c: In function `newdbrnobject': ./bsddbmodule.c:147: `RECNOINFO' undeclared (first use in this function) ./bsddbmodule.c:147: parse error before `info' ./bsddbmodule.c:152: `info' undeclared (first use in this function) ./bsddbmodule.c:164: warning: assignment makes pointer from integer without a cast ./bsddbmodule.c: In function `bsddb_dealloc': ./bsddbmodule.c:202: too few arguments to function ./bsddbmodule.c: In function `bsddb_length': ./bsddbmodule.c:232: structure has no member named `seq' ./bsddbmodule.c:233: `R_FIRST' undeclared (first use in this function) ./bsddbmodule.c:235: structure has no member named `seq' ./bsddbmodule.c:236: `R_NEXT' undeclared (first use in this function) ./bsddbmodule.c:229: warning: `status' might be used uninitialized in this function ./bsddbmodule.c: In function `bsddb_subscript': ./bsddbmodule.c:265: warning: passing arg 2 of pointer to function from incompatible pointer type ./bsddbmodule.c:265: too few arguments to function ./bsddbmodule.c: In function `bsddb_ass_sub': ./bsddbmodule.c:307: warning: passing arg 2 of pointer to function from incompatible pointer type ./bsddbmodule.c:307: too few arguments to function ./bsddbmodule.c:330: warning: passing arg 2 of pointer to function from incompatible pointer type ./bsddbmodule.c:330: too few arguments to function ./bsddbmodule.c: In function `bsddb_close': ./bsddbmodule.c:357: too few arguments to function ./bsddbmodule.c: In function `bsddb_keys': ./bsddbmodule.c:386: structure has no member named `seq' ./bsddbmodule.c:386: `R_FIRST' undeclared (first use in this function) ./bsddbmodule.c:407: structure has no member named `seq' ./bsddbmodule.c:407: `R_NEXT' undeclared (first use in this function) ./bsddbmodule.c:376: warning: `status' might be used uninitialized in this function ./bsddbmodule.c: In function `bsddb_has_key': ./bsddbmodule.c:440: warning: passing arg 2 of pointer to function from incompatible pointer type ./bsddbmodule.c:440: too few arguments to function ./bsddbmodule.c: In function `bsddb_set_location': ./bsddbmodule.c:466: structure has no member named `seq' ./bsddbmodule.c:466: `R_CURSOR' undeclared (first use in this function) ./bsddbmodule.c:453: warning: `status' might be used uninitialized in this function ./bsddbmodule.c: In function `bsddb_seq': ./bsddbmodule.c:503: structure has no member named `seq' ./bsddbmodule.c:489: warning: `status' might be used uninitialized in this function ./bsddbmodule.c: In function `bsddb_next': ./bsddbmodule.c:531: `R_NEXT' undeclared (first use in this function) ./bsddbmodule.c: In function `bsddb_previous': ./bsddbmodule.c:536: `R_PREV' undeclared (first use in this function) ./bsddbmodule.c: In function `bsddb_first': ./bsddbmodule.c:541: `R_FIRST' undeclared (first use in this function) ./bsddbmodule.c: In function `bsddb_last': ./bsddbmodule.c:546: `R_LAST' undeclared (first use in this function) make[1]: *** [bsddbmodule.o] Error 1 make[1]: Leaving directory `/home/thomas/tmp/Python-2.0.1/Modules' make: *** [sharedmods] Error 2 ------------------------------------------------------------------- -- Thomas Amsler tpamsler at ucdavis.edu amsler at cs.ucdavis.edu http://einstein.dyndns.org "Imagination is more important than knowledge." --Albert Einstein From dgilbert at dsl.ca Mon Jun 4 21:57:11 2001 From: dgilbert at dsl.ca (David Gilbert) Date: Mon, 04 Jun 2001 21:57:11 -0400 Subject: Wadda ya mean it's not defined? Impossible Error? References: <3B1C2727.D9E746CB@dsl.ca> <3B1C28D2.E4378E31@telocity.com> Message-ID: <3B1C3C77.5415002C@dsl.ca> Not the case here. the function is being called by the following code snippet: files = [] sampdef = {} for i in range(2,len(sys.argv)): files.append(sys.argv[i]+("/%04s/%02s" % (year, month)) + "/%d/%02d%02d.log") sampdef[('+', i)] = [] sampdef[('-', i)] = [] print files samples = {} skip = 1 minCache = {} names = ingestMapfile("/u/dgilbert/rules/hadrian3.rules.map") samples = parseLogs(files, names) ... and "print files" produces the following output: ['2/2001/05/%d/%02d%02d.log', '3/2001/05/%d/%02d%02d.log'] Adonis wrote: > just initialize paths; like in C/C++ (in idea) > def parseLogs(paths = '', custs): # should initialize path to NULL > > and your error should go away... > > David Gilbert wrote: > > > I'm getting what appears to be an impossible error. Here's a code > > snippet: > > > > def parseLogs(paths, custs): > > > > ipfRecord = re.compile("^([0-9]+)[ ]+([0-9]+)[ > > ]+([0-9a-z]+)([+-])") > > > > last = {} > > for i in range(len(paths)): # Create start times > > ... and so on. > > > > Here's the error snippet: > > > > File "../devel/ditty/bandsaw2.py", line 37, in parseLogs > > for i in range(len(paths)): # Create start times > > UnboundLocalError: local variable 'paths' referenced before assignment > > > > Just when should "paths" be assigned? > > > > Dave. From mwh at python.net Fri Jun 8 13:45:44 2001 From: mwh at python.net (Michael Hudson) Date: 08 Jun 2001 18:45:44 +0100 Subject: spell method chaining? References: <19l8IVAAgJI7EwAk@jessikat.demon.co.uk> Message-ID: scarblac at pino.selwerd.nl (Remco Gerlich) writes: > Usually you know that the base class is called eg Klass, and you simply call > that. In this case I think you have to store it inside the class manually, > like this: > > def gen(B): > class W(B): > def __init__(self): > self.__base.__init__(self) > W._W__base = B > return W > > (not the automatic 'name munging' the self.__base does, this way the > attribute is somewhat protected from classes inheriting it) But that doesn't work with />> class C: |.. def __init__(self): |.. pass \__ ->> gen(gen(C))() I couldn't think of a reasonable way around this in a few minutes of thinking; I could come up with some unreasonable ones (like, eg. bytecodehacks). > This is a bit of a hack, but then what you're doing isn't all that > common and it's fixed with nested scopes anyway. Yes. Cheers, M. -- C is not clean -- the language has _many_ gotchas and traps, and although its semantics are _simple_ in some sense, it is not any cleaner than the assembly-language design it is based on. -- Erik Naggum, comp.lang.lisp From jeff at ccvcorp.com Mon Jun 18 14:45:29 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: 18 Jun 2001 11:45:29 -0700 Subject: qt or gtk? References: <9gk8he$8gl$1@brokaw.wa.com> Message-ID: <16074dce.0106181045.139d80a5@posting.google.com> elf at halcyon.com (Elf Sternberg) wrote in message news:<9gk8he$8gl$1 at brokaw.wa.com>... > In article > sill at optonline.net (Rainy) writes: > > >> Qt is distributed under the GNU Public License and TrollTech's > >> Commercial License. What this means is that if you write a program > >> using Qt, you have two choices: you can distribute your program in the > >> whole, source code and all, or your can pay TrollTech's licensing > >> contract and keep your source code secret. > > >Is this true for both qt for X and qt for windows or only for X qt? > > The GNU Public License does not specify what operating systems > it applies to. If you can build or modify the GPL version of QT to work > with the Windows operating system, then you can build GPL programs for > Windows with QT. > > Elf But if (as was stated before) only the X11 codebase is available under GPL, then the fact that the license doesn't specify an OS is a technical detail. In order to run the GPL version under Windows, you would essentially be emulating Unix on Windows (cygwin + X-server), with all the little gotchas that tend to come with emulation. Of course, if the X11 source is GPL, then you could, in theory, port that to Win32 yourself.... Personally, I'd rather use wxPython. It's OS-independent, seems fairly simple to use, and tries to provide OS-native look-and-feel as much as is practical. Tkinter is similarly OS-independent, but (as someone else mentioned) the look of Tk seems somehow.... off. Tkinter also requires a running installation of TCL, and passes all commands through that, which I'm not too thrilled about (though this is mostly an aesthetic issue). Jeff Shannon Technician/Programmer Credit International From foo at ix.netcom.com Thu Jun 7 16:59:54 2001 From: foo at ix.netcom.com (Matt Butler) Date: 7 Jun 2001 13:59:54 -0700 Subject: Win32 Installer on 2.1? References: <50be6f7c.0105220115.612c9912@posting.google.com> <50be6f7c.0106062352.a6f2670@posting.google.com> Message-ID: <50be6f7c.0106071259.13fcbfc3@posting.google.com> Ben- Benjamin Schollnick wrote in message news: I haven't been following the conference too well lately, was there a > specific problem you are having with Installer under v2.1? Thanks for your response, I have actually not had a problem yet with 2.1, it's just that the readme omits 2.1 from the list of configurations on which Installer has been tested. I was trying to avoid the pain of upgrading only to have to revert back to 2.0 if it's horked. It seemed like a "gimme" that somebody who already had 2.1 would have tried it by now. I thought I'd get like ten responses of the "Yea, Works great. No, Definitely horked." variety and that would be that. Instead, I will just have to take the pain myself and report back here I guess... From nperkins7 at home.com Fri Jun 15 17:28:45 2001 From: nperkins7 at home.com (Nick Perkins) Date: Fri, 15 Jun 2001 21:28:45 GMT Subject: profile.run won't run! References: <24gW6.284794$oc7.18522490@news2.rdc2.tx.home.com> Message-ID: "Rainer Deyke" wrote in message news:EZpW6.288352$oc7.19519615 at news2.rdc2.tx.home.com... > My mistake; this should be: > > profile.run('solve_problem()') Thanks again, i thought so, and tried that, too. .. but it still won't run. I get an Unbound Local error at the first imported function.. Here is the error, and the relevant code, if anyone can help... Traceback (most recent call last): File "e:\komodo\mozilla\chrome\komodo\content\python\kdb.py", line 640, in ? requester.start(sys.argv[arg_num:]) File "e:\komodo\mozilla\chrome\komodo\content\python\kdb.py", line 570, in start return Requester.start(self, debug_args) File "e:\komodo\mozilla\chrome\komodo\content\python\kdb.py", line 256, in start self._do_start(debug_args) File "e:\komodo\mozilla\chrome\komodo\content\python\kdb.py", line 286, in _do_start self.kdb.run(code_ob, locals, locals) File "c:\python21\lib\bdb.py", line 351, in run exec cmd in globals, locals File "E:\Komodo\python\my\profile_soko.py", line 46, in ? profile.run('solve_problem()') File "c:\python21\lib\profile.py", line 71, in run prof = prof.run(statement) File "c:\python21\lib\profile.py", line 356, in run return self.runctx(cmd, dict, dict) File "c:\python21\lib\profile.py", line 362, in runctx exec cmd in globals, locals File "", line 1, in ? File "E:\Komodo\python\my\profile_soko.py", line 21, in solve_problem solv = sokoban.solver_class(filename) File "E:\Komodo\python\my\sokoban.py", line 413, in __init__ self.board, blocks, soko = load_soko(filename) File "E:\Komodo\python\my\sokoban.py", line 358, in load_soko file = open(file_name,'r') UnboundLocalError: local variable 'file_name' referenced before assignment ========== Python debug run finished. ========== here is the part that chokes: --------:file:profile_soko.py:----------- import sokoban import sys, time import profile filename = sys.argv[1] <= not the problem, arg is passing ok.. def solve_problem(): print 'you chose: ', filename <= works during profile run... solv = sokoban.solver_class(filename) <= chokes here, caused by imported sokoban.py start_time = time.time() solution = solv.find_solution() elapsed_time = time.time()-start_time print filename print elapsed_time, 'seconds' print solution print 'direct:' solve_problem() import __main__ __main__.solve_problem = solve_problem print 'profiled:' profile.run('solve_problem()') --------------::file sokoban.py::------------------------------- ... def load_soko(file_name): file = open(file_name,'r') <== line 358: Unbound Local error: 'file_name' lines = file.readlines() ( what's up with that???) file.close() ... more stuff.. class solver_class: def __init__(self,filename): self.board, blocks, soko = load_soko(filename) ...more stuff... It also still works if I call exec('solve_problem()'), but not if call profile.run('solve_problem()'). ...dazed and confuzed... --Nick Perkins. From jonbeebe at softhome.net Mon Jun 25 23:18:22 2001 From: jonbeebe at softhome.net (Beebe) Date: 25 Jun 2001 20:18:22 -0700 Subject: new to python Message-ID: Hello comp.lang.python, I am a Linux User and I am new to Python Programming and this newsgroup. I don't really know what python is all about so it would be much appreciated if you would answer my following questions. - Is python like c/c++ where you can make pretty much any kind of program you want whether is be games, gui apps, etc. or is it like cgi where you can only use it in websites? - Is python object oriented? - Should I develop in Python? Is it good for programming, is it powerfull and are job opportunities good for Python developers? - When I make a Python program, do I just leave it as a .py file or is there a way to make it into some kind of executable file like in C++? When I make a program in Python, how do I distribute it out to people? Do I just send out the .py file? Does the user need some kind of runtime environment or something? Do they need to download something else rather than my program? I know that's a lot of questions but I haven't found them on the net yet. Please answer my questions if you will by emailing me at jonbeebe at softhome.net. If you email me, that way I'll be sure to recieve the reply, otherwise, i might miss it. Thank you very much, - Beebe From BPettersen at NAREX.com Tue Jun 5 11:42:00 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Tue, 5 Jun 2001 09:42:00 -0600 Subject: subclassing wxMenuBar... Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D434@admin56.narex.com> > From: Tom Jenkins [mailto:tjenkins at devis.com] > Bjorn Pettersen wrote: > > > I was stepping through the wxPython tutorial, and came > across the part > > where they're creating the menus. It seemed like a good > idea to put the > > menu definition in a datafile instead of specifying it > programatically, > > so I though it would be a good chance to get some xml > experience too... > > > > > Yep, that makes sense... > > [snip] > > > > which I'm assuming means that the SWIGd code is expecting a > wxMenuBar > > pointer to be the first argument to Append and can't deal with a > > subclass... > > > > Does anyone know a way around this? > > > > -- bjorn > > > > > > Well I wouldn't subclass wxMenuBar; instead I'd create a helper class > that would handle reading the xml and loading it into the > wxMenuBar. I > took your code and changed it to work as a helper. Along the way I > added some functionality. Cool. Thanks! I was wondering how I would easily add callback definitions :-) -- bjorn From cer at tutopia.com Wed Jun 6 09:29:27 2001 From: cer at tutopia.com (Cristian Echeverria) Date: 6 Jun 2001 06:29:27 -0700 Subject: 2 language applications References: <9fk6ll$4ln39$1@ID-44371.news.dfncis.de> <9fkubv0i48@enews2.newsguy.com> Message-ID: <33476bef.0106060529.98d247f@posting.google.com> That is what I call "AN EXPLANATION"... ...Thank you very much Now I understand what are those .po and .mo files Cristian "Alex Martelli" wrote in message news:<9fkubv0i48 at enews2.newsguy.com>... > "Cristian Echeverria" wrote in message > news:9fk6ll$4ln39$1 at ID-44371.news.dfncis.de... > > Hi > > > > I have a gui application with all the messages in spanish, now I want to > > include an option that allow the user to choose the language. > > > > Wich is the right way to do things like this? > > Any suggestion that can help me? > > > > (I'am using Python2.0 and wxPython 2.3 on win9X) > > See standard Python module gettext -- it's part of core > Python so you should have it in any distribution. > > The tools to *generate* the needed messagefiles may or > may not be part of your Python distribution -- if you > can't find them, get a Python *source* distribution and > look for Tools/i18n. (Not sure why this VERY useful > directory is not included in some distributions - it's > just two Python scripts after all!-). > > Say I have this big Python application saluta.py...: > print "buon giorno!" > print "ciao!") > print "buona sera!" > > First I internationalize it as follows: > import os,gettext > > os.environ.setdefault("LANGUAGE","it") > gettext.install('saluta') > > print _("buon giorno!") > print _("ciao!") > print _("buona sera!") > > The key thing is marking with _(...) the > strings which ARE to be translated! > > Now I can't run it...: > > D:\py21>python saluta.py > Traceback (most recent call last): > File "saluta.py", line 4, in ? > gettext.install('saluta') > File "d:\python21\lib\gettext.py", line 251, in install > translation(domain, localedir).install(unicode) > File "d:\python21\lib\gettext.py", line 238, in translation > raise IOError(ENOENT, 'No translation file found for domain', domain) > IOError: [Errno 2] No translation file found for domain: 'saluta' > > D:\py21> > > I have to prepare a message file first...: > > D:\py21>python \python-2.1\Tools\i18n\pygettext.py saluta.py > > D:\py21>type messages.pot > # SOME DESCRIPTIVE TITLE. > # Copyright (C) YEAR ORGANIZATION > # FIRST AUTHOR , YEAR. > # > msgid "" > msgstr "" > "Project-Id-Version: PACKAGE VERSION\n" > "POT-Creation-Date: Wed Jun 06 11:29:12 2001\n" > "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" > "Last-Translator: FULL NAME \n" > "Language-Team: LANGUAGE \n" > "MIME-Version: 1.0\n" > "Content-Type: text/plain; charset=CHARSET\n" > "Content-Transfer-Encoding: ENCODING\n" > "Generated-By: pygettext.py 1.3\n" > > > #: saluta.py:5 > msgid "buon giorno!" > msgstr "" > > #: saluta.py:7 > msgid "buona sera!" > msgstr "" > > #: saluta.py:6 > msgid "ciao!" > msgstr "" > > > D:\py21> > > Now I have to edit this textfile to prepare the > needed .po files -- after the beginning metadata > (to be suitably edited), I'll have an it.po something > like: > #: saluta.py:5 > msgid "buon giorno!" > msgstr "buon giorno!" > > #: saluta.py:7 > msgid "buona sera!" > msgstr "buona sera!" > > #: saluta.py:6 > msgid "ciao!" > msgstr "ciao!" > > and an en.po something like: > #: saluta.py:5 > msgid "buon giorno!" > msgstr "good morning!" > > #: saluta.py:7 > msgid "buona sera!" > msgstr "good evening!" > > #: saluta.py:6 > msgid "ciao!" > msgstr "hello!" > > So I compile them: > D:\py21>python \python-2.1\Tools\i18n\msgfmt.py en.po > > D:\py21>python \python-2.1\Tools\i18n\msgfmt.py it.po > > And prepare the needed directories (lots of intermediate > mkdir's snipped:-): > D:\py21>mkdir \python21\share\locale\it\LC_MESSAGES > D:\py21>mkdir \python21\share\locale\en\LC_MESSAGES > > and put the .mo files in the right places: > > D:\py21>copy it.mo \python21\share\locale\it\LC_MESSAGES\saluta.mo > 1 file(s) copied. > > D:\py21>copy en.mo \python21\share\locale\en\LC_MESSAGES\saluta.mo > 1 file(s) copied. > > D:\py21> > > And NOW it finally runs properly: > > D:\py21>python saluta.py > buon giorno! > ciao! > buona sera! > > D:\py21>set LANGUAGE=en > > D:\py21>python saluta.py > good morning! > hello! > good evening! > > > I hope this simple toy example helps you get started... it's a > rich and complex system, meant to cover potentially very large > applications with dozens of languages, modules that must not > touch global settings, etc, etc, and it works quite smoothly > over its broad range of applicability, even though it MAY look > like a BIT of an overkill when just looking at one simple case > such as this one!-) > > > Alex From trace at reinventnow.com Wed Jun 13 11:15:32 2001 From: trace at reinventnow.com (tracy s. ruggles) Date: Wed, 13 Jun 2001 15:15:32 GMT Subject: Distutils error on a VPS Message-ID: Has anyone out there had experience installing new packages on a VPS (virtual private server)? I've posted a few question about trying to install MySQLdb and haven't received any response... Are there any tricks to installing on a VPS? All of the code in distutils/sysconfig.py spits out wrong directory paths for the include and header directories. I've tried altering that code but to no avail... I still get this error: building '_mysql' extension gcc -g -O2 -Wall -Wstrict-prototypes -fPIC -I~/usr/local/mysql-3.23.38/include/mysql -I/usr/home/ol0401/usr/local/Python-2.1/Lib -c _mysql.c -o build/temp.solaris-2.6-sun4u-2.1/_mysql.o _mysql.c:31: Python.h: No such file or directory _mysql.c:40: structmember.h: No such file or directory _mysql.c:41: mysql.h: No such file or directory _mysql.c:42: mysqld_error.h: No such file or directory _mysql.c:43: errmsg.h: No such file or directory error: command 'gcc' failed with exit status 1 Does anyone know what's going? Thanks, Tracy -- Tracy S. Ruggles -- COPI / OutputLinks -- http://www.outputlinks.com Email) TR at 888999copi.com Phone) 888/999.copi ext "TR" From sholden at holdenweb.com Thu Jun 14 08:18:39 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 14 Jun 2001 08:18:39 -0400 Subject: Office's Access XP ODBC DBI from PythonWin References: <9ga6cd02m44@enews1.newsguy.com> Message-ID: "Alex Martelli" wrote ... > "Steve Holden" wrote ... > ... > > Has the Win32 odbc module been updated at all since 2.0? I have a feeling > > you might find it less than satisfactory for extended use - I've certainly > > had problems myself. > > Hmmm, I did send you my partially-fixed version, yes...? > Yes. I've even installed a compiler so I can build myself a binary next time I get home :-) > > > Unfortunately the dbi.dbiDate object has a null __doc__,but I notice the > > dbi.py module requires mx.DateTime. Had you considered using mx.ODBC > instead > > of ODBC? If you don't plan commercial use it is free, and I can certainly > > recommend it for ease of use. > > Seconded. But a minimally-working free odbc would still be > a good thing IMHO. Say I write utilities to be internally > used here at work (commercial use by mx's terms). As long > as I run them on Windows only, I'm OK -- I can program to > ADO and connect that to whatever DB engine. But -- no funds > for mxODBC for that use. So -- no running my utilities on > Linux boxes. Notch one more black mark discouraging this > spread of Linux boxes around here:-(. > Good plan. I've noticed that Unix isn't as liberally supplied with ODBC dupport. I've tried to install both unixODBC and iODBC driver managers, and both have problems on my Linux boxes. Cross-platform support has a ways to go. regards STeve From tdelaney at avaya.com Tue Jun 26 20:36:25 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Wed, 27 Jun 2001 10:36:25 +1000 Subject: PEP 260: simplify xrange() Message-ID: > Here's another sweet and short PEP. What do folks think? Is > xrange()'s complexity really worth having? > > --Guido van Rossum (home page: http://www.python.org/~guido/) > > PEP: 260 > Title: Simplify xrange() > Version: $Revision: 1.1 $ > Author: guido at python.org (Guido van Rossum) > Status: Draft > Type: Standards Track > Python-Version: 2.2 > Created: 26-Jun-2001 > Post-History: 26-Jun-2001 > > Abstract > > This PEP proposes to strip the xrange() object from some rarely > used behavior like x[i:j] and x*n. > > > Problem > > The xrange() function has one idiomatic use: > > for i in xrange(...): ... If this is to be done, I would also propose that xrange() and range() be changed to allow passing in a straight-out sequence such as in the following code in order to get rid of the need for range(len(seq)): import __builtin__ def range (start, stop=None, step=1, range=range): """""" start2 = start stop2 = stop if stop is None: stop2 = start start2 = 0 try: return range(start2, stop2, step) except TypeError: assert stop is None return range(len(start)) def xrange (start, stop=None, step=1, xrange=xrange): """""" start2 = start stop2 = stop if stop is None: stop2 = start start2 = 0 try: return xrange(start2, stop2, step) except TypeError: assert stop is None return xrange(len(start)) a = [5, 'a', 'Hello, world!'] b = range(a) c = xrange(4, 6) d = xrange(b) e = range(c) print a print b print c print d print e print range(d, 2) Tim Delaney From LOLLYRB at aol.com Wed Jun 20 18:39:12 2001 From: LOLLYRB at aol.com (LOLLYRB at aol.com) Date: Wed, 20 Jun 2001 18:39:12 EDT Subject: Need info Message-ID: I joined click 6-2-01 and have enjoyed receiving messages. I have a pass word and confirmation of subscription. Please tell me how a post a message. Thank you Ruth West -------------- next part -------------- An HTML attachment was scrubbed... URL: From aleaxit at yahoo.com Mon Jun 18 03:55:53 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 18 Jun 2001 09:55:53 +0200 Subject: Python equivalent of CPAN Library modules References: Message-ID: <9gkc6a021cv@enews2.newsguy.com> "GADGIL PRASAD /INFRA/INFOTECH" wrote in message news:mailman.992846907.9012.python-list at python.org... > hello, > > I kinda find larry wall's thaught very interesting. And his complete > openness of ppl choosing lang other than perl. > > So, what I wanna ask is, > is it technically possible to use perl modules from python programs.. ? > > not parrot maybe but something in between.... http://www.equi4.com/minotaur/minotaur.html """ Minotaur for Perl, Python, andTcl Minotaur is an extension which can be used from Tcl, Python, or Perl to run scripts in any of the other languages. The latest news can be found at http://www.equi4.com/minotaur/ Source code can also be found at the above URL Prebuilt binaries: not yet... """ Alex From root at rainerdeyke.com Sun Jun 24 21:05:03 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 25 Jun 2001 01:05:03 GMT Subject: Nested Scopes Question (exec) References: Message-ID: <37wZ6.362911$oc7.43121264@news2.rdc2.tx.home.com> "Rainer Deyke" wrote in message news:DWvZ6.362805$oc7.43089434 at news2.rdc2.tx.home.com... > The wording here should probably be changed to "may or may not". Otherwise > people might start to rely on the fact that dictionary usually doesn't > affect the local variables and do stuff like this: > > def f(x): > d = locals() > d['x'] += 5 > exec 'print x' in d Oops, bad example. How about this: def f(x): d = locals() d['x'] += 5 assert d['x'] != x I know, it's totally contrived. More realistically: def run_arbitrary_code(code): try: exec code in locals() except: print 'Exception raised by arbitrary code: "%s"' % code run_arbitrary_code('del code;raise SyntaxError') If modifying the dictionary returned from 'locals' changes the local variables, then the function 'run_arbitrary_code' can be forced to throw an exception by malicious code. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From grante at visi.com Tue Jun 19 11:19:43 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 19 Jun 2001 15:19:43 GMT Subject: String encode() method error handling options? Message-ID: The documentation for the encode() method mentions that the default action for an encoding error is to raise ValueError. The other options are 'ignore' and 'replace'. Can anybody point me to documentation on or examples of the ingore and replace options? When doing encode('latin-1') on unicode strings received via COM/MAPI, I occasionally get a value error. When I look at the message with Outlook there's nothing obviously strange about the text. I forgot to save an example that causes the error, so I don't currently have any way to experiment. -- Grant Edwards grante Yow! Is the EIGHTIES at when they had ART DECO visi.com and GERALD McBOING-BOING lunch boxes?? From bsb at winnegan.de Mon Jun 25 09:10:06 2001 From: bsb at winnegan.de (Siggy Brentrup) Date: 25 Jun 2001 15:10:06 +0200 Subject: Scripts (running once) In-Reply-To: References: <3B37271F.759B0236@usa.net> Message-ID: <87ofrcn1sh.fsf@winnegan.de> Olaf Trygve Berglihn writes: > mixo writes: > > > How can one find out if there is a particular python script runnig, and > > hence prevent > > the same script from being run again? For instance, say I run a script > > 'mytes.py' with > > the following command: > > > > python mytes.py > > > > Now, the next time a user types the same command, a message saying the > > script is > > already running (or something of that sort) should be printed, as the > > script has not > > termintated. > > How about using a lock-file? This code removes the lock after the > program has ended. Replace the finally-statements with a pass if you > want the program to be executed only once. Note that the user must > have write-permissons for the lockfile. > > > #!/usr/bin/env python > > import os > > LOCKFILE="/tmp/myprog.lock" > > def main(): > #your code here > import time > time.sleep(20) # pause for 20 sek. > > if __name__ == '__main__': > if os.path.isfile(LOCKFILE): > import sys > sys.stdout.write("Already running myprog\n") > sys.exit(1) > else: > fd = open(LOCKFILE, 'w') > fd.close() > try: > main() > finally: > if os.path.isfile(LOCKFILE): > os.remove(LOCKFILE) This program contains a raise condition, what if two users are simultaneously trying to run it. On *nix systems use instead (Python 2.1): if __name__ == '__main__': from os import O_CREAT, O_EXCL import sys try: fd = os.open(LOCKFILE, O_CREAT+O_EXCL) except OSError: print >>sys.stderr, 'Already running ...' sys.exit(1) try: main() finally: os.remove(LOCKFILE) -- Siggy Brentrup - bsb at winnegan.de - http://www.winnegan.de/ ****** ceterum censeo javascriptum esse restrictam ******* From tommasz at frontiernet.net Mon Jun 4 13:29:39 2001 From: tommasz at frontiernet.net (Tom Maszerowski) Date: Mon, 04 Jun 2001 17:29:39 -0000 Subject: Struct question (SOAPpy095) Message-ID: <9fggi3+557b@eGroups.com> I am using Python 2.1, with SOAPpy095, with the Radio Userland SOAP server. Here is some code I have: ################ import SOAP import urlparse import string import types import pprint soapServer = SOAP.SOAPProxy(urlparse.urljoin(baseServerURL, examplesDir)) quote = soapServer.getStockPrice(symbol="AAPL") print quote ################ This results in: My question is, what is this and how do I access it? Forgive me, but I'm new to Python. Tom. From daniel.dittmar at sap.com Mon Jun 18 11:50:01 2001 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Mon, 18 Jun 2001 17:50:01 +0200 Subject: getting a reference to a class inside its definition References: <9noX6.14930$uR5.1138042@news20.bellglobal.com> Message-ID: <9gl7va$s1p$1@news1.wdf.sap-ag.de> > Still, I want to be able to reference a class inside it's own definition. > Is this possible or am I going to have to do It depends on what you try to achieve. If you want to access class variables inside the class definition, do so without any qualification: class SomeClass: hello = 'hello' world = 'world' greeting = hello + ', ' + world print SomeClass.greeting Daniel From ben.hutchings at roundpoint.com Thu Jun 28 15:55:31 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 28 Jun 2001 12:55:31 -0700 Subject: WinNT: Delete to recycle bin? References: <9hg04d$r9f$1@iocextnews.bls.com> Message-ID: "John Hoerr" writes: > hi! > i'm relatively new to python and am wondering if there's a way to remove > files to the windows recycle bin instead of deleting them outright. > > google searches of the web and this newsgroup didn't turn up much, but i'm > hoping i missed something? The Windows function to do this is SHFileOperation. As far as I can see, there is currently no Python wrapper for this. From paulp at ActiveState.com Sun Jun 17 16:29:33 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sun, 17 Jun 2001 13:29:33 -0700 Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? References: <3B2B60AD.942719AE@earthlink.net> Message-ID: <3B2D132D.811EDF1A@ActiveState.com> res04o20 wrote: > >... > > And lastly, ActiveState has announced "Visual Python". Only problem is, you > gotta have MS .Net. (shudder) (Yet another implementation of Python. This > time in C#. Another learning curve to be ultimately successful.) You are conflating two different things. Visual Python [1] and Python .NET [2] are completely unrelated (but interoperable, of course) [1] http://aspn.activestate.com/ASPN/Downloads/VisualPython/ [2] http://aspn.activestate.com/ASPN/NET/ -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From tim.one at home.com Mon Jun 4 01:40:22 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 4 Jun 2001 01:40:22 -0400 Subject: nested scopes in IDLE? (2.1) In-Reply-To: Message-ID: Kirby, "from __future__ import nested_scopes" isn't effective at the IDLE prompt. This was listed as an open issue in the design PEP and still isn't resolved. It is effective at a native shell prompt ("DOS box" on Windows), but that has access to internal machinery that *simulated* shells (like IDLE's and PythonWin's etc) can't get at -- at least not yet. The easiest way to use nested scopes in IDLE is to create a new IDLE edit window (File -> New window (Ctrl+N)), put from __future__ import nested_scopes at the top of it, type your code into it, and do Edit -> Run script (Ctrl+F5) from time to time. For example, I typed this into an edit window: from __future__ import nested_scopes def compose(f,g): return lambda f,g,x: f(g(x)) saved it, hit Ctrl+F5, then here's my IDLE session: Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. IDLE 0.8 -- press F1 for help >>> >>> c = compose(lambda x: x**2, lambda x: x+1) >>> c(12) Traceback (most recent call last): File "", line 1, in ? c(12) TypeError: () takes exactly 3 arguments (1 given) >>> That error msg is correct! The lambda you're returning does indeed require 3 arguments, so your code will never work the way you hope. At this point you're *glad* you had to use a separate window, because now you can just go back and edit it (I'm just removing the unwanted arguments to lambda here): from __future__ import nested_scopes def compose(f,g): return lambda x: f(g(x)) Save and hit Ctrl+F5 again, and here's what happens now: >>> c = compose(lambda x: x**2, lambda x: x+1) >>> c(12) 169 >>> c(11) 144 >>> c(0) 1 >>> c(1) 4 >>> All is cool. From rumjuggler at cryptarchy.org Fri Jun 29 20:22:25 2001 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Sat, 30 Jun 2001 00:22:25 GMT Subject: PEP scepticism References: Message-ID: On Sat, 30 Jun 2001 00:29:48 +0100, philh at comuno.freeserve.co.uk (phil hunt) wrote: >On Fri, 29 Jun 2001 17:43:34 -0400, Tim Peters wrote: >>Or the other existing method: >> >> # This is a multi-line comment. >> # Although it sure looks like a sequence of >> # single-line comments . > >This is truly bad, because it makes it harder to add new lines; >you have to type "# " repeatedly when adding new comment text, which >breaks the flow of thought -- at least it dores for me. You don't need to write them that way. I write long comments by just writing a bunch of stuff, letting it get colorized &c, and then going back and adding # at the appropriate place. No breakage in the flow of thought, no problem. -- Barnabas T. Rumjuggler Yet when he came down from the mountain, he had not gained any wisdom. In no way had he been able to solve the riddle of this story. And he had lost his faith. But he had discovered that he had an affinity for Dixieland music. -- Joe Frank, "The Road to Calvary" From richard at NOstarfighterSPAM.freeuk.com Mon Jun 11 13:52:55 2001 From: richard at NOstarfighterSPAM.freeuk.com (Richard Townsend) Date: Mon, 11 Jun 2001 18:52:55 +0100 Subject: Disabling a Pmw.ComboBox References: Message-ID: <2B7V6.88036$ML4.6330723@nnrp4.clara.net> "Martyn Quick" wrote in message news:Pine.GSO.4.21.0106111351450.10068-100000 at plesset... > I'm trying to work out how to `disable' a Pmw.ComboBox (in a similar > manner to setting state='disabled' for a Tkinter.Button). One way I > thought of doing it was to try setting state='disabled' for the > 'arrowbutton' component of the ComboBox. However, this arrowbutton is a > Tkinter.Canvas, so doesn't have state as a valid configuration option. > > Does anybody have a decent way of doing this? (My goal is to be able to > allow it be available for use or disabled according to other information.) > Take a look at: http://www.faqts.com/knowledge_base/view.phtml/aid/3960/fid/264 From see at my.signature Tue Jun 19 21:31:33 2001 From: see at my.signature (Greg Ewing) Date: Wed, 20 Jun 2001 13:31:33 +1200 Subject: Any other Python flaws? References: <#72#QIT9AHA.262@cpmsnbbsa09> <3b2a7edd.586265184@wa.news.verio.net> Message-ID: <3B2FFCF5.2C89B5B1@my.signature> Bengt Richter wrote: > > Why not the other way around? I.e., drop the mandatory "()" > for function defs with no args. I think it's good that () is always present in a function def. Otherwise, what does "def" mean? Something is being defined, but what? The () makes it clear that a function is being defined. It's not so important with a class, since the word "class" makes it pretty clear that we're defining a class! But it would be nice if () were at least optional in that case. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From quacko at lists.postmastergeneral.com Fri Jun 29 14:13:01 2001 From: quacko at lists.postmastergeneral.com (Quacko Lotto) Date: Fri, 29 Jun 2001 14:13:01 EDT Subject: PLAY TODAY! WIN $1,000,000 TOMORROW! Message-ID: <200106291822.MAA06061@s0227.pm0.net> **************************************** PLAY TODAY! WIN $1,000,000 TOMORROW! **************************************** Quacko Lotto continues to strive to be on the cutting edge of lotto games on the internet. We have the VERY BEST ODDS of Winning a $1,000,000 Grand Prize on the net. Is today your lucky day? The Internet's Only Pick 1 Game Plus the Best Odds of Winning a Grand Prize Check out what everyone is talking about! http://lotto.quacko.com WEEKLY DRAW & GIVEAWAYS! ****************************** How would you like to WIN a brand NEW DVD player? How would you like to WIN up to $2000 every week? Play every week to be entered in our random draw and win these great prizes! Click Here: http://lotto.quacko.com ****************************************** RECEIVE FREE MONEY AT SUPREMECASINO! ****************************************** http://www.supremecasino.com Free money on all deposits... just one of the reasons we're VOTED #1 with Online Wagerers! Have your tried PayPal Yet? Supremecasino offers the easiest and most reliable processing solutions for its wagerers! Just look what the CNET says about PayPal! 'PayPal's the most reliable personal bill payment service on the Web. It's easy to use, offers a convenient auction payment form, and delivers your dough faster than most of the other services we reviewed. We think PayPal offers the best combination of speed, security, and features. And best of all, it's free.' Why not try out Paypal today? 100% Bonus! Up to $75 free money on initial credit card deposits including PayPal and NETeller! 5% Bonus on any further Credit Card Deposits 40% Bonus Initial Western Union Deposits 15% Bonus on any further Western Union Deposits 20% Bonus On Wire or Personal Check Deposits Combine the BEST in online casino games with FREE money and you've got some major excitement! Come and play for free! http://www.supremecasino.com <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> * To remove yourself from this mailing list, point your browser to: http://inbound.postmastergeneral.com/remove?quacko * Enter your email address (python-list at cwi.nl) in the field provided and click "Unsubscribe". The mailing list ID is "quacko". OR... * Reply to this message with the word "remove" in the subject line. This message was sent to address python-list at cwi.nl X-PMG-Recipient: python-list at cwi.nl <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> <<<>>> From greg at cosc.canterbury.ac.nz Thu Jun 7 21:20:58 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 08 Jun 2001 13:20:58 +1200 Subject: Decimal can be Binary Too (was decimal or rational) References: <3B183614.E299F31E@home.com> Message-ID: <3B20287A.78370355@cosc.canterbury.ac.nz> Don O'Donnell wrote: > > If someone can think of a better name please let me know. How about "float10"? -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From spam_kill.guse at hobbiton.org Tue Jun 5 09:33:08 2001 From: spam_kill.guse at hobbiton.org (goose) Date: Tue, 05 Jun 2001 13:33:08 GMT Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3B1A47EA.AFBD45E8@lmf.ericsson.se> Message-ID: <3b1cdf94.55bd@bolder.com.co.za> Attila Feher merely scratched his head and went: < > [SNIP] >> In some countries there are even more Unix/Linux PCs than Windows PCs. Please >> never assume that what is valid in your country is valid for the rest of the >> world as well. You are not living alone on that planet and your country isn't >> the only one that exists or that is important. > [SNIP] > > Just to inform you: the worlds easiest to hack and crack systems are the > UNIX systems. this is an opinion ... not a fact ... www.hackinthebox.org was once giving out a top 20 list of sites which were most orginally hacked ... not a single unix machine on their list ... www.attrition.org has more info on what systems get hacked, and nt leads the pack, even though it is the least used of the lot as http servers. does this mean that the unicode bug is, finally, fixed ... 'cos i've seen script kiddies who don't know what a nybble is hack IIS, but get totally lost on UNIX systems ... sure bind has it's share of problems, but subscribe to the mailing lists www.securityfocus.com ... a real eyeopener if you think that unix is easier to crack than nt. > Due to the fact that they have been designed for > university (friendly) environment. serious multi-user environments, unlike windows which evolved from a single-user single-tasking os with no security at all ... > Serious users (security, incl. but > not limited to NATO, banks etc.) use VMS. Some smaller banks use(d) i agree > OS/2. But what is sure: Linux (UNIX) with sources is ony used (at > serious places) as firewall (where the actuall OS is inspected and > corrected line by line) and as a Web Server with no online connection to > the real internal network. So don't take UNIX to any higher level than > it is. i'm sorry - openbsd is probably *THE* most secure os on the planet ... go to the website and read up about it (not too sure what it is, but should be easy to find, considering it's popularity) ... be prepared to be impressed ... regards, -- goose ----- From chapman at bioreason.com Fri Jun 15 18:31:50 2001 From: chapman at bioreason.com (Mitch Chapman) Date: Fri, 15 Jun 2001 16:31:50 -0600 Subject: Any other Python flaws? References: <3B2A530C.5F798823@bioreason.com> <3dvglxe9j3.fsf@ute.cnri.reston.va.us> Message-ID: <3B2A8CD6.DB8AEF5C@bioreason.com> Paul Prescod wrote: > > Andrew Kuchling wrote: > > > > ... > > > > It's hard to see how you could implement cancellable threads with > > reasonable performance, though, unless the OS implements all the > > primitives and can therefore clean things up when a thread is > > cancelled. I lean more and more toward thinking that threads are a > > mistake, and if you think you need them, your OS simply has processes > > that are too heavyweight. > > There are many graphical applications that use threads to keep the user > interface responsive while doing heavy computation or network IO in the > background. Let's say we spin those out into processes. What would you > propose for sharing data structures? COM? These are precisely the sorts of applications where I've wished for usable threads. (Thanks for offering a more concrete example, Paul.) I need to manage long-running, parameter-rich computations from GUI applications while still responding to the user. I think I need threads because they make it easier to exchange all of those parameters between the GUI controller and the background computation than do separate processes. I think I need processes because I need to be able to cancel the background computation. This is cumbersome even though I'm using Python as the wire protocol to communicate parameters between processes.* Basically it bothers me that, on every platform (Solaris, Linux, Windows) on which I've done MT programming, the platform-native threading API has been more useful than the standard Python threading API. Maybe this is what you meant about threading being a mistake? I.e. that Python should just offer platform-specific facilities -- as it does for posix -- instead of trying to offer a lowest-common-denominator API? -- Mitch Chapman Mitch.Chapman at bioreason.com *[All that having been said, processes offer the obvious advantage of protecting the GUI process from bug-induced brain damage in the background process.] From bill-bell at bill-bell.hamilton.on.ca Fri Jun 22 15:56:34 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Fri, 22 Jun 2001 15:56:34 -0400 Subject: Sufficient conditions for COM local server to be singleton In-Reply-To: <993075729.911.47942.l8@yahoogroups.com> Message-ID: <3B336AB2.30394.406104F@localhost> On 20 Jun 2001, at 22:22, python-list at yahoogroups.com wrote: gmcm at hypernet.com (Gordon McMillan) wrote: > Bill Bell wrote: > > ... to make a COM local server fire up in only a single copy ... > > No, not quite. Using CLSCTX_LOCAL_SERVER is enough to ensure > that there's only a single copy of your module loaded. If you > want only one copy of your instance ... Gordon, thank you. In spite of the fact that I put the wrong question(!) what you wrote finally put me on the right path. - Bill Bill Bell, Software Developer From gustafl at algonet.se Wed Jun 20 10:25:41 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 20 Jun 2001 14:25:41 GMT Subject: Extremely strange problem with httplib/urllib References: <3B2FF349.DE4BF886@crc.co.jp> Message-ID: HEMMI Shigeru wrote: >I am using Python 2.1 on Win98. >I was able to use urllib from my computer. I really appreciate your help, but it's not a problem of understanding how to use urllib/httplib. I have used them before in various scripts, without this error. The scripts still work: it's only that I get a invalid page fault error afterwards all the time, and always when I have attempted a web connection using any of these two modules. I tried your code too, with the same result. So it's nothing wrong with the code. It's something strange going on between Python and my instance of Windows. It would problaby help to reinstall Windows, but I hope this won't be needed. Any other suggestions? Gustaf Liljegren From bh at intevation.de Fri Jun 29 11:24:46 2001 From: bh at intevation.de (Bernhard Herzog) Date: 29 Jun 2001 17:24:46 +0200 Subject: Augmented Assignement (was: Re: PEP scepticism) References: <6qn16r7i69.fsf@abnoba.intevation.de> <9hhu6701d5j@enews2.newsguy.com> Message-ID: <6qae2r71hd.fsf@abnoba.intevation.de> "Alex Martelli" writes: > "Bernhard Herzog" wrote in message > news:6qn16r7i69.fsf at abnoba.intevation.de... > > I think the main problem (in as much as there actually is a problem) is > > that whether augmented assignment rebinds the left hand side depends on > > the type of object, i.e. whether the object implements the appropriate > > Right! I think the main advantage (in as much as there actually is an > advantage) is that whether augmented assignment rebids the left hand > side depends on the type of object. i.e. whether the object implements > the appropriate methods. This is called *polymorphism* and is a concept > of *HUGE* power. Well, polymorphism is certainly very important and powerful in python but in an of itself that's no argument in favor of the intricacies of augmented assignment in Python. Just because something could depend on the types of the objects involved doesn't mean that it should. Augmented assignment doesn't actually offer anything that couldn't have been done with explicit method calls, at least as far as in-place modification is concerned, because under the covers it actually is a method call. Explicit is better than implicit. > > methods, which is very different from normal assignment which always > > rebinds. > > Do you consider: > fee.fie = foo > and/or > fee[fie] = foo > examples of "normal assignment"? In most cases, yes. For the builtin python objects (classes, instances, modules, list and dictionaries) this form of assignment simply rebinds and does nothing else. A class/type can of course override this behavior and it does make sense in some cases to do so, but deviation from the standard behavior should be kept to a minimum. Chances are that if you have to deviate too much you should use normal method calls instead. > Neither "always rebinds" -- it all > depends on the type of object, i.e. whether the object (fee) implements > the appropriate methods (__setattr__, __setitem__). Augmented > assignment, like attribute assignment and item assignment, is > polymorphic. I think we have to look carefully at which objects control the behavior here. In fee.fie = foo it's fee that's modified in place and fee.fie doesn't have anything to say about it. In fee.fie += foo it's either fee or fee.fie that's modified in place depending on the type of fee.fie, not fee (although the type of fee comes into play if fee.fie doesn't define __iadd__). This applies to fee[fie] as well. > Plain assignment to an _unqualified_ LHS isn't, so > maybe *THAT* one is the "odd man out"?-) No. In all three cases (plain assignment, setattr and setitem) the object the LHS evaluates to does not influence assignment. If it did there could be very confusing differences between the first assignment when the LHS doesn't exist yet and the subsequent ones. Bernhard -- Intevation GmbH http://intevation.de/ Sketch http://sketch.sourceforge.net/ MapIt! http://mapit.de/ From dalke at acm.org Fri Jun 22 00:53:23 2001 From: dalke at acm.org (Andrew Dalke) Date: Thu, 21 Jun 2001 22:53:23 -0600 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) References: Message-ID: <9guja6$ull$1@slb7.atl.mindspring.net> Uncle Tim: >But Python is >still introducing new keywords at the rate of one per 5 years ... Since the "access" keywords was dropped in 1.4(?), the loss rate is 1 every 10 years, so the overall keyword growth rate is 1 every 10 years. Andrew dalke at acm.org From dsh8290 at rit.edu Sat Jun 9 09:19:08 2001 From: dsh8290 at rit.edu (D-Man) Date: Sat, 9 Jun 2001 09:19:08 -0400 Subject: Python Shareware? In-Reply-To: ; from bbollenbach@homenospam.com on Sat, Jun 09, 2001 at 04:09:11AM +0000 References: <9fr2jm$16v$1@brokaw.wa.com> Message-ID: <20010609091908.E21104@harmony.cs.rit.edu> On Sat, Jun 09, 2001 at 04:09:11AM +0000, Brad Bollenbach wrote: | "Jonathan Gardner" wrote in message | news:9fr2jm$16v$1 at brokaw.wa.com... | > There is another benefit to you of free software: If you are | > really good at programming, you can show off with your GPL'ed | > code, and use that to get into a company that is willing to pay | > you to code stuff for them. You can't show off code that is | > closed-source, like code from, say, your previous job. So, with | > your GPL'ed code (which has been tested and developed by people | > who are actually interested in using it, so it will be much better | > than anything you can write on your own) you can claim a lot of | > credit for it, and demand $100,000 or more for salary. If they | > think you are crazy, tell them to read the code and try the | > software. If they want to produce software like that, then they | > have to hire you. | | Other than the really big names (a la Torvalds, GvR, Wall et al.) this | rarely happens. At the very least, when good programmers get good jobs, it's | because they are very bright people who have a lot to offer, not because of | the license they choose for their software. Realistically, most PHB's have | less than half-a-clue about what the GPL is (*hyuck* *hyuck* isn't that | onnuh them globawl pawsitioning thingmahoots?) I think Jonathan's point was mainly "how are you going to convince a company that you really are a good programmer if you can't show them any of the code you have written?" (aside from discussing personal beliefs wrt the problems with shareware). If your code is GPL'd (or, more precisely, free / open source) then you _can_ show it to a prospective future employer, but if all the code you have written is either owned by a previous employer, or part of your closed-source shareware then you can't show them. The main issue, apart from issues with the way shareware works from a business perspective, is to create a way to demonstrate that you are a good programmer. -D From sholden at holdenweb.com Mon Jun 18 12:25:54 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 18 Jun 2001 12:25:54 -0400 Subject: os.statvfs on FreeBSD References: Message-ID: If you don't want to run this every millisecond, you could run a "df" command and parse the results. regards Steve -- http://www.holdenweb.com/ "Tom Messmer" wrote in message news:f74c89ea.0106161951.2e55a814 at posting.google.com... > Thanks for looking at this, I took some time and noticed that there > was really no statvfs system call in FreeBSD (stable) and thought it > might be possible to use the statfs call and map it to the same tuple > returned by python's os.statvfs routine. Er, but thats as far as I got > with it so far because I'm new at Python and not much of a programmer > anyway. I looked at the os module itself and saw that it calls posix > for unix-like systems, but from there I couldnt tell how it accesses > system calls. If someone would care to explain this I'd love to hear > about it, my eyes crossed after staring at all these classes and > subclasses and sub sub...well you get the picture. All I really need > is to write some code to grab system disk statistics so my servers > don't get all full up, and i dont want to use some huge thing like big > brother or spong. > > Thanks for the posts. > Tom Messmer > > charles at aspen.sweetshade.net (Charles Allen) wrote in message news:... > > To follow up to my own followup a bit: > > > > >>>> os.statvfs("/") > > > Traceback (most recent call last): > > > File "", line 1, in ? > > > AttributeError: 'os' module has no attribute 'statvfs' > > > > I should have explained that FreeBSD has no statvfs library routine > > (at least 4-STABLE, I don't know about 5-CURRENT). If the original > > poster would explain the specific info he's looking for, perhaps an > > alternative can be found. From tundra at tundraware.com Thu Jun 28 13:50:04 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: Thu, 28 Jun 2001 17:50:04 GMT Subject: Introspection References: <25b2e0d9.0106280923.31cadb06@posting.google.com> Message-ID: <3B3B6E2B.3BAC40D5@tundraware.com> gods1child wrote: > > Is there a good resource that gives comprehensive coverage of Python's > introspection capabilities all in one place? > > Thanx. There is a section on introspection in: http://www.diveintopython.org/ -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From barry at digicool.com Thu Jun 21 01:44:34 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Thu, 21 Jun 2001 01:44:34 -0400 Subject: PEP 255: Simple Generators References: <9gnv2o$its$1@nntp6.u.washington.edu> <3B317D8B.A729897C@cosc.canterbury.ac.nz> Message-ID: <15153.35266.227415.297806@anthem.wooz.org> >>>>> "GE" == Greg Ewing writes: GE> So in the end I decided that combining their functions GE> into one statement was a reasonable thing to do after GE> all. But I still felt that something was needed to GE> distinguish it from an ordinary function definition, GE> since it's doing rather *more* than just defining GE> a function. So I settled on | generator g(args): | ... Sounds reasonable to me! :) -Barry From ljohnson at resgen.com Tue Jun 26 10:08:31 2001 From: ljohnson at resgen.com (Lyle Johnson) Date: Tue, 26 Jun 2001 09:08:31 -0500 Subject: python as plugin language References: <993529827.54981@newsmaster-04.atnet.at> Message-ID: > could someone please enlighten me! I want to embed python in my app > as a scripting language... I have succeeded in extending python via swig. > Not what I want, because main() has to come from my c-app. > > Then i can embed python in a c program with things #include "Python.h" > and Py_Initialize(), etc. but that is still not what i want, because i have no > idea how I can call C-Funktions with this approach... clear what i mean? > I fear not... > > From my app I want to load a plugin (a python script) and from this script > I want to access functions of my app. > > Some pointers would be _very_ welcome!! If you've already learned how to develop C extension modules (using SWIG, or "by hand") you've gotten past the biggest hurdle. And it sounds like you've got the idea w. r. t. embedding Python in your application. I know of two books that do a pretty good job of explaining the "big picture" for embedding Python as an application-scripting language. One is "Programming Python", by Mark Lutz; the other is "Internet Programming with Python", by Aaron Watters, Guido van Rossum and James C. Ahlstrom. The latter may be out of print, but if you run across it you'll probably be able to get it for cheap. A good general approach, though, is: 1. Develop one or more C extension modules that expose some subset of your application's functionality, i.e. the stuff you'd like to be able to access from a Python script. 2. Embed the Python interpreter in your application, initialize it by calling Py_Initialize(), etc. 3. At some selected point(s) during your application's execution, pass the user's "plugin" script to the embedded Python interpreter. Within that script, the user will presumably import your extension module(s) and make application-specific calls back into your application. Hope this helps, Lyle From tundra at tundraware.com Thu Jun 7 13:30:02 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 07 Jun 2001 17:30:02 GMT Subject: PalmOS Desktop Interface For Python? Message-ID: <3B1FB7E4.2F5D2FE3@tundraware.com> Is anyone aware of a Python module set which allows the PalmOS 4.0 desktop files (addressbook, todo, etc.) to be read and written? They only reference to something like this I've been able to find is dated several years ago and presumably now out of date. TIA, -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From pinard at iro.umontreal.ca Mon Jun 25 15:29:02 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 25 Jun 2001 15:29:02 -0400 Subject: Python scripting [was: Re: emacs speedbar for python mode?] In-Reply-To: References: Message-ID: [Bud Rogers] > Roman Suzi wrote: > > On Sun, 24 Jun 2001, Bud Rogers wrote: > >> I have had similar thoughts. Imagine a programmer's editor of the > >> calibre of [x]emacs that used python as a built in extension language > >> in the same way that emacs uses lisp. > > Did you mean Cool Edit? > Wow. It definitely has possibilites. I'll have to get better > acquainted. Thanks. I took a quick look at Cool Edit this morning. It has Python scripting capabilities indeed, and looks quite friendly (but it _requires_ X, sigh). I imagine Cool Edit to be very useful for moderate, yet capable editing jobs. On the other hand, at first glance, it seems far from being comparable to Emacs. I mean that, despite the most popular features are represented in Cool Edit, a great deal of work would be needed to retrofit Emacs level of comprehension and completeness. I also guess, but without really knowing, that the user would choke under the interface if she wanted to simultaneously edit hundreds of buffers, as it sometimes happens for bigger projects. Once again, Cool Edit seems very interesting for most users, wanting a tool more capable and versatile that most editors meant to be friendly, but I would not dare comparing it with Emacs, on the caliber standpoint. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From gerhard.nospam at bigfoot.de Sat Jun 16 20:21:34 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sun, 17 Jun 2001 02:21:34 +0200 Subject: MySQLdb-0.3.5 build problem (/usr/bin/ld: cannot find -lz) References: Message-ID: <3B2BF80E.E9A764A3@bigfoot.de> Darek Kedra wrote: > > Hi, > > I'm trying to install MySQLdb-0.3.5 with python 2.1 on Mandrake 8.0. > After: > # python setup.py build > I am getting: > > <--snip--> > running build_ext > building '_mysql' extension > skipping _mysqlmodule.c (build/temp.linux-i686-2.1/_mysqlmodule.o > up-to-date) > gcc -shared build/temp.linux-i686-2.1/_mysqlmodule.o -L/usr/lib/mysql > -lmysqlclient -lz -o build/lib.linux-i686-2.1/_mysql.so > /usr/bin/ld: cannot find -lz > collect2: ld returned 1 exit status > error: command 'gcc' failed with exit status 1 It's complaining about a missing zlib. Which is very strange, as zlib is usually present even on very basic Linux installs. If zlib is present in /lib, but not in /usr/lib, I would try changing setup.py to include "/lib" in the variable library_dirs (line 23 and 42). Good luck! Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://highqualdev.com public key at homepage public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From sill at optonline.net Tue Jun 12 17:29:52 2001 From: sill at optonline.net (Rainy) Date: Tue, 12 Jun 2001 21:29:52 GMT Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> Message-ID: On 12 Jun 2001 08:39:37 -0700, thinkit wrote: > humans should use a power of 2 as a base. this is more logical because it > synchs with binary, which is at the very heart of logic--true and false. it is > more natural perhaps, to use decimal--but logic should, and will, win out. > It's actually illogical to use binary for everything - it's simply too hard to write a large number in it. Try writing 1,388,034,093 in binary on a piece of paper then come back :-). -- Jupiter and Saturn Oberon Miranda And Titania Neptune Titan Stars can frighten - Syd From ngreco at softhome.net Wed Jun 27 13:56:24 2001 From: ngreco at softhome.net (Nahuel Greco) Date: Wed, 27 Jun 2001 14:56:24 -0300 Subject: GCC 3.0, Standard ABI & C++/Python Integration Message-ID: <20010627145624.054ad489.ngreco@softhome.net> Will the standarization of the ABI in gcc 3.0 help to do a better integration of C++ and python? - Nahuel Greco Web Development - Open Source - - http://www.codelarvs.com.ar Game Programming - Research - - Freelance coding / sysadmin Networking. The answer is 42. - From pj at sgi.com Thu Jun 28 20:32:39 2001 From: pj at sgi.com (Paul Jackson) Date: 29 Jun 2001 00:32:39 GMT Subject: PEP 260: simplify xrange() References: <6qg0ckydud.fsf@abnoba.intevation.de> Message-ID: <9hgib7$k61k7$1@fido.engr.sgi.com> |> And what's more google use Python ... I'm pretty sure that the performance critical paths, including probably every instruction executed on a search, are all in C now. I think they had some early prototypes in Python, and likely still run some off line or non-critical utilities in Python. But you can't run a site as insanely popular and great as theirs coding in just a script language, not even an insanely great script language. -- I won't rest till it's the best ... Manager, Linux Scalability Paul Jackson 1.650.933.1373 From fdrake at beowolf.digicool.com Fri Jun 22 14:53:37 2001 From: fdrake at beowolf.digicool.com (Fred Drake) Date: Fri, 22 Jun 2001 14:53:37 -0400 (EDT) Subject: [development doc updates] Message-ID: <20010622185337.BE51228927@beowolf.digicool.com> The development version of the documentation has been updated: http://python.sourceforge.net/devel-docs/ Lots of smallish updates and corrections, moved the license statements to an appendix. This version includes some contributed changes to the documentation for the cmath module. To make the LaTeX to HTML conversion work, I have made the resulting HTML contain entity references for the "plus/minus" and "infinity" symbols (± and ∞, respectively). These may be problematic for some browsers. Please let me know how it looks on your browser by sending an email to python-docs at python.org. Be sure to state your browser name and version, and what operating system you are using. Thanks! http://python.sourceforge.net/devel-docs/lib/module-cmath.html From jkn at nicorp.f9.co.uk Fri Jun 29 09:16:00 2001 From: jkn at nicorp.f9.co.uk (Jon Nicoll) Date: 29 Jun 2001 06:16:00 -0700 Subject: module for A/D-converter? References: <20010629.7381058@fb11lfm15.fh-muenster.de> Message-ID: <8351bb33.0106290516.66d3d6ef@posting.google.com> Hi Arend You will need to write an 'extension module' (in C) to the do the basic I/O to your A/D converter card. After that you can write the rest in Python. I have written code to do something similar, to access the LPT port on a PC. The mechanism depends on what Operating system you're using. My code is written to run under W95 and Linux. It will probably work on W98 as well, but not (yet) on NT. If you have a small amount of skill in C you could easily change it for your card. If you're interested, drop me an email. Regards Jon Nicoll  Arend von der Lieth wrote in message news:<20010629.7381058 at fb11lfm15.fh-muenster.de>... > Hi everybody, > > I am wondering if there is a way to implement a program (with python of > > course) that reads values from an A/D-converter card. > More precisely: I want to read data from an oscilloscope and do not want > > to use the languages that we used before (C, Pascal, VBS) > > Thanks in advance, > Arend From thomas at xs4all.net Thu Jun 28 16:04:38 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 28 Jun 2001 22:04:38 +0200 Subject: Building 2.1 Issues In-Reply-To: <01C0FFCA.C13708E0.gregory_engel@csgsystems.com> References: <01C0FFCA.C13708E0.gregory_engel@csgsystems.com> Message-ID: <20010628220438.A8098@xs4all.nl> On Thu, Jun 28, 2001 at 12:06:24PM -0600, Gregory Engel wrote: > So I run: > rpm -i /usr/src/redhat/RPMS/i386/expat-1.1-3tummy.i386.rpm > rpm -q expat > And get: > expat-1.1-3tummy > Looks good. So I run: > rpm --rebuild python2-2.1-5.src.rpm > and STILL get back: > > Installing python2-2.1-5.src.rpm > error: failed build dependencies: > expat-devel >= 1.1-3tummy is needed by python2-2.1-5 > db1-devel is needed by python2-2.1-5 Note that python2-2.1-5.src.rpm needs expat-*devel*, not just expat. I guess you can grab expat-devel-1.1-3tummy.{src,i386}.rpm from the same place you got the expat RPM, probably Sean's site. It also needs db1-devel, which you can grab from a RedHat CD or mirror. Or-you-can-switch-to-Debian-which-will-have-2.1.1-in-a-few-weeks-ly y'rs ;) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From greg at cosc.canterbury.ac.nz Mon Jun 25 01:47:07 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Mon, 25 Jun 2001 17:47:07 +1200 Subject: My PyGUI (Re: ANN: PythonCard mailing list) References: <3B31931E.D2F54D78@cosc.canterbury.ac.nz> <3B323CE6.1CB7A388@home.net> Message-ID: <3B36D05B.A22A502E@cosc.canterbury.ac.nz> Chris Barker wrote: > > This looks like a pretty nice start. Do you have any plans to continue > the project? Have you posted to this newsgroup in the past to find out > if there is enough interest to really get it moving? Some history behind this project: About 3 years ago, there was a discussion about designing a native Python GUI API that wasn't biased towards any particular platform or existing GUI toolkit. I and a couple of other people started (independently) doing some work on the idea. There was an initial burst of enthusiasm, and a SIG was formed, but discussion petered out after a while. The SIG mailing list is currently suspended as far as I know. The idea of a Python-specific GUI library, maintained by the Python community, seems to have fallen out of favour nowadays. The core Python developers say they don't have the time and energy that would be needed to maintain it for all the major platforms, and feel that the status quo is "good enough". This is not very encouraging, but I haven't entirely given up on the idea. I'd still like to finish at least one complete implementation of it one day, perhaps two (Unix and Mac). I'll need the help of at least one other person to do the Windows version, though. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From jajvirta at cc.helsinki.fi Sat Jun 30 02:49:04 2001 From: jajvirta at cc.helsinki.fi (Jarno J Virtanen) Date: 30 Jun 2001 06:49:04 GMT Subject: Is this a true statement: Part II References: <9hiifr$sjs$1@taliesin.netcom.net.uk> Message-ID: Fri, 29 Jun 2001 14:48:23 -0400 MDK wrote: > "Python can do everything C++ can do but just slower." [snip] > 1. Excluding writing device drivers the answer is a clear yes. [i'm not going into the device driver issue here] "yes" is a good answer to that statement if you don't have to actually do anything. ;-) In the so called real world, that is an oversimplification. It should be something like: "Implementation of some specification (which can and will be changed later) written in C++ is faster than written in Python, IF you can find the near optimal solution and you are able to design it so that you can isolate the time critical parts (which you can optimize) given the usual constraints such as deadlines (limited time), limited resources, different abilities of programmers and so on." Quoting The Mythical Man-Month by Frederick Brooks: "All programmers are optimistic." I rest my case. (PS. Okay, that quote was about schedules, but I think it can be generalized to optimization. ;-) From uioziaremwpl at spammotel.com Thu Jun 28 18:02:24 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Fri, 29 Jun 2001 00:02:24 +0200 (CEST) Subject: Augmented Assignement (was: Re: PEP scepticism) In-Reply-To: Message-ID: On Thu, 28 Jun 2001, Bruce Sass wrote: > On Thu, 28 Jun 2001, Paul Prescod wrote: > > > I think Python has been getting better and better as time goes on. But I > > do have a concern about augmented assignment. How can a newbie > > understand that tuples are "immutable" if this works: > > > > mytuple += (foo,bar) > > Ya, ok, it was a rhetorical question > maybe this sequence would help explain it to someone... [snip] I don't see your point. With a tuple "a" the following two statements are exactly the same: a += (1, 2) a = a + (1, 2) > > Worse, once they've learned that this does NOT affect other references > > to mytuple they are bound to be confused by > > > > mylist += [foo, bar] > > > > which does! > > >>> a = [1,2] > >>> a > [1, 2] > >>> id(a) > 135320620 > >>> a += [3,4] > >>> id(a) > 135320620 For list the following two statements are NOT the same: a += [1, 2] a = a + [1, 2] Let's see an example. >>> a = [1, 2] >>> b = a >>> a = a + [3, 4] >>> a [1, 2, 3, 4] >>> b [1, 2] Now, starting with the same first two statements (a=[1,2]; b=a): >>> a += [3, 4] >>> a [1, 2, 3, 4] >>> b [1, 2, 3, 4] Of course, this is (more or less) explained in the reference (and probably somewhere else, too), but it is somehow confusing that a += [3, 4] is more like a.extend([3, 4]) than a = a + [3, 4] . > > I've seen this confusion already -- in a draft of a book no less. > > Once they see that "adding" tuples creates a new object (it has to, > tuples are immutable), and the alternative is manually concatenating > the tuples yourself... > > ...what was a wart becomes a feature. As mentioned above, for tuples the "+=" is completely natural, but not for lists. Cheers, Carsten -- Carsten Geckeler From Randy.L.Kemp at motorola.com Thu Jun 7 09:07:49 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Thu, 7 Jun 2001 09:07:49 -0400 Subject: Windows editor? Message-ID: Ultra Edit (www.ultra.com) with the macro extension developed for Python is great, and only $30. You have to download the free Python, macro extension. -----Original Message----- From: Wolfgang Lipp [mailto:castor at snafu.de] Sent: Wednesday, June 06, 2001 6:36 PM To: python-list at python.org Subject: Re: Windows editor? > > > > >What's a good Python editor for programming under Windows, specifically > > > > >Windows 2000? According to Google archives it seems this question try www.textpad.com -wolf From cheongsa at limhk.dyn.cheapnet.net Sun Jun 3 00:04:46 2001 From: cheongsa at limhk.dyn.cheapnet.net (Cheong Siew Ann) Date: Sun, 03 Jun 2001 04:04:46 GMT Subject: Tkinter Q: Interrupting an update loop? Message-ID: Hi, I have been trying to adapt Guido's electrons.py example for my own use. Rather than moving items on a canvas, I have a class whose Update() function modifies the fill option of a static grid of squares on the canvas every time step. Whereas electrons.py creates a canvas and a fixed number of circles and run for 500 time steps before quiting, I would like to have some minimal control of the updating. Here's my class definition: class Ising: def __init__(self, ...): # following Guido's electrons.py and letting the Ising class owns # a Tk() object self.tk = tk = Tk() self.canvas = canvas = Canvas(tk, width=..., height=...) canvas.pack() quit_button = Button(tk, text="Quit", command=self.Quit) quit_button.pack(...) start_button = Button(tk, text="Start", command=self.Update) start_button.pack(...) ... ... def Update(self, ...) # modifies the fill option of squares tiling the canvas def RunMainLoop(self): self.tk.mainloop() def Quit(self): self.tk.quit() # main program def main(): ising = Ising(...) ising.RunMainLoop() The observed behaviour is as follows: (1) when the script is executed, the Tk() window is launched, and the initial state of the squares (initialized by another function in Ising) is displayed. (2) if the "Start" button is clicked, the state of the squares is updated by Update(), until the pre-specified number of time steps has elapsed, and the final state of the squares is displayed. (3) if the "Quit" button is clicked before the start of the simulation, or after the termination of the simulation, then the Tk() window closes. However, if I try to click the "Quit" button while the updating is in progress, then nothing happens. Is this because control has been passed from the self.tk.mainloop() to self.Update(), and no events are serviced until self.Update() returns control to self.tk.mainloop()? Is it possible to interrupt self.Update(), and pause the simulation? I notice that the destroy button at the top right corner of the Tk() window still works... Thanks in advance. Cheong Siew Ann From rnd at onego.ru Sat Jun 9 02:28:16 2001 From: rnd at onego.ru (Roman Suzi) Date: Sat, 9 Jun 2001 10:28:16 +0400 (MSD) Subject: is c faster? In-Reply-To: Message-ID: On Sat, 9 Jun 2001, akhar wrote: > I have a script I wrote in python , I love the time it took me to devellop > it faster than i could have done it in C. however after full review of my > code I am not sure I can optimize it any more( it basicaly consist of > importing an image and tranforming into a matrix to perform some for-looped > operations on it) : I went from 20 seconds to 2. I can't seem to bring the > execution time down :( . would C code be faster? by what factor? can I > optimise my code more? how? It varies depending on the task. You can look at http://www.bagley.org/~doug/shootout/craps.shtml - check boxes appropriate to your task and CPU/memory/lines_of_code weights. - and you will see the picture. My experience is that on large text-processing tasks Perl is only 2 times slower than C and Python only 2.5-3 times slower than C. You can also use profiler to find out where time is spent. > Stephane > > NB: I have a dual-celeron 400mhz with 256Mo of ram and a 20 gig 7200rpm HDD > Also anybody with a G4 with PIL and numpy install to test the speed of my > code?(my friend has a 1GHz and it takes him .65 sec to execute I would like > to know if an altivec enhanced computer would fair better) Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From pjdurai at hotmail.com Thu Jun 28 05:18:58 2001 From: pjdurai at hotmail.com (pj) Date: 28 Jun 2001 02:18:58 -0700 Subject: Using python interpreter over a network Message-ID: Greetings. I am trying to run a python script in a networked windows NT workstation. Python is not installed in this box. I have mapped another machine's (my win2k box) python (2.1) installation to the PATH of this NT box. I have set PYTHONHOME to Q:\Python while Q: is mapped to \\my_nt_box\cdrive. I also have Q:\winnt\system32 in the current path (for python dll). Python seems to work under the circumstances. I can run the interpreter and do simple stuff. But when I try to import some modules, it says it cant find those. 'win32net' for example. I am not sure how to make it aware of the fact that everything is under q:\python. Is it a requirement that python should be installed in the local machine? Or is there something (Env variable ? Registry ?) I can tweak to make this work. Appreciate your time. cheers pj From rdsteph at earthlink.net Sun Jun 17 19:37:53 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Sun, 17 Jun 2001 23:37:53 GMT Subject: Two more questions, and a comment: Cross-Platform... References: <3B2B60AD.942719AE@earthlink.net> Message-ID: <3B2BF029.14AAF29E@earthlink.net> 1. Is Tkinter likely to be ported over to MacOS X soon? 2. Is Tkinter gui-code usable in any kind of web scripting? In other words, are forms and tables generated in Tkinter usable to gather user input through web browsers and can Tkinter be used to output data to web browsers? I think not??? (OK I know I'm cheating, but two more closely related sub-questions) 1a. Is wxPython likely to be ported over to the Mac OS X opsys soon? Sooner or later than Tkinter? 2a. Is wxPython code usable in any kind of web scripting? Comment: For those of you who use Linux, there is a nice article in the new online issue of Linux Journal about using Glade as a gui User Interface development tool for Python. I am using Windows, but if I were using Linux, Glade would be a top priority perhaps. Link to article http://www2.linuxjournal.com/cgi-bin/frames.pl/index.html or to Linux Journal front page if above link doesn't work: http://www2.linuxjournal.com/cgi-bin/frames.pl/index.html Ron Stephens wrote: > I am taking a week's vacation the week after next. I plan to spend this > week trying to learn event-driven programming using Python. I would sure > appreciate any comments or guidance from folks on this list, so that I > hopefully can make productive use of my time. I admit to being a little > confused or overwhelmed by the many options available to me. > > I am very happy with my learning of Python as a procedural language. I > have committed the core language to memory and can program at will > without consulting documentation. I am learning to use library modules. > I have never been this successful with any other programming language. I > have limited time due to job related travel (I do not work in IT in any > way; this is I suppose a hobby, albeit it is becoming a serious one.). > > I have not been successful heretonow in gui or event driven programming > . Learning and using Tkinter is much harder for me that procedural > Python. I am doing fine on classes and object oriented Python also, but > not event driven programing. Some of the options available to me that I > am aware of are: (I am programming on a Windows 98 machine). > > 1. Tkinter and wxPython. I have not been too successful with Tkinter, > but I do not rule it out. I have just begun to look at wxPython. Does > anyone think wxPython is easier to learn and use than Tkinter, or about > the same? > > 2. Boa Constructor and wxPython. I have downloaded Boa and it looks > complicated, but I like the idea of a VisualBasic like gui designer. Is > Boa far enough along to be used? Any comments on Boa? > > 3. PythonWorks. I just downloaded the evaluation copy. OK, it costs > $395, a lot of money to pay for a hobbyist. However, if it were the > answer to my prayers and far better, as a gui painter, than any other > alternative, I guess I would consider it. Does anyone have experience > with Pythonware and could you comment? I am really mainly interested in > the gui painter. > > 4. theKompany's BlackAdder. Same as above. For some reason, I seem more > favorably inclined towards Pythonware, btu I don't know why ;-)) Anyone > have any experience with BlackAdder and can you comment? > > 5. I am vaguely aware of other alternatives such as qt toolkits, gtk > toolkits, etc. > > 6. Java based solutions. I am successful in getting my scripts to run > under Jython. I am a little, just a little, familiar with Java and the > JVM's. It occurs to me that there may be Java based gui painters that I > could use as a front end to connect to jython based programs? A few > years ago I used a Sun product called Java Studio that fell in this > category; I like Java Studio, but Sun discontinued it. Are there any > open source or even commercial products I should consider? > > 7. Someone on the list mentioned they use Jbuilder from Borland as a gui > painter for their Python programs. Hmmm, Jbuilder has a boxed package > for sale much cheaper than even Pythonworks ;-))) Any comments pro or > con???? I doubt that this would fit my definition of "easy" to learn and > to use, but who knows??? > > I would appreciate any comments. Python's ease of learning and ease of > use opens new doors for "low IQ" programmers like myself. But much that > one might wish to do involves event-driven programming, and Python does > not yet, it seems to me, offer the same ease of use in this arena. But I > keep searching and hoping. Event driven programming is awful important > and it would be nice if Python's core advantages could somehow extend > into this area. > > I would prefer to stick to a solution that is as much Python-like as > possible, but a jython-Java GUI solution is also of interest. Maybe I > will try one of each. > > I think this whole topic of discussions of interest to many newbie's and > programming hobbyists, not just to myself. A successful address to this > "problem" could seriously propel Python even further as an educational > and first-learning language. I would really enjoy a discussion of pros > and cons and possible directions to explore, both now and also in the > future, if anyone can predict future directions of even-driven GUI > programming and Python. ;-)))) > > Ron Stephens From tim.one at home.com Fri Jun 15 19:33:43 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 15 Jun 2001 19:33:43 -0400 Subject: str smarter than round? In-Reply-To: <9F852011A819CAA6.2C9141DBD4DB433F.3BFF2DB5D91E2E16@lp.airnews.net> Message-ID: [Tim] > Congratulations! You've elected yourself to be a guinea pig for reading > this new Tutorial Appendix: > > http://python.sourceforge.net/devel-docs/tut/node14.html [Cameron Laird] > Is there or will there be a (more) persistent URL for this > Appendix? I assumer "node14" is likely to vary every few > weeks or so. > > I ask in public, rather than only pestering timbot, because > it occurs to me that the answer might interest others. Beats me. I'm copying Fred Drake because he knows everything about this: the link is to an Appendix that will part of the core Python 2.2 Tutorial, and so when 2.2 is released it will be in the same boat (URL-wise and otherwise) as all other core Python docs. From matt at mondoinfo.com Tue Jun 5 13:27:34 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Tue, 05 Jun 2001 17:27:34 GMT Subject: How to put a scrollbar to a frame? References: <9fip1t$5js$1@bcarh8ab.ca.nortel.com> Message-ID: On Tue, 5 Jun 2001 10:06:50 -0400, JAY wrote: >Hi there, Hi! >I am pretty new to python. My python script makes a frame in a widget >to display some messages (UNIX system), it works fine. However, if >the message gets too long, the frame will be extended and make the >whole widget bigger than screen. >To solve the problem, I want to put a scrollbar to the frame for the >messages so that it's size won't change. But I don't know how. Could >anybody tell me how to do it? Scrolling a frame is a bit of a nuisance because frames don't have the necessary scrolling methods to start out with the way that canvases, for example, do. It's perfectly possible to do but requires a bit of work. Happily, you don't have to do the work because Greg McFarlane already has. His Pmw (Python megawidgets) is very handy. It's at: http://pmw.sourceforge.net/ It includes useful widgets such as ScrolledFrame, ScrolledText, and a bunch of others. Another handy thing (though not directly related to your question) is Fredrik Lundh's An Introduction to Tkinter. It's at: http://www.pythonware.com/library/tkinter/introduction/index.htm Between the two, they make Tkinter programming much easier. If I had a bunch of messages to display, I'd look at sticking them in a Pmw.ScrolledText and plan to live happily ever after. Regards, Matt From new_name at mit.edu Fri Jun 29 15:17:03 2001 From: new_name at mit.edu (Alex) Date: 29 Jun 2001 15:17:03 -0400 Subject: pdb name truncation References: <20010629.094021.1605894428.12508@troikanetworks.com> Message-ID: > Is there some setting to get it to expand the ... It's annoying to > have to restart not under pdb to see what error actually was. I've had problems with this, too, and your post induced me to finally fix it instead of work around it. :) (though usually you can get the complete error by re-executing the line that caused the error from the pdb prompt, even that's a bit of a pain.) Stick this in a file my_pdb.py in a directory that'll be in your sys.path, and do "from my_pdb import set_trace" or whatever it is you usually use from there. If people care, I could submit a patch to fix pdb directly. It'd be a lot simpler to do this sort of thing if each instance of pdb.Pdb created its own Repr.repr instance. HTH Alex. import pdb from repr import Repr r = Repr() r.maxother = 2000 r.maxstring = 2000 class my_Pdb(pdb.Pdb): repr = r.repr def user_exception(self, frame, (exc_type, exc_value, exc_traceback)): """This function is called if an exception occurs, but only if we are to stop at or just below this level.""" frame.f_locals['__exception__'] = exc_type, exc_value if type(exc_type) == type(''): exc_type_name = exc_type else: exc_type_name = exc_type.__name__ print exc_type_name + ':', self.repr(exc_value) self.interaction(frame, exc_traceback) def run(statement, globals=None, locals=None): my_Pdb().run(statement, globals, locals) def runeval(expression, globals=None, locals=None): return my_Pdb().runeval(expression, globals, locals) def runcall(*args): return apply(my_Pdb().runcall, args) def set_trace(): my_Pdb().set_trace() def post_mortem(t): p = my_Pdb() p.reset() while t.tb_next is not None: t = t.tb_next p.interaction(t.tb_frame, t) def pm(): post_mortem(sys.last_traceback) if __name__ == '__main__': set_trace() this_name_is_intended_to_produce_a_long_NameError From bernhard at intevation.de Tue Jun 12 11:05:33 2001 From: bernhard at intevation.de (Bernhard Reiter) Date: 12 Jun 2001 15:05:33 GMT Subject: MapIt! 1.0 - Webapplication for Rastermaps References: Message-ID: <9g5b3t$70ltn$2@ID-89274.news.dfncis.de> In article , Bernhard Herzog writes: > MapIt! 1.0 > http://www.mapit.de/ > MapIt! is a web-application that lets you navigate raster-maps through > your web-browser and lets you zoom in and out and select objects and > object classes that are identified on the map. > MapIt! is Free Software licensed under LGPL (GNU Library General Public > License). To keep you in the loop: MapIt! was developed by Intevation GmbH contracted by Logiball GmbH (www.logiball.de). Logiball uses MapIt! for serving their high quality maps independently of expensive and bloated GIS solutions. This makes MapIt! a commercial Free Software product. Python as a language and free software enabled us to implement MapIt! quickly and get a very flexible solution. Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) FSF Europe (fsfeurope.org) From rnd at onego.ru Tue Jun 26 15:51:12 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 26 Jun 2001 23:51:12 +0400 (MSD) Subject: PEP 260: simplify xrange() In-Reply-To: <20010626153909.A16590@harmony.cs.rit.edu> Message-ID: On Tue, 26 Jun 2001, D-Man wrote: >On Tue, Jun 26, 2001 at 10:47:28PM +0400, Roman Suzi wrote: >| >| What about str(x)? > >It's not needed : > >>>> class Example: >... def __repr__( self ) : return "Hello World" >... >>>> str( Example() ) >'Hello World' Thanks, I've not known this. >>>> > >I have no problems with the PEP and I think that the reduced code size >is a good thing. It is, of course. But after PEP 260 xrange is sequence no more. And also I think "x in xrange(...)" and "x not in xrange(...)" should not be dropped, because it is very near to for x in xrange(...) and has interesting use as in: if n in xrange(1, 101, 2): # odd number from [1, 100] ... Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, June 26, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "It is better to be brief than boring." _/ From guido at python.org Fri Jun 29 12:18:10 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 29 Jun 2001 16:18:10 GMT Subject: Not enough Python library development [was PEP scepticism] References: Message-ID: Roman Suzi writes: > Is there a formal TODO list of the libraries and respective priorities? No, although there's a PEP for small feature requests (PEP 42). If you want to start making a list of missing libraries and submit a PEP, please do! I'm sure many people will want to contribute. > For example, I think that some sort of standard GUI could help Python to > fight Java with it's Swing/AWT... This was tried many times -- there was even a GUI-sig with this goal. Nothing ever came to fruition. The problem is that designing and implementing a standard GUI that can compete with the existing offerings it an enormous amount of work, and folks always ran out of steam before they were even done with the requirements gathering. The folks who produced wrappers for existing GUI toolkits available for C or C++ were much more successful, so that's what we got. Python has more GUI choices than Java, and that's a good thing. > It could be also interesting to have time module as powerful as mxDateTime > in standard library. And so on. Well, propose one. But what exactly is the point of adding it to the standard library when you can get mxDateTime if you need it? I'd say your energy is better spent on reviving the catalog-sig (Python's CPAN-like effort, which needs new energy!) --Guido van Rossum (home page: http://www.python.org/~guido/) From mwh at python.net Thu Jun 7 08:55:49 2001 From: mwh at python.net (Michael Hudson) Date: Thu, 7 Jun 2001 13:55:49 +0100 (BST) Subject: python-dev summary 2001-05-24 - 2001-06-07 Message-ID: This is a summary of traffic on the python-dev mailing list between May 24 and Jun 7 (inclusive) 2001. It is intended to inform the wider Python community of ongoing developments. To comment, just post to python-list at python.org or comp.lang.python in the usual way. Give your posting a meaningful subject line, and if it's about a PEP, include the PEP number (e.g. Subject: PEP 201 - Lockstep iteration) All python-dev members are interested in seeing ideas discussed by the community, so don't hesitate to take a stance on a PEP if you have an opinion. This is the ninth summary written by Michael Hudson. Summaries are archived at: Posting distribution (with apologies to mbm) Number of articles in summary: 305 50 | [|] | [|] | [|] | [|] 40 | [|] | [|] | [|] | [|] [|] [|] 30 | [|] [|] [|] [|] | [|] [|] [|] [|] | [|] [|] [|] [|] | [|] [|] [|] [|] 20 | [|] [|] [|] [|] | [|] [|] [|] [|] [|] [|] [|] [|] | [|] [|] [|] [|] [|] [|] [|] [|] | [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] 10 | [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] | [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] | [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] | [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] 0 +-018-014-011-014-020-019-034-035-032-014-008-020-051-015 Thu 24| Sat 26| Mon 28| Wed 30| Fri 01| Sun 03| Tue 05| Fri 25 Sun 27 Tue 29 Thu 31 Sat 02 Mon 04 Wed 06 Another busy-ish fortnight. I've been in Exam Hell(tm) and am writing this when hungover, this so summary might be a bit sketchier than normal. Apologies in advance. * strop vs. string * Greg Stein leapt up to defend the slated-to-be-deprecated strop module by pointing out that it's functions work on any object that supports the buffer API, whereas the 1.6-era string.py only works with objects that sprout the right methods: The discussion quickly degenerated into the usual griping about the fact that the buffer API is flawed and undocumented and not really well understood by many people. * Special-casing "O" * As a followup to the discussion mentioned in the last summary, Martin von Loewis posted a patch to sf enabling functions written in C that expect zero or one object arguments to dispense with the time wasting call to PyArg_ParseTuple: The first version of the patch was criticized for being overly general, and for not being general enough . It seems the forces of simplicity have won, but I don't think the patch has been checked in yet. * the late, unlamented, yearly list.append panic * Tim Peters posted c.l.py has rediscovered the quadratic-time worst-case behavior of list.append(). And then ameliorated the worst-case behaviour. So that one was easy. * making dicts ... * You might think that as dictionaries are so central to Python that their implementation would be bulletproof and one the areas of the source that would be least likely to change. This might be true *now*; Tim Peters seems to have spent most of the last fortnight implementing performance improvements one after the other and fixing core-dumping holes in the implementation pointed out by Michael Hudson. The first improvement was to "using polynomial division instead of multiplication for generating the probe sequence, as a way to get all the bits of the hash code into play." If you don't understand what that means, ignore it because Tim came up with a more radical rewrite: which seems to be a win, but sadly removes the shock of finding comments about Galois theory in dictobject.c... Most of the discussion in the thread following Tim's patch was about whether we need 128-bit floats or ints, which is another way of saying everyone liked it :-) This one hasn't been checked in either. * ... and breaking dicts * Inspired by a post to comp.lang.python by Wolfgang Lipp and driven slightly insane by revision, Michael Hudson posted a short program that used a hole in the dict implementation to trigger a core dump: This got fixed, so he did it again: The cause of both problems was C code assuming things about dictionaries remained the same across calls to code that ended up executing arbitrary Python code, which could mutate the dict exactly as much as it pleased, which in turn caused pointers to dangle. This problem has a history in Python; the .sort() method on lists has to fight the same issues. These holes have been plugged, although it is still possible to crash Python with exceptionally contrived code: There's another approach, which is was the .sort() method uses: >>> list = range(10) >>> def c(x,y): ... del list[:] ... return cmp(x, y) ... >>> list.sort(c) Traceback (most recent call last): File "", line 1, in ? File "", line 2, in c TypeError: a list cannot be modified while it is being sorted The .sort() method magically changes the type of the list being sorted to one that doesn't support mutation while it's sorting the list. This approach would have some merit to use with dictionaries too; for one thing we could lose all the contrived code in dictobject.c protecting against this sort of silliness... * arbitrary radix formatting * Greg Wilson made a plea for the addition of a "%b" formatting operator to display integers in binary, e.g: >>> print "%d %x %o %b"%(10,10,10,10) 10 a 12 1010 There was general support for the idea, but Tim Peters and Greg Ewing pointed out that it would be neater to invent a general format code that would enable one to format an integer into an arbitrary base, so that >>>> int("1111", 7) 400 has an inverse at long last. But no-one could think of a spelling that wasn't in general use, and the discussion died :-(. * quick poll * Guido asked if anyone would object violently to the builtin conversion functions becoming type objects on the descr-branch: in analogy to class objects. There was general support and only a few concerns, and the changes have begun to hit descr-branch. I'm sure I'm not the only one who wishes they had the time to understand what is going on in there... Cheers, M. From aahz at panix.com Tue Jun 12 16:42:20 2001 From: aahz at panix.com (Aahz Maruch) Date: 12 Jun 2001 13:42:20 -0700 Subject: BIG problem if readline strips newlines References: Message-ID: <9g5urc$hrl$1@panix6.panix.com> In article , Pete Shinners wrote: > >i've seen frequent mention of an option for readline() to strip out >newlines as each string is read. this sounds like a great idea, but i >realized its gonna be very difficult to loop through a text file. the >standard python idioms will no longer work... > >for line in file.readlines(chomp=1): > pass Um. Think again? Why wouldn't this work? -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista gfarber: Thank God, or the belief system of your choice. pddb: Does human perversity count as a belief system? From aleaxit at yahoo.com Mon Jun 18 03:25:56 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 18 Jun 2001 09:25:56 +0200 Subject: l=l (was Re: list.sort()) References: <3B2CEBF1.CCF5377D@hack.org> Message-ID: <9gkae301v0s@enews2.newsguy.com> "Nick Perkins" wrote in message news:Xr7X6.265080$eK2.55163158 at news4.rdc1.on.home.com... > > "Rikard Bosnjakovic" wrote in message > ... > > >>> l = l > ... > I am pretty sure that > l = l > will never have any effect, whatsoever. Not in current Python, EXCEPT that it makes l local, which may cause an error in certain cases. E.g.: D:\py21>python Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. Alternative ReadLine 1.4 -- Copyright 2001, Chris Gonnerman >>> l=list('ciao') >>> def f(): ... print '-'.join(l) ... >>> f() c-i-a-o >>> def g(): ... l=l ... print '-'.join(l) ... >>> g() Traceback (most recent call last): File "", line 1, in ? File "", line 2, in g UnboundLocalError: local variable 'l' referenced before assignment >>> As you can see, the ONLY difference between functions f() and g() is that the latter does have a line: l=l This tells the compiler that l is local in g() [while it's global in f(), since f() does NOT rebind l], whence the error -- it can of course be fixed by adding to g() a further line: global l Alex From aahz at panix.com Wed Jun 6 12:12:02 2001 From: aahz at panix.com (Aahz Maruch) Date: 6 Jun 2001 09:12:02 -0700 Subject: floating point in 2.0 References: <3B1E50C9.7D2509F4@shore.net> Message-ID: <9flkoi$ofu$1@panix2.panix.com> In article <3B1E50C9.7D2509F4 at shore.net>, Kurt B. Kaiser wrote: > >While displayhook is a good thing, IMHO Python's value as a beginner >language is diminished by the new choice of default output format. >It would be interesting to know what percentage of those who use >Python "out of the box" really would choose the "more precise" default >output which has to be rounded off in their heads.... Quite the contrary! The sooner people realize that floating point is broken, the better off they are! channeling-the-timbot'ly yr's -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "NRE is a lot like cocaine. Feels great while you're on it, makes you feel very special and talented, and you become highly annoying to those who aren't on it." --Stef From glyph at twistedmatrix.com Thu Jun 14 05:20:30 2001 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: Thu, 14 Jun 2001 04:20:30 -0500 (CDT) Subject: substitute for c/java's ?: In-Reply-To: <3b2859da$0$329$8eec23a@newsreader.tycho.net> Message-ID: On Wed, 13 Jun 2001, Neil Macneale wrote: > In article <9g5fc4$m8u$01$1 at news.t-online.com>, "Jochen Riekhof" > wrote: > > > I am missing something like the c/Java ?: operator. > > The ?: operator is overrated. For the time you save typing, you > are wasting someone else's because they need to figure out what you were > thinking. Trust me, this is true. Compare the following actual examples: public static final String aan(String s) { char x = s.charAt(0); return ((( x == 'a') || (x == 'e') || (x == 'i') || (x == 'o') || (x == 'u') || (x == 'A') || (x == 'E') || (x == 'I') || (x == 'O') || (x == 'U')) ? "an " : "a " ); } def aan(name): """Utility which returns 'a' or 'an' for a given noun. """ if string.lower(name[0]) in ('a','e','i','o','u'): return 'an ' else: return 'a ' Now, if you're getting paid per line of code, I could see how the first example works better for you... but this was the *least* convoluted use of the ? operator in all of the code that I could find; and I think it's pretty clear which approach looks nicer. > > if elif else is not a proper substitute for switches, as the variable in > > I have found that using a dictionary of function pointers sometimes gives > the switch statement feel. For example, point to constructors... > > cases = {"dog": Dog, "cat": Cat, "rabbit": Rabbit} > > def createPet(type="cat"): > if casses.has_key(type): return casses[type]() #Good input... > else: return None # bad input, or 'default' in C/java The idiom that I've come to particularly like in Python, given a case like that: class PetShop: def pet_cat(self, name): ... def pet_dog(self, name): ... def pet_dinosaur(self, name): ... def buyPet(name="pooky", petType="cat"): petFunc = getattr(self, "pet_%s" % petType, None) if petFunc: return petFunc(name) else: # 'default' case mentioned above; usually raise something > The above code is generally hard to read, so use sparingly and comment > well. The thing I like about it is that the keys can be of any type. One > problem is that all the functions called are going to need similar > parameters, but sometimes its a usefull trick. If you use the specially-named-methods approach, it's almost self-documenting! I use this all over the place and I really like the way it helps to organize code (it also makes testing easier, since each method can be tested separately). It's like you can invent your own "adjectives" to describe methods. try-doing-*that*-in-java-ly y'rs, ______ __ __ _____ _ _ | ____ | \_/ |_____] |_____| |_____| |_____ | | | | @ t w i s t e d m a t r i x . c o m http://twistedmatrix.com/users/glyph From jwolff at ision.nl Wed Jun 13 14:52:48 2001 From: jwolff at ision.nl (Jeroen Wolff) Date: Wed, 13 Jun 2001 20:52:48 +0200 Subject: IP address to binary conversion Message-ID: Hi, Can somebody help me (a newbee) to convert an ip address to is 32 bits representation? i would like to store these 32bits interger into a MYSQL database together with the mask. Jeroen From mwh at python.net Mon Jun 18 15:10:12 2001 From: mwh at python.net (Michael Hudson) Date: 18 Jun 2001 20:10:12 +0100 Subject: Any other Python flaws? References: <3B2A5F6A.5A61183@destiny.com> Message-ID: D-Man writes: > On Fri, Jun 15, 2001 at 02:18:04PM -0500, Michael Chermside wrote: > | Oh well... at least people don't bump into this one much. And if you > | accidently clobber it, you can restore things with: > | > | def __None(): > | pass > | None = __None() > > Well, that doesn't work. One of the key features of 'None' is that > there only ever exists a single instance. This would create a new, > unique, instance bound to (a more local) 'None'. No it wouldn't. Try it! I agree that what Michael posted doesn't really do what he wanted; but it doesn't do what you said, either. Cheers, M. -- This is not to say C++ = bad, Lisp = good. It's to say C++ = bad irrespective of everything else. -- Alain Picard, comp.lang.lisp From thomas at xs4all.net Fri Jun 1 05:48:09 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 1 Jun 2001 11:48:09 +0200 Subject: (sent twice my machine crashed in the middle of this, In-Reply-To: <200105311833.UAA02883@boris.cd.chalmers.se>; from lac@cd.chalmers.se on Thu, May 31, 2001 at 08:33:19PM +0200 References: <200105311833.UAA02883@boris.cd.chalmers.se> Message-ID: <20010601114809.M690@xs4all.nl> On Thu, May 31, 2001 at 08:33:19PM +0200, Laura Creighton wrote: > We need a way to use news threading better. It would probably help if you posted follow-ups, rather than new postings with different subjects, and actually quoted text from the post you reply to. Real newsreaders also add the proper references in the headers. That would help a lot in finding out if a particular answer had already been given :) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From graham at coms.com Tue Jun 26 05:36:49 2001 From: graham at coms.com (Graham Ashton) Date: Tue, 26 Jun 2001 10:36:49 +0100 Subject: Defining accessor methods References: <3B37FED8.2DBA3AC2@cosc.canterbury.ac.nz> Message-ID: In article <3B37FED8.2DBA3AC2 at cosc.canterbury.ac.nz>, "Greg Ewing" wrote: > Graham Ashton wrote: >> >> I thought of having get_my_attribute() and set_my_attribute() but I >> don't really like the idea because it just makes code that uses them >> more (unnecessarily) long winded, and the author of the above URL >> advises against it (though they don't say why). > > They're talking about Smalltalk, and in that context it *is* > unnecessarily long-winded to include 'get' and 'set' in the method > names. I've had some very interesting replies to this thread, thanks to all who responded. In short, accessor methods don't appear to be all that popular, and there appear to be some good reasons why not, not least the __setattr__ and __getattr__ methods. I've just thrown away all my accessor methods and am going to have to repair rakes of code, but I must admit that things are looking cleaner already. > My experience suggests that, for internal code, it's usually easier not > to bother with accessor methods until a clear need for them arises. But, > as they say, your kilometerage may vary. Indeed. It's interesting how learning a new language changes your outlook on these issues on the fly... -- Graham From laurent.szyster at q-survey.be Sat Jun 23 11:42:22 2001 From: laurent.szyster at q-survey.be (Laurent Szyster) Date: Sat, 23 Jun 2001 17:42:22 +0200 Subject: stumbled on python iif() equivalent, at last Message-ID: <3B34B8DE.67D97C24@q-survey.be> as i was peeking into compileall.py, i stumbled on: cfile = fullname + (__debug__ and 'c' or 'o') surprise: Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. IDLE 0.6 -- press F1 for help >>> __debug__ and 'c' or 'o' 'c' so, there's an iif (condition, is_true, is_false) python equivalent: >>> 1 and 'c' or 'o' 'c' >>> 0 and 'c' or 'o' 'c' nice-to-have for one-liner :-) Laurent From jkn at nicorp.f9.co.uk Thu Jun 21 09:15:27 2001 From: jkn at nicorp.f9.co.uk (Jon Nicoll) Date: 21 Jun 2001 06:15:27 -0700 Subject: arguments to calldll.call_foreign_function() ? References: <8351bb33.0106200756.4776fed5@posting.google.com> <90C68291Bgmcmhypernetcom@199.171.54.154> Message-ID: <8351bb33.0106210515.60c434ba@posting.google.com> Thanks very much! I see there's been another posting just earlier around the same topic, synchronicitously (?). Your comments there were very helpful as well, Gordon, thanks. Jon N Onwards with my experimentation ... gmcm at hypernet.com (Gordon McMillan) wrote in message news:<90C68291Bgmcmhypernetcom at 199.171.54.154>... > Jon Nicoll wrote: > > >Hi there > > I want to experiment with using calldll to access a win32 > >function: QueryPerformanceCounter(), which has a prototype > > > >BOOL QueryPerformanceCounter( > > LARGE_INTEGER *lpPerformanceCount // address of current counter > >value > > ); > > [snip] > > >>> from dynwin import windll > >>> k = windll.module('kernel32') > >>> b = windll.membuf(8) > >>> k.QueryPerformanceCounter(b.address()) > 1 > >>> b.read() > '\367[\363\211\246\000\000\000' > >>> > > - Gordon From claird at starbase.neosoft.com Wed Jun 20 11:02:07 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 20 Jun 2001 10:02:07 -0500 Subject: Interfacing GUI applications..? References: <3B18032E.21AF631E@pfortin.com> Message-ID: In article , I muddied matters by mumbling: >In article <3B18032E.21AF631E at pfortin.com>, >Pierre Fortin wrote: >>Hi, >> >>I've been searching for a couple of days now and must resort asking for help... >> >>Does anyone know if it's possible to interface to a GUI application via a Python >>script? I'm writing an application and would like to invoke Adobe's AcroRead >>(on Linux) and feed data to a "fill-in" PDF file. >> >>The minimum requirement is to make AcroRead think it's coming from the >>keyboard. Extra points for mouse events (or shortcuts, though not all menus >>items have shortcuts). > . > . > . >Is this AcroRead operating under Windows? If so, >I think it will be useful to sharpen your question >to, "Does anyone know whether AcroRead is a COM >server?" That question, incidentally, has nothing >to do with Python, and little to do with GUIs; the >folks in comp.text.pdf will more likely be of help >with that. > >If you're operating under Windows (I speculate you >are), and if AcroRead is a COM server (I anticipate >that it is), then you're in luck; Python is a GREAT >language for COM scripting. > >If not ... we'll try something else. > >Incidentally, ReportLab might interest you. 'Any- >one out there have any user reports on ReportLab? >I've cobbled together some of my own PDF manipula- >tions, but I'll happily discard all of them for a >well-done package. . . . I apologize to everyone whom I confused by failing to notice Mr. Fortin's clear description of his use of Linux. I'm ad- justing my quality-control system. Part of the conversation has been private. I'll summarize: No one believes (Linux) AcroRead is scriptable, although I continue to fantasize someone will inform us to the contrary. Usually what people mean when they ask for something like this is a way to synthesize their own .PDF documents, based on templates already at hand. I'm considering writing an article or two on the subject. I'll put pointers at . Can Python "just" script GUI stuff, the way it does command- line applications? In general, no; X's model resists that quite thoroughly, although those truly dedicated to the task will like Android . Applications built with specific toolkits--Tk, GTK+, ...--often admit more convenient scripting, when adequate documentation is also available. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From glen at enabledventures.com Wed Jun 27 09:59:44 2001 From: glen at enabledventures.com (Glen Starchman) Date: Wed, 27 Jun 2001 13:59:44 GMT Subject: Escaping SQL in python References: <3B39A1B8.A7FCE4C7@kvarteret.uib.no> <9hcbml$j70$1@news1.wdf.sap-ag.de> Message-ID: <3B39E596.D50F21D4@enabledventures.com> Daniel Dittmar wrote: > > > Is there a method to escape ' " \ and the like in python auto-magiacaly > > ? > > It is probably best to use triple quoted strings. This allows single quotes > of either variety and SQL statements tend to spread over multiple lines > anyway. You *could* use the poor man's escape routing... urllib.quote_plus. There are some obvious problems with this (such as adding characters to the resulting string), it works fine so long as you remember to use urllib.unquote_plus on the string when you return it from the database. Or, you could roll your own with something like the following: """methods for making strings SQL safe, and back again, also used for URL encoding""" import string #add anything you like to the mappings dict mappings = {"'":"''", '"':'""', ' ':'+' } def escape(*args): arg_lst = [] if len(args)==1: return escape_single(args[0]) for x in args: arg_lst.append(escape_single(x)) return tuple(arg_lst) def escape_single(x): if type(x)==type(()) or type(x)==type([]): return escape(x) if type(x)==type(""): tmpstr='' for c in range(len(x)): if x[c] in mappings.keys(): if x[c] in ("'", '"'): if c+1 Message-ID: <3b34de9a$1_2@anonymous> "Tim Peters" wrote in message news:mailman.993260616.23719.python-list at python.org... > He does ignore them *now*, yes. Do you imagine you have an argument he > hasn't heard repeatedly in 10+ years of this? I don't, but am willing to be > astonished . Well, it's hard for me to imagine that there is an argument that hasn't already been voiced in all this time. Oddly, though the only conversations I found after a while reading google didn't address my issues. First, in the FAQ, Guido says that because delimiters aren't used, no disagreement can occur between the parser and the human reader. Say what? What's the most obvious quality of whitespace? It's not called spaces because it can be other characters too. This is precisely what I don't like about whitespace for grouping, that there is always the potential for the parser to disagree with the human reader. For example (you read mail with a fixed width font right?): if 1: if 0: print '1', print '2', print '3', print '4' What does it print? The answer is any of: 2 3 4 3 4 4 The source of the ambiguity? You guessed it: The always present python annoyance concerning the fact that tabs typically look like spaces for most people and their editors. On google, I only saw conversations concerning one author editing one file. I'm more concerned about multiple people on multiple systems with various editors trying to maintain the script. Everytime I look at the file I have to think, did someone edit this file and use spaces instead of tabs? Did someone convert tabs to spaces in an editor that displays a different indent for tabs than any of other people's editors? If I paste code from one script into another, I have to worry about tabs and spaces. All answers like "just use emacs to edit your files" don't fly because it's not just me dealing with a script. Many unfortunate souls simply don't have the willingness to learn emacs. Imagine a word processing program (bear with me) that always prints two characters alike, but it's a different two characters on different systems. On my system e and a both print as e. On my cow orker's system o and n both print as o. So, then you always have to worry about which systems the document has been edited on, so that you can be suspicious of es and as if it was modified on system a, and to be suspicious of os and ns if it was modified on system b. That's stupid! Ambiguity is bad (except maybe during sex). I think python is like this. > Tools/scripts/pindent.py. At the time Guido wrote that, he announced it was > his last word on the topic. The think I don't like about it is that the source file still works with plain python. I want all people working on the script to be required to use the preprocessor to avoid the spaces/tabs thing with multiple users. I want braces I guess, or some other short delimiter, e.g.: if 1: { if 0: { print '1', print '2', print '3', } print '4', } or, how about: (if 1: (if 0: print '1', print '2', print '3',) print '4',) And I want it to complain about syntax errors regarding the delimiters. A python syntax aware parser would be required I think. So, then I can tell what the program means regardless of the spaces/tabs thing. --------== Posted Anonymously via Newsfeeds.Com ==------- Featuring the worlds only Anonymous Usenet Server -----------== http://www.newsfeeds.com ==---------- From bs1535 at sbc.com Fri Jun 8 18:20:04 2001 From: bs1535 at sbc.com (SNYDER, BARRON F. (AIT)) Date: Fri, 8 Jun 2001 18:20:04 -0400 Subject: wxPython - Appending to wxChoice? Message-ID: <35BD410BA148D411A7ED00508BCFFBDA05CB29C7@msgil65170u05.nbk2305.il.ameritech.com> Regarding wxPython... > Would somebody please show me (or point me to) an example of how to Append > an entry to a wxChoice dropdown list? I looked at the documentation and I > think I'm doing it right (I get no errors), but the strings that I append > don't seem to get added. Do I need to refresh the control (somehow) after > I append entries to it? > > Thanks, > Barron From john.thai at dspfactory.com Wed Jun 6 10:33:29 2001 From: john.thai at dspfactory.com (John) Date: Wed, 6 Jun 2001 10:33:29 -0400 Subject: py2exe Message-ID: Hi, I get the following messages when I try to use py2exe : warning: install: modules installed to 'build\bdist.win32\winexe\lib\PROGRA~1\Py thon21\', which is not in Python's module search path (sys.path) -- you'll have to change the search path yourself The win32api module is not available - modules listed in the registry will not be found. ... ... ... warning: py2exe: * The following modules were not fo warning: py2exe: * win32api warning: py2exe: * miscc warning: py2exe: * printfwc warning: py2exe: * misc2c warning: py2exe: * streamsc warning: py2exe: * gdic warning: py2exe: * stattoolc warning: py2exe: * mdic warning: py2exe: * windowsc warning: py2exe: * riscos warning: py2exe: * framesc warning: py2exe: * riscosenviron warning: py2exe: * controlsc warning: py2exe: * windows2c warning: py2exe: * eventsc warning: py2exe: * controls2c warning: py2exe: * windows3c warning: py2exe: * ce warning: py2exe: * clip_dndc warning: py2exe: * sizersc warning: py2exe: * imagec warning: py2exe: * cmndlgsc warning: py2exe: * filesysc warning: py2exe: * riscospath warning: py2exe: *********************************** ********** How do I fix this? Thanks, John From opengeometry at yahoo.ca Mon Jun 11 15:11:10 2001 From: opengeometry at yahoo.ca (William Park) Date: Mon, 11 Jun 2001 15:11:10 -0400 Subject: detecting idle processor In-Reply-To: ; from s_gherman@yahoo.com on Mon, Jun 11, 2001 at 12:00:41AM -0700 References: Message-ID: <20010611151110.A742@node0.opengeometry.ca> On Mon, Jun 11, 2001 at 12:00:41AM -0700, Sorin Gherman wrote: > How can I use Python to detect when the processor is idle? You can run a process with low priority using 'nice', or obtain the system load by parsing 'uptime'. But, that's in Unix... > Or when the network traffic is idle, for a given computer? You can use 'pppstat' for PPP, but I am not sure about ethernet. > > I need this to implement a background program. Easiest solution is 'nice'. -- William Park, Open Geometry Consulting, 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From morten at pool.informatik.rwth-aachen.de Sat Jun 30 18:08:49 2001 From: morten at pool.informatik.rwth-aachen.de (Morten Gulbrandsen) Date: Sun, 01 Jul 2001 00:08:49 +0200 Subject: ImportError: No module named colormap Message-ID: <3B3E4DF0.3430571F@pool.informatik.rwth-aachen.de> Hello Programmers here is some python code from this URL: http://www.pauahtun.org/TYPython/ from Tkinter import * from Canvas import Line,Rectangle import sys import string from colormap import * from tkFileDialog import * I cant get through this error message: morten at debian:~$ python mandelbrot2.py Traceback (innermost last): File "mandelbrot2.py", line 7, in ? from colormap import * ImportError: No module named colormap How can I solve this Problem unter Debian and FreeBSD ? Yours Sincerely Morten Gulbrandsen -------------- next part -------------- An HTML attachment was scrubbed... URL: From agavrilov at home.com Fri Jun 1 17:15:10 2001 From: agavrilov at home.com (Alexander Gavrilov) Date: Fri, 01 Jun 2001 21:15:10 GMT Subject: Weird attribute behavior... References: <3B17E975.F11AB911@core.com> Message-ID: Your __data is the class attribute and is shared among all instances of Reading therefore. You have to remove __data from the class and move it to __init__ function like this: class Reading: def __init__(self, type, id, timezone, datestamp, value): self.__data = {} self.__data['id'] = id -- Alexander Gavrilov Brainbench MVP for C++ http://www.brainbench.com "Ralph Allan Rice" wrote in message news:3B17E975.F11AB911 at core.com... > I am developing a class that stores device reading information. It > looks like this: > > > import string > import dbi, odbc > > > class Reading: > __data = { } > > def __init__(self, type, id, timezone, datestamp, value): > self.__data['id'] = id > self.__data['timezone'] = timezone > self.__data['datestamp'] =datestamp > self.__data['value'] = value > self.__data['type']= type > > > def __getattr__(self, name): > if name in self.__data.keys(): > return self.__data[name] > else: > raise AttributeError, name > > def __repr__(self): > return "%s : %s" % (self.__data['datestamp'], self.__data['value']) > > > Now, there is a method in another class that creates instances of > Reading based on the number of records in a database... > > > (from Class User) > > def getReadings(): > s = None > cur = None > result = [ ] > try: > s = odbc.odbc("mydatabase/user/pwd") > sql = """ > set rowcount 100 > select rec_id, timezone,date_time, data from readings where user_id > = %d and rec_type = 'G' > order by date_time desc""" % self.__user['id'] > cur = s.cursor() > cur.execute(sql) > while 1: > rec = cur.fetchone() > if not rec: break > # Confimed: rec tuple is different every iteration..., so is each > element... > # rec is a tuple of immutable objects (int, string, etc) > xr = Reading ('G', rec[0], rec[1], rec[2], rec[3]) > result.append(xr) > cur.close() > s.close() > cur = None > s = None > except: > raise > > return result > > > When I call this method, it returns a list of Reading instances. > Examining each instance in the list: > ie.. (from command line): > >>> from mymods import User > >>> s = User() > >>> r = s.getReadings() <-- Returns a list of Reading instances > >>> r[0].id is r[1].id <-- Compare object references of two instances > 1 <-- How can this be? > >>> r[0].value is r[1].value <-- Compare another attribute > 1 <-- AGAIN?? > ... > When I print each instance of Reading, the values printed are the same. > In other words, the attributes in each instance of Reading is > referencing the SAME set of objects! How is this possible? > > My first thought was that the rec tuple returned from the cursor method > fetchone() is a tuple mutable objects, but after doing some type > checking, I have determined that the rec tuple's elements were immutable > built-ins (integer, strings, floats). > > Any ideas or suggestions??? This is so baffling! > > Thanks, > Ralph From tage at pasta.cs.uit.no Mon Jun 4 06:41:55 2001 From: tage at pasta.cs.uit.no (Tage Stabell-Kulo) Date: 4 Jun 2001 10:41:55 GMT Subject: random References: Message-ID: <9ffolj$d9t$1@news.uit.no> "Tim Peters" writes: >[Darren New] >> how random is the binary string "1001010010011100100"? How >> random is the binary string "0000000000000000000"? Such questions >> don't make any sense. >BTW, you can find attempts to answer such questions in Knuth, Vol 2. The >questions not only make sense, but finding non-trivial answers is important >in real life: even if you have a theoretically perfect physical RNG, how >can you have confidence in a specific real implementation? Knuth answers a different question. His question is "Algorthm X produced these bits: 010101. Based on them, can we detect some patterns that should refrain us from relying on this algorithm as a source of (pseudo)random bits?" In other words, he is analysing sources of randomness, not whether some string is random. An important difference. Randomness is interesting only for the next bit, not the ones you already have. Because you have them, they are not random. Thus, the bits 1001010010011100100 or 0000000000000000000 are not random, although they might have been. [TaSK] -- -- //// Tage Stabell-Kuloe |e-mail: Tage at ACM.org (at=@)//// ///Department of Computer Science/IMR|Phone : +47-776-44032 /// //9037 University of Tromsoe, Norway|Fax : +47-776-44580 // From aleaxit at yahoo.com Thu Jun 28 11:52:40 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 28 Jun 2001 17:52:40 +0200 Subject: Unicode and print with python 2.1 References: Message-ID: <9hfjs9068l@enews1.newsguy.com> "Alexandre Fayolle" wrote in message news:slrn9jmbi4.cf2.alf at leo.logilab.fr... > Hello, > > This is probably going to sound stupid, but here I go anyway. Please refer > me to TFM if this is what I deserve. > > Is it normal to get UnicodeError when I try to print a unicode string with > Python 2.1? Alas, yes. That's because *by default* the standard codec used by Python is 'ascii', which only covers the 7-bit range that is common to just about all encodings, and NOT the characters with the 8th bit set that one needs for various "national character" encodings. I think it's reasonable for most Western European Python sites to have a siteconfig.py module that sets the default encoding to 'latin-1' (aka iso-8859-1, but don't use that name: it uses, I believe, a slower implementation, while 'latin-1' has a built-in implementation, as far as I understand things). Note that you MUST do it in siteconfig.py (or by editing site.py, but that's not advisable), because the setdefaultencoding() function (originally in sys) is then removed by site.py, so the default encoding cannot be changed "in midstream". Well, you COULD: import sys reload(sys) sys.setdefaultencoding('latin-1') but that would be clearly against the design intent of the Unicode subsystem!-) Alex From MarkH at ActiveState.com Sat Jun 23 21:08:49 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sun, 24 Jun 2001 01:08:49 GMT Subject: How do I close a specific application via python (windows) References: <9gvva4$i4v$1@bob.news.rcn.net> <9h0jl5$ose$1@bob.news.rcn.net> Message-ID: <3B353DA4.9000500@ActiveState.com> Christian Reyes wrote: > I've been looking at the win32api.openprocess method and that seems to give > me hooks to killing an app. > But my problem is that openprocess needs a processID. > > How do i get the process id of an application? > Check out killProcName.py in the win32\scripts directory. Mark. From paulp at ActiveState.com Fri Jun 15 17:42:03 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 15 Jun 2001 14:42:03 -0700 Subject: Any other Python flaws? References: <3B2A530C.5F798823@bioreason.com> <3dvglxe9j3.fsf@ute.cnri.reston.va.us> Message-ID: <3B2A812B.A2474432@ActiveState.com> Andrew Kuchling wrote: > > ... > > It's hard to see how you could implement cancellable threads with > reasonable performance, though, unless the OS implements all the > primitives and can therefore clean things up when a thread is > cancelled. I lean more and more toward thinking that threads are a > mistake, and if you think you need them, your OS simply has processes > that are too heavyweight. There are many graphical applications that use threads to keep the user interface responsive while doing heavy computation or network IO in the background. Let's say we spin those out into processes. What would you propose for sharing data structures? COM? If we make processes lightweight, and we devise mechanisms for sharing structured data between them, we are basically reinventing threads so why not use threads in the first place? -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From jicondon at us.ibm.com Thu Jun 7 16:32:57 2001 From: jicondon at us.ibm.com (Jeffrey I Condon) Date: Thu, 7 Jun 2001 13:32:57 -0700 Subject: fyi - Two article on XML and Python Message-ID: Revisiting XML tools for Python ---------------------------------- David Mertz looks at advances in XML tools for Python developers. http://www-106.ibm.com/developerworks/xml/library/l-pxml.html?open&l=913,t=grx,p=xpyth XML Matters #2 ---------------------------------- On the "Pythonic" treatment of XML documents as objects (II) http://www-106.ibm.com/developerworks/xml/library/xml-matters2/index.html?open&l=913,t=grx,p=xm2 From aleaxit at yahoo.com Wed Jun 20 17:47:46 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 20 Jun 2001 23:47:46 +0200 Subject: Partially evaluated functions References: Message-ID: <9gr5k601nh4@enews1.newsguy.com> "Nick Perkins" wrote in message news:VL5Y6.296349$eK2.60381920 at news4.rdc1.on.home.com... ... > I tested your solution, the cookbook version, and Alex's nested_scopes > version. > All three work properly for the kwd args tests that I performed. ... > # by Rainer Deyke > class curry_RD: [snip: 8 LOCs] > # by Scott David Daniels (from cookbook) > class curry_CB: [snip: 11 LOCs] > # by Alex Martelli > # (using nested_scopes) > def curry_AM(func, *args, **kwds): [snip: 4 LOCs] Interesting. Given the compactness it affords for such tasks as currying, maybe scope nesting ain't so bad after all. It could be worth placing a comment on Scott's CB entry, since the various alternative techniques need to be considered... Alex From castor at snafu.de Wed Jun 6 19:12:21 2001 From: castor at snafu.de (Wolfgang Lipp) Date: Wed, 06 Jun 2001 23:12:21 GMT Subject: Problems with Vaults of Parnassus Message-ID: <1108_991869141@ns.seowon.ac.kr> readers, I am having a few problems with the vaults of parnassus recently. the vaults are undisputedly *the* one-stop station whenever you look for a python module. however, there are three problems i can see: the current categorization is somehow less than satisfying. i do not want to delve into an analysis here; if nobody feels this way, ignore the point. if someone agrees, perhaps this can be made more concrete. more seriously, the search engine does not work correctly. i have experienced this several times, and i am sure it is not a mistake i make, it is a malfunction. please go try for yourselves: on http://www.vex.net/parnassus/apyllo.py/751771926.353274583 you'll find jim fulton's extension classes (with a sadly broken link, but that's more of dc's problem). the author's name is in the field titled 'owner'. now go to the search form below and try to find 'jim', 'fulton', 'jim fulton', lowercase, uppercase. restrict the search to 'any text', 'owners', do what you will -- "No Parnassus records matching your search criteria were found." is the sole answer. then, try 'extensionclass' -- same, no results. only thing that does yield results is 'extension class' (13 records) and 'extension class' (87 records). it must be admitted that 'extensionclass' is not in the text of the page, but it's in the url. be that as it may, the name of the owner does appear and is not found. next, you say ok, those extensionclasses must be somewhere, so you follow the download link to fetch http://www.vex.net/parnassus/download/Parnassus-Condensed-by-Category.html which is sadly way behind time, and there, indeed! you find a lot of hits for 'extension' (using the browser's find-on-page function) plus one for 'extensionclass' (this time, the url is, of course, found because it is included in the listing). however, names of owners/authers do *not* appear in the listing. in all, if i was asked 'please find out whether a guy named jim fulton, who works for digital creations, has made available a module called extensionclass', and i go searching, i sure would have to answer in the negative, which is not correct. obviously, we have a few problems that intertwine here, and some of them are not within the vault's responsibility (although it may be hard to communicate to executives why links are not checked for validity and listings are not updated nightly). does anyone have similar experiences? where is the problem? -wolf From bos at hack.org Sun Jun 17 03:05:55 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Sun, 17 Jun 2001 09:05:55 +0200 Subject: Using the While Loop References: <20010616.101117.1469262009.1725@behemoth.miketec.com> Message-ID: <3B2C56D3.EBC30EBA@hack.org> Mike Johnson wrote: > I don't see why this first code snippet won't work, but I can't find any > pointers in the documentation. http://www.python.org/doc/FAQ.html#6.30 -- Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From ctavares at develop.com Sat Jun 30 00:03:20 2001 From: ctavares at develop.com (Chris Tavares) Date: Sat, 30 Jun 2001 04:03:20 GMT Subject: Python for air traffic control? References: Message-ID: "Russ" <18k11tm001 at sneakemail.com> wrote in message news:bebbba07.0106291642.6c799d15 at posting.google.com... > I am thinking about using Python for a unique safety-critical > application in air traffic control. It will monitor a few hundred > aircraft for conformance to assigned trajectories, and it will > initiate an automatic alarm (for both controller and pilot) if an > aircraft deviates from its assigned trajectory and is in danger of a > collision. (The trajectory and tracking data will come from existing > C/C++ programs.) The software must be as simple, clean, and robust as > humanly possible. The default languages here are C/C++, but I am > toying with the idea of using Python instead. However, I am a bit > nervous about the lack of type checking and function prototyping, > among other issues. Is Python up to this task? Thanks for your > insights. > I think Python is up to the task, as long as you do LOTS and LOTS of unit tests! If type checking is a concern, I'd suggest that perhaps you look at Eiffel instead. The language itself is fairly simple, and Bertrand Meyer is really into strong typing, so you'll not get away with anything other there. :-) -Chris From bokr at accessone.com Sun Jun 3 15:24:32 2001 From: bokr at accessone.com (Bengt Richter) Date: Sun, 03 Jun 2001 19:24:32 GMT Subject: Embedded 'C' problem? References: <3b195197.147691268@wa.news.verio.net> Message-ID: <3b1a6f43.220823978@wa.news.verio.net> On 3 Jun 2001 01:11:03 -0700, samschul at pacbell.net (Samuel Schulenburg) wrote: [...] >I would like to give a big thanks to your post. You hit the solution >right on the head. I ennded up escaping \" \' \\ and that fixed the >problem. Glad it worked out. Actually what prompted this is your \' above. UIAM you only need to escape the kind of quote you're quoting with. I think you should have been ok with just \" and \\ since you were quoting with """. I'm not saying \' will hurt anything, just wondering if you actually needed it. >>> print '"',"'","\"",'\'' " ' " ' Triple quotes give you more freedom, which is handy for writing __doc__ strings including newlines etc., but you still have to use an escape to quote the same kind of triple quote as you're quoting with: >>> print '''"""''',"""'''""","""""\"""",'''''\'''' """ ''' """ ''' I.e., you just have to avoid three in a row, which you can do by escaping the third. But with unknown input it's easier just to escape all the quotes matching your outside quotes. Your application did seem a little odd, but I suppose it was a test thing ;-) From loewis at informatik.hu-berlin.de Tue Jun 5 04:30:13 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 05 Jun 2001 10:30:13 +0200 Subject: Is PyRun_String() broken? References: Message-ID: David Gravereaux writes: > I've tried using Py_single_input for the start token, but the result of the > operation is sent to stdout. How is it possible to eval code and get the result > back? As far as I've able to RTFM and "use the source luke" is to determine > that eval_code2() when coming back out of the eval falls into the POP_TOP case > and does Py_DECREF(v) on the result to destroy it. > > I WANT IT! WHERE'D IT GO? If you want the result of some computation, that computation better be an expression; statements don't have a result. So you should use Py_eval_input. > If all that PyRun_String() returns is "exception or not", where/how is it > possible to get the last result of the operation? Is it true that POP_TOP in > eval_code2() of ceval.c discards the object before returning? How can I not pop > the top, and grab the result then Py_DECREF it after I'm done? You cannot. If you have a Py_file_input that has "computes some value", that file input should either assign to some variable, or be a function that you can call so that it returns a result. Why do you want the result of the last expression statement, anyway? Regards, Martin From carlf at panix.com Wed Jun 20 15:31:16 2001 From: carlf at panix.com (Carl Fink) Date: 20 Jun 2001 19:31:16 GMT Subject: ANN: PythonCard mailing list References: Message-ID: In article , Gary Herron wrote: > Could you please spare just one little sentence to describe > what a pythoncard discussion is *about*? People who have used HyperCard and its descendants and derivatives, discussing creating a Python-based and Python-scripted version of same. So embryonic it's still less than two days old. -- Carl Fink carlf at dm.net From loewis at informatik.hu-berlin.de Fri Jun 8 13:34:03 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 08 Jun 2001 19:34:03 +0200 Subject: Passing back an array from an extension module? References: <9fqqqo$1p3e$1@newshost.nmt.edu> Message-ID: "Bob Greschke" writes: > Then I need to pass that back to the Python side for graphing > the values. I initially thought I could just create a tuple and pass > that back, since nothing is going to be done with the values except to > draw a graph, but there is the possibility of there being 16,000,000 > data points...that makes for a slightly large statement, doesn't it? > It doesn't look like I can do this with arrays in stock Python, but it > does look like I can do it with the NumPy arrays. Is that correct? Not sure what 'this' is here. You certainly can create 'custom' array types in Python, see Modules/arraymodule for an example of an array type that is implemented using a C memory buffer of primitive C values. I don't know whether you can use a NumPy array off-the-shelf; I assume no since it probably manages its own memory. So you need to create a new type (see xxmodule.c for an example), and implement its tp_as_sequence slot. > Now what about Py_DECREF, INCREF and all of that stuff in these > situations? I read through a number of posts on dejagoogle that were > talking about this, but they only confused me more. :-) I recommend you read the "Embedding and Extending tutorial". Basically, you need to implement an array accessor, which creates and returns a PyInt_FromLong every time you access the nth element of your array. When the reference counter of your Python wrapper object drops to zero, you should free(3) the memory of the very large array. Regards, Martin From skip at pobox.com Fri Jun 1 12:31:06 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 1 Jun 2001 11:31:06 -0500 Subject: Obsolesence of <> In-Reply-To: References: Message-ID: <15127.49994.44256.416325@beluga.mojam.com> >>> "??b" == u"abc" ... UnicodeError: ASCII decoding error: ordinal not in range(128) Lulu> So the next obvious question: WHY is this error raised?! Python is trying to coerce the ASCII string on the left to be the same type as the Unicode string on the right. It fails because the first two characters have ordinal values greater than 127. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From loewis at informatik.hu-berlin.de Sat Jun 16 15:08:20 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 16 Jun 2001 21:08:20 +0200 Subject: Slightly Off Topic : restrictions on the response part in a SOAP-response References: Message-ID: "Thomas Weholt" writes: > Just wondering if I could put whatever XML I want into the response-part of > a SOAP-response. I think definite answers to that can be best found in the SOAP specification, http://www.w3.org/TR/SOAP/ My understanding is that section 5 (SOAP Encoding) is optional, and that you can use whatever content for the body as long as you declare the encoding properly (i.e. define your own encoding). If you want to follow section 5, you must have a schema definition for all the elements you want to use. Regards, Martin From aahz at panix.com Wed Jun 13 10:58:31 2001 From: aahz at panix.com (Aahz Maruch) Date: 13 Jun 2001 07:58:31 -0700 Subject: Global Variables + Threads References: <3B26796A.C3FAF2E3@telocity.com> Message-ID: <9g7v2n$6l2$1@panix6.panix.com> In article <3B26796A.C3FAF2E3 at telocity.com>, Adonis wrote: > >in python im declaring varibles in which willbe used by Tkinter as >objects within itself; now since they are globally declared i assumed >they would be fill as soon as the class thread finishes execution. or by >being a thread; thus being pushed to its own thread makes it lose >"contact" with the global variable and instead declares it as local? > >if this is the case then how may i fix it? Pass around a class instance. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Just because I'm selling you into slavery doesn't mean we can't be friends." B-movie cliche Hall of Fame (_Bounty Hunter: 2002_) From xyzmats at laplaza.org Wed Jun 13 15:26:19 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Wed, 13 Jun 2001 19:26:19 GMT Subject: Inner classes References: <3b27a1aa.6747983@news.laplaza.org> <3dae3cfcl4.fsf@ute.cnri.reston.va.us> Message-ID: <3b27bd5a.13836285@news.laplaza.org> On 13 Jun 2001 14:40:07 -0400, Andrew Kuchling wrote: >xyzmats at laplaza.org (Mats Wichmann) writes: >> Nonetheless, I was challenged by someone to describe how it isn't a >> shorcoming in Python that classes don't work this way and didn't >> convince the guy so I'm looking for a more erudite comparison. > >Work *what* way? It's perfectly legal to do this: > >class C: > class inner: > ... stuff for inner class > ... stuff for class C Right, but that doesn't work like a Java "inner class". If I've understood correctly, that just makes up a new class, which has a name "inner", a name that happens only to be visible inside C. But the class referred to by "inner" isn't otherwise related to C, and does not have access to symbols defined inside C except through qualification, which is a pain if you want attributes of an instance of C. Mats From grante at visi.com Mon Jun 4 14:48:08 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 04 Jun 2001 18:48:08 GMT Subject: I NEED to TEACH you something, QUICK! References: <9fghps$av0$1@newshost.accu.uu.nl> Message-ID: In article <9fghps$av0$1 at newshost.accu.uu.nl>, Martijn Faassen wrote: >Itamar Shtull-Trauring wrote: >> Rainer Deyke wrote: > >>> Did you actually write all that, or was it algorithmically >>> generated? > >> Really... can't you recognize a simple Usenet posting on the >> subject of "'Usenet discussions about war' as a metaphor for >> refactoring" when you see one? > >Perhaps the confusion is caused by the apparent lack of >context/attribution. She seems to be quoting someone in some >post that I don't know about. I try to give people the benefit of the doubt by assuming that it would have made sense if I'd been paying closer attention. That assumption is right more often than I'd like to admit. -- Grant Edwards grante Yow! There's a SALE on at STRETCH SOCKS down at the visi.com "7-11"!! From bill-bell at bill-bell.hamilton.on.ca Sat Jun 30 19:06:58 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Sat, 30 Jun 2001 19:06:58 -0400 Subject: data from Acces to Excel In-Reply-To: <993876187.1194.36282.l9@yahoogroups.com> Message-ID: <3B3E2352.20405.443D2D7@localhost> "baton" wrote, in part: > I wonder if there is a possibilyty to export table from Access > database to Excel using python language?? If yes, could you tell me > how to do it or where I can find info how to do it? Yes, it's possible and not too difficult. 1. Launch MS Excel. 2. Create a query against the Access database (Data | Get external data | Create new query). 3. Start saving a macro. 4. Import the data using the query you have just created (Data | Get external data | Run database query). 5. Stop saving the macro. 6. Open the macro in the Visual Basic editor (Tools | Macro | Macros) and translate it to Python, using techniques described in Chapter 12 of Hammond and Robinson, Python Programming on Win32, O'Reilly (this chapter is available on www.oreilly.com). That's it! If you need to import different data from MS Access then make your Python script construct the query for itself rather than using MS Excel to do it in the way mentioned above. Good luck. Bill From qrczak at knm.org.pl Tue Jun 12 03:30:01 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 12 Jun 2001 07:30:01 GMT Subject: PEP 259: Omit printing newline after newline References: <3dd78ag04f.fsf@ute.cnri.reston.va.us> Message-ID: 11 Jun 2001 17:47:12 -0400, Andrew Kuchling pisze: > -1; I'd rather see a strip_trailing_whitespace argument added to > .readlines(), or some alternative idiom encouraged that sidesteps the > issue. Magical behaviour is bad. print is too magic in the first place. I would rather add write builtin function, equivalent to sys.stdout.write, and arrange that write functions are easy to use, i.e. allow multiple arguments, apply str to them, and maybe have also writeln. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From me at nospam.com Sat Jun 2 12:17:56 2001 From: me at nospam.com (Bart Kowalski) Date: Sat, 2 Jun 2001 12:17:56 -0400 Subject: best language for 3D manipulation over web ? References: Message-ID: <4b8S6.455$ZW.116496@news20.bellglobal.com> > Oh... and all you anti Cross - Post fanatics out there chill > out!!!!!!!!!!!!! e-commerce/Internet privacy and security is an illusion. > Its all public whether we like it or not. What the hell are you talking about? It's not about security. It's about not starting yet another stupid flame war between Java zealots and C++ zealots. Bart. From tjenkins at devis.com Mon Jun 4 09:26:28 2001 From: tjenkins at devis.com (Tom Jenkins) Date: Mon, 04 Jun 2001 09:26:28 -0400 Subject: subclassing wxMenuBar... References: <6957F6A694B49A4096F7CFD0D900042F27DB6B@admin56.narex.com> Message-ID: <3B1B8C84.3060403@devis.com> Bjorn Pettersen wrote: > I was stepping through the wxPython tutorial, and came across the part > where they're creating the menus. It seemed like a good idea to put the > menu definition in a datafile instead of specifying it programatically, > so I though it would be a good chance to get some xml experience too... > Yep, that makes sense... [snip] > which I'm assuming means that the SWIGd code is expecting a wxMenuBar > pointer to be the first argument to Append and can't deal with a > subclass... > > Does anyone know a way around this? > > -- bjorn > > Well I wouldn't subclass wxMenuBar; instead I'd create a helper class that would handle reading the xml and loading it into the wxMenuBar. I took your code and changed it to work as a helper. Along the way I added some functionality. First I changed the format of the xml by wrapping it in a menubar tag. This allows us to have one or more menu elements. To handle this in the code, I changed the for loop to loop over each "menu" element in the menubar: menubar = minidom.parse(self._filename) # loop over and process all of the menu elements in the menubar for menu in menubar.getElementsByTagName('menu'): Another addition I made was to add a callback attribute. Then if you pass a class instance to the load method, the load method will attempt to hookup the method name set in the callback attribute in the controller class instance. To use this new class you would do the following in the frame: loader = XMLMenuLoader('menu.xml') loader.load(wxMenuBar = self.mainmenu, controller=self) loader.setMenuBar(None) By changing your original code from a subclass of a wxMenuBar to an helper class, we can expand the usefulness. Perhaps instead of xml we decide to use nested lists? We can refactor the XMLMenuLoader class into a base MenuLoader class and various subclasses. Thanks for the initial post Bjorn, I had fun working on this... -- Tom Jenkins devIS - Development Infostructure http://www.devis.com -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: menu.py URL: From aleaxit at yahoo.com Sun Jun 3 15:17:12 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 3 Jun 2001 21:17:12 +0200 Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> <3B1A82DD.C4D78472@san.rr.com> Message-ID: <9fe2g302841@enews2.newsguy.com> "Darren New" wrote in message news:3B1A82DD.C4D78472 at san.rr.com... > Alex Martelli wrote: > > So what does the "GIVEN _complete_ information" above > > is, if not a statement that you CAN be given complete > > information about > > I interpreted it as meaning "given that you know everything about the > system that it's possible to know." If you have complete information, > then you know the exact probabilities that any particular item is in any > particular state. Just like if you have "perfect dice", it means that > all the probabilities are exactly 1/6. This doesn't tell you which > number a perfect die will roll next. But why should "perfect information" about the dice tell me only that they're perfect, and not their state? That's like saying that "perfect information" about an algorithm tells me only it's a good one, and gives me no information about the state it starts in. What can I predict then? > > I still haven't heard your definition of > > 'perfect' randomness, for example. > > Generally, this is something along the lines of: > Given all available information about the mechanism used to generate the "available" seems to play a rather crucial role here, then. > bits, and an arbitrarily long sequence of generated bits, it's > impossible to predict with >50% accuracy what the next bit in the > sequence will be. > > I'm not sure it always includes the first condition. That would only leave the arbitrarily long sequence of generated bits and no other info? Fine, then: > I don't think Chaitin's Omega meets this definition, since it is by > definition a single number than anyone can calculate equally well. But from Omega's first N bits, you get no hint at all that lets you predict its N+1-th bit "with > 50% accuracy". So, if the definition does not include the first condition, from the bits only you're not going to get any farther than from N tosses of an idealized coin. Alex From glen at enabledventures.com Fri Jun 15 12:16:46 2001 From: glen at enabledventures.com (Glen Starchman) Date: Fri, 15 Jun 2001 09:16:46 -0700 Subject: Inner classes References: <3b27a1aa.6747983@news.laplaza.org> Message-ID: <3B2A34EE.FEF14DBC@enabledventures.com> Paul Prescod wrote: > In Java all of the code would have to be in a class and _onclick would > have to be defined in *another* class (because you can't pass references > to functions/methods). Thus you need inner classes. One of the most difficult (well, maybe not *difficult*, but definitely time-consuming) things in converting Java classes to Jython (or Python) classes is that bastard of all Java features: the anonymous inner class. Given code that looks like: class StupidExample { StupidExample() { JButton button = new JButton("Dumb Button"); button.addActionListener(new ActionListener() { actionPerformed(event e) { doSomething(); ... } } } } What happens if you decide to add another button that has similar functionality? In this case, you end up writing yet another anonymous inner class. Icky. So, in Jython, what I do is either implement ActionListener in the parent class, and write a multi-purpose handler, or write a second class for the handler: class StupidExample(ActionListener): def __init__(self): self.button = JButton("Dumb Button") self.button.addActionListener(self) def actionPerformed(e): if e.getSource==self.button: doSomething() ... Now, after typing all of that I have forgotten my point... oh, yeah... Inner Classes (and *especially* Anonymous Inner Classes) suck. > > In some languages without first-class classes, you hack classes through > function "closures". In languages without first-class functions, you > hack functions through "one-method classes". Python has both and you > don't have to hack! Hurray for Python! > -- > Take a recipe. Leave a recipe. > Python Cookbook! http://www.ActiveState.com/pythoncookbook From MarkH at ActiveState.com Thu Jun 7 19:19:41 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 07 Jun 2001 23:19:41 GMT Subject: ActivePython and WSH problem References: Message-ID: <3B200C2D.5020701@ActiveState.com> JohnB wrote: > However, on running it, the following error is displayed "...pytest.wsf(6, > 14) Windows > Script Host: The value for the attribute is not valid : language". > I've seen it claimed on the net that this should work, so I suspect my > ActivePython install didn't register something as a script engine for > Windows Scripting Host, or I'm doing something stupid. Any ideas? Almost certainly a problem with ActivePython (that will be fixed next version :) Go to a command-prompt, change to the win32comext\axscript\client directory, and execute the following commands: python pyscript.py --unregister python pyscript.py And all should be fine. Mark. From loewis at informatik.hu-berlin.de Mon Jun 18 06:55:10 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 18 Jun 2001 12:55:10 +0200 Subject: get class instance from C++ extension? References: <8kiW6.41$%3.2442@news3.dion.ne.jp> Message-ID: "Toshiya Kawakami" writes: > I read the spec of PyObject_CallFunction() in "Python/C API > Reference Manual", but cannot understand how to use it. > Is there any simple example for PyObject_CallFunction()? Please have a look at Objects/readline.c. There, you have on_completion(char *text, int state) which ought to call a completion function. It does so by writing r = PyObject_CallFunction(completer, "si", text, state); if (r == NULL) goto error; The "s" means that the first argument to the completer is a string, and the "i" means the second argument is an integer. Regards, Martin From m.faassen at vet.uu.nl Mon Jun 18 14:02:40 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 18 Jun 2001 18:02:40 GMT Subject: Type/Class Distinction References: <9gdpbp$61k$6@newshost.accu.uu.nl> <9gfp64017jh@enews1.newsguy.com> <9ggc6n$f22$1@newshost.accu.uu.nl> Message-ID: <9glfo0$gp2$1@newshost.accu.uu.nl> Michael Hudson wrote: > m.faassen at vet.uu.nl (Martijn Faassen) writes: [snip] >> > You're behind the times, I think (if I understand you correctly): >> >> So I am! I wasn't aware this was the case. Does not seem to be mentioned in >> Andrew Kuchling's 'What's new in Python 2.1'. > Well, that would be because it wasn't "new in Python 2.1"; > >>> import types > >>> isinstance(1, types.IntType) > 1 > works in 1.5.2 (the oldest version I have lying around). Duh. (hits himself in the head) :) Shows you how often I use 'isinstance()'! I'll-go-back-to-*deliberately*-silly-posts-now-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From senux at senux.com.NOSPAM Mon Jun 18 00:58:05 2001 From: senux at senux.com.NOSPAM (Brian Lee) Date: Mon, 18 Jun 2001 04:58:05 GMT Subject: freeze.py error? Message-ID: <3B2D8AA3.7050902@senux.com.NOSPAM> On Python 2.1 I want to ``freeze'' a application with wxPython and xmlwpclib. Error occours like this. Distutils is version 1.0.2. Any ideas? - Brian,. PS) I completed to make C code from sample code, hello.py and it works well. But my only application do not work with freeze.py $ python freeze.py -o dir mydomainclient-0.1.0.py Traceback (most recent call last): File "freeze.py", line 465, in ? main() File "freeze.py", line 344, in main mf.run_script(scriptfile) File "modulefinder.py", line 90, in run_script self.load_module('__main__', fp, pathname, stuff) File "modulefinder.py", line 259, in load_module self.scan_code(co, m) File "modulefinder.py", line 279, in scan_code self.import_hook(name, m) File "modulefinder.py", line 102, in import_hook q, tail = self.find_head_package(parent, name) File "modulefinder.py", line 143, in find_head_package q = self.import_module(head, qname, parent) File "modulefinder.py", line 229, in import_module m = self.load_module(fqname, fp, pathname, stuff) File "modulefinder.py", line 244, in load_module co = compile(fp.read()+'\n', pathname, 'exec') File "", line 65 ^ SyntaxError: invalid syntax From gardner at cardomain.com Mon Jun 4 15:07:24 2001 From: gardner at cardomain.com (Jonathan Gardner) Date: Mon, 4 Jun 2001 12:07:24 -0700 Subject: What does x[:]=[4,5,6] mean? References: <9fb7cu$lq6$1@newsreaderg1.core.theplanet.net> <87elt2u5rr.fsf@litterbox.meowing.net> Message-ID: <9fgm2k$at7$1@brokaw.wa.com> Indirect Meowbot wrote: > "Franz GEIGER" wrote: > >> In site.py I saw >> sys.path[:] = L >> What does this mean? Why is the '[:]'? Why not simply >> sy.path = L ? > > In a language like C you have to work a little bit harder to get a > pointer to something. In Python, you have to work a little bit harder > _not_ to get just a reference. > >>>> meow = [1,2,3] >>>> woof = meow >>>> meow[0] = 42 >>>> print meow, woof > [42, 2, 3] [42, 2, 3] >>>> # Ewww! > ... >>>> meow = [1,2,3] >>>> woof[:] = meow >>>> meow[0] = 42 >>>> print meow, woof > [42, 2, 3] [1, 2, 3] >>>> # Yay. The bottom line is the assignment operator _never_ makes a copy of something - the end result is to make the variables point to the object on the right hand side. Try this: >>> a = 3 >>> b = a >>> id (a) 135045160 >>> id (b) 135045160 >>> # What? a and b are the SAME OBJECT! >>> b += 1 >>> id (a) 135045160 >>> id (b) 135045148 >>> # Now they are different So, the only "value" that the variables hold in python is the address of whatever object they are pointing to. Therefore, every variable in Python is a reference, or a pointer, whatever you prefer. From dnew at san.rr.com Sun Jun 3 21:02:37 2001 From: dnew at san.rr.com (Darren New) Date: Mon, 04 Jun 2001 01:02:37 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> <3b19393d.703539923@news.okstate.edu> Message-ID: <3B1ADE2D.A6E86ECE@san.rr.com> "David C. Ullrich" wrote: > That's assuming that physics is not all wrong. And > probably I should not have said what I did the > way I did, because my impression is that there > is really no such thing as complete information > about a physical system. Last I heard, the "hidden variable" theory was disproved by the Bell Inequality. I.e., there's no information in a system that is just invisible but really controlling when the atom will decay. Instead, that information just isn't there. Apparently, you can actually do experiments to tell the difference. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. This is top-quality raw fish, the Rolls-Rice of Sushi! From elf at halcyon.com Sun Jun 17 01:46:52 2001 From: elf at halcyon.com (Elf Sternberg) Date: 17 Jun 2001 05:46:52 GMT Subject: qt or gtk? References: <9ggof8$gmd$1@brokaw.wa.com> Message-ID: <9ghg8c$teo$1@brokaw.wa.com> In article <9ggof8$gmd$1 at brokaw.wa.com> Jonathan Gardner writes: >Courageous wrote: >> Do recall that Qt is only *half* free. It is free for Linux development, >> but costs an arm and a leg on Windows. >Now I feel stupid. I thought Qt was free to use if your software is >free, but costs money if you plan to sell it. Qt is distributed under the GNU Public License and TrollTech's Commercial License. What this means is that if you write a program using Qt, you have two choices: you can distribute your program in the whole, source code and all, or your can pay TrollTech's licensing contract and keep your source code secret. Note that this does not mean you cannot sell your GPL version of your Qt program. Sure you can. It does mean that if you do so, you also give whoever receives your program the right to modify, sell, or otherwise distribute it under the same terms as you yourself. Elf -- Elf M. Sternberg, rational romantic mystical cynical idealist http://www.halcyon.com/elf/ Dvorak Keyboards: Frgp ucpoy ncb. ru e.u.bo.v From sholden at holdenweb.com Wed Jun 20 18:20:49 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 20 Jun 2001 18:20:49 -0400 Subject: Properties in Python References: Message-ID: "phil hunt" wrote in message news:slrn9j1aj0.893.philh at comuno.freeserve.co.uk... > On Wed, 20 Jun 2001 02:04:33 GMT, Peter Caven wrote: > >I'm sure that many people reading this newsgroup are aware that the C# > >(C-Sharp) language has a syntax for 'Properties' that allows a class > >implementor to hide the implementation of an instance's attribute behind a > >'get'/'set' interface. > >In Python terms this would look like: > > > >class Demo: > > def __init__(self): > > self.attr1 = 1 > > self.attr2 = 2 > > > > def AMethod(self): > > pass > > > >and where: > > > >d = Demo() > >a1 = d.attr1 # would actually execute something like: d.attr1.get() > >d.attr2 = 3 # would actually execute something like: d.attr2.set(3) > > > >So, instead of allowing direct access to the instance attributes, C# > >actually executes 'get' and 'set' methods (if defined) for the attributes. > >This lets a programmer change the behavior of the attributes defined in the > >class (to have side-effects for example) without changing any code written > >by users of the class. > > > >Does anyone have any ideas on how to do this (elegantly) in Python? > > Yes: > > class Demo: > def __init__(self): > self.attr1 = 1 > self.attr2 = 2 > > def getAttr1(self): return self.attr1 > def setAttr1(self, v): self.attr1 = v > > def getAttr2(self): return self.attr2 > def setAttr2(self, v): self.attr2 = v > > What's so hard about that? > I think the intention was to hide the mechanism under standard assignment, as (for example) Delphi allows you to do for Pascal. In that way it appears you are assigning to/from properties, but the language actually invokes the appropriate logic (which can do much more than read or set a variable) automagically. regards sTEVE From pearu at cens.ioc.ee Mon Jun 18 14:42:58 2001 From: pearu at cens.ioc.ee (Pearu Peterson) Date: Mon, 18 Jun 2001 20:42:58 +0200 Subject: getting a reference to a class inside its definition In-Reply-To: <9noX6.14930$uR5.1138042@news20.bellglobal.com> References: <9noX6.14930$uR5.1138042@news20.bellglobal.com> Message-ID: On Mon, 18 Jun 2001, dan wrote: > class SomeClass: > pass > SomeClass.clsref = SomeClass If it will be used as >>> SomeClass().clsref then it is equivalent to >>> SomeClass().__class__ So, why would you want .clsref attribute if .__class__ is available already? Pearu From Tom_Good1 at excite.com Mon Jun 25 17:58:58 2001 From: Tom_Good1 at excite.com (Tom Good) Date: 25 Jun 2001 14:58:58 -0700 Subject: How useful do you find the interactive interpreter? References: <4688f24b.0106231658.43d2c446@posting.google.com> Message-ID: slaytanic_killer at disinfo.net (slaytanic killer) wrote in message news:<4688f24b.0106231658.43d2c446 at posting.google.com>... > Hi, > > I am looking at Python seriously, and I can see that the interpreter > would be really good for testing out ideas. Getting small things to > work and then switching over to a text editor to generalize what I've > learned. Is this how people generally use it? Or is it an even > deeper part of coding? > > Thanks. I use it all the time for developing ideas and for interactive testing of objects. I do interactive testing/experimenting a lot from the interactive shell, like this: import foo foo.someFunction(improvisedTestData) [see that it didn't do what I expected, go edit foo.py] reload(foo) foo.someFunction(improvisedTestData) [now it works] Only trouble is, then when I switch back to Java or C++, I tend to edit my code, *forget* to recompile it, then run it and wonder why nothing changed :-) Tom From qrczak at knm.org.pl Sat Jun 16 17:42:34 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 16 Jun 2001 21:42:34 GMT Subject: Any other Python flaws? References: Message-ID: 15 Jun 01 09:32:06 GMT, Mattias Engdeg?rd pisze: > except that it doesn't do it properly - you still cannot assign to a > variable bound in a surrounding scope, something you can do in *all* > other languages supporting nested scopes. Except those which don't assign to names at all, like OCaml or Haskell. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From carlf at panix.com Sat Jun 30 22:42:59 2001 From: carlf at panix.com (Carl Fink) Date: 1 Jul 2001 02:42:59 GMT Subject: any books for python for downloading? References: <993939668.727430@athnrd02.forthnet.gr> Message-ID: In article <993939668.727430 at athnrd02.forthnet.gr>, whats_really_hot wrote: > so, are there..........give me a feedback and some help(how about some URL's > with books for downloading) for learning Python...... I could, but instead why don't you follow the links at www.python.org? I recommend the tutorial there. You also should look for _Dive Into Python_. -- Carl Fink carlf at dm.net From gmullerNoSpam at worldonline.nl Sat Jun 30 17:11:10 2001 From: gmullerNoSpam at worldonline.nl (GerritM) Date: Sat, 30 Jun 2001 23:11:10 +0200 Subject: Python for air traffic control? References: Message-ID: <9hlfbn$6ok$1@nereid.worldonline.nl> Safety is first of all a determined by the quality of the design and secondly by the engineering skills of the developers. Most errors found during the developement lifecycle have little relationship with type checking or prototyping. Instead semantic errors and missing design aspects (such as performance, exception handling, concurrency etcetera) are the majority of errors. The use of a clear and expressive language, such as Python, will help to decrease this category of errors. However, keep in mind that the quality of the architects and engineers is an absolute must for this type of application! Regards Gerrit -- www.extra.research.philips.com/natlab/sysarch "Russ" <18k11tm001 at sneakemail.com> schreef in bericht news:bebbba07.0106291642.6c799d15 at posting.google.com... > I am thinking about using Python for a unique safety-critical > application in air traffic control. It will monitor a few hundred > aircraft for conformance to assigned trajectories, and it will > initiate an automatic alarm (for both controller and pilot) if an > aircraft deviates from its assigned trajectory and is in danger of a > collision. (The trajectory and tracking data will come from existing > C/C++ programs.) The software must be as simple, clean, and robust as > humanly possible. The default languages here are C/C++, but I am > toying with the idea of using Python instead. However, I am a bit > nervous about the lack of type checking and function prototyping, > among other issues. Is Python up to this task? Thanks for your > insights. From aleaxit at yahoo.com Thu Jun 14 15:43:08 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 21:43:08 +0200 Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> Message-ID: <9gb41r0s6p@enews1.newsguy.com> "David LeBlanc" wrote in message news:9gao5s$8ft$7 at 216.39.170.247... > One thing that bugs me about Python is that there's no really good way to > have named constants so that magic numbers can be avoided. Assigning to a > variable that (should) never changes is not the same (i.e. the "should > never" part). It's pretty easy to ensure that an exception is raised when an attribute of a given module is re-bound -- all it takes is for that module to NOT be a module, but rather an instance. Put in const.py...: :: start class ConstError(TypeError): pass class _const: def __setattr__(self,name,value): if self.__dict__.has_key(name): raise ConstError, "Can't rebind const(%s)"%name self.__dict__[name]=value import sys sys.modules[__name__]=_const() sys.modules[__name__].ConstError = ConstError :: finis That's it. Now any module can: import const and names can be bound ONCE in const: const.magic = 23 but NOT twice: const.magic = 42 # raises a const.ConstError This doesn't give you an 'alias' that's actually an arbitrary string of code, and as written still lets you explicitly del const.magic const.magic = 88 though it would suffice to add __delattr__ to impede that, of course. But I think it's sufficient, anyway. Hmmm, maybe I should add that to the Cookbook... it seems a little-known technique. I think it only works in Python 2.1, btw. [Done -- not approved yet, but it's at http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/65207 and I think it's already generally-visible]. Alex From mwh at python.net Sat Jun 2 08:54:42 2001 From: mwh at python.net (Michael Hudson) Date: 02 Jun 2001 13:54:42 +0100 Subject: Printing getopt.GetoptError message? References: Message-ID: gustafl at algonet.se (Gustaf Liljegren) writes: > I'm trying to print the GetoptError message that I get if I don't use the > try-except construction, but it won't work: > > try: > opts, args = getopt.getopt(sys.argv[1:], "c:d:h:") > except getopt.GetoptError: > print getopt.GetoptError.msg > sys.exit(2) > > All I get is an empty string. What is wrong here? You want something more like: try: opts, args = getopt.getopt(sys.argv[1:], "c:d:h:") except getopt.GetoptError, exc: print exc.msg sys.exit(2) HTH, M. -- "The future" has arrived but they forgot to update the docs. -- R. David Murray, 9 May 2000 From mwh at python.net Fri Jun 1 07:44:21 2001 From: mwh at python.net (Michael Hudson) Date: 01 Jun 2001 12:44:21 +0100 Subject: is this a python bug? References: <6564c76c.0105302046.2f24ab47@posting.google.com> Message-ID: paragate at gmx.net (Wolfgang Lipp) writes: > I'm not so sure about what this is I've found. I run the code > snippet below (Py2.1, Win95), and the Python Interpreter blows up. Yep. Here too. > Now, this code does have a few problems It's certainly not the clearest code I've ever seen! Doesn't look like it should dump core, though. Oh, I see what's going on. I think. The problem is that a dictionary gets mutated while it's being printed, and thus there are pointers pointing off into never-never land. I can reproduce this with the rather shorter: class Child: def __init__(self, parent): self.__dict__['parent'] = parent def __getattr__(self, attr): self.parent.a = 1 self.parent.b = 1 self.parent.c = 1 return getattr(self.parent, attr) class Parent: def __init__(self): self.a = Child(self) print Parent().__dict__ I'm *almost* certain this is the same problem you're seeing. It doesn't crash CVS Python, but I think this is more in the details than anything; this sort of thing depends on eg. the order of items in the dictionaries internal vector and that's changed recently. Yep; this one crashes CVS: class Child: def __init__(self, parent): self.__dict__['parent'] = parent def __getattr__(self, attr): self.parent.a = 1 self.parent.b = 1 self.parent.c = 1 self.parent.d = 1 self.parent.e = 1 self.parent.f = 1 self.parent.g = 1 self.parent.h = 1 self.parent.i = 1 return getattr(self.parent, attr) class Parent: def __init__(self): self.a = Child(self) print Parent().__dict__ I'll get Tim on the case . > The code below is more or less reduced to the max. Don't fight over > the meaningfulness of it; it's but a tiny senseless portion of the > original. That's as may be; but if I was up to this level of __getattr__ hackery, I'd have serious thoughts about the design of my application. > My issue is here: Granted that the code is dumb, should it > (or any code fed to python.exe) be able to blow up the interpreter? No. This is (as code like yours demonstrates) surprisingly hard to achieve, though. Cheers, M. -- "declare"? my bogometer indicates that you're really programming in some other language and trying to force Common Lisp into your mindset. this won't work. -- Erik Naggum, comp.lang.lisp From jurberg at my-deja.com Mon Jun 18 12:49:20 2001 From: jurberg at my-deja.com (John Urberg) Date: 18 Jun 2001 09:49:20 -0700 Subject: Integrating a Python GUI into a PowerBuilder App References: <49624b0b.0106121135.61b6bd6c@posting.google.com> <49624b0b.0106140505.79851658@posting.google.com> <9gahru048k@enews1.newsguy.com> <49624b0b.0106150407.626295ca@posting.google.com> <9gdd1r0pde@enews1.newsguy.com> Message-ID: <49624b0b.0106180849.451a2178@posting.google.com> Alex Martelli wrote: > Yes, but I don't think it directly implements ActiveX controls > with a visual interface (just good ol' plain COM servers). No > problem, of course, since that's exactly what HTML Scriptlets > are for -- letting you make an ActiveX control out of *ANY* > language supporting the ActiveScripting protocol (as Python > does, with the win32all extensions or in the ActivePython > build). People who dislike Internet Explorer just don't really > understand what an INCREDIBLE wealth of reusable COM and > ActiveX stuff it's composed of... more even than Mozilla, and > that *IS* saying something:-). A couple of questions about this approach: - Are all windows controls available for use? - Are there any examples out there of how to do this? Thanks, John Urberg From jestes39 at yahoo.com Thu Jun 28 09:26:46 2001 From: jestes39 at yahoo.com (jestes39 at yahoo.com) Date: Thu, 28 Jun 2001 13:26:46 -0000 Subject: Can I pass a cursor to a function? Message-ID: <9hfbam+71gk@eGroups.com> I am trying to figure out whether or not Python will let me pass a cursor variable to a function so that I don't have to create another connection instance to Oracle. Here's the chunk of code: try: dbc = odbc.odbc(conn_str) crsr = dbc.cursor() except: raise database_error while 1: sql = "SELECT DATA, ROWID FROM ;" crsr.execute(sql) records = crsr.fetchall() for record in records: pid = `record`[2:4] rowid = `record`[129:-2] row_flag = 'TRUE' if row_flag == 'TRUE': if pid == 'RE': receipt_flag = 'TRUE' receipt_mod.receipt(crsr,record) else: time.sleep(5) I set data up so that both if statements evaluate to true, the flag is set, and the receipt function is invoked. I get this error if I try to pass dbc or crsr: Traceback (most recent call last): File "C:\proc_mgr.py", line 33, in ? receipt_mod.receipt(crsr,record) AttributeError: receipt If I just pass the record variable, things work fine. Is there a way that I can pass crsr that I am not seeing or can I make it global and use it in the function that way? Any help or suggestions will be appreciated. Thanks. Jason From michael at damaru.com Mon Jun 4 10:46:34 2001 From: michael at damaru.com (Michael Davis) Date: Mon, 04 Jun 2001 14:46:34 GMT Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> Message-ID: <3B1BA00A.398E905B@damaru.com> Harald Hanche-Olsen wrote: > > + Tim Churches : > > | No experience (I am in a similar situation to you wrt UML), just > | some advice: don't buy the O'Reilly book 'UML in a Nutshell' - it is > | the only O'Reilly title I have encountered which is truly woeful > | (most are quite good). > > Hmm. Has it occured to you that this might be a reflection on UML > rather than on the book per se? Personally, I like UML and dislike the Nutshell book. But I worked with a colleague for a few years who hated UML. He hated it because some of the symbols seem arbitrary and meaningless, and hard to remember. I don't mind that so much, but when I try to remember whether a closed diamond on the end of an association line means "contains by reference" or "object containment", I can't easily find the answer in the Nutshell book. It lacks a quick guide to the notation, which is a serious flaw. The 'Distilled' book is okay. I haven't yet come across a truly great book on UML yet. Regards, -- Michael Davis Damaru Custom Programming - Web Development - Database Design http://www.damaru.com 416-540-1284 From xyzmats at laplaza.org Fri Jun 8 18:38:43 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Fri, 08 Jun 2001 22:38:43 GMT Subject: Interesting speed benchmark References: Message-ID: <3b2153b5.26078699@news.laplaza.org> On Tue, 5 Jun 2001 22:32:21 -0500 (CDT), Glyph Lefkowitz wrote: > >On Tue, 5 Jun 2001, Pete Shinners wrote: > >> "Mahesh Padmanabhan" wrote >> > in which the author does some (by his own admission) subjective >> > benchmarks between java and python. While most of it is usual >> > stuff, the one test that stood out was the following: > >Well, that's me. > >I suppose my little ranting essay has gone beyond its original intention. >I've been getting lots of email about it this week in particular, and this >post just underscores the need to rewrite it ;). > >If you're interested, please email me suggestions as to how I can re-do >the comparison. I think that the performance numbers are a bit contrived >and might not be a good approach to it, but I'd like to be heavy on code >examples and quantitative data, if possible. > >> it's still a whole lot slower than the java version :[ > >I am still curious as to why this is. It's not been an issue for me yet >(the one thing in Python that's irked me a little bit is the allocation >overhead for method calls, but even that hasn't been a serious problem), >but it seems odd that it should take so long. Curious if anyone's tried this with the new object allocator available with Python 2.1 (you have to rebuild with --with-pymalloc which I've never gotten around to doing). Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From jcopella at cfl.rr.com Wed Jun 13 12:22:38 2001 From: jcopella at cfl.rr.com (John Copella) Date: Wed, 13 Jun 2001 16:22:38 GMT Subject: How to tell if interpreter is in interactive mode References: Message-ID: Thanks for your suggestions folks. Basically what I have is a module that I want to have print some identifying information when it is imported, but only during interactive sessions -- if the user imports the module from a script I don't want to clutter the tty with this stuff when the script runs. I hadn't thought about the IDE aspect as I use the command line for my work, but it's something to consider. Either way, I'm a little surprised this isn't easier to determine. Michael Hudson wrote in message news:m3iti0wl90.fsf at atrus.jesus.cam.ac.uk... > "John Copella" writes: > > > I have some code in a module that I need to run only when the > > interpreter is running interactively. Is there any way to test for > > this at run time? > > There's a C global (Py_InteractiveFlag or somesuch), but I don't think > it's exposed to Python. > > > I have looked at sys.stdin.isatty(), but this returns 1 when running > > non-interactively as well (unless you do something odd like redirect > > stdin to /dev/null). > > Well, yes, seeing as sys.stdin is still connected to a tty... > > Are you sure you want to do this? If the user's using idle or my > pyrepl or something similar, then Python isn't running interactively > from its point of view, but is from the user's. > > Cheers, > M. > > -- > FORD: Just pust the fish in your ear, come on, it's only a > little one. > ARTHUR: Uuuuuuuuggh! > -- The Hitch-Hikers Guide to the Galaxy, Episode 1 > From rumjuggler at cryptarchy.org Wed Jun 20 14:13:09 2001 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Wed, 20 Jun 2001 18:13:09 GMT Subject: PEP 255: Simple Generators References: Message-ID: <24q1jt8qrbrfrguub5hofsfno0l26qredt@4ax.com> On Tue, 19 Jun 2001 20:19:29 -0400, "Tim Peters" wrote: >The title of the PEP is "Simple Generators", and the adjective is important: >these will never make it in if they explode anyone's head, and this isn't >meant to be esoteric wizard stuff but useful to everyday programmers. Wouldn't it be just as useful, or possibly more, if the generators allowed brain explosion for those who wanted it, but could still be used simply by those who didn't? Is it necessarily the case that adding the capability for more complex use removes the possibility of ordinary use? -- Barnabas T. Rumjuggler Yet when he came down from the mountain, he had not gained any wisdom. In no way had he been able to solve the riddle of this story. And he had lost his faith. But he had discovered that he had an affinity for Dixieland music. -- Joe Frank, "The Road to Calvary" From aleaxit at yahoo.com Fri Jun 15 05:53:39 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 15 Jun 2001 11:53:39 +0200 Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> Message-ID: <9gclvm02tte@enews1.newsguy.com> "David LeBlanc" wrote in message news:9gbsdv$8ft$9 at 216.39.170.247... ... > alias where (argument) substition is done! At least conceptually the body > of a function replaces it at invocation time.) Fortunately ***NOT***!!! Such a horrible "conceptual" choice for a function-execution model would put pay to any chance of *RECURSION*. > read so nicely to be able to say "if something is true" rather then "if > something is not 0" (saves on typing too :-)). Such "read so nicely" tests would of course not work as expected (with or without alias). The object None, for example, evaluates as false, but if you test its identity with 0, you will of course find they're not *identical* (how COULD they be -- they're different in every respect, the ONLY thing they have in common is evaluating as false!). It seems to me that the LAST thing we need is encouraging "read so nicely" forms that do NOT do what a naive newbie might expect. It is absolutely fundamental that the newbie learns to write his/her logical tests as: if something: ... and if not something: ... and *NOT* if something is 1: ... or if something is 0: ... or any "aliases" of these flawed forms. > Other suggestions to import large libraries or make modules instances are > not things calculated to gladden the heart of a newbie who seeks > simplicity, The module-instance (the const.py example I gave) would of course be made by a NON-newbie, the newbie would just USE it. Why would "a newbie who seeks simplicity" consider: const.magic = 23 less simple than alias magic : 23 ?!?! The former uses exactly the same syntax as any other binding, requiring the newbie to learn absolutely no new syntax. The latter requires the newbie to learn one more "simple keyword-statement", with a syntax totally different from that of all OTHER simple keyword statements. It seems to me that your claim that all of the extra conceptual and syntactical baggage FAVOURS simplicity, when common sense suggests extra baggage REDUCES simplicity, is an extraordinary claim, and thereby requires extraordinary proof. > nor would the code enlargement (my aren't I diplomatic ;)) > win the approval of an experienced developer who doesn't want to search > exteraneous lines when a bug pops up - which is statistically more likely What "code enlargement" are you talking about? Which "exteraneous" (?) lines? In a script using "module const" there may or may not be a single line import const for explicitness (the alternative is having it performed implicitly at startup, e.g. by sitecustomize.py &c &c, placing const in the __builtin__ module, of course). That's up to the "experienced developer" who decides constants are necessary at his/her site. > with more lines of code, not to mention the antics needed to do something > that should be as simple as possible (imho). What "antics"? If you want 'const' to be activated by default in every Python installation (e.g. in site.py), write a PEP proposing just that. You DO realize, of course, that no matter what little chance such a PEP may have, it IS going to be at least a thousand times more likely to be adopted than anything that will introduce a new keyword and thereby break perfectly working code -- that's something that can *possibly* happen only for really momentous developments (such as the new proposed "yield" keyword-statement for generators) which DESPERATELY NEED a new statement (can't POSSIBLY work halfway-decently without). > One can certainly argue that this is syntactical sugar. It does however > serve a multitude of good purposes among which are: maintainability; > clarity; consistancy; correctness; good programming habbits; - a not > inconsiderable set of advantages for a little sugar. I fail to see ANY of these advantages when comparing your "alias" with a "const" module installed by site.py. How is alias magic : 23 more maintainable, clearer, more consistent, more correct, or a better programming habit than const.magic = 23 ?!?! Please bring SOME kind of argument for such extraordinary assertions... your bald statements are not "support" for them! > Finally, this wouldn't break any code, Puh-LEEZE. *ANY* use of 'alias' in existing code would be broken. Let's not make such obviously-false assertions... Alex From parywu at seed.net.tw Sun Jun 10 14:29:47 2001 From: parywu at seed.net.tw (jainweiwu) Date: Mon, 11 Jun 2001 02:29:47 +0800 Subject: list-display semantics? Message-ID: <9g0dhl$if1$1@news.nsysu.edu.tw> Hi all: I tried the one-line command in a interaction mode: [x for x in [1, 2, 3], y for y in [4, 5, 6]] and the result surprised me, that is: [[1,2,3],[1,2,3],[1,2,3],9,9,9] Who can explain the behavior? Since I expected the result should be: [[1,4],[1,5],[1,6],[2,4],...] -- Pary All Rough Yet. parywu at seed.net.tw From SBrunning at trisystems.co.uk Tue Jun 12 04:25:19 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Tue, 12 Jun 2001 09:25:19 +0100 Subject: PEP 259: Omit printing newline after newline Message-ID: <31575A892FF6D1118F5800600846864D78BD25@intrepid> > From: Guido van Rossum [SMTP:guido at digicool.com] > In order to avoid having to add yet another magic variable to file > objects, I propose to give the existing 'softspace' variable an > extra meaning: a negative value will mean "the last data written > ended in a newline so no space *or* newline is required." Better another magic variable than a magic value for an old one, I think. Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From ncroglio at altavista.com Thu Jun 28 16:50:52 2001 From: ncroglio at altavista.com (ncroglio at altavista.com) Date: Thu, 28 Jun 2001 20:50:52 -0000 Subject: RSPython or R - S interface Message-ID: <9hg5bc+cdan@eGroups.com> Is the RSPython interface supposed to work with Windows? In only found a tar file, so I had to make some modifications to install it. It is not working either from R to Python or vis versa. Can anyone point me to some help other than that on the http://www.omegahat.org/RSPython/ or give me advise? Thanks From mwright at pro-ns.net Wed Jun 6 16:37:11 2001 From: mwright at pro-ns.net (Mark Wright) Date: 6 Jun 2001 13:37:11 -0700 Subject: How do I return binary data from a python CGI called from CGIHTTPServer? References: <9f96kb01mq8@enews1.newsguy.com> <6c8b7eb9.0106061043.57104307@posting.google.com> Message-ID: dirck at pacbell.net (Dirck Blaskey) wrote in message news:<6c8b7eb9.0106061043.57104307 at posting.google.com>... > "Alex Martelli" wrote in message news:<9f96kb01mq8 at enews1.newsguy.com>... > > "Mark Wright" wrote in message > > news:f9ff3f62.0106011427.6243e5e9 at posting.google.com... > > ... > > > But my original problem/question remains: how does a CGI program > > > return binary data on windows? Is it even possible? The problem is > > > > python.exe must be run with option -u, to have binary standard input > > and output streams, rather than text ones as it has by default. > > In order to send or receive binary files from Python CGIs under IIS > (and Xitami) under Win32, I had to do the following in the scripts, > instead of using the -u option: > > try: > import msvcrt > msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) > msvcrt.setmode(sys.stdout.fileno(),os.O_BINARY) > except: > pass > > The -u option broke something in cgi.py, I don't remember what. Perfect. This is exactly what I was looking for. And it has the added benefit of allowing me to print headers using single '\n' and then switching the mode to binary when I print the binary page content. Contrary to a prior post, there is no bug in popen, just one in the documentation. Although the .hlp file doesn't say so, like open(), popen()'s 2nd argument can include the 'b' attribute to indicate that a binary input stream is being opened. If 'b' isn't specified, then the calling process will not see any data past the ctrl-z. It's not enough to call python with the '-u' directive (or set the mode as above). If you popen a process in python, you must use 'rb' rather than 'r' if your client returns a ctrl-z. This is why CGIHTTPServer is truncating the data at the ctrl-z - it used popen(filename, 'r') rather than popen(filename, 'rb'). It seems to me that this should be changed in CGIHTTPServer. Mark From akuchlin at mems-exchange.org Wed Jun 20 09:54:47 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 20 Jun 2001 09:54:47 -0400 Subject: Curses question References: <1462444.zMo0RvPX7a@mysiu-pysiu> <3d7kyff75v.fsf@ute.cnri.reston.va.us> <3B2A3007.7EB3A68F@ak-studio.com.pl> Message-ID: <3dithrdzo8.fsf@ute.cnri.reston.va.us> Piotr Waskiewicz writes: > But I can't find any info about this method, and xxx.resize.__doc__ > returns None :( Can you point me to any info about this method? "Use the ncurses docs and read the source code" is all that I can say. --amk From donn at drizzle.com Wed Jun 27 23:19:53 2001 From: donn at drizzle.com (Donn Cave) Date: Thu, 28 Jun 2001 03:19:53 -0000 Subject: Python on BeOS References: <9hb0ib$d4i6k$1@ID-22517.news.dfncis.de> <993619377.780885@yabetcha.drizzle.com> <9hc16t$d3o67$1@ID-22517.news.dfncis.de> Message-ID: <993698391.267169@yabetcha.drizzle.com> Quoth "Harvest T. Moon" : | "Donn Cave" schrieb |> Bethon is not a GUI module, and it sure is thread-safe, but indeed |> it is wrappers for the native BeOS API. What did you do, that led |> you to think it was not thread-safe? | | hum, maybe it's my way to work with threads. but i.e. in a listbox: | everytime i tried to insert an item to it from some other thread than the | mainthread the application crashes. i'll look up the code and post it later | the day :) Say no more. If I am right about what you're doing, I can reproduce the crash - in Python, or in C++. Before you modify data structures associated with a thread, you have to lock it. Here, that means you must invoke the Lock() function of the BWindow that draws the BListView, then call BListView::AddItem(), and then BWindow::Unlock(). Or, I really strongly prefer to post a message to the BWindow's message dispatching loop. Both the window and the view have message handlers and can receive the message, depending on your preference. It can be awkward in a way, but as your program gets larger and more complex this technique doesn't get any harder to deal with, whereas the perils of locking grow to the point of certain disaster. What if a function invoked from the window's message dispatch loop eventually calls the function that adds the list item? Lock() will hang forever. To call a function with non-trivial arguments, you can set the data aside somewhere and let the other thread come and get it; here, interlocking is safe and desirable. To get a more synchronous execution model, than the default, you can supply a reply message in BMessenger::Send(). Donn Cave, donn at drizzle.com From rnd at onego.ru Mon Jun 18 09:42:14 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 18 Jun 2001 17:42:14 +0400 (MSD) Subject: Loading select queries into objects In-Reply-To: Message-ID: On Mon, 18 Jun 2001, Graham Ashton wrote: >Hi. I've just started playing with database access from Python and have >stumbled across yet another hole in my knowledge of Python idioms. > >I've got a class that has an attribute for each column in a database >table, and an accessor method that sets the value of each attribute. I >then populate the attributes with the result of a database query. > >Here's an example: > > query = """ > SELECT column1, column2, some_column > FROM a_table > """ > > cursor = self.db.cursor() > cursor.execute(query) > tup = cursor.fetchone() > > self.column1(tup[0]) # this could be better! > self.column2(tup[1]) > self.some_column(tup[2]) > >What I'm wondering is; is there an idiomatic way of applying the values >in a tuple to a list of functions? In Perl I'd use map(), but I'm not >sure if there's a "cleaner" way in Python. map(apply, functions, values) ? Like in: >>> map(apply, [int, str, string.lower], [["123"], ["abc"], ["Abc"]]) [123, 'abc', 'abc'] >When the number of columns grows large the above is not only ugly, but a >nightmare to maintain. > >Thanks. > Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Monday, June 18, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Nostalgia isn't what it used to be." _/ From bs1535 at sbc.com Wed Jun 13 11:16:33 2001 From: bs1535 at sbc.com (SNYDER, BARRON F. (AIT)) Date: Wed, 13 Jun 2001 11:16:33 -0400 Subject: [wxPython] Help with wxChoice! Message-ID: <35BD410BA148D411A7ED00508BCFFBDA05CB29D2@msgil65170u05.nbk2305.il.ameritech.com> Thanks for you reply! Actually I just wanted to be sure that I was using the correct syntax. Since the wxWindows docs are geared towards C programming, I wasn't sure if the dot notation I am using is correct. But since you ask , I'm actually trying to append to a wxChoice control that was laid out using wxDesigner. Since the widget code is automatically generated from wxDesigner, I have to get the handle of the specific widget I want by using wxPyTypeCast. class ABCForm(wxMDIChildFrame): def __init__(self, parent, id, title = "ABC Form", pos = wxPyDefaultPosition, size = wxPyDefaultSize, style = wxDEFAULT_FRAME_STYLE): wxMDIChildFrame.__init__(self, parent, id, title, pos, size, style) ABCFormGUI( self, true ) val = self.GetOriginatorSalescode() val.Append("ABC123") def GetOriginatorSalescode(self): return wxPyTypeCast( self.FindWindowById(ID_ORIGINATOR_SALESCODE), "wxChoice" ) -----Original Message----- From: David Bolen [mailto:db3l at fitlinxx.com] Sent: Tuesday, June 12, 2001 6:19 PM To: python-list at python.org Subject: Re: [wxPython] Help with wxChoice! "SNYDER, BARRON F. (AIT)" writes: > That is what I'm doing and I don't get an error but the new value isn't > being appended either. > > Any help is appreciated! Could you perhaps post a snippet of the actual code being used and what version of wxPython you are using? I just tried 'Append'ing to a choice control on my system and it seems to be working fine (wxPython 2.2.1 with either Python 1.5.2 or 2.0) -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ -- From tim.one at home.com Sun Jun 10 15:45:24 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 10 Jun 2001 15:45:24 -0400 Subject: list-display semantics? In-Reply-To: <9g0dhl$if1$1@news.nsysu.edu.tw> Message-ID: [jainweiwu] > I tried the one-line command in a interaction mode: > > [x for x in [1, 2, 3], y for y in [4, 5, 6]] > > and the result surprised me, that is: > > [[1,2,3],[1,2,3],[1,2,3],9,9,9] > > Who can explain the behavior? > > Since I expected the result should be: > > [[1,4],[1,5],[1,6],[2,4],...] It's "a feature", but a bad one, and I opened a bug report on it: The problem is that your original got parsed as: [x for x in ([1, 2, 3], y) for y in [4, 5, 6]] ^ ^ which is roughly equivalent to: temp = [] for x in ([1, 2, 3], y): for y in [4, 5, 6]: temp.append(x) That interpretation of the comma is surprising in context, and I expect Python will change to disallow it. To get the effect you want: >>> [[x, y] for x in [1, 2, 3] for y in [4, 5, 6]] [[1, 4], [1, 5], [1, 6], [2, 4], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6]] >>> From jeff at ccvcorp.com Fri Jun 22 16:56:02 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Fri, 22 Jun 2001 13:56:02 -0700 Subject: Another Wart! string.find() [ was: namespace issue? ] References: Message-ID: <3B33B0E2.867053FE@ccvcorp.com> Michael Powe wrote: > >>>>> "Steven" == Steven D Majewski writes: > > Steven> ( But I can't really think of a good reason for > Steven> string.find to return -1 *except* that it wouldn't > Steven> surprise a C programmer. ) > > Well, if we had boolean values, it could just return false! I wonder > what percentage of the time string.find() is used just as I was using > it, to check for the existence of a substring rather than actually > doing something with it when found. Maybe, we just need the python > equivalent of strchr() in C (returns a pointer or NULL, i.e., true or > false). > > mp Except that, even if string.find() returned None (false), it still wouldn't work: s = "spam" sub = "sp" if string.find(s, sub): dospam() In this case, dospam() never executes, even though our substring *is* found. While you *could* explicitly test if string.find(s, sub) is not None: I don't see this as being really any better than if string.find(s, sub) >= 0: or if string.find(s, sub) == -1 In other words, it is possible for a valid positive return from string.find() to still evaluate to a boolean false... so the idiom that you would like to use is not going to work, without doing away with 0-based indexing. And that would be a really bad idea, even discounting how much code it would break. (Alex Martelli has explained in great detail why not too long ago--search google for "0-based index" or "half-open ranges" for more details) Jeff Shannon Technician/Programmer Credit International From opengeometry at yahoo.ca Sun Jun 17 13:58:22 2001 From: opengeometry at yahoo.ca (William Park) Date: Sun, 17 Jun 2001 13:58:22 -0400 Subject: list.sort() In-Reply-To: <3B2CEBF1.CCF5377D@hack.org>; from bos@hack.org on Sun, Jun 17, 2001 at 07:42:09PM +0200 References: <3B2CEBF1.CCF5377D@hack.org> Message-ID: <20010617135822.A1032@node0.opengeometry.ca> On Sun, Jun 17, 2001 at 07:42:09PM +0200, Rikard Bosnjakovic wrote: > >>> l = l.sort() > >>> l > >>> print l > None > > If we split the problem into parts, "l.sort()" sorts l and it becomes > [2,3,4]. I expected it to be [2,3,4] after assigning it to itself (after > it got sorted), but the list seem to got deleted instead. I don't like > this behaviour, at all. 'l.sort()' returns 'None', and you are assigning this 'None' back to 'l'. Instead, try >>> l.sort() >>> print l > Why does Python behave like this? Why does sort() change lists > _in-place_, instead of returning a list? Efficiency. -- William Park, Open Geometry Consulting, 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From missive at hotmail.com Fri Jun 1 12:01:25 2001 From: missive at hotmail.com (Lee Harr) Date: Fri, 1 Jun 2001 16:01:25 +0000 (UTC) Subject: Zope questions and comments (&Tkinter???) References: <3B158C50.887E3D59@earthlink.net> Message-ID: On Fri, 01 Jun 2001 00:01:39 GMT, Ron Stephens wrote: Zope is cool. I am using it an environment where I want to easily be able to delegate control of different areas to many different people, and my feeling is that Zope is the best way to accomplish that. Zope can be quite complicated and confusing at times. I find that my understanding comes in levels, and that the farther I progress, the more I like Zope. That said, if you are wanting to run a very simple system and be the only one making updates to the website, and learn the whole thing in a weekend, Zope probably is not the way to go. From greg at cosc.canterbury.ac.nz Wed Jun 6 01:34:28 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 06 Jun 2001 17:34:28 +1200 Subject: Obsolesence of <> (fwd) References: <9f6el30dv5@enews2.newsguy.com> <3B16D681.E12A4554@Lugoj.Com> <9f7pmt029se@enews1.newsguy.com> <3B17D9B9.E3CA8EC8@Lugoj.Com> <9fjgjl$rp0$1@brokaw.wa.com> Message-ID: <3B1DC0E4.125CF8B@cosc.canterbury.ac.nz> Nick Perkins wrote: > > When two mathematicians > exchange e-mail, how do they write a formula that would otherwise use such > 'mathematical notation'? TeX? -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From qrczak at knm.org.pl Wed Jun 20 10:58:48 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 20 Jun 2001 14:58:48 GMT Subject: PEP 255: Simple Generators References: Message-ID: 19 Jun 2001 23:55:26 +0200, Denys Duchier pisze: > The one thing that rubs me the wrong way with this proposal is that it > is not compositional. Unless I misread the PEP, the entire generation > logic must be defined in a single function (because the `yield' > keyword must statically occur within the body of the generator > function). This makes it impossible to use higher-order programming > to assemble complex generators from smaller blocks. Isn't for x in g(): yield x a way to compose generators? What more do you want? -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From gurnavage at agere.com Thu Jun 21 10:19:27 2001 From: gurnavage at agere.com (Jim Gurnavage) Date: Thu, 21 Jun 2001 10:19:27 -0400 Subject: ActivePython 2.1.0 build 211 References: Message-ID: <3B32026F.89DB4FD7@agere.com> Paul, I believe there is a problem with the win32commc.pyd (DLL) in the 211 build for Windows 98. (Disclaimer: I am a totally newbie, with roughly 12 hours of Python experience; so this may all be naivet?!). According to DependancyWalker (http://www.dependencywalker.com/) the DLL file win32commc.pyd is looking for a system file called python15.dll. I think it should be looking for python21.dll. To reproduce the problem, run the following code sample. The "import win32comm" will attempt to load win32commc.pyd and fail with the following error: ======== PythonWin output start ========== PythonWin 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32. Portions Copyright 1994-2001 Mark Hammond (MarkH at ActiveState.com) - see 'Help/About PythonWin' for further copyright information. Traceback (most recent call last): File "c:\python21\pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript exec codeObject in __main__.__dict__ File "C:\_mywork\python\commtest\JUNK.PY", line 3, in ? import win32comm File "c:\python21\lib\win32comm.py", line 1043, in ? import win32commc ImportError: DLL load failed: One of the library files needed to run this application cannot be found. >>> ====== end PythonWin output ============= #------- import sys import win32comm # ============================================================ # Test code. # ============================================================ def _test_(): print "Hello!" # ============================================================ if __name__ == '__main__': _test_() ## end of file Thanks for any help. Jim -------------- next part -------------- A non-text attachment was scrubbed... Name: gurnavage.vcf Type: text/x-vcard Size: 276 bytes Desc: Card for Jim Gurnavage URL: From glyph at twistedmatrix.com Thu Jun 28 22:39:50 2001 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: Thu, 28 Jun 2001 21:39:50 -0500 (CDT) Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: On Sun, 24 Jun 2001, Tim Peters wrote: > [Glyph Lefkowitz] > > If python's answer to "what should we do with new feature X"? is > > "add a keyword" it will turn into Perl before too long. > > Since that's very rarely Python's answer, this is slippery-slope FUD shouted > from a flat plane. My point is that 'yield' is a keyword, and that new keywords are bad. Although there has been a Pronouncement on this :) I still disagree with it; it would not require a keyword addition if creating a generator were something like import generator def _genfunc(): for i in range(100): generator.yield(i) gen = generator.create(_genfunc) But again, given that there's been a pronouncement, this is just rearranging the deck chairs on the titanic, so I'll be quiet now :). > Generators are much simpler and often suffice. Point taken. Upon reflecting, 'for' does not preclude the inclusion of 'while' loops; for myself, I really can't see generators as anything but an aberrant special case of coroutines, but the fact that the language treats them differently doesn't necessarily mean they'll be broken. And it does seem that many others see them as independantly useful. > > (or should we have syntax for that too? 'task' anyone?) > > That's something for the microthreads PEP to stake out. You know that > implementing the semantics efficiently in Jython too has been a severe > impediment to Stackless adoption, right? I know that, but I don't agree with it. Jython can't do even-based I/O, but the 'select' module remains in the Python standard library. The JVM is kinda crappy; if I wanted to be bound to the limitations of Java, there's another language I could program in, thank you very much :) > Generator semantics are simple and synchronous. > ... > For the same reasons, Python would retain "while" loops even if Guido > added a "goto". > The audience for microthreads is enthusiastic but small, and the best > shot it has is to ride in as a generalization of something else. I had been thinking the opposite way... shame on me for doubting the wisdom of guido :) > If you're eager to ignore the *pragmatics* of generators, then I'm > happy to repay the favor wrt microthreads. I'll have to give generators the benefit of the doubt. > Neil's implementation is so elegant it makes me smile -- calling it a > hack is at best in bad taste. > If you looked into it instead of ranting about it, you'd discover that > the things he did to the eval loop are necessary preconditions for > implementing microthreads too -- the ability to suspend a frame in > midstream is fundamental to all these gimmicks. This will be the end > of the path for most, but it takes you closer to your goal. Although I'd read it before, reading it again with this comment in mind (while chanting "refactor, refactor, refactor" to myself in a trancelike state) makes it much clearer to me how such a transformation would be made. And that it would, in fact, be easier to make it from Neil's patches than without them... > Generators aren't becoming central to Python; they're an especially > powerful instance of 2.2's iterator interface (a point you should > consider: generators live in the iterator world, not in the thread > world, and iterators are ubiquitous in all kinds of apps; thread-like > control flow has a much smaller audience, and smaller still if the > "threads" block at synchronous I/O calls, and smaller still again if > they don't act like "real threads" when running in foreign code). Thanks for illustrating this. FWIW, I retract my objections to PEP 255; your description of why it's useful has been very helpful and educational. but-I-still-can't-entirely-forgive-guido-for-print>>-and-lambda-ly y'rs, ______ __ __ _____ _ _ | ____ | \_/ |_____] |_____| |_____| |_____ | | | | @ t w i s t e d m a t r i x . c o m http://twistedmatrix.com/users/glyph From aleaxit at yahoo.com Thu Jun 7 05:19:50 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 7 Jun 2001 11:19:50 +0200 Subject: Why should i use python if i can use java References: Message-ID: <9fngvl011jg@enews2.newsguy.com> "Glyph Lefkowitz" wrote in message news:mailman.991892413.1443.python-list at python.org... > > On 6 Jun 2001, Chris Goringe wrote: > > !snip! > > > python doesn't [have ...] > > strong typing (love it or hate it...) > > Hate it :) What _I_ hate is the confusion between weak vs strong typing AND static vs dynamic typechecks, though it's a classic one:-). Weak typing, properly, is what (e.g.) Perl has, where you can use any scalar wherever, and it will try to guess what you mean, freely treating strings as numbers, viceversa, etc. What Python has (like, say, Scheme) I'd call strong typing that is dynamically enforced. E.g.: D:\py21>python Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. Alternative ReadLine 1.4 -- Copyright 2001, Chris Gonnerman >>> "ciao"[1.0] Traceback (most recent call last): File "", line 1, in ? TypeError: sequence index must be integer >>> That's *WEAK* typing?! I call it pretty strong indeed -- and love it! (Java works similarly here -- it's an error to use a non-integer as array index -- although C and C++ happily accept the float and truncate it...). It's *DYNAMICALLY* checked and enforced, not statically. I think it's more precise and useful to draw the distinction as static vs dynamic than as strong vs weak, no matter which way one wants to argue for or against it. > > interfaces (ditto) > > Well, python *does* have interfaces, at a much deeper level than Java; you ...but no way to specify them precisely and explicitly (not that Java excels here, since it lacks preconditions and postconditions on interfaces, sigh). Anyway, PEPs 245 and 246 would help a lot with this, I think! > > an elegant way of implementing singletons (or does it? anyone?) > > Aah, the singleton. Global variables for the new millennium. First of > all, the singleton "pattern" is usually a bad idea. If you have a class *AMEN, HALLELUJAH*! This makes two of us sharing this dislike for the Singleton Design Pattern, so I'm not a Singleton any more -- see, that's one typical issue with Singleton DP, what starts out as a singleton often becomes not one:-). > that can "only be instantiated once", then you're dealing with per-process > state, and representing it as a class instance can be misleading. If it's Yes. You may want to use instances because of flexible arrangements you can make regarding all sorts of operations (calls, attribute accesses/bindings, etc etc) through special methods (in Python, at least:-). But separating the two issues is simpler and thus preferable: have the instances (if instances are needed) be freely created, shared, deleted, etc -- it suffices that the instances *DO NOT HAVE SPECIFIC PER-INSTANCE STATE* but 'delegate' all of their state to the "object appearing but once" (a "singleton" by some way to mean this word, but not a singleton Design Pattern:-). > Thankfully, Python provides a much better mechanism for doing so! > "Modules" are actually singletons wearing funny shoes. Any "singleton" > state can be specified as a variable in a module. (Which is usually > declared with the 'global' keyword. Coincidence?) Today you can also have an instance masquerading as a module, as it happens -- delicate, but it does mean you can control attribute setting and getting on a "module"!-) Witness: D:\py21>python Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. Alternative ReadLine 1.4 -- Copyright 2001, Chris Gonnerman >>> class AllAttrStrings: ... def __setattr__(self, name, value): ... if type(value)!=type(''): ... raise TypeError,"Attributes must be strings" ... self.__dict__[name]=value ... >>> import sys >>> sys.modules['AAS']=AllAttrStrings() >>> import AAS >>> AAS.foo='bar' >>> AAS.foo 'bar' >>> AAS.peep=23 Traceback (most recent call last): File "", line 1, in ? File "", line 4, in __setattr__ TypeError: Attributes must be strings >>> The "import AAS" references the instance-object that is masquerading as a module, once the appropriate entry in sys.modules is properly initialized, no matter what other module IS importing AAS. Now, used with care and good taste of course, ISN'T this cool...?!-) > > but most of all, it doesn't have > > > > J2EE > > J2ME > > Actually it does! With Jython, you can access any Java API from Python. > Neat, huh? Absolutely! But does any commercial IDE, as you earlier referenced, support Jython yet? I don't know of any. Alex From tim.one at home.com Fri Jun 29 04:04:08 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 29 Jun 2001 04:04:08 -0400 Subject: functional programming and default parameters In-Reply-To: Message-ID: [Nick Perkins, tries assorted ways to make a list of functions s.t. > fns[0]() -> 0 > fns[1]() -> 1 > fns[2]() -> 2 > etc. but without abusing default arguments] Here's one easy way: >>> from __future__ import nested_scopes >>> def makefunc(i): ... return lambda: i >>> fns = [makefunc(i) for i in range(10)] >>> fns[5]() 5 >>> fns[2]() 2 >>> etc. Without nested scopes, you may have to resort to eval (or exec in fancier contexts): >>> fns = [eval("lambda: %d" % i) for i in range(10)] >>> fns[5]() 5 >>> fns[2]() 2 >> etc. From dsh8290 at rit.edu Fri Jun 1 22:07:54 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 1 Jun 2001 22:07:54 -0400 Subject: Copying files to multiple comp's on a lan In-Reply-To: <16074dce.0106011606.4a7b987d@posting.google.com>; from jeff@ccvcorp.com on Fri, Jun 01, 2001 at 05:06:02PM -0700 References: <9f8k3v$1i04$1@news.cybercity.dk> <16074dce.0106011606.4a7b987d@posting.google.com> Message-ID: <20010601220754.A8321@harmony.cs.rit.edu> On Fri, Jun 01, 2001 at 05:06:02PM -0700, Jeff Shannon wrote: | Hm, I'd probably use the os.system() call in preference to reading the | source and then creating new destination files, as D-Man's example does, | though the choice is probably trivial and entirely personal opinion. There is a bit of technical tradeoff in the choice when using Windows see below. | Example: | | --------------------- | import sys | import os | | # note Win32 uses \, not / :) Yeah, but ... | machines = [ "\\Mach1\C" , "\\Mach2\C" , "\\Mach3\C" ] >>> print machines ['\\Mach1\\C', '\\Mach2\\C', '\\Mach3\\C'] >>> print len( machines[0] ) 8 # wasn't that supposed to be 9? and where'd that extra \ in front of # the C come from? backslashes are rather evil -- they tend to undergo a bit of metamorphosis in various environments... | source_file_path = sys.argv[1] | dest_path = sys.argv[2] | | for machine in machines: | # always use os.path.join() when building paths.... | dest_fullpath = os.path.join(machine, dest_path) | cmd_string = "copy %s %s" % (source_file_path, dest_fullpath) | os.system(cmd_string) Also, make sure that what cmd.exe sees here is what you expected (with backslashes, spaces, etc. I have no philosophical issues with this sort of technique, though I've been bitten by the evil M$ backslashes a few times with my shell scripts (where one script invokes another, and yet another layer of backslash escaping is evaluated away). I once had to label a printer as \\\\\\\\Red1\\\\HPLaserJ (!) //Red1/HPLaserJ works much better :-). If fact the bash script I included used the 'cp' command (the cygwin binary of the unix command, roughly equivalent to copy.exe). On the tutor list Tim Peters enlightened us to one of M$'s deepest secrets -- the win32 API accepts forward slashes as a path delimiter. I was rather relieved to learn that this (often) works from the shell as well (bash, anyways, cmd.exe still tends to not like it). Using forward slashes saves a lot of headaches. -D From beazley at cs.uchicago.edu Wed Jun 20 10:02:58 2001 From: beazley at cs.uchicago.edu (David Beazley) Date: Wed, 20 Jun 2001 09:02:58 -0500 (CDT) Subject: function attributes (ANN: Introducing PLY-1.0 (Python Lex-Yacc)) In-Reply-To: <3B30A64D.EB779804@lemburg.com> References: <3B306425.1BA938BE@lemburg.com> <15152.40380.99624.826511@gargoyle.cs.uchicago.edu> <3B30A64D.EB779804@lemburg.com> Message-ID: <15152.44306.490638.543472@gargoyle.cs.uchicago.edu> M.-A. Lemburg writes: > > > > A fine idea, but the implementation is completely useless because > > there is no syntactically convenient way to attach the > > attributes. > > Ah... so that's what you're after: convenience ! > That, of course, is true. Yep. > So the conclusion should be: how can we make function attribute > assignment more convienent and not why not to use them :-) I'd definitely consider using them if they were syntactically convenient to use. However, I'm mostly at a loss as to how you would actually go about doing that. I suppose you could have something like this: def p_expr_plus(t): .gram = 'expr : expr PLUS expr' ... However, I'm not sure how the community would react such syntax. Cheers, Dave From edcjones at erols.com Mon Jun 25 20:13:48 2001 From: edcjones at erols.com (Edward C. Jones) Date: Mon, 25 Jun 2001 20:13:48 -0400 Subject: Debugging reference count errors; PIL problem Message-ID: <3B37D3BC.5000304@erols.com> I have some Python extensions written in C that have memory leaks. Almost certainly, I am doing something wrong with Py_INCREF or Py_DECREF. Some searching showed that this problem is common and that the solutions are not straightforward. 1. What is currently the easiest way to track down reference count errors? 2. I compiled and installed Python 2.1 with the "--with-pydebug" switch for "configure". Why do even trivial programs leave a large number of unDECREFed objects? Is there any documentation for using the reference count debugging features? 3. I compiled PIL. "import _imaging" fails with the message: ImportError: ./_imaging.so: undefined symbol: Py_InitModule4 What's going on here? Thanks, Ed Jones From emarkp at CSUA.Berkeley.EDU Sat Jun 2 17:19:00 2001 From: emarkp at CSUA.Berkeley.EDU (E. Mark Ping) Date: Sat, 2 Jun 2001 21:19:00 +0000 (UTC) Subject: Why isn't Python king of the hill? References: <9fb5fl$26kf$1@agate.berkeley.edu> <9fb90m01koq@enews2.newsguy.com> Message-ID: <9fbl84$2emf$1@agate.berkeley.edu> In article <9fb90m01koq at enews2.newsguy.com>, Alex Martelli wrote: >It's ONE lazy and error-prone way; another one is not keeping >the possible errors and approximations always in one's mind >(and there are others yet, but those are the main two, I think). Too true, actually. It's more common to simply pretend the issue doesn't exist, from what I've seen. >I do >not personally know anybody (who has done significant numerical >programming) who can claim he has never been guilty of either >while looking at me eye to eye and keeping a straight face (there >must be such people somewhere, I'm sure -- just not in my circle >of real life acquaintances). Granted. We've all been sinners in the past. But that's not the same as *advocating* it. -- Mark Ping emarkp at soda.CSUA.Berkeley.EDU From loewis at informatik.hu-berlin.de Sun Jun 17 16:34:55 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 17 Jun 2001 22:34:55 +0200 Subject: why is there no class (static) methods in Python ? References: <3B2D114E.7B39D954@intraware.com> Message-ID: Richard Gruet writes: > I (and other people on the Python french mail list) wonder why there > are no class (static) methods in Python. You cannot define a really > unbounded (ie to an instance) method within the namespace of a class. First of all, you *can* define such a thing if you absolutely want, see http://www.python.org/doc/FAQ.html#4.84 > It's not natural nor elegant to have to create an instance to call a > method which is not related to a particular instance. We would like to > be able to write things like: > > class C: > def staticFoo(x): print x > > C.staticFoo(1) I'd like to question why you want to do this. Isn't it much better to write class C: pass def staticFoo(x): print x I.e. what has class C to do with staticFoo? Regards, Martin From ullrich at math.okstate.edu Fri Jun 1 15:40:53 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Fri, 01 Jun 2001 19:40:53 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> Message-ID: <3b17ed86.19508127@nntp.sprynet.com> On Fri, 1 Jun 2001 18:16:19 +0200, "Alex Martelli" wrote: >"David C. Ullrich" wrote in message >news:3b17a2f1.411766 at nntp.sprynet.com... > ... >> Could you give us a hint regarding exactly what work >> of Chaitin's shows we can get "truly random" numbers from >> arithmetic algorithms? > >I think his latest book, "Exploring Randomness" published >by Springer-Verlag, is probably 'it'... gotta order it one >of these days (it's been out a month and I yet haven't... >sigh, my sloth's getting worse... to my excuse, the UK >branch of Amazon claims it's not there yet, and Chaitin's >page mentions a Springer-Verlag special offer on all 3 >of his books but Springer-Verlag seem to never have heard >of it, and...). > > >> A physical RNG can have the property that one cannot make >> any prediction about the value of the next bit even given >> _complete_ information about how the numbers are being > >"From impossibilia sequitur quodlibet". *IF* you could >have complete information, *THEN* you could predict all >you want. Problem is, you CANNOT have complete info due >to that Heisenberg fellow, therefore you cannot predict >(precisely). Huh? You cannot have complete information about a _physical_ RNG, which is why you _can_ get "really random" numbers from a physical RNG. But you certainly can have complete information regarding the state of an _arithmetic_ _algorithm_. > From what I know of Chaitin's life work, >it started with just the idea of defining randomness in >terms of minimal amount of information (in bits) you need >for prediction. If YOUR definition of 'randomness' is >something that needs INFINITE number of bits to predict, >go ahead and have fun, but you're unlikely to get some >constructive results out of it. It seems fairly likely that there's a point here, but I don't see what it is. Given an arithmetic algorithm it does _not_ take an infinite number of bits to do any predicting. > Chaitin, Martin-Loef, >and Solovay, do have various definitions that ARE of some >use, and apparently they all turn out to be equivalent >(and "Exploring Randomness" includes, inter alia, proofs >of the equivalence that a layman DOES have a chance to >follow -- I'm told). > >A physical system that is macroscopic enough to escape >Heisenbergian conumdrums There is no such system. > could also be describable in >a finite number of bits, in terms of enabling somebody >to predict the 'next outcome'. That was, if I'm not >mistaken, Laplace's take on probability (and not his >only), all the way up to Einstein's in this century -- >that it's all about hidden variables, information that >we do not happen to have, rather than information that >intrinsically CANNOT be had. I continue to miss your point. See, Einstein was wrong about quantum mechanics (or so the people best qualified to know believe). I forget whose theorem it is (Von Neumann's, I think maybe!) that you _cannot_ describe "classical quantum mechanics" in terms of hidden variables. >Measuring randomness in terms of amount of information >seems like it works nicely. I'm certain it does. I don't see how saying that says anything about VN being wrong with his comment about how arithmetic RNG's cannot be perfect. > More when I _have_ managed >to get and study "Exploring Randomness", if it's not >too far over my head...! > > >Alex > > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From rob at ZOOstation.cc Thu Jun 7 22:31:20 2001 From: rob at ZOOstation.cc (Rob Brown-Bayliss) Date: 08 Jun 2001 14:31:20 +1200 Subject: [pygtk] HTML Widget In-Reply-To: References: Message-ID: <991967480.4503.0.camel@ZOOstation.cc> > Did you get a new version of pygme or recompile the existing copy of pygme > when upgrading mozilla? The mozilla embedding API is not stable, and > changes occasionally (the binary API breaks more often than source API). Yeah, I tried recompiling. The soucre for pygme (in the gnome cvs) has not changed since october though. The best I can get is a grey window in the component. The output in the shell suggests it is working, but not displaying... > > Is ther a binding for gtkhtml? > > There is a gtkhtml binding included with gnome-python. It is not built by > default though. Pass the --enable-gtkhtml switch to configure to build > it. Is there any reason for not building by default? for example stability? Thanks -- Rob Brown-Bayliss ---======o======--- www.ZOOstation.cc From jessw at loop.com Thu Jun 21 15:51:34 2001 From: jessw at loop.com (Jesse W) Date: Thu, 21 Jun 2001 12:51:34 -0700 Subject: ANNOUNCE: The Neophyte Pythoneers List Message-ID: <3B31EDD6.17856.E3EB319@localhost> Dear Pythoneers, (Exactly how should you spell "Pythoneers", anyway?) I have just now created a mailing list via Yahoo for the sharing, joint debugging and general discussion of Python programs. The list is intended to be primarily for those who have not yet reached expert level in Python programming, but experts are also very welcome. You can join by sending a blank email to: neophyte_pythoneers-subscribe at yahoogroups.com Good luck to you all, Jesse Weinstein From boyd at insultant.net Wed Jun 6 06:56:06 2001 From: boyd at insultant.net (Boyd Roberts) Date: Wed, 6 Jun 2001 12:56:06 +0200 Subject: How do I return binary data from a python CGI called from CGIHTTPServer? References: <9f96kb01mq8@enews1.newsguy.com> Message-ID: <9fl2ah$3g3$1@quark.noos.net> "Mark Wright" a ?crit dans le message news: f9ff3f62.0106051130.6e19c22c at posting.google.com... > This works correctly for 0x0a, but it still gets upset about 0x1a - > a.k.a. ctrl-Z, a.k.a. end of file. If there's a ctrl-z in the output > of my CGI script CGIHTTPServer truncates the data. ctrl-z is NOT end of file, except on certain braindamaged systems. it is SUB (substitute). From aleaxit at yahoo.com Sat Jun 2 03:42:34 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 2 Jun 2001 09:42:34 +0200 Subject: Why isn't Python king of the hill? References: Message-ID: <9fa5fi0fru@enews2.newsguy.com> "Grant Edwards" wrote in message news:slrn9hgpmo.jl.grante at tuxtop.visi.com... ... > _never_ expect an exact result and not to use binary floating > point if you require an exact result. > > You may thing that 1.0 + 2.0 == 3.0 ought to be true, but you And it is (on any FP system respecting IEEE 754 -- and any other FP system I've ever heard about). > should always treat floating point operations as if there are > small random numbers being thrown in at every step. So you I think this is exactly what Kahan describes as one of the widespread (and false) myths about floating point. Alex From fredrik at pythonware.com Tue Jun 26 10:13:23 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 26 Jun 2001 14:13:23 GMT Subject: Ascii characters References: <3B386147.79E68C69@wanadoo.be> Message-ID: <7M0_6.4105$e5.767781@newsb.telia.net> Johan Daine wrote: > I am using using swish++ with Zope in a french context. > In orger to filter the user requests, I need to filter accented > characters to the unaccented char. assuming you have 2.0 or later, something like this should work: import unicodedata, string def maketable(): # build iso-latin-1 to "undotted" ascii translation table table = range(256) for i in table: x = unicodedata.decomposition(unichr(i)) if x and x[0] == "0": table[i] = int(x.split()[0], 16) return string.join(map(chr, table), "") text = "...some accented iso-latin-1 text..." noaccents = maketable() undotted_text = string.translate(text, noaccents) hope this helps! From sholden at holdenweb.com Wed Jun 13 07:21:39 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 13 Jun 2001 07:21:39 -0400 Subject: Keyword argument parsing in error in 2.0? References: <9g6c550qrb@drn.newsguy.com> Message-ID: Cool. Two things: a) Erm, who told you that was a decimal number? I definitely remember thinking "that's a HEX number as I wrote it". b) So you mean you won't reply to anything with decimal in it? regards Steve 108 (decimal) -- http://www.holdenweb.com/ "thinkit" wrote in message news:9g6c550qrb at drn.newsguy.com... > i'd consider looking at this, but it contains a decimal number. use hexadecimal > only if you want to be taken seriously. > > In article , "Steve says... > > > >I'm working on a SQL abstraction layer, using methods to generate SQL > >appropriate to a particular database back-end. This has involved using > >keyword arguments to many of the methods. As a catchall (to avoid having to > >handle too much SQL syntax) many methods have a REST keyword argument, which > >is appended to the generated statement. The 2.0 compiler is complaining > >about the following statement: > > > >c.UNION(c.SELECT(["l.beer", "l.drinker", ["count(distinct s.bar)", > >"nbars"]], > > FROM=[["likes", "l"], ["serves", "s"]], > > WHERE="l.beer=s.beer", > > REST="group by l.beer, l.drinker"), > > c.SELECT("distinct beer, drinker, 0 as nbars", > > FROM="likes", > > WHERE="beer not in (%s)" % > > c.SELECT("beer", > > FROM="serves")), > > REST="order by 3 desc") > > > >This validates fine in PythonWin, but when the module containing it is > >executed I get: > > > >Traceback (most recent call last): > > File "alltest.py", line 396, in ? > > REST="order by 3 desc"), > >TypeError: keyword parameter redefined: REST > > > >The implication is clearly that the system is seeing two definitions of the > >same keyword argument, but I have tried to analyze the statement carefully > >and it seems to me that the different REST arguments are being provided to > >different calls. > > > >Just to check, I tried running the following program: > > > >def a(x, y, z, REST="NothingA"): > > return "%s %s %s %s" % (x, y, z, REST) > > > >def b(x, y, z, REST="NothingB"): > > return "%s %s %s %s" % (x, y, z, REST) > > > >print "STARTING" > > > >print a("a", > > b("m", "n", "o", REST="Ignore1"), > > a("s", "t", "u", REST="Ignore2"), > > REST="Ignore3") > > > >This runs fine, printing > > > >STARTING > >a m n o Ignore1 s t u Ignore2 Ignore3 > > > >Is this a bug, or can I simply not see my error for looking too hard? > > > >regards > > Steve > > > > > > > > > From dnew at san.rr.com Sun Jun 3 21:12:32 2001 From: dnew at san.rr.com (Darren New) Date: Mon, 04 Jun 2001 01:12:32 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> <3B1A82DD.C4D78472@san.rr.com> <9fe2g302841@enews2.newsguy.com> Message-ID: <3B1AE07F.CEDA4A3A@san.rr.com> Alex Martelli wrote: > But why should "perfect information" about the dice tell me only > that they're perfect, and not their state? Because "the state" is that they're perfect. I.e., "the state" of a radioactive atom is that it has decayed, or hasn't decayed, and the half-life of the atom. There *is* *no* *state* to tell you when it *will* decay. It's just not there. 100% of the information about the atom is probabilistic. You don't know where it is. You only know that it's *there* with 99.9999% probability. It might not even be there when you look. > That's like saying that > "perfect information" about an algorithm tells me only it's a good > one, and gives me no information about the state it starts in. No, it's not. I'm not sure why you assert this. An algorithm is a mathematical concept, and hence fully defined. > > > I still haven't heard your definition of > > > 'perfect' randomness, for example. > > > > Generally, this is something along the lines of: > > Given all available information about the mechanism used to generate the > > "available" seems to play a rather crucial role here, then. No. "available" means "possible to be obtained in any way." What you seem to be missing is that in the world of quantum physics, the information just plain isn't there. You can go so far as to measure the fact that it isn't there. > > bits, and an arbitrarily long sequence of generated bits, it's > > impossible to predict with >50% accuracy what the next bit in the > > sequence will be. > > > > I'm not sure it always includes the first condition. > > That would only leave the arbitrarily long sequence of generated > bits and no other info? Fine, then: > > I don't think Chaitin's Omega meets this definition, since it is by > > definition a single number than anyone can calculate equally well. > > But from Omega's first N bits, you get no hint at all that lets > you predict its N+1-th bit "with > 50% accuracy". How did you get the first N bits? If you can calculate them, so can I. > So, if the > definition does not include the first condition, from the bits > only you're not going to get any farther than from N tosses > of an idealized coin. Sure. *I* can write an algorithm to calculate the bits of Omega. Then I run my algorithm, see that the first N bits of its output matches the first N bits of your sequence, and predict with very high probability what the next bit is, right? If you calculate the first 100,000 bits of Omega and give it to me, and you don't tell me that it's the first 100,000 bits of Omega, and I think to try calculating the first 100,000 bits of Omega and they match, then I guess the 100,001'st bit of Omega, then I have a >50% chance of getting the next bit right. If, on the other hand, you run a random number generator based on quantum radioactive decay, or you flip a coin 100,000 times, and it just *happens* to match the first 100,000 bits of Omega, and I notice that, and I guess the 100,001'st bit of Omega, then I have still only a 50% probability of being right. This is why some people say that any given finite string cannot be considered random or non-random by itself, without knowing how it's generated. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. This is top-quality raw fish, the Rolls-Rice of Sushi! From mwright at pro-ns.net Wed Jun 6 16:06:53 2001 From: mwright at pro-ns.net (Mark Wright) Date: 6 Jun 2001 13:06:53 -0700 Subject: How do I return binary data from a python CGI called from CGIHTTPServer? References: <9f96kb01mq8@enews1.newsguy.com> Message-ID: D-Man wrote in message news:... > In MS-DOS terminals ctrl-z is used to indicate that you want to close > the input stream (EOF). On Unix terminals it is ctrl-d instead. I > think that the problem must be the sub-process thinks it is writing to > a tty rather than a regular file, and thus is closing the output when > you try and write ctrl-z. > > How is the sub-process started? What is the command for the > sub-process? I don't know the details of Win32 process forking, but > if you are using a *nix system you will have to change 'python' to > 'python -u' when you exec in the child. (Or just adjust the string > passed to popen) This actually seems to be a bug in win32popen. If I print out some binary data with an embedded 0x1a, like this: #binaryprinter.py import sys sys.stdout.write('\n\x1a' + 'abcdefg') I get the correct result when running this program from the command line: # reader.py import sys print repr(sys.stdin.read()) C:\tmp>python -u binaryprinter.py | python -u reader.py '\n\x1aabcdefg' However, I get the wrong value when I do a win32pipe.popen(), like this program: # opener.py import sys import win32pipe print repr(win32pipe.popen('python.exe -u binaryprinter.py').read()) C:\tmp>python -u opener.py '\n' How do I report this? Mark From rajarshi at presidency.com Tue Jun 5 04:03:23 2001 From: rajarshi at presidency.com (Rajarshi Guha) Date: Tue, 5 Jun 2001 13:33:23 +0530 Subject: reding in a png/jpg etc and displaying it Message-ID: <9fk77u$4ga6l$1@ID-91520.news.dfncis.de> Hi, Iw as looking through PIL and it seems pretty neat. The source indicates that there is a function to read in an image and output it to a Tk window. Could anybody help me out in displaying the read in image into a Gtk window. Actuall, am I right in saying 'display it to a Gtk window' or should it be canvas/pixmap/image.... I'm a little confused on how to display images via the Gtk interface. TIA, -- ------------------------------------------------------------- Rajarshi Guha email: rajarshi at presidency.com web: http:/www.psynet.net/jijog From njm at rectec.net Tue Jun 26 16:00:11 2001 From: njm at rectec.net (NJM) Date: Tue, 26 Jun 2001 15:00:11 -0500 Subject: Windows shutdown problem Message-ID: My computer locks up in the shutting down screen after I use python. If I don't use any python, it shuts down fine. Does any one have any ideas?? Thanks for the help. From junkster at rochester.rr.com Wed Jun 13 19:50:33 2001 From: junkster at rochester.rr.com (Benjamin Schollnick) Date: Wed, 13 Jun 2001 23:50:33 GMT Subject: DNSlib issues? Message-ID: Folks, If I give an invalid DNS server address in the DNSLIB demo, the App waits for keyboard manual entry....(i.e. instead of failing with a socket error, the socket seems to be connecting to stdin)... Is there anyway for me to catch this? And to ensure that it isn't connected to the stdin? - benjamin From mmanti at home.com Sat Jun 30 20:56:41 2001 From: mmanti at home.com (Michael Manti) Date: Sat, 30 Jun 2001 20:56:41 -0400 Subject: PEP scepticism In-Reply-To: References: Message-ID: <01063020564100.01941@cp305909-a> On Saturday 30 June 2001 07:13, you wrote: > On Sat, 30 Jun 2001 01:09:03 GMT, Rainer Deyke wrote: > >"phil hunt" wrote in message > >news:slrn9jq3rc.qg9.philh at comuno.freeserve.co.uk... > > > >> On Fri, 29 Jun 2001 17:43:34 -0400, Tim Peters wrote: > >> >Or the other existing method: > >> > > >> > # This is a multi-line comment. > >> > # Although it sure looks like a sequence of > >> > # single-line comments . > >> > >> This is truly bad, because it makes it harder to add new lines; > >> you have to type "# " repeatedly when adding new comment text, which > >> breaks the flow of thought -- at least it dores for me. > > > >Strange. In C++, I always use '//' for multiline comments in favor of > >'/**/'. ('//' in C++ is equivalent to '#' in Python.) This makes the > >comment more readable IMO. Why not just type the comment text first, and > >add '#' marks later? > > That's what I do. I still find it an irritating hassle. > > I appreciate your point that beginning all comment lines with // > makes for visibility. When I have long multi-line comment, I > usually enclose them like this: > > /********* > Start of long comment > > > > > > end of long comment > *********/ > > Which I find nice and visible. Which editor or IDE do you use that makes commenting such an "irritating hassle"? I think just about every programming mode in Emacs has a convenient function and keybinding for commenting--the modes for Python and C/C++ included--and I'd be genuinely surprised if other editors and IDEs didn't have the same. From fredrik at pythonware.com Wed Jun 13 18:01:08 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 13 Jun 2001 22:01:08 GMT Subject: base converter References: Message-ID: Jeroen Wolff wrote: > I looked on the net for a baseconverter written in python. Is there > any? Something like: > > BaseConvert(20,2) --> "10100" def BaseConvert(x, b): out = "" while x: x, d = divmod(x, b) out = str(d) + out return out (why has decimal to binary conversion suddenly turned into a FAQ the last few months? it wasn't this way in the old days, and I cannot remember ever having to output things as binary numbers in a real-life project... can anyone explain?) From Jerry.Spicklemire at IFLYATA.COM Tue Jun 19 14:22:06 2001 From: Jerry.Spicklemire at IFLYATA.COM (Spicklemire, Jerry) Date: Tue, 19 Jun 2001 13:22:06 -0500 Subject: Re. PythonCard - was Re: Event-driven GUIs ... Message-ID: <977A39E65CFCD3119ABF00D0B741D849E10247@innt-73.ata.com> Hi Roman, Neil, et. al., Neil suggested: "However, the market, which was given several HyperCard like products to choose from, has decided against this form of development environment." to which Roman replied: "The market ways are unpredictable, because decisions are made not on the basis of technical merits but with some strange reasoning behind." Just my $.02 about "the market" where Open Source and FREE software is concerned. There is actually something of a parallel universe phenomenon at work, an inevitable side effect of the Web and it's predecessors. Python is a great example of a tool that is virtually invisible to "the market", but which has been thriving nonetheless. Think Linux, prior to about 1997. As many Java and C++ refugees frequenting these lists can attest, "the market" no longer has the last word. We're witnessing the birth of a "paramarket". Python has risen on its merit entirely independent of "conventional wisdom", "market forces", "public relations", "strategic imperative", and other counterproductive distractions. So, as for Python Card- Go For It! If HyperCard faded due to "extenuating circumstances", perhaps a comeback is in order. Later, Jerry S. From see at my.signature Tue Jun 12 21:36:43 2001 From: see at my.signature (Greg Ewing) Date: Wed, 13 Jun 2001 13:36:43 +1200 Subject: Python Shareware? References: <3B25AF24.EAC22242@my.signature> Message-ID: <3B26C3AB.852BCA75@my.signature> Will Ware wrote: > > shareware authors are already > entirely reliant on the honor system anyway. Of course. I was referring specifically to the "public domain" part of the suggested scheme. If you announce that something is in the public domain, you're saying "anyone can do what they want with this, and I don't care". If you do care, that's obviously the wrong message to send. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From careye at spamcop.net Sun Jun 17 03:27:20 2001 From: careye at spamcop.net (Carey Evans) Date: 17 Jun 2001 19:27:20 +1200 Subject: crypt module on win32? References: <3B299A96.C42FC98C@senux.com.NOSPAM> Message-ID: <87y9qr8t2f.fsf@psyche.dnsalias.org> Brian Lee writes: > I want to use some Python code on MS-Windows. The code use crypt > module but there is no such module on Python for MS-Windows. I've ported Eric Young's fcrypt.c to Python. The speed isn't particularly impressive, but it does work: http://home.clear.net.nz/pages/c.evans/sw/ -- Carey Evans http://home.clear.net.nz/pages/c.evans/ "Quiet, you'll miss the humorous conclusion." From shredwheat at mediaone.net Fri Jun 29 12:48:53 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Fri, 29 Jun 2001 16:48:53 GMT Subject: Python for Commercial Games? References: <9haoiv$jnv$1@mtc1.mtcnet.net> <52e5ab5f.0106270823.599f61ae@posting.google.com> Message-ID: "Dirk Krause" wrote > Maybe it is even possible to write a pygame2sdl converter (could this > be? Pete?) hmm, it would be a bit of work, but i don't know if it would be worthwhile. for the most part pygame is pretty 'thin'. it just boxes up your python arguments and sends them off to the SDL api. there are parts of the code where the pygame code is thicker, but none of that will be found in the performance heavy portion of the code. more of the work would involve changing your sprite and game python classes into c/c++ code. there's just too much stuff you do with your python objects that isn't readily available in c. From diwanh at rcs-sgi.server.rpi.edu Fri Jun 8 10:28:01 2001 From: diwanh at rcs-sgi.server.rpi.edu (Hasan Diwan) Date: 8 Jun 2001 10:28:01 -0400 Subject: Socket problem Message-ID: <9fqndh$1v6k@rcs-sgi.server.rpi.edu> I'm having problems with the socket.connect method... Code below, the reason I'm using python 1.xx is that the target machine doesn't have 2.xx yet. The offensive line is denoted as such: #!/usr/bin/env python # proxy.py, sets up a generic TCP proxy... needs python 1.xx """ Generic TCP proxy server using CGI expects: host, port returns: cli_port """ import cgi field=cgi.FieldStorage() form_ok=0 if (field["host"].value != "" or field["port"].value != ""): form_ok=1; if not form_ok: print '' print 'Error
The script makes no assumptions about hostname and port, so you must be verbose about it

comments here, please' # Now start socket code from socket import * import errno push=socket(AF_INET, SOCK_STREAM) pull=socket(AF_INET, SOCK_STREAM) push.bind(('',0)) #localhost, random port pull.connect(field["host"].value, field["port"].value) # this line offends the python interpreter push.listen(SOMAXCONN) (localhost, cli_port) = push.getsockname() print '' print 'Success
Proxy successfully set up on port ',cli_port,' to ',host,':',port,'Have a good time
' From me at mikerobin.com Wed Jun 20 15:01:57 2001 From: me at mikerobin.com (Michael Robin) Date: 20 Jun 2001 12:01:57 -0700 Subject: regex functionality ( was: Re: function attributes (ANN: Introducing PLY-1.0 (Python Lex-Yacc))) References: <3B306425.1BA938BE@lemburg.com> <15152.40380.99624.826511@gargoyle.cs.uchicago.edu> Message-ID: <52e5ab5f.0106201101.49173bc7@posting.google.com> This is from the PLY1.0 doc page: """ The lexer requires input to be supplied as a single input string. Since most machines have more than enough memory, this rarely presents a performance concern. However, it means that the lexer currently can't be used with streaming data such as open files or sockets. This limitation is primarily a side-effect of using the re module. """ In my limited Python experiences I've already encountered this "problem" and a related desired feature for re(): (1) An ".append(moreString) / .allDone()" type of functionality, with eager matching semantics. E.g., I should be able to find out after each .append() (character-by-character, or whatever granularity is desired) if the match has already failed (and perhaps if it's currently succeeding due to "constant-match" or "wildcard"). Perhaps the yield() and friends will make state-maintainance easier for this purpose, and least for stuff witten in pure python. (2) Partial- or fuzzy-match semantics, or "scoring". This could be as simple as the number of characters and/or fields matched, or more complicated, based on caller-provided character classes or other means. Having the # of characters that matched before is all I needed at the time, and seems rather useful. (I should RTFM again and make sure this info isn't available.) I'm sure there's lot's of magic in good regex code, so I'll plead ignorance if these features don't really map to the implementaion. m ------------------------------ "M.-A. Lemburg" wrote in message news:... > David Beazley wrote: > > > > M.-A. Lemburg writes: > > > > > > Just a suggestion: PLY seems to use the same logic for attaching > > > grammar snippets to functions as SPARK does. IMHO, this is bad > > > design since doc-strings should really only be used for documentation > > > and not include vital information for the program logic. > > > > Actually, I thought the doc string hack was one of the neatest > > programming tricks I've ever seen (which is exactly why I copied it > > from SPARK). Why would I write a different documentation string for a > > grammar rule anyways? The grammar rule in the docstring not only > > tells the parser generator what to do, but it precisely documents what > > the function does at the same time. I don't know what inspired John > > to take this approach in SPARK, but it's pure genius if you ask me :-). > > IMHO, doc-strings are there to > document functions/methods in a human readable way, with additional > comments and maybe even usage examples. As such they are nice > to have around in the source, but are not necessarily needed > for program execution (e.g. python -OO removes them). > > Maybe just me, but I believe that putting program logic into > documentation is not a clean design. > > > > Note that in Python 2.1 we have function attributes which were > > > added for exactly this reason, so the doc-string approach is > > > not really needed anymore. I'd suggest to move to these for one > > > of the next releases. > > > > A fine idea, but the implementation is completely useless because > > there is no syntactically convenient way to attach the > > attributes. > > Ah... so that's what you're after: convenience ! > That, of course, is true. > > So the conclusion should be: how can we make function attribute > assignment more convienent and not why not to use them :-) > > > IMHO, having to type something like this is an even more > > horrible design than using the docstrings (not to mention that it > > looks ugly and unnatural): > > > > def p_expr_plus(t): > > t[0] = t[1] + t[3] > > > > p_expr_plus.grammar = 'expr : expr PLUS expr' > > > > I don't have any plans to abandon the use of doc strings because I > > like the way that they work. If I were to use function attributes for > > anything, I would probably use them for some purpose other than > > grammar specification. I'd have to think about that however. From idivanov at hotmail.com Sun Jun 24 09:15:21 2001 From: idivanov at hotmail.com (Ivan) Date: 24 Jun 2001 06:15:21 -0700 Subject: how to pass arguments to rexec? References: <9dab6033.0106231632.1be8db3e@posting.google.com> Message-ID: <9dab6033.0106240515.66f8f8ed@posting.google.com> I have it: Here is a module to use:import sys import rexec import __main__ class sandbox(rexec.RExec): def __init__ ( self, hooks=None, \ verbose=0, re_arg=None): self.re_arg_ =re_arg; rexec.RExec.__init__ (self, hooks, verbose); print "new restricted environment created" 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__'] m.re_arg =self.re_arg_ return m class arg_test: def __init__ (self): self.msg_ ="Yes, the test works!" print "module sandbox2 loaded, no problems" ------------------------------------ and to test: 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 sandbox2 module sandbox2 loaded, no problems >>> arg = sandbox2.arg_test() >>> re = sandbox2.sandbox(None, 1) new restricted environment created >>> re.r_exec("print re_arg") None >>> re2 = sandbox2.sandbox(None, 1, arg) new restricted environment created >>> re2.r_exec("print re_arg") >>> >>> re2.r_exec("print re_arg.msg_") Yes, the test works! >>> arg >>> From tom at peresys.co.za Sun Jun 10 08:42:49 2001 From: tom at peresys.co.za (Tomasz Stochmal) Date: 10 Jun 2001 05:42:49 -0700 Subject: py2exe how safe is my source ? Message-ID: I want to distribute my end product to clients. How safe is my source code ? Can you easily reverse-engineer pyc files ? From ommadawn at club-internet.fr Thu Jun 7 10:56:34 2001 From: ommadawn at club-internet.fr (Sgluarb) Date: Thu, 7 Jun 2001 15:56:34 +0100 Subject: Windows editor? References: <3af2c38f.341431824@News.CIS.DFN.DE> <3B1F345B.4E04FDE9@rk-speed-rugby.dk> Message-ID: <9fo167$j1v$1@reader1.imaginet.fr> "Brian Elmegaard" a ?crit dans le message news: 3B1F345B.4E04FDE9 at rk-speed-rugby.dk... > > > > > >What's a good Python editor for programming under Windows, specifically > > > > > >Windows 2000? According to Google archives it seems this > > IMHO, Nothing beats emacs. Scite (really good !!) www.scintilla.com Komodo www.activestate.com From Christopher.Cox at honeywell.com Thu Jun 21 16:42:29 2001 From: Christopher.Cox at honeywell.com (Chris) Date: 21 Jun 2001 13:42:29 -0700 Subject: Pythonwin embedded in another program... Message-ID: <13bf971.0106211242.d94cf0f@posting.google.com> My company is trying to do some testing on a particular piece of hardware to be used on aircraft engines. In order to test this unit, a monitor program was built with a version of pythonwin embedded in it (using python version 1.5). The connection between our test unit and our PC (running WinNT4.0 SP6) is a serial port. I've written some scripts using the serial i/o module which work under a normal instance of pythonwin. However, when I try to run those same scripts under our own software, I get an error. One of the developers of our monitor mentioned something about using a debug(???) version of python (I'm not intimately familiar with our monitor so I may be off a bit there). After building elapsedTimer_d.pyd and sio_d.pyd I manually made reference to them in the registry where the other module references are. Upon trying to import from the interactive prompt in our monitor I get the following error. >>> from Serial import Serial Traceback (innermost last): File "", line 1, in ? File "C:\Python\Serial\Serial.py", line 38, in ? File "C:\Python\Serial\MsTimer.py", line 5, in ? ImportError: DLL load failed: One or more arguments are invalid This may have to do with our monitor not working properly, and understandably no one will be able to help me with that particular portion, but are there any suggestions on what to try? As I've said before, this import statement works fine in pythonwin, and the serial module works flawlessly. If I can't get our monitor to run the scripts without error, I was thinking that as an alternative, I can somehow open pythonwin from within a script running on our monitor and doing what I need to do in there, then return to the original script. If I need to go this route, are there any suggestions to accomplish this (in as simple a manner as possible since our tools need to go through a rather rigorous verification process as mandated by the FAA)? If this is possible, what about passing arguments from the main script to a separate script running in pythonwin and then returning some value? I apologize for the length of this post and for the semi-off-topic content. I'm only 2 months into writing with python and reading this NG has been extremely helpful in the knowledge I've gained so far so I thought I'd try the obviously capable python community at large. Thanks for any help that can be offered. Chris Christopher.Cox at honeywell.com From ajm at enteract.com Fri Jun 22 18:40:01 2001 From: ajm at enteract.com (Alan Miller) Date: Fri, 22 Jun 2001 17:40:01 -0500 Subject: cmdline.py not working in ActiveState Python 2.1 References: <3B339168.9D7A9094@raqia.com> Message-ID: David Lees (DavidLSpamNoNo at raqia.com) wrote: >when called with command line 'testcmd.py -x 3' >from a Linux version of Python 2.1 it works correctly. However, using >the same build (ActiveState) under windows NT, the command line option >is not recognized and 'b' has value zero. > >Any idea what is going on here? I think this command line parser used >to work on older windows Python distributions. Are you sure it's getting the command line at all? There was some discussion recently about the requirement to launch python programs on NT as "python testcmd.py -x 3" instead of just "testcmd.py -x 3" to get command line options passed correctly. ajm From mal at lemburg.com Sat Jun 16 19:10:48 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Sun, 17 Jun 2001 01:10:48 +0200 Subject: Writing new codecs References: <002201c0f689$4d46c550$445d4540@D1XYVL01> Message-ID: <3B2BE778.FF80B75@lemburg.com> Brian Quinlan wrote: > > I just finished writing a modified UTF-7 encoder/decoder in Python and > am planning on contributing it back. > > My question is regarding form: should new codecs be written in C or > Python? For often used codecs which need good performance, C is certainly the language of choice. Writing such a C module is easy: you may want to use the _codecsmodule.c code and the UTF-8 codec in unicodeobject.c as templates. > AFAIK, Python does not currently include any codecs written in Python > (I'm not counting the character mapping ones or the trivial wrappers > around C code). Is this because the current codecs are all "important" > and future codecs should be implemented elsewhere to avoid adding too > much junk to codecmodule.c and unicodeobject.c? No, it's because performance matter ;-) > Or is the pattern of providing the actual implementation in > unicodeobject.c going to continue? Only the most important codecs will be placed into unicodeobject.c. I think that UTF-7 would be a good candidate, since it is a native Unicode encoding. UTF-32 would be another candidate. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From jorgenru at jeeves.stud.ntnu.no Thu Jun 7 08:03:00 2001 From: jorgenru at jeeves.stud.ntnu.no (Jørgen Ruud) Date: Thu, 7 Jun 2001 12:03:00 +0000 (UTC) Subject: python 2.1 install problem Message-ID: I have downloaded python 2.1, and done a configure with the --prefix=/local swotch. But I want to install python to another directory than /local, because i'll will use it as a package to distribute other to machines. With some MAKEFILES you can use: 'make DESTDIR=directory install' (where DESTDIR, is the destinationdirectory) to install it to another place. Is this possible with python? (I know it dosn't use the DESTDIR option) -- J?rgen Ruud jorgenru at stud.ntnu.no From hgebel at home.com Sun Jun 3 00:44:21 2001 From: hgebel at home.com (Harry Henry Gebel) Date: Sun, 03 Jun 2001 04:44:21 GMT Subject: Looking up device major and minor numbers in Python Message-ID: <20010603.004420.1504569917.19294@elroy.house> Is there a way to find the device major and minor numbers of character and block special device files using python? -- Harry Henry Gebel West Dover Hundred, Delaware GPG encrypted email gladly accepted. Key ID: B853FFFE Fingerprint: 15A6 F58D AEED 5680 B41A 61FE 5A5F BB51 B853 FFFE From oliphant.travis at ieee.org Mon Jun 25 10:16:58 2001 From: oliphant.travis at ieee.org (Travis Oliphant) Date: Mon, 25 Jun 2001 14:16:58 +0000 Subject: ?Multipack latest version? References: Message-ID: <9h8644$ije$1@news.xmission.com> Norman Shelley wrote: > Where is the latest version of Multipack? > > I have found this site, http://pylab.sourceforge.net/ but previous posts > mentioned a cvs only accessable site which did not look up-to-date. > That site does contain the latest Multipack version. Multipack is becoming part of a larger project called SciPy which is being developed on CVS (www.scipy.org) and will be available this summer. -Travis From dsh8290 at rit.edu Fri Jun 1 14:25:06 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 1 Jun 2001 14:25:06 -0400 Subject: Copying files to multiple comp's on a lan In-Reply-To: <9f8k3v$1i04$1@news.cybercity.dk>; from hbn@imada.sdu.dk on Fri, Jun 01, 2001 at 07:41:45PM +0200 References: <9f8k3v$1i04$1@news.cybercity.dk> Message-ID: <20010601142506.A7774@harmony.cs.rit.edu> On Fri, Jun 01, 2001 at 07:41:45PM +0200, Henrik Berg Nielsen wrote: This sounds more appropriate for a shell script to me. (First install cygwin to get a (real, useful, etc) shell http://sources.redhat.com/cygwin) ~~~~~~~~~~~~~ smbcopy.sh ~~~~~~~~~~~~~~~~~~~~ #!/bin/bash IFS=":" # In this ficticious network the machines are Mach1, Mach2, and Mach3 # and all have a samba share named 'C' which is the base path for the # destination. # Here is the list of machines to copy to, I assume via Samba? MACHINES=" //Mach1/C : //Mach2/C : //Mach3/C " for DEST in $MACHINES ; do # assemble the command so as not to duplicate code COMMAND="cp $1 $DEST/$2" # display the command to the user echo $COMMAND # execute the command $COMMAND done ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This could be done in Python using a list and and a for loop, then calling os.system( ) to do the copying, or open the source file for reading and iteratively open the destination files for writing and write the data. Ex: ~~~~~~~~~~~~ smbcopy.py ~~~~~~~~~~~~~~~~~~~~~~~~~ #!/usr/bin/env python import sys import os # same as above machines = [ "//Mach1/C" , "//Mach2/C" , "//Mach3/C" ] source_file_path = sys.argv[1] dest_path = sys.argv[2] source_file = open( source_file_path , "rb" ) source_data = source_file.read() source_file.close() for dest in machines : dest_file = open( dest + "/" + dest_path , "wb" ) dest_file.write( source_data ) dest_file.close() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Both of these sample programs assume that the input (command line arguments) existed and were valid. The scripts could be improved to include more error handling and user feedback. If you went with a python implementation you might want to create a GUI for it (not trivial!) that would allow point-and-click selection of files and destinations. HTH, -D From chapman at bioreason.com Wed Jun 20 15:21:01 2001 From: chapman at bioreason.com (Mitch Chapman) Date: Wed, 20 Jun 2001 13:21:01 -0600 Subject: re.match(...) fails to find a match References: Message-ID: <3B30F79D.8C8CD74B@bioreason.com> Kevin Cole wrote: > Just attempting to get an ampersand working, I've tried: > > p = re.compile('[&]+') > [...] > print p.match('This string & that string') > > always returns "None". The docstring for p.match notes that it tries to match at the beginning of a string. Try p.search instead. -- Mitch Chapman Mitch.Chapman at bioreason.com From aahz at panix.com Fri Jun 15 01:39:07 2001 From: aahz at panix.com (Aahz Maruch) Date: 14 Jun 2001 22:39:07 -0700 Subject: Threads and Event objects References: <20010615.145947.1694224903.5941@topic.com.au> Message-ID: <9gc71r$2is$1@panix2.panix.com> In article <20010615.145947.1694224903.5941 at topic.com.au>, Matthew Hawkins wrote: > >I have a class that fires off some threads to do some i/o, and I'm trying >to have it collate the results. I send in a Conditional variable to >control access to the data buffer, and an Event variable so the thread >can signal when there's some data to come pick up. Use a queue instead. See http://starship.python.net/crew/aahz/ for some examples. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista I wasn't licking it, I was chewing it. From fredrik at pythonware.com Thu Jun 14 15:40:55 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 14 Jun 2001 19:40:55 GMT Subject: Lookup all available registered Codecs at once? References: <3B28F412.3D36FFA6@stroeder.com> Message-ID: Michael Str?der wrote: > Is there a way to look up all registered Codecs (in module codecs) > at once? Something like this might work: import os import encodings names = encodings._cache.keys() for file in os.listdir(os.path.dirname(encodings.__file__)): name, ext = os.path.splitext(file) if ext == ".py" and name not in names: try: encodings.search_function(name) except SystemError: pass else: names.append(name) print "codecs:", names print "aliases:", encodings.aliases.aliases.keys() if you wish to speed it up, you can skip the call to search_function, and just filter out "__init__" and "aliases". Hope this helps! From dsh8290 at rit.edu Thu Jun 28 14:29:38 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 28 Jun 2001 14:29:38 -0400 Subject: Recursive functions In-Reply-To: ; from tomh@optiscan.com on Thu, Jun 28, 2001 at 04:28:28PM +1000 References: Message-ID: <20010628142938.B19571@harmony.cs.rit.edu> On Thu, Jun 28, 2001 at 04:28:28PM +1000, Tom Harris wrote: | Hi, | | I am very new to Python, and I am trying to get a recursive function | working. The problem is that the function modifies one of its arguments, | which is not a local copy of a variable (local to this stack frame of the | function, like in call by value in C) but a reference to a variable owned by | the function namespace, so changes to the variable are inherited by other | calls to the same function. I tried copying the argument to a variable in | the function body, but of course this suffers from the same problem. This is the same as in C -- the argument 'aList' would be of type GList* (if you use glib). | This is the idea, but the list just keeps on growing. | | def f(aList): | ... | aList.append(stuff) | f(aList) | | What is the solution? This depends on what you are doing in '...'. Maybe def f( aList ) : ... f( aList + stuff ) would help. The add operator on a list creates a shallow copy of the list with the 'stuff' at the end of it. It is similar to doing tmp = aList[:] tmp.append( stuff ) f( tmp ) HTH, -D From ken_chiba at hotmail.com Fri Jun 22 23:56:44 2001 From: ken_chiba at hotmail.com (Ken) Date: Sat, 23 Jun 2001 03:56:44 GMT Subject: libssl.so & libssl.so req'd for rpm install References: <3b327452.95354923@news1.on.sympatico.ca> <3B33CD23.90A98765@wombatzone.freeserve.co.uk> Message-ID: <3b341337.201568550@news1.on.sympatico.ca> Ok. I'll give it a shot in the morning -- I have tried to compile the src rpm for 2.1-5... and there were a lot of files that didn't work out (is there a way to pipe the output from the install into a file?). Thanks, kc On Fri, 22 Jun 2001 23:56:35 +0100, Iain Calder wrote: >Ken wrote: >> >> Hi, >> >> I guess this is kind of a follow up from my last message; I'm trying >> to install python 2.1-5 off the rpm, which I'm assuming will work fine >> if it can work out its dependencies. It's failing on the following >> dependencies: >> >> libcrypto.so.0.9.6 >> libssl.so.0.9.6 >> >> I previously didn't have these files installed, but I managed to >> install the right RPM, and they are now there: >> >> /usr/lib/libcrypto.so.0.9.6 >> /usr/lib/libssl.so.0.9.6 >> >> ...yes the RPM install still fails. I'm running on a farily minimal >> clean install of RH7.1. >> >> Any suggestions? >> >> TIA! >> >> kc > >I haven't tried to install 2.1-5, but this worked for me with 2.1-4 on >RH 7.1: > >1) Download the source rpm python2-2.1-4.src.rpm >2) rpm --rebuild python2-2.1-4.src.rpm >3) rpm -i /usr/src/redhat/RPMS/i386/python2-2.1-4.i386.rpm >4) rpm -i /usr/src/redhat/RPMS/python2-devel-2.1-4.i386.rpm > >Iain From juergen.erhard at gmx.net Sat Jun 23 11:11:30 2001 From: juergen.erhard at gmx.net (=?ISO-8859-1?Q?=22J=FCrgen_A=2E_Erhard=22?=) Date: Sat, 23 Jun 2001 17:11:30 +0200 Subject: PEP 255: Simple Generators In-Reply-To: <3B318348.E4D5E5D6@cosc.canterbury.ac.nz> (message from Greg Ewing on Thu, 21 Jun 2001 17:16:56 +1200) References: <3B318348.E4D5E5D6@cosc.canterbury.ac.nz> Message-ID: <23062001.1@wanderer.local.jae.ddns.org> >>>>> "Greg" == Greg Ewing writes: Greg> Bob Alexander wrote: >> As an Icon programmer, it never occurred to me that there was a >> need for a syntactic distinction. Greg> As I pointed out in an earlier message on Greg> python-iterators at lists.sourceforge.net, the Icon situation Greg> doesn't carry over to PEP255, because the semantics are Greg> different. There's no semantic difference between them in Greg> Icon, but there is in PEP255. I agree. And want to add a little tidbit: As Tim said: in Icon everything is a generator (I don't know Icon, so I just have to believe it). So why should Icon make a syntactic difference when there's no semantic difference? Bye, J -- J?rgen A. Erhard (juergen.erhard at gmx.net, jae at users.sourceforge.net) My WebHome: http://members.tripod.com/Juergen_Erhard The Python Programming Language (http://www.python.org) I wish I had more energy -- or less ambition. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 248 bytes Desc: not available URL: From rarice at core.com Fri Jun 1 16:08:54 2001 From: rarice at core.com (Ralph Allan Rice) Date: Fri, 01 Jun 2001 16:08:54 -0400 Subject: HELP: Weird attribute behavior... References: Message-ID: <3B17F656.510B68AE@core.com> Steven, Yep, it looks like that was the reason. I also found it in the "Learning Python" book by Lutz & Ascher, page 158-159. Thanks, Ralph "Steven D. Majewski" wrote: > > On Fri, 1 Jun 2001, Ralph Allan Rice wrote: > > > I am developing a class that stores device reading information. It > > looks like this: > > > > > > import string > > import dbi, odbc > > > > > > class Reading: > > __data = { } > > > > def __init__(self, type, id, timezone, datestamp, value): > > self.__data['id'] = id > > self.__data['timezone'] = timezone > > self.__data['datestamp'] =datestamp > > self.__data['value'] = value > > self.__data['type']= type > > > > > > change that to: > > class Reading: > ## move __data > def __init__(self, type, id, timezone, datestamp, value): > self.__data = { } ## to here > self.__data['id'] = id > self.__data['timezone'] = timezone > self.__data['datestamp'] =datestamp > self.__data['value'] = value > self.__data['type']= type > > > In your example, __data is a shared class attribute. > If you create it in the __init__ method, then it's owned by > that instance only. > > -- Steve Majewski From nospamnntp at stone.nu Mon Jun 11 04:12:46 2001 From: nospamnntp at stone.nu (Fredrik Steen) Date: 11 Jun 2001 08:12:46 GMT Subject: What version of python is the right version? Message-ID: What version of python should I use for new projects? 1.5.2, 2.0, 2.1? -- .Fredrik Steen http://www.stone.nu/ From gmcm at hypernet.com Wed Jun 20 09:09:11 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 20 Jun 2001 13:09:11 GMT Subject: PEP 255: Simple Generators References: <3B303FE5.735A5FDC@cosc.canterbury.ac.nz> Message-ID: <90C65699Dgmcmhypernetcom@199.171.54.194> Greg Ewing wrote: >But under PEP 255, there is *nothing* anywhere >in the code that you can point to and say "look, >here is where the generator-iterator is created!" Sure there is. It's in the "for". Before iterators, you could look at for x in f(): and say "Aha, f() returns a sequence". In 2.2, you'll have to say "f() returns something that follows the iterator protocol". Now if a casual reader happens upon the definition of f, misses the "yield" and comes away with the impression that f is an "ordinary" function, I say "So what?". Monte Carlo sampling is no way to understand code. - Gordon From philh at comuno.freeserve.co.uk Wed Jun 20 09:51:28 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Wed, 20 Jun 2001 14:51:28 +0100 Subject: Properties in Python References: Message-ID: On Wed, 20 Jun 2001 02:04:33 GMT, Peter Caven wrote: >I'm sure that many people reading this newsgroup are aware that the C# >(C-Sharp) language has a syntax for 'Properties' that allows a class >implementor to hide the implementation of an instance's attribute behind a >'get'/'set' interface. >In Python terms this would look like: > >class Demo: > def __init__(self): > self.attr1 = 1 > self.attr2 = 2 > > def AMethod(self): > pass > >and where: > >d = Demo() >a1 = d.attr1 # would actually execute something like: d.attr1.get() >d.attr2 = 3 # would actually execute something like: d.attr2.set(3) > >So, instead of allowing direct access to the instance attributes, C# >actually executes 'get' and 'set' methods (if defined) for the attributes. >This lets a programmer change the behavior of the attributes defined in the >class (to have side-effects for example) without changing any code written >by users of the class. > >Does anyone have any ideas on how to do this (elegantly) in Python? Yes: class Demo: def __init__(self): self.attr1 = 1 self.attr2 = 2 def getAttr1(self): return self.attr1 def setAttr1(self, v): self.attr1 = v def getAttr2(self): return self.attr2 def setAttr2(self, v): self.attr2 = v What's so hard about that? -- ## Philip Hunt ## ## philh at comuno.freeserve.co.uk ## From glyph at twistedmatrix.com Tue Jun 5 23:32:21 2001 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: Tue, 5 Jun 2001 22:32:21 -0500 (CDT) Subject: Interesting speed benchmark In-Reply-To: <9fjuhh$ghu$1@news.unitel.co.kr> Message-ID: On Tue, 5 Jun 2001, Pete Shinners wrote: > "Mahesh Padmanabhan" wrote > > in which the author does some (by his own admission) subjective > > benchmarks between java and python. While most of it is usual > > stuff, the one test that stood out was the following: Well, that's me. I suppose my little ranting essay has gone beyond its original intention. I've been getting lots of email about it this week in particular, and this post just underscores the need to rewrite it ;). If you're interested, please email me suggestions as to how I can re-do the comparison. I think that the performance numbers are a bit contrived and might not be a good approach to it, but I'd like to be heavy on code examples and quantitative data, if possible. > it's still a whole lot slower than the java version :[ I am still curious as to why this is. It's not been an issue for me yet (the one thing in Python that's irked me a little bit is the allocation overhead for method calls, but even that hasn't been a serious problem), but it seems odd that it should take so long. ______ __ __ _____ _ _ | ____ | \_/ |_____] |_____| |_____| |_____ | | | | @ t w i s t e d m a t r i x . c o m http://twistedmatrix.com/users/glyph From gustafl at algonet.se Tue Jun 12 17:58:03 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 12 Jun 2001 21:58:03 GMT Subject: Getting "Recieved:" headers from rfc822 Message objects? Message-ID: Python 2.1, regarding the rfc822 module: I have found some mails in my inbox that have no "Date" header. So instead, I though about using the date in the last recieved header of a Message object. How do you recieve the "Recieved: " headers? I have tried m.getallmatchingheaders('recieved'), but it returns an empty list. Regards, Gustaf Liljegren From dsh8290 at rit.edu Tue Jun 12 21:41:56 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 12 Jun 2001 21:41:56 -0400 Subject: New guy question In-Reply-To: <9g64uv1j8j@enews1.newsguy.com>; from aleaxit@yahoo.com on Wed, Jun 13, 2001 at 12:23:46AM +0200 References: <3B255439.DFD33F59@home.net> <9g4ik305pa@enews2.newsguy.com> <9g64uv1j8j@enews1.newsguy.com> Message-ID: <20010612214156.B26826@harmony.cs.rit.edu> On Wed, Jun 13, 2001 at 12:23:46AM +0200, Alex Martelli wrote: | "D-Man" wrote in message | news:mailman.992364979.25779.python-list at python.org... | ... | > Some dinosaurs aren't all that old ;-). I don't think the shell on | > NT/2000 is any better, except maybe the screen drawing is less buggy | > (helps for bash, vim, less, man, mutt, etc.). | | Oh come on, we just went over this -- would you rather have: Hmm, sorry, that must have been in a thread I wasn't following. | C:\> peep 2>err.txt | run peep with stderr redirection, a la NT, or run peep with I didn't know that any Windows considered the existence of such high-level shell operations ... | stdout redirected and an argument of 2, a la 95/98, for | example...?! And how can a shell where you can run | foo.py directly "not be any better" than one where you | just *can't* extend the range of executable extensions? | Again, NT is the former, 95/98 the latter. Specifically, I had recently learned that "windows" (I double checked, but I only have win2k at work) could run scripts (.py files) automatically if the associations in explorer were correct. | cmd.exe in one case, command.com in the other. And | don't let me get started about how the *consoles* (not | strictly a shell problem, but that's where you run shells) | behave for copy and paste in the two systems, etc, etc... !!! Have you ever read the vim FAQ? There is a quote in it re win9x console supposedly from a M$ employee. Rather amusing. | bash may well be better than either, but that's no excuse | for ignoring the large differences between them. And Well, since I don't use either (command.com or cmd.exe) I was unaware of the rare high-level constructs they have and the differences thereof. I use the '#!' convenience to extend the range of executable extensions. -D From goringe at avaya.com Thu Jun 7 00:22:16 2001 From: goringe at avaya.com (Chris Goringe) Date: 6 Jun 2001 21:22:16 -0700 Subject: Question re local bindings in nested scopes References: <8gdnht4as9mg09un8vu2ci2re80p2ujssq@4ax.com> <1104_991864564@ns.seowon.ac.kr> Message-ID: <3e7e9334.0106062022.2ce58a46@posting.google.com> This isn't really new in 2.1; below b() refers to the global 'a', but c(), because it contains an assignment to 'a' binds to a local variable and dies. d() fixes this by declaring global. So, is there an analogue of global for nested scopes? >>> a = 1 >>> def b(): ... print a ... >>> def c(): ... print a ... a = a + 1 ... >>> def d(): ... global a ... print a ... a = a + 1 ... >>> b() 1 >>> c() Traceback (most recent call last): File "", line 1, in ? File "", line 2, in c UnboundLocalError: Local variable 'a' referenced before assignment >>> d() 1 From fdrake at beowolf.digicool.com Sat Jun 23 22:41:04 2001 From: fdrake at beowolf.digicool.com (Fred Drake) Date: Sat, 23 Jun 2001 22:41:04 -0400 (EDT) Subject: [development doc updates] Message-ID: <20010624024104.A757728927@beowolf.digicool.com> The development version of the documentation has been updated: http://python.sourceforge.net/devel-docs/ A couple of small updates, including spelling the keywords correctly in the language reference. This version brings back the hyperlinked grammar productions I played around with earlier. They still need work, but they are somewhat better than plain text. From twofingersalute at atl.mediaone.net Tue Jun 12 15:08:13 2001 From: twofingersalute at atl.mediaone.net (myself) Date: Tue, 12 Jun 2001 19:08:13 GMT Subject: tummy compile Mandrake 7.2 References: <20010608.214013.1469262009.16325@K7.atl.mediaone.net> <20010609.104451.1884661237.1229@K7.atl.mediaone.net> <3B24154E.C70211ED@student.gu.edu.au> <20010610.232821.1789366143.1225@K7.atl.mediaone.net> <3B25F742.F4E25C37@student.gu.edu.au> Message-ID: <20010612.151135.165344818.1845@K7.atl.mediaone.net> In article <3B25F742.F4E25C37 at student.gu.edu.au>, "Joal Heagney" wrote: > myself wrote: > >> need a *basic* understanding of the language :-). Just out of >> curiosity, doesn't the -devel part install the header files necessary >> to build the actual expat support? > > Depends on the package builder's preference. If you look at a spec file, > you'll see a whole load of %package directives, which define additional > packages such as devel. However, if you're in a hurry to fold a tar > source up into an rpm, most people write a basic spec file that installs > binaries, libraries and headers in one go. The reason why the build > fails is because it looks for the rpm expat-devel, which isn't in your > rpm database, even though the files it theoretically would provide are > on your system (from the package expat). > >> >> BTW, did you update or do you have 1.5.2 and 2.1 coexisting? I'm trying >> to do latter, being fearful 2.1 will break something if I replace >> 1.5.2. Comments? >> >> thanks a heap! > > Good idea to go for the coexistance thing. I ran rpm -q --whatrequires > python and got the following list back pygtk-0.6.6-4mdk > rpm-devel-3.0.5-27mdk rpm-python-3.0.5-27mdk icepref-1.1-3mdk > python-devel-1.5.2-12mdk rpmlint-0.24-1mdk tkinter-1.5.2-12mdk > python-imaging-1.1-2mdk pythonlib-1.23-2mdk Theoretically I could do > without these, but I'd have to give up some of my favourite Mandrake > features. Either that, or rebuild them for python2.1 > I can't thank you enough for this generous and thorough post. I thought I had it licked from a source install, but there are problems which I don't have the expertise to resolve- hope you'll bear with me if I ask just a *couple* more Q's...and yep, I got similar dependencies as above, plus a few more. > Anycase, here's my hack on the rpm spec file. After a lot of mucking > around, it turns out to be something really insignificant. Look ahead to > step 8. > nah, I like the suspense :-) > 1.First, install the src.rpm under /usr/src/RPM rpm -i > python2-2.1-4.src.rpm > you certainly have more knowledge/success/experience than me, but according to the advice from LM: Building RPM's as root is dangerous, because the binary files are installed on the system before being packaged, thus you must always build as normal user so you won't accidentally pollute your system http://www.linux-mandrake.com/howtos/mdk-rpm/ please don't take this as criticism, it's more a question, as i haven't seen this advice elsewhere. For all I know, building as user is part of my problem? > 2. Cd to the spec file location > cd /usr/src/RPM/SPECS > > 3. Prep and compile the package > rpm -bc python-2.1.spec > > Now begins the hacking on the spec file. 4. Make sure you fix that > depend to expat, not expat-devel still not totally clear on this, but I'll try (actually might try to satisfy the darn thing first- generic rpm or source install) > > This next step is optional. I've tried with and without, and it doesn't > have any effect whatsoever. If you use emacs however, restoring the > colours does make it easier to errorcheck 5. Go through the changelog > and backslash all occurances of " and (one) ' (E.g. " -> \"). Add a " to > the end of the changelog. I'm not to sure this does anything, but it > does restore my emacs colours to what they should be. > I'm automatically impressed with *anyone* who uses emacs :-) > > Again this next step is optional. If you're only going to develop with > python 2.1, you're better off leaving it the same, removing your already > installed python-tools and replace it with your new 2.1 based > python-tools. > 6. Replace the "idle" on the ends of lines 191, 192 and 193 with > idle%{binsuffix}, so they look like this: ######## # Tools > echo '#!/bin/bash' >${RPM_BUILD_ROOT}%{_bindir}/idle%{binsuffix} echo > 'exec %{_prefix}/bin/python%{binsuffix} > /usr/lib/python2.1/Tools/idle/idle.py' >>>${RPM_BUILD_ROOT}%{_bindir}/idle%{binsuffix} > chmod 755 ${RPM_BUILD_ROOT}%{_bindir}/idle%{binsuffix} cp -a Tools > ${RPM_BUILD_ROOT}%{_prefix}/lib/python2.1 > > Note that the second echo and the >>${PRM_BUILD_ROOT} line are the one > line in the spec file. Netscape is just TOO helpful. thanks-that helped........ > > 7. In the make files section, do as for step 6 and replace line 208 echo > "%{__prefix}"/bin/idle >>tools.files with this echo > "%{__prefix}"/bin/idle%{binsuffix} >>tools.files > > This makes sure your python 2.1 version of idle is installed as idle2. > This prevents conflicts when you try to install your new python2-tools > rpm with an already installed python-tools. > ok, here's my main question, and I think it goes to all the "idle" stuff above- when I installed source build, I chose "altinstall" -obviously to allow a non-replacement- it doesn't create a hard link to "python" named "python". Sounds reasonable. But doing: [root at K7 test]# find /usr/local/lib -type f -print0 | xargs -r -0 grep "#! /usr/bin/env" /usr/local/lib/python2.1/site-packages/idle/PyShell.py:#! /usr/bin/env python /usr/local/lib/python2.1/site-packages/idle/eventparse.py:#! /usr/bin/env python/ /usr/local/lib/python2.1/base64.py:#! /usr/bin/env python /usr/local/lib/python2.1/difflib.py:#! /usr/bin/env python and *dozens* more of similar nature- they all call python, which would be my 1.5.2, rather than the python2.1 which the install created. I can't create a symlink, otherwise the system will call 2.1, which I'm trying to avoid. E.g., if I run "python2.1 regrtest.py" or "./regrtest.py" from the test directory, which ver. is running?? Perhaps after studying Python and bash for another year I'd know for myself :-). Is this an issue? If it is, does your method address it? > > This next step ISN'T optional. I've found (Through a LOT of trial and > error) that THIS this that chokes rpm during the install. 8. On line 217 > you'll find the following %{__prefix}/man/man1/python%{binsuffix}.1.gz > Unfortunatly Mandrake doesn't package man pages as gzips, but as bzip2s. > So change this line to > %{__prefix}/man/man1/python%{binsuffix}.1.*z* and it work for gzip or > bzip2 > I'm way cofused on the purpose of the LM rpm macros and how exactly they're used (or not), but looks like /usr/lib/rpm/brp-compress is 'sposed to handle that...... > 9. Now we go ahead with our install. > > rpm -bi --short-circuit python-2.1.spec > > Now you may see lots of error messages that state: > > "Finding Provides: (using /usr/lib/rpm/find-provides)... Finding > Requires: (using /usr/lib/rpm/find-requires)... line 246: Dependency > tokens must begin with alpha-numeric, '_' or '/': %defattr(-, root, > root) > line 246 etc- looks familiar :-( > Failed to find Requires:" > > This is the bit that really had me stumped. After a LONG time trying to > remember how I got around the error messages, I rediscovered that get > your RPMS if you just go ahead and build the damn things. > > 10. rpm -bb --short-circuit python-2.1.spec > again my ignorance probably shows, but man rpm says --short-circuit is only valid w/ -bc and -bi......and another thing- after all that, couldn't you find a stronger expletive than "damn"? ;-) > If you look under RPMS/i586 you should see four python2 rpms. Feel free > to check them using package query mode, listing all the files in each. > rpm -qpl python2-2.1-4.i586.rpm > rpm -qpl python2-devel-2.1-4.i586.rpm rpm -qpl > python2-tkinter-2.1-4.i586.rpm rpm -qpl python2-tools-2.1-4.i586.rpm > > After all that rubbish and it's just a matter of Mandrake using a > different file compression tool to mainstream. *sheesh* > > As you can see, source building is a mixture of applied knowledge (Which > usually comes from incomplete documentation and previous attempts), > trial-and-error and some days, a good voodoo curse and a heavy > dependency on alchohol/coffee/frustration-relief-aid-of-choice. In this > case, a blind willingness to do what seems to be a bad thing helps a > little, "just to see what happens". *evil grin* Have fun. I'm glad this is somebody's idea of "fun"! But, good explanation of the necessary ingredients. Python2.1 Will Get Installed on my box; maybe not today, maybe not this week, but I'm gonna persevere! I'll post results, hopefully positive. I know there are others who'll benefit from your post as well- I'm seeing more Python q's on a.o.l.m.... kind sir, may your tracebacks be few and far between From paulsid at home.com Sat Jun 23 22:21:28 2001 From: paulsid at home.com (Paul Sidorsky) Date: Sat, 23 Jun 2001 20:21:28 -0600 Subject: How useful do you find the interactive interpreter? References: <4688f24b.0106231658.43d2c446@posting.google.com> Message-ID: <3B354EA8.4AAAAB93@home.com> slaytanic killer wrote: > I am looking at Python seriously, and I can see that the interpreter > would be really good for testing out ideas. Getting small things to > work and then switching over to a text editor to generalize what I've > learned. Is this how people generally use it? Or is it an even > deeper part of coding? I'm still learning the finer points of Python, and I've found myself using the interactive interpreter a lot more frequently in recent days. It's really handy for getting answers that might be hard to find in the documentation, or when it's just faster to try it rather than look it up. I've also started to use it for experimentation. The biggest problem is that, coming from C/C++ as I am, I have to keep remembering that I do actually have the benefit of an interpreter now! It's a real easy thing to forget about when you're used to looking up stuff and writing test programs by default. Doing stuff interactively in the interpreter takes me back to my days of doing BASIC in grade school, except this time the language is much nicer. :-) Things I recently did in interactive sessions: - Checked to make sure an empty list evaluated to false. - Checked to see what the __dict__ attribute looked like on classes vs. objects. - Experimented with some of the more advanced features of regular expressions. - Profiled the hash() function to see if hashing a string was faster/slower than hashing an integer. All of this stuff would have taken a lot longer to either look up in the docs or write test programs for, so I'm very glad the interactive mode was there! -- ====================================================================== Paul Sidorsky Calgary, Canada paulsid at home.com http://members.home.net/paulsid/ From gustin at pcpm.ucl.ac.be Thu Jun 21 02:40:15 2001 From: gustin at pcpm.ucl.ac.be (Cédric Gustin) Date: Thu, 21 Jun 2001 08:40:15 +0200 Subject: Help installing pygtk, libglade in Windows - please References: <9gqd28$j36$1@nntp6.u.washington.edu> Message-ID: <9gs50h$8sq$1@estragon.sri.ucl.ac.be> Hi, > I'm trying to install pygtk and libglade on a Win9x system. The local > Windows guy advises me that it is necessary to edit the Windows registry > to install DLLs. Is this truly the case with the DLLs associated with > these? Why do you want to edit the registry ? Simply copy the py files from Hans Breuer pygtk for win32 distribution (http://www.hans.breuer.org/ports/) to %PYTHONPREFIX%\Lib(where %PYTHONPREFIX% is the Python installation directory, let's say C:\Python21), and the *pyd files to %PYTHONPREFIX%\DLLs. Remember that there is no site-packages directory in the python win32 distribution ! You'll also need the gtk+ for win32 dlls as available on http://user.sgic.fi/~tml/gimp/win32/downloads.html. You can either choose to download the gimp installer that will copy the required dlls to your windows system directory, or to select the developer packages (at least glib,gtk+ and libiconv), unzip them and add the target directory (that contains the DLLs) to your %PATH%. If you want to work with pygtk without libglade support on python 2.0, Hans Breuer's port is fine. But because I really needed libglade to port my pygtk application on win32, I recently recompiled pygtk-0.6.4 for python 2.1, including _libglade.pyd, using mingw32. If you're interested, I can send you the DLLs. Cedric Gustin From gustafl at algonet.se Wed Jun 27 05:39:16 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: Wed, 27 Jun 2001 11:39:16 +0200 Subject: Should I use a dictionary? References: <9h91pb$e3k$1@panix6.panix.com> <9h9ckq$nf$1@apollo.csd.net> <9hc2m2$gtf$1@news.service.uci.edu> Message-ID: <9hca9i$dmb$1@cubacola.tninet.se> "Danyel Fisher" wrote: > > Thanks. This suits me perfectly. I get the date in the format "2001-01-01 > > 13:12", so that would be "200101011312" with no risk for confusion. > True. But you may still wish to consider UNIX standard date/time: > it will make your data interprable in other contexts, should you need to. As Kosh said, it will improve performance to do the sorting with integers. You're right that it may be confusion, but I think a comment in the right place will prevent that. :-) After doing the sorting, the integer is to be transformed into a date again, using the mkdate function: d = time.mkdate((date[:4],date[5:6],date[7:8],date[9:10],date[11:12])) The remaining question is if the time saved on sorting integers is more than the time it takes to convert from and to a date before and after sorting. I'll try this later today. Regards, Gustaf Liljegren From jmarshal at mathworks.com Mon Jun 11 15:41:11 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 11 Jun 2001 19:41:11 GMT Subject: EXECing multiple lines. References: <3B2518B9.5C5CE56B@olen.to> Message-ID: <9g36sn$8mp$1@news.mathworks.com> Joonas Paalasmaa wrote: > What might be wrong when I get the following error? >>>> exec """for x in range(5): > print x""" > Traceback (innermost last): > File "", line 1, in ? > exec """for x in range(5): > File "", line 2 > print x > ^ > SyntaxError: invalid syntax >>>> It works if you put a newline at the end. I don't know if it's a bug that it doesn't work without the newline. From charles at aspen.sweetshade.net Sat Jun 16 15:27:42 2001 From: charles at aspen.sweetshade.net (Charles Allen) Date: 16 Jun 2001 19:27:42 GMT Subject: os.statvfs on FreeBSD References: Message-ID: To follow up to my own followup a bit: >>>> os.statvfs("/") > Traceback (most recent call last): > File "", line 1, in ? > AttributeError: 'os' module has no attribute 'statvfs' I should have explained that FreeBSD has no statvfs library routine (at least 4-STABLE, I don't know about 5-CURRENT). If the original poster would explain the specific info he's looking for, perhaps an alternative can be found. -- Charles Allen From bokr at accessone.com Thu Jun 14 15:07:58 2001 From: bokr at accessone.com (Bengt Richter) Date: Thu, 14 Jun 2001 19:07:58 GMT Subject: PEP 259: Revise to remove context-driven magic from print References: <486de2.0106131406.5c0cbef9@posting.google.com> <9gamor$8ft$6@216.39.170.247> <9gap8i0fss@enews1.newsguy.com> Message-ID: <3b29060b.489799304@wa.news.verio.net> On Thu, 14 Jun 2001 18:37:32 +0200, "Alex Martelli" wrote: >"David LeBlanc" wrote in message >news:9gamor$8ft$6 at 216.39.170.247... > ... >> makes sense to me. I also liked someone's idea of __print__ - if that > >The 'someone' was me ("was I"...?). > >> idea was in respect of giving objects the power to (as it where) print >> themselves (return their string representation - so call it asstring()). > >How would that differ from the existing __str__ and __repr__ methods? > >No, __print__ would rather underlie the print statement just like >__import__ underlies the import (and from) statements. But I guess >I gotta write a PEP about it... Another bit of grist for the PEP 259 mill: If you thought of print arg1,arg2 as implicitly doing print __builtins__.defaultformat % (arg1,arg2) and borrowed an old idea from Fortran re format specs, so you could handle "as many as necessary" in a format, e.g., print "%(%s )\n" % (arg1,arg2) would generate as many "%s " (note trailing space, if that's what you want) as necessary. I might prefer print "%s%( %s)\n" Other handy uses would shorten specific-length repeated patterns print "This is an 8-col table:\n--\n%4(%6s: %7.3f )\n--\n" ... With an appropriate place to store print's default format, one could override at will. With the above, any special behaviour would then be a matter of tweaking format specification/interpretation instead of messing with print itself. From qrczak at knm.org.pl Sun Jun 10 15:45:05 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 10 Jun 2001 19:45:05 GMT Subject: Why should i use python if i can use java References: <9fngvl011jg@enews2.newsguy.com> Message-ID: 07 Jun 2001 09:49:36 -0700, Don Dwiggins pisze: > Use the Singleton pattern when > - there must be exactly one instance of a class, and it must be > accessible to clients from a well-known access point. One in what? In the world? In all runs of the process? In the current run of the process? In a large subcomputation? Why would you create an arbitrary scope of life? > - when the sole instance should be extensible by subclassing, and > clients should be able to use an extended instance without modifying > their code. If subclassing would alter the behavior of the object - what would happen if several clients alter it in incompatible ways? Global implicit state rarely makes sense; mainly for interfacing with the OS and supporting the runtime system of the language. It's inflexible - with global state you can't take the meaning of the program and execute it twice in the process, you can't take a part of the program and execute it in a different context (it's will not be self-contained), threading may be problematic. It's nothing wrong when a stateless data is global. For example function definitions and class definitions are almost always stateless. Immutable or lazily evaluated data which doesn't depend on the process environment is stateless. These are fine because it doesn't matter when it's created and in how many copies - they statically define the program. But state, i.e. objects with meaningful identity, should be managed explicitly. As a quick hack in small scripts it can be convenient to have a global variable or two, but it's inflexible. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From gerrie at trispen.com Fri Jun 1 03:01:12 2001 From: gerrie at trispen.com (Gerrie Roos) Date: Fri, 01 Jun 2001 09:01:12 +0200 Subject: Zope questions and comments (&Tkinter???) References: <3B158C50.887E3D59@earthlink.net> Message-ID: <3B173DB8.F3C5CC65@trispen.com> I'm no python/zope guru, but from my little experience i'd say do check out zope further. I started zope without any python knowledge even, so i suppose that made it even a bit more tricky to get my head around it...especially the part where you call zope methods with parameters from zope tags...argh...but its getting better now. so i'd say for someone with some python background, go for it...if you know some basic html and forms, you'll find it fairly easy to make some nice pages and do backend stuff with python. even if you don't use all the zope features, its worth it just for the management interface, security, etc...all kinds of stuff you might not think you need now, but it would be easy to implement once you know its there and you see all kinds of need for it. i mean, what if your little site wants to grow into something bigger? do join the zope mailing list... zope at zope.org Ron Stephens wrote: > I am interested in Zope and I have few questions. My interest is in > running a "simple" Zope based web server in order to have the ability > to run server side Python scripts; I might eventually be interested in > the object oriented database aspects of Zope, but it is not clear > whether I would be able to devote enough time and energy to actually be > able to do so. Someone recommended a Zope based hosting service named > hurrah.com and it looks good to me at first glance. I downloaded Zope > and fooled around a few weeks ago, it looked good but complex. My > questions: > > 1. Will Zope be too complex for me??? Specifically, if my primary > interest, in the short run, is to be able to run server side scripts > written in Python (or at least in a Python-like language) , will Zope > allow me to do this? Or will writing scripts in Zope be so complex that > it renders void my attraction for writing in Python because it is simple > and intuitive, i. e. , rather easy and enjoyable? > > 2. I have already discovered that the gui type input/output functions of > my scripts are the hardest part for me. I am only interested in simple > input and output by end users, but I want it to look good and be user > friendly. I do not need fancy graphics nor multimedia, just well > designed attractive forms and user input followed by outputed results in > verbal and numerical form. Will this kind of input/output be a big > problem using Zope? I almost don't dare ask, but I assume Tkinter will > not be supported by Zope? Will I really need to resort to other means, > such as JavaScript, to do such things ??? How straight forward is input > and output, in event driven programs, in server side scripting using > Zope??? > > 3. Would I be better served by using CGI, once I find a host that allows > me to do so? If CGI scripts written in Python are just as easy and > flexible as using Zope, maybe that's the way for me to go in the > beginning. I will still need to find a Python CGI friendly host company. > > 4. Any suggestions on host companies for Python and/or Zope? > > 5. I do have an always-on cable modem connection in my home. Should I > consider setting up a very simple web server on my own machine (rather > than finding a Zope Host?). If I could set up such a simple server, > allowing me to run server side Python scripts, or even CGI, I could link > to those pages from my other web site, on my non-Python non-CGI friendly > web host site. > > 6. Is Zope simply so complex that I will soon forget about why I enjoy > Python, i. e., intuitive, easy to use fun coding? > > General and unrelated comment, for no particular reason, but it comes to > mind in thinking about what I want to do in the project I have in > mind::: > > It seems to me that Python offers straight forward, self consistent, > logical coding. I like that! But any kind of GUI coding, including > Tkinter, seems to me to be less intuitive, less consistent; involving > more memorization of lots of non-connected facts. Python allows me to > memorize principles and consistently and easily implement them. Most GUI > programming seems more like I recall Java or even JavaScript coding; > random, unconnected stuff that is no fun because it's detailed and > random > > sorry for the rant. please disregard ;-))))) From candy1982 at aol.com Fri Jun 15 09:31:57 2001 From: candy1982 at aol.com (Candy) Date: 15 Jun 2001 13:31:57 GMT Subject: LIVE TEEN CAM in my ROOM! Message-ID: <9gd2od$ntg$18804@cyan.nl.gxn.net> http://jarnc.tripod.com BONDAGE CAMS, EVERYTHING for FREE!!! Just visit or mail me, or SEE ME AT http://jarnc.tripod.com Love, CaNdY! ;) From rcstadheim at scarabweb.com Fri Jun 22 22:01:31 2001 From: rcstadheim at scarabweb.com (RCS) Date: Sat, 23 Jun 2001 04:01:31 +0200 Subject: SV: brazil References: Message-ID: Hello! I will be in Brazil shortly (this summer) if that helps! Regards, RCS Edson Tavares de Camargo skrev i meldingsnyheter:mailman.993153153.9557.python-list at python.org... > hello! > There are somebody of Brazil in list?? > > Edson > From pras_patel at yahoo.com Wed Jun 27 00:52:11 2001 From: pras_patel at yahoo.com (prashant patel) Date: 26 Jun 2001 21:52:11 -0700 Subject: Web Application framework (python/java) Message-ID: I am Intrested in created a web application famework, on which and developer,a web novice and created his application. I also wanted to make it in python. since i have my skill in java, it is also a potential. but since python is more productive i would like to make it in python, also the time constraint in which i have to devliver this product. My question is java has a lot of web related tools, since i am new to python i am not familair with the web libraries in python,also going through core python programming quickly to find out what i can do with it. i want to do it in python, can it be a language to concieve the "web application famework". please give your thought and suggestion. prashant. From sholden at holdenweb.com Mon Jun 18 17:31:24 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 18 Jun 2001 17:31:24 -0400 Subject: Any other Python flaws? References: <3B2A5F6A.5A61183@destiny.com> Message-ID: "Michael Hudson" wrote in message news:m3d78161uz.fsf at atrus.jesus.cam.ac.uk... > D-Man writes: > > > On Fri, Jun 15, 2001 at 02:18:04PM -0500, Michael Chermside wrote: > > | Oh well... at least people don't bump into this one much. And if you > > | accidently clobber it, you can restore things with: > > | > > | def __None(): > > | pass > > | None = __None() > > > > Well, that doesn't work. One of the key features of 'None' is that > > there only ever exists a single instance. This would create a new, > > unique, instance bound to (a more local) 'None'. > > No it wouldn't. Try it! > > I agree that what Michael posted doesn't really do what he wanted; but > it doesn't do what you said, either. > > Cheers, > M. > PythonWin 2.0 (#8, Mar 7 2001, 16:04:37) [MSC 32 bit (Intel)] on win32. Portions Copyright 1994-2001 Mark Hammond (MarkH at ActiveState.com) - see 'Help/About PythonWin' for further copyright information. >>> del __builtins__.None [PythonWin goes completely AWOL and must be terminated: even "break into running code" does nothing. On terminating the main window, PythinWin displays a dialog box entitiled "Python traceback when executing ExitInstance handler" in which you see the message "exceptions.NameError: There is no variable named 'None'"] However, in a DOS window: C:\WINDOWS>python ActivePython 2.0, build 203 (ActiveState Tool Corp.) based on Python 2.0 (#8, Mar 7 2001, 16:04:37) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> del __builtins__.None >>> None Traceback (most recent call last): File "", line 1, in ? NameError: There is no variable named 'None' >>> def fn(): ... pass ... >>> fn() >>> print repr(fn()) None >>> None Traceback (most recent call last): File "", line 1, in ? NameError: There is no variable named 'None' >>> The interpreter is designed to reproduce a vestigial environment even when crucial builtins like None disappear. This doesn't mean it's a good idea to disappear them... Also, you should remember that an assignment to None in the local module namespace doesn't change the real None, which lives in the __builtins__ namesapce. regards Steve -- http://www.holdenweb.com/ From aahz at panix.com Mon Jun 4 11:00:36 2001 From: aahz at panix.com (Aahz Maruch) Date: 4 Jun 2001 08:00:36 -0700 Subject: Python as REXX replacement? References: <9fg5l3$deo$1@news.rchland.ibm.com> Message-ID: <9fg7qk$81m$1@panix3.panix.com> In article <9fg5l3$deo$1 at news.rchland.ibm.com>, Larry Whitley wrote: > >A friend in Poughkeepsie currently uses REXX as his scripting language but >is becoming increasingly interested in Python. He asked if there is a >version that runs on the IBM 390 systems under VM or MVS? Does a port to >390 (also known as zSeries) exist? Well, I'm sure Python's available on Linux on a 390, but I haven't seen any info about a direct port to VM or MVS. There's an AS/400 project; perhaps you should get in touch with those folks. Note: one missing feature in Python from the REXX perspective is extended-precision floating-point decimal arithmetic. I'm currently working on fixing that; in the meantime, you can use FixedPoint.py as a mostly-suitable replacement. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 I surf faster than you do, monkey boy. (My take on Netscape vs. Lynx) From dsh8290 at rit.edu Tue Jun 19 16:22:05 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 19 Jun 2001 16:22:05 -0400 Subject: Obsolesence of <> In-Reply-To: ; from mertz@gnosis.cx on Thu, May 31, 2001 at 07:24:09PM -0400 References: Message-ID: <20010619162205.A7294@harmony.cs.rit.edu> A while ago many people stated that the "<>" spelling of the inequality operator is not obsolete, and actually preferred by some (with Pascal-ish backgrounds). While looking through the Ref. Man. on a totally unrelated topic, I noticed the following : ============================= The forms <> and != are equivalent; for consistency with C, != is preferred; where != is mentioned below <> is also accepted. The <> spelling is considered obsolescent. ============================= This newsgroup seems to think that last sentence is erroneous. Does anyone want to "fix" the ref man ? (http://www.python.org/doc/current/ref/comparisons.html) At-least-I'm-not-senile-yet-ly y'rs -D From jeremy at alum.mit.edu Tue Jun 19 22:12:08 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Tue, 19 Jun 2001 22:12:08 -0400 Subject: New statement proposal for Python Message-ID: Tim Peters wrote: > [Greg Ewing] >>Instead of introducing a new syntax, however, I'd rather >>see some work done on the implementation of module >>namespaces to make them more like local namespaces >>are now -- i.e. so that names the compiler knows about >>are accessed by indexing into an array instead of >>looking up a dictionary. >> >>I think this would be a much more worthwhile investment >>of effort, since it would benefit *all* accesses to >>globals, not just "constant" ones! >> > > I agree. Jeremy was looking into this seriously, but the month he intended > to work on it got lost when paternity leave came a month earlier than > planned. So, blame God or not, but there's no bandwidth at PythonLabs to > look into this now. Would still make a good PEP. I posted some notes on python-dev for a PEP I was working on before the babies came: http://mail.python.org/pipermail/python-dev/2001-May/014995.html Subject: pre-PEP on optimized global names I think the draft I posted there doesn't go into much detail about the changes to the interpreter internals. I think there are a lot of issues there, not least of which is that there is no builtin dictionary type that represents the globals of a module. This is one instance of many changes that programmers using the C API would need to cope with. Perhaps 2.2 is the right time to make these changes, since the C API will probably change a lot anyway. I don't know what the PEP deadline or alpha release schedule is for 2.2, so it's hard to say if it's too late. If someone wants to pick up these notes and draft a full PEP, I'd be thrilled. I can't promise much help, although I'd like to. Jeremy From darked at my-deja.com Fri Jun 15 18:38:45 2001 From: darked at my-deja.com (Darek Kedra) Date: 15 Jun 2001 15:38:45 -0700 Subject: MySQLdb-0.3.5 build problem (/usr/bin/ld: cannot find -lz) Message-ID: Hi, I'm trying to install MySQLdb-0.3.5 with python 2.1 on Mandrake 8.0. After: # python setup.py build I am getting: <--snip--> running build_ext building '_mysql' extension skipping _mysqlmodule.c (build/temp.linux-i686-2.1/_mysqlmodule.o up-to-date) gcc -shared build/temp.linux-i686-2.1/_mysqlmodule.o -L/usr/lib/mysql -lmysqlclient -lz -o build/lib.linux-i686-2.1/_mysql.so /usr/bin/ld: cannot find -lz collect2: ld returned 1 exit status error: command 'gcc' failed with exit status 1 I did: "export LD_LIBRARY_PATH=/lib:$LD_LIBRARY_PATH" but to no avail. How to solve it? Thanks a lot for your help. Darek Kedra From uioziaremwpl at spammotel.com Wed Jun 20 20:00:52 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Thu, 21 Jun 2001 02:00:52 +0200 (CEST) Subject: Any other Python flaws? In-Reply-To: <9gr8c1$hhq$3@newshost.accu.uu.nl> Message-ID: On 20 Jun 2001, Martijn Faassen wrote: > Carsten Geckeler wrote: > > On 18 Jun 2001, Martijn Faassen wrote: [snip] > >> But since single element tuples are a wart by themselves, this extra > >> magic is necessary. Perhaps a language is possible where single > >> element tuples actually are single elements, though that may introduce > >> other warts. > > > So that's your point. > > Not the only point. I still think I have a point that the mandatory > () around a tuple in that place are a wart. I'd have liked it to > be different but that would mean a change in Python's precendence rules > that would probably cause other annoyances. OK, let's assume we make "," higher precedence as "%". Then you can write the following lines of code: print "%x" % 1 # gives "0x1" print "%x %x" % 1, 2 # gives "0x1 0x2" But when you want to add other elements to the list, you have to do the following print ("%x" % 1), 2 # gives "0x1 2" Same as for the next: x = [1, "%i" % 2, 3] has to be written with changed precedence as x = [1, ("%i" % 2), 3] So a changed precedence would have drawbacks like the current one. I admit that the usage of % taking all following elements is more frequent. But as you pointed out, changing it now is almost impossible. And there is the "%" operator in numeric scope, where a list as second argument makes no sense, as in (5%2, 2). So from my POV, the current implementation is the best. > > But then propose another way of making one-element > > tuples. BTW, I don't see "(1,)" as magic, more as simple given syntax. > > I see the single element syntax as 'magical syntax', just like: > > print "foo", > > is magical syntax. It's just syntax that isn't very pretty as everwhere > else the comma implies there either is another element coming or that if it's > the last element, the comma is ignored. That's a problem with the "plug and play" print statement of Python. It's convinient in most cases, but makes other things very hard. The last time I've encountered a print statement as in Python before was with my old Sinclair Spectrum 48K and the included Basic. :) > 'magic' (here Martijn defines magic) is where something suddenly behaves > different in a way that's outside of an easy to predict pattern that > holds elsewhere. It's where hard to detect subtleties can have uncommonly > large effects. Where the mind stumbles. > > > Since the curly brackets {} are used for dictionaries, normal brackets [] > > for lists, there are only the parenthesis () left. And since they are > > used for grouping, this special case for one-element tuple is needed. > > Although I admit that I doesn't look very nice, I don't see any > > alternatives. > > And the parenthesis aren't even necessary for tuples, which is nice in > some circumstances. But in an ideal world there would be another type of > brackets on my keyboard. :) I can find the angles <> here on mine! But how to handle the following? ;) x = <1, 2>3, 4> Or how about << >>? Cheers, Carsten -- Carsten Geckeler From geoff at homegain.com Thu Jun 14 15:28:52 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Thu, 14 Jun 2001 12:28:52 -0700 Subject: VI Message-ID: <393D961EA4FCD311B03F00D0B746D65803275EA5@HQSXCH01> > From: Emile van Sebille [mailto:emile at fenx.com] > > I always liked the description that vi has two modes: one > beeps at you, and > the other destroys your file. ;-) Hee! There's a lovely section in the 'JOKES' file that goes out as part of emacs (on my old-ish RH box, in /usr/share/emacs/20.5/etc/JOKES) that describes "a typical novice's session with the mighty ed". I always found that particularly amusing, because it described my early experiences with vi quite nicely: ----BEGIN QUOTE---- golem> ed ? help ? ? ? quit ? exit ? bye ? hello? ? eat flaming death ? ^C ? ^C ? ^D ? Note the consistent user interface and error reportage. Ed is generous enough to flag errors, yet prudent enough not to overwhelm the novice with verbosity. -----END QUOTE----- On the other hand, I use vim religiously now. I can't imagine editing in anything else. I've used emacs, and it used to drive me absolutely insane the way 9/10 of what I wanted to do required typing M-x really-longass-function-name, and how I had to re-bind my keyboard to be useful on every new machine I worked on. I resisted the vi religion at first, despite the efforts of my kernel-hacker co-workers to convert me, but once I got the basic commands under my fingers, there was no looking back. I won't install emacs any more, if I'm building my own machine. Novices can use pico, and I can always stand to have the extra gig of disk space for something I'll use. :) Thanks, --G. --- Geoff Gerrietts Software Engineer, HomeGain.com 510-655-0800 x4320 From steve.waterbury at gsfc.nasa.gov Mon Jun 18 11:45:13 2001 From: steve.waterbury at gsfc.nasa.gov (Steve Waterbury) Date: Mon, 18 Jun 2001 11:45:13 -0400 Subject: Problems with PYTHONPATH in generated Makefile for 2.1 Message-ID: <3B2E2209.56BE6725@gsfc.nasa.gov> There seems to be a problem with the way PYTHONPATH is set up in the configure-generated Makefile for Python 2.1. In order to build Python 2.1 from source on Solaris (I don't know about other platforms), I had to make some adjustments. I'm not sure if the way I did it was the best way. Specifics: I was trying to build Python 2.1 on Solaris 2.6 (on a SPARC 20), using Sun's compiler (Sun WorkShop 6 update 1 C 5.2 2000/09/11). Every time the build process got down to setup.py, it would die, saying (some additional lines are quoted for context): ---------------------------------------------------- .... cc -mt -o python \ Modules/ccpython.o \ libpython2.1.a -lpthread -lsocket -lnsl -ldl -lthread -lm PYTHONPATH= ./python ./setup.py build 'import site' failed; use -v for traceback Traceback (most recent call last): File "./setup.py", line 9, in ? import sys, os, getopt ImportError: No module named os *** Error code 1 make: Fatal error: Command failed for target `sharedmods' --------------------------------------------------- I got it to work by commenting out the following statements in the Makefile: # PYTHONPATH=$(COREPYTHONPATH) # COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(TESTPATH)$(MACHDEPPATH)$(TKPATH) ... and setting PYTHONPATH in root's environment as PYTHONPATH=$SRCDIR:$SRCDIR/Lib export PYTHONPATH I don't really know if this is the right solution, but I know there is a problem, and this appeared to solve it. -- Steve. From mwh at python.net Fri Jun 15 03:47:40 2001 From: mwh at python.net (Michael Hudson) Date: 15 Jun 2001 08:47:40 +0100 Subject: Any other Python flaws? References: <9gbe4e$gla$2@newshost.accu.uu.nl> Message-ID: barry at digicool.com (Barry A. Warsaw) writes: > Another one is the fact that you can't mix try/finallys with > try/excepts. Isn't the usual argument about this one that it's not obvious what gets executed when? Eg. does try: raise Exception except Exception: pass finally: print "hullo" print "hullo"? I guess so. Still, the explicitness of what you have to do now seems to me to be a win over the pain of multiple indentations. Cheers, M. who has, on occasion, written functions that start with three successive "try:"s... -- People think I'm a nice guy, and the fact is that I'm a scheming, conniving bastard who doesn't care for any hurt feelings or lost hours of work if it just results in what I consider to be a better system. -- Linus Torvalds From nas at python.ca Wed Jun 20 10:44:54 2001 From: nas at python.ca (Neil Schemenauer) Date: Wed, 20 Jun 2001 07:44:54 -0700 Subject: PEP 255: Simple Generators In-Reply-To: ; from rnd@onego.ru on Wed, Jun 20, 2001 at 02:08:05PM +0400 References: <31575A892FF6D1118F5800600846864D78BD63@intrepid> Message-ID: <20010620074454.E16584@glacier.fnational.com> Roman Suzi wrote: > > Pipes instead of generators: > > q = openpipe() > > def g(pipe): > for i in range(10): > pipe.put(i) # this brings g into sleep till pipe is read > raise StopIter # this will be raised where reading from pipeoccurs AFAIK, something like this cannot be implemented in Jython. Neil From sebrosa at artenumerica.com Fri Jun 1 19:26:39 2001 From: sebrosa at artenumerica.com (Jose' Sebrosa) Date: Sat, 02 Jun 2001 00:26:39 +0100 Subject: Obsolesence of <> (fwd) References: Message-ID: <3B1824AF.5BBDA@artenumerica.com> Lulu of the Lotus-Eaters wrote: > > Jose' Sebrosa wrote: > |The problem with complexes is to arrange them in a unidimentional structure. As > |we can map R to C (and vice-versa), it is possible: > |[...complex mapping C --> R...] > |Thats the only way I can figure to invent a comparison between two complexes, > |and it seems preety absurd to me... > > Here's an obvious way to well-order two complex numbers: > > def lexigraphic_order(c1,c2): > if c1.real < c2.real: return -1 > elif c1.real > c2.real: return 1 > else: return cmp(c1.imag,c2.imag) > > For most purposes, the lexigraphic order has little mathematical use. > Here's another obvious one that has a bit of mathematical meaning: > > def magnitude_order(c1,c2): > if c1==c2: return 0 > elif abs(c1)==abs(c2): return cmp(c1.real,c2.real) > else: return cmp(abs(c1),abs(c2)) > > I-could-probably-even-order-unicode-strings-ly yours, Lulu... Sure, you are all right and I was overcomplicating it all. I like most the map-complexes-to-tuples-then-compare-tuples approach, but these could also do. Sebrosa From aleaxit at yahoo.com Thu Jun 14 10:38:19 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 16:38:19 +0200 Subject: substitute for c/java's ?: References: <9ga8ue$7aj$07$1@news.t-online.com> Message-ID: <9gai91052m@enews1.newsguy.com> "Jochen Riekhof" wrote in message news:9ga8ue$7aj$07$1 at news.t-online.com... ... > /**Utility which returns 'a' or 'an' for a given noun. */ > public static final String aan(String name) { > return ("aeiou".indexOf(name.toLowerCase().charAt(0)) < 0) ? "a" : > "an"; > } > > which, compared to > > def aan(name): > """Utility which returns 'a' or 'an' for a given noun. > """ > if string.lower(name[0]) in ('a','e','i','o','u'): > return 'an ' > else: > return 'a ' > > is not all that bad ;-). Of course you can use if else you like this better. If you like the horrid oneliner style above, def aan(name): return ("a","an")[name[0].lower() in "aeiou"] is the Python equivalent. Why the H**K would one code "in ('a','e','i','o','u')" rather than the exactly equivalent "in 'aeiou'", for example? I'd slightly prefer the following non-strict-equivalent: return ("a","an")[name[0] in "aeiouAEIOU"] but that doesn't substantially change the oneliner- mentality behind such opaque coding...:-). Alex From kjcole at well.com Wed Jun 20 15:04:25 2001 From: kjcole at well.com (Kevin Cole) Date: 20 Jun 2001 12:04:25 -0700 Subject: re.match(...) fails to find a match Message-ID: Hi. I'm using Python 1.5.2 under Linux, and wish to find and replace several special characters (punctuation characters). So, I've been attempting to test a basic match and cannot get it to return anything. How would I match any of [/|&{}#@^~\"] (excluding the delimiting square brackets? Just attempting to get an ampersand working, I've tried: p = re.compile('[&]+') p = re.compile(r'[&]+') p = re.compile(r'[\&]+') p = re.compile('[\&]+') p = re.compile('[\\&]+') p = re.compile('[\\\&]+') p = re.compile('[\\\\&]+') and every other combination of r'...' and '\\\...' I can think of. I've tried it without the square brackets, and even with an extra set of brackets. But print p.match('This string & that string') always returns "None". From loewis at informatik.hu-berlin.de Sun Jun 17 04:37:50 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: Sun, 17 Jun 2001 10:37:50 +0200 (MEST) Subject: Writing new codecs In-Reply-To: <002801c0f6a8$932a5ea0$445d4540@D1XYVL01> (brian@sweetapp.com) References: <002801c0f6a8$932a5ea0$445d4540@D1XYVL01> Message-ID: <200106170837.KAA02291@pandora.informatik.hu-berlin.de> > > I hope not. New codecs should certainly use their own modules, which > > still leaves the question whether these should be C or Python modules. > > That would be a bit odd too, I think. The number of C modules in Python > could really blow up. Please have a look at http://sourceforge.net/projects/python-codecs. There are a few additional codecs, and none of them extends _codecs. Each of the modules provides a set of codecs, not a single one. Personally, I think on systems that offer iconv, the iconv codec should be the only one you'd ever need - although the UTF-7 converter is supported in gconv only starting with glibc 2.2. Regards, Martin From aleaxit at yahoo.com Sun Jun 3 05:03:19 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 3 Jun 2001 11:03:19 +0200 Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> Message-ID: <9fcumq0215o@enews2.newsguy.com> "Nick Perkins" wrote in message news:A3iS6.121059$eK2.28202517 at news4.rdc1.on.home.com... ... > > """ > > A physical RNG can have the property that one cannot make > > any prediction about the value of the next bit even given > > _complete_ information about how the numbers are being > > generated. > > """ ... > This is not a contradiction. > > if we define predicates: > I : have complete information > P : can make prediction > > then the first statement is: > I implies (not P) Ah, there's the rub of our disagreement: I read the 1st stmt as: not (I implies P) That is, in natural language, I don't read a statement "the fact of having complete information implies I cannot make a prediction" (which would afford some inference, the way natural language is commonly used, that maybe NOT having complete information might make things better!), but rather "it's not the case that having complete information implies I can make a prediction", i.e., "DESPITE having complete information, I _still_ could not make a prediction". "Even given (a powerful army) I could not (defeat Napoleon)". Do you read this as "having a powerful army IMPLIES I cannot defeat Napoleon"? This doesn't sound right to me. Surely it's "NOT (having a powerful army IMPLIES I can defeat Napoleon)"? "Even (using Python) I cannot (make my GUI pretty)". Do you read this as it being the fact of using python that IMPLIES my inability to make GUIs pretty? Surely the 'Even' removes all doubt -- if you *didn't* have it in the original sentence your reading would be quite sensible. But what is that 'even' doing there if not EXACTLY impliying the reading is NOT: (using Python) IMPLIES (no pretty GUI) but rather NOT ( (using Python) IMPLIES (pretty GUI) ) ...? Alex From jm7potter at hotmail.com Tue Jun 26 12:19:59 2001 From: jm7potter at hotmail.com (Joe Potter) Date: Tue, 26 Jun 2001 12:19:59 -0400 Subject: newbie with major "lambda" problem (perhaps a scope problem as well) References: Message-ID: On Tue, 26 Jun 2001 16:09:06 GMT, "Rainer Deyke" wrote: >"Joe Potter" wrote in message >news:j5ahjtkfmf32lkqtap0q1u6rig385d7b5i at 4ax.com... >> # the "button" below works like a champ !! >> #Button(root, text='Fetch', >> #command=(lambda v=vars: fetch(v))).pack(side=LEFT) >> >> # the "button" below does not do anything ?????? >> Button(root, text='Fetch', command=(fetch(vars))).pack(side=LEFT) > >Of course this doesn't work. It calls 'fetch(vars)', and passes the result >to 'Button'. Use the lambda, that's what it's there for. Or use one of the >'curry' alternatives (see archives). My question is *why* the lambda is allowed to call the perfectly defined function fetch, but a direct call of fetch is not. In other words --- I already knew that I had to use lambda, but I do not know why! In the 6 or 7 other languages I have used over time --- if you call a defined function it works --- but in Python there is a mystery here. Or, perhaps the mystery is deep down in Tkinter? Regards, Joe From aleaxit at yahoo.com Tue Jun 12 11:27:47 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 12 Jun 2001 17:27:47 +0200 Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: <9g5486016t4@enews2.newsguy.com> <9g57h5$7bkkg$1@ID-11957.news.dfncis.de> Message-ID: <9g5cdk01lb9@enews2.newsguy.com> "Emile van Sebille" wrote in message news:9g57h5$7bkkg$1 at ID-11957.news.dfncis.de... > > "Alex Martelli" wrote in message > news:9g5486016t4 at enews2.newsguy.com... > > > Those guys and gals have never seen a 'printing terminal', > > Totally off topic: > > But this reminds me of remotely debugging an HP 2000 Basic app designed to > run on a Hazeltine 1500 block mode terminal. We followed the code while > the user talked us through his steps. No way was this happening. We asked > him to go slower, and tell _everything_ he did. Only when he got to "... > then I scroll the paper back..." did we figure out he was on a TI810 hard > copy terminal. ;-) I'll always have a soft spot in my heart for printing terminals, most particularly the LA36 Decwriter which saved my a**e back when I was working on my thesis. We had been working for months, porting a partial APL-coded prototype (originally coded on a rock-solid IBM 370 system which we could only access remotely) to a new, yet-unstable VAX 11/780 (Fortran and assembler) -- and for reasons I can only describe as somewhat fetishistic I kept all of the interactive-session printouts (sometimes being a pack rat helps...). One day, the system disks died... and the tape drives had not been installed yet! POOF, all of our work gone, just like that. All EXCEPT the paper trail, that is... in less than a week (a somewhat frantic one:-), it was all back in the machine again (so I did eventually manage to get my "Laurea"!-). Some months later, I was working for IBM Research, a well-funded place with glass terminals, and the somewhat-peeved machine-room operator wanted to know how come I was printing out session logs twice daily and never recycling the paper... (admittedly, a dead disk on a production machine WAS an unknown occurrence there, AND, just in case, tape backups WERE religiously kept, but...:-). Eventually I did have to accept that I couldn't keep clogging my office with that much paper, but I was really on edge for a while when I did stop...:-) Alex From matchison at ufm.org Mon Jun 18 13:08:07 2001 From: matchison at ufm.org (Marshall) Date: 18 Jun 2001 10:08:07 -0700 Subject: ftplib possible bug? Please help. Message-ID: <4b866f80.0106180908.31a3b6b5@posting.google.com> I am using Python 2.0 on NT 4.0 When I ftp a file from one NT server to another, using ftplib, it changes the end of the line from CRLF to LF. It does this EVEN when the transfer is Binary. Passive mode or not passive does not make a difference either. Is this a known problem? and is there a fix? Thanks. From thomas.heller at ion-tof.com Tue Jun 26 02:39:45 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Tue, 26 Jun 2001 08:39:45 +0200 Subject: DistUtils and optimized compile References: <3B375869.E417C833@stroeder.com> <9h7lng$cdpjl$1@ID-59885.news.dfncis.de> <3B375F47.64A232D2@stroeder.com> <9h7nlg$cbtbq$1@ID-59885.news.dfncis.de> <3B37CAB1.D200EADC@stroeder.com> Message-ID: <9h9ak6$c9m0q$1@ID-59885.news.dfncis.de> "Michael Str?der" wrote in message news:3B37CAB1.D200EADC at stroeder.com... > Thomas Heller wrote: > > > > python setup.py install -O1 > > Anything similar for compiling optimized byte-code into a RPM with > python setup.py bdist_rpm ? Totally clueless here. Anyone else? Thomas From aleaxit at yahoo.com Sun Jun 3 05:14:14 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 3 Jun 2001 11:14:14 +0200 Subject: Python and databases References: <991557251.316332@seven.kulnet.kuleuven.ac.be> Message-ID: <9fcv2j021uk@enews2.newsguy.com> "Pieter Laeremans" wrote in message news:991557251.316332 at seven.kulnet.kuleuven.ac.be... > Hi, > > Does python has something like perl 's DBI? > I can 't find any documentation about it in the python docs. http://www.python.org/topics/database/ The problem may be finding complete implementations of the current (release 2.0) DB-API spec, but that depends on a lot of factors: are you going to make commercial use of it, and in that case do you have funding -- for non-commercial use, OR for pay in the case of commercial use, you can get Lemburg's excellent mxODBC implementation (if ODBC is what you want to use). You can also get implementations for quite a few specific database engines. Alex From robin at jessikat.fsnet.co.uk Tue Jun 19 07:51:21 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Tue, 19 Jun 2001 12:51:21 +0100 Subject: ReportLab 1.08 Released Message-ID: Version 1.08 of the ReportLab toolkit has been released. This is mostly a bugfix/enhancement release. Most of the changes are related to attribute handling in graphics widgets. We have improved the support for 2.1. Initial support for Mac OS 9 has been done (thanks to Just van Rossum) and accelerator binaries are available at http://www.reportlab.com/ftp/mac-dlls/ -- Robin Becker From johnroth at ameritech.net Wed Jun 27 01:00:52 2001 From: johnroth at ameritech.net (John Roth) Date: Tue, 26 Jun 2001 22:00:52 -0700 Subject: newbie with major "lambda" problem (perhaps a scope problem as well) References: Message-ID: "Joe Potter" wrote in message news:n8dhjt8qmel0ajjae7tv9gmjf60c39qag5 at 4ax.com... > On Tue, 26 Jun 2001 16:09:06 GMT, "Rainer Deyke" wrote: > > >"Joe Potter" wrote in message > >news:j5ahjtkfmf32lkqtap0q1u6rig385d7b5i at 4ax.com... > >> # the "button" below works like a champ !! > >> #Button(root, text='Fetch', > >> #command=(lambda v=vars: fetch(v))).pack(side=LEFT) > >> > >> # the "button" below does not do anything ?????? > >> Button(root, text='Fetch', command=(fetch(vars))).pack(side=LEFT) > > > >Of course this doesn't work. It calls 'fetch(vars)', and passes the result > >to 'Button'. Use the lambda, that's what it's there for. Or use one of the > >'curry' alternatives (see archives). > > > My question is *why* the lambda is allowed to call the perfectly defined function > fetch, but a direct call of fetch is not. > > In other words --- I already knew that I had to use lambda, but I do not know why! Since I tripped over this a few times before I got it through my head, here's an attempt to explain. In Python, functions are objects. If you say something like >>>name = foo() you're calling the function foo with a null parameter list, and the result will be whatever foo() returns. if you say >>>name = foo you're binding name to the function object "foo", not calling it. Later, you can say something like >>>name() and it should return whatever foo() does! When you use a lambda as a command arguement in a Tkinter call, you're actually passing a function object to Tkinter. Later, Tkinter will invoke that function object when it needs to do a callback. if you wanted to say "command = lambda: foo()", you could just as easily say "command = foo". Notice the lack of parenthesis! What you can't do is use this to pass parameters to foo, because that would cause it to be executed, rather than pass the function object. Lambda gets around this problem with a "neat hack." When I say something like: command = lambda a=x, b=y: foo(a, b) Then in effect I'm building an unnamed function definition, and assigning default values to the two parameters. Those default values will travel with the definition, so when Tkinter calls it later, they will be availible to the actual execution. The call of foo(a,b) in the definition above is part of the definition - it won't be executed until the function object is executed later. John Roth > > > > Regards, Joe From emile at fenx.com Fri Jun 29 21:51:43 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 29 Jun 2001 18:51:43 -0700 Subject: Augmented Assignment (was: Re: PEP scepticism) References: Message-ID: <9hjbk0$dvtqt$1@ID-11957.news.dfncis.de> It's nothing that examining the id doesn't resolve: >>> a = [1,2,3] >>> id(a) 18916180 >>> a += [4,5] >>> a [1, 2, 3, 4, 5] >>> id(a) 18916180 >>> b = (1,2,3) >>> id(b) 15261292 >>> b += (4,5) >>> b (1, 2, 3, 4, 5) >>> id(b) 18736580 >>> I think that once new users distinguish the object from the label things start to fall into place appropriately. -- Emile van Sebille emile at fenx.com --------- "Paul Prescod" wrote in message news:mailman.993841846.2132.python-list at python.org... > Guido van Rossum wrote: > > > >... > > > > The right way to think about this is "list objects are mutable and > > tuples are not". So if you want to give a library function a sequence > > object of yours but you don't want it to be changed, pass it a tuple. > > If you want it to be changed (or don't care) pass it a list. > > My point is that it is hard for a new user to "believe me" (or at least > understand me) when I say that tuples are not mutable but they see them > changing right in front of their eyes: > > >>> a=(1,2,3) > >>> a+=(8,3) > > The old behaviors strongly emphasized the non-mutability of things. The > new operators undermine that understanding. Maybe the benefits outweigh > this cost but I've seen this misunderstanding myself so I know it is a > real cost. > -- > Take a recipe. Leave a recipe. > Python Cookbook! http://www.ActiveState.com/pythoncookbook > From support at internetdiscovery.com Wed Jun 20 04:07:26 2001 From: support at internetdiscovery.com (Mike Clarkson) Date: Wed, 20 Jun 2001 08:07:26 GMT Subject: idle BUG References: <3b2e552f.2621005@nntp.ix.netcom.com> <2MTskUAVjoL7Ewqc@jessikat.fsnet.co.uk> Message-ID: <3b2fb646.442466@24.0.228.33> On Tue, 19 Jun 2001 00:03:49 +0100, Robin Becker wrote: >In article <3b2e552f.2621005 at nntp.ix.netcom.com>, Mike Clarkson > writes >.... >>Robin, try this (you'll have to fix the tk.eval lines back up to be >>all one line). In Tkinter.py, change quit() to >> >> def quit(self): >> """Quit the Tcl interpreter. All widgets will be destroyed.""" >> self.tk.eval('foreach w [winfo child .] {wm protocol $w >>WM_DELETE_WINDOW {}; catch {destroy $w}}') >> self.tk.eval('catch {set w .; wm protocol $w WM_DELETE_WINDOW >>{}; destroy $w}') >> self.tk.quit() >> >>If it works for you, I'll explain why it's required under Tkinter, but >>not Tk. >> >>This makes self.quit() do what it's documented to do, and leaves >>self.tk.quit (which is _tkinter.quit) to do what it does now, namely >>signals the mainloop to end but destroys no widgets. >> >... >sorry my app hangs as before. have you got other changes in place? >>Mike. No, it's a vanilla ActiveState 2.1, but it's on Windows 98 which differs a little from Win95. The only change is this self.quit patch. Make sure you are not calling or binding self.tk.quit() - use the patched self.quit() instead. self.tk.quit() is the _tkinter quit, which just says bail out of the self.tk.mainloop(). It doesn't destroy any windows, delete any Tk intepreter or even delete any of the tcl commands declared in Python as callbacks. So it's not at all like a Tk [exit]. If you take idle as an example, after the .mainloop() statement in PyShell, add the following in main() (NB: console application only): root.tk.eval('puts [winfo child .]') after the root.mainloop() You'll see that after idle exists its mainloop, there are two Tk toplevel windows still alive: . and .123456 (some number). It's because root.tk.quit() does not destroy any windows. My patched root.quit() makes sure they're all destroyed. My theory was/is that the undestroyed windows might be stopping Python from unloading the Tk and exiting cleanly. Note that the next statement in idle main() root.destroy() doesn't destroy any Tk windows or intepreter. It's an internal function that deletes the Python callback functions. It should probably be renamed to _deletetclcallbacks, and maybe even included in my patched self.quit() before the tk.evals. Mike. probably be renamed From paulp at ActiveState.com Fri Jun 29 15:17:59 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 29 Jun 2001 12:17:59 -0700 Subject: Augmented Assignement (was: Re: PEP scepticism) References: Message-ID: <3B3CD467.E9A1A528@ActiveState.com> Mark 'Kamikaze' Hughes wrote: > >... > What would you expect from "mytuple = mytuple + (foo,bar)", and why > would this be different from "mytuple += (foo,bar)"? Different people expect different things. Based on my knowledge of C I would expect that mytuple += would rebind. >... > > What would you expect from "mylist = mylist + [foo, bar]", and why > would this be different from "mylist += [foo, bar]"? It is different right now: >>> mylist = yourlist = [5] >>> mylist = mylist + [3,4] >>> mylist [5, 3, 4] >>> yourlist [5] >>> mylist = yourlist = [5] >>> mylist += [3,4] >>> mylist [5, 3, 4] >>> yourlist [5, 3, 4] Naive users do not expect the operator's relationship to the *namespace* to depend on the type of the operands. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From tdelaney at avaya.com Wed Jun 6 20:40:04 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Thu, 7 Jun 2001 10:40:04 +1000 Subject: Interesting speed benchmark Message-ID: > As one poster suggested, Python's reference counting might be the > culprit, so I modified the Java test as follows (probably not the > correct way to do it): > > public class ObjectTest { > public ObjectTest next; > public static void main(String[] args) { > for (int i = 0; i < 1000; i++) { > ObjectTest root = new ObjectTest(); > for (int j = 0; j < 10000; j++) { > root.next=new ObjectTest(); > root=root.next; > System.gc(); // <-----------Force garbage collection > > } > } > } > } Actually, just as a note, System.gc() will not *force* a garbage collection, but gives a hint that "now would be a good time for gc ...". If your thread is running at a higher priority than the gc thread, it's likely that no gc will occur anyway. However, it seems on your JVM that gc is getting the chance to run. BTW, it's not so much Python's reference counting which is the overhead, as what happens when the references to an object reach zero, which is what happens in your algorithm. As you set root = root.next each time, the old "root" drops to a refcount of 0. As a result, the object is destroyed. This has both advantages and disadvantages. The disadvantage is that it takes a little bit longer each time throught. The advantages include: 1. You know *when* the object will be destroyed (in a program a trivial as this). 2. Since you only ever have 2 ObjectTest instances at any time, it's highly likely that the memory for them will be reused for the two instances, meaning you don't have to continually allocate more memory. This means thr program is more likely to run in a smaller memory footprint - always a Good Thing (TM). Tim Delaney From elf at halcyon.com Thu Jun 7 15:55:08 2001 From: elf at halcyon.com (Elf Sternberg) Date: 7 Jun 2001 19:55:08 GMT Subject: PYML, Python, Perl and Zope References: Message-ID: <9fom6s$prn$1@brokaw.wa.com> In article johnca at DIESPAMmac.com (John Abbe) writes: >PYML looks very neat for web delivery (Python embedded in HTML). >http://www.pyml.org/ There's excellent competition in this from Webware, which is a Python-only application server. It has PSP (Python Server Pages) which in effect work exactly like PyML, but it also has a complete database interface and a lot of other goodies. Elf -- Elf M. Sternberg, rational romantic mystical cynical idealist http://www.halcyon.com/elf/ Dvorak Keyboards: Frgp ucpoy ncb. ru e.u.bo.v From dsh8290 at rit.edu Fri Jun 8 09:21:41 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 8 Jun 2001 09:21:41 -0400 Subject: gc issues In-Reply-To: <655abd4a.0106080504.66a9d6a0@posting.google.com>; from etoffi@bigfoot.com on Fri, Jun 08, 2001 at 06:04:23AM -0700 References: <655abd4a.0106080504.66a9d6a0@posting.google.com> Message-ID: <20010608092141.D18227@harmony.cs.rit.edu> On Fri, Jun 08, 2001 at 06:04:23AM -0700, e toffi wrote: | hello | | lets say i wanted to integrate 2 languages with gc's (lua, | [small]eiffel, python, javascript). | | how do i keep the gc's from eating each other? | | i know this will require some *very* careful prgramming techniques. | can anyone point me in the right direction? ILU might help (from Xerox PARC, there is a Debian package). Or use XML-RPC or SOAP or CORBA and don't bring both interpreters into the same process. (C)Python plays well with other GC implementations because it uses ref counting. It doesn't need to traverse the pointer tree on the heap. -D From idivanov at hotmail.com Thu Jun 21 11:28:08 2001 From: idivanov at hotmail.com (Ivan) Date: 21 Jun 2001 08:28:08 -0700 Subject: rexec works strange... References: Message-ID: <9dab6033.0106210728.2c77e6fd@posting.google.com> Thanks! the try/except seems to be a good solution! Ivan From m.mariani at imola.nettuno.it Wed Jun 13 10:39:23 2001 From: m.mariani at imola.nettuno.it (Marco Mariani) Date: Wed, 13 Jun 2001 16:39:23 +0200 Subject: VI In-Reply-To: Message-ID: <20010613163923.A6420@zoidberg> On Wed, Jun 13, 2001 at 08:38:34AM -0500, Kemp Randy-W18971 wrote: > Do you mean VI on Unix? It's a standard line based editor that comes with Unix. Yeah, it's as much line based as Microsoft Word is. From aleaxit at yahoo.com Fri Jun 29 10:37:16 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 29 Jun 2001 16:37:16 +0200 Subject: the center of the world (was Re: Check out O'Reilly's Open Source Convention Highlights) References: <3B3AA82D.1A0FE860@seebelow.org> <3B3B2DED.5303198A@seebelow.org> <9hhri7019jd@enews2.newsguy.com> Message-ID: <9hi3ru01o0q@enews2.newsguy.com> wrote in message news:m3pubn2yqo.fsf at kepler.ibp.de... ... > Then find first the weighted average as a point in three-dimensional > space, i.e. as (an approximation to) the center of gravity of the > human population. This will be some point deep in the interior of the > Earth, Good idea! Now I finally know how the Python Secret *Underground* got its much-feared name...!!! > which you could the project back to the surface. Why ever would one do THAT?! Seems like a very superficial approach to me. Alex From niemeyer at conectiva.com Tue Jun 12 14:47:59 2001 From: niemeyer at conectiva.com (Gustavo Niemeyer) Date: Tue, 12 Jun 2001 15:47:59 -0300 Subject: sre improvements Message-ID: <20010612154758.Q13940@tux.distro.conectiva> Hi there!! I have looked into sre, and was wondering if somebody is working to implement more features in it. I'd like, for example, to see the (?(1)blah) operator, available in perl, working. Should I care about this? Should I write some code?? Anybody working in sre currently? Thanks! -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ] From mcherm at destiny.com Fri Jun 29 09:10:00 2001 From: mcherm at destiny.com (Michael Chermside) Date: Fri, 29 Jun 2001 08:10:00 -0500 Subject: [Python-iterators] While we're at it... References: <03d701c0ff61$ac3bba80$156ff181@idi.ntnu.no> Message-ID: <3B3C7E28.7FF6093E@destiny.com> Magnus Lie Hetland wrote: > > I'm sure there are plenty of similar cases (functions > working on sequences that can be made to work on > iterators), but how about random.choice? > I don't see the benefit. It's REALLY easy to type this: random.choice(list(myIterator)) If we expected to WANT to pass iterators to random.choice a lot, then it might be a good idea anyway. But I wouldn't expect this. Why? random.choice is not a place where we expect to probably use only the first few items and therefore want an iterator so we don't have to generate them all -- on expectation we expect to use fully 1/2 the items. Worse, we probably need to generate ALL of them in order to count them. Basically, what we need is a sequence, so why not require the explicit conversion. It gets worse when you consider that one important feature of iterators is that they may NOT have a length! Infinitely producing iterators will be less common, but certainly not uncommon. I agree we should modify a number of std library functions to use iterators, but random.choice seems to me to be a very poor (excuse the pun!) choice. -- Michael Chermside From spam_kill.guse at hobbiton.org Tue Jun 5 10:16:02 2001 From: spam_kill.guse at hobbiton.org (goose) Date: Tue, 05 Jun 2001 14:16:02 GMT Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3B1B1825.8109BA83@lmf.ericsson.se> <3b1ce1f7.5642@bolder.com.co.za> <3B1CE4D3.18F99168@lmf.ericsson.se> Message-ID: <3b1ce9a2.57e7@bolder.com.co.za> Attila Feher merely scratched his head and went: > goose wrote: >> > [SNIP] >> this can be done as long as cross-platform means that actuall PC's will >> be used, if u tell me make my sw run on ce, then u might as well ask me to run >> it on toasters ... > [SNIP] > > U C people with Windows CE stuff might not agree with you. They don't > care if the SW runs on toasters or not, but they want it to run on CE - > that is the reason they bought it. :-))) CE is unline toasters: it has > a GUI in 99% of the cases, and of course an interactive SW will support > only the GUI. BTW it is unicode and Win32 so what runs on NT as UNICODE > (and carefully written) will run on this one, too. Let's suppose it > does not need 1/2G RAM :-)) > sorry ... temporary brain-fade induced by getting into an argument concerning "everybody uses windows, so u should only develop for microsoft" ... terribly sorry :-) bye -- goose ----- From jeff at ccvcorp.com Thu Jun 7 21:02:27 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: 7 Jun 2001 18:02:27 -0700 Subject: Windows editor? References: <3af2c38f.341431824@News.CIS.DFN.DE> Message-ID: <16074dce.0106071702.e51ec8d@posting.google.com> "Nick Perkins" wrote in message news:... > I have used Boa Constructor (just the editor), for general-purpose Python > programming. I find it to be more stable than PythonWin. In PythonWin, I > find that if my program crashes or hangs, it will often take the IDE down > with it. Same goes for IDLE. In Boa, I can usually kill my program without > killing the editor, too. The rest of Boa (wxWindows gui design) is also > pretty good, but needs some work. This is probably a result of the fact that PythonWin, and IIRC IDLE, run your Python code in the same thread that the IDE runs in. This can cause problems that, when your code is stuck on something, PythonWin can't service it's message queue. Boa Constructor, from what I've heard, runs user code in a separate thread (or perhaps it was a separate process?), thus preventing this sort of problem. But from what Mark Hammond (creator of PythonWin and major force behind Komodo) has said, running user code out-of-process is a lot more difficult, which is why there are no plans to do that for PythonWin (though Komodo *does* do this). Also, PythonWin doesn't tend to cooperate too well with multithreaded programs, or with gui-package programs (ie, Tkinter/wxPython). Other than those caveats, though, PythonWin is great--I really like having the autocomplete! Jeff Shannon Technician/Programmer Credit International From BPettersen at NAREX.com Mon Jun 18 16:08:21 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Mon, 18 Jun 2001 14:08:21 -0600 Subject: why is there no class (static) methods in Python ? Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D48B@admin56.narex.com> > From: D-Man [mailto:dsh8290 at rit.edu] > > On Mon, Jun 18, 2001 at 12:21:53PM -0700, James_Althoff at i2.com wrote: > <...> > | I notice that yourModule.yourFunction1 > | is exactly what I want, but I need to override > yourModule.yourFunction2 in > | order to adapt it for myModule.MyClass. How can I do this > (preferably > | WITHOUT resorting to "black magic" and whilst preserving > | "thread-safeness")? > > #### myModule.py > > import yourModule > > myFunction1 = yourModule.yourFunction1 > > def myFunction2( ) : > pass Doesn't work: d:\>type A.py def fun1(): fun2() def fun2(): print 'A.fun2()' d:\>type B.py import A fun1 = A.fun1 def fun2(): print 'B.fun2()' fun1() d:\>python B.py A.fun2() d:\> -- bjorn From gardner at cardomain.com Thu Jun 21 20:45:55 2001 From: gardner at cardomain.com (Jonathan Gardner) Date: Thu, 21 Jun 2001 17:45:55 -0700 Subject: weakrefs and things that point to each other Message-ID: <9gu4eg$838$1@brokaw.wa.com> Okay, here''s the idea. Object A can have many things of Class B. Object B can be had by many things of Class A. When A is destroyed, it wants to let B know that it no longer has it. When B is destroyed, it wants to let A know it no longer should have it. So: # Without weakrefs... class A: def __init__(self): self.has = [] def add(self, b): if b not in self.has: self.has.append(b) def remove(self, b): self.has.remove(b) def __del__(self): for b in self.has: b.removedfrom(self) class B: def __init__(self): self.hadby = [] def addedby(self, a): self.hadby.append(a) def removedfrom(self, a): self.hadby.remove(a) def __del__(self): for a in self.hadby: a.remove(self) But, because of circular references, we need to use weak refs on at least half of the equations. However, I want the B to destroy itself even when there is one or more A's pointing to it. So I will implement weakrefs on both sides. # With weakrefs... class A: def __init__(self):V self.has = [] def add(self, b): if b not in self.has: self.has.append(weakref.ref(b)) def remove(self, b): self.has.remove(b) def __del__(self): for b in self.has: b().removedfrom(self) class B: def __init__(self): self.hadby = [] def addedby(self, a): self.hadby.append(weakref.ref(a)) def removedfrom(self, a): self.hadby.remove(a) def __del__(self): for a in self.hadby: a().remove(self) Question 1: Is this the way it should be done? Question 2: "if b in self.has:" will not ever return true because: >>> a = Something() >>> b = a >>> c = weakref.ref(a) >>> b is a 1 >>> c is a 0 >>> c() is a 1 -- Jonathan Gardner "Infinity isn't all that large - except at the end." -- Uncle Al Please don't take anything I say seriously, even if you are really gullible. From greg at cosc.canterbury.ac.nz Wed Jun 6 01:27:45 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 06 Jun 2001 17:27:45 +1200 Subject: Obsolesence of <> References: <3B17787F.266644CB@student.gu.edu.au> <9f7imv01muo@enews1.newsguy.com> Message-ID: <3B1DBF51.F9B52A21@cosc.canterbury.ac.nz> Alex Martelli wrote: > > it's hard to maintain that <> should > continue to apply where neither < nor > now do anymore:-). Oh, I don't know. Given that we live in a quantum- mechanical universe, it may make perfectly good sense to say that "<>" means "less than or greater than, but don't try to ask which". :-) -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From MarkH at ActiveState.com Mon Jun 25 23:36:56 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 26 Jun 2001 03:36:56 GMT Subject: win32 extension installation problem References: <3B355CE8.8060605@ActiveState.com> <9YuZ6.123682$%i7.85882471@news1.rdc1.sfba.home.com> Message-ID: <3B38035F.9070303@ActiveState.com> zihonglu wrote: > Thanks for your reply. I have tried changing the version in Python21.dll to > "MyPython21", changing registry version accordingly, and put the file back > to c:\winnt\system32 directory, manually put win32 extension files under the > python directory. It worked. You should definitately _not_ put this modified DLL in the system directory, as this will, by definition, override any system installed Python. > However, since the Python21.dll has been changed, I wanted it to be located > in c:\MySoftware\Python to prevent being accidentally overwritten . As far > as python is concerned, it seems to work fine. I could register the > PythonService.exe as well. However, I can't start my python service. The > problem went away as soon as I put the modified Python21.dll back to the > system32 directory. I vaguely remember I have the same problem with > PyWinTypes.dll. Any solution? Hrm. Try moving "pythonservice.exe" into the same dir as the modified DLL. Mark. From phd at phd.fep.ru Wed Jun 20 06:15:29 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Wed, 20 Jun 2001 14:15:29 +0400 (MSD) Subject: Class destructors In-Reply-To: Message-ID: On Wed, 20 Jun 2001, Graham Ashton wrote: > I understand that Python doesn't have the equivalent of the DESTROY() You understand it wrong. There IS constructor __init__, and there IS destructor __del__. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From beechd at gatsby.tafe.tas.edu.au Wed Jun 13 07:54:39 2001 From: beechd at gatsby.tafe.tas.edu.au (David) Date: 13 Jun 2001 04:54:39 -0700 Subject: ODBC and date References: Message-ID: "Steve Holden" wrote in message news:... > "Maurice HUET" wrote in message > news:FYHU6.106$GJ3.438333 at nnrp3.proxad.net... > > Hello, > > > > I want transfert data from a progress database to a MySql database > with > > python and the ODBC module. (Win plateform) > > How can I specify date selection in the SQL order ? > > The date data cause problem (dbidate type) when i want write tem in a > > text file between then two database ? MySQL uses an ISO format date. I have been using Marc Lemburg's ODBC driver which is very good (http://www.lemburg.com/python) and found that when using dates if it's necessary to set the dateformat for the cursor: db = Connect(dsn, user, pwd) c = db.cursor() c.datetimeformat=3 There are constants for the date formats so you can interpret the date in many ways. David From vputz at nyx.net.removeme Fri Jun 8 23:50:55 2001 From: vputz at nyx.net.removeme (Victor B. Putz) Date: 8 Jun 2001 20:50:55 -0700 Subject: gc issues References: <655abd4a.0106080504.66a9d6a0@posting.google.com> Message-ID: <2058655.000065f7.007@drn.newsguy.com> >Basically, you need to announce the objects of one language to the >other language's garbage collector. ... >To summarize: as long as you don't create cycles involving objects >from both languages, you only need to make sure that objects >referenced from one language are not collected by the collector of the >other language. If you have cycles of mixed languages, I doubt there >is prior art integrating the GC routines. A note: When I was writing ePolyglot (more of a "pilot project" than a library, really) I was able to write several little programs using eg Python objects from Eiffel or Eiffel objects from Python (including making an eiffel extension module which could be loaded entirely from within the interactive Python interpreter). Basically, you had pure eiffel objects, pure python objects and then two different sorts of "shadow" classes--Eiffel objects which held an opaque pointer to a Python object, and Python objects which held an opaque pointer to an Eiffel object. In the Eiffel-holding-a-pointer-to-a-Python-object case, managing "gc" wasn't too bad--when you accepted a reference to a Python object, you increased its count, and in the redefined "dispose" method (from class MEMORY), you decreased its count. I never really stress-tested this, but the idea seemed good, and since Python 1.5.2 (the version I used at the time) was strictly reference-counted, you could be pretty sure that the Python object wasn't going to vanish for no reason... In the Python-holding-a-pointer-to-Eiffel case, there was no reference count (on the Eiffel side) to increment or decrement, so it was trickier. I never tried this with ePolyglot, but one way to solve it would be to have a singleton (CONTAINER)[ANY] which stored Eiffel objects being shadowed by Python; every time a Python-holding-an-eiffel-pointer object was created, you could store that eiffel object in the singleton container, preventing unwanted cleanup by Eiffel's GC. In any case, although it was more an exercise in Makefile hell than a truly reusable library, I still think there are lessons to be learned from ePolyglot (which got as far as using Haskell, Python, and Eiffel in the same executable...). If you're interested in multilanguage programming, check out http://epolyglot.sourceforge.net with LOTS of documentation (it was an independent study for my MS)...it's not all pretty, but you might be able to glean some useful nuggets out of it. -->VPutz From aleaxit at yahoo.com Wed Jun 6 05:57:44 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 6 Jun 2001 11:57:44 +0200 Subject: Dynamic scoping References: Message-ID: <9fkuqo0inv@enews2.newsguy.com> "Arun Sharma" wrote in message news:slrn9hr0ft.1kj.adsharma at eagle.mirabella.net... > I've searched the archives of this group as well as the net, about the > advantages and disadvantages of lexical vs dynamic scoping. I'm > convinced by the arguments that lexical scoping is what people want > most of the time. > > However, under some circumstances, people might want to use dynamic > scoping. Is there a reason why python doesn't support it ? (Unlike > perl ?). But it does, if you want it badly enough -- why do you think the exec statement and eval function let you pass dictionaries to specify the global and local namespaces to use? Why, it's *exactly* (among other things:-) so you can dynamically build whatever scope you need... the amount of trouble you have to go to in order to obtain the right codeobject for eval or exec is accurately proportioned to correspond to just the right degree of dissuasion of use of dynamic scoping (1:99.44 being the mathematically exact and indisputable ratio thereof...:-). Seriously: for that 1 time in 100 you do want dynamic scoping, and are exactly right in thus wanting, eval/exec/execfile with specified dictionaries are just right. AND they give you far more control than bare dynamic-scoping would... plus, their relative obscurity helps ensure that somebody using them has that solid grasp of Python needed to ensure they REALLY do want to scope dynamically. Probably a serendipitous result rather than a fully-though-out design decision, but who can tell -- Guido moves in mysterious ways, his wonders to perform, ya know... Alex From ckucera at globalcrossing.com Wed Jun 13 13:59:51 2001 From: ckucera at globalcrossing.com (Christopher J. Kucera) Date: Wed, 13 Jun 2001 12:59:51 -0500 Subject: VI References: Message-ID: <3B27AA17.A2F8158A@globalcrossing.com> Pilgrim wrote: > Can someone tell me what "vi" is for a text editor to work with python? > Where can I get this? You've entered unholy ground here, as the age-old "emacs versus vi" debate has been known to tear small countries apart, but for what it's worth: I use vim (Vi IMproved) exclusively as my editor. I've never needed anything else, and nothing else I've tried out of curiosity piqued my interest. I also disagree with other comments that vi is not suitable for large projects; like I said, I use it for everything. It will do syntax highlighting, automatic indentations, and a whole bunch of other really cool stuff. While vi originated on UNIX, there is a Windows version of vim as well, and you can get it from www.vim.org. Or, I believe it also comes with Cygwin (http://sources.redhat.com/cygwin). Some selling points: * vi will typically be available on any flavor of UNIX you come across * vi is very lightweight (vim admittedly less so), so you're not buried in excessive overhead. * vi typically works very well through just about any terminal you happen to be running in * vi is FAST. Once you understand the commands, you will be able to do simply phenomenal things VERY quickly. Some caveats: * vi's command syntax will give you nightmares until you get used to it. vim is actually rather forgiving in this respect, as it's much more lax about what you can and can't do while in edit mode, etc, but prepare for a steep learning curve. Once you get past this, it's absolute nirvana, but it will take some (read: a great deal of) patience. * vi does not attempt to do the world for you. If you want an integrated environment that will check your mail, compile your programs and cook you dinner, you're best off with another editor (this is where emacs typically steps in). So, there you go. More than you ever needed to know, I'm sure. :) -CJ From jinushaun at hotmail.com Sat Jun 9 16:03:39 2001 From: jinushaun at hotmail.com (Shaun Pen) Date: Sat, 09 Jun 2001 13:03:39 -0700 Subject: Unicode problem Message-ID: I'm writing a script that translates romaji to the appropriate hiragana or katakan characters. This is Japanese, btw. >From the unicode website, I find that the character code for the hiragana "NA" is "306a" (JIS). I know it outputs as ?? (JIS). **So how do I get from "306a" to ?? ??? ** In Javascript, document.write("\u306a") outputs ?? correctly. When I try that in Python (print u"\u306a"), I get the error: UnicodeError: ASCII encoding error: ordinal not in range(128) I've also tried printing u"\u0030\u006a" and u"\30\6a", but those give me the wrong thing. All the docs I've read only deal with Latin encoding, which fall in the 0-127 range nicely. And they deal with mostly u"???" to u"\344\366\374", instead of the other way around. Please help. Sorry if this is long. I'm trying to avoid people screaming RTFM. Jinushaun _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com From xyzmats at laplaza.org Mon Jun 18 18:37:13 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Mon, 18 Jun 2001 22:37:13 GMT Subject: os.statvfs on FreeBSD References: Message-ID: <3b2e81d3.30063649@news.laplaza.org> On 16 Jun 2001 20:51:12 -0700, t_messmer at yahoo.com (Tom Messmer) wrote: >Thanks for looking at this, I took some time and noticed that there >was really no statvfs system call in FreeBSD (stable) and thought it >might be possible to use the statfs call and map it to the same tuple >returned by python's os.statvfs routine. Statvfs is the generalized sucessor to statfs, so this seems the most reasonable approach. statfs is filesystem-specific, statvfs was defined to get information through an abstraction layer, the vfs (virtual filesystem switch, I believe it stands for). Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From boyd at insultant.net Wed Jun 6 07:14:25 2001 From: boyd at insultant.net (Boyd Roberts) Date: Wed, 6 Jun 2001 13:14:25 +0200 Subject: How do I return binary data from a python CGI called from CGIHTTPServer? References: <9f96kb01mq8@enews1.newsguy.com> Message-ID: <9fl3cs$cii$1@neon.noos.net> "D-Man" a ?crit dans le message news: mailman.991771931.11834.python-list at python.org... > In MS-DOS terminals ctrl-z is used to indicate that you want to close > the input stream (EOF). On Unix terminals it is ctrl-d instead. ctrl-d is only interpretted by the unix tty driver. it has no meaning anywhere else. it means end of input stream and this can occur multiply on ttys. there are three cases: 1. nothing in the tty's input queue 2. some number of chars in tty's input queue 3. the tty is in 'raw' mode 1 and 2 are really the same case because the ctrl-d tells the tty driver to send up what's in the input queue so that the process reading the tty gets the characters and the number of characters. case 3 just hands up the characters as they are typed, so you _could_ read a ctrl-d -- it does not mean end of file. 'raw' mode is complicated by how braindamaged the tty driver is. on unix, when a process calls read _in all cases_ (not just ttys) a return of a 0 count indicates end of file. > I think that the problem must be the sub-process thinks it is writing to > a tty rather than a regular file, and thus is closing the output when > you try and write ctrl-z. you might be heading in the right direction, but you've got it around the wrong way. some braindamaged process reads the ctrl-z and treats that as end of file. or maybe you said that there are m < n bytes in the data stream and at m bytes (instead of n) the reader says 'ok, end of file'. lesson: in-band signaling is a sin. From mixo77 at usa.net Wed Jun 27 10:19:29 2001 From: mixo77 at usa.net (mixo) Date: Wed, 27 Jun 2001 16:19:29 +0200 Subject: Handling IP's Message-ID: <3B39EB71.DEBBF242@usa.net> Is there a built function/method to check if an IP falls within a certain range? For example, if you have a network a.b.c.d, where "a", and "b" are fixed but "c"and "d" variy (I think this a class B network), is there a function that can check that some ip say, j.k.l.m, is part of the network? From sholden at holdenweb.com Fri Jun 29 14:00:22 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 29 Jun 2001 14:00:22 -0400 Subject: Augmented Assignement (was: Re: PEP scepticism) References: Message-ID: "Mark 'Kamikaze' Hughes" wrote in ... > 28 Jun 2001 11:32:34 -0700 in , > Paul Prescod spake: > > I think Python has been getting better and better as time goes on. But I > > do have a concern about augmented assignment. How can a newbie > > understand that tuples are "immutable" if this works: > > mytuple += (foo,bar) > > What would you expect from "mytuple = mytuple + (foo,bar)", and why > would this be different from "mytuple += (foo,bar)"? > We would expect these to be the same. > > Worse, once they've learned that this does NOT affect other references > > to mytuple they are bound to be confused by > > mylist += [foo, bar] > > which does! > > What would you expect from "mylist = mylist + [foo, bar]", and why > would this be different from "mylist += [foo, bar]"? > The two statements *can indeed* have different results. The difference lies in the apparent changes to other names bound to the same object: >>> lst1 = ['one', 'two'] >>> lst2 = ['two', 'three'] >>> steveslist = lst1 >>> markslist = lst2 >>> lst1 = lst1 + ['new', 'list', 'items'] >>> lst2 += ['new', 'list', 'items'] >>> steveslist ['one', 'two'] >>> markslist ['two', 'three', 'new', 'list', 'items'] *Now* do you get it? > > I've seen this confusion already -- in a draft of a book no less. > > I'm confused by your confusion. However, it looks like that author > should probably make this more clear. > Despite your questions, mutable object behavior does vary between explicit and augmented assignment, although immutable object behavior does not and can not. regards Steve -- http://www.holdenweb.com/ From aleaxit at yahoo.com Tue Jun 12 18:36:49 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 13 Jun 2001 00:36:49 +0200 Subject: BIG problem if readline strips newlines References: Message-ID: <9g65ei0kar@enews1.newsguy.com> "Bjorn Pettersen" wrote in message news:mailman.992379739.20351.python-list at python.org... ... """ > >standard python idioms will no longer work... > > > >for line in file.readlines(chomp=1): > > pass > > Um. Think again? Why wouldn't this work? I think he meant: while 1: line = file.readline(chomp=1) if not line: break """ So if you want your lines pre-chomped you have to use the faster .xreadlines() approach -- doesn't seem a bad thing to me... incentive towards progress!-) Alex From robin at jessikat.fsnet.co.uk Tue Jun 26 11:30:54 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Tue, 26 Jun 2001 16:30:54 +0100 Subject: Running slower in win2k Tkinter References: <$HBeGIALtDO7EwzP@jessikat.fsnet.co.uk> Message-ID: <4e4PQKAuqKO7EwDj@jessikat.demon.co.uk> In article <$HBeGIALtDO7EwzP at jessikat.fsnet.co.uk>, Robin Becker writes >I have a Tkinter app that needs to run a search over a set of packages. >Basically the search imports all the modules finds all objects and sorts >into a set of dictionaries. There is no interaction with tk, but when >run in the tk app the search takes 5-6 times longer than when run >directly without the tk windows. The Tkinter app isn't threaded and >appears fully blocked while the computation takes place. > >I expect some slowdown in Tkinter as it must respond to messages etc, >but the difference 1.51" vs 10.72" seems way too large. > >What am I missing? OK ifigured out that Pmw has a 'loader' that dramatically slows down importing and that causes my problem. The fix is to temporarily remove the 'loader', do the work and then restore it. -- Robin Becker From fluxent at yahoo.com Mon Jun 25 16:09:06 2001 From: fluxent at yahoo.com (Bill Seitz) Date: 25 Jun 2001 13:09:06 -0700 Subject: SQL-SELECT against View via ODBC? Message-ID: I'm writing ASP page that uses the generic Python ODBC driver to query MsSql2K. Have some generic Python that grabs both an array of the resultSet (cursor FetchAll), plus an array of fieldNames (cursor Description). When I run this code against a view (which just does a pretty simple join: have queried the view fine in MsSqlQueryAnalyzer), I get an error message about SQL select Failed - "select * from timechargesAsHours" - [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index in FETCH Is there a problem getting cursor descriptions via ODBC? From aleaxit at yahoo.com Thu Jun 28 11:47:03 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 28 Jun 2001 17:47:03 +0200 Subject: noncommercial Python+QT on Windows? (was Re: qt or gtk?) References: <9gk8he$8gl$1@brokaw.wa.com> <16074dce.0106181045.139d80a5@posting.google.com> <3b3b40a0@news.uia.ac.be> Message-ID: <9hfjho05to@enews1.newsguy.com> wrote in message news:3b3b40a0 at news.uia.ac.be... ... > The licensing for non-commercial applications for Qt/Win32 was changed > very recently. Have a look here : > http://www.trolltech.com/company/announce/noncommercial.html Very interesting -- NOW, is there a way one can develop Python software, cross-platform, using Qt, and redistribute it: legally, for free and with sources? Alex From duncan at NOSPAMrcp.co.uk Fri Jun 22 05:37:56 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Fri, 22 Jun 2001 09:37:56 +0000 (UTC) Subject: weakrefs and things that point to each other References: <9gu4eg$838$1@brokaw.wa.com> Message-ID: Jonathan Gardner wrote in news:9gu4eg$838$1 at brokaw.wa.com: > Okay, here''s the idea. Object A can have many things of Class B. > Object B can be had by many things of Class A. When A is destroyed, it > wants to let B know that it no longer has it. When B is destroyed, it > wants to let A know it no longer should have it. > > But, because of circular references, we need to use weak refs on at > least half of the equations. However, I want the B to destroy itself > even when there is one or more A's pointing to it. So I will implement > weakrefs on both sides. If you have weak references on both sides then are you sure something is going to keep all those bees alive? > Question 1: Is this the way it should be done? Have you looked at the WeakValueDictionary class? If all you want to do is keep a collection of weakly referenced objects it will handle the deletion automatically (use the id as a convenient key). If you need to do more on the deletion use the callback option on a weak reference instead of doing things in __del__. > > Question 2: "if b in self.has:" will not ever return true because: >>>> a = Something() >>>> b = a >>>> c = weakref.ref(a) b is a 1 c is a 0 c() is a 1 you have to remember to dereference the weak references before comparing. Something like WeakValueDictionary makes this transparent. Here is how I would do it: ---- begin ---- from weakref import WeakValueDictionary class A: def __init__(self, name=""): self.has = WeakValueDictionary() self.name = name def __repr__(self): return "" % (self.name, id(self)) def add(self, b): self.has[id(b)] = b b.addedby(self) class B: def __init__(self, name=""): self.hadby = WeakValueDictionary() self.name = name def __repr__(self): return "" % (self.name, id(self)) def addedby(self, a): self.hadby[id(a)] = a b1, b2, b3 = B('b1'), B('b2'), B('b3') a1, a2, a3 = A('a1'), A('a2'), A('a3') a1.add(b1) a1.add(b2) a2.add(b2) a2.add(b3) a3.add(b3) a3.add(b1) print a1, "has", a1.has.values() print a2, "has", a2.has.values() print a3, "has", a3.has.values() print b1, "had by", b1.hadby.values() print b2, "had by", b2.hadby.values() print b3, "had by", b3.hadby.values() del a2 print "Deleted a2:" print a1, "has", a1.has.values() print a3, "has", a3.has.values() print b1, "had by", b1.hadby.values() print b2, "had by", b2.hadby.values() print b3, "had by", b3.hadby.values() del b2 print "Deleted b2:" print a1, "has", a1.has.values() print a3, "has", a3.has.values() print b1, "had by", b1.hadby.values() print b3, "had by", b3.hadby.values() --- end --- Which produces output like this: has [, ] has [, ] has [, ] had by [, ] had by [, ] had by [, ] Deleted a2: has [, ] has [, ] had by [, ] had by [] had by [] Deleted b2: has [] has [, ] had by [, ] had by [] Found b3 in a3 -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From spam_kill.guse at hobbiton.org Wed Jun 6 11:40:37 2001 From: spam_kill.guse at hobbiton.org (goose) Date: Wed, 06 Jun 2001 15:40:37 GMT Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3b1cdc84.5514@bolder.com.co.za> <9fleid$3rp$1@oslo-nntp.eunet.no> Message-ID: <3b1e4ef5.3788@bolder.com.co.za> Thomas Hansen merely scratched his head and went: > [...snip...] > I am not going to comment on all since it was very long and I don't have > time... > But fact is : > -If you have a computer and you play games, you probably (80% or > something) have bought it as a "package" from some kind of > hoover-salesman... > -If you buy from a hoover-salesman you WILL have windows installed > default... IIRC, the original post said 99.99% of computers run windows ... I would like to see the source for this info ...maybe a web-page link ? > -If you play alot of games, you're probably having a lot of spare time. > -If you have alot of spare time you probably don't know much computer. > -If you don't know much computer, STAY AWAY FROM *nix... > I have a friend of me which has been spending 3 weeks on getting X to > work on Linux since he's got a PS/2 mouse it's conflicting with some other > hardware (very common in the latest core), and since he "doesn't have a > mouse" he can't start X... > And my friend has got a Masters Degree in Programming!!! > > That would NEVER happen on a preinstalled hoover delivered version of > windows as long as you don't press delete on you windows/system directory, > or open a mail named "I am a virus and I'll crash your BIOS, CMOS, OS, > HARDDISC and nerval-system"!! i seem to be missing your argument, maybe i'm just a little dense today... what is your point ? that 99.99% of computers run windows ? that 80% of home computers run windows ? that a pre-installed computer *always* comes with windows ? that i cannot order a 'blank' computer from a hoover-salesman ? regards, -- goose ----- " as a matter of fact, I don't find it very funny that this guy has posted the same joke twice in 2 days...... it's bad enough when other people steal jokes off each other but when you rip off your own jokes there's something wrong with you " --atj, cillian on about BretMS From ken_chiba at hotmail.com Sat Jun 23 18:33:31 2001 From: ken_chiba at hotmail.com (Ken) Date: Sat, 23 Jun 2001 22:33:31 GMT Subject: How to install python on clean RH7.1 install References: <3b313462.13451051@news1.on.sympatico.ca> <3B33F025.D275AAB1@student.gu.edu.au> Message-ID: <3b35170a.268083173@news1.on.sympatico.ca> On Sat, 23 Jun 2001 11:25:57 +1000, Joal Heagney wrote: >Question 1. >To find out which packages require python, use the following command: >rpm -q --whatrequires python > >I haven't tried to replace python1.5 in a distro, prefering to install >python2.1 beside the system python, but if I were going to do this, I'd >install python2.1 either from the source using --altinstall rather than >--install, with --prefix=/usr during the configure step, or build and >install python2 from any of the python2*src.rpm files out there. > >This will install python2 under /usr, but your /usr/bin directory will >(or should) look like this (for the python2.src.rpm option) >-rwxr-xr-x 1 root root 423260 Oct 1 2000 python -> >python1.5 >-rwxr-xr-x 1 root root 423260 Oct 1 2000 python1.5 >-rwxr-xr-x 2 root root 521020 Jun 15 20:39 python2 -> >python2.1 >-rwxr-xr-x 2 root root 521020 Jun 15 20:39 python2.1 > >Then I'd get all the packages that depend on python1.5, preferably in >src.rpm form. Go to /usr/bin and swap around the default python >cd /usr/bin >mv python python-old >ln -s python2.1 python >and build each of the dependancies packages, but don't install them. >Fix the hacking you did on the /usr/bin directory >rm python >mv python-old python >Then rebuild the python2 src.rpm but edit the spec file so that it build >python2 as the package python >rpm -i python2*src.rpm >cd /usr/src/RPM/SPECS >emacs python.spec >(Focus on the first 5 to 8 lines, and save the file) >rpm -bb python.spec >cd /usr/src/RPM/RPMS/i386 >rpm -i python.rpm > >If things stuff up, you may have to go back to your old packages. Cd to >your CD, and >rpm -U --oldpackage python.rpm old packages> > >In fact, if you're worried, I'd build all your dependancies packages >from source (Which you can retrieve from your src.rpm packages after you >install them.), making sure they go into python2.1, test each one out, >and then do what I suggested above. > >What you have to ask, is it worth it? Will a coexistant install do what >you require with far less effort than a total replace? > >Question 2. >You need to install the development packages of crypto and ssl, they'll >be on your cd. Also, install the readlines development library before >your build. With this, python will install readlines into the binary, >and when you're working in interactive mode, you'll be able to repeat >any of your previous commands by tapping the up-down arrows (Like >xterm/bash, as opposed to the _ trick, which only repeats the last >command.) This also goes for any other modules that you want, but will >probably require system libraries to build. (Read the python >documentation for hints as to this.) >-- > Joal Heagney is: _____ _____ > /\ _ __ __ _ | | _ ___ | > /__\|\ || ||__ |\ || |___|/_\|___] | > / \ \_||__ ||___| \_|! | | \ \ ! Thanks for your response. I'm going to give up on the idea of replacing 1.5 for now... in the effort to get 2.1-5 up. I'm still stuck. I already have the rpm openssl (and its development library) installed, and the rpm install for python still claims that it's failing dependencies for the files in question. Here is a snippet of the RPM install, using -vv ----------------------- # rpm -i -vv python2-2.1-5.i386.rpm ... D: Requires: libutil.so.1 YES (db provides) D: opening db index /var/lib/rpm/Name create mode=0x42 D: Requires: libcrypto.so.0.9.6 NO D: package python2-2.1-5 require not satisfied: libcrypto.so.0.9.6 D: Requires: libcrypt.so.1 YES (db provides) ... D: Requires: libreadline.so.4.1 YES (db provides) D: Requires: libssl.so.0.9.6 NO D: package python2-2.1-5 require not satisfied: libssl.so.0.9.6 ... D: opening db index /var/lib/rpm/Conflictname create mode=0x42 error: failed dependencies: libcrypto.so.0.9.6 is needed by python2-2.1-5 libssl.so.0.9.6 is needed by python2-2.1-5 D: ========== recording tsort relations D: ========== tsorting packages D: 0 (1,1) python2-2.1-5 D: ========== successors only (presentation order) D: closed db index /var/lib/rpm/Depends D: closed db index /var/lib/rpm/Conflictname D: closed db index /var/lib/rpm/Providename D: closed db index /var/lib/rpm/Basenames D: closed db index /var/lib/rpm/Name D: closed db index /var/lib/rpm/Packages ------------- You can see that it failed the dependencies for the files libcrypto.so.0.9.6, and libssl.so.0.9.6. Just in case I was losing it, I checked for the RPMs the files would be in by running: # rpm -qf /usr/lib/libssl.so.0.9.6 openssl-0.9.6-3 # rpm -qf /usr/lib/libcrypto.so.0.9.6 openssl-0.9.6-3 ... which I'm assuming is telling me what RPMs the files exist in. To double check, I ran the following: # rpm -q openssl openssl-0.9.6-3 ... and verifying the openssl package gave me: #rpm -V openssl .. (nothing) - which I'm assuming means everything is well. Please advise! Thanks, kc From roryking at aol.com Sun Jun 17 04:33:02 2001 From: roryking at aol.com (Rory Baker) Date: 17 Jun 2001 08:33:02 GMT Subject: humans and logic References: <9gbuci019gt@drn.newsguy.com> Message-ID: <20010617043302.26506.00001812@ng-xb1.aol.com> Humans are naturally illogical. It was illogical to raise a point that so many people could argue against. It is illogical for me to waste my time pointing out flaws in an argument that may no longer exist in about a year. But I do it anyway, because part of myself (the illogical part) compells me to do this. Yeah, binary *might* be a good mathmatical base to work upon, but there will always be some dude in the back that won't switch. People have machines to convert number systems and languages and all this nice stuff so that people aren't spending days just trying to say 'hi' to one another. There is no 'ideal' operating system, no 'ideal' language, no 'ideal number system. Even the most "logical" concepts of human thought are flawed. Take, for example, the concept of negative numbers. Except for financial cases where negative numbers indicate debt, or graphing, where negative numbers indicate position, negative numbers have no relavance in a positive universe. I cannot run negative miles. I cannot go to McDonalds and order the McNegative Cheeseburger with a side of negitavesize fries, and by paying for this negative meal with negative money, gain positive money. Then there is the question of dividing by zero. How much of nothing can you fit in to 1? How much nothing can you cram in to nothing? To paraphrase "The Hitchhikers Guide To The Galaxy" (Douglas Adams), you could, for example, have both a cup of tea and no tea at the same time. In one hand, you have tea, and in the other, you have no tea. To conclude, everybody is kinda right and kinda wrong on this one. Then again, maybe it's just me. I don't know. Anyone want to help me out? Anyone? From bobh at hslda.org Thu Jun 7 11:41:50 2001 From: bobh at hslda.org (Robert) Date: 7 Jun 2001 08:41:50 -0700 Subject: WHY is python slow? References: Message-ID: <4a249347.0106070741.3f1e2c21@posting.google.com> Here it is: http://www.bagley.org/~doug/shootout/ Not sure how well they are implemented but have a look and let us know. : ) Bob From tjg at hyperlinq.net Mon Jun 25 23:41:05 2001 From: tjg at hyperlinq.net (Timothy Grant) Date: Mon, 25 Jun 2001 20:41:05 -0700 Subject: Windows Printing using win32print In-Reply-To: <9h8smc$csrv8$1@ID-11957.news.dfncis.de>; from emile@fenx.com on Mon, Jun 25, 2001 at 07:35:59PM -0700 References: <9h8smc$csrv8$1@ID-11957.news.dfncis.de> Message-ID: <20010625204105.C7806@trufflehunter.hyperlinq.net> Thanks for the input I really appreciate it. However, The printer name I am using is correct. In fact, when single stepping through the code in the debugger, I can actually see the job appear and then disappear from the queue. Unfortunately nothing prints. On Mon, Jun 25, 2001 at 07:35:59PM -0700, Emile van Sebille wrote: > I'm not sure if this helps with your specific problem is, but I can say that > you need to figure out the name the printer goes by. I've seen different > names for printers working with various applications in windows. Here are > two examples that I'm currently using. > > destPrinter = r'NEC Silentwriter 95 v2011.111 on LPT1:' > destPrinter = r"\\NT401\HP Laserjet 4000N Front Desk on NE02:" > > I got the names by going into immediate mode from within Office 2000. Here > are my notes. > > ## to figure out the printer name recognized in MS Office apps, > ## - go into the app > ## - print a document to the target printer > ## - alt-F11 into visual basic > ## - go into immediate mode > ## - print Application.ActivePrinter > ## - copy and paste the name in > > Again, not sure it'll help, but hope it does. > > -- > > Emile van Sebille > emile at fenx.com > > --------- > "Timothy Grant" wrote in message > news:mailman.993507818.30090.python-list at python.org... > > I'm not much of a windows programmer, but I am in a situation > > where I need to write a test programme that does a lot of very > > small print jobs from a Windows box. I have downloaded > > win32all, and cobbled together a little app that I think > > should, maybe work, but doesn't. > > > > In my first iteration, I simply wrote a text file, then used > > os.system('copy filename lpt1:') to print it. This worked just > > fine, but one of the variables I need to test is how an > > interaction with the actual Windows printers works. To that end > > I started reading up on win32print. I was able to come up with > > the following... > > > > > > import win32print > > > > text2print = """ > > This is a test to see if I can get this text to actually print\n > > > > > > > > It will be multiple lines...\n > > > > Watch and see\n > > """ > > printer = win32print.OpenPrinter('Tektronix Phaser 600 Extended') > > jid = win32print.StartDocPrinter(printer, 1, ('TEST DOC', > 'c:\\test\\test.tjg', 'RAW')) > > bytes = win32print.WritePrinter(printer, text2print) > > win32print.EndDocPrinter(printer) > > win32print.ClosePrinter(printer) > > print bytes > > > > > > Now this is where my understanding of how things should work > > gets a bit shaky. I have read that the WritePrinter() function > > should send printer ready data. So since text2print is not in > > ps or pcl native format, I'm curious as to whether I'm even > > close. > > > > If I do need to send printer ready data, how do I create the > > printer ready data from my print string? > > > > Thanks for any assistance you might be able to provide. > > > > -- > > Stand Fast, > > tjg. > > > > Timothy Grant www.hyperlinq.net > > Chief Technology Officer tjg at hyperlinq.net > > HyperLINq Technologies, Inc. <>< (503) 246-3630 > > >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< > > >>>>This machine was last rebooted: 20 days 22:08 hours ago<< > > > > > -- > http://mail.python.org/mailman/listinfo/python-list -- Stand Fast, tjg. Timothy Grant www.hyperlinq.net Chief Technology Officer tjg at hyperlinq.net HyperLINq Technologies, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 21 days 3:38 hours ago<< From reuter at Uni-Hohenheim.DE Fri Jun 22 13:16:31 2001 From: reuter at Uni-Hohenheim.DE (Daniel Reuter) Date: Fri, 22 Jun 2001 19:16:31 +0200 (MET DST) Subject: Numeric 20.0.0 and 19.0.0 crash Python 2.1 Message-ID: Hello there, When I do the following: import Numeric Python 2.1 crashes with a segmentation fault. This is on a Debian/GNU Linux system, Python is configured --with-pymalloc --with-cxx=g++ --with-cycle-gc --enable-threads However Python 2.1 itself compiled perfectly, make test worked well (except for the two unicode modules, but that's not much of a problem), so I suspect a problem with Numeric, however as far as I can remember, I already had Numeric 19.0.0 running with Python 2.0. Anybody experiencing the same? Solutions? Regards, Daniel From jochen at riekhof.de Thu Jun 14 11:40:38 2001 From: jochen at riekhof.de (Jochen Riekhof) Date: Thu, 14 Jun 2001 17:40:38 +0200 Subject: substitute for c/java's ?: References: <9ga8ue$7aj$07$1@news.t-online.com> <9gai91052m@enews1.newsguy.com> Message-ID: <9galsa$ssh$07$1@news.t-online.com> >return ("a","an")[name[0].lower() in "aeiou"] Yeah, this is the method I found out for myself (see one of my above posts in this thread). Still has the drawback to evaluate both values of choice and much less readable than ?: IMO. Ciao ...Jochen From dsh8290 at rit.edu Wed Jun 20 14:15:02 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 20 Jun 2001 14:15:02 -0400 Subject: OOP in Python In-Reply-To: <4e2ddb70.0106200954.11faa218@posting.google.com>; from jonas.b@home.se on Wed, Jun 20, 2001 at 10:54:50AM -0700 References: <4e2ddb70.0106200954.11faa218@posting.google.com> Message-ID: <20010620141502.C7820@harmony.cs.rit.edu> On Wed, Jun 20, 2001 at 10:54:50AM -0700, Jonas Bengtsson wrote: | Ok I admit - I am a Python-newbie! | | What about local variables and class variables when dealing with | classes? | With local vars I mean temporaryly used variables in a function. Will | they be treated as 'normal' instance attributes? Do I have to delete | them by myself when I'm leaving a function? | With class vars I mean if many class instances of a class may share a | variable. In C++ this is accomplished by a static variable. How do I | do in Python? class Demo : # this is a class variable, ("static") var1 = "Hello" # this function/method is called immediately after construction. # It is supposed to inialize the instance, referred to by the # first argument. def __init__( self ) : # this creates an instance variable self.var2 = "World" def meth1( self ) : # this is a local variable. It is not prefixed by 'self.' and # will be destroyed upon completion of the function var3 = "." # one of the following lines accesses the class variable # through the class object, the other through the instance # object print Demo.var1 + " " + self.var2 + var3 print self.var1 + " " + self.var2 + var3 demo_obj = Demo() demo_obj.meth1() HTH, -D From garry at sage.att.com Fri Jun 22 11:22:55 2001 From: garry at sage.att.com (Garry Hodgson) Date: Fri, 22 Jun 2001 15:22:55 GMT Subject: problem building 2.1 on SunOS 5.7 References: <3B325CF1.9A970D6D@sage.att.com> Message-ID: <3B3362CF.5210C665@sage.att.com> Garry Hodgson wrote: > > i'm trying to download python 2.1 on a new machine, and having > some problems. i do a configure, then a make, and get: > > ->make > gcc -c -g -O2 -Wall -Wstrict-prototypes -I. -I./Include -DHAVE_CONFIG_H > -o Modules/python.o Modules/python.c > In file included from > /usr/local/lib/gcc-lib/sparc-sun-solaris2.4/2.7.2/include/time.h:90, > from /usr/include/sys/time.h:405, > from /usr/include/sys/select.h:17, > from > /usr/local/lib/gcc-lib/sparc-sun-solaris2.4/2.7.2/include/sys/types.h:274, > from /usr/include/sys/wait.h:20, > from > /usr/local/lib/gcc-lib/sparc-sun-solaris2.4/2.7.2/include/stdlib.h:17, > from Include/Python.h:50, > from Modules/python.c:3: > /usr/include/sys/siginfo.h:74: parse error before `pthread_attr_t' > /usr/include/sys/siginfo.h:74: warning: no semicolon at end of struct or > union > /usr/include/sys/siginfo.h:76: parse error before `}' > *** Error code 1 > make: Fatal error: Command failed for target `Modules/python.o' > > the same thing happens with 1.6.1 > > it works ok on another machine running SunOS 5.6. > does anyone know of a fix/workaround? okay, i'm answering my own question. but just in case anyone else trips over this, i got it to work using ./configure --without-gcc the regular sun c compiler built it without a hiccough. -- Garry Hodgson sometimes we ride on your horses Senior Hacker sometimes we walk alone Software Innovation Services sometimes the songs that we hear AT&T Labs are just songs of our own garry at sage.att.com From syver at NOSPAMcyberwatcher.com Thu Jun 21 21:36:54 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Fri, 22 Jun 2001 03:36:54 +0200 Subject: Standard module unittest, where has unittestgui gone? Message-ID: <9gu7je$58c$1@troll.powertech.no> I can't seem to find an updated unittestgui module for the version of unittest.py that's included in the Python 2.1 distro. Anyone know what's happened to it? On the PyUnit project page there is only very old versions of unittestgui and it's not compatible with the latest version of unittest.py. By the way, has anybody got any cool python icons, the standard snake is okay, but it's hard to distinguish between them when you have a messy desktop like I have. From tim at digicool.com Mon Jun 25 15:02:22 2001 From: tim at digicool.com (Tim Peters) Date: Mon, 25 Jun 2001 15:02:22 -0400 Subject: PEP 255: Simple Generators, Revised Posting In-Reply-To: <15159.33613.478566.584749@beluga.mojam.com> Message-ID: def emptyg(): return yield None # never reached [Bernhard Herzog] > Only until the compiler becomes smart enough to remove > that unreachable yield statement. :) [Rainer Deyke] > By that time, the compiler will hopefully be smart enough to > perform static analysis *before* removing dead code. [Skip Montanaro] > My peephole optimizer would have removed it... That's OK: the yield has no *runtime* purpose there, it's only being used as a signal to the compiler to set the CO_GENERATOR flag in the code object's co_code member. Under the covers, generator code objects and bytecode are exactly the same as for non-generators, except for that flag bit. So code that "looks dead" is just as dead as before . There's nothing magic about RETURN_VALUE in a generator's bytecode either. In fact, eval_frame() knows nothing about generators (it never looks at the CO_GENERATOR flag). From jonas.b at home.se Wed Jun 20 13:48:23 2001 From: jonas.b at home.se (Jonas Bengtsson) Date: 20 Jun 2001 10:48:23 -0700 Subject: Which IDE ? References: Message-ID: <4e2ddb70.0106200948.30a7bea0@posting.google.com> Have you tried Komodo? I think it is pretty great! Has code completions and all other nifty features! Try it out! /Jonas VanPopering wrote in message news:... > Which IDE would you recommend for someone *just starting out* with Python? > > -I'm not a professional programmer but Im interested in learning Python > -I want to use opensource whenever possible > -For now I'm just here for the basics; some scripting etc. > > I'd LOVE to use idle since its part of it and free, but I have heard that it freezes upand > has other problems...is this really a problem that it happens a lot? Are there things I can > do to avoid this - does it happen with larger more complex programs only? If it froze while > running the script and that was the only potential problem, then I'd just save it first... > > I am wondering if these were copmplaints by professional programmers who > needed and expected more... > > Komodo looks interesting, but I do admit it looks like a bit much for my purposes: > I want to write, edit, debug, and run simple python thingys > > I hope I misunderstood what I had heard about Idle's short comings - > > *I dont know yet and thats why Im asking* > > (I wonder what Guido uses...) > > > -David > ______________________________________________________________________ > David van Popering > Running Linux > > I'm not sleeping, I'm checking my eyelids for holes. From klassa at cisco.com Mon Jun 4 14:41:38 2001 From: klassa at cisco.com (John Klassa) Date: Mon, 04 Jun 2001 18:41:38 -0000 Subject: can't get tkinter to work with 2.1 / Solaris Message-ID: Try as I might, I can't make tkinter happy. I'm doing: make distclean ./configure --prefix=/users/klassa/local --enable-gcc \ --libdir=/users/klassa/local/lib \ --includedir=/users/klassa/local/include make make install make install libinstall I just downloaded Tcl 8.3 and installed it into the /users/klassa/local tree. It's there. :-) To wit: % cd /users/klassa/local/lib % ls -alF libt* -r-xr-xr-x 1 klassa eng 707476 Aug 31 1999 libtcl8.2.so* -r-xr-xr-x 1 klassa eng 709428 Jun 4 12:35 libtcl8.3.so* -rw-r--r-- 1 klassa eng 2012 Aug 31 1999 libtclstub8.2.a -rw-r--r-- 1 klassa eng 2012 Jun 4 12:35 libtclstub8.3.a -r-xr-xr-x 1 klassa eng 906684 Aug 31 1999 libtk8.2.so* -r-xr-xr-x 1 klassa eng 991204 Jun 4 12:38 libtk8.3.so* -rw-r--r-- 1 klassa eng 1862 Aug 31 1999 libtkstub8.2.a -rw-r--r-- 1 klassa eng 3706 Jun 4 12:38 libtkstub8.3.a -rw-r--r-- 1 klassa eng 478674 Mar 29 2000 libtransfig.a The .h files are in /users/klassa/local/include, as expected. My LD_LIBRARY_PATH includes /users/klassa/local/lib, but does *not* include /usr/local/lib. When I build python, it seems happy. When I install it and run it, then try to "import _tkinter" (per http://www.python.org/topics/tkinter/trouble.html#checking), I get: % python Python 2.1 (#1, Jun 4 2001, 13:45:22) [GCC 2.9-cisco-98r1] on sunos5 Type "copyright", "credits" or "license" for more information. >>> import _tkinter Traceback (most recent call last): File "", line 1, in ? ImportError: ld.so.1: python: fatal: libtcl8.0.so: open failed: No such file or directory >>> Note that /users/klassa/local/lib does *not* include libtcl8.0.so, which is undoubtedly the source of the problem. Yet, I can't figure out how to make python look for libtcl8.3.so. If I change my LD_LIBRARY_PATH to include a directory that has libtcl8.0.so, it works. I don't want 8.0, however. :-) I don't see anywhere that I'm explicitly telling the build process to look in /usr/local/lib (which is where it's getting the 8.0 version), yet it appears to want to go there anyway. I went so far as to edit setup.py, to remove the references to /usr/local (which it inserts, regardless -- as borne out by the comments). Didn't help. I'm grasping at straws now... Pointers to useful docs appreciated. I think I've read all the relevant once (I read through the tkinter installation and trouble-shooting pages, and grepped the source tree for other useful tidbits). Ideas? Thanks, John -- John Klassa / Cisco Systems, Inc. / RTP, NC / USA / klassa at cisco.com / <>< [ Save bits! Don't quote entire threads in your reply. ] From jcea at argo.es Fri Jun 8 11:41:41 2001 From: jcea at argo.es (Jesus Cea Avion) Date: Fri, 08 Jun 2001 17:41:41 +0200 Subject: Reraising exceptions "intact" Message-ID: <3B20F235.1FC3A9A@argo.es> I'd like to know how to reraise a "catched" exception, intact: while 1 try : func() except exceptions.KeyboardInterrupt : raise exceptions.KeyboardInterrupt except : pass Here we keep "func" running except if the user press CONTROL+C. But in this case I'd like to see a traceback for the original interrupt point, not the "artificial" "raise". Any suggestion? PS: Please, send me a copy of your reply to mi mailbox, since I can't follow the group timely. Thanks in advance. -- Jesus Cea Avion _/_/ _/_/_/ _/_/_/ jcea at argo.es http://www.argo.es/~jcea/ _/_/ _/_/ _/_/ _/_/ _/_/ _/_/ _/_/ _/_/_/_/_/ PGP Key Available at KeyServ _/_/ _/_/ _/_/ _/_/ _/_/ "Things are not so easy" _/_/ _/_/ _/_/ _/_/ _/_/ _/_/ "My name is Dump, Core Dump" _/_/_/ _/_/_/ _/_/ _/_/ "El amor es poner tu felicidad en la felicidad de otro" - Leibniz From rajarshi at presidency.com Sun Jun 3 12:51:12 2001 From: rajarshi at presidency.com (Rajarshi Guha) Date: Sun, 3 Jun 2001 22:21:12 +0530 Subject: Python output for Glade Message-ID: <9fdprb$3hpec$2@ID-91520.news.dfncis.de> Hi, does anybody know of patches etc that can give me Python source for a Glade project. I tried using glade.py but it gives a number of errors and suggests I use libglade. Is there any docs/webpages available showing how to use libglade? TIA, -- ------------------------------------------------------------- Rajarshi Guha email: rajarshi at presidency.com web: http:/www.psynet.net/jijog From gardner at cardomain.com Fri Jun 22 15:05:40 2001 From: gardner at cardomain.com (Jonathan Gardner) Date: Fri, 22 Jun 2001 12:05:40 -0700 Subject: Pythoin MUD (PyMUD?) References: <9gqq3t$hvs$1@brokaw.wa.com> Message-ID: <9h04sn$94o$1@brokaw.wa.com> Jonathan Gardner wrote: > I was tinkering around and I got the base skeleton for a python MUD > working (you can LOOK and LOOK at something... cool.) > > 3) Any newbies want to watch a mud being created? (OR - should I put this > on sourceforge? Or will you throw rotten eggs at me?) > It looks like enough people like muds to play with this. I put a project up at sourceforge called "simpymud". I just want to make this a simple python mud. I don't know much about muds, but I am going to place these restrictions from the outset: - No writing code *in* the mud. There are other people who are writing really neat muds in python - this is not it. - The MUD Driver and the MUD Game are going to be on the same level for simplicity. Again, there are other people writing really neat muds and such, this is not it. Of course, this can all be bent. I don't want a full-featured professional heavyweight champion mud. I want something small, easy to hack and grok, and fun to play with. I also want new and strange mud ideas so this can be truly unique. It'll be up in 72 hours. I'll have some code by then (and some documentation). The current status is you can actually set attributes of objects around you, and you can reference objects by one of three methods. And there are rooms and very simple exits. And you can create objects and exits and such. -- Jonathan Gardner "Infinity isn't all that large - except at the end." -- Uncle Al Please don't take anything I say seriously, even if you are really gullible. From sagwy at earthlink.net Wed Jun 13 18:00:36 2001 From: sagwy at earthlink.net (mo) Date: Wed, 13 Jun 2001 16:00:36 -0600 Subject: One of Python's Distant Ancestors Message-ID: <009e01c0f454$53950840$fbde1004@gatesway> Pythoneers who appreciate history will enjoy this fine article, "Pioneers of the 'Fortran' Programming Language", by Steve Lohr, appearing in today's New York Times. http://www.nytimes.com/2001/06/13/technology/13LOHR.html Mo From emile at fenx.com Wed Jun 27 23:28:42 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 27 Jun 2001 20:28:42 -0700 Subject: list of dictionaries References: <3B3A4B97.5F4EB1F1@cc.gatech.edu> <9hdjmt$dk0ki$1@ID-11957.news.dfncis.de> <3B3A58A1.AE09529@cc.gatech.edu> <9hdme5$di2n4$1@ID-11957.news.dfncis.de> <3B3A8F20.71F0DE04@cc.gatech.edu> Message-ID: <9he8hh$ddqps$1@ID-11957.news.dfncis.de> You need to get a handle on mutable objects, labels, and references. A dictionary is a mutable object. When you append it to a list, you're actually just putting a reference to the mutable object on the list, not the object itself. When the object changes, all references that point to the object show the changes, as there is only one object. >>> d = {1:1} # create a dictionary object and keep a reference to it in d >>> l = [] #create a list object >>> l.append(d) # put a reference to the dictionary object in the list >>> l [{1: 1}] >>> d[1]=2 #change the dictioanry object >>> l [{1: 2}] # the list reflects the change. >>> HTH, -- Emile van Sebille emile at fenx.com --------- "George Thomas" wrote in message news:3B3A8F20.71F0DE04 at cc.gatech.edu... > Hi, > > That makes sense. However, to make sure I understand completely, I'll > list the steps in question. > Given: A single dict object, call it dict (how original!) > 1. Start with empty list > 2. Update fields of dict > 3. append dict to list. > 4. Update fields of dict. > 5. append dict to list. > The thing I can't understand is: even though dict reflects the change in > (4), the append() operation seems to ignore it completely, giving me a > copy of the previous contents. Why does this happen ? Double check your results here. The list contains two references the the single resulting dict. > Thanks for the insight on the alternative solution. I guess I'll rest > easy when the issue above has an explanation :) > > Emile van Sebille wrote: > > > > It is appended. That's why you see two copies of the same dict in the list. > > To get different dicts in the list, you *must* create new dicts for each > > entry. Otherwise, each entry simply points to the same dict. You can use > > the {}.copy method for this data, but be forewarned that you need to be > > careful for nested data structures. > > > > dict_entry['a'] = a2 > > dict_entry['b'] = b2 > > dict_entry['c'] = c2 > > dict_entry['d'] = d2 > > sample_list.append(dict_entry.copy()) > > ------------------------------------------------------------ > George Thomas > reduce (lambda c,d:chr(ord(d)-2)+c, 'ofcpqkekhhC"zwpkN"fgtgyqR/pqjv{R') > ------------------------------------------------------------ From bsass at freenet.edmonton.ab.ca Sat Jun 23 21:12:51 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Sat, 23 Jun 2001 19:12:51 -0600 (MDT) Subject: Any other Python flaws? In-Reply-To: <9gr8o8$hhq$4@newshost.accu.uu.nl> Message-ID: On 20 Jun 2001, Martijn Faassen wrote: > Bruce Sass wrote: > [snip] > > If you want to use someone's GPLed lib, or GPLed software that > > exposes its libs APIs so others can make use of it, in your > > proprietary project, make sure you release the source for the libs you > > used and for any tweaks you may have made to it. > > Not to get into an endless GPL debate here, so I won't say anything > more about this, but what you say here is not the common interpretation > of the GPL. The common interpretation of the GPL is that your > software should be GPLed or GPL-able if it links to a GPL-ed library. > What you say is true for the LGPL. Yes. I was confused. > That's the last I'll say in this particular thread about the GPL. :) ditto - Bruce From tundra at tundraware.com Thu Jun 7 17:26:16 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 07 Jun 2001 21:26:16 GMT Subject: Zip File Comment Extraction Message-ID: <3B1FF0C7.D3D04952@tundraware.com> I note that the current release of the ZipFile module is unable to process zip archives which have comments in them. All my zip files have comments in them - can anyone suggest another module set or workaround so I can manipulate these files from python? TIA, -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From cja at well.com Mon Jun 4 17:37:28 2001 From: cja at well.com (Chris Abraham) Date: Mon, 4 Jun 2001 14:37:28 -0700 (PDT) Subject: Zope-Python User Group Follow-Up! In-Reply-To: Message-ID: Announcing New User Group and Associated Meeting. Zope Python Users Group. Meeting June 20th Our charter meeting is being sponsored by the DC Linux User Group and will be on June 20, 2001 at 7pm at the National Institute of Health in Bethesda, Maryland (directions & map). The presenters for the June 20th meeting will be the gang from Digital Creations, the company that supports the development of Zope and Python. Zope is a Python-based Open Source web application server for dynamic web-based business applications such as intranets and portals. Zope makes it easy to build features such as site search, news, personalization, and e-commerce into your web applications. This meeting is co-sponsored by Zope and Python User Group and DCLUG. It will be a valuable opportunity for both Zope and Python lovers to dote, as well as turning on a load of Linux Users to the unique powers, strengths, and flexibility of Zope and Python -- a couple of swell Open Source tools. -- chris abraham, managing director beehive North America, washington, dc, +1 202 548 0410 wk +1 202 478 0276 From m.faassen at vet.uu.nl Sat Jun 2 06:56:54 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 2 Jun 2001 10:56:54 GMT Subject: Python celebrities photos References: Message-ID: <9fagpm$bca$2@newshost.accu.uu.nl> Oleg Broytmann wrote: > On Wed, 30 May 2001, Simon Brunning wrote: >> > From: Oleg Broytmann [SMTP:phd at phd.fep.ru] >> > I am looking for photos of other our celebrities: Tim Peters, Barry >> > Warsaw, Jeremy Hilton (in random order, really) and other. Can anyone >> > provide pointers or just send photos? Thanks in advance. >> >> IIRC, the timbot runs on a PDP-10. I'm sure that you can find a picture here >> - . > :))) > I certainly remember seeing a photo of a person who pretends to be Real > Tim Peters... May be he was just a representative of timbot. I talked to him, but I don't believe for a minute he was the real Tim Peters. He made it all appear very vague too, when we confronted him on it. > I agree to put > his (the representative person's) photo. But I certainly not interested to > put a photo of a PDP-10, however clever programs it runs! Perpetuate the myth that Tim Peters is a real person, hm? Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From greg at cosc.canterbury.ac.nz Mon Jun 25 21:39:00 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Tue, 26 Jun 2001 13:39:00 +1200 Subject: PEP 255: Simple Generators References: <9h1tt9$16i$1@slb1.atl.mindspring.net> Message-ID: <3B37E7B4.AA2A1095@cosc.canterbury.ac.nz> Andrew Dalke wrote: > > Chemist: A what? What's a generator? > Me: It's a function that returns a special kind of object. You shouldn't have said "function", you should have said "callable object". > Me: Well, you can think of a class as a function that returns > a special kind of object. You're going way too fast for this guy, given that he doesn't know about OO yet. He needs to become comfortable with OO concepts first, then you can explain iterator objects, *then* you can explain what generators do. Until then, generators are going to seem like black magic no matter what keyword they're defined with. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From emmanuel.astier at winwise.fr Wed Jun 27 09:33:33 2001 From: emmanuel.astier at winwise.fr (Emmanuel Astier) Date: Wed, 27 Jun 2001 13:33:33 GMT Subject: Creating a _light_ python dll Message-ID: <3b39df15.103692562@news.iway.fr> Hi, I would like to use Python as a script for internet games. The game will be avalaible by download only, so size really matters. What are the modules that I can remove from the standard python ? I thought of : complex, long object, AudioOp, imageOp, md5, md5module, rgbimgmodule, rotormodule, shamodule, signalmodule, soundex, yuvconvert Are any of these necessary for python ? Are there any other module I could take back ? Is thread and threadmodule necessary, if I want to make a single thread application ? Thanks for any help, Emmanuel From dougfort at dougfort.net Tue Jun 26 08:31:17 2001 From: dougfort at dougfort.net (Doug Fort) Date: 26 Jun 2001 13:31:17 +0100 Subject: Python and Functional Programming References: Message-ID: <3b388095_5@news5.uncensored-news.com> Fabien wrote: > Dear Python People, > > I professionally use the functional programming language Clean to > write heavy-algorithmic applications, and am at the moment seeking a > flexible and powerful way to glue these applications together, along > with some GUI front-end. I read a few introductory articles about the > Python and JPython languages that seem to provide a tremendous > flexibility and a vast library panel. > > I have heard that the new versions of Python had integrated some > concepts taken from functional programming, and I would be interested > in having a few pointers to these topics. > > Sincerely yours, Fabien > Dr. David Mertz has several good articles on functional programming in Python. Check out http://gnosis.cx/publish/tech_index.html -- Doug Fort http://www.dougfort.net ______________________________________________________________________ Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com With Seven Servers In California And Texas - The Worlds Uncensored News Source From krel at is-antisocial.net Sat Jun 23 16:30:55 2001 From: krel at is-antisocial.net (krel) Date: Sat, 23 Jun 2001 20:30:55 GMT Subject: newbie question: Message-ID: Um, this is certainly a stupid sounding question, what is the syntax for putting data into and retrieving data from a multidimensional list? I checked the docs, perhaps not well enough? -- Never trust anything with more limbs than you. -krel From chrishbarker at home.net Mon Jun 4 17:09:33 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 04 Jun 2001 14:09:33 -0700 Subject: Newbie Question References: <3B1BC3C5.57F98FCD@erols.com> Message-ID: <3B1BF90D.23B3CD8C@home.net> John Cristion wrote: > > MATLAB vs. PYTHON > Please compare and contrast for this MATLAB user and newbie to PYTHON > (beyond the obvious cost, etc. issues) There's a lot to be said about this, but here are few of my thoughts as a previous heavy MATLAB user, and current heavy Python user (for somewhat, but not entirely, different things). MATLAB has a much more complete set of pre-existing numeric functions MATLAB has much better plotting facilities. All the ones for Python are wrappers around something else, none of them are truly cross platform, and all of which are harder to use thatn MATLAB. Python is much better for doing anything other than number crunching/data visualization (i.e. making a GUI, text crunching, etc.) NumPy Arrays have some nifty features that MATLAB's don't: array broadcasting, for example. I really like being able to write: >>> x = array([1,2,3,4]) >>> x array([1, 2, 3, 4]) >>> y = array([[5],[6],[7],[8]]) >>> y array([[5], [6], [7], [8]]) >>> z = x*y >>> z array([[ 5, 10, 15, 20], [ 6, 12, 18, 24], [ 7, 14, 21, 28], [ 8, 16, 24, 32]]) >>> Rather than: >> x = [1,2,3,4] x = 1 2 3 4 >> y = [5;6;7;8] y = 5 6 7 8 >> [X,Y] = meshgrid(x,y) X = 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 Y = 5 5 5 5 6 6 6 6 7 7 7 7 8 8 8 8 >> z = X.*Y z = 5 10 15 20 6 12 18 24 7 14 21 28 8 16 24 32 >> The constant need for meshgrid is annoying, and memory wasteful. Numeric arrays can be any of a large number of types, not just doubles. This can save a whole lot of memory when you need just small integers, for example. NumPy has much better facilities for dealing with arrays of greater than two dimensions. NumPy used element-wise operations by default, rather than matric operations. THis makes if more awkward to do matrix operations, but I find I do element-wise operations far more often. Python has much better object-orientation, and is generally a nicer, more powerful general perpose language. That's a few quick comments. If you're going to be using Python for MATLAB lie activities, take a look on the web for assorted useful stuff. Here area couple of links to get you started: http://scipy.org/ http://MatPy.sourceforge.net/ Have fun! -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From faustus at pureevil.org Fri Jun 8 09:36:16 2001 From: faustus at pureevil.org (Dr. Faustus) Date: 8 Jun 2001 06:36:16 -0700 Subject: Bios calls in Python? References: <3b1e6611.6945219@news.muenster.de> <72e66889.0106061446.5ffae35e@posting.google.com> <3b1fdb3b.472708@news.muenster.de> Message-ID: <72e66889.0106080536.5cac6fca@posting.google.com> m.bless at gmx.de (Martin Bless) wrote in message news:<3b1fdb3b.472708 at news.muenster.de>... > Are you sure? Does that mean my oh so very important dos application > (no joke) won't run with XP any more? My bad. Let me back off of my statement a bit. If it was an INT 21 function that was supported under DOS, then it will definitely be supported under NT/2K/XP when run from a 16-bit process. If it was an INT 21 function that was added for Windows 95 (ie for long file name support) then it will probably be supported under NT/2K/XP when run from a 16-bit process. I don't believe that *either* of these categories are supported in a 32-bit process, because it's NTVDM.EXE that implements the 16-bit interrupt functions, and that wouldn't be available in a 32-bit process. As I assumed you would be running Python as a 32-bit process under NT :), it didn't occur to me that you might have built it for DOS support and be running it as a 16-bit process. HOWEVER, I have not actually tried to verify this, and for all I know, a 32-bit process might indeed be able to issue int 21 calls under NT. > Unfortunately IT'S NOT GetFullPathName. The business is not expanding > from relative to absolute, like in: > win32api.GetFullPathName('m:\\') -> 'm:\\' > > but from substituted to unsubstituted: > rem Working dos example: > m:>truename m:\x.bat -> c:\somewhere\x.bat If the DOS functions you were using is int 21, fn 7160, then GetFullPathName is the official alternative. Of course, the SubstExpand flag is available in the int 21 version and not in the API call, but then SUBST isn't supported through any official Win32 APIs anyway. For that matter, SUBST has been on a death watch since the early 90s. -- Dr. Faustus faustus at pureevil.org From grante at visi.com Sun Jun 24 20:31:55 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 25 Jun 2001 00:31:55 GMT Subject: Is this a true statement? References: <3b34939b.410758@nntp.sprynet.com> <3b35ed3b.1401529@nntp.sprynet.com> <3b360fba.10233292@nntp.sprynet.com> Message-ID: On Sun, 24 Jun 2001 13:29:24 -0400, D-Man wrote: >When I read the original question I got the impression that >"write a device driver in Python" meant "A person sits down at >a console with a text editor, writes some Python code that >implements the device's spec in terms of the driver API >specified by the kernel". That's what the author meant, and what everybody understood (with the possible exception of David Ullrich). One could use a "deeply embedded" Python bytecode interpreter running inside the kernel to allow the user to write a driver in Python. It would take a fair amount of work, but I don't think it would be particularly difficult -- at least under Linux. People have already a lot of the requied work in order to run a Python interpreter on embedded systems. Sounds like a good MS project to me... -- Grant Edwards grante Yow! - if it GLISTENS, at gobble it!! visi.com From glen at enabledventures.com Fri Jun 8 18:46:33 2001 From: glen at enabledventures.com (Glen Starchman) Date: Fri, 08 Jun 2001 15:46:33 -0700 Subject: WHY is python slow? References: Message-ID: <3B2155C9.92733B35@enabledventures.com> Kemp Randy-W18971 wrote: > > So many factors, they are too long to mention. Machine you are running on. Operating system. Other processes or programs running. Termites chewing on the computer circuits. Maybe your watch has stopped. The Zen nature of interpreters. Time for a history lesson: When Guido first began working on Python, he was using a lowly 286 with 2MB of memory. Henceforth, he was used to his Python scripts running at a certain speed. So as not to shock himself with the performance of his new language, he created a function that would make his interpreter more steadfast: void slow(long milliseconds) { sleep(milliseconds); } As time went on, and his development machines got faster and faster, the more places he found himself placing calls to the slow method, and the longer and longer the milleseconds parameter became. At last count, there are 1400 calls to slow in pythonrun.c alone, with an average millesecond param of 500! Someday some brave soul will remove all of those slow calls and Python will be several orders of magnitude faster. From mrchameleon at hotmail.com Sun Jun 17 17:42:28 2001 From: mrchameleon at hotmail.com (Chris Reay) Date: 17 Jun 2001 14:42:28 -0700 Subject: Text Widget toolkit References: Message-ID: <7652139e.0106171342.1a280da3@posting.google.com> > > My question is : What are the various python text based toolkits available? > I don't think you'll find many. Frederick Lundh wrote a "console" ui for MS Windows, and there are a couple of wrappers around "dialog" for Linux. I have written a pure-Python text ui for ncurses and Linux which is early alpha and very clunky. I plan to release it under GPL one day (when it's further developed and I'm less ashamed of it). You'd be welcome to it (with the usual disclaimers) if you'd like. Yours Chris From nas at python.ca Tue Jun 19 20:19:38 2001 From: nas at python.ca (Neil Schemenauer) Date: Tue, 19 Jun 2001 17:19:38 -0700 Subject: Partially evaluated functions In-Reply-To: ; from rvprasad@cis.ksu.edu on Tue, Jun 19, 2001 at 06:23:13PM -0500 References: Message-ID: <20010619171938.A15411@glacier.fnational.com> This works in 2.1 (a little more magic is needed for older Pythons): >>> from __future__ import nested_scopes >>> def conv(b, c): ... return lambda a: (a + b) * c ... >>> faren2cel = conv(-32., 5./9) >>> faren2cel at 0x810f45c> >>> faren2cel(10) -12.222222222222223 >>> faren2cel(-40) -40.0 Not exactly what you want but close. Neil From tim.one at home.com Sat Jun 30 00:38:22 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 30 Jun 2001 00:38:22 -0400 Subject: [Python-iterators] While we're at it... In-Reply-To: Message-ID: [Tim, quoting from eventual 2.2 NEWS] > - The following functions were generalized to work nicely with iterator > arguments: > map(), filter(), reduce(), zip() > [many others omitted] [David Eppstein] > Is there a PEP for this? It doesn't seem to be in 234. Right -- as Thomas said, it's "too obvious". All the contexts mentioned worked by iterating over sequences before, and the Iterator PEP generalized the notion of iterating over sequences. So it was just screamingly natural to generalize *all* contexts that iterated over sequences in the same way. > Can I assume that "work nicely" means they act like simple generators > in yielding partial results even when their inputs are infinite > sequences? No, and *none* of them do except for those that did before; for example, zip stops as soon as any of its sequence arguments says "I'm done", even if other zip arguments have not been exhausted: >>> zip(range(3), xrange(sys.maxint)) [(0, 0), (1, 1), (2, 2)] >>> These have always returned (for the most part) lists, and that can't be changed: lists have a rich set of methods, while iterators have only one ("get me the next item"), so we can never change a list-producing context into an iterator-producing one without risking major code breakage. That's OK by me! While I've been spending some of my work time and virtually all of my "spare time" getting this new stuff to work well, it's not something I expect people will use *routinely*. Explicit lists are great, and mucking around with lazy alternatives is something most people won't have to worry about most of the time. When you do need to worry about it, the new facilities are great too, but you'll have to "do something" to get them then. For everyone else, it's 100% backward compatible (even better, faster than it was before, and easier to write new iterators). From paragate at gmx.net Wed Jun 6 06:33:43 2001 From: paragate at gmx.net (Wolfgang Lipp) Date: 6 Jun 2001 03:33:43 -0700 Subject: ExtensionClasses for Python 2.1? Message-ID: <6564c76c.0106060233.100516da@posting.google.com> Does anyone know whether Jim Fulton of Zope's ;-) ExtensionClass module is available for Python 2.1 (preferrably compiled for w95, actually...)? AFAIK, the current version should be at least 1.2; also, ExtensionClasses seemed to have worked at least upto Python 2.0. Also, if anyone knows about alternative implementations of either Extension Classes in general (inheritance from 'Types' that is) or Acquisition, please let me know. Thanks a lot, some-python-modules-are-too-hard-to-find-ly yours, -wolf From thomas.heller at ion-tof.com Fri Jun 22 05:25:59 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Fri, 22 Jun 2001 11:25:59 +0200 Subject: How to tell if interpreter is in interactive mode References: <9gl7ba07u8@enews2.newsguy.com> Message-ID: <9gv2s2$ao024$1@ID-59885.news.dfncis.de> "Alex Martelli" wrote in message news:9gl7ba07u8 at enews2.newsguy.com... [John Copella asked how to tell if interpreter is in interactive mode] > > It IS pretty easy -- sorry, hadn't noticed your question earlier! > Hoping the answer is still of interest despite the 5 days since > you asked...: > > In module sys, an attribute named ps1 exists during interactive > interpreter sessions. IDE's such as IDLE and PythonWin also set > it (it's normally the string ">>> "). This attribute is *NOT* set > if the interpreter is NOT interactive. > The only catch is that this attribute is not yet defined when sitecustomize is imported. Any other solutions? Thomas From grante at visi.com Sun Jun 24 20:52:23 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 25 Jun 2001 00:52:23 GMT Subject: Is this a true statement? References: <3B364F79.F20EFAB0@tundraware.com> Message-ID: On 24 Jun 2001 20:40:01 GMT, Tim Daneliuk wrote: >I also have no doubt that there are some things that are highly >impractical to "do" in Python and that you can also find such >an example for any language. What is "practical" for a particular language is often a function of available memory and processor speed. I remember when programming for many embedded applications in a high level language was deemed impractical. What's practical when you've got 128 bytes of RAM, 512 bytes of ROM, and a 100KHz processor is different than what's practical with 8M of RAM, 4M of ROM and a 44MHz processor. Implimenting a Python byte-code interpreter in kernel-space on a mondern Unix system wouldn't be that hard. The things that low-level device drivers (the ones that diddle hardware) do are simple and low level, and C is pretty well suited for the task. Mid-level stuff (e.g. filesystem manipulation and network protocols) would be a lot more suitable for Python implimentation. >But to the larger point of the original poster's question: I cannot >conceive of ANY reason to use C++ for ANYTHING and I've felt that way >from the day Stroustrup first exposed it to the rest of us. My feelings exactly. Use C when you have to, Python or Modula-3 when you can. >It is an abomination on the face of programming, there were and >are much better choices if you insist on using OO (which I do >not think is the Silver Bullet is has been proclaimed to be), >and it has the worst of all worlds: the complexity of an OO >infrastructure, the ease of self-annihilation of a systems >language, and a syntax so awful as to be virtually unreadable. Hear, hear. (or is it "here, here"?) -- Grant Edwards grante Yow! I always have fun at because I'm out of my visi.com mind!!! From rnd at onego.ru Sun Jun 17 01:31:14 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 17 Jun 2001 09:31:14 +0400 (MSD) Subject: += overloading? In-Reply-To: <3b2c2cbb$0$324$8eec23a@newsreader.tycho.net> Message-ID: On Sat, 16 Jun 2001, Neil Macneale wrote: >I am creating a colored stringbuffer class, and I want to append words to >the buffer with the '+=' operator. Ex: > >>>>csb = CSB("INIT STRING") >>>>csb += "Hello" >>>>print csb >INIT STRINGHello > >would be the desired effect. I can't seem to find anything in the lib >docs about overloading that operator though. Am I looking in the wrong >place? It is also important that a new object is NOT created every time >the operator is used, because that would be a waste. class CSB: def __iadd__(self, x): self._string += x >Suggestions? Thanks for any tips! > >Neil Macneale > >-- >To reply to me via email, remove the '-devnull' from my address. > Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, June 17, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Tis better to have loved a short than to never have loved a tall." _/ From tjenkins at devis.com Tue Jun 5 17:58:16 2001 From: tjenkins at devis.com (Tom Jenkins) Date: Tue, 05 Jun 2001 17:58:16 -0400 Subject: PyGame, IDE problems References: Message-ID: <3B1D55F8.9050001@devis.com> Nick Perkins wrote: > I can not run the example programs from Pygame from within either PythonWin > or IDLE. I am running Py 2.1 on NT4. > ( They both freeze up ) > > The examples do run by themselves, (ie not from within an IDE). > Also, curiously enough, they do run from within Boa Constructor's editor. > > Does anyone know why this is so? > Does anyone have the same problem, or is it just me? > > I believe its a threading issue... both PythonWin and IDLE run your app in the same thread (and GUI event loop) as the IDE. BOA runs your app in another process I believe so you won't have that problem. -- Tom Jenkins devIS - Development Infostructure http://www.devis.com From ralf.muschall at alphasat.de Wed Jun 27 18:21:12 2001 From: ralf.muschall at alphasat.de (Ralf Muschall) Date: 28 Jun 2001 00:21:12 +0200 Subject: PEP 260: simplify xrange() References: Message-ID: Roman Suzi writes: > in webified forms (somewhere). If gcc people will want to remove, say, > scanf function, they will certainly find that Linux kernel uses it ;-) No, it doesn't (I just (find -exec grep)ped it (but I didn't expect such a wart there anyway)). Only a few standalone programs living there use it, and a SCSI driver defines its own function "dc390_scanf" (which calls stroul) and is found therefore. Btw., am I the only one who thinks that removing scanf would be a good idea (for the libc people, not the gcc ones)? Do they accept CDPs[1]? > Then GvR just googles around to find out that, OK, xrange is not used > anywhere in the 3 month old code, so we should remove it from CVS. CVS is such a powerful protocol that this could be happen automatically, giving GvR more time to add continuations and monads. Another problem is people who write text like "don't use xrange(a)[b:c]" and put *that* on the web. Since google's philosophy is "be fast and complete, not smart", this will never be recognized. [1] C depletion proposal Ralf From cfelling at iae.nl Thu Jun 14 15:10:31 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 14 Jun 2001 21:10:31 +0200 Subject: Python 2.0.1c1 - GPL-compatible release candidate References: Message-ID: <9gb277$71h$1@animus.fel.iae.nl> Guido van Rossum wrote: > With a sigh of relief I announce Python 2.0.1c1 -- the first Python > release in a long time whose license is fully compatible with the GPL: > http://www.python.org/2.0.1/ Thanks a lot! This must be one of my better Python days: GPL compatible again and coroutine like generators at the horizon. -- groetjes, carel From volucris at hotmail.com Thu Jun 21 18:13:14 2001 From: volucris at hotmail.com (Volucris) Date: Thu, 21 Jun 2001 17:13:14 -0500 Subject: launching a file with its associated application on windows References: <3b313ae6$0$327$6e49188b@news.goldengate.net> Message-ID: <3b327114$0$319$6e49188b@news.goldengate.net> "Volucris" wrote in message news:3b313ae6$0$327$6e49188b at news.goldengate.net... > If it's pre 2.0, I think you can prefix a popen() command with 'start ' to > do the same thing. > > import os > os.popen('start %s' % r'C:\sish\MyPic.bmp') yeah, I'm stupid. That should be system() not popen(), although popen() would work, too, depending on what exactly you are doing. You wouldn't want a pipe to a (.bmp) file, though, would you? Maybe. I don't know. I'm rambling again. Good bye. > > > -- > > Volucris (a) hotmail.com > "Eu n?o falo uma ?nica palavra do portugu?s." > "Tim Peters" wrote in message > news:mailman.993076625.9823.python-list at python.org... > > [Christian Reyes] > > > Is there a method that takes a file as an argument and then opens > > > that file with the its associated viewer? > > > > This must be a Windows question, right? If so, in Python 2.0 or later, > the > > Windows-specific os.startfile() does exactly that. > > > > > > From arunramu at usa.net Fri Jun 29 13:47:08 2001 From: arunramu at usa.net (Blue whale) Date: 29 Jun 2001 10:47:08 -0700 Subject: threading question? References: <9hh5b9$j2r$1@panix3.panix.com> Message-ID: Thanks very much! Arun aahz at panix.com (Aahz Maruch) wrote in message news:<9hh5b9$j2r$1 at panix3.panix.com>... > In article , > Blue whale wrote: > > > >I am relatively new to python. Can anyone guide me to a good resource > >where I can learn more about the threading module in python. I just > >know that using threads one can write a program which can perform > >multiple tasks indepedently and simultaneously. > > http://starship.python.net/crew/aahz/ From aleaxit at yahoo.com Sat Jun 30 17:26:20 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 30 Jun 2001 23:26:20 +0200 Subject: 'with' statement in python ? References: Message-ID: <9hlg5902as5@enews1.newsguy.com> "D-Man" wrote in message news:mailman.993920867.31303.python-list at python.org... > On Thu, Jun 28, 2001 at 10:13:40PM -0400, Steve Holden wrote: > | The reappearance of the FAQ wizard allowed me to enter: > | > | 6.31. Why doesn't Python have a "with" statement like Delphi's Object > | Pascal? > > I just found out that JavaScript has a "with" statement (spelled > "with" too). Might want to add that. Visual Basic (and VBA, and VBScript) have it, too. Again, same spelling for the keyword, but attributes of the 'with-ed' object are spelled with a leading dot. Nested with's are allowed, but the outer one[s] are not "active" within an inner one -- e.g., in: with fee with fie .foo = .fum(23) end with end with both the .foo AND .fum references MUST be to attributes of object fie -- there is NO role implicitly played by object fee in this case. Alex From hellan at acm.org Wed Jun 6 15:39:42 2001 From: hellan at acm.org (Jon K Hellan) Date: 06 Jun 2001 21:39:42 +0200 Subject: writing gnumeric functions in python References: Message-ID: <8766e9s8ht.fsf@parus.parus.no> Skip Montanaro writes: > I'm using Gnumeric 0.64 as delivered with Mandrake 8.0. I'm trying to > figure out what you can do in Python to program the Gnumeric spreadsheet. I > couldn't find anything in the Gnumeric manual. I have a few questions and > was hoping someone here could steer me in the right direction. I'll refrain from giving detailed howto advice here, partly because the scripting support in Gnumeric is experimental and may change without notice, partly because it's been over a year since I touched that part of the code. However, there is documentation about writing spreadsheet functions in Python in the file doc/python-gnumeric.txt in the source tarball. You can view it on line at http://cvs.gnome.org/lxr/source/gnumeric/doc/python-gnumeric.txt There is also a python plugin loader which lets you write new plugins in Python. Apart from the source, there is no documentation for this. We would be very happy to receive input about improving the Python plugins, and about how to do scripting in general. Firming up the scripting API is one of the things we'll turn to after the 1.0 release is out the door. Regards Jon K?re Hellan From nytaylor at bestweb.net Wed Jun 27 19:05:57 2001 From: nytaylor at bestweb.net (Michaell Taylor) Date: Wed, 27 Jun 2001 19:05:57 -0400 Subject: exec "global" problem Message-ID: <01062719055701.09000@penguin> I have seen lots of discussion of the problem of executing the following code: global sub sub=['sub1', 'sub2', ...'sub600'] def make(): for X in range(1,600): exec "global sub%s" % (X) exec "sub%s={}" % (X) other stuff The problem is the exec "global sub%s" % (X) line which doesn't execute because of the timing of the execution of the exec and the global statements - which I don't entirely understand. These 600 dictionaries are subsequently passed to a variety of functions. My real question is how can I get around this without specifying each of the 600 variables which need global declarations. Any ideas? I really need a good wildcard as in : global sub* ========================================= Debra Taylor From qrczak at knm.org.pl Wed Jun 6 14:52:13 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 6 Jun 2001 18:52:13 GMT Subject: How do I return binary data from a python CGI called from CGIHTTPServer? References: <9f96kb01mq8@enews1.newsguy.com> Message-ID: Tue, 5 Jun 2001 16:11:57 -0400, D-Man pisze: > In MS-DOS terminals ctrl-z is used to indicate that you want to close > the input stream (EOF). On Unix terminals it is ctrl-d instead. I > think that the problem must be the sub-process thinks it is writing to > a tty rather than a regular file, and thus is closing the output when > you try and write ctrl-z. Ctrl-z in DOS is not fully analogous to Ctrl-d in Unix. Text files are usually assumed to end if Ctrl-z is encountered - it's not only for terminals. This silliness comes from CP/M which did not store file sizes exactly but rounded up to the block size, so applications had to agree on a convention for ending text files at an arbitrary point. Old editors often put a single Ctrl-z at end of file, and for example appending to files in Turbo Pascal checks for possible Ctrl-z in the last couple of bytes in the file and overwrites it if necessary. Handling Ctrl-z applies to text files like newline conversion, except that it's hardly ever output now. Since C was invented together with Unix, C on other platforms translates newline markers to the C & Unix convention, and many other languages picked this idea too, because it's simpler to uniformly work on a distinguished constant character for line ending (and they can often use the C library to do the actual work)... -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From thinkit8 at lycos.com Sat Jun 9 21:18:15 2001 From: thinkit8 at lycos.com (thinkit) Date: 9 Jun 2001 18:18:15 -0700 Subject: extracting hex mant+exp from double? Message-ID: <2135894.0001544d.006@drn.newsguy.com> python docs say floats are all doubles...which usually (i think always) is the IEEE spec for 8-byte float. are there any routines out there to extract the binary mantissa and exponent...or better hexadecimal mantissa and exponent out of the float? i want to do some statistics but don't want to use decimal. i know you can access the 8 bytes with struct lib...then do some bit manipulations to do the trick. has anybody done this already? From nospam at newsranger.com Sat Jun 30 09:52:50 2001 From: nospam at newsranger.com (Levente Sandor) Date: Sat, 30 Jun 2001 13:52:50 GMT Subject: Why Not Translate Perl to C References: Message-ID: In article , Oleg Broytmann says... > This is about Perl, but it applies to Python as well. And of course not >only to C, but to native code too. > >http://www.perl.com/pub/a/2001/06/27/ctoperl.html > > "A C program to do what your Perl program does would have to do most of >the same things that the Perl interpreter does when it runs your Perl >program. There is no reason to think that the C program could do those >things faster than the Perl interpreter does them, because the Perl >interpreter itself is written in very fast C." > I think there is a very serious reason to think that. Of course, calling a C function from an interpreted language isn't significantly slower than doing the same thing in machine code. But just compare some "pure" Python functions or loops to their C equivalents. "4.7 cStringIO -- Faster version of StringIO The module cStringIO provides an interface similar to that of the StringIO module. Heavy use of StringIO.StringIO objects can be made more efficient by using the function StringIO() from this module instead." (From the Python Library reference) Levi From bos at hack.org Mon Jun 18 08:26:12 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Mon, 18 Jun 2001 14:26:12 +0200 Subject: list.sort() References: <3B2CEBF1.CCF5377D@hack.org> <3B2DA731.1BAA305E@hack.org> Message-ID: <3B2DF364.EDBAE989@hack.org> Martin von Loewis wrote: > If you think such methods should be added, please write a PEP. I'm horrible at writing documents and expressing my minds in a manner that is legible and comprehensive, and I'm sure a PEP by me would be thrown away pretty fast. -- Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From mcfletch at home.com Sun Jun 10 02:15:22 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Sun, 10 Jun 2001 02:15:22 -0400 Subject: extracting hex mant+exp from double? In-Reply-To: Message-ID: <000401c0f174$bbb3b170$a9807018@cr706570a> Has anyone ever used it since it was slipped in (save you, in this one case)? I must be suspicious when a time machine is hanging around. I've never noticed code using it (that I can recall). "practicality-beats-purity-ly y'rs" how does it apply? I mean, I can see maybe in interactive environments you might get cases where you forgot to put x = in front of the last value and could save a few seconds recalculation, but otherwise it just seems like pointless magic. Oh well, once the time machine's been used I suppose the decision's done. I'll just console my offended sensibilities with the hope that no-one actually uses it. Of course, trying to strip it out without access to the time machine would be impractical, so I suppose that could be the practicality argument... or an argument to free up access to the time machine... Ick still, even if it were hidden in there the whole time and not just more Time Machine fiddling, Mike -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Tim Peters Sent: June 10, 2001 01:49 To: python-list at python.org Subject: RE: extracting hex mant+exp from double? ... > Ick, > Mike Hunting this down in CVS, Guido added it in ceval.c, Revision 2.64.2.6, on Thu Apr 28 12:51:01 1994 UTC. I agree it's *so* un-Pythonic that Python really wouldn't be Python without it . practicality-beats-purity-ly y'rs - tim -- http://mail.python.org/mailman/listinfo/python-list From clpy at snakefarm.org Fri Jun 22 10:45:50 2001 From: clpy at snakefarm.org (Carsten Gaebler) Date: Fri, 22 Jun 2001 16:45:50 +0200 Subject: File name from file descriptor? References: Message-ID: <3B335A1E.809B3FF7@snakefarm.org> Carlos Ribeiro wrote: > functionality depend a lot on the OS being used. Could you please tell us > why do you *need* to make it work using file descriptors? The problem is this: I have a script that is called like ./myscript.py < somefile where somefile is a text file which may or may not be gzipped. To determine whether or not the data is gzipped I read in one byte via the gzip module. If that raises an exception I know the data is not gzipped. But I'd miss the first byte if it is gzipped. Yes, I could store this byte somewhere and then pass it around somehow, but ... you know? :-) So I'd like to open a second 'instance' of the file for reading but I only have sys.stdin's file descriptor. cg. > > At 14:03 22/06/01 +0200, Carsten Gaebler wrote: > >Hi there! > > > >How can I determine a file's name if I only have the file descriptor? > >os.fdopen(fd).name just returns '(fdopen)'. > > From ullrich at math.okstate.edu Thu Jun 7 11:10:11 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Thu, 07 Jun 2001 15:10:11 GMT Subject: random References: <3b1cf00f.5441109@nntp.sprynet.com> <3b1e4957.3040319@nntp.sprynet.com> <9flkqc01nfp@enews2.newsguy.com> Message-ID: <3b1f97ca.4530449@nntp.sprynet.com> On Wed, 6 Jun 2001 18:12:59 +0200, "Alex Martelli" wrote: >"David C. Ullrich" wrote in message >news:3b1e4957.3040319 at nntp.sprynet.com... >> On Tue, 05 Jun 2001 20:42:47 GMT, wtanksle at dolphin.openprojects.net >> (William Tanksley) wrote: >> >> >On Tue, 05 Jun 2001 15:09:25 GMT, David C. Ullrich wrote: >> >>But this question is not meant to be rhetorical: We have a syntax where >> >>the valid programs are exactly finite sequences of 0's terminated by a >1. >> >>Does this count as "self-delimiting"? >> > >> >Yes, but I don't think it counts as a UTM program. There are only >> >countably many possible programs for this machine, while a UTM can run >> >uncountably many. >> >> Um. Some of these "programs" have infinite length, then? If they > >I think a Universal Turing Machine should by definition >accept programs of infinite length. I don't think that it should. It's supposed to be able to "emulate" an arbitrary TM. It takes only finitely much space to define a given TM - I don't see any _reason_ to use infintely much space to hold finitely much data. What you're calling part of the program here and elsewhere I would regard as part of the input stream to a program, not part of the program itself. I would not presume to insist that my usage is "correct" here, but that's what I meant (and also if an arbitrary input stream is allowed as part of a TM then there _does_ for example exist a TM that calculates the bits of Omega one by one.) > It has an infinite >length tape and the program is written there; is there >any clause I'm forgetting which says the tape cannot have >an infinite number of symbols on it when the run starts? > >> all have finite length then there's only countably many - that's >> even if the length is unbounded. If a UTM actually runs programs >> of infinite length then fine, but I can't imagine what it means >> to run such a program. > >Some of those runs will in fact halt (not all of the >program steps that are on the tape need be reachable, >surely?), other won't, some of those that don't halt >will reach all steps on the tape. I don't see what >is strange about that, so I may be missing something. > >Let's take an example to fix ideas. We won't even >take a Universal TM, just a plain TM. Symbols on the >tape mean (summarizing a little): > 0 print a 0, overwrite the 0 with NOP, get to state A > 1 print a 1, overwrite the 1 with NOP, get to state A > X get to state B, move right > NOP if state B move right, if state A move left > H halt >A typical program is an X followed by a sequence of >0 and 1 (there may be NOP's there, but they have no >effect -- there may be X's, which also have no >effect on the output -- there may be H's, of course, >to halt the program). > >If the program is finite, this non-universal Turing >Machine prints a finite sequence of 0's and 1's then >halts. If the program is infinite but contains a H >somewhere, ditto -- nothing right from the H is even >considered. If the program is infinite and contains >no 'H', we have a non-halting program, which just >keeps printing 0's and 1's as its original "source >code" (:-) specifies. > >It seems clear to me that this IS a pretty ordinary >Turing Machine. Am I missing something? > >The sets of programs for this TM seems to be in a >natural correspondence with all reals between 0 >and 1. Many programs output the same real, of >course, since we have the ability to place NOP's, >but by a typical Cantor diagonal argument the cardinality >of the set of programs would seem to be that of the >reals (am I missing something here?) as we can >easily encode each program into a real (between >0 and 1, say) by using 3 bits to encode each >symbol and just catenating them. > >By definition of Universal, a UTM should be able >to execute these programs (as well as many others). >So, the set of programs a UTM can execute has a >cardinality of at least that of the reals. Since >a UTM's program is an enumerable sequence from a >finite alphabet, the cardinality of the set of >programs seems to be EXACTLY that of the reals >(same construction as above). > >It's been a LONG, LONG time since I had to wrestle >with such stuff, so please DO let me know what >subtle clauses in the various relevant definitions >I'm missing, if any... I really am _not_ an authority on the definitions here. But my impression is that people do use the phrase "TM" ambiguously: The definition of "TM" sounds like the tape is part of the TM, but when people talk about how many TM's there are and what a TM can and cannot do it seems clear they are no including that tape as part of the TM, otherwise everything they say would be nonsense. >(Ah, to be 20 again...!-) > > >Alex > > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From whisper at oz.nospamnet Tue Jun 12 12:56:20 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 12 Jun 2001 16:56:20 GMT Subject: Python grammar.. References: <9g3ee3$dcq$1@news.mathworks.com> Message-ID: <9g5hjk$ird$1@216.39.170.247> In article <9g3ee3$dcq$1 at news.mathworks.com>, jmarshal at mathworks.com says... > John wrote: > > Hi, > > > I previously asked whether Python accepts function arguments without the > > opening/closing brackets and commas, like so: foo(x,y) would become foo x > > y. The answer to this was no. So, I am wondering if it would be easy to > > modify the source and rebuild the interpretor to accept this format? I > > tried modifying the Grammar file but that didn't seem to work... > > This introduces an ambiguity: how do you parse "f(1,2)"? Is it the > function f called with 2 arguments or is it f called with one > argument--the tuple (1,2)? I don't think there's any way to > disambiguate using parens. > > This issue doesn't come up in SML (the only other language I know that > uses concatenation for function application) because all functions in > SML take exactly one argument. > Smalltalk is paren free for function calls: |mystring len dict croak| #arg declarations such as they are - no typing. mystring := String new. mystring add: "this is a string". len := mstring length. len := (mystring add: "this is a string") length. dict := Dictionary new. dict at: "frog" put: "ribbet". croak := dict at: "frog". One thing to note is that keyward arguments that expect a value use : (required syntax) to denote that they do have an argument. Also, as you can see, parens can be used to control order of evaluation and the above paren'd expression results in the string to which the length method message is sent. Parens are actually required to enforce the commonly expected order of evaluation - * does not have precedence of evaluation over (for instance) -. Smalltalk uses strict left to right evluation unless parens are used. deprecating parens as argument grouping operators is one thing i'd love to see happen in Python! And postfix (only!) ++ and -- and .... and .... aond of course implied self! Regards, Dave LeBlanc From jeff at ccvcorp.com Wed Jun 13 17:30:41 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: 13 Jun 2001 14:30:41 -0700 Subject: Need help with threads References: <_nOV6.9330$ki5.130125@vixen.cso.uiuc.edu> Message-ID: <16074dce.0106131330.5204fe29@posting.google.com> Damian Menscher wrote in message news:<_nOV6.9330$ki5.130125 at vixen.cso.uiuc.edu>... > I'm trying to use threads to run various processes that require some > I/O. This is apparently broken. Here's a simple program: > > ================================================= > > #!/usr/bin/python > import time > import thread > import popen2 > > While I'm posting... is there an elegant way to wait till all threads > have finished? I can't count on things finishing in a fixed time for > my application. > > Ideas? Please?? > > Damian Menscher My suggestion would be to use the 'threading' module instead of the 'thread' module--it's a higher level, cleaner interface. import threading def ThreadFunc(my_arg): print "Thread given argument of: %s" % str(my_arg) for n in range(10): threadname = "MyThread%d" % n newthread = threading.Thread( target=ThreadFunc, name=threadname, args=(n,) ) newthread.start() the threading module defines a Thread class whose constructor takes several keyword arguments, some of which are optional. Most important is the target argument, which is the function that comprises the body of the thread. This function is passed a tuple of arguments specified by args. Check the docstrings and help file of the threading module for more details. Also, if you wish to pause until a particular thread is finished, you can use the Thread.join() method, which also has an optional timeout parameter-- i.e., mythread.join(30) will pause until mythread finishes execution or 30 seconds have passed, whichever comes first, thus allowing you to have a chance to kill or recover from a deadlocked thread. (Timeouts are a good thing.) p.s. I suspect that your problem may have been due to some subtle deadlock or race condition between your threads, though I'm not sure. Any time any thread accesses a global resource, it should be protected by some sort of lock or semaphore. Technically, this probably applies even to the print statement in my example, but..... :) Jeff Shannon Technician/Programmer Credit International From mwh at python.net Sun Jun 17 05:05:34 2001 From: mwh at python.net (Michael Hudson) Date: 17 Jun 2001 10:05:34 +0100 Subject: forcing python to build a static libpython2.1.a References: Message-ID: Roman Milner writes: > Is there an easy way to have the build process disable dynamic > loading? I just want a plain old static libpython2.1.a. > > I've been able to build a static lib, but only by manually creating > one after the python build process. I'm looking for a configure > switch (that I haven't been able to find) or something similar, that > will do this for me. I think the most efficuient way to do what you want is to uncomment the modules you want to build statically in Modules/Setup. Read the comments in the top of Modules/Setup.dist in the source distribution for more info. Cheers, M. -- My hat is lined with tinfoil for protection in the unlikely event that the droid gets his PowerPoint presentation working. -- Alan W. Frame, alt.sysadmin.recovery From rnd at onego.ru Wed Jun 27 09:55:57 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 27 Jun 2001 17:55:57 +0400 (MSD) Subject: regex scanner question In-Reply-To: Message-ID: On 27 Jun 2001, Michael Hudson wrote: > ... as here. It's my understanding that these features are > experimental, possibly buggy and certainly not documented. > > OTOH, if you (or anyone else) think they're useful, can get them to > work and (especially) write some docs, there's every chance thay will > become a standard feature. Good proposal! > [...] > > Is it standard Python feature I could safely use or will it be dropped > > soon as it happened to xrange as a sequence type? > > It might get binned if noone makes use of it. But if there's a move > to get rid of it, I'm sure it would be preceded by a "is anyone using > sre.scanner?" query. Probably I need to look at the source for comments.. > > > Could use of .scanner be recommended or not recommended? > > If it solves your problem, I'd recommend it. They're not going to go > away before 2.2, you can be sure . Of course it solves! It allows to search for matches one at a time. The problem is that I think in 2.3 probably regex will be rewritten again to adopt iterators/generators... > > BTW, generators could be very useful if applied inside regex routines. > > They will make it easy to hop from ane finding to another without taking > > too much memory. > > Example? text = """ 1 2 ..... dfsdfds 234 dfs324234 """" r = re.compile("\d+") for match in r.matches(text): # <<< allmatches is a generator print match.group() ... Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From aleaxit at yahoo.com Wed Jun 6 04:51:42 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 6 Jun 2001 10:51:42 +0200 Subject: priority queue References: Message-ID: <9fkquu0a79@enews2.newsguy.com> "Nick Perkins" wrote in message news:TgkT6.142529$eK2.34324960 at news4.rdc1.on.home.com... > I need a priority queue, but I am not sure what kind I should use. I will > be doing insertions that will likely fall somewhere in the middle, and will > only be removing from the front of the queue. I expect insertions to > out-number removals by about 2 or 3 to one. That queue is going to grow VERY, VERY big if 2 or 3 things are inserted into it for each one that is removed...! > The easy way would be to just have a list, and .sort() it at each insertion. > This, i am sure, would not be the fastest way. > > I think that a heap would best suit my needs. > I could code one myself, but it must have been done before. > I can't find one in the cookbook, or the vaults! Standard module bisect, particularly with the 2.1 enhancements (functions insort() & friends), is, I suspect, just what you want. To wrap it up as a class: import bisect class PriorityQueue: def __init__(self, initseq=[]): self._seq = list(initseq) self._seq.sort() def push(self, item): bisect.insort(self._seq, item) def pop(self): return self._seq.pop() def __length__(self): return len(self._seq) this uses the end of the self.seq as "front of the queue" -- it will yield the LARGEST current element at each .pop(). Presumably you can arrange your items and their comparison so that works right for your purposes. If you'd rather have an explicit "priority" field accompanying each item: class AnotherPQ: def __init__(self): self._seq=[] def push(self, item, priority): bisect.insort(self._seq, (priority, item)) def pop(self): return self._seq.pop()[1] def __length__(self): return len(self._seq) or thereabouts... For a Heap data structure, see: http://www.faqts.com/knowledge_base/view.phtml/aid/2820/fid/481 Alex From sdm7g at Virginia.EDU Fri Jun 1 15:53:54 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Fri, 1 Jun 2001 15:53:54 -0400 (EDT) Subject: HELP: Weird attribute behavior... In-Reply-To: <3B17E975.F11AB911@core.com> Message-ID: On Fri, 1 Jun 2001, Ralph Allan Rice wrote: > I am developing a class that stores device reading information. It > looks like this: > > > import string > import dbi, odbc > > > class Reading: > __data = { } > > def __init__(self, type, id, timezone, datestamp, value): > self.__data['id'] = id > self.__data['timezone'] = timezone > self.__data['datestamp'] =datestamp > self.__data['value'] = value > self.__data['type']= type > > change that to: class Reading: ## move __data def __init__(self, type, id, timezone, datestamp, value): self.__data = { } ## to here self.__data['id'] = id self.__data['timezone'] = timezone self.__data['datestamp'] =datestamp self.__data['value'] = value self.__data['type']= type In your example, __data is a shared class attribute. If you create it in the __init__ method, then it's owned by that instance only. -- Steve Majewski From xyzmats at laplaza.org Wed Jun 6 09:49:45 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Wed, 06 Jun 2001 13:49:45 GMT Subject: Interesting speed benchmark References: <3B1D6FED.4070506@nospam.yahoo.com> <9fkh50$6e1$1@panix6.panix.com> <9fkt3u$1i0ub$1@sky.inp.nsk.su> Message-ID: <3b1e331b.1407333@news.laplaza.org> On Wed, 6 Jun 2001 16:28:29 +0700, "Andy Salnikov" wrote: > >"Aahz Maruch" wrote in message >news:9fkh50$6e1$1 at panix6.panix.com... > >> My guess is that this represents a pathological case for Python's memory >> management system. Each time through the outer loop after the first, >> Python has to walk the chain of 10K objects, deallocating them >> one-by-one > >I'd better say that it represents a pathological case for Java memory >management, which does not bother to destroy unreachable objects and instead >eats up memory like a pig:) Anyone compared memory usage in these two tests? That's because Java leaves that to the gabage collector. Which is quite sophisticated but to us mere mortals often presents the image of "yeah, yeah, I'll get around to it. Maybe tomorrow." But this sounds like a place where it would do okay, because the whole wonky chain of 10000 objects can be reaped by the gc. Nonetheless, I'm not convinced that's what's going on here. Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From philh at comuno.freeserve.co.uk Fri Jun 15 13:54:51 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 15 Jun 2001 18:54:51 +0100 Subject: Parrot-0.2.6 released References: Message-ID: On 15 Jun 2001 13:59:29 GMT, Sam Holden wrote: >On Fri, 15 Jun 2001 13:34:58 -0000, > Jan Schaumann wrote: >>* phil hunt wrote: >>> >>> I have just released Parrot version 0.2.6. >> >>http://use.perl.org/article.pl?sid=01/03/31/206248 >> >>Any connection or a coincidence? > >Coincidence I suspect... It is. BTW I was using the name first. -- ## Philip Hunt ## ## philh at comuno.freeserve.co.uk ## From dgoodger at bigfoot.com Sat Jun 16 09:56:41 2001 From: dgoodger at bigfoot.com (David Goodger) Date: Sat, 16 Jun 2001 09:56:41 -0400 Subject: ihooks or imputil? References: <233dd1ac.0106160043.5e4bd1a5@posting.google.com> Message-ID: on 2001-06-16 4:43 AM, Frank Conradie (frank at opticode.co.za) wrote: > Can anybody please tell me which is the "preferred" or "official" way > to create custom importers, and where I can find *recent* example code > or documentation? Check out my "cross-platform import hook for end-of-line conversion": http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/59867 It uses ihooks. -- David Goodger dgoodger at bigfoot.com Open-source projects: - Python Docstring Processing System: http://docstring.sf.net - reStructuredText: http://structuredtext.sf.net - The Go Tools Project: http://gotools.sf.net From jm7potter at hotmail.com Wed Jun 27 08:35:57 2001 From: jm7potter at hotmail.com (Joe Potter) Date: Wed, 27 Jun 2001 08:35:57 -0400 Subject: newbie with major "lambda" problem (perhaps a scope problem as well) References: Message-ID: On Tue, 26 Jun 2001 22:00:52 -0700, "John Roth" wrote: > >"Joe Potter" wrote in message >news:n8dhjt8qmel0ajjae7tv9gmjf60c39qag5 at 4ax.com... >> On Tue, 26 Jun 2001 16:09:06 GMT, "Rainer Deyke" >wrote: >> >> >"Joe Potter" wrote in message >> >news:j5ahjtkfmf32lkqtap0q1u6rig385d7b5i at 4ax.com... >> >> # the "button" below works like a champ !! >> >> #Button(root, text='Fetch', >> >> #command=(lambda v=vars: fetch(v))).pack(side=LEFT) >> >> >> >> # the "button" below does not do anything ?????? >> >> Button(root, text='Fetch', command=(fetch(vars))).pack(side=LEFT) >> > > >Then in effect I'm building an unnamed function definition, and assigning >default >values to the two parameters. Those default values will travel with the >definition, >so when Tkinter calls it later, they will be availible to the actual >execution. > >The call of foo(a,b) in the definition above is part of the definition - it >won't be >executed until the function object is executed later. > Thanks John, I think I see it. If I can get a look at the solution to the code example that I used in my reply to Chris Barker --- I'll have it made. Perhaps you can take a look at that example also? Thanks again. Regards, Joe From aahz at panix.com Mon Jun 25 10:58:09 2001 From: aahz at panix.com (Aahz Maruch) Date: 25 Jun 2001 07:58:09 -0700 Subject: any idea how i could test if a variable is a floating point number? References: <9h76io$ht3$1@neptunium.btinternet.com> Message-ID: <9h7ji1$b5p$1@panix6.panix.com> In article <9h76io$ht3$1 at neptunium.btinternet.com>, Gaz wrote: > >any idea how i could test if a variable is a floating point number? if isinstance(var, type(1.1)): This is preferred over if type(var) == type(1.1): because when the type/class dichotomy gets healed (probably in 2.2), it will be possible to subclass from float and the second version will fail with subclasses. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Those who do not remember the past are condemned to repeat it." From aleaxit at yahoo.com Thu Jun 14 05:40:14 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 11:40:14 +0200 Subject: base converter References: Message-ID: <9ga0q902gl7@enews1.newsguy.com> "Greg Jorgensen" wrote in message news:GE_V6.166783$p33.3516294 at news1.sttls1.wa.home.com... > > "Fredrik Lundh" wrote: > > > def BaseConvert(x, b): > > out = "" > > while x: > > x, d = divmod(x, b) > > out = str(d) + out > > return out > > > > Slightly modified to work with bases > 10: > > def BaseConvert(x, b): > "convert decimal number x to base b" > digits = "0123456789ABCDEF" > out = "" > if b <= len(digits): > while x: > x, d = divmod(x, b) > out = digits[d] + out > return out In general, I think it's better to avoid building a string by a loop concatenating single characters. It may not matter much in this case, but... def BaseConvert(x, b): import string digits = string.digits + string.uppercase if b>len(digits): raise ValueError, "base %s too large"%b if x == 0: return '0' elif x<0: negative = 1 x = -x else: negative = 0 result = [] while x: x, d = divmod(x, b) result.append(digits[d]) if negative: result.append('-') result.reverse() return ''.join(result) I've also tried to fix the bug which (I believe) would make this loop endlessly for x<0, &c. Alex From gmcm at hypernet.com Thu Jun 28 22:16:16 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 29 Jun 2001 02:16:16 GMT Subject: Python Standalone?? References: Message-ID: <90CEE3C7Agmcmhypernetcom@199.171.54.194> [posted and mailed] njm at rectec.net (NJM) wrote in : >I have run Standalone.py on a small app that I wrote. The cycle >completes and all appears to be well, until I try to launch the .exe >file. My system claims a illegal function and immediately shuts down >the program. > >Could this be because python is already on my machine?? > >Or am I doing something wrong?? I don't think I've ever heard of this happening on one machine. I've certainly seen it in building on one and running on another. So far, it's always been due to .dlls (and I'm pretty sure that's your problem, too, but not sure how). For example, building on Win2K may pick up some .dlls that crash when you try them on NT or Win9x. Look through the dlls in your dist_xxx directory, and remove any that aren't directly Python. It may have picked up a system dll that doesn't belong there. If you find the culprit, email me and I'll add it to the excludes list. - Gordon From petro at bounty.org Fri Jun 1 14:53:58 2001 From: petro at bounty.org (petro) Date: Fri, 1 Jun 2001 11:53:58 -0700 Subject: Problem installing Python2.1 on RH 7.1 In-Reply-To: <20010601123424.A7521@harmony.cs.rit.edu> References: <991402384.98784@nntp01.uskonet.com> <20010601123424.A7521@harmony.cs.rit.edu> Message-ID: >There is an option to rpm (-l maybe) to list the files that a package >contains. You could try > >$ rpm -l python.rpm | less Do a ` rpm -qa | grep python ` to find the name of the python package, then do a `rpm -ql to get a list of the files that the RPM database thinks is there. -- -- http://www.apa.org/journals/psp/psp7761121.html It is one of the essential features of such incompetence that the person so afflicted is incapable of knowing that he is incompetent. To have such knowledge would already be to remedy a good portion of the offense. From dsh8290 at rit.edu Thu Jun 14 14:20:52 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 14 Jun 2001 14:20:52 -0400 Subject: New statement proposal for Python In-Reply-To: <9gao5s$8ft$7@216.39.170.247>; from whisper@oz.nospamnet on Thu, Jun 14, 2001 at 04:19:08PM +0000 References: <9gao5s$8ft$7@216.39.170.247> Message-ID: <20010614142052.B130@harmony.cs.rit.edu> On Thu, Jun 14, 2001 at 04:19:08PM +0000, David LeBlanc wrote: | One thing that bugs me about Python is that there's no really good way to | have named constants so that magic numbers can be avoided. Assigning to a | variable that (should) never changes is not the same (i.e. the "should | never" part). I was just thinking that a class instance that overrides __setattr__ can provide the same thing. I suppose use keyword arguments to __init__ to provide the values, and all future assignments blow up. -D From aleaxit at yahoo.com Wed Jun 6 17:39:16 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 6 Jun 2001 23:39:16 +0200 Subject: print foo, adds a space to beginning of next line? References: <3B1E7D78.53A5BE30@ll.mit.edu> Message-ID: <9fm83404eh@enews1.newsguy.com> "George Young" wrote in message news:3B1E7D78.53A5BE30 at ll.mit.edu... > [python 2.1, intel linux] > def f(): > print 'what is your name: ', > x=sys.stdin.readline() > print 'what is your age: ', > y=sys.stdin.readline() > > f() > what is your name: mememe > what is your age: 48 > > Why does it print a space at the beginning of the second line? Looks like the .softspace attribute on sys.stdout is not being cleared by sys.stdin.readline() [and indeed how could it be?]. You can clear it up yourself if you wish: sys.stdout.softspace=0 after each print and/or readline(). Or avoid ever setting it by: > If I use sys.stdout.write('what is your name: ') instead, it > works fine. Yep. Or if you use raw_input('what is your name:'), which is designed exactly for this job, of course [but it removes the trailing \n, which .readline() doesnt...] :-). Alex From wchang at sympatico.ca Sat Jun 2 23:06:34 2001 From: wchang at sympatico.ca (chang) Date: Sat, 2 Jun 2001 23:06:34 -0400 Subject: Tkinter and Swing Message-ID: hi... I'm currently looking for an extension of the swing package. I've been trying to translate python code into Jpython. However, along with some minor difficulities, the major limitation is Swing's canvas widget functionality for item handling is nowhere near the Tkinter canvas widget's. So can please someone help me out and tell me where can i find such extensions, if it exists at all (~~hope i don't have to write them myself~~) . The main goal of this translation is of course being able the run the current GUI as applets on the web. . . thx in advance.... oh, by the way, love this newsgroup!!!! hsin chang From chrishbarker at home.net Thu Jun 7 14:45:44 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 07 Jun 2001 11:45:44 -0700 Subject: floating point in 2.0 References: <9fiptc$m9d$1@panix2.panix.com> <3B1D154B.81016685@home.net> <3B1DC3AE.6EA1F09D@accessone.com> Message-ID: <3B1FCBD8.C43504C1@home.net> Helen Dawson wrote: > Remember that floating point has a mantissa and an *exponent*. So, if I > have a binary floating point format with a one bit mantissa and an eight Thank you, I had not considered that. Your example helped me sort it out. > > interestingly enough, If you try to diplay more, you get: > > >>> '%.70f' % 0.1 > > '0.1000000000000000055511151231257827021181583404541015625000000000000000' > > > > now the extra is all zeros. I now know the answer to that. From the Library Reference: "For safety reasons, floating point precisions are clipped to 50;" And the corresponding footnote: "These numbers are fairly arbitrary. They are intended to avoid printing endless strings of meaningless digits without hampering correct use and without having to know the exact precision of floating point values on a particular machine." -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From aleaxit at yahoo.com Sun Jun 10 11:06:15 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 10 Jun 2001 17:06:15 +0200 Subject: py2exe how safe is my source ? References: Message-ID: <9g02if021ee@enews2.newsguy.com> "Tomasz Stochmal" wrote in message news:f20ea932.0106100442.79f1ab55 at posting.google.com... > I want to distribute my end product to clients. How safe is my source code ? > Can you easily reverse-engineer pyc files ? Yes! Consider a typical tr.py such as: def greet(name): print "Hello",name def rept(n): for i in range(n): greet(i) It's trivial, given its .pyc, to perform: >>> import tr >>> import dis >>> dis.dis(tr) Disassembly of greet: 0 SET_LINENO 1 3 SET_LINENO 2 6 LOAD_CONST 1 ('Hello') 9 PRINT_ITEM 10 LOAD_FAST 0 (name) 13 PRINT_ITEM 14 PRINT_NEWLINE 15 LOAD_CONST 0 (None) 18 RETURN_VALUE Disassembly of rept: 0 SET_LINENO 4 3 SET_LINENO 5 6 SETUP_LOOP 38 (to 47) 9 LOAD_GLOBAL 0 (range) 12 LOAD_FAST 0 (n) 15 CALL_FUNCTION 1 18 LOAD_CONST 1 (0) >> 21 SET_LINENO 5 24 FOR_LOOP 19 (to 46) 27 STORE_FAST 1 (i) 30 SET_LINENO 6 33 LOAD_GLOBAL 3 (greet) 36 LOAD_FAST 1 (i) 39 CALL_FUNCTION 1 42 POP_TOP 43 JUMP_ABSOLUTE 21 >> 46 POP_BLOCK >> 47 LOAD_CONST 0 (None) 50 RETURN_VALUE >>> I don't know if anybody has bothered pattern-recognizing the output of dis.dis back into Python source, but at least for one fixed Python version it should be rather doable. >From a .pyc you even get the line numbers to help you reconstruct the exact layout, blank lines and all... at least a .pyo (as obtained for import when you run Python with -O, or -OO to eliminate docstrings too) hides _that_:-) Alex From deker at slackdot.org Wed Jun 6 13:11:11 2001 From: deker at slackdot.org (Rob Deker) Date: 6 Jun 2001 10:11:11 -0700 Subject: htmllib question Message-ID: <91928a98.0106060911.108cec61@posting.google.com> So, after some perusal of the newsgroup, I've gotten a basic understanding of how to use htmllib, but here's the question I've got. Is there an easy way to modify the HTML one is parsing while it's being parsed? For example, if I wanted to change absolute links to relative links. Any help is appreciated. --d From r2d2 at mao.acc.umu.se Fri Jun 8 02:50:24 2001 From: r2d2 at mao.acc.umu.se (Niklas Frykholm) Date: Fri, 8 Jun 2001 06:50:24 +0000 (UTC) Subject: WHY is python slow? References: Message-ID: >now, if we accept the postulate that premature programme optimisation >is an evil and that python has been around much longer than ruby, has >much better documentation and that in Bruce Eckel's words: >"...For some reason, the creator of the language saw Python and >decided to do a clone, and people who had never used Python thought >it was a good idea. Harsh, maybe, but that's my impression: if you've >used Python at all, you wouldn't give Ruby a second glance. Sad to see someone like Bruce Eckel engage in language bashing. The statement "had never used Python" is utterly misleading. The Python-awareness in the Ruby-community is much greater than the Ruby-awareness in the Python-community. Ruby and Python are my favorite languages. It just breaks my heart to see them claw at each other's eyes. C'mon guys, can't we just get along? // Niklas From boud at rempt.xs4all.nl Tue Jun 26 15:39:38 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 26 Jun 2001 19:39:38 GMT Subject: [OT] Is there any tutorial for those who learn Java after Python ;-) References: Message-ID: <9haodq$72q$1@news1.xs4all.nl> Roman Suzi wrote: > I want to learn Java (Not that I am dissatisfied with Python, > but this seem to be "the must" to find a job ;-) > And some simple things makes me wonder: > public class JavaRules { > public static void main(String args[]) { > System.out.println(2+2+"a"); > System.out.println("a"+2+2); > } > } > Quick quiz: what this program will output? > 1. syntax/compilation error (Java is strict typed!!!) > 2. 4aa22 > 3. 4aa4 > 4. 22aa22 > 5. 22aa4 > Your answer: [ ] Quite apart from type casting and operator overloading nonsense, which I always have to try out myself (can't bring myself to actually learning the silly certification book by heart), none of your answers can be right: these are to println's - and println will always print a new line. -- Boudewijn Rempt | http://www.valdyas.org From scarblac at pino.selwerd.nl Sun Jun 10 06:43:01 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 10 Jun 2001 10:43:01 GMT Subject: extracting hex mant+exp from double? References: Message-ID: Mike C. Fletcher wrote in comp.lang.python: > It's a bleeding anonymous magic variable man! Who let that into the > language! The variable is _magic_ I say. Wizardry! Sorcery! Appearing > without explicit assignment! But it's not in the language, only in the interactive interpreter. -- Remco Gerlich From max at alcyone.com Mon Jun 18 23:27:54 2001 From: max at alcyone.com (Erik Max Francis) Date: Mon, 18 Jun 2001 20:27:54 -0700 Subject: PEP 255: Simple Generators References: Message-ID: <3B2EC6BA.4D504554@alcyone.com> Tim Peters wrote: > Abstract > > This PEP introduces the concept of generators to Python, as well > as a new statement used in conjunction with them, the "yield" > statement. This is an extremely clever idea. It starts with a real problem (the present awkwardness of a current construct), an analysis of the solutions, and an elegant proposal for an isolated and clean solution to the problem. I'm all for it. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ There is nothing wrong with sobriety in moderation. \__/ John Ciardi Alcyone Systems' Daily Planet / http://www.alcyone.com/planet.html A new, virtual planet, every day. From gustafl at algonet.se Sat Jun 2 09:50:51 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 2 Jun 2001 13:50:51 GMT Subject: httplib design question Message-ID: Python 2.0 (Win32): =================== I have noticed that the HTTP method doesn't try to connect to the server: >>> h = httplib.HTTP('abc') >>> So I can give it a bad URL, and things will be fine until I try to get something with the putrequest() method. >>> h.putrequest('GET', '/index.html') Traceback (most recent call last): File "", line 1, in ? File "e:\python20\lib\httplib.py", line 425, in putrequest self.send(str) File "e:\python20\lib\httplib.py", line 367, in send self.connect() File "e:\python20\lib\httplib.py", line 351, in connect self.sock.connect((self.host, self.port)) File "", line 1, in connect socket.error: host not found >>> Why doesn't the HTTP method handle this check instead? Here's what I'm trying to do: try: h = httplib.HTTP(host) except: print "Sorry. Can't find " + host sys.exit() The workaround I found is to use the connect() method: try: h = httplib.HTTP() h = h.connect(host) except: print "Sorry. Can't find the host " + host sys.exit() Regards, Gustaf Liljegren From phd at phd.fep.ru Mon Jun 25 12:26:35 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Mon, 25 Jun 2001 20:26:35 +0400 (MSD) Subject: DCOracle: platforms? In-Reply-To: <2hJZ6.16808$g4.471561@e420r-atl2.usenetserver.com> Message-ID: On Mon, 25 Jun 2001, Steve Holden wrote: > Cam anyone tell me if they have the DCOracle module working on Windows? The http://www.google.com/search?q=dcoracle+windows+binary Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From rnd at onego.ru Mon Jun 11 09:39:51 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 11 Jun 2001 17:39:51 +0400 (MSD) Subject: Global in multiple files In-Reply-To: <9g212o0260r@enews2.newsguy.com> Message-ID: On Mon, 11 Jun 2001, Alex Martelli wrote: >"Roman Suzi" wrote in message >news:mailman.992228330.22368.python-list at python.org... > ... >> >Mhm. It seems a little too much overhed for a simple list of users. >> >> What if one day you decide to use threads and userlist is to be shared. >> How do you manage your list without breaking it then? But if some object >> will be in charge of this resource, it will be much-much easier. You will >> need blocking written only once. > >There is a serious risk in over-designing systems "because >one day it might be handy". Yeah, right, but meanwhile you're >paying the price of complexity *RIGHT NOW*!-) I always try to choose more flexible way as long as it doesn't add to complexity. When it is style of thinking, it doesn't require much overhead to always code more generally than is required "right now". I have too much work "right now" to mend things which were somebody's "right yesterday". Somehow, more general solutions do not always require more work or mean more complexity, but are of better quality. >"Do the simplest thing that could possibly work", because >"you ain't gonna need it" (where "it" is the rich, complex, >over-engineered, over-designed very general solution:-). That is why Microsoft systems still have those funny A:, B:, C: letters before file paths ;-) Because "right yesterday" 640K was enough for everything. >See http://c2.com/cgi/wiki?YouArentGonnaNeedIt ... > > >Alex Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Monday, June 11, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Useless Invention: Fur sink." _/ From nperkins7 at home.com Wed Jun 20 14:16:21 2001 From: nperkins7 at home.com (Nick Perkins) Date: Wed, 20 Jun 2001 18:16:21 GMT Subject: Partially evaluated functions References: Message-ID: "Rainer Deyke" wrote... > ... > My version is superior in that it doesn't use named arguments. Consider: > > def f(self): > print self > > curry(self = 5) # This will fail with the cookbook version. > ..Of course, you mean: curry(f, self=5) .. which works fine with the cookbook version. ( why wouldn't it? ) > > I notice that that the cookbook version makes a copy of the kwargs > > dictionary. > > I suppose this prevents kwargs from being modified after being supplied to > > curry. > > Tests show that 'kwargs' is always a new object in the current > implementation, but I suppose that could change in the future. > Yes, my tests also show that curry does not need to make a copy of the kwargs dict. > > Also the actual call to the function uses the * and ** operators to > 'expand' > > the arguments. > > My version would have those too if I had been paying attention while I was > writing it. I tested your solution, the cookbook version, and Alex's nested_scopes version. All three work properly for the kwd args tests that I performed. Here is the test script: It tests only kwd args, not positional args. I omit the output, but in every case the output matched the expected output. from __future__ import nested_scopes # (for Alex's version) # by Rainer Deyke class curry_RD: def __init__(*args, **kwargs): self = args[0] self.function = args[1] self.args = args[2:] self.kwargs = kwargs def __call__(self,*args, **kwargs): kwargs.update(self.kwargs) return self.function(*(self.args + args), **kwargs) # by Scott David Daniels (from cookbook) class curry_CB: def __init__(self, fun, *args, **kwargs): self.fun = fun self.pending = args[:] self.kwargs = kwargs.copy() def __call__(self, *args, **kwargs): if kwargs and self.kwargs: kw = self.kwargs.copy() kw.update(kwargs) else: kw = kwargs or self.kwargs return self.fun(*(self.pending + args), **kw) # by Alex Martelli # (using nested_scopes) def curry_AM(func, *args, **kwds): def callit(*moreargs, **morekwds): morekwds.update(kwds) return func(*(moreargs+args), **morekwds) return callit curries = {'Cookbook':curry_CB,'Rainer':curry_RD, 'Alex':curry_AM } def fn(size='small',color='blue',shape='circle'): return '%s %s %s' % (size,color,shape) for name in curries.keys(): curry = curries[name] print print name print f = curry(fn) print 'expect: small blue circle' print f() print print 'expect big red circle' f = curry(fn,color='red') print f(size='big') print print 'TEST: nested curries:' f = curry(fn, shape='square') f2 = curry(f, size = 'big') print 'expect big purple square' print f2(color='purple') print 'expect big blue square' print f2() print kwargs = {'size':'medium','color':'orange','shape':'oval'} f = curry(fn,**kwargs) print 'expect medium orange oval' print f() print # see if we can change a kwd arg after curry... # ( does curry need to copy kwd dict?) kwargs['shape']='rectangle' print 'expect medium orange oval (not rectangle)' print f() print From schaffer at optonline.net Wed Jun 27 00:04:10 2001 From: schaffer at optonline.net (Les Schaffer) Date: Wed, 27 Jun 2001 04:04:10 GMT Subject: strftime: %Z, timezone, and all that Message-ID: i tried adding a date header to an email as per the python docs, like so: def _dateStamp(): """Stamp an rfc-8222 compilant date for the header.""" return strftime("%a, %d %b %Y %H:%M:%S %Z", localtime()) this is what it looks like in the (outgoing) email file: Date: Tue, 26 Jun 2001 23:40:46 Eastern Daylight Time and when i use smtplib to deliver da mail, the (received) date gets mangled like so: Date: Tue, 26 Jun 2001 23:40:46 +0000 (Eastern) seems like %Z in strftime should either return a +0500 or an EDT, no? the Python doc says this: """ Here is an example, a format for dates compatible with that specified in the RFC 822 Internet email standard. 6.1 >>> from time import * >>> strftime("%a, %d %b %Y %H:%M:%S %Z", localtime()) 'Sat, 27 Jan 2001 05:15:05 EST' >>> """ les schaffer From alain at onesite.org Thu Jun 7 18:17:46 2001 From: alain at onesite.org (Alain TESIO) Date: Fri, 08 Jun 2001 00:17:46 +0200 Subject: Mutable class attributes are shared among all instances, is it normal ? Message-ID: <27vvht4uslv2ibq2q8ee4tovg86e7qempb@4ax.com> Hi, sometimes class attributes added just after "class ...:" outside a functions interfere among instances, more precisely mutable objects are linked to the same object as if it were a static attribute. See the test case below. If I delete the line "val=[None]" in class Y and add "self.val=[None]" in its __init__ it works as class X. Is it a bug or did I miss something ? I'm using Python 2.1, it has the same behaviour on Linux and Windows. Alain ============ start of file 'cl.py' import random class X: val=None def __init__(self): for i in range(3): self.val=random.random() def __repr__(self): return str(self.val) class Y: val=[None] def __init__(self): self.val[0]=random.random() def __repr__(self): return str(self.val) ============ end of file 'cl.py' 21:56:03 observer ~ $python Python 2.1 (#2, Apr 30 2001, 22:51:42) [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import cl >>> x1=cl.X() >>> x2=cl.X() >>> x1 0.395920790054 >>> x2 0.691535797136 >>> y1=cl.Y() >>> y2=cl.Y() >>> y1 [0.078289390442599416] >>> y2 [0.078289390442599416] >>> From a.d.stribblehill at durham.ac.uk Fri Jun 8 10:09:50 2001 From: a.d.stribblehill at durham.ac.uk (Andrew Stribblehill) Date: 08 Jun 2001 15:09:50 +0100 Subject: Decimal can be Binary Too (was decimal or rational) References: Message-ID: <87g0db6p1t.fsf@womble.dur.ac.uk> "Tim Peters" writes: > ... For "typical" commercial use, the > problem is that converting between base-2 (internal) and base-10 (string) is > very expensive relative to the one or two arithmetic operations typically > performed on each input. For example, hook up to a database with a million > sales records, and report on the sum. The database probably delivers the > sale amounts as strings, like "25017.18". Even adding them into the total > *as* strings would be cheaper than converting them to a binary format first. Boo! I was hoping that by base-2 you were talking about base -2. We don't need no steenkeeng two's complement. -- Andrew Stribblehill Systems programmer, IT Service, University of Durham, England From phd at phd.fep.ru Fri Jun 29 07:15:24 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Fri, 29 Jun 2001 15:15:24 +0400 (MSD) Subject: =?windows-1251?Q?E-mail_-__=F0=E5=EA=EB=E0=EC=E0?= In-Reply-To: <543320016529102810488@publicist.com> Message-ID: It was russian spam. Please veryone complain to postmaster at pronetisp.net Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From jwolff at knoware.nl Thu Jun 14 00:59:16 2001 From: jwolff at knoware.nl (Jeroen Wolff) Date: Thu, 14 Jun 2001 06:59:16 +0200 Subject: base converter References: Message-ID: On Wed, 13 Jun 2001 22:01:08 GMT, "Fredrik Lundh" wrote: >(why has decimal to binary conversion suddenly turned into a >FAQ the last few months? it wasn't this way in the old days, >and I cannot remember ever having to output things as binary >numbers in a real-life project... can anyone explain?) > > > Me it is to convert an ip addresses like (192.168.2.1/24) into a 32 bits integer. Also the mask i wil convert to a 32 bit interger. Via converting the 4 octets into its binary representation. Put all the 32 bits in a string and convert it to a interger. After that i can do an AND between these two integers and calucate the network part of it. Wat i would like to have is a database of ip records. With ip number and mask stored as an integer. This way i can lookup an ip addres in the database and find out to wich (sub)network a.i. customer it belongs.... Maybe i'm on the wrong track to solve my problem..... Jeroen From piet at cs.uu.nl Mon Jun 18 05:04:36 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 18 Jun 2001 11:04:36 +0200 Subject: qt or gtk? References: <3B2B609B.285DCB06@web.de> <9gi652$n7p$05$1@news.t-online.com> <9gisq0$nif$1@tyfon.itea.ntnu.no> Message-ID: >>>>> "Magnus Lie Hetland" (MLH) writes: MLH> "Even" may not be the right word here... To those of the Open Source MLH> bent, the FSF's definition is quite restrictive... You aren't free to MLH> do what you want with GPL software ... :) That's because the GPL isn't meant to make YOU free, but to make the SOFTWARE free. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From sandipan at vsnl.com Mon Jun 11 06:25:58 2001 From: sandipan at vsnl.com (Sandipan Gangopadhyay) Date: Mon, 11 Jun 2001 15:55:58 +0530 Subject: Access to modules from co-exiting 1.5.2 and 2.1 Message-ID: <024601c0f260$e8ba9ca0$020000c3@node02> I have installed the following: RH7.1 including openssl-0.9.6 openssl-python-0.9.6 python-1.5.2 I can access M2Crypto from python without any problems! Now, I need python-2.1. I intend to use the 2.1 RPM from tummy.com for this purpose. I want both pythons to coexist. My question is: 1. How do I install the 2.1 RPM to co-exist with 1.5.2 rather than replace it. 2. How do I access M2Crypto from python 2.1 ? Do I need a separate M2Crypto or openssl-python ? Thanks Sandipan From alan.gauld at bt.com Mon Jun 4 13:37:26 2001 From: alan.gauld at bt.com (Alan Gauld) Date: Mon, 04 Jun 2001 18:37:26 +0100 Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> Message-ID: <3B1BC755.65510E63@bt.com> Grant Edwards wrote: > I took a 3 day class on UML once. My impression: yet another > "silver bullet" that doesn't work in real life. Like any design notation UML is there to communicate. If the peer group is small enough the advantages are marginal. If you are working in a distributed group of 20 or more programmers something likev UML is near essential. Most of my projects involve several hundreds of programmers (250 on the current one) and there we simply couldn't operate without UML. But a small team UML may be overkill. Frankly I think the best bits of UML are the component/package diagrams and the deployment diagrams for documenting the physical design. > thought it was marginally useful, but like any other form of > documentation, if it's not maintained (and it never is, AFAICT) > it becomes worse than useless. It depends on the level that you work at. Architectures don't vary that much and are useful for maintainers. But code varies a lot so if you try to use UML for documenting code without tool support for reverse engineering changes then I agree it quickly becomes out of date. But How else do we communicate design to a new start - it takes a long time to read a million lines of code.... UML and similar tools cut that time down by an order of magnitude. Alan G. From com-nospam at ccraig.org Fri Jun 1 08:45:32 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 01 Jun 2001 08:45:32 -0400 Subject: Why can't slice use non-int. indices? References: <3B168CF7.F44777F9@yahoo.com> <20010531.201603.771151432.2277@bur-jud-175-024.rh.uchicago.edu> Message-ID: <87u220s70z.fsf@elbereth.ccraig.org> "Ben Wolfson" writes: > For that matter, why doesn't this work? > > >>> lst = range(10) > >>> slc = slice(2,6) > >>> lst[slc] > Traceback (most recent call last): > File "", line 1, in ? > lst[slc] > TypeError: sequence index must be integer > > Seems like it ought to. foo[start:stop] calls foo.__getslice__(start, stop) while foo[start:stop:step] calls foo.__getitem__(slice(start, stop, step)) The PySequence_GetItem function takes an integer as its second argument (key), so it cannot accept a slice object. The difference in the extended versus simple slicing is caused by the fact that the extended slice syntax was imported from Numeric and the simple version had to be maintained for backwards compatibility. -- Christopher A. Craig "When all else fails, read the instructions." From emile at fenx.com Sun Jun 10 15:21:46 2001 From: emile at fenx.com (Emile van Sebille) Date: Sun, 10 Jun 2001 12:21:46 -0700 Subject: list-display semantics? References: <9g0dhl$if1$1@news.nsysu.edu.tw> Message-ID: <9g0hj3$6i2oc$1@ID-11957.news.dfncis.de> I don't quite get the results you get, but from: print [[x,y] for x in [1,2,3] for y in [4,5,6]] I get [[1, 4], [1, 5], [1, 6], [2, 4], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6]] Which looks like what you want. From: print [x for x in [1, 2, 3], y for y in [4, 5, 6]] I get: [[1, 2, 3], [1, 2, 3], [1, 2, 3], 6, 6, 6] The difference is that the comma following [1,2,3] causes [1,2,3] to be treated as the first element of a tuple, and the then current value of y as the second element (in my case 6, in your case 9). Now your for y in [4,5,6] might as well be for i in range(3) as the y value in the loop is not used in the result. Note the subtle namespace issue. Your line of code then reads: "Give me a list of x's for x iterating over ([1,2,3] , y) three times. HTH, -- Emile van Sebille emile at fenx.com --------- "jainweiwu" wrote in message news:9g0dhl$if1$1 at news.nsysu.edu.tw... > Hi all: > I tried the one-line command in a interaction mode: > [x for x in [1, 2, 3], y for y in [4, 5, 6]] > and the result surprised me, that is: > [[1,2,3],[1,2,3],[1,2,3],9,9,9] > Who can explain the behavior? > Since I expected the result should be: > [[1,4],[1,5],[1,6],[2,4],...] > -- > Pary All Rough Yet. > parywu at seed.net.tw > > From cribeiro at mail.inet.com.br Mon Jun 25 20:30:36 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Mon, 25 Jun 2001 21:30:36 -0300 Subject: 'with' statement in python ? In-Reply-To: <002a01c0fdc0$f17d1af0$d938a8c0@Hadfield> References: Message-ID: <5.0.2.1.0.20010625212039.027178b0@mail.inet.com.br> At 21:50 25/06/01 +0000, Mark Hadfield wrote: >From: "asgard" > > > > Hello, > > writing self before every object's method really drives me > > crazy. Shouldn't there be 'with' statement like in Pascal, ie. > >There was an extensive discussion on this recently. Perhaps you'd like to >try a search on Google Groups. IIRC the consensus was that adding this to >Python would not be a good idea, because when "with" blocks are nested they >become hard to read and possibly ambiguous. I'll repeat the same argument that I gave some time ago. Maybe it's a good answer for this FAQ :-) Some languages, such as Object Pascal, Delphi, and C++, use static types. So it is possible to know, in a unambiguous way, what member is being assigned in a "with" clause. This is the main point - the compiler *always* knows the scope of every variable at compile time. Python uses dynamic types. It is impossible to know in advance which attribute will be referenced at runtime. Member attributes may be added or removed from objects on the fly. This would make it impossible to know, from a simple reading, what attribute is being referenced - a local one, a global one, or a member attribute. For instance, take the following snippet (it is incomplete btw, just to give you the idea): def with_is_broken(a): with a: print x The snippet above assume that "a" must have a member attribute called "x". However, there is nothing in Python that guarantees that. What should happen if "a" is, let us say, an integer? And if I have a global variable named "x", will it end up being used inside the with block? As you see, the dynamic nature of Python makes such choices much harder. Carlos Ribeiro From joonas.paalasmaa at nokia.com Mon Jun 18 04:37:06 2001 From: joonas.paalasmaa at nokia.com (Joonas Paalasmaa) Date: Mon, 18 Jun 2001 08:37:06 GMT Subject: Problems with urllib Message-ID: <3B2DCC2B.B3DCDDD5@nokia.com> I get the following error message when trying to open a website with urllib. Internet connections are ok and I can access the page with browser. Platform is WinNT4. >>> indexfile = urllib.urlopen("http://www.python.org").readlines() Traceback (most recent call last): File "", line 1, in ? indexfile = urllib.urlopen("http://www.python.org").readlines() File "c:\python21\lib\urllib.py", line 71, in urlopen return _urlopener.open(url) File "c:\python21\lib\urllib.py", line 176, in open return getattr(self, name)(url) File "c:\python21\lib\urllib.py", line 283, in open_http h.putrequest('GET', selector) File "c:\python21\lib\httplib.py", line 432, in putrequest self.send(str) File "c:\python21\lib\httplib.py", line 374, in send self.connect() File "c:\python21\lib\httplib.py", line 358, in connect self.sock.connect((self.host, self.port)) File "", line 1, in connect IOError: [Errno socket error] (10060, 'Operation timed out') From aahz at panix.com Fri Jun 1 01:29:56 2001 From: aahz at panix.com (Aahz Maruch) Date: 31 May 2001 22:29:56 -0700 Subject: Obsolesence of <> (fwd) References: Message-ID: <9f798k$hc4$1@panix2.panix.com> In article , Lulu of the Lotus-Eaters wrote: >aahz at panix.com (Aahz Maruch) wrote: >>Lulu of the Lotus-Eaters wrote: >>>I'm not really sure I like the change Alex points to. It makes >>>something like the below fail: >>> >>> l = [(1+1j),(2-2j),Klass(),Klass(),Klass,5,4,3,'c','b','a'] >>> l.sort() >>> >>>Many of the comparisons have no particular meaning. But it is nice to have >>>everything have some arbitrary inequality relation in order to create >>>partial orderings on the subsets of things that really do have an order. >> >>Yup, this used to work. Then came Unicode.... > >Huh? What does Unicode have to do with anything? The below works fine, >for example: > > Python 2.0.42-S1.2.23 (#0, Apr 25 2001, 20:59:49) [GNU C/C++] on os2 > Type "copyright", "credits" or "license" for more information. > >>> x = u"spam" > >>> y = "spam" > >>> z = 1+1j > >>> w = u"eggs" > >>> x < y > 0 > >>> x < z > 0 > >>> x < w > 0 Hrm. There was a thread a month or two back that I can't find about list.sort() breaking in 2.0 because of a change in the way types were implemented. I *thought* I remembered it being because of Unicode, but I could be wrong. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Characters exist to suffer, you know. An author needs a little sadism in her makeup." --Brenda Clough From bill-bell at bill-bell.hamilton.on.ca Fri Jun 15 15:54:10 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Fri, 15 Jun 2001 15:54:10 -0400 Subject: question about threads In-Reply-To: <992626120.385.77971.l9@yahoogroups.com> Message-ID: <3B2A2FA2.30469.1818187@localhost> Alan Tsang wrote: > Is it possible to explicitly tell a thread to pass execution to > another thread in Python? Any help is much appreciated. Alan, do you mean the way one co-routine might call another? If so, then you might find something in the archives for this list, since co-routines were discussed here a few weeks ago. - Bill From me at mikerobin.com Wed Jun 27 14:08:28 2001 From: me at mikerobin.com (Michael Robin) Date: 27 Jun 2001 11:08:28 -0700 Subject: PEP 260: simplify xrange() References: Message-ID: <52e5ab5f.0106271008.12219586@posting.google.com> I second this sentiment - if xrange is going to be used idiomatically for looping only (well, in any case) I would like to see the sequence itself acceptable as a parameter. xrange(seq) seems perfectly clear (and in single-parameter form also doesn't depend on a 0-based start index as len(seq) does). Side-discussion: Of course, you could just call (or alias) the new xrange "indices(...)" (and/or "indexes" :) ) to make evident its true colors, and mark xrange for complete removal in a later version, while supplying a python-coded version to keep code working - but I guess xrange is too embedded in the pythoner's psyche... (The name "range" is especially confusing in a way, considering you pass in what's normally considered the mapping's "range" and it's returning the "domain".) It sounds like the PEP won't kill much code, but restricting xrange as proposed reduces the symmetry in the laguage which is one of its good points. I wonder = using the non-use metric, there are probably other things that can be removed. (How many people use "if dict1 < dict2 ..."?) It seems like lot's of stuff could be removed from the core, and the outliers could be put in (C or python-coded) modules that could be included to "round-out" a particular class of objects, so if you really wanted to compare dictionaries you could include (import) this support. (When we can subclass types, this should be easier.) m "Delaney, Timothy" wrote in message news:... > > Here's another sweet and short PEP. What do folks think? Is > > xrange()'s complexity really worth having? > > > > --Guido van Rossum (home page: http://www.python.org/~guido/) > > > > PEP: 260 > > Title: Simplify xrange() > > Version: $Revision: 1.1 $ > > Author: guido at python.org (Guido van Rossum) > > Status: Draft > > Type: Standards Track > > Python-Version: 2.2 > > Created: 26-Jun-2001 > > Post-History: 26-Jun-2001 > > > > Abstract > > > > This PEP proposes to strip the xrange() object from some rarely > > used behavior like x[i:j] and x*n. > > > > > > Problem > > > > The xrange() function has one idiomatic use: > > > > for i in xrange(...): ... > > If this is to be done, I would also propose that xrange() and range() be > changed to allow passing in a straight-out sequence such as in the following > code in order to get rid of the need for range(len(seq)): > > import __builtin__ > > def range (start, stop=None, step=1, range=range): > """""" > > start2 = start > stop2 = stop > > if stop is None: > stop2 = start > start2 = 0 > > try: > return range(start2, stop2, step) > except TypeError: > assert stop is None > return range(len(start)) > > def xrange (start, stop=None, step=1, xrange=xrange): > """""" > > start2 = start > stop2 = stop > > if stop is None: > stop2 = start > start2 = 0 > > try: > return xrange(start2, stop2, step) > except TypeError: > assert stop is None > return xrange(len(start)) > > a = [5, 'a', 'Hello, world!'] > b = range(a) > c = xrange(4, 6) > d = xrange(b) > e = range(c) > > print a > print b > print c > print d > print e > print range(d, 2) > > Tim Delaney From ullrich at math.okstate.edu Tue Jun 19 07:32:21 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Tue, 19 Jun 2001 11:32:21 GMT Subject: Aargh! Function takes exactly x arguments, y given.. References: <9gkrud$pru$1@news.inet.tele.dk> <3B2E1C02.109197B5@alcyone.com> Message-ID: <3b2f3759.467766@nntp.sprynet.com> On Mon, 18 Jun 2001 08:19:30 -0700, Erik Max Francis wrote: >Anders And wrote: > >> I am a happy pythoneer using a combination of C++ and Python for my >> everyday >> work. >> Usually, debugging is easy but every now and then, I get the "function >> takes >> exactly x arguments, y given" error message, clearly due to some other >> problem than what Python thinks. Does anybody have any experience with >> this >> particular error message? I don't know what triggers it and thinking >> back, I >> think I have solved most of my problems with this message with a major >> code >> rewrite. > >The error means just what it says: You are calling a function with too >many or too few arguments. Why you're doing that exactly is something >we couldn't tell you without code examples that actually give you the >error. > >Only thing I can think of is that you've got a confusion with bound and >unbound methods; if you call an unbound method (C.f where C is a class >and f is a method), then you need to provide an instance of C as the >first method (the implicit self method becomes explicit). Or he's not calling the function that he thinks he is, possibly because of an "import *". (I refrained from guessing at first cuz I didn't want to leave anything out. Is there a natural third possibility?) > Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ > __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE >/ \ There are defeats more triumphant than victories. >\__/ Montaigne > Alcyone Systems / http://www.alcyone.com/ > Alcyone Systems, San Jose, California. David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From Denys.Duchier at ps.uni-sb.de Thu Jun 21 11:14:19 2001 From: Denys.Duchier at ps.uni-sb.de (Denys Duchier) Date: 21 Jun 2001 17:14:19 +0200 Subject: PEP 255: Simple Generators References: Message-ID: Guido van Rossum writes: > Well, that settles it -- I find Tim's version much easier to read > than Denys's version. Thanks for playing. :-) Ouch! of course the PEP 255 way will usually be easier to read: that's the entire point of introducing concrete linguistic support for a new computational mechanism. I was discussing mechanisms. PEP 255 proposes both a mechanism and concrete syntax to support it. I pointed out that the proposed mechanism had important limitations (well, important to me I suppose: I like it when abstractions can commute; this is not the case with the generators of PEP 255) and I offered a more general mechanism, but I did not suggest convenient concrete syntax for it. Note that my proposal is not in contradiction with PEP 255. Instead PEP 255 can be viewed as offering nice concrete syntax for the common case, but with my proposal, a power-user is not stuck with just the common case :-) I guess the bottom-line is that as an academic I like generality, but that's just not the Python way :-) Cheers, -- Dr. Denys Duchier Denys.Duchier at ps.uni-sb.de Forschungsbereich Programmiersysteme (Programming Systems Lab) Universitaet des Saarlandes, Geb. 45 http://www.ps.uni-sb.de/~duchier Postfach 15 11 50 Phone: +49 681 302 5618 66041 Saarbruecken, Germany Fax: +49 681 302 5615 From s713221 at student.gu.edu.au Mon Jun 4 04:38:22 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Mon, 04 Jun 2001 18:38:22 +1000 Subject: Python 2.1 dependencies References: <3B18151A.E95C4E4B@ucdavis.edu> <3B1A1EB9.C051301D@student.gu.edu.au> <3B1A913F.CB24619D@ucdavis.edu> Message-ID: <3B1B48FE.2F3AA26C@student.gu.edu.au> Bruce Wolk wrote: > > I decided to cross my fingers and install the rpms using "--nodeps " and so > far everything seems to work fine, including abiword. > > Bruce Cool then. Have fun. Wait until the day you get a package that doesn't work and you try your luck at building a source rpm. You thought just installing a package was bad ... Joal Heagney/AncientHart From phrxy at csv.warwick.ac.uk Thu Jun 21 21:07:08 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Fri, 22 Jun 2001 02:07:08 +0100 Subject: Two minor syntactic proposals In-Reply-To: References: <16074dce.0106181057.528dfea@posting.google.com> <3b30ee5e.1008026215@wa.news.verio.net> Message-ID: On Thu, 21 Jun 2001, John Roth wrote: [...] > > >How about just the dot? I.e., ".x" means "self.x" > > > > That sounds a good idea. > > I like it! I don't think it will break anything. [...] It's been said before, but 's.x' is pretty short, and if you use it consistently in some reasonable chunk of code, nobody's going to misunderstand it. John From thomas.heller at ion-tof.com Thu Jun 21 06:50:56 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 21 Jun 2001 12:50:56 +0200 Subject: My PyGUI (Re: ANN: PythonCard mailing list) References: <3B31931E.D2F54D78@cosc.canterbury.ac.nz> Message-ID: <9gsjk5$ao46a$1@ID-59885.news.dfncis.de> "Greg Ewing" wrote in message news:3B31931E.D2F54D78 at cosc.canterbury.ac.nz... > You might be interested in looking at a project I > started on a while ago to create an almost-pure-python > GUI library: > > http://www.cosc.canterbury.ac.nz/~greg/python_gui/ > > I haven't worked on it for a while, but there's > actually a more recent version of the implementation > available than the one for downloading from that > page. If anyone is interested I can update the > download links. Please do! Thomas From m.faassen at vet.uu.nl Fri Jun 29 18:53:33 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 29 Jun 2001 22:53:33 GMT Subject: the center of the world (was Re: Check out O'Reilly's Open Source Convention Highlights) References: <3B3AA82D.1A0FE860@seebelow.org> <3B3B2DED.5303198A@seebelow.org> <9hhri7019jd@enews2.newsguy.com> Message-ID: <9hj0td$bdu$1@newshost.accu.uu.nl> Alex Martelli wrote: [snipped] > Of course, there are enough degrees of freedom in the outlined > procedure that it can probably be used for my real purpose, i.e., > proving that the relevant "center of the world" is within easy > walking distance from my home and thereby convincing the PS^H^H > O'Reilly to hold their next conference somewhere that's highly > convenient for me... In fact even a petition with signatures from half (random estimate) the attendees at IPC8 *including* the PythonLabs team to hold IPC9 in Amsterdam is apparently not convincing to the organizers, as obviously there wouldn't be enough interest in such a conference in Europe. Talk about a self fulfilling prophecy. :) The PSU must want this kind of gathering in the US. Perhaps they're hoping the gathered attendees will quickly implement the AsteroidImpactError exception before they lob an asteroid at the place, and they feel the US is more expendable than Europe. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From shalehperry at home.com Fri Jun 1 19:45:06 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Fri, 01 Jun 2001 16:45:06 -0700 (PDT) Subject: Lego Mindstorms robotics control via Python? In-Reply-To: Message-ID: On 01-Jun-2001 Kevin Altis wrote: > I would like to control a robot via Python on Windows (specifically Windows > 2000). The Lego Mindstorms product is relatively inexpensive and easy to > find and supports an infrared transmitter, so that seems like a good choice > to program around. Does anyone know if there is a already a Python wrapper > for issuing RCX ("yellow brick") commands? If not, how about a COM-enabled > app that I could control or a C library/source that I could wrap in Python? > Any other suggestions, reading material, or URLs for further info would be > appreciated. I would be interested in controlling other robotic devices, but > only if they are commercially available and relatively inexpensive. > There is a project called LegOS. You should track it down. Makes mindstorm programming useful again. From frankimmich at gmx.de Thu Jun 7 12:22:19 2001 From: frankimmich at gmx.de (Frank Immich) Date: Thu, 7 Jun 2001 18:22:19 +0200 (MEST) Subject: nt-services Message-ID: <26225.991930939@www20.gmx.net> Mark, thanks for your answer, but at the moment I am fighting with win32 events. Probably I will have to deal with accounting later on. In the example win32/demos/service/... it is done for named pipes : .... hr = ConnectNamedPipe(pipeHandle, self.overlapped) .... rc = WaitForMultipleObjects((self.hWaitStop, self.overlapped.hEvent), 0,INFINITE) I want to bind accept() from the socket module to a win32event, so I can catch if there is a connection to a socket. Someone told that it might work with win32file.AcceptEx but I have no clue how....Is this the right way or am I totally wrong? Ciao Frank > Hello there, > I have a question concerning socket connections running as NT-Service. I > found the demoscript in win32/demos/service/ PipeService.py and I think > (hope) I understood most of it. But transferring this example using sockets > instead of named pipes doesn't work. Basically I want to have a little service > running on NT which is waiting for a command from a Unix machine, passing back > stdin , sdterr .... Without the NT-service-thing it is working fine. > I hope you are good address for win32 questions. I have asked this in the > german newsgroup too, but most of the guys seem to be more experienced in > UNIX/LINUX (thanks for the answers, anyway). Maybe you can give me a clearer > hint. Thanks in advance , Ciao Frank > [code snipped] Frank, NT Services are rather particular in that by default they start up under the "Local System" account which does not have access to the network stack. Your best bet is to start your service under an account that has been setup on the machine with network access. You can do this by installing the service then in the Service Manager Control panel applet, right click on the installed python service and select properties. This dialog will give you a tab that allows you to specify what account (username and password are required) to start the service under. When NT starts the service it will use this account. NOTE: You do not have to be logged in under this account at the time the service starts. Yes, this is a PITA, but that's life with NT/Win2K. HTH -Mark -- Machen Sie Ihr Hobby zu Geld bei unserem Partner 1&1! http://profiseller.de/info/index.php3?ac=OM.PS.PS003K00596T0409a -- GMX - Die Kommunikationsplattform im Internet. http://www.gmx.net From nperkins7 at home.com Mon Jun 18 22:42:21 2001 From: nperkins7 at home.com (Nick Perkins) Date: Tue, 19 Jun 2001 02:42:21 GMT Subject: Sorting Apache Log Files References: Message-ID: If you are merging really big logfiles, you probably don't need to read them all into memory in order to do this. Since you are merging 2 files that are already sorted, you don't really need the full power of the sort() function. You could just open both files, as well as the output file, then read one line from each output file, decide which one comes first, and write that line to the output. Then just keep going until one file is done, and copy the rest of the other file over. With a bit more logic, you could generalize this to merge more than 2 files, but then you can always do that anyway, by just merging them 2 at a time, and 'accumulating' the result. "Lenny Self" wrote in message news:rfyX6.597$Qp2.488157 at news.uswest.net... > Thanks for your help. This is what I ended up doing... It seems to work > quite nicely and seems fast enough. Although, I'm not sure how fast its > going to be with 20MB of logs :) > > #!/usr/bin/pyton > > import string > > # Reading file into list > list = open("d:/work/access.log","r").readlines() > def compare (line1,line2): > # Nicely sucks out the apache date stamp > datestamp1 = line1[string.find(line1,"[") + 1:string.rfind(line1,"]")] > datestamp2 = line2[string.find(line2,"[") + 1:string.rfind(line2,"]")] > # Compare the date stamps and return appropriate value > if datestamp1 < datestamp2: > return -1 > elif datestamp2 < datestamp1: > return 1 > else: > return 0 > list.sort(compare) > # Writing sorted list to new file > open("d:/work/newfile.txt","w").writelines(list) > > Thanks. > > -- Lenny > > > "Sheila King" wrote in message > news:td3titkav6amrrfjimkjkf4kngp7u4ahpg at 4ax.com... > > On 18 Jun 2001 15:55:53 -0700, lenny.self at qsent.com (Lenny) wrote in > > comp.lang.python in article > > : > > > > : I was planning on loading each of the log files > > :into a list and then sorting the list. Unfortualy, I am unaware of > > :how to do that when the value I wish to search on isn't at the > > :beginning of the line. I need to search on Apache's date string. > > > > How about this? Create a list of tuples, where the tuple is: > > > > (datestamp, full_line) > > > > So, as you put each line from the log into the list, grab the datestamp > > from the line, make a tuple and then sort the list on the first element > > of each tuple? > > > > -- > > Sheila King > > http://www.thinkspot.net/sheila/ > > http://www.k12groups.org/ > > > > > > From bernhard at intevation.de Wed Jun 13 06:09:59 2001 From: bernhard at intevation.de (Bernhard Reiter) Date: 13 Jun 2001 10:09:59 GMT Subject: MapIt! 1.0 - Webapplication for Rastermaps References: <9g5b3t$70ltn$2@ID-89274.news.dfncis.de> <3b26b2af.58266963@news-server.bigpond.net.au> Message-ID: <9g7e5n$7n8d2$2@ID-89274.news.dfncis.de> In article <3b26b2af.58266963 at news-server.bigpond.net.au>, sorular at netscape.net (sorular) writes: > Can MapIt work with Zope server? There are not explicit provisions to integrate it with Zope. But there is also nothing stopping you from just calling the python functions from Zope and use them. :) Overall I would say: 80% yes > On Tue, 12 Jun 2001 15:57:07 GMT, wware at world.std.com (Will Ware) > wrote: > >>Bernhard Reiter (bernhard at intevation.de) wrote: >>> > MapIt! 1.0 >>> > http://www.mapit.de/ >> >>Given the laziness of us numerous American slugs who can't be bothered >>to learn other folks' languages, there may be some interest as well in >>the English-language home page: >> >>http://www.mapit.de/mapit.en.html Thanks, I have missed to give the right URL (sorry). Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) FSF Europe (fsfeurope.org) From george at cc.gatech.edu Wed Jun 27 17:09:43 2001 From: george at cc.gatech.edu (George Thomas) Date: Wed, 27 Jun 2001 17:09:43 -0400 Subject: list of dictionaries Message-ID: <3B3A4B97.5F4EB1F1@cc.gatech.edu> Hi everyone, As part of a project, I've ended up deciding to use a list of dictionaries. However, I don't seem to be getting the "expected" results of the append() operation on the list object. Here's some sample code to illustrate the problem. import string dict_entry = { 'a':'', 'b':'', 'c':'', 'd':'' } a1 = "apples" a2 = "oranges" b1 = "bananas" b2 = "peaches" c1 = "coconuts" c2 = "pears" d1 = "dalmatians" d2 = "pecans" sample_list = [] dict_entry['a'] = a1 dict_entry['b'] = b1 dict_entry['c'] = c1 dict_entry['d'] = d1 sample_list.append(dict_entry) dict_entry['a'] = a2 dict_entry['b'] = b2 dict_entry['c'] = c2 dict_entry['d'] = d2 sample_list.append(dict_entry) It's something subtle or I'm making a stupid mistake somewhere. Either ways, can someone see what's going on ? ------------------------------------------------------------ George Thomas ------------------------------------------------------------ From idivanov at hotmail.com Sat Jun 23 20:32:54 2001 From: idivanov at hotmail.com (Ivan) Date: 23 Jun 2001 17:32:54 -0700 Subject: how to pass arguments to rexec? Message-ID: <9dab6033.0106231632.1be8db3e@posting.google.com> Hi, someone should already encountered this problem, I will try to describe it, what exactly I am trying to do. Hope someone in the group is going to have a good insight about this topic. So, I am writing a CORBA-based server application and I want to embed Python on the server side for some data validation, filtering and other purposes. Because Python code will be supplied as a string from clients it must run in the restricted environment (rexec module). Because I cannot import in the restriced engine any modules (if I do import all CORBA needed modules there's going to be a non-restricted engine :)) So the last possibility I see is to prepare the code that is static - initialization, some corba prolog code etc, in a python module file where I can afford to import whatever I need on the server side and to run only the the few lines of client code in erxec engine. The engine will need then the CORBA-object itself. I am trying to put an instance of an object into the rexec engine without the need to import any modules in the rexec itself. So the object must be passed to rexec and be callable without any modules to be imported. Is it opssible to achive this in python and if yes - how? Thanks for your help, Ivan From res04o20 at gte.net Sun Jun 17 23:27:11 2001 From: res04o20 at gte.net (Dave Wald) Date: Mon, 18 Jun 2001 03:27:11 GMT Subject: Two more questions, and a comment: Cross-Platform... References: <3B2B60AD.942719AE@earthlink.net> <3B2BF029.14AAF29E@earthlink.net> Message-ID: Me again... ;-) Hint: Turn the problem around. Instead of trying to host Tkinter or wxPython windows in a browser, host the browser in your windows, just like IE does, for example. IE is just a container for two MS Active-X controls, shdocvw.dll and mshtml.dll. The first is called the WebBrowser control, and it in turn hosts the HTML parser. Again, I think there is an example of this in one of the books I mentioned earlier. At any rate, I think you would have better luck with this approach using wxPython than Tkinter, since it is C++-based to begin with. But at any rate... > 1. Is Tkinter likely to be ported over to MacOS X soon? No idea. No speaky Mac. > 2. Is Tkinter gui-code usable in any kind of web scripting? In other words, > are forms and tables generated in Tkinter usable to gather user input > through web browsers and can Tkinter be used to output data to web browsers? > I think not??? Short answer: No. Not "through" the browser. Here is how I would approach this. I don't see any reason you could not simply use your Tkinter or wxPython objects from within script blocks in a (D)HTML page. Once you're in Python, you're IN Python. Put them in a separate module in your application package and import what you need. The windows should just pop up in front of the browser, just like an alert or a VBScript Msgbox. Get your user input and truck on. (Marketing alert: It's usually not a good idea to mix UI paradigms, it may confuse your users/customers. And they do NOT like feeling confused... believe me. But, Microsoft Money does it all over the place... ) The only technical problem I can see here is threading. Since you are running in the same process with the browser, and in this scenario the browser is the host, you might have to run your Tk or wx windows on a separate thread, but I doubt it. Same potential problem as running Tkinter modules from within PythonWin, but that's another story... This gets real technical, and may not be worth the trouble, but really should not be too difficult using one of the threading modules available, if you HAVE to. Here again, I'm not a guru on this aspect by any means, yet, (I'll probably have to become one before it's all over), but it should work just fine. But again, if you turn the problem around as above, and host the browser control in YOUR window, there should not be ANY problems. I would investigate the pure-Python-based examples of this first, since it sounds like cross-platform is a major concern for you. Again, I apologize for my Windows-centric approach to all of this, but all of our customers are Windows, so that's the focus I know best at this point. But I KNOW I've seen an example of the pure Python approach, probably in the PP2E book. > > (OK I know I'm cheating, but two more closely related sub-questions) > > 1a. Is wxPython likely to be ported over to the Mac OS X opsys soon? Sooner > or later than Tkinter? Again, no idea. I would suspect sooner. Just gut feel. The wx guys are hungrier. ;-) But really, I would ask them if it's a serious concern. > 2a. Is wxPython code usable in any kind of web scripting? > Same deal as above, just might be a little cleaner, since there is no Tcl layer. Regards, Dave From mertz at gnosis.cx Fri Jun 1 16:56:38 2001 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Fri, 01 Jun 2001 16:56:38 -0400 Subject: Obsolesence of <> (fwd) Message-ID: Darren New wrote: |If you're looking for a consistant but nonsense way of comparing tuples, |you could compare them as tuples of floats. Not very good |mathematics, but then mathematicians don't try to do that. :-) Sure they do. Quick, name an obvious well ordering of Aleph{Aleph_Naught}. we-don't-need-no-stinkin'-(generalized)-continuum-hypothethis-ly yours, Lulu... From gs at styrax.com Thu Jun 7 12:03:54 2001 From: gs at styrax.com (Garry Steedman) Date: Thu, 7 Jun 2001 16:03:54 +0000 Subject: WHY is python slow? In-Reply-To: Message-ID: <3B1FA5EA.11685.13D960E1@localhost> if you go to: http://www.bagley.org/~doug/shootout/craps.shtml and change the weightings to 0 for CPU and memory usage respectively (CPUs and memory are way cheaper than programmers after all!), and 10 for lines of code, ruby and python are the clear winners. now, if we accept the postulate that premature programme optimisation is an evil and that python has been around much longer than ruby, has much better documentation and that in Bruce Eckel's words: "...I usually find that this question [Do you have any opinions about the Ruby language, especially compared to Python?]is asked by someone who is considering learning to program, and was snagged by the fact that Ruby is new, and perhaps thinks that it's going to be the next great thing like Java. From everything I can see, it's not. For some reason, the creator of the language saw Python and decided to do a clone, and people who had never used Python thought it was a good idea. Harsh, maybe, but that's my impression: if you've used Python at all, you wouldn't give Ruby a second glance. " then python is the clear winner! so there. cheers, Garry On 7 Jun 2001, at 12:34, Mitchell Morris wrote: From: mitchell.morris at cingular.com (Mitchell Morris) Subject: Re: WHY is python slow? Organization: Cingular To: python-list at python.org Date sent: 7 Jun 2001 12:34:09 GMT > Steven Haryanto wrote in > : > > > Although it is generally accepted that Python is slower than > > Java/Perl/Ruby, a layman like me would be curious to know why > > exactly this is so. In other words, why is the implementation > > of a language like Ruby (which is on par with Python in terms > > of 'everything is an object', strong reflection, dynamic > > nature). > > > > My first guess would be the ubiquitous use of dictionaries? > > > > Steve > > http://stevne.haryan.to/ > > > > > > Well, perhaps your population sample isn't actually representative. I, > for one, don't believe that your speed ordering is accurate, and I > would further postulate that few other people on this newsgroup would > agree with you. > > > > My second observation is that constructing a group of languages that > includes Java, Perl, and Ruby as members but doesn't include Python > must be using a very fine discriminant indeed . > > > > As a single point of data, may I present the language-specific pages > from Bagley's "Computer Language Shootout" > . Each presents the > finishing place for that language on each specific test. In addition, > the average finishing place is calculated through an unspecified > method (I'm assuming it's the arithmetic mean, but I'm not sure) in > three categories: CPU usage, memory usage, and lines of code. > Perl: > CPU: 14, Memory: 17, LOC: 7 > http://www.bagley.org/~doug/shootout/lang/perl/ > Python: > CPU: 17, Memory: 12, LOC: 7 > http://www.bagley.org/~doug/shootout/lang/python/ > Ruby: > CPU: 18, Memory: 14, LOC: 5 > http://www.bagley.org/~doug/shootout/lang/ruby/ > Java: > CPU: 12, Memory: 20, LOC: 15 > http://www.bagley.org/~doug/shootout/lang/java/ > Tcl: > CPU: 19, Memory: 12, LOC: 12 > http://www.bagley.org/~doug/shootout/lang/tcl/ > OCaml: [my new favorite toy -- ed.] > CPU: 3, Memory: 5, LOC: 10 > http://www.bagley.org/~doug/shootout/lang/ocaml/ > Under this ranking, Java is barely faster than Perl which is even more > barely faster than Python which just as barely faster than Ruby which > is (once again) only barely faster than Tcl. Mr.Bagley neglected to > provide summary statistics for inter-language comparisons on these > pages, so I have to provide my own: > > Language Mean Std.Dev > -------- ---- ------- > Perl 13.6 6.2 > Python 16.6 3.8 > Ruby 18.0 4.6 > Java 11.5 4.2 > Tcl 20.8 4.0 > > (Warning: undocumented math and unwarranted jumping-to-conclusions > ahead) > > Notice the large standard deviation for Perl's results, especially > compared to the standard deviation of the other datasets. This > suggests that there are some outliers in the Perl dataset which are > skewing the mean, and that generally the other languages perform more > consistently over these tests. In addition, the mean/std.dev > comparisons suggest that we can't yet conclude that Perl actually > finshes ahead of either Python or Ruby in the general case, but they > do suggest that we can tentatively say that Perl finshes ahead of Tcl > for these tests. (Isn't it wonderful how statistics lets you be so > certain about making such sweeping statements? <0.1 wink>) > > > > > I have my own reservations about the applicability of this shootout to > anything but Usenet arguments, but since that *IS* what we're having > I'm delighted to wield it . > > > > if-you'd-only-claimed-Jython-was-slow-ly y'rs, > +Mitchell > > > > P.S. Keep in mind that all this is based on the finishing placements > in the elements of the test suite, not the raw performance numbers > which I didn't feel like extracting from all over the entire website. > Jiggery-pokery, indeed! -- > http://mail.python.org/mailman/listinfo/python-list +-------------------------------------------+ Garry Steedman mailto:gs at styrax.com Styrax Associates http://www.styrax.com/ "The Good Man has no shape." +-------------------------------------------+ From brian at rk-speed-rugby.dk Thu Jun 14 07:13:23 2001 From: brian at rk-speed-rugby.dk (Brian Elmegaard) Date: Thu, 14 Jun 2001 13:13:23 +0200 Subject: History substitution on dos References: <3B285D25.3D9B9851@rk-speed-rugby.dk> <9ga1pl02hko@enews1.newsguy.com> Message-ID: <3B289C53.532A5DA6@rk-speed-rugby.dk> great. Thanks alex -- Brian (remove the sport for mail) http://www.et.dtu.dk http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug \TeX, tak From mike_haspert at credence.com Mon Jun 18 12:50:18 2001 From: mike_haspert at credence.com (Mike Haspert) Date: 18 Jun 2001 09:50:18 -0700 Subject: Examples\pde build problem, SWIG with NT and VC++ Message-ID: I am new to Python and SWIG. I managed to build the pde example in the SWIG doc using VC++6.0, Python2.1, and SWIG1.1, but only after commenting out extern "C" around #include python.h. in pde_wrap.cpp (and changing the extension of the output file from .c to .cpp). Everything seems to work but I am not confident I've done the right thing and suspect that I'm doing a newbie thing like using/not using some option incorrectly. Should I expect the wrapper file to need tweaks or not? Has anyone working with SWIG and VC++ built this example? If so, did you hit this problem, and do you have a better idea than tweaking the wrapper? Thanks in advance for any help. -mlh ///////////////////details/////////////////////////////////////// I ran SWIG like this and got no error messages: swig -python -c++ -shadow pde.i The code I had to comment out in the wrapper file was as follows: //#ifdef __cplusplus //extern "C" { //#endif #include "Python.h" //#ifdef __cplusplus //} //#endif The compile errors I got before commenting it out were consistent, math.h gets sucked in when including python.h and it has template code that doesn't get preprocessed away: pde_wrap.cpp C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\math.h(514) : error C2894: templates cannot be declared to have 'C' linkage C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wchar.h(700) : error C2733: second C linkage of overloaded function 'wmemchr' not allowed C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wchar.h(699) : see declaration of 'wmemchr' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wchar.h(702) : error C2733: second C linkage of overloaded function 'wcschr' not allowed C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wchar.h(701) : see declaration of 'wcschr' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wchar.h(704) : error C2733: second C linkage of overloaded function 'wcspbrk' not allowed C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wchar.h(703) : see declaration of 'wcspbrk' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wchar.h(706) : error C2733: second C linkage of overloaded function 'wcsrchr' not allowed C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wchar.h(705) : see declaration of 'wcsrchr' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wchar.h(708) : error C2733: second C linkage of overloaded function 'wcsstr' not allowed C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wchar.h(707) : see declaration of 'wcsstr' Error executing cl.exe. The #defines that lead to the offending code being included seem correct to me. From boyd at insultant.net Thu Jun 7 13:42:34 2001 From: boyd at insultant.net (Boyd Roberts) Date: Thu, 7 Jun 2001 19:42:34 +0200 Subject: best language for 3D manipulation over web ? References: <9fl1k2$avh$1@neon.noos.net> Message-ID: <9foegv$f0j$1@quark.noos.net> "Suchandra Thapa" a ?crit dans le message news: slrn9htia7.1o7.ssthapa at hepcat.telocity.com... > Window's ACL system is being integrated into Linux systems. > It has several advantages over the traditional unix system since the > it has a finer granularity. oh great. it still doesn't fix the real problem: root they plan 9 authentication model is much simpler and cleaner. > As for uptimes, I've heard of a > VMS system with something like a 19 year uptime. totally doable with unix systems before the bloat set in the late '80s and '90s. From tjg at hyperlinq.net Sun Jun 24 18:30:18 2001 From: tjg at hyperlinq.net (Timothy Grant) Date: Sun, 24 Jun 2001 15:30:18 -0700 Subject: readline, python 2.1 and LFS In-Reply-To: <3B35B57F.1E0F956B@nospam.de>; from nospam@nospam.de on Sun, Jun 24, 2001 at 11:40:15AM +0200 References: <3B35B57F.1E0F956B@nospam.de> Message-ID: <20010624153018.D23754@trufflehunter.hyperlinq.net> On Sun, Jun 24, 2001 at 11:40:15AM +0200, Uwe Hoffmann wrote: > Timothy Grant wrote: > > > > .... > > then recompiled Python. This time it built readline support. > > > > However, when I try and import readline, I get the following > > error. > > > > ImportError: /usr/local/lib/python2.1/lib-dynload/readline.so: > > undefined symbol: tputs > > > > I think you need to link the readline module with either ncurses > or termcap > Thanks for the tip Uwe, but I still can't get it to work correctly. I've gone back and started from the beginning (at least its the beginning as far as I know). ncurses v5.2 readline v4.2 python v2.1 I'm sure I'm missing a configuration option or something similar, but I can't figure out what. -- Stand Fast, tjg. Timothy Grant www.hyperlinq.net Chief Technology Officer tjg at hyperlinq.net HyperLINq Technologies, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 19 days 22:28 hours ago<< From chapman at bioreason.com Sat Jun 16 17:12:13 2001 From: chapman at bioreason.com (Mitch Chapman) Date: Sat, 16 Jun 2001 15:12:13 -0600 Subject: Any other Python flaws? References: <3B2A530C.5F798823@bioreason.com> <3dvglxe9j3.fsf@ute.cnri.reston.va.us> <3B2A8CD6.DB8AEF5C@bioreason.com> Message-ID: <3B2BCBAD.E278E78A@bioreason.com> Paul Prescod wrote: > > Mitch Chapman wrote: > > > >... > > > > I need to manage long-running, parameter-rich computations from > > GUI applications while still responding to the user. I think I > > need threads because they make it easier to exchange all of those > > parameters between the GUI controller and the background computation > > than do separate processes. I think I need processes because I > > need to be able to cancel the background computation. > > When I need to do something like that I do this: > > while not self._cancel: > do_more_computation() Yep, this is a common approach. See Xt work procedures, Gtk+ idle tasks, or even guides to programming in Oberon. Unfortunately, this method doesn't work very well when your background thread needs to do blocking operations, e.g. reading from a socket. -- Mitch Chapman Mitch.Chapman at bioreason.com From dougfort at downright.com Sun Jun 3 12:35:35 2001 From: dougfort at downright.com (Doug Fort) Date: 3 Jun 2001 17:35:35 +0100 Subject: xmlrpc Server References: <2f14b602.0106030721.441faa31@posting.google.com> Message-ID: <3b1a674e$1_1@news5.uncensored-news.com> Andrew wrote: > > > def add(self, method, params): > self.x = self.x + int(params[0]) > return "Sum = %s" % str(self.x) > I believe the add method should have the prototype 'def add(self, params)'. I don't think params[0] contains what you think it cpontains. for more examples of xmlrpc, check out: http://pyagent.sourceforge.net -- Doug Fort Senior Meat Manager Downright Software LLC http://www.downright.com ______________________________________________________________________ Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com With Seven Servers In California And Texas - The Worlds Uncensored News Source From aleaxit at yahoo.com Thu Jun 14 12:34:27 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 18:34:27 +0200 Subject: Python grammar.. References: <3B28458C.F171FDB0@my.signature> <9ga2bu02i71@enews1.newsguy.com> <9gak5c$8ft$4@216.39.170.247> Message-ID: <9gap2o0fkj@enews1.newsguy.com> "David LeBlanc" wrote in message news:9gak5c$8ft$4 at 216.39.170.247... ... > Moving a bit off to the side, I wonder if VB's "simplification" could be > due to the fact that in the VBScript vs. Javascript arena, VBScript is > the hands down loser - something like 80% of _all_ server scripting is > done with javascript even on IIS. VBScript disappears -- there will only be VB (and Javascript) in .NET. > course, in all language usage surveys since about 1960, BASIC has been > the most used language of all by wide margins... I'd rather be condemned > to using Perl! Having to choose between Perl, Javascript and VBscript for a certain task recently (don't ask...), I choose VBscript. About 500 lines all told (would no doubt have been fewer in the other languages, or, of course, in Python). If I had to make the same choice again (well, I _could_ resign, I guess...), it would be VBScript again. Alex From pst at bbn.hp.com Fri Jun 8 08:19:36 2001 From: pst at bbn.hp.com (Peter Stoldt) Date: Fri, 8 Jun 2001 14:19:36 +0200 Subject: Compiling Python2.1 under HP-UX with threads ? References: Message-ID: <3b20c450$1@hpb10302.boi.hp.com> Hello, Philipp Jocham wrote: > On Thu, 07 Jun 2001 20:08:00 +0200, M.-A. Lemburg wrote: > >I am having trouble compiling Python 2.1 under HP-UX 11.00 > >with threads. > > > >Even though the compile runs fine (ok, termios and _curses fail > >to compile, but I don't need those), the test suite fails to > >pass all tests which try to use threads. The error I get is: Compiling Python 2.1 on HP-UX 11.00 works for me. I have used the following compler: B3899BA B.11.01.07 HP C/ANSI C Developer's Bundle for HP-UX 11.00 (S700) B3911DB B.11.01.06 HP aC++ Compiler (S700) I found a solution for the _curses problem. For that, a Python header file has to be changed. In py_curses.h exchange the line with #include with #include This will include a matching header file for HP-UX 11.00. To get _termios to work, I have no idea. Peter From tonearm at home.com Sat Jun 9 22:13:54 2001 From: tonearm at home.com (Tonearm) Date: Sun, 10 Jun 2001 02:13:54 GMT Subject: Need help with audioop module... Message-ID: Hi, Anyone out there working with wave audio in python? I would appreciate any help you could provide here... As a newcomer to Python I am having trouble understanding what is meant by an audio "fragment" in the description of the audioop module. I understand that these are signed integer samples stored in python strings, but am unsure read data from a wave file and store it as such in a "fragment". Thanks in advance! Andrew From ullrich at math.okstate.edu Mon Jun 4 11:55:36 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 04 Jun 2001 15:55:36 GMT Subject: random References: <9ffolj$d9t$1@news.uit.no> Message-ID: <3b1baf39.10056958@nntp.sprynet.com> On 4 Jun 2001 10:41:55 GMT, tage at pasta.cs.uit.no (Tage Stabell-Kulo) wrote: >"Tim Peters" writes: > >>[Darren New] >>> how random is the binary string "1001010010011100100"? How >>> random is the binary string "0000000000000000000"? Such questions >>> don't make any sense. > >>BTW, you can find attempts to answer such questions in Knuth, Vol 2. The >>questions not only make sense, but finding non-trivial answers is important >>in real life: even if you have a theoretically perfect physical RNG, how >>can you have confidence in a specific real implementation? > > >Knuth answers a different question. His question is "Algorthm X >produced these bits: 010101. Based on them, can we detect some >patterns that should refrain us from relying on this algorithm as a >source of (pseudo)random bits?" In other words, he is analysing >sources of randomness, not whether some string is random. An >important difference. He's agreeing with me then. When this gets out people are going to stop buying his books. >Randomness is interesting only for the next bit, not the ones you >already have. Because you have them, they are not random. Thus, the >bits 1001010010011100100 or 0000000000000000000 are not random, although >they might have been. > > > [TaSK] > > >-- >-- >//// Tage Stabell-Kuloe |e-mail: Tage at ACM.org (at=@)//// >///Department of Computer Science/IMR|Phone : +47-776-44032 /// >//9037 University of Tromsoe, Norway|Fax : +47-776-44580 // David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From tim.one at home.com Fri Jun 15 13:53:48 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 15 Jun 2001 13:53:48 -0400 Subject: str smarter than round? In-Reply-To: <25b2e0d9.0106150811.11efdd73@posting.google.com> Message-ID: [gods1child] > What does str() know that round() doesnt in the following lines? > > >>> a = 1.69 > >>> round(a,2) > 1.6899999999999999 > >>> round(a,1) > 1.7 > >>> str(a) > '1.69' > >>> > > How does str manage to get the accurate representation of floating > points? I am using Windows 2000, Python 2.0 Congratulations! You've elected yourself to be a guinea pig for reading this new Tutorial Appendix: http://python.sourceforge.net/devel-docs/tut/node14.html never-ask-a-question-unless-you-really-want-an-answer-ly y'rs - tim From idivanov at hotmail.com Wed Jun 20 05:25:33 2001 From: idivanov at hotmail.com (Ivan) Date: 20 Jun 2001 02:25:33 -0700 Subject: rexec works strange... Message-ID: <9dab6033.0106200125.252a9673@posting.google.com> The following code shows it is possible to exit a process from rexec code - is this a bug in python rexec module? Is there a fix? D:\>python Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> import sys; >>> import rexec; >>> restr_eng =rexec.RExec(None, 1); >>> restr_eng .r_exec("print 1111111"); 1111111 >>> restr_eng .r_exec("import sys; sys.exit(0)"); D:\> From clpy at snakefarm.org Mon Jun 18 07:13:43 2001 From: clpy at snakefarm.org (Carsten Gaebler) Date: Mon, 18 Jun 2001 13:13:43 +0200 Subject: davlib question Message-ID: <3B2DE267.996E1697@snakefarm.org> Hi there! I am using the davlib module to read some information from a WebDAV server. First I read all property names for a specific directory (which succeeds) and then try to get the value of the "getlastmodified" property (which fails). I do not understand why it fails, perhaps someone could give me a hint? The script and its output follow. Regards Carsten. #!/usr/bin/python import davlib dav = davlib.DAV("dav") # get all properties of directory response = dav.allprops("/space1/2/d7055372/", 0) print response.status, response.reason print response.read() print # get 'getlastmodified' property of directory response = dav.getprops("/space1/2/d7055372/", "getlastmodified") print response.status, response.reason print response.read() 207 Multi-Status /space1/2/d7055372/ 2001-06-18T11:00:04Z Mon, 18 Jun 2001 11:00:04 GMT "3530002-1000-3b2ddf34" httpd/unix-directory HTTP/1.1 200 OK 207 Multi-Status /space1/2/d7055372/ HTTP/1.1 404 Not Found From mlh at idi.ntnu.no Sun Jun 17 14:27:12 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Sun, 17 Jun 2001 20:27:12 +0200 Subject: qt or gtk? References: <3B2B609B.285DCB06@web.de> <9gi652$n7p$05$1@news.t-online.com> Message-ID: <9gisq0$nif$1@tyfon.itea.ntnu.no> "Amal Kurian" wrote in message news:9gi652$n7p$05$1 at news.t-online.com... > Dominic wrote: > > (QT is not completely free but that doesn't make it bad, actually > > it's the best X- Toolkit for C++ programming.) > > This is not correct, since Qt is available under the terms of the GNU > General Public License (and even the Free Software Foundation considers > this a free License ;) "Even" may not be the right word here... To those of the Open Source bent, the FSF's definition is quite restrictive... You aren't free to do what you want with GPL software ... :) > > Kind regards, > Amal. > -- Magnus Lie Hetland http://www.hetland.org "Reality is that which, when you stop believing in it, doesn't go away." -- Philip K. Dick From isabelle.todescato at libertysurf.fr Tue Jun 26 07:35:20 2001 From: isabelle.todescato at libertysurf.fr (Fabien) Date: 26 Jun 2001 04:35:20 -0700 Subject: Python and Functional Programming Message-ID: Dear Python People, I professionally use the functional programming language Clean to write heavy-algorithmic applications, and am at the moment seeking a flexible and powerful way to glue these applications together, along with some GUI front-end. I read a few introductory articles about the Python and JPython languages that seem to provide a tremendous flexibility and a vast library panel. I have heard that the new versions of Python had integrated some concepts taken from functional programming, and I would be interested in having a few pointers to these topics. Sincerely yours, Fabien From rjh at 3-cities.com Thu Jun 28 22:10:09 2001 From: rjh at 3-cities.com (Robert J. Harrison) Date: Fri, 29 Jun 2001 02:10:09 GMT Subject: Comment on PEP-0238 Message-ID: <3B3BE855.A6223E70@3-cities.com> >From recent discussion it is not clear to me if PeP 0238 (http://python.sourceforge.net/peps/pep-0238.html) has gained favor, or not. Two comments. First, its major emphasis is on benefitting inexperienced programmers, but, by being inconsistent with other mainstream languages, it is not clear to me that it is actually a benefit for them. It is certainly not a benefit for experiencd programmers that routinely switch between Python and other languages. Second, even if the change of behavior for divide (/) is accepted, I see no point in introducing the // operator. A plethora of infrequently used operators will make Python more Perl-like. Better an explicit 'cast' to integer. -- Robert J. Harrison (rjh at 3-cities.com) From matt at mondoinfo.com Tue Jun 12 14:24:51 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Tue, 12 Jun 2001 18:24:51 GMT Subject: [Tkinter]: tkMessageBox Internazionalization? References: Message-ID: On Tue, 12 Jun 2001 17:25:17 GMT, Nicola S. wrote: >Is there a comfortable way to change the text of the buttons in the >dialog window shown, for example, by tkMessageBox.askokcancel? >I'd like to use another language for the text 'OK' 'Cancel'; but >maybe this concerns tcl/tk internals. It seems that the text for those buttons is, as you suspect, buried in the sources. You might find it almost as easy to use the SimpleDialog module, which seems to be more flexible: >>> s=SimpleDialog.SimpleDialog(root,text="Continue?", ... buttons=("Yes","No"),default=0,cancel=1,title="test") >>> s.go() 1 Regards, Matt From jkraska1 at san.rr.com Sat Jun 23 13:32:51 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 23 Jun 2001 17:32:51 GMT Subject: Pythoin MUD (PyMUD?) References: <9gqq3t$hvs$1@brokaw.wa.com> <9gqt0r$1q$1@news.mathworks.com> <9h052d$94o$2@brokaw.wa.com> Message-ID: <7ok9jtkcrh3lkniof698a65om2qik3ipsg@4ax.com> >http://www.stackless.com > >I might suggest you look at Microthreads. Once your digesting it all, >keep in mind that the reason you can run so many threads in Stackless >is that the context-switching cost is trivialized;... Adding to my own post, I'd like to point out that I happen to have done some serious performance analysis work on this subject; python-with- continuations performs astonishingly well even when compared with the "faster" languages such as C++, Java, and Lisp. Arguably, you cannot even build a system in Java to handle 20-30,000 threads as I did with Python. In C++, I used a cooperative multithreading environment, and got similar performance to Python, probably because any advantages the C++ offered were overwhelmed by Python's lack of context-switching overhead. Because of my C++ implementations stackfullness, however, I ran out of addressable memory at just under 32,000 threads. This didn't happen in Python... the boundaries are available memory and processing power. FYI, there *is* an implementation of C with continuations on the net. I never tried that in part because it's source-incompatible with the standard libraries (as it has to be: all the compiled std libraries expect a stack). C// From phd at phd.fep.ru Tue Jun 5 05:44:05 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Tue, 5 Jun 2001 13:44:05 +0400 (MSD) Subject: PYML, Python, Perl and Zope In-Reply-To: Message-ID: On Tue, 5 Jun 2001, John Abbe wrote: > Zope looks neat, too. Simply the best! :) > Zope uses DHTML, right? Not only. You can use Zope Page Templates, too. > and how is Zope for coding in languages other than Python? (e.g., Perl) Yes, write Perl Methods in Zope. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From cribeiro at mail.inet.com.br Sat Jun 2 21:04:03 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Sat, 02 Jun 2001 22:04:03 -0300 Subject: Controlling CDR drives using Python in Windows Message-ID: <5.0.2.1.0.20010602214742.009fcec0@mail.inet.com.br> I'm looking for information on how to control a CDR drive from Windows, using Python scripts, of course. I'm planning to automate my home backups using Python scripts. If someone has any information on how to make it work, I'll be glad to know. JFYI, I tried to find information over the web on CDR API. Most of the information that I found was either commercial, incomplete or it was vendor specific. Even at http://www.cdrfaq.org/ - the wealth of information is immense, but software list seems to cover only commercial or outdated offerings (I'm still to check them all). That's why I'm asking on the group. Carlos Ribeiro From no at spam.com Fri Jun 22 07:48:49 2001 From: no at spam.com (MDK) Date: Fri, 22 Jun 2001 07:48:49 -0400 Subject: Is this a true statement? Message-ID: <9gvb8q$ssl$1@taliesin.netcom.net.uk> Python can do everything C++ can do but just slower. From scarblac at pino.selwerd.nl Tue Jun 5 04:33:35 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 5 Jun 2001 08:33:35 GMT Subject: Wadda ya mean it's not defined? Impossible Error? References: <3B1C2727.D9E746CB@dsl.ca> Message-ID: David Gilbert wrote in comp.lang.python: > I'm getting what appears to be an impossible error. Here's a code > snippet: > > def parseLogs(paths, custs): > > ipfRecord = re.compile("^([0-9]+)[ ]+([0-9]+)[ > ]+([0-9a-z]+)([+-])") > > last = {} > for i in range(len(paths)): # Create start times > ... and so on. > > Here's the error snippet: > > File "../devel/ditty/bandsaw2.py", line 37, in parseLogs > for i in range(len(paths)): # Create start times > UnboundLocalError: local variable 'paths' referenced before assignment I don't get the error. You probably had a typo in the file when you tried it (misspelled the first paths?). -- Remco Gerlich From sorular at netscape.net Tue Jun 12 20:20:15 2001 From: sorular at netscape.net (sorular) Date: Wed, 13 Jun 2001 00:20:15 GMT Subject: MapIt! 1.0 - Webapplication for Rastermaps References: <9g5b3t$70ltn$2@ID-89274.news.dfncis.de> Message-ID: <3b26b2af.58266963@news-server.bigpond.net.au> Can MapIt work with Zope server? ~sor On Tue, 12 Jun 2001 15:57:07 GMT, wware at world.std.com (Will Ware) wrote: >Bernhard Reiter (bernhard at intevation.de) wrote: >> > MapIt! 1.0 >> > http://www.mapit.de/ > >Given the laziness of us numerous American slugs who can't be bothered >to learn other folks' languages, there may be some interest as well in >the English-language home page: > >http://www.mapit.de/mapit.en.html > >-- >-----------------------------------+--------------------- > 22nd century: Esperanto, geodesic | Will Ware > domes, hovercrafts, metric system | wware at world.std.com From insanc at cc.gatech.edu Mon Jun 18 10:33:20 2001 From: insanc at cc.gatech.edu (Holland King) Date: 18 Jun 2001 14:33:20 GMT Subject: bad python display References: <9gdie8$r2v$1@solaria.cc.gatech.edu> Message-ID: <9gl3fg$3rt$1@solaria.cc.gatech.edu> In comp.os.linux.misc David Efflandt wrote: : Are you running X under ssh-agent (I have "ssh-agent startx" as an alias : to startx), then ssh-add from an xterm? That should automatically set up : your DISPLAY variable on the other end to tunnel everything back through : ssh. Not quite sure how to do that from GUI login (runlevel 5). i will try this and see if that works. thanks : If not tunnelling through ssh, maybe there is a port permission problem : on either end or you may need to use xhost to allow it. I don't really : know anything about python or tkinter, but do other X programs run : remotely automatically display locally (xterm, netscape, etc.)? netscape and gimp both display correctly. i haven't tested it much past that though. -- Joseph Holland King | "God whispers to us in our pleasures, speaks in our | conscience, but shouts in our pains: it is His | megaphone to rouse a deaf world." C. S. Lewis From aahz at panix.com Tue Jun 26 00:07:07 2001 From: aahz at panix.com (Aahz Maruch) Date: 25 Jun 2001 21:07:07 -0700 Subject: Should I use a dictionary? References: Message-ID: <9h91pb$e3k$1@panix6.panix.com> In article , Gustaf Liljegren wrote: > >I have an object type for e-mail messages based on the rfc822 >module. After picking out some messages from several sources, I want >to sort them in order of the date property of the message object (as >far as I understand, everything in this process needs to be kept in >memory). Anyway, the problem is that I need some hints about how to >sort the messages, as they are not sorted in way I get them. > >One idea I came up with was to put the date property of the message >object as a key in a dictionary, and let the rest of the message be >the value! But even if it would work, I think it's ugly. If someone >can convince me that it's not ugly, or give a better (i.e. faster) >solution, I'd be happy. For this purpose, a list is probably better, with the values being a tuple of (, ). The problem is that dicts want the key to be unique, and dealing with key collisions in this case is almost certainly more trouble than it's worth. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Those who do not remember the past are condemned to repeat it." From Reiner_Bielefeld at web.de Fri Jun 8 14:36:25 2001 From: Reiner_Bielefeld at web.de (Reiner Bielefeld) Date: Fri, 8 Jun 2001 20:36:25 +0200 Subject: Semaphores in Python 1.4 Message-ID: <9fr5pe$ti8$07$1@news.t-online.com> Hi Folks, I have to port a python application from AIX to Linux. To use semaphores, the application imports a "Semc" which is a buildin C-module. I found the module Semcmodule.o in the libModules.a in the config directory of the installed Python Version 1.4. Cause its an object module I can't use it under Linux. Where can I get this module in source ? Thanks a lot. Reiner Bielefeld From bokr at accessone.com Wed Jun 20 14:44:16 2001 From: bokr at accessone.com (Bengt Richter) Date: Wed, 20 Jun 2001 18:44:16 GMT Subject: Two minor syntactic proposals References: <16074dce.0106181057.528dfea@posting.google.com> Message-ID: <3b30ee5e.1008026215@wa.news.verio.net> On 18 Jun 2001 11:57:59 -0700, jeff at ccvcorp.com (Jeff Shannon) wrote: >philh at comuno.freeserve.co.uk (phil hunt) wrote in message news:... >> >> I propose a different way of doing this: make 'self' implied in all >> references to instance variables. This involves definiing 2 new keywords, >> qclass and insvars. So: I think I prefer just an easier way to type "self." How about just the dot? I.e., ".x" means "self.x" [...] >I much prefer having all member variables and member functions explicitly >qualified. Having moved to Python from C++, where members can be referred >to implicitly, it seems to me that the explicit requirement of Python makes >code *much* easier to read--no more hunting about to try to figure out whether >a given variable is a class member, or a parameter, or a global, or from some >other scope... then there's also this problem (using your notation): [...more reasons...] So what about a plain prefixed '.' as an abbreviation for 'self.' ? From nperkins7 at home.com Thu Jun 21 17:29:09 2001 From: nperkins7 at home.com (Nick Perkins) Date: Thu, 21 Jun 2001 21:29:09 GMT Subject: Partially evaluated functions References: Message-ID: I meant to repy on clp, but only sent email by accident. Rainer is right. His implementation of curry does avoid a certain class of problems, namely, when you want to pass a kwd arg to the 'inner' function, but the actual curry function 'grabs' the arg for itself if the keyword matches any formal parameters to the curry function. (eg. 'self', or 'func') I am sorry, I did not understand at first. Also, Alex has pointed out a flaw in the 'no kwd.copy() necessary' thing, for curry implementations that give precedence to call-time kwd args. The original cookbook version had it right to begin with. Now I know why. So, incorporating the elimination of named args, and my preference for 'left-to-right' positional args, and call-time precedence, and the elegance of the functional version supplied by Alex, I presently have: def curry(*args, **create_time_kwds): func = args[0] create_time_args = args[1:] def curried_function(*call_time_args, **call_time_kwds): args = create_time_args + call_time_args kwds = create_time_kwds.copy() kwds.update(call_time_kwds) return func(*args, **kwds) return curried_function It's a bit longer becuase I am trying to be very explicit about the 'trick'... ps. it would be nice if dict1 + dict2 returned a new 'merged' dictionary.. From johnca at DIESPAMmac.com Tue Jun 5 05:19:00 2001 From: johnca at DIESPAMmac.com (John Abbe) Date: Tue, 05 Jun 2001 02:19:00 -0700 Subject: PYML, Python, Perl and Zope Message-ID: PYML looks very neat for web delivery (Python embedded in HTML). http://www.pyml.org/ With Python 2.1 does it still need the SGML thing? Is there anything like it for Perl? ---- Zope looks neat, too. Zope uses DHTML, right? Is anyone using it with PYML? and how is Zope for coding in languages other than Python? (e.g., Perl) Thanks... John -- The links i wish i had the first week i got OS X: http://www.ourpla.net/guiunix/GettingXGoing.html From akhar at videotron.ca Fri Jun 1 13:51:33 2001 From: akhar at videotron.ca (akhar) Date: Fri, 1 Jun 2001 10:51:33 -0700 Subject: PIL speed and fears Message-ID: <50OR6.12931$sc4.527985@wagner.videotron.net> I have been using pil for robtic vision, however due to a lack of funding my project is not very far yet ( I have only been parcticing with static images). Now I have been optimising code and all but (I am under windows) I see some lag when I manipulate large images 640*480, what I do that I use pil to split the image into three matrixes and then scan for specified values and filter out others and discontinuities in them, the only real lag apears in two places in the code both coresponding to when I call PIL to show the images resulting from the filters. I noticed that it tries to open a dos session and then shows me the image in paint. I am afraid that for phase two when I start using streams of images directly from the camera that their will be an enormous lag. Is it only because of windows? should I be using something else for realtime video streams like pySDL? or is it windows and I should use freebsd to do this? Regards Akhar From pkalliok at cc.helsinki.fi Fri Jun 1 08:47:15 2001 From: pkalliok at cc.helsinki.fi (Panu A Kalliokoski) Date: 1 Jun 2001 12:47:15 GMT Subject: The Selecting package - 0.85 Message-ID: <9f82sj$qim$2@oravannahka.helsinki.fi> Hello all, I've been reading your interests in the issue over select() management. Especially, I took the time to write a routine for building outgoing connect()ing select channels for SelectManager. They're available in the current version of selecting, which is at http://sange.fi/~atehwa-u/selecting/ and http://sange.fi/~atehwa-u/selecting-0.85.tar.gz I've inspected the TKinter mainloop() case a little and reached the conclusion that the only way to write your own mainloop is to write code that calls tkinter.update() periodically. This is easily achieved in selecting by putting into the event queue a permanent event (every half seconds or so) of calling tkinter.update(). No need for TKSelectManager, that way. The "proper" way to handle select() with TKinter would be to somehow get TKinter to tell the file handles it uses to communicate with X. Is there any way to do this? Panu Kalliokoski From max at alcyone.com Wed Jun 6 11:57:14 2001 From: max at alcyone.com (Erik Max Francis) Date: Wed, 06 Jun 2001 08:57:14 -0700 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3b1cdc84.5514@bolder.com.co.za> <9fleid$3rp$1@oslo-nntp.eunet.no> <3B1E4951.7F36D4E4@alcyone.com> <3B1E50E1.35AE59C@lmf.ericsson.se> Message-ID: <3B1E52DA.BBC9FC32@alcyone.com> Attila Feher wrote: > BTW some competents I know play games... really... although I have > never > seen an original box of any game they play :-))) So OK they do play. > But do they buy? That competent computer users play games but never buy them is also ridiculous. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ The purpose of man's life is not happiness but worthiness. \__/ Felix Adler Maths reference / http://www.alcyone.com/max/reference/maths/ A mathematics reference. From jessw at loop.com Fri Jun 22 14:55:20 2001 From: jessw at loop.com (Jesse W) Date: Fri, 22 Jun 2001 11:55:20 -0700 Subject: beginner ques: dir( ) does'nt list my instance methods? References: Message-ID: <3B339498.78F9@loop.com> Dear karthik, I have written a short function that should show all the references in a given object. I think it has a few bugs, but I don't remember what they are. Here it is: def super_dir(object, top=1): """Return _all_ variables, functions, and methods. This is a fix for the dir function that is provided with Python. It will return all class methods, even if they are defined in a base class. It also works with class objects, showing all the methods, not just those defined in the given object.""" answer=dir(object) if hasattr(object, '__class__'): answer=answer+super_dir(object.__class__, 0) elif hasattr(object, '__bases__'): for item in object.__bases__: answer=answer+super_dir(item, 0) if top: new_answer=[] for item in answer: if item not in new_answer: new_answer.append(item) return new_answer return answer For those who missed the original message: karthik_guru at rediffmail.com wrote: > > class test: > def __init__(self): > print 'hello test' > self.foo = 100 > self.bar = 900 > > def func(self): > print 'hello' > > if __name__ == '__main__': > t = test() > print dir(t) > print t.__dict__ > > Both dir(t) and t.__dict__ print only foo and bar. > They don't print the func which is also a instance attribute (method > reference)? > > But they are printed when i do test.__dict__ and dir(test)..ie > > why is it not getting printed in the earlier case?(wiht instance) > > I might be required to do a look up from dir(instance) and if an > attribute happens to be of the type method i can invoke it? > > thanks > karthik. From jkraska1 at san.rr.com Sat Jun 16 13:14:11 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 16 Jun 2001 17:14:11 GMT Subject: New statement proposal for Python References: <9gf434089d@enews1.newsguy.com> Message-ID: <2c5nitojddkrfhljglfq2ai4r4v6ri9a1q@4ax.com> >Guido should have made "keyword" a keyword too. Then we could have had a >keyword statement at the top of each module, identifying all the post-1.0 >keywords your code wants to use <0.9 wink>. Well, I think you're kidding, but this should be part of a more general directive system. :) C// From phd at phd.fep.ru Fri Jun 15 16:08:13 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Sat, 16 Jun 2001 00:08:13 +0400 (MSD) Subject: kjbuckets for Python 2.1 In-Reply-To: Message-ID: Cyrill Slobin who recently announced Python build for DOS (by DJGPP compiler) reported he just built this kjbuckets into the DOS port. It is Python 2.1, so I think this kjbuckets module can easily be compiled for Python 2.1 on any OS. On Thu, 14 Jun 2001, Oleg Broytmann wrote: > -- updated for Python 2.0 > (Berthold Hoellmann ) > > -- Makefile.in/Setup for old-style compilation/configuration > -- setup.py for new-style (Distutils) compilation/configuration > (Oleg Broytmann ) > > -- kjbuckets.pyd Windows DLL for Python 2.0 > -- sqlsem.py patch to use it with kjbuckets.pyd > (Adnan Merican ) > > Download: > http://phd.pp.ru/Software/Python/#kjbuckets > http://phd.pp.ru/Software/Python/misc/kjbuckets.tar.gz > > Fatser mirrors: > http://phd2.chat.ru/Software/Python/#kjbuckets > http://www.crosswinds.net/~phd2/Software/Python/#kjbuckets Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From rhystucker at rhystucker.fsnet.co.uk Thu Jun 7 01:40:42 2001 From: rhystucker at rhystucker.fsnet.co.uk (rhys) Date: Thu, 07 Jun 2001 06:40:42 +0100 Subject: How to change Pythonwin background colour? - Thank you References: <3B1E8047.17E114FC@rhystucker.fsnet.co.uk> <3B1EBEF4.6080103@ActiveState.com> <3B1EC850.7655D790@rhystucker.fsnet.co.uk> <3B1ECE77.5050606@ActiveState.com> Message-ID: <3B1F13DA.CE8E8B8E@rhystucker.fsnet.co.uk> Mark Hammond wrote: > > rhys wrote: > > > This is a real problem for me as I have a sensitivity to bright light. > > I've downloaded the Pythonwin source - is it just a matter of finding > > white_brush or something similar, changing it and recompiling? > > Open pywin.framework.interact > > Find the following function: > > def SetStyles(self): > FormatterParent.SetStyles(self) > Style = pywin.scintilla.formatter.Style > > You can add a 3rd param to the "Style()" function. This is an RGB value > for the background. Eg: > > self.RegisterStyle( Style(STYLE_INTERACTIVE_EOL, > STYLE_INTERACTIVE_PROMPT, 8421504 ) ) > self.RegisterStyle( Style(STYLE_INTERACTIVE_PROMPT, formatInput, 8421504 ) ) > > etc - note the 3rd param I added - this is win32api.RGB(128,128,128), > and gives a pretty horrible grey as the background color. Add it to all > or any of the Style() calls you like. > > If you want to generalize this somehow so the value is read from the > registry I would be happy to include if. I may even get around to > adding it to the dialog so it can be specified. > > Mark. Thank you. rhys From sholden at holdenweb.com Tue Jun 26 09:35:04 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 26 Jun 2001 09:35:04 -0400 Subject: Sybase module 0.27 released References: Message-ID: "Pieter Claerhout" wrote ... > Does anyone know if this will work for MS SQL Server as well? It's a rip-off > of Sybase anyway, as far as I remember. > > Pieter > > > -----Original Message----- > From: Dave Cole [mailto:djc at object-craft.com.au] > Sent: Tuesday, June 26, 2001 12:36 PM > To: python-list at python.org > Subject: Sybase module 0.27 released > > > What is it: > > The Sybase module provides a Python interface to the Sybase relational > database system. The Sybase package supports almost all of the Python > Database API, version 2.0 with extensions. > > The module works with Python versions 1.5.2 and later and Sybase > versions 11.0.3 and later. It is based on the Sybase Client Library > (ct_* API), and the Bulk-Library Client (blk_* API) interfaces. > > The 0.20 and later releases are a re-implementation of the module using > a thin C wrapper on the Sybase-CT API, and a Python module to provide > the DB-API functionality. It is still a work in progress, but should > be good enough for most purposes. > > Changes for this release: > > - Sybase.py module no longer imports exceptions module. > > - Optional auto_commit argument has been added to Sybase.connect(). > The default value is 0. > > - Optional delay_connect argument has been added to Sybase.connect(). > The default value is 0. This allows you to manipulate the Sybase > connection before connecting to the server. > > >>> import Sybase > >>> db = Sybase.connect(server, user, passwd, delay_connect = 1) > >>> db.set_property(Sybase.CS_HOSTNAME, 'secret') > >>> db.connect() > > - Removed redundant argument from sybasect.ct_data_info() > > - Added pickle capability to NumericType - I somehow forgot to copy > this over from the old 0.13 module. > > - Re-arranged sybasect.h to make it easier to follow - I hope. > > - Documentation updates. > >From memory, you can use it with other databases, including MS SQL Server. I couldn't do so, however, as I would have had to recompile the package for my Linux SPARC system, and I didn't have the required Sybase header files. Also, I don't *think* this module is (yet) ported to Windows, so you might also require a Unix driver manager to use MS SQL Server (since, strangely, the MS product doesn't seem to have been ported to Unix). I'm not sure the term "rip-off" is fair: Microsoft and Sybase decided to go their separate ways, is all. Just like IBM and Microsoft. Nobody could call Windows a rip-off of OS/2, now could they? In truth both companies have done different things with the codebase they started with. I happen to believe that Sybase's directions are more sensible, but the marketplace clearly doesn't agree. Nothing new there, then :-) regards Steve -- http://www.holdenweb.com/ From asgard at hellnet.cz Mon Jun 25 14:33:11 2001 From: asgard at hellnet.cz (asgard) Date: Mon, 25 Jun 2001 20:33:11 +0200 (CEST) Subject: 'with' statement in python ? Message-ID: Hello, writing self before every object's method really drives me crazy. Shouldn't there be 'with' statement like in Pascal, ie. self.a=1 self.b=2 could be written as with self: a=1 b=2 ? Of course it would work with other names too. Have anyone considered this, is it a total nonsense or probably should I write a PEP ? (I am not able to implement it myself anyway). Thanks Regards Jan Samohyl From Attila.Feher at lmf.ericsson.se Wed Jun 6 11:58:39 2001 From: Attila.Feher at lmf.ericsson.se (Attila Feher) Date: Wed, 06 Jun 2001 18:58:39 +0300 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3b1cdc84.5514@bolder.com.co.za> <9fleid$3rp$1@oslo-nntp.eunet.no> <3b1e4ef5.3788@bolder.com.co.za> Message-ID: <3B1E532F.7158FCFD@lmf.ericsson.se> goose wrote: > IIRC, the original post said 99.99% of computers run windows ... > I would like to see the source for this info ...maybe a web-page link ? http://www.m$marketingbullshitandlies.neverbelieveit.ohboy.lie :-)))) > i seem to be missing your argument, maybe i'm just a little dense > today... I can send over some migren if you need a cause :-))) It is a real A class one! :-) > what is your point ? > that 99.99% of computers run windows ? I don't think so. > that 80% of home computers run windows ? That may not be true in the US (Apple has a much higher % there than eg. in Hungary) but it is really true that games manufacturers can still get a very big market with MS only SW. Even MS Win9x/ME only. > that a pre-installed computer *always* comes with windows ? This might have changed lately but it _was_ true. Places where you can get it w/o Windows are not well know by the "simple" public. Really. I live in Finland now. All PC ads have Windows whatever preinstalled. No choice, only between a Win9x/ME or NT (4/2K/XP will be now). :-((( This is the country of Linux! > that i cannot order a 'blank' computer from a hoover-salesman ? Now that was true in Hungary! Maybe not today, but I doubt that big cos changed a lot. I said I want it w/o OS they said: no way. MS _forces_them_ to sell Windoze with every PC. I said then I don't want a HDD in it. They say OK, then it costs +100USD. I say: so long suckers... and bought a PC from a "garage company". The ridicul is that I had highest possible MSDN and I was buying this SMP stuff for development... I already bought the OS for a lot of money from MS. Actually _all_ OSs including the traditional Chinese versions... And now comes: the garage PC needed me to install a new vent into it for the HDD was too hot... So at least where I am you don't get a PC w/o MS OS. :-((( A From piet at cs.uu.nl Thu Jun 7 09:38:37 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 07 Jun 2001 15:38:37 +0200 Subject: integers References: Message-ID: >>>>> "Bjorn Pettersen" (BP) writes: BP> And introducing them now would change the meaning of: BP> x--1 It wouldn't because there is only one way to parse this, but it would make the parser more difficult. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From jhoerr at resnet.gatech.edu Thu Jun 28 15:15:47 2001 From: jhoerr at resnet.gatech.edu (John Hoerr) Date: Thu, 28 Jun 2001 15:15:47 -0400 Subject: WinNT: Delete to recycle bin? Message-ID: <9hg04d$r9f$1@iocextnews.bls.com> hi! i'm relatively new to python and am wondering if there's a way to remove files to the windows recycle bin instead of deleting them outright. google searches of the web and this newsgroup didn't turn up much, but i'm hoping i missed something? thanks, john From root at rainerdeyke.com Thu Jun 21 00:13:10 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Thu, 21 Jun 2001 04:13:10 GMT Subject: Partially evaluated functions References: Message-ID: "Nick Perkins" wrote in message news:abeY6.301566$eK2.61312477 at news4.rdc1.on.home.com... > > Rainer Deyke: > > > >>> def f(self, **kwargs): > > > ... print self, kwargs > > > ... > > > >>> f(f, self=5) > > > Traceback (most recent call last): > > > File "", line 1, in ? > > > TypeError: keyword parameter redefined: self > > > Carsten Geckeler: > > > Probably you mean > > curry(f, self=5) > > and not > > f(f, self=5) > > > > But you are right that you get a TypeError due to the __init__ function in > > the class. > > > Of course you get an error when you try to pass a keyword argument to a > function that does not take any keyword arguments. Read the example again. I am trying to get 'self : 5' into 'kwargs'. > ( and why are you trying to pass 'self'?) The name is irrelevant. > What does work, for the cookbook version, and Alex's functional version, is > any of the following: > > def print_thing( thing='boat' ) > print thing > print_plane = curry( print_thing, thing='plane' ) > print_plane() > > ..now calling print_plane() will simply print 'plane' > > > or, the same thing without the keywords: > > def print_thing( thing ): > print thing > print_plane = curry( print_thing, 'plane' ) > print_plane() > > > or.. you can even do this: > > def print_thing( thing='boat' ): > print thing > print_plane = curry( print_thing, 'plane' ) > print_plane() > > ..with a positional arg being 'promoted' to a keyword arg. This also works: def print_thing(thing): print thing print_plane = curry(print_thing, thing = 'plane') print_plane() This doesn't work: def print_fun(fun = 'boat'): print 'A %s is fun.' % fun print_plane = curry(print_fun, fun = 'plane') print_plane() Neither does the obvious variation: def print_fun(fun): print 'A %s is fun.' % fun print_plane = curry(print_fun, fun = 'plane') print_plane() -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From alan.gauld at bt.com Wed Jun 13 19:04:51 2001 From: alan.gauld at bt.com (Alan Gauld) Date: Thu, 14 Jun 2001 00:04:51 +0100 Subject: Has anyone used UML? References: <9flodi$32m$1@brokaw.wa.com> <3b228485.13884244@news.laplaza.org> <3B250921.F9F1D571@bt.com> <9g5oml$ird$6@216.39.170.247> Message-ID: <3B27F193.DD94F852@bt.com> David LeBlanc wrote: > > Not true! Rumbaugh and then Jacobson specifically joined > > Rational to create the UML. By the time they joined they > > already recognised the need for a unifying language. > wellll.... actually Rational bought both Rumbaugh's and Ivarson's > companies and they came along with the sale. Might be true of Jacobsen since he had left Ericsson by that time but I thought Jim R was still with GEC when he went to Rational? > From what I hear there is a good deal of not so cordial > dislike between/among the "3 amigos" I don't think they've ever claimed to be best buddies. Several disagreements have been acknowledged in articles etc But they all recognised that the method wars would do more harm than good. > For all the ado about UML, there seems to be few competitors to Rose, I think that there are plenty now: Together, Object Domain, iLogix etc... But they are all complex tools doing a very complex job so they cost lots. Best tool for small projects is a tool like Visio, DIA, SmartDraw etc. IMHO Alan G From jeff at ccvcorp.com Thu Jun 28 12:35:25 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Thu, 28 Jun 2001 09:35:25 -0700 Subject: PEP 260: simplify xrange() References: <3B398BBE.A2D455C9@darwin.in-berlin.de> <9hclc1$qv5$1@panix2.panix.com> <3B3A08B5.3C142546@darwin.in-berlin.de> <3B3A1DC0.3583E9D8@ccvcorp.com> <3B3A2639.69BA1DCE@Lugoj.Com> Message-ID: <3B3B5CCD.40781FF1@ccvcorp.com> James Logajan wrote: > Jeff Shannon wrote: > > To make a long story short, the discussion regarding FP boils down to the > > fact that "1.0" cannot be exactly represented in FP. Every time you increment > > your "frange", you are introducing nasty rounding errors, and by the time > > you've > > done several thousand iterations, they're going to be very significant > > rounding > > errors. > > Perhaps you mean 0.1 can't be represented exactly using standard internal > representations? Whoops! Yes, that's exactly what I meant. Gotta start proofreading better before I hit "send" ... :) >>> count = 0.0 >>> for i in range(10): ... count += 0.1 ... repr(count) ... '0.10000000000000001' '0.20000000000000001' '0.30000000000000004' '0.40000000000000002' '0.5' '0.59999999999999998' '0.69999999999999996' '0.79999999999999993' '0.89999999999999991' '0.99999999999999989' Many things can get thrown off by those little rounding errors. (Or, if you don't like "errors", then... unpredicted differences. ) Mind you, all of this could potentially be solved by the rational numbers/decimal FP proposals that have been brought up in the not-too-distant past... Jeff Shannon Technician/Programmer Credit International From chrishbarker at home.net Fri Jun 15 16:05:10 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 15 Jun 2001 13:05:10 -0700 Subject: idle BUG References: Message-ID: <3B2A6A76.66930481@home.net> Robin Becker wrote: > I don't believe that blaming the other guy (Tcl) is the right way to go. How about blaming the other other guy...Windows9* Develop on *nix, (or Win2k, apparently), and you'll have no problem. From James_Althoff at i2.com Tue Jun 26 13:19:48 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Tue, 26 Jun 2001 10:19:48 -0700 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) Message-ID: Tim Peters wrote: >Some implementations of Icon work that way, but they've used several >approaches over the years. In no case did they expose any of the internals, >though. We didn't *have* to expose Python's generator-iterator object >either, but doing so adds (IMO) significant power over Icon's generators -- >and it's more Pythonic to do so anyway. I agree. Thanks for an excellent decision! :-) Jim From johnroth at ameritech.net Wed Jun 20 14:49:22 2001 From: johnroth at ameritech.net (John Roth) Date: Wed, 20 Jun 2001 11:49:22 -0700 Subject: graceful version detection? References: <3B2D2F44.50007@red-bean.com> Message-ID: Just my .02 cents on this one. Python, like most other languages I know, doesn't have any clean syntax for checking this. I think all languages should have something like a "requires" or a "standards" statement that declares the minimum compiler level required, as well as the highest level that the maintainer(s) have verified it under. For example: requires 2.0, 2.1, tkinter Unfortunately, it isn't there. If it was, compliant compilers would simply refuse to compile it, with an understandable error message. John Roth "Ben Collins-Sussman" wrote in message news:3B2D2F44.50007 at red-bean.com... > Please excuse me if this is a common newbie question; I didn't find it > in the FAQ or tutorial. > > If I write a python script that uses 2.X features, and then run it with > a 1.X interpreter, I get a bunch of exceptions. Presumably this happens > during the initial byte-compilation. > > I'd like the script to instead gracefully print: > > "Sorry, this program requires Python 2.0 or higher." > > I tried writing some code to do this by parsing `sys.version' at the top > of my program; but as I said, the byte-compiler seems to choke first. > > What's the correct solution? > > Please cc: my email address (sussman at red-bean.com), as I don't read this > group regularly. > > Thanks in advance -- > > Ben Collins-Sussman > sussman at red-bean.com > From emile at fenx.com Thu Jun 14 14:10:37 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 14 Jun 2001 11:10:37 -0700 Subject: Automatic registration of Python DCOM object Message-ID: <9gauua$89nno$1@ID-11957.news.dfncis.de> I've got a DCOM python object that is intended to be used from within Excel. It works fine on the system I've worked on, and on a test system where I've manually configured things. The intent is that the spreadsheet be located in a shared folder for general access. I'd like _not_ to have to specifically install/setup the DCOM object (or python ;-) on each system that may use it, and so I'm investigating how I can cause the worksheet to register the object and allow transparent access to the DCOM object. To this end, it looks like http://support.microsoft.com/support/kb/articles/Q145/6/79.asp will allow me to create the required registry entries. So far, however, this doesn't seem to be enough. Has anyone done something like this, or know one way or the other if it _can't_ be done. The target systems are all NTWS. -- Emile van Sebille emile at fenx.com --------- From s713221 at student.gu.edu.au Fri Jun 22 21:42:33 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Sat, 23 Jun 2001 11:42:33 +1000 Subject: Numeric 20.0.0 and 19.0.0 crash Python 2.1 References: Message-ID: <3B33F409.A7092D2F@student.gu.edu.au> Chad Everett wrote: > > SuSE 7.1 Linux version 2.4.3-pre6 (gcc version 2.95.2 > 19991024 (release)) #1 SMP Wed Mar 21 17:18:55 MST 2001 > > I just installed Numeric-20.0.0 in my Python 2.1 (#1, Apr 18 2001, 12:17:25) > and it is smooth. > > My python 2.1 was just configured and built with: > > ./configure --prefix=/opt/Python-2.1 > > On Fri, 22 Jun 2001 19:16:31 +0200 (MET DST), Daniel Reuter wrote: > >Hello there, > > > >When I do the following: > >import Numeric > >Python 2.1 crashes with a segmentation fault. > >This is on a Debian/GNU Linux system, Python is configured --with-pymalloc Here is the problem. Read up on the "What's New" of python2.1 about pymalloc - basically it will crash certain third-party modules that haven't quite followed the API. It didn't matter for previous releases of python, but it matters for python2.1. Basically, if you want Numeric, don't use --with-pymalloc on your python build. As can be seen, the other poster was successful with is build, because he didn't use pymalloc. -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From ullrich at math.okstate.edu Sun Jun 24 12:12:49 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 24 Jun 2001 16:12:49 GMT Subject: Is this a true statement? References: <3b34939b.410758@nntp.sprynet.com> <3b35ed3b.1401529@nntp.sprynet.com> Message-ID: <3b360fba.10233292@nntp.sprynet.com> On 24 Jun 2001 14:18:22 GMT, carlf at panix.com (Carl Fink) wrote: >In article <3b35ed3b.1401529 at nntp.sprynet.com>, David C. Ullrich wrote: > >Are you trolling or just having trouble with English? Are you trying to be insulting or just having trouble with English yourself? You accused me of _intentionally_ missing the distinction between "writing a file" and "writing a program", but when I ask for an exlplanation of the difference you don't give one. (Probably you thought that what's below clarifies the distinction.) >> I may well be misunderstanding something, but it's not deliberate. >> What _is_ the distinction between "write to a file" and >> "create a new program"? (I'm assuming that the "program" >> in question is the device driver. _Is_ that something other >> than a file? And if not then what does a C program that >> writes device drivers do, other than write a file?) > >But "writing a device driver" isn't something the *program* does at >all. It's something a *programmer* does. The programmer, working in >Python, could technically write a device driver, but for practical >purposes wouldn't be "using" Python to create the driver. He/she >would be writing the device driver in pure machine language and the >only use of Python would be to perform a file write operation. > >"Writing a device driver", I repeat, is what the *programmer* does, >not what the *program that writes the actual file* does. So Python cannot write a device driver without a programmer telling it exactly what to do. That's certainly true. But I don't know why you would think _I_ was trolling here - seems to me that if this is how we're using the words then Python cannot do anything, and neither can C. (Which is why I had no idea we were using the words this way.) Or is writing a device driver something that C can do without a programmer? >-- >Carl Fink carlf at dm.net David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From bkc at Murkworks.com Wed Jun 6 17:57:27 2001 From: bkc at Murkworks.com (Brad Clements) Date: Wed, 6 Jun 2001 17:57:27 -0400 Subject: McMillan Installer 4 error ImportError: No module named posixpath Message-ID: <3b1ea684$1_4@127.0.0.1> I have a very simple python 1.5.2 script on w2k that I want to distribute. I've tried beta 4 of the installer to create either a standalone or simple distribution, but when I run it (either one), I get the same error. Trace attached below. I tried explicitely importing posixpath, but that doesn't matter. tried with and without the -win32 option. My module imports: import win32ras import smtplib, rfc822, sys import string, traceback, time, getopt import mimetypes, urllib, tempfile, MimeWriter, base64 The runtime error is: E:\prj\src\strader\Dial\dist_DialAndSendL>DialAndSendL.exe Start Opening self Unpacking binaries Manipulating evironment Loading python E:\prj\src\strader\Dial\dist_DialAndSendL\python15.dll Getting entry points Setting Python vars Initializing Python Manipulating Python's sys.path Setting sys.argv importing modules from CArchive loading imputil loading archive_rt Installing import hooks executing import archive_rt;sys.path.append(archive_rt.ZlibArchive(r'E:\prj\src\ strader\Dial\dist_DialAndSendL\DialAndSendL.exe', 47616)) Running scripts extracting DialAndSendL (2, s) running DialAndSendL Traceback (innermost last): File "", line 38, in ? File "D:\Program Files\Python\Lib\mcMillan\MEInc\Dist\../../support\imputil.py ", line 88, in _import_hook top_module = self._import_top_module(parts[0]) File "D:\Program Files\Python\Lib\mcMillan\MEInc\Dist\../../support\imputil.py ", line 170, in _import_top_module module = item.import_top(name) File "D:\Program Files\Python\Lib\mcMillan\MEInc\Dist\../../support\imputil.py ", line 197, in import_top return self._import_one(None, name, name) File "D:\Program Files\Python\Lib\mcMillan\MEInc\Dist\../../support\imputil.py ", line 252, in _import_one module = self._process_result(result, fqname) File "D:\Program Files\Python\Lib\mcMillan\MEInc\Dist\../../support\imputil.py ", line 281, in _process_result exec code in module.__dict__ File "d:\Program Files\Python\Lib\mimetypes.py", line 27, in ? import posixpath File "D:\Program Files\Python\Lib\mcMillan\MEInc\Dist\../../support\imputil.py ", line 91, in _import_hook raise ImportError, 'No module named ' + fqname ImportError: No module named posixpath Finalizing Python -- Brad Clements, DevNet Sysop 5 Developer Network Sysop Team -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From ken_chiba at hotmail.com Thu Jun 21 18:28:27 2001 From: ken_chiba at hotmail.com (Ken) Date: Thu, 21 Jun 2001 22:28:27 GMT Subject: libssl.so & libssl.so req'd for rpm install Message-ID: <3b327452.95354923@news1.on.sympatico.ca> Hi, I guess this is kind of a follow up from my last message; I'm trying to install python 2.1-5 off the rpm, which I'm assuming will work fine if it can work out its dependencies. It's failing on the following dependencies: libcrypto.so.0.9.6 libssl.so.0.9.6 I previously didn't have these files installed, but I managed to install the right RPM, and they are now there: /usr/lib/libcrypto.so.0.9.6 /usr/lib/libssl.so.0.9.6 ...yes the RPM install still fails. I'm running on a farily minimal clean install of RH7.1. Any suggestions? TIA! kc From MarkH at ActiveState.com Sun Jun 17 19:50:03 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sun, 17 Jun 2001 23:50:03 GMT Subject: __getattr__ and other customization methods References: Message-ID: <3B2D425E.9080901@ActiveState.com> Brian Quinlan wrote: > Is there any reason why getattr, when called on an instance, should call > that instance's __getattr__ method for other customization methods > (methods starting with __)? Otherwise you have no way of saying "this method does not exist". Consider an object that wraps another object - ie, a proxy. Some objects you proxy may provide a __len__ method, while others may not. However, Python changes behaviour based on the *existence* of this method. Generally you will want your proxy to behave exactly the same as the proxied object. So, if the proxy class always provides a __len__ method, it loses this ability - what would __len__ return if the proxied object does not provide the method? The only reasonable way is to have __getattr__ ask for these attributes. Further, it is, IMO, much cleaner this way. Special method names are just attributes. The lack of surprises here makes for a cleaner model. I agree there are gotchyas, but I don't think it should be any different. And finally, changing this would break too much code, so I seriously doubt it will happen. Mark. From ykingma at accessforall.nl Sun Jun 3 08:13:52 2001 From: ykingma at accessforall.nl (Ype Kingma) Date: Sun, 03 Jun 2001 13:13:52 +0100 Subject: Why no 'elif' in try/except? References: <3B1A06EE.F484930A@snakefarm.org> Message-ID: <3B1A29DE.9876770D@accessforall.nl> Carsten Gaebler wrote: > > Hi there! > > How about adding an 'elif' to try/except? I.e.: > > try: > res = dosomethingnasty() > except: > complain() > elif res == 1: > behappy() > > instead of > > try: > res = dosomethingnasty() > except: > complain() > else: > if res == 1: > behappy() > > Any opinions? The 'else:' in 'try: except: else:' should have been called 'normally:'. Regards, Ype P.S. A possible cause of this problem is that sheep normally don't fly: try: sheep.fly() except: sheep.fell() normally: ??? P.P.S. Perhaps this code be preceeded by "while 1:" to make it more clear. -- email at xs4all.nl From nperkins7 at home.com Thu Jun 14 21:36:57 2001 From: nperkins7 at home.com (Nick Perkins) Date: Fri, 15 Jun 2001 01:36:57 GMT Subject: idle BUG References: Message-ID: I gave up using IDLE a while ago, especially to write Tkinter apps. It is hopelessly unstable on my NT box. I have tried a few python editors/IDEs... PythonWin is a little better, and Boa Constructor is better, still, but they all crash or hang sometimes. SciTe has just begun to work, now that I have my evnironment paths set up, i will have to give that one another chance.. I have a sneaking suspicion that editors writtin in, and running in, Python itself, all suffer from problems related to running user programs in the same process, even the same interpreter, as the editor itself. I am currently evaluating Komodo for 21 days, and it seems to be the best that I have tried, so far. It is very stable--I have not crashed it at all yet. In fact, one time, my program crashed python.exe, but Komodo gracefully recovered control like nothing had happened. It also has a few cool features that I haven't seen elsewhere. My only complaint about Komodo is that it is very slow and unresponsive. Sometimes it seems to freeze up for about five seconds, and response to keyboard input in the edit window is noticeably slow. These things, I suspect, are due to the mozilla stuff underneath. I have never been impressed with a mozilla app, they have neat-looking interfaces, but they are always a little flakey, and noticeably slow in reacting to the mouse and keyboard. In my desperation, I have even gone so far as to try to install vim, but I couln't seem to find and install it in any easy way, so I gave up and got the Komodo demo. ...still searching a rock-solid python ide... From reageer.in at de.nieuwsgroep Sun Jun 24 15:04:33 2001 From: reageer.in at de.nieuwsgroep (Rene Pijlman) Date: Sun, 24 Jun 2001 21:04:33 +0200 Subject: What's object-oriented? References: Message-ID: "zoodoo" schreef: >What's the concept/logic behind object-orientation? What is it suppose to >mean? http://www.google.com/search?q=object+orientation http://www.crosswinds.net/~agauld/tutclass.htm -- Vriendelijke groet, Ren? Pijlman Wat wil jij leren? http://www.leren.nl/ From gbreed at cix.compulink.co.uk Mon Jun 18 13:08:15 2001 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: 18 Jun 2001 17:08:15 GMT Subject: nested classes References: <3B2E2D3A.75F329D@sympatico.ca> Message-ID: <9glchv$kcm$1@plutonium.compulink.co.uk> In article <3B2E2D3A.75F329D at sympatico.ca>, seefeld at sympatico.ca (Stefan Seefeld) wrote: > hi there, > > I'd like to provide a hierarchy of config data by means of > nested classes and static variables, such as: > > class A: > prefix='usr/local' > class B: > datadir = A.prefix + '/share' > ... > > however, I get a NameError: name 'A' is not defined See the earlier message "getting a reference to a class inside its definition" and the flood of no good ideas at all that followed it. > What am I doing wrong ? The above is possibly a bit driven > by my C++ programming style. What is the python way of doing > this ? You can get that to work in C++? It looks strange to me, I'm sure you can't be trying to do what you think you're trying to do. This is the nearest I can think of that works: >>> class A: ... prefix = 'usr/local' ... >>> class B(A): ... datadir = A.prefix+'/share' ... >>> A.prefix 'usr/local' >>> B.datadir 'usr/local/share' You may also like to take a look at os.path.join >>> import os.path >>> class A: ... prefix = os.path.join('usr','local') ... >>> class B(A): ... datadir = os.path.join(A.prefix, 'share') ... >>> print A.prefix usr\local >>> print B.datadir usr\local\share >>> print B.prefix usr\local It'll give the right results on a UNIX system, and stop double or omitted slashes. Graham From tim.one at home.com Mon Jun 11 22:17:24 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 11 Jun 2001 22:17:24 -0400 Subject: [Python-Dev] Feedback on new floating point info in tutorial In-Reply-To: <15141.10257.487549.196538@beluga.mojam.com> Message-ID: [Skip Montanaro, on the in-progess 2.2 Tutorial appendix] > I took a quick look at that appendix. One thing that confused me > a bit was that if 0.1 is approximated by something ever-so-slightly > larger than 0.1, how is it that if you add ten of them together you > wind up with a result that is ever-so-slightly less than 1.0? Good for you, Skip! In all the years I've been explaining this stuff, I only recall one other picking up on that immediately. I'm not writing a book here, though , and any intro numeric programming text emphasizes that n*x is a better bet than adding x together n times. >>> .1 * 10 1.0 >>> Greg Ewing put you on the right track, if you want to figure it out yourself (as Deep Throat said, "follow the bits, Skip -- follow the bits"). > I didn't expect it to be exactly 1.0. Other floating point naifs > may be confused in the same way: > > >>> "%.55f" % 0.5 > '0.5000000000000000000000000000000000000000000000000000000' > >>> "%.55f" % 0.1 > '0.1000000000000000055511151231257827021181583404541015625' > >>> "%.55f" % (0.5+0.1) > '0.5999999999999999777955395074968691915273666381835937500' Note that this output is platform-dependent. For example, the last on Windows is >>> "%.55f" % (0.5+0.1) '0.5999999999999999800000000000000000000000000000000000000' > ... > IEEE-754-is-full-of-traps-for-the-unwary-ly y'rs, All computer arithmetic is; and among binary fp systems, 754 has got to be the best-behaved there is. Know how many irksome bugs I've fixed in Python mucking with different sizes of integers across platforms, and what C does and doesn't guarantee about them? About 20x more than fp bugs. Of course there's 10000x as much integer code in Python too . god-created-the-integers-from-1-through-3-inclusive-and-that's-it-ly y'rs - tim From kirk at strauser.com Mon Jun 18 12:08:40 2001 From: kirk at strauser.com (Kirk Strauser) Date: 18 Jun 2001 11:08:40 -0500 Subject: Python version of IQ has been updates (IQ v0.34.python) References: <505.566T11T1243597threeseas@earthlink.net> <3B2A7F5E.MD-1.4.4.padf@ihug.com.nz> <3871.567T2214T9794928threeseas@earthlink.net> <87puc3ao42.fsf@pooh.honeypot> <2509.568T2823T9766233threeseas@earthlink.net> Message-ID: <87elshahyv.fsf@pooh.honeypot> At 2001-06-17T20:23:03Z, "Timothy Rue" writes: > Kirk, > No I haven't looked into Perl. The RE pattern matching functions in Python > are more than enough, more than I expected. Hey I can use white spaces in > patterns now!!!. Regular expressions in any language are certainly not for the faint of heart. The "Programming Perl" (aka "Camel") book contains some bizarrely complex expressions for matching nested parenthesis and quotes in a document. > Is Perl syntax as easy to read as python, for the beginner? If you already know C or a similar language, then yes, Perl is easy to read. Or at least, it can be when written by someone who considers "maintainability" to be an important goal. It's unfortunately easy to create Perl that is totally, utterly, completely unreadable - do a Google search for "obfuscated perl contest" and take a look at some of the winners. > Can perl be compiled into byte code for faster startup or put into a stand > alone application? Or is Perl strickly an interpreted language? Perl ships with a Perl-to-C converter that you can use to create compiled apps. Perl is also, by its nature, a bytecode compiler. When you type "perl foo.pl", foo.pl is compiled and executed at that moment. > Of course you can port IQ to Perl if you want, but in any case (perl, > python, rebol, arexx) it'd be nice to incorporate into IQ, the ability to > access files thru the internet in a way that is as simple as accessing a > file on the system you are using IQ on. Perl has massively extensive libraries of add-on functionality - check out www.cpan.org. -- Kirk Strauser From tushar at hursley.ibm.com Mon Jun 11 14:03:42 2001 From: tushar at hursley.ibm.com (Tushar Wagle) Date: Mon, 11 Jun 2001 19:03:42 +0100 Subject: CGI Empty Form problem (over https) Message-ID: <3B2507FE.8838C412@hursley.ibm.com> I'm having a problem with a cgi form in a cgi script. Running over a secure connection (https:..), my CGI script gets an empty cgi-form, ie FieldStorage(None, None, []) whereas running the same script in a non-secure environment works fine. Any ideas on what might be happening (eg is there something in the cgi module which requires special 'tweaking' to run over SSL)??... Regards, Tushar. From s713221 at student.gu.edu.au Thu Jun 14 16:47:05 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Fri, 15 Jun 2001 06:47:05 +1000 Subject: tummy compile Mandrake 7.2 References: <20010608.214013.1469262009.16325@K7.atl.mediaone.net> <20010609.104451.1884661237.1229@K7.atl.mediaone.net> <3B24154E.C70211ED@student.gu.edu.au> <20010610.232821.1789366143.1225@K7.atl.mediaone.net> <3B25F742.F4E25C37@student.gu.edu.au> <20010612.151135.165344818.1845@K7.atl.mediaone.net> <3B288E62.FC946467@student.gu.edu.au> <20010614.083914.1875335928.1071@K7.atl.mediaone.net> Message-ID: <3B2922C9.4B8B5D6E@student.gu.edu.au> > if I understand- say I do "rpm --rebuild prog.src.rpm"- it actually > installs the resulting prog.rpm that it builds? Is there a way to prevent > the final pkg install using --rebuild? Sometimes I like to examine an rpm > before installing just to see what the potential for damage is (config > files, libraries, locations, etc). I know I can go through the process > you recommend, look at the spec and configure files, and then install- > just was hoping using src.rpm would do *everything* I want *exactly* the > way I want it to :-). No, rpm --rebuild only re-builds the binary rpm. You have to install it. The install step in rpm is where the package manager actually installs to a special directory (/var/tmp/something) as if it was system root, then the files in this directory are wrapped up into a package. There's another option called --build which will build and install onto your system, but it won't create a binary rpm. > > Just passing the favour forward. And what's a.o.l.m? Another python > > newsgroup *starts salivating* > > well, since you offered a pre-built LM binary, I assumed you were using > Mandrake, no? We could really use another knowledgeable poster such as > yourself on alt.os.linux.mandrake. > > peace Yep, I'm using Mandrake. I'll have to bounce over there. Now that we seem to be talking about rpm exclusively as compared to python, this thread is probably more appropriate for that group anycase. -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From donod at home.com Fri Jun 15 03:51:39 2001 From: donod at home.com (Don O'Donnell) Date: Fri, 15 Jun 2001 07:51:39 GMT Subject: sorting values in dict References: Message-ID: <3B29B970.683D90F5@home.com> Jeroen Wolff wrote: > > I want to display a dict sorted by value. > > This is my dict: > > total={} ... Use list comprehension to reverse key:value pairs, then sort the list: vsort = [(v,k) for k,v in total.items()] vsort.sort() -Don From wart at softhome.net Tue Jun 5 06:29:41 2001 From: wart at softhome.net (Wartan Hachaturow) Date: 05 Jun 2001 14:29:41 +0400 Subject: Programming ASP with ActivePython [also a general Web question] References: <87lmn8fdmi.fsf@penguin.aktivist.ru> Message-ID: <87y9r7z0bu.fsf@penguin.aktivist.ru> >>>>> "Paul" == Paul Prescod writes: Paul> Run: Paul> pyscript.py --unregister Paul> then run Paul> pyscript.py again. Paul> If this does or doesn't work for you, please give a shout. Yeah, thanks, it worked. -- Regards, Wartan. echo "Your stdio isn't very std." -- Larry Wall in Configure from the perl distribution From wware at world.std.com Tue Jun 12 09:21:13 2001 From: wware at world.std.com (Will Ware) Date: Tue, 12 Jun 2001 13:21:13 GMT Subject: Python Shareware? References: <3B25AF24.EAC22242@my.signature> Message-ID: Greg Ewing (see at my.signature) wrote: > But then there's a chance that other people will fix the bugs and > add the new features that you would have done, so you won't get any > money. It might be safer to release it with a "use-but-don't-modify" > kind of license instead. That's a valid concern, but the shareware world already has plenty of competition. As far as I'm aware, no case of shareware "piracy" has ever come before a real court, so shareware authors are already entirely reliant on the honor system anyway. Once or twice in my less enlightened days I tried releasing a few bits of shareware myself, and if I'm typical, then shareware authors have neither the means nor the serious intention to prosecute cases of "piracy". So the notion that there is already a water-tight business model in shareware is a delusion. I suspect anybody who has written shareware for any length of time is dispelled of it. Where somebody is sufficiently new at it to believe the delusion, they will invest lots of energy looking for ways to "secure" their code. As was pointed out in earlier responses, this is really futile if "pirates" are sufficiently motivated. As long as people keep buying the delusion, they will continue to waste energy on ineffectual protection schemes, and waste their emotional energy on both the adolescent thrill of breaking those schemes and the anger and frustration of having one's scheme broken. Stop catering to the psychology of the 31337 haxor, and you're left with the people who are honestly appreciative of useful work and likely to observe the honor system. With open source code, there is always a risk that somebody else can fork your code and make faster progress with it than you will. You can try to build a brand name for yourself ala Red Hat so that marketing momentum is in your favor. If you can't make the investment necessary to do that, and you can't keep up with features and bug fixes offered by others, then it seems to me you should just acknowledge that trying to make money this way is inherently risky. -- -----------------------------------+--------------------- 22nd century: Esperanto, geodesic | Will Ware domes, hovercrafts, metric system | wware at world.std.com From jonathan at webtop.com Tue Jun 5 06:47:39 2001 From: jonathan at webtop.com (jonathan at webtop.com) Date: 05 Jun 2001 10:47:39 GMT Subject: spurious IndexError [interfacing with swig generated code] Message-ID: <3b1cb8cb$0$15024$ed9e5944@reading.news.pipex.net> Hi We've been using swig to generate a python binding to a company C++ class library. I've spotted a bug/problem which occurs in the following code : [call to unrelated SWIG generated constructor] w ="article"; v ="articl"; print w==v; # fails here with a spurious IndexError (list index out of range) Has anyone seen a similar problem before, or know a fix? Jon From bbollenbach at homenospam.com Tue Jun 12 20:30:02 2001 From: bbollenbach at homenospam.com (Brad Bollenbach) Date: Wed, 13 Jun 2001 00:30:02 GMT Subject: Integrating a Python GUI into a PowerBuilder App References: <49624b0b.0106121135.61b6bd6c@posting.google.com> Message-ID: I work as a full-time Powerbuilder developer, and wish for pretty much *any* other development tool than it to do my work (even if the language was excellent, Powerbuilder's IDE is /nasty/. But as it turns out Powerbuilder's language -- Powerscript -- is even worse anyways :). The problem I can see though is coming up for an alternative to datawindow controls/objects. Unfortunately, I don't have any experience in what you're trying to do, but am more hoping to gain some insight from anyone else's replies to this thread. "John Urberg" wrote in message news:49624b0b.0106121135.61b6bd6c at posting.google.com... > Hi all, > > We are looking into languages to replace PowerBuilder in our shop. > The kicker is that we need to slowly migrate to the new language so > the choice would have to be able to integrate into a PowerBuilder MDI > application. I'd really like to push Python as the new language, but > I need to find a way to seemlessly integrate a Python GUI into the > PowerBuilder app (i.e. as child windows of the MDI). I would expect > we would want to use wxPython being as that is the closest to standard > Windows look and feel. > > Any ideas on how I can accomplish this? > > Thanks in advance, > John Urberg From mlh at idi.ntnu.no Mon Jun 18 15:47:58 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Mon, 18 Jun 2001 21:47:58 +0200 Subject: qt or gtk? References: <3B2B609B.285DCB06@web.de> <9gi652$n7p$05$1@news.t-online.com> <9gisq0$nif$1@tyfon.itea.ntnu.no> Message-ID: <9gllte$33s$1@tyfon.itea.ntnu.no> wrote in message news:ubsnm17mj.fsf at cs.uu.nl... > >>>>> "Magnus Lie Hetland" (MLH) writes: > > MLH> "Even" may not be the right word here... To those of the Open Source > MLH> bent, the FSF's definition is quite restrictive... You aren't free to > MLH> do what you want with GPL software ... :) > > That's because the GPL isn't meant to make YOU free, but to make the > SOFTWARE free. Sure - the GPL is very nice. My point was that to say that "Even the FSF considers this a free license" connotes that then everyone will, as if they were the most restrictive in their use of the word "free". This is of course not true - they merely have a different definition from certain other groups. > -- > Piet van Oostrum > URL: http://www.cs.uu.nl/~piet [PGP] > Private email: P.van.Oostrum at hccnet.nl -- Magnus Lie Hetland http://www.hetland.org "Reality is that which, when you stop believing in it, doesn't go away." -- Philip K. Dick From JamesL at Lugoj.Com Wed Jun 27 14:30:17 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Wed, 27 Jun 2001 11:30:17 -0700 Subject: PEP 260: simplify xrange() References: <3B398BBE.A2D455C9@darwin.in-berlin.de> <9hclc1$qv5$1@panix2.panix.com> <3B3A08B5.3C142546@darwin.in-berlin.de> <3B3A1DC0.3583E9D8@ccvcorp.com> Message-ID: <3B3A2639.69BA1DCE@Lugoj.Com> Jeff Shannon wrote: > To make a long story short, the discussion regarding FP boils down to the > fact that "1.0" cannot be exactly represented in FP. Every time you increment > your "frange", you are introducing nasty rounding errors, and by the time > you've > done several thousand iterations, they're going to be very significant > rounding > errors. Perhaps you mean 0.1 can't be represented exactly using standard internal representations? Because 1.0 can and is represented exactly (unless the string to float algorithm is seriously brain-dead). See: >>> a = 1.0 >>> b = a + a + a >>> if b == 3.0: ... print "aha!" ... aha! As long as the integers don't get too large and you aren't dealing with division that results in fractions does the issue get muddled. But if you are stepping by 0.1, yes you will have some issues when trying to do exact comparisons. From rod_weston at yahoo.com Wed Jun 6 13:42:48 2001 From: rod_weston at yahoo.com (Rod Weston) Date: 6 Jun 2001 10:42:48 -0700 Subject: Learning OOP... Message-ID: Trying to decide which language to learn first. I have programming experience in PICKBASIC and now want to learn OOP.At this point, I am leaning toward learning Ada and then Python. Any ideas on why I should or should not use these languages in this sequence? From sholden at holdenweb.com Thu Jun 14 02:27:01 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 14 Jun 2001 02:27:01 -0400 Subject: HREF to same server, different port Message-ID: Sorry this is off-topic, but I'm trying to create a relative url to a different port on the same server (inheriting the server name or address from the current URL). I've tried //:8081/ and :8081/ and neither works. ANyone tell me how? regards Steve -- http://www.holdenweb.com/ From tundra at tundraware.com Mon Jun 25 14:54:02 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 25 Jun 2001 18:54:02 GMT Subject: Is this a true statement? References: <8NuZ6.362378$oc7.42924874@news2.rdc2.tx.home.com> Message-ID: <3B3788A2.3BD1D672@tundraware.com> Rainer Deyke wrote: > > "Steven D. Majewski" wrote in message > news:mailman.993411997.2625.python-list at python.org... > > I don't retract the statement that the fact that you can compute > > any computable function in any Turing complete does not mean that > > you can *DO* the same thing in any language. > > I agree here. > > To a program, "doing something" means "interacting with the outer world". > It is a given that, if a program can receive the proper input from the > world, it can calculate (but not necessarily perform) the proper output. > Python includes many ways of interacting with the outer world in its > standard library, but C++ usually includes more. Python can sometimes get > around this by outputting machine code, but only if the problem is defined > in a way that allows this. > > To a programmer, however, "doing something" generally means structuring code > in a certain way. Programming is about putting all information in only one > place. Variables are one tool for doing this: > > > > From this perspective, there are a couple of areas where C++ is more > powerful, but they are eclipsed by the many areas where Python is more > powerful. > > [Diving back in at great personal risk...] I still do not understand/agree with this line of reasoning entirely. As I mentioned in a previous post, one has to define what we mean by "do" or "program". It is a fundamental truth of Computer Science that all Turing-Complete languages have *exactly* the same computational abilities - i.e., They all handle the exact same set of algorithms - in particular, those algorithms which are Turing Computable (which excludes things like the Halting Problem). This *includes* all "interactions with the outside world" because such interaction is, by definition, algorithmic. (Fine Point: There is a debatable point here about whether adaptive algorithms like those found in Genetic Programming are really formally "algorithms" at all because they do not behave consistently when faced with he same input conditions, but that's way outside the scope of this discussion.) Now, if we say "Language X can "do" things we cannot "do" in Language Y" we are saying one of several possible things: 1) Language X embraces problems greater than just the Turing-Complete set (Impossible - If anyone disagrees, please send me your solution to the Halting Problem and we'll both be famous ;))) 2) Language Y is not Turing-Complete (possible, but not in the class of languages under discussion in this thread). 3) There is something about how X and Y are *implemented* which causes this disparity (almost certainly the case). Most likely, Y is implemented in a way which restricts its use somehow. Note that the *language* itself is not restricted - it still accepts the entire set of Turing-Complete problems - its just crippled *in practice* because of its implementation. It's like putting a 400hp Porsche engine on a motorcyle frame - the limitation is not the engine, but rather the *context* in which the engine is expected to operate. (Now watch, someone will chime in that they have a 911 Turbo powerplant mounted on their BMW R100 frame ;) N.B. These "limitations" are most usually *intentional* on the language or systems designer's part to promote better coding style, create a more effective working paradigm, or preserve overall system security and sanity. "Limitations" in this context are a *good* thing. For instance, we don't let the arbitary programmer on a Unix system read and write kernel memory in their C programs *even though the language can do it because we want a sane and stable OS runtime environment. Now, back to the debate at hand. We've all agreed that some things are easier to do in C++ (yuck) than Python. Let's take the example of writing device drivers. Using today's language and syntax to handle interrupts in Python, you realistically have only a few choices: 1) Write a library in another language that implements interrupt handling and then give it a Python interface. 2) Have Python write out a set of machine code bits which are understood by the underlying implementation and hardware to be the correct handling of an interrupt. 3) Add a native interrupt object to the language. 1) clearly takes us out of "pure Python" and is thus of no further interest (unless you actually want to *solve* this problem in the real world, in which case this is probably the best solution ;))) 2) Works just fine, but is kind of clumsy and unnatural to use. Note, however, that it is 2) that gives us the ability to do *anything* in Python which we can "do" in any other Turing-Complete language. 3) is where the rocks start to get thrown. If I do 3), have I "extended" the language to do something it could not previously? NO! I have implemented what I could already do with 2) in a more programmer-friendly manner, but I have not changed the net computational power of the language. So, I close with this claim (which I believe is well supported by the theory): Define "Computational Power" to be the number of algorithms a given language can compute. Then: Increasing "Computational Power" for a given language is only possible if that language is less than Turing-Complete. In every other case, all we are doing is changing the *programmer's* perception and paradigm of work, not the net "Computational Power" of the language. ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From feedback at netlcr.de Thu Jun 14 15:54:07 2001 From: feedback at netlcr.de (Florian Scholz) Date: Thu, 14 Jun 2001 21:54:07 +0200 Subject: bsddb: must bsddb write a file ? References: <3B28D465.229D7BF7@netlcr.de> Message-ID: <3B29165E.102550FD@netlcr.de> > Florian> hi again.. > Florian> the bsddb: class (binary tree, hash-table,..) > Florian> needs to write its data to a file: > Florian> db = bsddb.btopen('filename','c'); > > Florian> the file can be removed, but is there a way to avoid the file ? > > Well, you could just use a dictionary instead. If you don't want your > key/value pairs saved to a file, why use bsddb? bsddb used as a binary- tree has a .last()-methode to get the element with the biggest key. there is no such funktion in the build in hash-table. that was the reason switching to bsddb From eduard.hiti at t-online.de Sat Jun 30 07:11:25 2001 From: eduard.hiti at t-online.de (Eduard Hiti) Date: Sat, 30 Jun 2001 13:11:25 +0200 Subject: [Python-iterators] While we're at it... References: Message-ID: <9hkckn$lsr$00$1@news.t-online.com> | | Anything else come to mind? The core language coverage is pretty broad | already, so lots of stuff in the .py libraries should "just work by magic" | with any iterable argument. OTOH, we all have blind spots, and, e.g., I | never would have thought of the "right-hand side of a multiple-target | assignment stmt" context on my own. | Could iterators be made slicable? Then a 'fib()[3:6]' would give you the third to fifth fibonacci numbers. From gened at linuxenvy.com Sat Jun 2 00:09:23 2001 From: gened at linuxenvy.com (Gene D) Date: Fri, 1 Jun 2001 21:09:23 -0700 Subject: Control M string termination with Python 1.2 1nd Win2000 Message-ID: <991454923.88308@yabetcha.drizzle.com> I installed Python 2.1 and emacs on Windows 2000 a week ago and started to learn python. Several days ago I loaded cygwin and noticed that the path was changed to a cygwin version of Python. I fixed the path and checked to make sure that emacs was running the right version. Now when I print text it ends with a ^M and I have no idea how to get rid of the problem. Any help on this problem would be greatly appreciated. From pfortin at pfortin.com Thu Jun 21 00:04:06 2001 From: pfortin at pfortin.com (Pierre Fortin) Date: Thu, 21 Jun 2001 00:04:06 -0400 Subject: Was this import behaviour planned...? References: <3B314800.EA4F0A7E@pfortin.com> <90C6E55D7gmcmhypernetcom@199.171.54.154> Message-ID: <3B317236.795FADE0@pfortin.com> Gordon McMillan wrote: > > Pierre Fortin wrote: > > >The core question: if "import foo.bar.baz" really means > >"foo/bar/baz...", shouldn't import ignore any files such as ./foo.py, > >foo/bar.py, etc....? > > But it doesn't. It means "find something in foo named bar, then find > something in that named baz". foo/bar/baz.py is just one implementation, > and it requires foo/__init__.py and foo/bar/__init__.py. But foo.bar could > be a module, and baz an object in foo.bar, or even worse. Bummer.... this is not quite it either 'cuz Python prefers foo.py even if bar.baz does not exist therein, ignoring the valid stuff in foo/bar/baz... Guess we'll need to ensure there is no .py next to ...//... Thanks, Pierre > Or maybe they're modules, but not in your filesystem. > > Planned? No way. Packages were introduced after someone hacked them up with > a module name "ni" and lots of people started using it 'cause one flat > namespace was just too restrictive. > > - Gordon From tim.one at home.com Fri Jun 15 02:28:54 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 15 Jun 2001 02:28:54 -0400 Subject: Python 2.0.1c1 - GPL-compatible release candidate In-Reply-To: Message-ID: [Will Ware] > ... > Just to make sure I understand the way GPL coverage extends to derived > works, here is what I think is true. > ... Python is not licensed under the GPL, so most of your questions don't really make sense: the GPL doesn't apply to any of your Python derivatives, unless you *choose* to put such derivatives under the GPL, or have to put them under the GPL because of other components in your derivative that are under the GPL. Then you should read the GPL's fine print for all of its rules. The FSF agreed that the 2.0.1 license is GPL *compatible*. That doesn't mean the 2.0.1 license *is* the GPL; and it is not. It's best to go straight to the source for an explanation: http://www.fsf.org/philosophy/license-list.html From wjdandreta at worldnet.att.net Tue Jun 12 14:20:07 2001 From: wjdandreta at worldnet.att.net (William Dandreta) Date: Tue, 12 Jun 2001 18:20:07 GMT Subject: File open problem? References: Message-ID: Hi Remco, >Wild guess: did you do "from os import *" ? > >The os module contains its own, different open() function. > Thanks that was the problem. BTW, it was no wild guess, it was an educated guess. Bill From msoulier at storm.ca Fri Jun 8 23:25:41 2001 From: msoulier at storm.ca (Michael P. Soulier) Date: Sat, 09 Jun 2001 03:25:41 GMT Subject: Interesting speed benchmark References: <3B1D6FED.4070506@nospam.yahoo.com> <3B1EC430.9020201@nospam.yahoo.com> Message-ID: On Thu, 07 Jun 2001 03:29:47 GMT, Rainer Deyke wrote: > > Basically that you have to do manual resource management for non-memory > resources. > > The following function leaks a file handle under Jython but works correctly > under CPython: > > def print_file(fname): > file = open(fname) > print file.read() But it's not a permanent leak, no? It leaks temporarily, but then the derefereced file objects should be deleted when the GC finally fires up. Mike -- Michael P. Soulier "With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead." -- RFC 1925 From xyzmats at laplaza.org Wed Jun 20 10:58:18 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Wed, 20 Jun 2001 14:58:18 GMT Subject: Solaris 8/x86: Build problems References: <3b2a7fc2.5552674@news.laplaza.org> <3b2c215f.791227@news.laplaza.org> Message-ID: <3b30b96e.641352@news.laplaza.org> On 17 Jun 2001 13:29:34 +0200, Martin von Loewis wrote: >xyzmats at laplaza.org (Mats Wichmann) writes: > >> I'll go back and extricate that soon. Up until you get to distutils, >> all the compile steps spit out for easy capture, but once you get the >> the module building phase, it not longer automatically tells you what >> each step is doing. > >It sure does. To re-run all compilation steps, you have to either make >clean, or remove the "build" directory tree. distutils will then >report any compiler invocation it issues. And so it does. And when I redid it this way to see what was wrong, nothing was wrong any longer, everything built okay. I do know what the difference was: the earlier time through, the build was done with an environment variable "CC=gcc", the second time, where it worked, that was not set. Curious (but no more than that, since I now have a working Python 2.1) why that makes a difference? I had the "CC=gcc" set while I was doing "configure" on a whole bunch of packages, Python happened to be just one of them. Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From frank at chagford.com Sun Jun 3 09:29:01 2001 From: frank at chagford.com (Frank Millman) Date: Sun, 3 Jun 2001 15:29:01 +0200 Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> Message-ID: <991574786.733151@nntp01.uskonet.com> > >Does anyone have any knowledge or experience of UML that they would like to >share? > I realise belatedly that, as this question has got nothing to do with Python, it should not have been posted to this group. My apologies. Having said that, can anyone suggest an appropriate news group for this kind of question. Frank From bos at hack.org Wed Jun 6 00:42:05 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Wed, 06 Jun 2001 06:42:05 +0200 Subject: Help a newbie pls! References: Message-ID: <3B1DB49D.655730E@hack.org> "David A." wrote: > > Hi to all, > > I am a newbie to python and I was writing a very simple script taht takes > the content of one file and then re-writes it in the H4x0r style (i know, I > know, it's completly stupid and useless, and, no I am no of them, it is just > a toy program...) http://bos.hack.org/hacks/elite.py might help. -- Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From pbrian at demon.net Fri Jun 1 12:02:34 2001 From: pbrian at demon.net (Paul Brian) Date: Fri, 1 Jun 2001 17:02:34 +0100 Subject: screenscraping Message-ID: <991411356.20275.0.nnrp-10.c1c3e154@news.demon.co.uk> all, I may be scraping the bottom of the barrel as well a screen, but I would like to know if it is possible to (using python) activate a windows application that takes input from a GUI, and enter in data through the GUI programmatically. For example, bring up the address page, "tab" over to Surname and enter in "foo" I am prevented from using any kind of API or direct interface to real work. Thank you P Brian From gmcm at hypernet.com Sat Jun 30 09:17:23 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 30 Jun 2001 13:17:23 GMT Subject: Python for air traffic control? References: Message-ID: <90D055403gmcmhypernetcom@199.171.54.154> Russ wrote: >I am thinking about using Python for a unique safety-critical >application in air traffic control. [snip] >(The trajectory and tracking data will come from existing >C/C++ programs.) The software must be as simple, clean, and robust as >humanly possible. The default languages here are C/C++, but I am >toying with the idea of using Python instead. However, I am a bit >nervous about the lack of type checking and function prototyping, >among other issues. Is Python up to this task? The set of all type errors caught by the compiler is a strict subset of the set of all type errors (it's easy to fool C/C++'s type system, intentionally or not) is a strict subset of the set of all semantic type errors (oops, was that miles? I wanted kilometers...). Go for it (just be careful). - Gordon From jwolff at knoware.nl Thu Jun 14 01:14:07 2001 From: jwolff at knoware.nl (Jeroen Wolff) Date: Thu, 14 Jun 2001 07:14:07 +0200 Subject: IP address to binary conversion References: <3B27FE3A.D7F9879E@hack.org> <3B27FECA.FD9A7A74@hack.org> Message-ID: <4shgit0hg1t6rc38lp3ba7u0vaj81l3vrv@4ax.com> On Thu, 14 Jun 2001 02:01:14 +0200, Rikard Bosnjakovic wrote: >Here's a solution for the reverse: > >>>> socket.inet_ntoa(struct.pack("!I", long(1074015239))) >'64.4.44.7' Thanks for the solution! But when i try: interpret_addr("195.7.145.2") --> -1022914302 the result is an signed long. So the way back is not good.... Is there a way to make it unsigned? ( a 32 bits unsigned value needed) Jeroen From Sir-XaoS at gmx.net Wed Jun 27 08:33:38 2001 From: Sir-XaoS at gmx.net (C. Koehler) Date: Wed, 27 Jun 2001 14:33:38 +0200 Subject: repost: ?automatic user authentification? Message-ID: <3B39D2A2.2B4D6F1F@gmx.net> hi again, could somebody please help me with this question?- How do I use already existing accounts for a session with python, actually Zope? e.g. something like a unix account; I only need this usermanagement behind a Firewall and the user authentification will only be used for distiguishing between the users. The [password] security is only pro forma. I just need something to bind in a website which distinguishes the users by itself, not by interacting with the user again. I know that in PHP exist some functions which can deal with unix accounts, etc.- So: how do I handle them in Python? a better documentation, like found on www.python.org, would help me, too. thanks already, Christian From charlie at charliedyson.net Sun Jun 17 13:34:48 2001 From: charlie at charliedyson.net (Charlie Dyson) Date: Sun, 17 Jun 2001 17:34:48 +0000 Subject: Global Namespace Message-ID: <9gim6l$2in$1@s1.uklinux.net> This question either has a simple answer, or there is no way to do this at the moment. I want to be able to set a variable in the global namespace to a given value. Easy? What if all you have is a string containing the name of the variable. I need a pointer to the global namespace. So class MyClass: def mymethod(self, varname, varvalue): setattr(pointer_to_global_namespace, varname, varvalue) m = MyClass() m.mymethod('var', 'ASDF') print var # Should print 'ASDF' Any ideas? Is there a __builtins__ funtion that provides a reference/pointer/whatever you call it to the global namespace. Thanks in advance, Charlie Dyson - charlie at charliedyson.net From me at mikerobin.com Tue Jun 19 03:25:39 2001 From: me at mikerobin.com (Michael Robin) Date: 19 Jun 2001 00:25:39 -0700 Subject: VI References: <9g9f1v$7oqr5$1@ID-11957.news.dfncis.de> <9gaul7$mth$2@brokaw.wa.com> Message-ID: <52e5ab5f.0106182325.4d1fe0d0@posting.google.com> I just downloaded vim - wow! (I'm going to catch up on vim in the c.l.p archives and see what she can do python-wise. Don't suppose there's a VI mode for Scite, PythonWin or Komodo??) It's like riding a bike! I'd forgotten how much sense a "modefull" editor made, and how fast you can edit by keeping your hands where they belong. I always thought a pointing device was great to draw pretty pictures with - how did it get thrust upon us to perform every possible function? Certainly a keystroke or two is more preferable than "navigating" to a toolbar hieroglyphic that needs to be looked up anyway? (If not WIMPS, what would have prevailed??) It must be late... ZZ (works the same as :wq when you're tired...) mike Jonathan Gardner wrote in message news:<9gaul7$mth$2 at brokaw.wa.com>... > Emile van Sebille wrote: > > I always liked the description that vi has two modes: one beeps at you, > > and the other destroys your file. ;-) > > When I was first learning vi, I found the beeps quite common. What was even > more mystical is the way it would mangle your text with ease. A great way > to learn how to use vi is to go to normal mode, and type a random letter. > That's how I learned about and . Cool feature. > > > Actually, I use it daily. I'd just prefer something (oh, ok, _anything_) > > else. > > I am addicted to vi. I can't imagine editing text any other way. If only I > could get those little textboxes in web forms to use vi instead of basic > textedit stuff... oh well. From whisper at oz.nospamnet Thu Jun 7 00:49:38 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 7 Jun 2001 04:49:38 GMT Subject: Running mod_python on NT References: <1a18c6fa.0106060811.5f09477f@posting.google.com> <2YxT6.948$Q8.31005@juliett.dax.net> Message-ID: <9fn152$9d3$1@216.39.170.247> In article <2YxT6.948$Q8.31005 at juliett.dax.net>, thomas at cintra.no says... > I've recently finished a project using these tools, allthough with a never > version of Apache. > When I had the same problem it was because I hadn't copied the contents of > the lib-folder > in mod_python-2.7.x into pythons lib-folder.The install-instructions for > mod_python is pretty > simple, but it doesn't work with ActivePython 2.1 yet. > > Hope this helps- > > thomas > > > > "Peter Nye" wrote in message > news:1a18c6fa.0106060811.5f09477f at posting.google.com... > > Has anyone been able to overcome the error message: > > python_handler: make_obcallback returned no obCallBack! > > and successfully run mod_python on NT. I have read all kinds of > > postings of people having this problem but have not found any answers. > > > > Thank you for any help you can give. > > > > Running NT 4.0 > > Apache 1.3.14 > > Python 2.0 > > mod_python 2.7.2 > > > > Peter Nye > > > I've used mod_python with Apache 1.3.19 and Python 2.1 on NT although, not much. It does work as far as i've played with it. Dave LeBlanc From aaronf at nospam.telusplanet.net Tue Jun 5 23:45:53 2001 From: aaronf at nospam.telusplanet.net (Aaron Fransen) Date: Wed, 06 Jun 2001 03:45:53 GMT Subject: Running an AS/400 CL program via ODBC References: <285T6.2595$Jg4.368004@news1.telusplanet.net> Message-ID: Further, I kinda got it working...but without parameters. If I embed the values of the various strings in the actual CALL, it works; this is a pain in the butt, but it'll do the trick to a point. The other problem is where the callproc procedure would really be handy, which isn't implemented in the Win32 stuff from ActiveState. I actually need to (a) call a program, (b) give it parameters, and be able to (c) read back two of the parameters, which the AS/400 program would have modified. Thoughts? "Aaron Fransen" wrote in message news:285T6.2595$Jg4.368004 at news1.telusplanet.net... > The user ID is authorized for the various objects on the AS/400, but > interestingly I get a "Syntax Error" when using the LIB/PGM nomenclature. > > And most surprisingly, there are NO entries in the joblog on the AS/400! In > fact event the QZDASOINIT job only shows that it's servicing a request, but > not the details of the request. Obviously I've got some logging option > turned off so maybe I'll check into that in the meantime. > > I suspect it has to do with the cursor type, perhaps? I remember having a > buggar of a time figuring it out in VB; actually running a program seemed to > be so dramatically different in terms of VB's required syntax than simply > running an SQL query that it makes me think that there's something more > complicated I have to do in Python. > > "Simon Brunning" wrote in message > news:mailman.991730178.25094.python-list at python.org... > > > From: Aaron Fransen [SMTP:aaronf at nospam.telusplanet.net] > > > I have a problem executing an AS/400 CL program from the SQL/ODBC > > > interface > > > in Python. I know the interface on the AS/400 works because I actually > > > wrote > > > the code to do it originally in VB, which has been live on our web site > > > for > > > months. I'm getting sick of the Really Big Visual Basic Corporation > > > though, > > > and am in the process of converting the site to Python, which seemed to > me > > > to be about the best/easiest/really cool tools out there. > > > > > > I can run any SQL query via the ODBC 2 interface (Python 2.1) using the > > > following code: > > > > > > dbc=odbc.odbc("datasourcename/as400username/password") > > > cursor=dbc.cursor() > > > cursor.execute("Select * from MYTABLE") > > > result=cursor.fetchall() > > > > > > Works perfectly. However, if I try something like this: > > > > > > cursor.execute("{{Call > > > LIB.PROGNAME(?,?,?,?,?,?)}}",['PARM1','TWO','THREE','1','','']) > > > > > > it bakes with "SQL0204 - PROGNAME in LIB type *N not found. in EXEC". > > > > > > Thoughts? > > > > Is the user ID that you are using authorised to the program? > > > > Are there any exit programs on your system which could be blocking access? > > > > Have you tried the LIB/PGM naming convention? > > > > Anything else in the job log? > > > > Cheers, > > Simon Brunning > > TriSystems Ltd. > > sbrunning at trisystems.co.uk > > > > > > > > > > ----------------------------------------------------------------------- > > The information in this email is confidential and may be legally > privileged. > > It is intended solely for the addressee. Access to this email by anyone > else > > is unauthorised. If you are not the intended recipient, any disclosure, > > copying, distribution, or any action taken or omitted to be taken in > > reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot > > accept liability for statements made which are clearly the senders own. > > > > From rnd at onego.ru Sat Jun 23 04:18:49 2001 From: rnd at onego.ru (Roman Suzi) Date: Sat, 23 Jun 2001 12:18:49 +0400 (MSD) Subject: the indentaion for grouping thing In-Reply-To: <3b33d9d6$1_1@anonymous> Message-ID: On Fri, 22 Jun 2001, Anonymous wrote: >Someone quoted Guido as saying (I'm paraphrasing) that he >is determined to be ignorant of any discussion regarding the white >space for grouping thing. How sad. How crusty. How typical. Whydoyouneedtogroupanddelimitthingsbythosefunny;delimiters;(andbraces)?;Iamsure,thatyouwantwriteprograms,whichlooklikethissentence. But we do not want to read your programs! >Anyway, I will continue to use Python I guess, but I gather that someone >has written a preprocessor that allows you to use delimiters with python. >Is this true? If so, where can I find it, I would like to use it. You can write your own easily. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Saturday, June 23, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "He's not dead, Jim, he's just metabolically challenged." _/ From dam at parasoft.com Wed Jun 13 18:48:24 2001 From: dam at parasoft.com (David McCaw) Date: 13 Jun 2001 15:48:24 -0700 Subject: memory profiling References: Message-ID: <2d3244d.0106131448.29425caa@posting.google.com> We at ParaSoft have a tool called Insure++ that is able to track memory problems in C and C++. In fact, PPython Labs uses Insure++ to find bugs on the Linux platform. If you'd like to try it out, feel free to email me. For more info, you can go to http://www.parasoft.com David McCaw dam at parasoft.com matthew.russell at securetrading.com (Matt Russell) wrote in message news:... > I am aslo interested in finding a way to track memory leaks in python > programs. > Does one have to have the module resource.c compiled into the > interpreter B 4 using something such as memprof_c or are their other > tools availble for tracking memory leaks? > > TIA > Matt > > > Geoffrey Gerrietts wrote in message news:... > > I'm sure this question has been asked and answered a few times now, but I > > can't seem to find an answer for it, either in the FAQ or in the newsgroup > > archives. > > > > How do people do memory profiling in python? I'd like to compare, for > > instance, the memory consumed by a dictionary-based approach versus a list > > or tuple based approach. I've seen the tool in mxTools, sizeof, which is > > nice, but that doesn't seem to address the big "random" factor, the empty > > pointers in the dictionary. > > > > Does a tool exist that will let me measure this in some reasonably > > straightforward way? Are other people doing any kind of memory profiling, or > > do folks just "eyeball it"? Am I missing something blatantly and plainly > > obvious that I should be embarassed for not seeing? > > > > Thanks in advance, > > --G. > > > > --- > > Geoff Gerrietts > > Software Engineer, HomeGain.com > > 510-655-0800 x4320 From emile at fenx.com Sun Jun 10 17:14:02 2001 From: emile at fenx.com (Emile van Sebille) Date: Sun, 10 Jun 2001 14:14:02 -0700 Subject: Catching Errors References: <3B20E042.DA0AF3C1@usa.net> <9fqpii$5mk9n$1@ID-11957.news.dfncis.de> <9g0idm01lap@enews1.newsguy.com> Message-ID: <9g0o5i$6gp21$1@ID-11957.news.dfncis.de> You're right, I didn't test using win9x. It does work on win2k, which is on most of the systems I use regularly. It also works on winnt, although I only tried: C:\>python 2>errors.txt on a system I don't have python installed on. (WinNT Terminal Server). The different handling of arguments on win9x and the winnt families is certainly unexpected. -- Emile van Sebille emile at fenx.com --------- "Alex Martelli" wrote in message news:9g0idm01lap at enews1.newsguy.com... > "Emile van Sebille" wrote in message > news:9fqpii$5mk9n$1 at ID-11957.news.dfncis.de... > > If you want to capture error output to a file, you can also try: > > > > c:\> python errors-catch.py 2>errors.txt > > That doesn't help on Windows/98 (nor on NT, I think), as would > seem to be suggested from the 'c:\>' prompt...: > > D:\py21>python -c "import sys;print>>sys.stderr,sys.argv" 2>oo.txt > ['-c', '2'] > > D:\py21>dir oo.txt > > Volume in drive D is DISCO D > Volume Serial Number is 4140-11E0 > Directory of D:\py21 > > OO TXT 0 06-10-01 9:32p oo.txt > 1 file(s) 0 bytes > 0 dir(s) 354,697,216 bytes free > > > The '2' becomes a program-argument and the redirection is of > standard-output anyway. > > > Alex > > > From brian at sweetapp.com Sat Jun 23 15:43:58 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Sat, 23 Jun 2001 12:43:58 -0700 Subject: Writing new codecs In-Reply-To: Message-ID: <000001c0fc1c$e0c33ff0$445d4540@D1XYVL01> I just finished writing a UTF-7 codec for inclusion in unicodeobject.c. However, it would be nice to expose some features not available as part of the regular encoding interface. Namely, I would like to allow the caller to specify whether the encoder should escape whitespace and other characters likely to cause problems when transmitted over e-mail gateways (Set O as described in RFC2152). Would using keyword arguments be acceptable? e.g. 'Test\n\r'.encode( 'utf-7', 'strict', encodewhitespace=1, encodeseto=0) AFAIK, the only change I would have to make is in my utf7_encode function in _codecsmodule.c. Cheers, Brian From meowbot at meowing.net Fri Jun 1 22:56:53 2001 From: meowbot at meowing.net (Generic Meowbot) Date: 01 Jun 2001 22:56:53 -0400 Subject: Writing an end of string character in Python References: Message-ID: <87vgmf37yi.fsf@litterbox.meowing.net> Charlie Clark wrote: > I have a slight bug with the python module for writing attributes in > BeOS. String values need to be terminated with a "\O" in order for them > to be correctly read by some applications but I read in PP2E that "\0" > does not terminate the string in Python. Is there anyway I can force it > to? The data in a string object is padded with a NUL, though Python itself doesn't use it. PyString_AsString() is even documented to work this way, so if you're not getting that, something is Very Wrong somewhere. One gotcha is that Python also allows NUL to appear within a string, so you should ask the Python API what it thinks not rely on strlen() and the like to return a correct value. From root at rainerdeyke.com Fri Jun 15 13:07:26 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 15 Jun 2001 17:07:26 GMT Subject: str smarter than round? References: <25b2e0d9.0106150811.11efdd73@posting.google.com> Message-ID: "gods1child" wrote in message news:25b2e0d9.0106150811.11efdd73 at posting.google.com... > What does str() know that round() doesnt in the following lines? > > >>> a = 1.69 > >>> round(a,2) > 1.6899999999999999 > >>> round(a,1) > 1.7 > >>> str(a) > '1.69' > >>> > > How does str manage to get the accurate representation of floating > points? I am using Windows 2000, Python 2.0 'str' is lying to you. The result of 'round' is displayed with 'repr', which is more or less telling the truth. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From chris.gonnerman at newcenturycomputers.net Sun Jun 24 00:11:04 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Sat, 23 Jun 2001 23:11:04 -0500 Subject: adding instance methods after instantiation References: <3B34C28A.23673.1E1CC8@localhost> Message-ID: <009001c0fc63$b41dfd40$0101010a@local> ----- Original Message ----- From: "Bill Bell" > "Chris Gonnerman" > wrote, in part: > > From: "Skip Montanaro" > > > Lee> Is there some way to make m2 an instance method so that it > > > will Lee> automatically get passed c1 as its first argument? > > > > > > Check out the instancemethod function of the new module. > > > > Here is code based on Lee's sample: > > > > ###################################################### > > ### adding an instance method after the fact > > import new > > > > class c: > > def __init__(self): > > self.a1 = 1 > > def m1(self): > > self.a2 = 2 > > > > def m2(self): #note, outside of class c definition > > self.a3 = 3 > > > > c1 = c() > > c1.m2 = new.instancemethod(m2, c1, c) > > > > c1.m2() > > print c1.a3 > > Although 'a3' may appear to act as a method of instance 'c1' > unfortunately not all of the properties of 'c1' are available within 'm2'. Incorrect. c1's current properties are ENTIRELY accessible within c1.m2()... see below for an explanation. > For instance, if the definition of 'm2' is replaced with > > def m2(self): > self.a3 = 3 * self.a2 > > the Python interpreter complains that, "AttributeError: c instance > has no attribute 'a2'". Of COURSE it does. c1.a2 is NOT ASSIGNED until c1.m1() is called. This code works fine: ###################################################### ### adding an instance method after the fact import new class c: def __init__(self): self.a1 = 1 def m1(self): self.a2 = 2 def m2(self): #note, outside of class c definition self.a3 = 3 * self.a2 c1 = c() c1.m2 = new.instancemethod(m2, c1, c) ### THIS gets the c1.a2 attribute set. Remove it, and the next call fails. c1.m1() c1.m2() print c1.a3 From altis at semi-retired.com Tue Jun 19 23:19:53 2001 From: altis at semi-retired.com (Kevin Altis) Date: Tue, 19 Jun 2001 20:19:53 -0700 Subject: ANN: PythonCard mailing list Message-ID: http://groups.yahoo.com/group/pythoncard I just created this group so we can take the discussion out of comp.lang.python. Feel free to start posting. ka From johnroth at ameritech.net Sun Jun 10 18:18:18 2001 From: johnroth at ameritech.net (John Roth) Date: Sun, 10 Jun 2001 15:18:18 -0700 Subject: Python Imaging Library on Win32 References: <3B23C9FA.D527D9D3@arca.net> Message-ID: "Maurizio Manetti" wrote in message news:3B23C9FA.D527D9D3 at arca.net... > HI, I am learning to code with Python both on platform Linux and > Windows. > I've got some problem with PIL on Windows. > > When I type "import Image" it works. > But for every not dull operation I try to do with that module I get the > following error: > > ImportError: The _imaging C module is not installed > > > Where I have to put libraries? > And which is the _imaging C module? > Is it the _imaging.dll file? > Are there some other file I have to install on my system? My system shows "_imaging.pyd" and "_imagingtk.pyd", both in c:\python21\bin. The ".pyd" suffix is pythonese for ".dll". If they aren't in that library, either you need to put them there, or you need to put them somewhere that Python will find them. Since they've got the same change date, I assume you need both of them. John Roth > > Thank you. > > Maurizio Manetti From rarice at core.com Fri Jun 1 15:13:57 2001 From: rarice at core.com (Ralph Allan Rice) Date: Fri, 01 Jun 2001 15:13:57 -0400 Subject: HELP: Weird attribute behavior... Message-ID: <3B17E975.F11AB911@core.com> I am developing a class that stores device reading information. It looks like this: import string import dbi, odbc class Reading: __data = { } def __init__(self, type, id, timezone, datestamp, value): self.__data['id'] = id self.__data['timezone'] = timezone self.__data['datestamp'] =datestamp self.__data['value'] = value self.__data['type']= type def __getattr__(self, name): if name in self.__data.keys(): return self.__data[name] else: raise AttributeError, name def __repr__(self): return "%s : %s" % (self.__data['datestamp'], self.__data['value']) Now, there is a method in another class that creates instances of Reading based on the number of records in a database... (from Class User) def getReadings(): s = None cur = None result = [ ] try: s = odbc.odbc("mydatabase/user/pwd") sql = """ set rowcount 100 select rec_id, timezone,date_time, data from readings where user_id = %d and rec_type = 'G' order by date_time desc""" % self.__user['id'] cur = s.cursor() cur.execute(sql) while 1: rec = cur.fetchone() if not rec: break # Confimed: rec tuple is different every iteration..., so is each element... # rec is a tuple of immutable objects (int, string, etc) xr = Reading ('G', rec[0], rec[1], rec[2], rec[3]) result.append(xr) cur.close() s.close() cur = None s = None except: raise return result When I call this method, it returns a list of Reading instances. Examining each instance in the list: ie.. (from command line): >>> from mymods import User >>> s = User() >>> r = s.getReadings() <-- Returns a list of Reading instances >>> r[0].id is r[1].id <-- Compare object references of two instances 1 <-- How can this be? >>> r[0].value is r[1].value <-- Compare another attribute 1 <-- AGAIN?? ... When I print each instance of Reading, the values printed are the same. In other words, the attributes in each instance of Reading is referencing the SAME set of objects! How is this possible? My first thought was that the rec tuple returned from the cursor method fetchone() is a tuple mutable objects, but after doing some type checking, I have determined that the rec tuple's elements were immutable built-ins (integer, strings, floats). Any ideas or suggestions??? This is so baffling! Thanks, Ralph From thecalm at NOSPAM.btinternet.com Tue Jun 26 18:53:51 2001 From: thecalm at NOSPAM.btinternet.com (G. Willoughby) Date: Tue, 26 Jun 2001 23:53:51 +0100 Subject: Closing a child window using Tkinter??? Message-ID: <9hb3ob$hai$1@neptunium.btinternet.com> This is the code i am using to display a new window from another window, but when i click the close button it closes the whole program when i only want to close the new 'child' window. any ideas whats wrong? ta. def newWindow(): aboutbox=Toplevel() aboutbox.resizable(0, 0) aboutbox.title("About...") aboutFrame = Frame(aboutbox, bd=1, relief=SUNKEN) aboutFrame.pack() Label(aboutFrame, text="Testing...", wraplength=300, justify=LEFT, padx=10, pady=10).grid(row=0, column=0, sticky=W+E) Button(aboutFrame, text="Close", width=15, relief=GROOVE, command=aboutbox.quit).grid(row=1, column=0, padx=10, pady=10) Gaz. From rnd at onego.ru Wed Jun 27 06:12:05 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 27 Jun 2001 14:12:05 +0400 (MSD) Subject: PEP 260: simplify xrange() In-Reply-To: <9hc97q$rpt$1@slb6.atl.mindspring.net> Message-ID: On Wed, 27 Jun 2001, Andrew Dalke wrote: >Uncle Tim: >>> although-it-would-be-impolite-to-ask-we-why-still-ship-a-directory- >>> full-of-crufty-old-irix5-demos-in-the-std-library-ly > >James Logajan: >>Perhaps because the Irix community would be quite Irate if they were >>removed? > >As an ex-member of the Irix community, I never used those >modules because I knew my code needed to run under non-IRIX >platforms. Let them be deprecated. > >As a double check, I did a google search for > +"import al" +def Interesting. This method assumes that source code must be in open form on the web: google doesn't look into (even) gz archives! Not mentioning code which is developed for custom tasks and interest nobody but it's authors to be put on the web! * On the other hand, it's interesting approach. For example, Linux kernel is in webified forms (somewhere). If gcc people will want to remove, say, scanf function, they will certainly find that Linux kernel uses it ;-) May be we establish new policy for the PEP process, obliging authors of the software written in Python to put (and update!!!) their code on the web so everybody will see that such and such library is still used. Then GvR just googles around to find out that, OK, xrange is not used anywhere in the 3 month old code, so we should remove it from CVS. And everbody is happy (it's a fault of those who failed to put source code on the web in time ;-) >The only hits related to Python were from Python itself >(documentation or audiodev.py) > >No relevant hits from +"import fm" +def , except that there >is a Mac Python module "import Fm". Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Wednesday, June 27, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "No sense being pessimistic. It wouldn't work anyway." _/ From bsass at freenet.edmonton.ab.ca Thu Jun 28 17:36:16 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Thu, 28 Jun 2001 15:36:16 -0600 (MDT) Subject: Augmented Assignement (was: Re: PEP scepticism) In-Reply-To: Message-ID: On Thu, 28 Jun 2001, Bruce Sass wrote: > On Thu, 28 Jun 2001, Paul Prescod wrote: > > > I think Python has been getting better and better as time goes on. But I > > do have a concern about augmented assignment. How can a newbie > > understand that tuples are "immutable" if this works: > > > > mytuple += (foo,bar) > > Ya, ok, it was a rhetorical question > maybe this sequence would help explain it to someone... > > >>> a = 1,2 > >>> b = a > >>> a, b > ((1, 2), (1, 2)) > >>> id(a), id(b) > (135055732, 135773292) opps, not when I cut'n'paste the wrong line. s/b, (135773292, 135773292) > >>> a = a + 3,4 > Traceback (most recent call last): > File "", line 1, in ? > TypeError: can only concatenate tuple (not "int") to tuple > >>> a = a + (3,4) > >>> a > (1, 2, 3, 4) > >>> id(a) > 135523340 > >>> a += 5,6 > >>> a, b > ((1, 2, 3, 4, 5, 6), (1, 2)) > >>> id(a), id(b) > (135746564, 135773292) - Bruce From urpala at ampeeri.ee.tut.fi Wed Jun 6 14:58:55 2001 From: urpala at ampeeri.ee.tut.fi (Uoti Urpala) Date: 6 Jun 2001 18:58:55 GMT Subject: random References: <3b1cf00f.5441109@nntp.sprynet.com> <3b1e43f4.1661099@nntp.sprynet.com> Message-ID: In article <3b1e43f4.1661099 at nntp.sprynet.com>, David C. Ullrich wrote: >>requirements of the results. The encoding must allow "arbitrary binary >>data" to be included. >consisting of all 0's terminated by a 1. Assunming that >"arbitrary binary data" means only finitely much binary >data that's no problem. I meant that more literally: the encoding must allow binary data to be included "as is", so that a constant of x bits takes no more than x bits of program space. >What I'm trying to track down is what does make the proof work. >In particular what I'm curious about is whether the requirments >that make the proof of the randomness work are really all that >natural, or whether they were just chosen to make the randomness >come out right in the end... The requirements aren't all that strong. Basically, "self-delimited turing-complete program with binary data" is enough. You first read the program (with whatever self-delimited computable encoding, one where the first 1 bit terminates as in your example above is OK). The program can then read the following bits. "A random program terminating" can then be defined as "select an infinite stream of random bits; take the (if any) prefix that is a self-delimited encoding; whenever the program reads a bit, give it the next one from the stream; does the program ever halt?". To work with finite programs-with-data in the above scenario, you can define that a program trying to read more data than there is or trying to halt before reading all the data fails (doesn't halt) - it wasn't self-delimiting, as it didn't know the total length. The must-read-all-data part allows simple calculation of lower bounds for Omega, as it fixes the problem of the total being greater than 1 (no halting program can be a prefix of another). -- Uoti Urpala From robin at jessikat.fsnet.co.uk Wed Jun 6 06:36:34 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 6 Jun 2001 11:36:34 +0100 Subject: Tkinter and Win 95 Message-ID: I'm running Python 2.1 with Win32 and am using Pmw as a framework for building an App. I'm having problems when killing the app using the window manager. In particular under win95 although the application window disappears I sometimes get a hanging python process. This process can be killed using the standard techniques, but it leaves something behind that effectively prevents Win95 from shutting down completely. Something that is intensely annoying as it prevents clean autobooting etc. I am using the traditional trick of handling the wm event as ..... self.root.wm_protocol("WM_DELETE_WINDOW",self.quit) ....... def quit(self): self.root.destroy() but how can I get this to work cleanly on Win95? -- Robin Becker From dougfort at downright.com Sun Jun 10 20:52:20 2001 From: dougfort at downright.com (Doug Fort) Date: 11 Jun 2001 01:52:20 +0100 Subject: Lost between urllib and httplib References: Message-ID: <3b241642_6@news5.uncensored-news.com> Content-Transfer-Encoding: 8Bit Gustaf Liljegren wrote: > Python 2.1: > > I'm choosing between urllib and httplib, but have trouble with both. > urllib.urlopen() is hiding HTTP errors (hope this will be fixed in next > version!), and httplib.HTTP() doesn't seem to be able to access some pages > if you only supply a domain name. > > Here's the script I use for testing httplib: > > import urlparse > import httplib > import sys > > url = sys.argv[1] > > try: > h = httplib.HTTP(urlparse.urlparse(url)[1]) > h.putrequest('GET', urlparse.urlparse(url)[2]) > h.putheader('Accept', 'text/html') > h.endheaders() > except: > print "Host not found." > sys.exit() > > print h.getreply()[0] > > On some websites, I get HTTP error 301, 302 or even 404. Try for example: > > http://www.webstandards.org (301) > http://www.native-instruments.com (302) > http://www.chaos.com (404) > > If using urllib however, these places are all accessed successfully. What > is it in urllib.urlopen() that has to be added if using httplib? > > Regards, > > Gustaf Liljegren > HTTP results 301 and 302 are redirections. You have to handle them yourself using httplib. The good news is that httplib gives you the flexibility to handle them as you want. I have attached one of our HTTP clients that uses httplib. It handles all three sites you mentioned. This code is used in our website load testing system http://www.stressmy.com -- Doug Fort Senior Meat Manager Downright Software LLC http://www.downright.com -------------- next part -------------- A non-text attachment was scrubbed... Name: rawhtmlpage.py Type: text/x-java Size: 14233 bytes Desc: not available URL: From dsh8290 at rit.edu Tue Jun 5 22:20:08 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 5 Jun 2001 22:20:08 -0400 Subject: Bios calls in Python? In-Reply-To: ; from bwalker@earth1.net on Tue, Jun 05, 2001 at 07:46:28PM -0400 References: Message-ID: <20010605222008.A14318@harmony.cs.rit.edu> On Tue, Jun 05, 2001 at 07:46:28PM -0400, Bill Walker wrote: | Is it possible to make BIOS calls in Python (Windows version)? In | particular, I would like to plot graphic points in EGA resolution to the | console screen. Can you make BIOS calls in C? If so you can write a C extension to provide BIOS access to Python :-). -D From sholden at holdenweb.com Tue Jun 12 00:06:56 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 12 Jun 2001 00:06:56 -0400 Subject: Basic gadfly question References: <9e6V6.15027$lq1.4843531@typhoon.austin.rr.com> Message-ID: <#ub8hWv8AHA.277@cpmsnbbsa07> "W. Jarrett Campbell" wrote in message news:9e6V6.15027$lq1.4843531 at typhoon.austin.rr.com... > I'm new to the world of Python, Databases, and SQL but it has been a fun > adventure so far! > > I have basic question regarding the Gadfly package. I'm working with the > sample database generated by the gftest.py module. I'm trying to execute an > SQL statement such as: > > INSERT INTO frequents (DRINKER, BAR) values ('Jarrett', 'cheers') > > When I do this I get an error back saying that I did not define a value for > the column 'PERWEEK' > > My questions are these? Do you have to set all values in the insert > statement or is there some way around this? Is this bad database > programming form to want to set only some fields? Is this related to gadfly > not supporting Null values? SQL allows the use of a "NOT NULL" constraint which forces a particular column to contain a value. Gadfly can't (yet) handle NULL values, so each column of each row must hold a value. In general it isn't necessarily sinful to build databases holding NULL values, but the whole NULL idea, bringing triple-valued logic in tow as it does, is full of pitfalls for the unwary. > > When using the ODBC package in the win32all distribution, I can achieve this > functionality with MS Access databases. I wanted to stick with gadfly to > remain platform independent and not require my users to purchase Access. > Any advice? > You may find that you can use a null string ("") to represent no value. A lot depends on the application. As a matter of interest you can download enough of the Jet engine to establish ODBC data sources without having to buy and load Access itself. Jat, and also the MSDE engine, which IIRC comes as a part of the Office suite and also as a part of VisualStudio, can be freely redistributed if you have the right license. Thanks to Alex Martelli for pointing some of this out to me. regards Steve From tundra at tundraware.com Tue Jun 26 14:50:03 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 26 Jun 2001 18:50:03 GMT Subject: Is this a true statement? References: <8NuZ6.362378$oc7.42924874@news2.rdc2.tx.home.com> <3B3788A2.3BD1D672@tundraware.com> <9h89pn$oj5$1@slb2.atl.mindspring.net> Message-ID: <3B38D94E.727A0EEF@tundraware.com> Andrew Dalke wrote: > > Software is used for more things than "Computational Power." > Take again the example I posted a few days ago on allocating in > shared memory. > > Suppose I have a hardware environment where there is special > shared memory hardware which can be used to pass data between > otherwise different processors. One example is the CAVE > visualization system, which is an immersive reality system > where images are projected on the walls of a room to make it > look like you are inside of a synthetic environment -- the > closest we can get to Star Trek's holodeck. One processor > is used to generate the visualization model into shared memory, > then other CPUs (one for each wall) gets the model to generate > the appropate image with the correct viewpoint. > > In C++ I can define how 'new' and 'delete' work on a given > class, so that I can allocate and deallocate the objects > to be shared from the shared memory arena while leaving > the other objects (like file I/O) in local non-shared (and > more plentiful and cheaper) memory. > > There is no way nor even a proposal of a way to use special > memory allocation routines for specific object, at least not > in a very Pythonic fashion. So using different memory arenas > is an example where you can "do" something in C++ which is > much harder to do in Python. It is not a limitation or > restriction of the implementation of Python - it's in the > language itself. > > To bring it back to Turing machines, the concept of "shared > memory" or "I/O ports" or "interrupts" or "signals" does not > exist in a TM. To talk about them in a TM context requires > emulating their physical behaviour, and it is that emulation - > that translation from a language description to a physical > device - that some languages do not provide. > > Andrew > dalke at acm.org What prevents me from writing out a byte string from Python which is a set of primitives for accessing the SM hardware and then building up higher level Python interfaces from these primitives? -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From tim.one at home.com Fri Jun 22 18:42:20 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 22 Jun 2001 18:42:20 -0400 Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: [Carsten Geckeler] > ... > I just wanted to point out that "calling a class" (i.e. creating an > instance by calling class(args)) also returns an object, but that this > is of course not a reason to define it with "def", because the way the > definition is evaluated and what is returned is completly different as > how a function definition is evaluated (as you pointed out). And the > same with generators. If you're only interested in the first 100 nanoseconds of a generator's life, that's true . But when you write a generator, or analyze a generator, or think about a generator, or step thru a generator in a debugger (etc), they're just resumable functions; much like class methods are just functions with a magical first argument. We spell class methods with "def" to emphasize the similarities; ditto for generators. That doesn't mean differences don't exist, but that the similarities are so deep that harping on the differences is more distracting than helpful. From see at my.signature Thu Jun 14 01:03:08 2001 From: see at my.signature (Greg Ewing) Date: Thu, 14 Jun 2001 17:03:08 +1200 Subject: Python grammar.. References: Message-ID: <3B28458C.F171FDB0@my.signature> "Delaney, Timothy" wrote: > > a 1 ' OK > a(1) ' memory leak The "memory leak" part of that sounds like a bug in the implementation. It doesn't say anything about the merits or otherwise of the syntax. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From hgg9140 at fred.local Mon Jun 4 19:03:15 2001 From: hgg9140 at fred.local (Harry George) Date: 04 Jun 2001 16:03:15 -0700 Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> <3B1BC755.65510E63@bt.com> Message-ID: I've done "software engineering" data and process modeling in big death march projects and in small XP efforts. In every case, the problem is to use models/diagrams where/when they are needed, not just "because they told us to". And the only way they seem to be maintained is if there is no printed documentation -- everything is live on the web. Edit and publish in a 3 second cycle time. Under these circumstances, UML models (specifically Dia) make sense for conceptual modeling, logical data modeling, a dash of DFD's, and the occassional state diagram. The idea is to bring the community of players into a high0-level mindmeld as ASAP, not to lock down every nuance of the implementation. Then do design and code reviews on the implementation, which conveniently is in an easy-to-read langauge, like...python grante at visi.com (Grant Edwards) writes: > In article <3B1BC755.65510E63 at bt.com>, Alan Gauld wrote: > > > >> I took a 3 day class on UML once. My impression: yet another > >> "silver bullet" that doesn't work in real life. > > > >Like any design notation UML is there to communicate. If > >the peer group is small enough the advantages are marginal. > > Agreed. All of the projects I've worked on have been small (1-2 > people typically, 4-5 max). Resources are always scarce and > when schedule and budget gets tight, maintining the system and > design description always seems to be the first thing to fall > off the bottom of the priority list. > > "Just get the fix released to production, and we'll worry > about updating the documents later..." > > >If you are working in a distributed group of 20 or more > >programmers something likev UML is near essential. Most > >of my projects involve several hundreds of programmers > >(250 on the current one) and there we simply couldn't > >operate without UML. > > One of the problems I've run into consistently over the past 10 > years is when management insists on using "big project" > methodologies on tiny projects. Their reasoning seems to go > something along the lines of: If one person can do a project > like this in nine months using the "seat of the pants" method, > then if we make him use Flowcharts/SASD/UML/whatever, then it > should only take half as long! > > >> thought it was marginally useful, but like any other form of > >> documentation, if it's not maintained (and it never is, AFAICT) > >> it becomes worse than useless. > > > >It depends on the level that you work at. Architectures don't > >vary that much and are useful for maintainers. But code varies > >a lot so if you try to use UML for documenting code without > >tool support for reverse engineering changes then I agree it > >quickly becomes out of date. > > > >But How else do we communicate design to a new start - it takes > >a long time to read a million lines of code.... UML and similar > >tools cut that time down by an order of magnitude. > > I agree that you certainly need something for documenting large > systems. The fashion in what that "something" is has varied > over the years, and UML seemed as good as anything (certainly > better than some). > > -- > Grant Edwards grante Yow! -- In 1962, you could > at buy a pair of SHARKSKIN > visi.com SLACKS, with a "Continental > Belt," for $10.99!! From kalle at gnupung.net Sat Jun 23 15:13:20 2001 From: kalle at gnupung.net (Kalle Svensson) Date: Sat, 23 Jun 2001 21:13:20 +0200 Subject: Missing file Python.h In-Reply-To: References: Message-ID: <20010623211320.A1990@gnupung.net> Sez Jeffrey Stephens: > I am running Redhat 6.2 and just downloaded and tried to compile the files > sip-2.4.tar.gz and PyQt-2.4.tar.gz. Running the configure script after > unzipping and untaring either of these produces the error that I am missing > the file Python.h. Running rpm -qa | grep python indicates that I have the > following packages installed: > > python-1.5.2-27.6.x > python-docs-1.5.2-13 > pythonlib-1.23-1 > rpm-python-3.0.4-0.48 > openssl-python-0.9.5a-2.6.x > python-tools-1.5.2-13 > python-numpy-15.2-2 > > None of these seems to contain a file Python.h. I also ran find /usr -name > Python.h with negative results. What rpm should contain this file? Can > someone point me in the right direction? Many thanks. IIRC, python-devel is the RPM you want. Peace, Kalle -- Email: kalle at gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From rdsteph at earthlink.net Wed Jun 13 21:10:07 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Thu, 14 Jun 2001 01:10:07 GMT Subject: Python equivalent of CPAN Library modules References: Message-ID: <3B26BFBD.46EE2435@earthlink.net> I think this is a great idea! I would certainly be interested in the resulting libraries, and so would many others, I am quite sure. I do feel that I am not sufficiently capable to contribute meaningful help in the programming work, yet. Hopefully someday. But if you go forward, I think you will be following in some pretty noble footsteps of public-benefactor pioneering Pythonistas of old.. Bravo! and hopefully others will be motivated to help, thus contributing to the good of mankind, civilization, and the human-way... David Hurt wrote: > Hello, > > Before I begin, I want to state that I am a python AND perl user. I typically > prefer python. > > At last year's python conference, the theme seemed to be "batteries included" > referring to the high availability and quality of pre-built functionality in > the python standard library. > > One thing I think may help python is the availability of even more "batteries" > in the form of additional modules available. > > One such source may be the perl CPAN repository. The CPAN has a collection of > very high quality libraries for a variety of applications. If these libraries > could be converted to equivalent python, then the libraries could be used for > python programs :) > > I think this could be done, as python is roughly equivalent to perl in terms > of language features (dynamic structures, regular expressions, hash=dict, > array=list, etc). I have even done some things like this before Python->perl > conversions and perl->python conversions > > I have a couple of questions before I start on some grand effort. > > 1. Has anyone looked at doing something like this before? > 2. Would anyone be interested in the results? > 3. Is this even a worthwhile effort? > > I am a part-time grad student and full-time employee. I may use this effort > as a project for credit if possible. > > My general plan is this > > 1. Examine the CPAN archive and map the Perl modules to equivalent python > standard library modules (and contributed modules in the Vaults of Parnassus) > (I imagine that this will be a HUGE effort) > 2. Get a list of the most commonly requested CPAN modules > 3. Convert the highest CPAN module that is not already mapped to python and > submit to the Vaults of Parnassus > 4. Repeat steps 1-3 until some arbitrary time or until the "most important" > 20-30% of the CPAN modules have a python equivalent. > > I would appreciate any feedback on the practicality/usefulness/etc. of this > effort. > > Thanks, > David Hurt > davehurt at flash.net From scarblac at pino.selwerd.nl Wed Jun 20 02:26:38 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 20 Jun 2001 06:26:38 GMT Subject: list 2 dictionary newcomer question References: Message-ID: Tom Messmer wrote in comp.lang.python: > Lets say I have a list of arbitrary, but definitely even length, and I > want to convert it to a dictionary. List might look like ['/', '15', > '/proc', '100'](I'm parsing the output of df) I'd simply like to pair > 'em up like {'/':'15', '/proc':'100'} I have a feeling I'm going to be > embarrassed at how easy this is, but I cant seem to figure it out. > I've seen examples on doing this with lists of lists, but not flat > lists. Any takers? L = [...] dict = {} for i in range(0, len(L), 2): dict[L[i]] = L[I+1] -- Remco Gerlich From rdsteph at earthlink.net Sun Jun 3 04:40:47 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Sun, 03 Jun 2001 08:40:47 GMT Subject: Jython book Message-ID: <3B18A902.92912FCF@earthlink.net> It seesm to me there is a huge opportunity fro someone to coem out with the first good book on Jython. It is a good tool, but a really good book would be of immense help. >From what I have seen of the knowledge of some on this list, the capability is theree for someone to write a definitive masterpiece. I hope anyway. Maybe Alex Martelli??? From andymac at bullseye.apana.org.au Wed Jun 13 07:59:48 2001 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Wed, 13 Jun 2001 21:59:48 +1000 (EST) Subject: statically linking the entire runtime (HPUX Python2.1) In-Reply-To: <3b091a1c.0106120045.5f49191e@posting.google.com> Message-ID: On 12 Jun 2001, cmkl wrote: > On HP-UX I'm trying to build python2.1 without building the C-modules found > in Modules/ as shared libraries. With the Version 2.0 this was the default. > I played around with configure, setup.py and Modules/Setup but I always > end up with a binary depending on various shared libraries. > I need this, bacause I want to freeze my pythons scripts as a single binary. > Distribution is much easier this way. > What is the trick to do that? I don't know specifically about HP-UX, but in general: 1: uncomment the modules you want in Modules/Setup 2: comment any "*shared*" terms in Modules/Setup 3: don't bother with setup.py, as its only for dynload modules -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andrew.macintyre at aba.gov.au (work) | Snail: PO Box 370 andymac at bullseye.apana.org.au (play) | Belconnen ACT 2616 andymac at pcug.org.au (play2) | Australia From bokr at accessone.com Sat Jun 23 13:49:09 2001 From: bokr at accessone.com (Bengt Richter) Date: Sat, 23 Jun 2001 17:49:09 GMT Subject: Why sys.ps2 after interactive #-line? Message-ID: <3b34d6cc.89984150@wa.news.verio.net> >>> >>> # comment ... # why ... at beginning of this line? ... # and this, and the next? ... >>> Why not a fresh sys.ps1 prompt after each #-line ? Just curious :) From ullrich at math.okstate.edu Sun Jun 3 11:21:13 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 03 Jun 2001 15:21:13 GMT Subject: random References: Message-ID: <3b1a5442.2461877@nntp.sprynet.com> On Sun, 03 Jun 2001 05:51:12 GMT, "Nick Perkins" wrote: > >"Tim Peters" wrote in message >> Chaitan is a bit of a self-promoter, and his rhetoric is often colorful, >but >> by all indications his work is rock solid. A very nice high-level intro >is >> this transcript of a lecture he gave at CMU: >> >> http://www.cs.umaine.edu/~chaitin/cmu.html >> >> > >I just read (almost all of) that page. >Very mind-blowing stuff. > >I am not sure, but think I managed to find the answer to this question: > >>"David C. Ullrich" wrote in message >>news:3b17a2f1.411766 at nntp.sprynet.com... >> ... >>> Could you give us a hint regarding exactly what work >>> of Chaitin's shows we can get "truly random" numbers from >>> arithmetic algorithms? > >Chaitan's work seems to imply that no algorithm (of finite size) can >possibly produce 'perfectly random' numbers. Before we can prove this we need a definition. Given a perfectly reasonable definition (cf post which may appear sometime when the news server at the office wakes up) it does not require Chaitin's work to show this, it's trivial. >Chaitan says "..something is random if the smallest program that calculates >it is the same size as it is..". He defines the randomness of data as the >inverse of it's 'structure', where structure is defined as the length of the >smallest program that produces the data. So it would seem to me that any >algorithm (or program) can not produce can not produce numbers of 'infinite >randomness'. > >The very idea of 'infinite randomness', in all it's unattainable glory, is >somehow very pure and clear in everyone's mind. It is, after all, the first >concept of randomness that we all learned as children: that something is >simply unpredictable, period. Strange that it takes centuries of advanced >math to try to pin down exactly what randomness means. > >Chaitan gives an example of a 'truly' random number, based on the 'Halting >Problem'. He shows that the probablity of a program halting is >fundamentally unknowable. It is an actual number between zero and one, but >where it is in that range is not only unknown, but 'unknowable'. In binary >representation, we can not even get the slightest idea of what the first >digit is, no matter how long of a program we write to figure it out. > >I may be mangling this a tiny bit, not being a mathematician, but I can see >where some of the confusion may have set in. It is easy to mis-understand >Chaitan's work as giving an algorithm for producing a 'truly' random number. >In fact, what I think he shows, is that there is a number that is 'truly >random', but producing the Nth bit of that number requires a program that is >at least N bits long. Read it again. There is _no_ algorithm to find the N-th bit. None whatever. That's not quite accurate, or at least it's susceptible to misinterpretation. Technically, the bits are recursively enumerable but not recursive: There _is_ an algoorithm which will ouput a sequence of reals, and those reals _will_ converge to Omega. Hence (well, there are details here as well, but let's just say "hence") the bits in the approximations _do_ converge to the bits in Omaga. So there _is_ something which will eventually print out the first 100 bits of Omega. But there is no way to know _when_ it's got the first 100 bits right. Um, that's the way it seems to me, anyway, based on what I thought that stuff was all about and what I read just now in that paper. I could be misinterpteting something. >...anyway, my brain is going all loopy at this point, and I may have >min-understood Chaitan, but I think I understood that Chaitan's ideas >support (or conclude, or rely on) the idea that no finite algorithm can >produce 'truly random' numbers. > >Have I mis-understood anything? > >Did anyone else read that page? What did you think? > >No? ..here it is again: (thanks, Tim) >> http://www.cs.umaine.edu/~chaitin/cmu.html > > > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From dalke at acm.org Sat Jun 23 07:09:53 2001 From: dalke at acm.org (Andrew Dalke) Date: Sat, 23 Jun 2001 05:09:53 -0600 Subject: PEP 255: Simple Generators References: Message-ID: <9h1tt9$16i$1@slb1.atl.mindspring.net> Carsten Geckler: >Could you tell me, how e.g. a "generator" statement would >be distracting? I can't see how a more clearifying statement could >possibly distract people. Me: Okay, the "def" statement is how you make a function. Chemist: Yeah, functions, I know those from FORTRAN. Me: And the "class" statement is how to make a new class. Chemist: Ohh! I finally get to learn about object-oriented programming! Me: And the "generator" statement is how to make a new generator. Chemist: A what? What's a generator? Me: It's a function that returns a special kind of object. Chemist: Then why isn't it called a function? Me: Well, you can think of a class as a function that returns a special kind of object. Chemist: Oooo..kaaay.. Me: Okay, how about this. A generator turns a function into ... You know, I just don't know how to explain it well enough. But they are really easy to use - just pretend they are functions that return a list, except that you can only ask for the next item in the list. Chemist: But you said Python was also easy to understand. Andrew dalke at acm.org From ngps at madcap.dyndns.org Thu Jun 14 12:18:11 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 14 Jun 2001 16:18:11 GMT Subject: Postgresql Woes References: <436ad7a4.0106131131.57bc1cd1@posting.google.com> Message-ID: <9gao43$ajs$1@violet.singnet.com.sg> According to Sreekant : > con=pg.connect("mydb") > tbl=pg.query("show all tables from mydb") or something similar ?? "select tablename from pg_tables where tableowner = current_user" Other system tables of interest are pg_user(s) and pg_database(s). -- Ng Pheng Siong * http://www.post1.com/home/ngps Quidquid latine dictum sit, altum viditur. From tiago.henriques at portugal.sun.com Wed Jun 20 05:45:05 2001 From: tiago.henriques at portugal.sun.com (Tiago Henriques) Date: 20 Jun 2001 02:45:05 -0700 Subject: Any other Python flaws? References: <3b296534.514160393@wa.news.verio.net> <3b2a94a6.591842855@wa.news.verio.net> Message-ID: <636fd38f.0106200145.337888a3@posting.google.com> bokr at accessone.com (Bengt Richter) wrote in message news:<3b2a94a6.591842855 at wa.news.verio.net>... > On 15 Jun 2001 18:11:48 +1200, Paul Foley wrote: > > >On Fri, 15 Jun 2001 04:01:49 GMT, Bengt Richter wrote: > > > >> One benefit would be that Python could have its _own_ standard > >> hierarchical file-and-such-entities-as-my-be-desired name space > >> independent of platform, or at least more independent. > > > Having an abstract tree would also make possible laying out python > package and module relations in terms of their standardized abstract > tree locations without worrying about where they were actually > installed on disks or networks, or indeed whether they were hooked-in > python objects playing proxy roles. > While we're on the subject of namespaces, one thing that I've felt from the beginning was missing from Python is a way to navigate the name space tree like a file system. For example, instead of typing: dir(os.path) dir(os) one could type: cd(os.path) dir() cd(..) dir() pwd() 'os' or something similar. This could also be coupled with a context dependant help function. This is not so much a wart as a missing feature, but I feel it would make python even more enjoyable for newbies. Another annoying missing feature is the absence of command line editing in the python shell. Perhaps now that the license has been made gnu-compatible it will be possible to ship python pre-compiled with the readline library, instead of having to compile python yourself. I have compiled python with readline support myself, and it's pretty easy, but for the average user who is afraid of makefiless and compilations, it would be extra-nice if python were a bit more user-friendly out-of-the-box. -- Tiago From wjdandreta at worldnet.att.net Mon Jun 11 13:55:28 2001 From: wjdandreta at worldnet.att.net (William Dandreta) Date: Mon, 11 Jun 2001 17:55:28 GMT Subject: File open problem? Message-ID: I am getting an error I do not understand. 1st line in script (/mnt/floppy/setup.py) is: myfile = open('/etc/rc.d/rc.sysinit','r') error is: Traceback (innermost last): File "/mnt/floppy/setup.py", line 5, in ? myfile = open('/etc/rc.d/rc.sysinit','r') TypeError: illegal argument type for built-in operation What does it mean? from Python 1.5.2 on Linux Mandrake 7.2. A line like myfile = open('test','r') in the interpreter gives the same error. The same line under Windows it OK. Bill From atsang at hk.linkage.net Fri Jun 15 13:06:39 2001 From: atsang at hk.linkage.net (Alan Tsang) Date: Sat, 16 Jun 2001 01:06:39 +0800 Subject: performance of python threads References: <9g4ap8$1mh$1@news.hk.linkage.net> Message-ID: <9gdfaf$ibr$1@news.hk.linkage.net> David First of all, thanks for your post. Indeed, in my last post, with regards to performance, I mainly concern with the additional overhead that bring into thread scheduling. Regards David Bolen wrote: > Alan Tsang writes: > >> I am going to code for a small system that will invoke multiple threads >> and >> process data concurrently. Has any body done some sort of benchmark on >> the performance of python threads? > > I think you'll probably need to be clearer on what you mean by > "performance" since there are a lot of things you could measure with > respect to threads. If you could describe the sort of activities that the > system will be performing in the threads, it might help. > From elf at halcyon.com Wed Jun 6 13:14:26 2001 From: elf at halcyon.com (Elf Sternberg) Date: 6 Jun 2001 17:14:26 GMT Subject: Has anyone used UML? References: Message-ID: <9flodi$32m$1@brokaw.wa.com> In article Harald Hanche-Olsen writes: >+ Tim Churches : >| No experience (I am in a similar situation to you wrt UML), just >| some advice: don't buy the O'Reilly book 'UML in a Nutshell' - it is >| the only O'Reilly title I have encountered which is truly woeful >| (most are quite good). >Hmm. Has it occured to you that this might be a reflection on UML >rather than on the book per se? No, it's true. The UML book by O'Reilly is atrocious. The author tries *so hard* to convince the reader that UML is not about modelling programs but about modelling "business practices" that he goes overboard avoiding programming examples. The author also seems to introduce topics at random without going through the process of actually creating a model for the user to use. The big problem I have with UML is that it's owned, lock, stock and barrell, by Rational Rose. Every book I have seen on the subject cheerleads Rational Rose products and makes it sound like, "yes, you can do it without Rational Rose, but you can also build a computer with tinkertoys. Why do that when we'll give your our superduperdeluxeUMLpackage for only $79,999.95?" UML is nothing more than a simple way of describing program models. Two of the better books I've seen on the subject are "A UML Pattern Language" (totally buzzword compliant, but the concise summary of "what UML is" in part 1 and the "best UML practices" collection in part 2 were worth it) and "Building Web Applications with UML" (again, because the summary is precise and maybe because appservers are my field of specialization), but the latter is a Rational cheerleader. Oddly, it's the little things that help. I didn't really grok the relationship between a Use Case and a Sequence Diagram until someone told me "In a sequence diagram, the vertical bar is the lifetime of an instance; the horizontal bars are applications of a use case." And then a lot of the OO stuff I'd been using for years clicked. ... and then it was time to refactor. :-) Elf -- Elf M. Sternberg, rational romantic mystical cynical idealist http://www.halcyon.com/elf/ Dvorak Keyboards: Frgp ucpoy ncb. ru e.u.bo.v From greg at cosc.canterbury.ac.nz Mon Jun 25 02:29:32 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Mon, 25 Jun 2001 18:29:32 +1200 Subject: Another Wart! string.find() [ was: namespace issue? ] References: <3B33A3A4.99CDB06@home.net> Message-ID: <3B36DA4C.851C1702@cosc.canterbury.ac.nz> Chris Barker wrote: > > I suppose the time machine was not yet functional either... But surely any time machine which is *ever* functional is *always* functional. Since if it breaks down you can just go back and repair whatever it was that broke just before it broke... -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From aleaxit at yahoo.com Sun Jun 3 04:53:27 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 3 Jun 2001 10:53:27 +0200 Subject: random References: Message-ID: <9fcu3601vet@enews2.newsguy.com> "Nick Perkins" wrote in message news:kfkS6.122583$eK2.28480687 at news4.rdc1.on.home.com... ... > > http://www.cs.umaine.edu/~chaitin/cmu.html Nice pointer indeed, and it contains others that are just as nice. > I may be mangling this a tiny bit, not being a mathematician, but I can see > where some of the confusion may have set in. It is easy to mis-understand > Chaitan's work as giving an algorithm for producing a 'truly' random number. Chaitin. I point it out because you spell this "Chaitan" in a few more places further on. > In fact, what I think he shows, is that there is a number that is 'truly > random', but producing the Nth bit of that number requires a program that is > at least N bits long. He gives the program-size requirement as the _definition_ of randomness, and what he proves is that such a number exists -- defines it and explores it. Shows the purely arithmetic (Diophantine) equation which it solves, &c. http://www.cs.umaine.edu/~chaitin/sciamer2.html, his Scientific American article, goes into this more than the above-quoted URL, which is more about how his work fits in 20th century mathematics. > ...anyway, my brain is going all loopy at this point, and I may have > min-understood Chaitan, but I think I understood that Chaitan's ideas > support (or conclude, or rely on) the idea that no finite algorithm can > produce 'truly random' numbers. > > Have I mis-understood anything? I would say "define" rather than 'support' or whatever. Having defined the randomness of a number as the size of the smallest program that generates it as output (and gone on to prove that you cannot get a lower bound measure on randomness for all save a finite subset of numbers), it's trivial that a program of finite dimension can only generate a number of finite randomness, and apparently what people seem to mean by 'truly' or 'perfect' random is infinite randomness. Omega, aka the Chaitin number (but he doesn't call it by his name himself:-), is defined as the probability that a randomly generated program will halt. There are some technical issues, key one being to ensure the program is self-limiting -- it asks for its next bit in sequence and self-determines algorithmically whether it has already received all of its bits -- and of course one has to fix a specific binary Universal Turing Machine encoding, but that's not the deep part:-). And the 'randomly' in the definition doesn't explore how the random independent bits of the program are in turn generated -- assume classical coin tosses. Again nothing deep as in principle the same Omega could be obtained without having randomness to start with by enumerating all programs of N bits for all naturals N (of course that determination could not run in finite time or space:-). But the method summarily given in the Sci.Am paper does show how to program the computation of any given bit of Omega (given a machine without bounds on the size of the program nor the size of numbers storable in its registers). The size of the program grows with the index k of the bit you want to compute. But it seems to me (still from the layman-level presentation in the paper) that these programs are in turn generable by a finite program -- if you give up the finiteness constraint along the time axis, or, in other words, the guarantee that a program will halt. "Hence the diophantine equation actually has infinitely many solutions for a particular value of its parameter k if the kth bit of Omega turns out to be a 1, and for similar reasons it has only finitely many solutions if the kth bit of Omega turns out to be a 0". Here any program size is finite (if the register-sizes aren't, at least:-), but some would say the finite program is not "an algorithm" because it's not finite in time -- it may never halt (and we know about trying to prove if it halts...:-). So, summing up: Chaitin has surely not shown that a finite program running in finite time can generate infinite randomness -- that would contradict his definition of randomness. He HAS shown infinite (true, perfect, whatever) randomness can be obtained in arithmetic if dropping the finiteness constraints on the definition of 'algorithm'. He also shows (handwaving, but apparently there are solid proofs in his 'Exploring Randomness' book -- it will take some days before I can read it though:-) that this mathematical randomness has all the typical characteristics of classical-physics random numbers: """ In my approach I bring both notions of independence to bear. The answer to my question for one value of k is logically independent of the answer for another value of k. The reason is that the individual bits of Omega, which determine the answers, are statistically independent. Although it is easy to show that for about half of the values of k the number of solutions is finite and for the other half the number of solutions is infinite, there is no possible way to compress the answers in a formula or set of rules; they mimic the results of coin tosses. Because Omega is algorithmically random, even knowing the answers for 1,000 values of k would not help one to give the correct answer for another value of k. A mathematician could do no better than a gambler tossing a coin in deciding whether a particular equation had a finite or an infinite number of solutions. """ So where's the "state of sin" in this arithmetical and almost-algorithmical- except-for-the-little-detail-of-finiteness approach to randomness? Alex From isis at wanadoo.be Tue Jun 26 12:58:43 2001 From: isis at wanadoo.be (Johan Daine) Date: Tue, 26 Jun 2001 18:58:43 +0200 Subject: Ascii characters References: <3B386147.79E68C69@wanadoo.be> <7M0_6.4105$e5.767781@newsb.telia.net> Message-ID: <3B38BF43.43DD28CB@wanadoo.be> Fredrik Lundh a ?crit : > > Johan Daine wrote: > > I am using using swish++ with Zope in a french context. > > In orger to filter the user requests, I need to filter accented > > characters to the unaccented char. > > assuming you have 2.0 or later, something like this > should work: > > import unicodedata, string > > def maketable(): > # build iso-latin-1 to "undotted" ascii translation table > table = range(256) > for i in table: > x = unicodedata.decomposition(unichr(i)) > if x and x[0] == "0": > table[i] = int(x.split()[0], 16) > return string.join(map(chr, table), "") > > text = "...some accented iso-latin-1 text..." > > noaccents = maketable() > > undotted_text = string.translate(text, noaccents) > > hope this helps! > > > > Thanks for your help... From rdsteph at earthlink.net Tue Jun 19 23:29:55 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Wed, 20 Jun 2001 03:29:55 GMT Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: <3B2EADB0.9DBC6FC8@earthlink.net> Message-ID: <3B2EC98E.FE0F1B6E@earthlink.net> Sigh, sounds like we got a lot of folks, of whom I am by far the worst, who would love to contribute. I would think the hardest part would be to find a couple of truly competent leaders, who are expert programmers, sort of our own mini-Linus's or Guido's. The leaders could then moderate the "toolkit wars" and make final decisions. My guess is it might be extraordinarily hard to find such leaders for an open source project like this ;-(((((. One could only suggest Roman Suzi and Neil Hodgson since they were the first two to mention HyperCard. (and it sounds like they know what they're talking about) Anyway, should anyone be foolish enough to reluctantly volunteer as fearless leaders, it looks like they could expect lot of eager followers... Of course one would hope that some of the followers could actually produce good code...;-))))) rs Neil Hodgson wrote: > Ron Stephens: > > Of course, each person undoubtedly has a different set of concepts in mind > > when he thinks of "PythonCard"..still, an intriguing amount of interest in > 24 > > hours... > > I'd like, at least initially, a fairly straight clone of HyperCard but > with true colour graphics. While my other open-source activities don't leave > much time for contributing, I'd be able to do a script editor / debugger. > > Is it time to have the toolkit war? > > How suitable would ZODB be as the persistence back end? > > Neil From cja at well.com Wed Jun 20 13:53:28 2001 From: cja at well.com (Chris Abraham) Date: Wed, 20 Jun 2001 10:53:28 -0700 (PDT) Subject: Final Info Before the DC ZPUG Meeting In-Reply-To: Message-ID: DCLUGsters, PIGies, Zopesters, and ZPugs! First of all, here's where we need to be: This first meeting takes place at the National Institute of Health campus in Bethesda, Maryland, in the Lippsett auditorium located in the main hospital building (Bldg. 10). This is the time line: Our meetings normally start at 7 pm, with loose banter and issues of the day; by 7:20 we are ready to go into the talks. We normally take 1-1.5hr for the talk, and allow questions from the audience, or not, at speaker's discretion. This is the web site you can refer to: http://www.zpug.org And further directions are here: http://www.nih.gov/about/index.html#visitor Who, What, When, Where, Why, How: Our presenters will be the gang from Digital Creations. This charter meeting will be straight from the horse's mouth and will be a valuable opportunity for both Zope and Python lovers to dote as well as turning on a load of Linux Users to the unique powers, strengths, and flexibility of Zope and Python. We have Guido Van Rossum, Jim Fulton, and Ken Manheimer at least! Cheers, Chris From altis at semi-retired.com Wed Jun 20 12:14:22 2001 From: altis at semi-retired.com (Kevin Altis) Date: Wed, 20 Jun 2001 09:14:22 -0700 Subject: PythonCard mailing list References: Message-ID: Nevermind, I found the setting to make messages publicly available. Doh! ka "Kevin Altis" wrote in message news:TF3Y6.596$Xy3.138507 at news.uswest.net... > My apologies, I forgot that Yahoo Groups (eGroups) apparently requires > registration even to just read messages. At least one person has already > brought this up here on comp.lang.python. > > If anyone has a suggestion for a forum where we can discuss, either > your own listserv or a free listserv service where we can make individual > messages and/or the archives available I would like to make the switch now > rather > than later. I'm not running my own server at this point, so I can't set one > up and I don't know of a service offhand that doesn't require some kind of > regisration, even for reading. Geograwler and some of the other sites just > put a > web front end on various lists, I don't think they host the list as well?! > > Thanks, > > ka > > "Kevin Altis" wrote in message > news:MBUX6.1875$zE1.693567 at news.uswest.net... > > http://groups.yahoo.com/group/pythoncard > > > > I just created this group so we can take the discussion out of > > comp.lang.python. Feel free to start posting. > > > > ka > > > > > > From bokr at accessone.com Wed Jun 6 12:24:35 2001 From: bokr at accessone.com (Bengt Richter) Date: Wed, 06 Jun 2001 16:24:35 GMT Subject: Numeric dimensions, units ,etc. Was: Re: I had a thought ... (I know, call the newspapers). References: <9f5nhn02816@enews2.newsguy.com> <9fb78v$qf5$1@216.39.170.247> <3B1DC3DB.A9F38F4C@cosc.canterbury.ac.nz> Message-ID: <3b1e4c1b.473967659@wa.news.verio.net> On Wed, 06 Jun 2001 17:47:07 +1200, Greg Ewing wrote: >David LeBlanc wrote: >> >> Currency might be a comfortable metaphor for people, >> especially accounting types who probably think a number is naked without >> a currency symbol. > >But you need *some* numbers other than currency. >If I buy 3 widgets at $1.23 each I'm spending >3 * $1.23, not $3 * $1.23, which would give a >result in square dollars. > >I don't know what square dollars look like, >but I'm sure my bank wouldn't accept them... > You put your finger on an interesting aspect of numeric quantity representation and computing. Here's a questing and a few thoughts OTTOMH: Has anyone built a class to deal systematically with this and related issues? I have in mind a kind of quantity class with an abstract value as a pure number, plus associated dimension and unit ids (e.g., 'distance' and 'meters', or 'currency' and 'USD'), and some kind of precision/accurancy representation specification and control mechanism that could support a q.IsAccurate(srep) boolean-returning method that could be used in assertions. The idea would be to be able to assert that a string representation of the class instance value was accurate within the criteria specified when quantity instances were created. I am thinking this could support writing a validate test for a program meant to deal with defined ranges of legal values and output formats for same. I would guess that you might need interval arithmetic of some kind to represent the guaranteed value ranges of the abstract pure number values, and for operations on them, to do this is a bullet proof way. I suppose dimensions and units could be carried as tuples, e.g., ( ('distance' 'meters' 1) ('time' 'seconds' -2) ) for acceleration. If you ordered the tuple elements in a canonical way, you should then potentially be able to write space-probe-saving assertions ;-) From osu-nntp at portzer0.virtualave.=NOSPAM!!!=net Tue Jun 5 23:54:12 2001 From: osu-nntp at portzer0.virtualave.=NOSPAM!!!=net (Locke) Date: Tue, 5 Jun 2001 23:54:12 -0400 Subject: .pyc files Message-ID: <9fk9gk$5uo$1@charm.magnus.acs.ohio-state.edu> When I run my python scripts by pressing F5 in IDLE, it makes a .pyc file in whatever directory the script is in. This file doesn't appear when I run python from the command line. What is this? Why do I want this? Thanks. From dkuhlman at rexx.com Thu Jun 14 12:55:47 2001 From: dkuhlman at rexx.com (Dave Kuhlman) Date: Thu, 14 Jun 2001 16:55:47 -0000 Subject: when embedding Python, how do you redirect stdout/stderr? References: Message-ID: <992537747.711779@rexx.com> If you want to do it all in C, then I do _not_ have an answer for you. However, if you want to do some of it in Python and initiate it from C, then create a Python class with a "write" method and use PyRun_SimpleString to assign an instance of that class to sys.stdout. You can read about it at: http://www.python.org/doc/current/lib/module-sys.html (search for "stdout") And here is an example: PyRun_SimpleString("import sys"); PyRun_SimpleString("import myredirector"); PyRun_SimpleString("sys.stdout = myredirector.Redirector()"); OK, _I_ did the easy part. Now _you_ create the custom GUI texbox in Python. - Dave David Gravereaux wrote: > > Hi all, > > The subject says it all. I'm embedding (or trying) and want to have all std > traffic sent to a custom textbox in a windows GUI. Is there anyway to do this? > A good place for examples for me to read? I played around a little bit with > this, but need a more stream'ish way: > > output = PycStringIO->NewOutput(1024); > > /* capture all interpreter error output */ > PySys_SetObject("stderr", output); > > /* so that error is printed on standard error, redirected above */ > PyErr_Print(); > message = PycStringIO->cgetvalue(output); > string = PyString_AsString(message); > length = PyString_Size(message); > > I've since updated the exception getting part, so I don't have to redirect, but > I do need to have the std traffic now go somewhere. Any ideas? > -- > David Gravereaux > -=[ Ray's Famous and Truly the Original Pizza, NYC ]=- -- Dave Kuhlman dkuhlman at rexx.com From brian at sweetapp.com Sat Jun 16 19:38:20 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Sat, 16 Jun 2001 16:38:20 -0700 Subject: Writing new codecs In-Reply-To: <3B2BE778.FF80B75@lemburg.com> Message-ID: <002901c0f6bd$6e3bf990$445d4540@D1XYVL01> M.-A.Lemburg wrote: > Only the most important codecs will be placed into unicodeobject.c. > I think that UTF-7 would be a good candidate, since it is > a native Unicode encoding. UTF-32 would be another candidate. What about UTF-7, modified to be used in IMAP, as described in RFC2060 (I could also modify it slightly for vanilla UTF-7 [RFC1642])? I ask you directly since you are likely going to be assigned the patch :-) From dsh8290 at rit.edu Thu Jun 7 18:21:40 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 7 Jun 2001 18:21:40 -0400 Subject: Why should i use python if i can use java In-Reply-To: <9foms801hod@enews1.newsguy.com>; from aleaxit@yahoo.com on Thu, Jun 07, 2001 at 10:02:58PM +0200 References: <9fngvl011jg@enews2.newsguy.com> <9foms801hod@enews1.newsguy.com> Message-ID: <20010607182140.B18014@harmony.cs.rit.edu> On Thu, Jun 07, 2001 at 10:02:58PM +0200, Alex Martelli wrote: | "D-Man" wrote in message | news:mailman.991931005.1422.python-list at python.org... | ... | > On Thu, Jun 07, 2001 at 11:19:50AM +0200, Alex Martelli wrote: | > | > Ditto to all the Dynamic, but still strong, typing and the Design | > Patterns discussion explaning why Java is _still_ a very low level | > language even though it is bytecode-compiled and interpreted. | | Well, not VERY low...!-). Just lower than Python... Sometimes (far too often, especially when writing unit tests) Java feels very low level. | > | > Actually it does! With Jython, you can access any Java API from | Python. | > | > Neat, huh? | > | | > | Absolutely! But does any commercial IDE, as you earlier | > | referenced, support Jython yet? I don't know of any. | > | > Not commercial, but (g)vim supports this! Version | | GVIM rules (5.8's what I'm using now), but I doubt even 6.0 provides | me with a Jython debugger &c...?-) No, not yet. The debugger should provide a way (hook) to jump to the source in an editor, using an existing editor process if it is already running. | > 6.0 is nearly finished and has some really cool new features including | > "folding" (the ability to collapse a block of text into a single line | > on the display). | | Cool indeed (I'm sure the EMACSers are laughing at us of course:-). One of my coworkers who uses emacs said "Emacs has had that for 10 years!" :-). The funny thing is vim has hardly been around that long. -D From cwebster at nevada.edu Sun Jun 3 14:58:50 2001 From: cwebster at nevada.edu (Corran Webster) Date: Sun, 03 Jun 2001 11:58:50 -0700 Subject: Why PEP 245?? References: Message-ID: <030620011158504832%cwebster@nevada.edu> In article , wrote: > As it seems to be now, an Interface is similar to a class which has no > implementation, but *requires* doc-strings. But what keeps the > doc-strings meaningful? Nothing, other than good coding practise. But that's true of all doc-strings. > Let me go out on a limb and post code (untested because I do not have > access to a build with interface implemented): > > > class square: > def __init__(self): > pass > def show(self): > "Doc-string specific to square.show" > print """ > ***** > * * > * * > ***** > """ > > class circle: > def __init__(self): > pass > def show(self): > "Doc-string specific to circle.show" > print """ > *** > * * > * * > *** > """ > > class triangle: > def __init__(self): > pass > > > Now we could add an interface: > > > interface ShowInterface: > "Classes can _show_ themselves" > > def show(): > "Display ASCII representation of the object" > > > and I modify my class definition: > > > class square implements ShowInterface: > > > > class circle implements ShowInterface: > > > > class triangle implements ShowInterface: > > > > > But now what? What makes sure the doc-strings stay current or make > sense? Does a "ContractUnfulfilledError" occur when I create an > instance of 'triangle' because 'show' was never defined/implemented? > In short, what can I do now that I could not? According to the proposal, these definitions would not generate any sort of error - and that's reasonable because even though triangle doesn't satisfy the interface on definition, Python is sufficiently dynamic that it could be changed on-the-fly to satisfy it; or maybe triangle class is meant to be an abstract class with subclasses like IsocelesTriangle and EquliateralTriangle which always satisfy the interface (which would probably be bad design, but shouldn't be outlawed, I guess). What the PEP allows is run-time testing for compliance to an interface. For example: def showlist(mylist): for object in mylist: if implements(object, ShowInterface): object.show() else: print str(object) This would fail if you fed it a list containing a triangle instance, but that's a fairly easy error to detect. The PEP would also assist debugging through assertions. For example: def describe(object): assert implements(object, ShowInterface) print "The object you have selected looks like:" object.show() You can do these sort of tests in Python already, for example: def implementsShowInstance(object): return (hasattr(object, "show") and callable(object.show)) but this sort of thing is tedious at best if you have lots of complex interfaces, and still doesn't full capture all the information that the interface gives, such as the number of arguments to show and any default arguments (it's possible to discover these, but it is a lot of work). The problem you describe with the triangle class can be ameliorated as described in the PEP by using the deferred method of the interface: Showable = ShowInterface.deferred() ... class triangle(Showable): ... # as above, doesn't have a show method triangle.show() # gives an explicit error message But perhaps the most important reason for having something like the interface proposal is that Python already uses the concept of interfaces, but without any formal mechanism for supporting them in the language. There is talk about "file-like" objects and "callable" objects and "sequences" and "mappings" in the documentation, and there is a rough consensus amongst developers about what these interfaces are, but no explicit definitions of exactly what methods an object needs to be considered to satisfy the interface. Hope this helps, Corran From donod at home.com Fri Jun 1 20:39:02 2001 From: donod at home.com (Don O'Donnell) Date: Sat, 02 Jun 2001 00:39:02 GMT Subject: Decimal can be Binary Too (was decimal or rational) Message-ID: <3B183614.E299F31E@home.com> (If this is a dup post, pls excuse, orig got lost -D) Alex Martelli wrote: > >"Laura Creighton" wrote in message >news:mailman.991303187.29241.python-list at python.org... > ... > > > is decimal, not rational that is the way to go, somebody try to talk us > > out of it> is exactly what Burke was talking about. > > I'm not a candidate for "talking (anybody) out of it", where > "it" is having (e.g.) 7.35 mean a floating-point-decimal 7.35 > rather than a rational 7.35, because I'm _deeply_ undecided > myself. My criterion: what *WOULD* be harder to explain to (and > have accepted by) an intelligent beginner? Potentially *VERY > SLOW* (and memory-consuming) behavior for computation, or the > risk of unexpected (to said beginner) 'strange' results? And > I'm not talking about a vacuum -- I'm talking about a real-world > where people's expectations ARE very much shaped by the > calculators they've dealt with for years, and those ARE FP > decimal (at least typically). A computation doesn't slow > down as it proceeds, but it does often lose precision... If by "floating-point-decimal" you mean internal representation of both the mantissa and the exponent by some sort of a binary-coded decimal, let me point out that it is not necessary to go to full decimal in order to to achieve the `7.35` == "7.35" goal. By letting the exponent represent powers of 10 rather than 2, the base (or mantissa) and exponent can both be represented in binary as an int or long. Thus, the internal calculations can use the fast integer hardware instructions, rather than decimal arithmetic which would have to be done by software. Scaling would require a multiply or divide by 10 every time the exponent is incremented/decremented by one, not as fast as a left or right bit shift; but it can be done pretty fast considering that a multiply by 10 is equivalent to a left shift by 3 (*8) followed by two adds (10*x == (8+2)*x == 8*x + 2*x == 8*x + x + x): >>> x = 42 >>> (x<<3) + x + x # multiply by 10 without using * op 420 I'm not sure that this is any faster than x*10; in Python, probably not, but in C it may be. (Haven't looked at any CPU timing charts lately, so I may be all wet here; it used to be that mult & div were very expensive.) (A quick timing check shows that the above shift and add calculation takes about 3 times longer in Python than a straight *10, as expected.) Obviously, this binary-based decimal-powered floating-point would not be as fast as using the hardware FPU, but it wouldn't be as bad as doing all calculations in decimal as with a full decimal implementation. I'm in the process of writing an "efloat" class which implements these ideas as a proof of concept. "efloat" for expected float, i.e., one that meets your expectations, no surprises, as with: >>> 7.35 7.3499999999999996 If someone can think of a better name please let me know. I didn't want to call it dfloat since that should be reserved for a full decimal implementation. Come to think of it, efloat may not be such a good name since it can be confused with the "e" in the binary float literal display (0.735e1). I'll post the source code when I'm done, in case anyone is interested in checking it out. As far as decimal vs rational for a built-in Python type, couldn't we have both? And if we do get both, I think: 7.35 or 735d-2 should be the literal for the decimal-float 7.35e0 or 735e-2 should be the literal for binary float 735/100 or 735r-2 should be the literal for rationals -Don From thomas.hansenNOSPAMORILLSUEYOURASS at entermatch.com Fri Jun 8 09:05:10 2001 From: thomas.hansenNOSPAMORILLSUEYOURASS at entermatch.com (Thomas Hansen) Date: Fri, 8 Jun 2001 15:05:10 +0200 Subject: best language for 3D manipulation over web ? References: <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3B1B1825.8109BA83@lmf.ericsson.se> <2v4ohtgldvce84sn87kh1eg1lnes37getq@4ax.com> <3B1C9E65.B73A4FE@lmf.ericsson.se> <3B1DFD87.F3BFDB57@lmf.ericsson.se> <9fpra3$352$1@oslo-nntp.eunet.no> <3B2083A5.15B40637@lmf.ericsson.se> Message-ID: <9fqi1i$dsq$1@oslo-nntp.eunet.no> "Attila Feher" wrote in message news:3B2083A5.15B40637 at lmf.ericsson.se... > Thomas Hansen wrote: > > > > > >> Every user should have his/her own registry (and not just a sub-tree) > > > > > > > > TOTALLY agreed. > > > > > > See, we can agree to many different things ^__^ > > > > > > > Not possible unless you want to install a billion ActiveX/COM components x > > times where x is the number of users on that computer... > > Due to bad design... > > A Might be, but if every user were supposed to have a completely custom registry, and info about COM servers were supposed to be stuffed in that registry, it wouldn't be possible to have their own version of the registry without multiple install of COM servers... From xyzmats at laplaza.org Sat Jun 9 16:18:20 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Sat, 09 Jun 2001 20:18:20 GMT Subject: Has anyone used UML? References: <9flodi$32m$1@brokaw.wa.com> Message-ID: <3b228485.13884244@news.laplaza.org> On 6 Jun 2001 17:14:26 GMT, elf at halcyon.com (Elf Sternberg) wrote: >In article > Harald Hanche-Olsen writes: > >>+ Tim Churches : > >>| No experience (I am in a similar situation to you wrt UML), just >>| some advice: don't buy the O'Reilly book 'UML in a Nutshell' - it is >>| the only O'Reilly title I have encountered which is truly woeful >>| (most are quite good). > >>Hmm. Has it occured to you that this might be a reflection on UML >>rather than on the book per se? > > No, it's true. The UML book by O'Reilly is atrocious. The >author tries *so hard* to convince the reader that UML is not about >modelling programs but about modelling "business practices" that he goes >overboard avoiding programming examples. The author also seems to >introduce topics at random without going through the process of actually >creating a model for the user to use. > > The big problem I have with UML is that it's owned, lock, stock >and barrell, by Rational Rose. Every book I have seen on the subject >cheerleads Rational Rose products and makes it sound like, "yes, you can >do it without Rational Rose, but you can also build a computer with >tinkertoys. Why do that when we'll give your our >superduperdeluxeUMLpackage for only $79,999.95?" Yes, it's kind of interesting that way. Three of the main practitioners of OO methodologies and modeling strategies all ended up working for Rational, leaving them with the odd situation of having the proponents of three different modelling schemes on staff. Clearly that's a problem they needed to solve, and along the way, the solution has become a standard, not that that's a bad thing for the rest of us either, but it seems to be something that benefits Rational most of all... on the other hand, it may be that Rational Rose really is "that damn good" (personally, I have zero experience with it). Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From victor at prodigy.net Tue Jun 12 15:21:06 2001 From: victor at prodigy.net (Victor Muslin) Date: Tue, 12 Jun 2001 19:21:06 GMT Subject: xml parser memory leak??? Message-ID: <3b266a66.1651006521@localhost> Using Python 2.1 on Windows 2000 platform. The following program produces a HUGE memory leak, but only when the parsed request is malformed. Unfortunately, when the request is malformed it is not possible to unlink dom for the deallocation (i.e. "dom.unlink()" inside except clause), because dom is undefined. Any suggestions? TIA import xml.dom.minidom good = 'yada yada yada' bad = 'yada yada yada' for i in range(2000): try: dom = xml.dom.minidom.parseString(bad) dom.unlink() except xml.sax._exceptions.SAXParseException, e: pass From scarblac at pino.selwerd.nl Mon Jun 25 11:01:00 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 25 Jun 2001 15:01:00 GMT Subject: Nested Scopes Question (exec) References: Message-ID: Rainer Deyke wrote in comp.lang.python: > "Ryan LeCompte" wrote in message > news:mailman.993417398.9618.python-list at python.org... > > P.S. --- Aren't the following two calls the same: > > > > exec "print 'hello'" > > exec "print 'hello'" in globals(), locals() > > No. Modifying the dictionary returned from 'locals' does not change the > bindings of local names. Except when it does, of course (mainly outside of functions I believe, but in general the result is undefined). -- Remco Gerlich From MarkH at ActiveState.com Sat Jun 9 02:21:36 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sat, 09 Jun 2001 06:21:36 GMT Subject: Error connecting to COMServer References: <7049ba55.0106080434.1bcbc8d2@posting.google.com> Message-ID: <3B21C08F.8080905@ActiveState.com> Mike M?ller wrote: > > Dim Adder As New AddingMachine > It appears the ProgID of the object is simply "AddingMachine" >>>>from win32com.client import Dispatch >>>>a = Dispatch("Adder.AddingMachine") Try just using "AddingMachine". > Can I conclude anything if I look into at the file generated by COM > Makepy? Why not open it and see :) You should find some generated comments telling you the correct Prog ID to use for all the objects in the library. Mark. From graham at coms.com Wed Jun 20 06:42:36 2001 From: graham at coms.com (Graham Ashton) Date: Wed, 20 Jun 2001 11:42:36 +0100 Subject: Class destructors References: <9gpu9t$7e6$1@norfair.nerim.net> Message-ID: In article <9gpu9t$7e6$1 at norfair.nerim.net>, "Gilles Lenfant" wrote: > Just add a "__del__(self):" method in your class to make a custom > cleanup (close file, socket...). > > It's perhaps what you need. > More info at... > http://www.python.org/doc/current/ref/customization.html Ah, thanks. Perhaps I mis-interpreted the tutorial when it said: >> "There are no special constructors or destructors." In other words, perhaps I shouldn't have ignore the word "special". -- Graham From mcfletch at home.com Sun Jun 10 01:34:03 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Sun, 10 Jun 2001 01:34:03 -0400 Subject: extracting hex mant+exp from double? In-Reply-To: Message-ID: <000301c0f16e$f66a92d0$a9807018@cr706570a> It's a bleeding anonymous magic variable man! Who let that into the language! The variable is _magic_ I say. Wizardry! Sorcery! Appearing without explicit assignment! Pact-with-the-devil-and-dancing-at-midnight-curses-and-hexes! Spawn-of-PERL! Magic, I say! [I spent 2 minutes trying to figure out why you were translating 0, what language you were using (base-2-eese?), and what special meaning 0 had for translation tables. How did I miss something so... icky... getting added?] Ick, Mike -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Tim Peters Sent: June 10, 2001 00:13 To: python-list at python.org Subject: RE: extracting hex mant+exp from double? ... >>> math.frexp(.1) (0.80000000000000004, -3) >>> m = _[0] ... From johnbabhorsspam at donotspampeakaudio.com Thu Jun 7 18:11:11 2001 From: johnbabhorsspam at donotspampeakaudio.com (JohnB) Date: Thu, 7 Jun 2001 16:11:11 -0600 Subject: ActivePython and WSH problem Message-ID: I installed ActivePython under NT and believe that the following .wsf file should work: However, on running it, the following error is displayed "...pytest.wsf(6, 14) Windows Script Host: The value for the attribute is not valid : language". I've seen it claimed on the net that this should work, so I suspect my ActivePython install didn't register something as a script engine for Windows Scripting Host, or I'm doing something stupid. Any ideas? Thanks in advance, -- JohnB johnbabhorsspam at donotspampeakaudio.com From tim.one at home.com Fri Jun 15 17:05:02 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 15 Jun 2001 17:05:02 -0400 Subject: [Python-iterators] RE: PEP 255: Simple Generators In-Reply-To: Message-ID: [Tim] > For a very simple example, > > def genid_func(i): > while 1: > yield i > i += 1 > > getid = genid(5).next Make that line getid = genid_func(5).next instead. It was correct when I posted it, but the PSU Ministry of Bot Oversi From qrczak at knm.org.pl Thu Jun 21 13:00:07 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 21 Jun 2001 17:00:07 GMT Subject: nested classes References: <3B2E2D3A.75F329D@sympatico.ca> <9glchv$kcm$1@plutonium.compulink.co.uk> <3B2E4725.535AB18E@sympatico.ca> <3b2e8989.32036776@news.laplaza.org> Message-ID: Mon, 18 Jun 2001 23:07:07 GMT, Mats Wichmann pisze: > Java and C++ are compiled. The class definition is instructions to > the compiler, and can be self-referential, because the /reference/ is > not going to happen until the class is loaded - no inconsistency. Being compiled is not necessary to be able to self-reference everything. Haskell and Clean are usually compiled, but when they are interpreted, they work the same way: because they use lazy evaluation, it's normal to have every name defined in a group visible in all the bodies. This applies to all value definitions, not only to functions, even if it's nonsensical, i.e. 'let x = y+1; y = x+1 in x' is only a runtime error or an infinite loop. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From see at my.signature Wed Jun 20 00:12:45 2001 From: see at my.signature (Greg Ewing) Date: Wed, 20 Jun 2001 16:12:45 +1200 Subject: nested classes References: <6957F6A694B49A4096F7CFD0D900042F27D493@admin56.narex.com> Message-ID: <3B3022BD.1709500A@my.signature> Skip Montanaro wrote: > > When defining a class, the code within the class's scope is executed > immediately, before a class object has been bound to the class's name. But it *could* be done differently. An empty class object could be created, bound to the name, and then methods added to it. This would be analogous to what is done with modules. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From scarblac at pino.selwerd.nl Wed Jun 20 04:43:32 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 20 Jun 2001 08:43:32 GMT Subject: How do I access the last "un-caught" variable in the interpreter? References: <39503ed5.0106191912.5b054b42@posting.google.com> Message-ID: Dan Moskowitz wrote in comp.lang.python: > Pretty simple question: > > >>> 2+2 > 4 > >>> # can i access the 4 if i didn't catch it in a var? > > Is there some variable for the last result returned from the > interpreter? I thought that I used to know how to do it, but I've > forgotten. Anyone know? > > interpreter.last ? >>> _ 4 (only works interactively) -- Remco Gerlich From gmcm at hypernet.com Wed Jun 20 23:01:22 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 21 Jun 2001 03:01:22 GMT Subject: Was this import behaviour planned...? References: <3B314800.EA4F0A7E@pfortin.com> Message-ID: <90C6E55D7gmcmhypernetcom@199.171.54.154> Pierre Fortin wrote: >The core question: if "import foo.bar.baz" really means >"foo/bar/baz...", shouldn't import ignore any files such as ./foo.py, >foo/bar.py, etc....? But it doesn't. It means "find something in foo named bar, then find something in that named baz". foo/bar/baz.py is just one implementation, and it requires foo/__init__.py and foo/bar/__init__.py. But foo.bar could be a module, and baz an object in foo.bar, or even worse. Or maybe they're modules, but not in your filesystem. Planned? No way. Packages were introduced after someone hacked them up with a module name "ni" and lots of people started using it 'cause one flat namespace was just too restrictive. - Gordon From pbrian at demon.net Mon Jun 25 06:47:35 2001 From: pbrian at demon.net (Paul Brian) Date: Mon, 25 Jun 2001 11:47:35 +0100 Subject: ActiveX Controls in Python References: <4dfd15be.0106242017.36042c10@posting.google.com> Message-ID: <993466066.23152.0.nnrp-08.c1c3e0bb@news.demon.co.uk> Python has some very good COM interfaces, written by Mark Hammond and detailed well here: http://www.python.org/windows/ http://starship.python.net/crew/mhammond/ Avaialble here: http://aspn.activestate.com/ASPN/Downloads/ActivePython/Extensions/Win32all Basically, pyhton is able to act as a COM server and client depending on the choice of module you import from Win32All...its incredibly simple - honest. cheers pbrian David White wrote in message news:4dfd15be.0106242017.36042c10 at posting.google.com... > I'm a C++ programmer whose considering using Python to prototype an > ActiveX control. However, I can't seem to find any samples or > resources on implementing ActiveX controls in Python. Would anyone be > able to give me any pointers on how to do it? > > Also, the control will have to make heavy use of a grid control, what > grid controls are available that have Python interfaces? > > Help would be appreciated. > > David White > Programmer > WebLink Pty Ltd From tdickenson at devmail.geminidataloggers.co.uk Thu Jun 21 11:02:54 2001 From: tdickenson at devmail.geminidataloggers.co.uk (Toby Dickenson) Date: Thu, 21 Jun 2001 16:02:54 +0100 Subject: [Python-iterators] PEP 255 - BDFL Pronouncement: 'def' it stays In-Reply-To: <200106211432.f5LEWeA03163@odiug.digicool.com> References: <200106211432.f5LEWeA03163@odiug.digicool.com> Message-ID: On Thu, 21 Jun 2001 10:32:40 -0400, Guido van Rossum wrote: > Another idea might be to somehow continue the frame with an >exception at this point -- but I don't have a clue what exception >would be appropriate (StopIteration isn't because it goes in the other >direction) Im sure any exception is appropriate there. What about restarting the frame as if the 'yield' had been followed a 'return'? Toby Dickenson tdickenson at geminidataloggers.com From glenfant.nospam at bigfoot.com Tue Jun 19 07:34:07 2001 From: glenfant.nospam at bigfoot.com (Gilles Lenfant) Date: Tue, 19 Jun 2001 13:34:07 +0200 Subject: Getting all client http headers References: <3B2F1A51.EC21BD1C@nokia.com> <3B2F0DF6.EB339753@stroeder.com> <3B2F1C80.DF4CEB85@nokia.com> Message-ID: <9gnd23$ova$1@norfair.nerim.net> Just have a look to the test() function of the cgi.py and all will be clear... In addition, just create the script below in any cgi directory and run it through a browser. After this, all should be clear in your mind. import cgi cgi.test() Note you cant provide arguments to this script through GET or POST forms and see your form data. "Joonas Paalasmaa" a ?crit dans le message news: 3B2F1C80.DF4CEB85 at nokia.com... > Michael Str?der wrote: > > > > Joonas Paalasmaa wrote: > > > > > > How can I get all client http headers in python. > > > Can I use cgi-module? > > > > Assuming that you implement a simple CGI-BIN program you have to > > stick to the CGI-BIN environment vars which contain some of the HTTP > > header information (usually prefix HTTP_). > > Do you mean os.environ? > Does it contain ALL headers? From victor at prodigy.net Thu Jun 14 17:36:58 2001 From: victor at prodigy.net (Victor Muslin) Date: Thu, 14 Jun 2001 21:36:58 GMT Subject: sorting values in dict References: Message-ID: <3b292d23.1831931958@localhost> This may not be the shortest or most efficient, but it does the trick: a={'a':9,'b':8,'c':7} l=[] for k,v in a.items(): l.append((v,k)) l.sort() for v,k in l: print v,k This should produce: 7 c 8 b 9 a On Thu, 14 Jun 2001 23:24:11 +0200, Jeroen Wolff wrote: >I want to display a dict sorted by value. > >This is my dict: > >total={} >srcAS = a string which i wil take from a file.... >Bytes = also a string which i wil take from a file... > >if total.has_key(srcAS): > total[srcAS] = total[srcAS] + string.atoi(Bytes) >else: > total[srcAS] = string.atoi(Bytes) > > >This is how i sort it by keys: > >keys = total.keys() >keys.sort() >for n in keys: > print n, total[n] > > >But i would like to have is sorted (on screen) by value.... > >Is this possible? > >Jeroen From qrczak at knm.org.pl Mon Jun 25 15:05:53 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 25 Jun 2001 19:05:53 GMT Subject: Defining accessor methods References: Message-ID: Mon, 25 Jun 2001 09:48:23 +0100, Graham Ashton pisze: > def my_attribute(self, val=None): > The obvious problem with the above is that you can't use it to set an > attribute to None. The generic solution to such problems is to use the following syntax instead of default values of parameters: def my_attribute(self, *args): Extra arguments are available in the tuple args. A downside is that you should implement checking for the right number of arguments yourself, i.e. somebody might call obj.my_attribute(x,y,z) and it's your business to detect this. Arbitrary meaning to keyword arguments is specified thus: def my_attribute(self, *args, **kwargs) Note that it's impossible to detect the order of keyword arguments... -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From SBrunning at trisystems.co.uk Fri Jun 22 03:15:35 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Fri, 22 Jun 2001 08:15:35 +0100 Subject: A recommendation on programming tutorials? Message-ID: <31575A892FF6D1118F5800600846864D78BD86@intrepid> > From: CCRazy1 at msn.com [SMTP:CCRazy1 at msn.com] > I've just started studying the Python programming language 3 days ago. > Though I've already found a tutorial on Python programming and am > fully aware of the tutorial published with the Python Compiler, I > would appreciate further recommendation on online reading regarding > Python Programming. Thanks in advance. If you haven't programmed before, check out Alan Gauld's 'Learning to Program' at . This teaches Python to complete beginners. If you have programmed before, try 'Dive into Python at . Links to *loads* of tutorials can be found at . And don't forget the Python tutor mailing list, at . Well worth joining if you are learning Python. Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From mrossland at yahoo.com Tue Jun 26 12:57:42 2001 From: mrossland at yahoo.com (Mark Ross) Date: Tue, 26 Jun 2001 09:57:42 -0700 (PDT) Subject: (no subject) Message-ID: <20010626165742.18488.qmail@web14703.mail.yahoo.com> __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ From fredrik at pythonware.com Thu Jun 14 06:09:13 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 14 Jun 2001 10:09:13 GMT Subject: PEP 259: Revise to remove context-driven magic from print References: <486de2.0106131406.5c0cbef9@posting.google.com> Message-ID: Robin Thomas wrote: > always seemed to me quite a lame thing > I have never exploited that feature > print is a novice feature > lazy scripts can avoid code breakage with minor edits > the softspace crap. is this a joke of some kind? if not, it's clearly the most ignorant and arrogant PEP proposal I've ever seen. From edcjones at erols.com Wed Jun 6 00:14:25 2001 From: edcjones at erols.com (Edward C. Jones) Date: Wed, 06 Jun 2001 00:14:25 -0400 Subject: C parser with readable output? Message-ID: <3B1DAE21.7C971571@erols.com> Does anyone know of a good, easy to use, C parser that outputs a human readable parse tree? Thanks Ed Jones From davidw at weblink.com.au Tue Jun 26 22:49:44 2001 From: davidw at weblink.com.au (David White) Date: 26 Jun 2001 19:49:44 -0700 Subject: ActiveX Controls in Python References: Message-ID: <4dfd15be.0106261849.27d2a80d@posting.google.com> "Bill Bell" wrote in message news:... > davidw at weblink.com.au (David White) wrote, in part: > > I'm really hoping I can do the [hierarchial grid] prototype in > > Python, because I don't want to even think about touching Visual > > Basic. > > I ~know~ whatcha mean! [snip] > > 2. So host the ActiveX in Python code written with the aid of > wxPython. I must admit that I'm not terribly familiar with Python's windows extensions, and so I'm not sure I understand your solution properly. Please correct me if I say something that betrays a misunderstanding... The main problem I see is that I was planning to use MFC directly, not wxWindows. I'm not very familiar with wxWindows, but I understand it's interface is very different from that of MFC, and that it can't do some things MFC can do, as it is a portable library, and can only supply the common subset of functionality that is available on various platforms. Is this correct? Since I'll be doing the final product using MFC, I was hoping to do the prototype using Python's MFC bindings; also, I haven't used wxWindows before, and time is going to be quite an issue - so it'd be better to use MFC due to my familiarity with it. David White Programmer Weblink Pty Ltd > > Overall, make C++ code in the ActiveX as simple as possible and > favour development in Python. > > This topic interests me and I'd value your opinion. > > Bill > > Bill Bell, Software Developer From dwig at advancedmp.net Thu Jun 7 12:49:36 2001 From: dwig at advancedmp.net (Don Dwiggins) Date: 07 Jun 2001 09:49:36 -0700 Subject: Why should i use python if i can use java In-Reply-To: "Alex Martelli"'s message of "Thu, 7 Jun 2001 11:19:50 +0200" References: <9fngvl011jg@enews2.newsguy.com> Message-ID: Alex Martelli quotes Glyph Lefkowitz: >> > an elegant way of implementing singletons (or does it? anyone?) >> >> Aah, the singleton. Global variables for the new millennium. First of >> all, the singleton "pattern" is usually a bad idea. If you have a class > *AMEN, HALLELUJAH*! This makes two of us sharing this dislike > for the Singleton Design Pattern, so I'm not a Singleton any > more -- see, that's one typical issue with Singleton DP, what > starts out as a singleton often becomes not one:-). According to the GOF "Applicability" section on Singleton: Use the Singleton pattern when - there must be exactly one instance of a class, and it must be accessible to clients from a well-known access point. - when the sole instance should be extensible by subclassing, and clients should be able to use an extended instance without modifying their code. If you take the whole description of the Singleton pattern seriously, to say that you "hate" the pattern would seem to mean that you don't believe that programs should ever need something that satisfies these criteria. Is that true for both of you? Whether it is or not, I'd like to hear a bit more explanation for the strong emotional reaction to the pattern. (I suppose I should mention that I've only used the pattern once, in a C++ program, to hold a transformed version of the parameter list to the program. It seemed like a reasonable usage -- although I didn't need subclassing -- since the various parameters were accessed in a variety of places in the code, and needed some interpretation, validation, and processing before use. In Smalltalk I probably would have used a class that was never instantiated -- a "system-supplied" singleton.) -- Don Dwiggins "Solvitur Ambulando" Advanced MP Technology dwig at advancedmp.net From scarblac at pino.selwerd.nl Thu Jun 14 02:30:02 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 14 Jun 2001 06:30:02 GMT Subject: binary file comparison with the md5 module References: <9g8ahr$s6t$1@bob.news.rcn.net> Message-ID: Christian Reyes wrote in comp.lang.python: > I'm trying to write a script that takes two binary files and returns whether > or not their data is completely matching. > > One of my peers suggested that an efficient way to do this would be to run > the md5 algorithm on each file and then compare the resultant output. Since > md5 returns a unique 128-bit checksum of it's input, this should > theoretically work. > > The problem i'm having is with reading the binary file in as a string. > > I tried opening the file with the built-in python open command, and then > reading the contents of the file into a buffer. But I think my problem is > that when I read the binary file into a buffer, the contents get tweaked > somehow. I would expect the print statement to give me some huge string of > gibberish but instead what I get is 'RIFFnap'. Regardless of what size the > file is. I'll try to read in a 5 meg file and all I get when I try to print > the buffer is some variation of 'RIFFxxx' (where xxx is any arbitrary set of > 3 characters). > > >>> x = open('d:\\binary.wav') You need to open the file in binary mode: x = open("d:\\binary.wav", "rb") -- Remco Gerlich From thinkit8 at lycos.com Tue Jun 12 19:31:40 2001 From: thinkit8 at lycos.com (thinkit) Date: 12 Jun 2001 16:31:40 -0700 Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> <3b266270$1_7@news5.uncensored-news.com> Message-ID: <9g68os0cd9@drn.newsguy.com> In article <3b266270$1_7 at news5.uncensored-news.com>, Doug says... > >thinkit wrote: > >> humans should use a power of 2 as a base. this is more logical because it >> synchs with binary, which is at the very heart of logic--true and false. >> it is more natural perhaps, to use decimal--but logic should, and will, >> win out. >> >> >Why shouldn't I use whatever base I find convenient at the moment: 2, 10, >16, 60.... If I need to communicate a number to you, my software agent or >PDA should convert it to whatever units you are using at the moment. Note >that the movement to convert the U.S. to the metric system is fading away. >If I need to give you a measurement in I can convert it to cm, or cubits, >or whatever. > >Instead of having a single monolithic number base, or measurement system, >(or programming language) why shouldn't we have hundreds or thousands or >millions? We've got these computers now, we don't need to count on our >fingers or measure with our feets. >-- >Doug Fort >Senior Meat Manager >Downright Software LLC >http://www.downright.com > >______________________________________________________________________ >Posted Via Uncensored-News.Com - Still Only $9.95 - >http://www.uncensored-news.com >With Seven Servers In California And Texas - The Worlds Uncensored News Source i should quote you on that..."we don't need to count on your fingers". in my quest to convert the world to hexadecimal, i've heard the "you have fingers for decimal" argument countless times! you present a different argument than most. i'm not against using all the bases we might want...but we all need a general purpose base. decimal is that now, and hexadecimal would make a better choice. From johnroth at ameritech.net Mon Jun 25 14:12:23 2001 From: johnroth at ameritech.net (John Roth) Date: Mon, 25 Jun 2001 11:12:23 -0700 Subject: any idea how i could test if a variable is a floating point number? References: <9h76io$ht3$1@neptunium.btinternet.com> Message-ID: "Gaz" wrote in message news:9h76io$ht3$1 at neptunium.btinternet.com... > any idea how i could test if a variable is a floating point number? > > gaz. > > import types if type(foo) == types.FloatType: Check the spelling - this is from yesterday's memory John Roth From mmueller at dgfz.de Wed Jun 13 06:37:57 2001 From: mmueller at dgfz.de (=?ISO-8859-1?Q?Mike_M=FCller?=) Date: 13 Jun 2001 03:37:57 -0700 Subject: COM memory limitations? Message-ID: <7049ba55.0106130237.2e1af30c@posting.google.com> Hi, I built a in process COM server (DLL) which is accessed by Python via win32com.client.Dispatch. Everything works fine as along as the arrays created in the server are small. Only if I use bigger arrays there is a problem of variable values being undefined (loosing the assigned value that is supposed to stay and does with small arrays). There seems to be an upper limit of memory for the server. Is this a problem of the client (i.e. Python) or rather how the server is set up? If Python restricts the memory, how can I increase the memory that it uses for the server? Thanks Mike From grante at visi.com Mon Jun 11 16:09:35 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 11 Jun 2001 20:09:35 GMT Subject: Newbie References: <20010611151900.11318.00004174@ng-mp1.aol.com> Message-ID: <3A9V6.11832$Dd5.3141345@ruti.visi.com> In article , Kurt B. Kaiser wrote: >www.python.org : check out "Top Documentation Links", > especially the tutorials. Then, > >Book: David Beazley, "Python Essential Reference" Is the second edition out yet? -- Grant Edwards grante Yow! OVER the at underpass! UNDER the visi.com overpass! Around the FUTURE and BEYOND REPAIR!! From aleaxit at yahoo.com Wed Jun 6 17:33:56 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 6 Jun 2001 23:33:56 +0200 Subject: Generating Multiple Class Instances References: <3B1E9271.B05CC4E3@fnal.gov> Message-ID: <9fm7nc046k@enews1.newsguy.com> "Julie Torborg" wrote in message news:3B1E9271.B05CC4E3 at fnal.gov... > I'm no wiz at OOP, but I have the following problem: > > I have a list of some hundreds of items, each of which has several > attributes,What I want to do is peg each of the values to the list item > and move it around my program. This seems like the perfect opportunity > to take advantage of the OOP aspect of Python by setting up a class, but Maybe. If the attributes are a simple tuple, tuples may be simpler and thus better than classes for your purpose. Anyway... > I can't create or use instances without hard-wiring it for every list > item. What I want to do is: > > class Quark: > def __init__(self): > self.color=getcolor() > self.mass=getmass() > > flavor=['up', 'down', 'strange', 'charm', 'top', 'bottom'] > for each in flavor: > each=Quark() You want to *rebind* a loop variable in the loop body? You can, but of course it will be bound again on the very next leg of the loop -- so it's a pretty futile exercise. Maybe you want to use string 'each' as the name of an attribute of some object? Then it's easy: class Buncho: pass bunch=Buncho() for each in flavor: setattr(bunch, flavor, Quark()) though I'm not surer how getcolor() and getmass() are supposed to get their values -- are you SURE you don't mean something like: class Quark: def __init__(self, name): self.color=getcolor(name) self.mass=getmass(name) # and maybe self.name = name ? In this case the for body would be: setattr(bunch, flavor, Quark(flavor)) But anyway I'm not clear how this generalizes to HUNDREDS of items... still, it would work, though how you'd get your item names I don't know. > ###Then later: > for each in flavor: > print each.color In the above approach it would be for each in flavor: print getattr(bunch,each).color Of course it *WOULD* be marginally neater to have instead: bunch={} and instead of the setattr and getattr you would have bunch[flavor] = Quark(flavor) and print bunch[flavor].color but if you do want bunch to be an instance object instead of a dictionary, it ain't hard, just a bit less convenient. Or maybe you want a list...: for ieach in range(len(flavor)): flavor[ieach] = Quark(flavor[ieach]) and then later: for each in flavor print each.color WOULD work. Personally, I'd far prefer this one, btw. > ###What I'm relegated to doing is: > > up=Quark() > down=Quark() > strange=Quark()... > > print up.color > print down.color > print strange.color... I'm still unsure about how the getcolor() and getmass() global functions are supposed to guess at the quark's characteristics without getting the quark name as an argument, of course. But anyway, local variables are the least appropriate ways to keep so many things with systematic names, of course. List items, dictionary items, instance attributes (basically just syntax sugar for dictionary items), are all better here. > Which works, but with hundreds of list items, gets messy in a hurry. > I've also tried messing around with using something that looks more like > quark=Quark() several times, but then all the info stored in the > previous instance gets obliterated. I've also tried using lists and > dictionaries, but they're bulky In what sense? In the above examples the suggestions I give to use dictionaries and lists of instances seem quite un-bulky. > and what's the point of using an OOP > language if there's no additional functionality or elegance? You have a multi-paradigm language at hand, you must learn to use the right construct for each job. Each Quark object is quite well modeled as an instance object, apparently, but the issue is, where do we keep the references to those instances. Not in local variables of course -- that's got nothing to do with OOP!-). Another separate instance with the only role of bunching up the quarks can work, as I've shown, but IMHO is not optimal. Containers (lists and dictionaries) are good ways to contain stuff (here, e.g., contain instances, if you do want to model each Quark by an instance, which might well be optimal, depending). You may want to write your own containers by OOP, but often using the existing ones is going to be best, they're simple and speedy (anything BUT bulky!-). Alex From mark21rowe at yahoo.com Wed Jun 20 03:47:46 2001 From: mark21rowe at yahoo.com (Mark Rowe) Date: Wed, 20 Jun 2001 19:47:46 +1200 Subject: Embedding Message-ID: <3b305ce7@news.actrix.gen.nz> Hey all, Just been fiddling round with embedding Python in a C program, and one thing has me stuck. I would like the user to be able to enter some python code containing functions, then at a later point execute one of these functions by name. I'm not really sure what i need to do for this to work Mark From scarblac at pino.selwerd.nl Sun Jun 17 05:54:56 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 17 Jun 2001 09:54:56 GMT Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> <9gclvm02tte@enews1.newsguy.com> <9gdspv$324$0@216.39.170.247> Message-ID: David LeBlanc wrote in comp.lang.python: > you mistake a simple example for how something would of necessity be > done. it could just as esasily be "alias true : not none and not 0" > > Of course you would prefer your method... true = not None true = not 0 true = not None and not 0 are all completely equal to true = 1 So I'm completely confused about what you want with that statement. -- Remco Gerlich From johnroth at ameritech.net Thu Jun 7 13:39:26 2001 From: johnroth at ameritech.net (John Roth) Date: Thu, 7 Jun 2001 10:39:26 -0700 Subject: Problem 2.1 - Menus hang command line Message-ID: I've been trying to put together what should be a simple user interface with a few entry fields and some drop down selection boxes implemented as menu buttons. The menu entries seem to fire when they are added to the menu, and not when they are selected, which is exactly the opposite of what I would expect. In addition, upon exit (either the first or second time), the command line hangs, and I have to ctl-alt-delete to get out of it. It doesn't seem to matter if the interface actually manifests or if the test goes on a syntax error: it still hangs the DOS box. Python 2.1, Windows 98 second edition. Code is: # there are two major classes: ADateTime and ADateTimeUI. from Tkinter import * class ADateTimeUI: def __init__(self, parent, pADateTime): parent.title("Enter Date and Time") # This goes away eventually rownum = 0 self.CalType = "Not Set" # default for testing Label(parent, text="Date:").grid(col=0, row=rownum) self.DateWidget = Entry(parent) self.DateWidget.grid(col=1, row = rownum, sticky=E+W) self.CalType = Menubutton(parent, text = "Gregorian") self.CalType.grid(col=2, row = rownum, sticky=E+W) ctMenu = Menu(self.CalType, tearoff=0) self.CalType.config(menu=ctMenu) ctMenu.add_command(label="Gregorian", command=self.CalCmd("Gregorian")) print ctMenu.config() ctMenu.add_command(label="Julian", command=self.CalCmd("Julian")) ctMenu.add_command(label="BCE", command=self.CalCmd("BCE")) ctMenu.add_command(label="AD", command=self.CalCmd("AD")) ctMenu.add_command(label="CE", command=self.CalCmd("CE")) ctMenu.add_command(label="NS", command=self.CalCmd("NS")) ctMenu.add_command(label="OS", command=self.CalCmd("OS")) rownum = 1 Label(parent, text="Time:").grid(col=0, row=rownum) self.TimeWidget = Entry(parent) self.TimeWidget.grid(col=1, row = rownum, sticky=E+W) AMPMWidget = Label(parent, text="AMPM?") AMPMWidget.grid(col=2, row=rownum) rownum = 2 Label(parent, text="Zone:").grid(col=0, row=rownum) self.ZoneWidget = Entry(parent) self.ZoneWidget.grid(col=1, row = rownum, sticky = E+W) TimeTypeWidget = Label(parent, text = "GMT") TimeTypeWidget.grid(col = 2, row=rownum) parent.columnconfigure(0, weight = 0) parent.columnconfigure(1, weight = 1) parent.columnconfigure(2, weight = 1) def CalCmd(self, which): self.CalType = which print which # might want to recalculate here, depending on if the date has been # filled in yet. If it has, then we should recalcualte the julian date, # in case we're displaying it. if __name__ == "__main__": box = Tk() it = ADateTimeUI(box, None) box.title("ADateTime Dialog") mainloop() print it.CalType ---End of Code--- By the way - I tried OptionMenu first, since it looked like exactly what I wanted, and it didn't work at all. The button didn't have anything printed on it. John H. Roth Jr. From wware at world.std.com Fri Jun 8 22:39:06 2001 From: wware at world.std.com (Will Ware) Date: Sat, 9 Jun 2001 02:39:06 GMT Subject: Python Shareware? References: Message-ID: Jian Chen (jchen at 263.net) wrote: > I am considering writing some shareware in python... > Is there any good shareware in python? ... > How can I lock/secure my python shareware? Stephen King once experimented with a new way to distribute his writing. He wrote four chapters and posted them on his website, saying that anybody could download them and read them, but he wanted readers to send him a dollar. If 75% of the downloaders sent in a dollar, then he would post the fifth chapter. If 75% of the downloaders of the fifth chapter sent another dollar, he would post the sixth chapter. He would continue doing this until the whole book was published. King's experiment failed, only a few more chapters got posted. He insistied that 75% of his readers had to be honest, and that wasn't realistic. His experiment would have worked if he had changed things in this way. Post the first four chapters as before, and then announce a fixed number of dollars that would make him publish chapter five. Update his website to let people know how close the total gets to the fixed number. When he gets that number of dollars, he posts chapter five on the site, and announces a fixed dollar amount to post chapter six. Keep going til the book is all published. This would mean that he would publish the first four chapters and not get any money, but he could amortize the cost of writing the first four chapters over the dollar amounts for the later chapters. He could publish excerpts of the later chapters as teasers. In the end, he'd get all the money he wanted, and he would have revolutionized publishing, which was really the purpose of the original experiment. He would have published a book and gotten paid for it without the intervention of a publishing house. How does this relate to shareware? Publish an initial version for free and place it in the public domain. Include with it the URL for your website and an announcement that when you receive N hundred dollars in donations, you will fix any reported bugs and add several new features. As you work on the new features, periodically publish test output (not the code itself) as a teaser for the new features. When you've received the N hundred dollars of donations, publish the new code and place it in the public domain. Again announce that you will fix any new bugs and add some more features for some fixed total of donations. Repeat until you are fabulously wealthy. What's new about publishing shareware this way? (1) You don't need to worry about security at all. The code can spread more easily to a larger audience, so the number of people who can send you donations will be larger. (2) Nobody needs to feel guilty for not paying you, and you don't have to put any effort into enforcement. (3) If your program does something interesting, then placing it in the public domain is a contribution to the pool of shared human knowledge. You might not care about this. (4) Publishing your code publicly will help you to become well-known as a programmer so you can have better luck hunting for jobs in the future. (5) As your programming reputation grows, you can ask for larger amounts of donations. People will know your code is good because they can read it for themselves. (6) If Bill Gates had done this, he _still_ would have gotten rich, but he wouldn't have everybody so mad at him all the time. -- -----------------------------------+--------------------- 22nd century: Esperanto, geodesic | Will Ware domes, hovercrafts, metric system | wware at world.std.com From nsp1 at bigian.org Sun Jun 10 11:43:19 2001 From: nsp1 at bigian.org (Ian) Date: Sun, 10 Jun 2001 17:43:19 +0200 Subject: Custom COM interface q. Message-ID: <9g013q$49r$1@news.inter.net.il> Hi, I have COM server for Nokia GSM suite that doesn't support IDispatch. Makepy.py generates file from it's typelib but I don't know how to use custom interfaces from this file and what I should write in the CoCreateInstance function. Thanks, Ian From not.this at seebelow.org Thu Jun 28 09:15:25 2001 From: not.this at seebelow.org (Grant Griffin) Date: Thu, 28 Jun 2001 08:15:25 -0500 Subject: Check out O'Reilly's Open Source Convention Highlights References: <3B3AA82D.1A0FE860@seebelow.org> Message-ID: <3B3B2DED.5303198A@seebelow.org> Andy Todd wrote: > > Grant Griffin wrote in > <3B3AA82D.1A0FE860 at seebelow.org>: > > >Guido van Rossum wrote: > >> > >> I promise this is a one-time ad! Check out the Python track: > >> > >> http://conferences.oreillynet.com/cs/os2001/pub/w/os2001/sessions_pytho > >> n.html > > > >Durn--it's in California. Why aren't these things ever held in the > >Midwest?--it's centrally located, ya' know. > > > >must-be-some-kindda-darn-conspiracy-for-you-East-Cost-folks-to > > -rack-up-frequent-flyer-miles--ly y'rs, > > > >=g2 > > Hummpph, bah humbug. Blimey. > > Time to pull out the atlas again and redefine 'world' from "between-the- > east-coast-and-the-west-coast" to "blimey-its-a-big-ball-type-thing-that- > doesn't-just-stop-when-you-get-to-the-wet-bits" ;-) > > Greetings from far, far, away, > Andy Greetings back, Andy. :-) Hey, who said anything about "world"?... But now that you mention it, the US Midwest *is* pretty centrally located on a "world" basis. as-much-as-anything-else-on-this-sphere--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From pfortin at pfortin.com Wed Jun 20 21:04:00 2001 From: pfortin at pfortin.com (Pierre Fortin) Date: Wed, 20 Jun 2001 21:04:00 -0400 Subject: Was this import behaviour planned...? Message-ID: <3B314800.EA4F0A7E@pfortin.com> The core question: if "import foo.bar.baz" really means "foo/bar/baz...", shouldn't import ignore any files such as ./foo.py, foo/bar.py, etc....? Pierre Nearly 2 weeks ago, I wrote: [snipped] > Compiled 2.1 on Linux Mandrake 7.2 system (incl expat)... > > Yet, when I run a sample script (from > http://www-106.ibm.com/developerworks/xml/library/l-pxml.html?open&l=912,t=grx,p=xpyth )... > > xmlsaxtest.py: > "Simple SAX example, updated for Python 2.0+" > import string > import xml.sax > from xml.sax.handler import * > > it won't even get past the imports... > > Traceback (most recent call last): > File "xmlsaxtest.py", line 3, in ? > import xml.sax > File "xml.py", line 1, in ? > import _xmlplus.parsers.expat > ImportError: No module named _xmlplus.parsers.expat > > Probably missing something obvious/subtle; but... YUP... subtle... Just found that this error was caused by another test file "xml.py" in my test directory. This raises a question: if "import foo.bar.baz" really means "foo/bar/baz...", shouldn't import ignore any files such as ./foo.py, foo/bar.py, etc....? Thanks, Pierre From slobin at ice.ru Fri Jun 8 19:17:39 2001 From: slobin at ice.ru (Cyril Slobin) Date: 8 Jun 2001 16:17:39 -0700 Subject: RS232 support for DOS on 486? References: Message-ID: Oleg Broytmann wrote in message news:... > (DOS, after all, is completely dead, as well as Python for DOS), so I am Nevertheless I have used Python-DX (Python for MS-DOS) in a Win95 dosbox for a very long time - until discovered how to enable readline services in Windows version. And I'm sure it is still possible to compile modern versions of Python with djgpp. Maybe I'll do it as a weekend project... From thomas.wright1 at ntlworld.REMOVETHIS.com Sat Jun 30 16:38:44 2001 From: thomas.wright1 at ntlworld.REMOVETHIS.com (Tom wright) Date: Sat, 30 Jun 2001 21:38:44 +0100 Subject: Python for Windows CE 3.0 Message-ID: Guys n Gals, I have an Compaq Ipaq hand held running Windows CE 3.0 Does any one know of any ports of python to it ? Many thanks Tom From Gareth.McCaughan at pobox.com Sun Jun 17 19:08:02 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Mon, 18 Jun 2001 00:08:02 +0100 Subject: Two minor syntactic proposals References: Message-ID: Roy Katz wrote: > I am interested to know what you find inelegant about the existing > define-a-function-and-bind-it-to-a-class (d-b-c) idiom? > > Look at it this way: The "in .. def" statement's only usable purpose is > to implement something which can already be done.. > > There was a similar proposal to add 'aliasing' to Python with a > "alias X: existingVar" statement, but Alex M. very nicely stated that a > simple '=' is elegant enough. Well, I think Alex was absolutely right about the "alias" statement. I'm not sure what similarity you see here. The inelegance I see with the existing idiom is a matter of verbosity and repetition. You have to say the name of the new function three times (unless you define it with a different name -- "_" or something -- but that is inelegant for more obvious reasons). > With regards to your latter proposal, again: having 'self' as the first > argument is *so* critical. Say class C has a method foo, and > an instance c. When one calls 'c.foo()', the interpreter calls > C.foo(c)'. That is why 'self' is the first argument to a method. Er, yes, I know. If I gave the impression that I don't understand what the "self" parameter means and why it's used, then I screwed up. Sorry. > I suppose.. one could modify the interpreter to allow > statements like these: > > class C: > > def self.x(...): pass # method > def C.x(...): pass # static or class method Um. That's an argument against my proposal, because the way I'd imagined it the second would define an ordinary method in which the instance argument was called "C". If people might think of the proposal as enabling class methods, that would definitely be a problem with it. > but then, 'self' was never a special keyword... Nor was I proposing that it should be one. > (note also that static methods can be implemented in modules instead of in > classes. I like this approach because I hate my CompSci instructors, who > like C++ and /insist/ on being able to define class methods > (imbecilic concept IMHO. print>>^H^H ). But that's just me. In languages where the class is the unit both of encapsulation and of inheritance, class methods make a lot of sense. I prefer languages like Python and Common Lisp where the concepts are separated, but it's not a no-brainer. -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From aleaxit at yahoo.com Wed Jun 13 11:29:05 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 13 Jun 2001 17:29:05 +0200 Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: <9g4nec0cnr@enews2.newsguy.com> <3b266453.317327753@wa.news.verio.net> <3b2768b5.1425762@nntp.sprynet.com> Message-ID: <9g80s302q1f@enews1.newsguy.com> "David C. Ullrich" wrote in message news:3b2768b5.1425762 at nntp.sprynet.com... ... > >I like orthogonality too. ... > So just out of curiosity: Roughly what do you > mean by "orthogonality" above? http://www.dictionary.com/cgi-bin/dict.pl?term=orthogonal suggests (after several other meanings): """ orthogonal Mutually independent; well separated; sometimes, irrelevant to. Used in a generalisation of its mathematical meaning to describe sets of primitives or capabilities that, like a vector basis in geometry, span the entire "capability space" of the system and are in some sense non-overlapping or mutually independent. In logic, the set of operators "not" and "or" is orthogonal, but the set "nand", "or", and "not" is not (because any one of these can be expressed in terms of the others). Also used in comments on human discourse: "This may be orthogonal to the discussion, but ..." See also orthogonal instruction set. [Jargon File] (1994-12-21) Source: The Free On-line Dictionary of Computing, ? 1993-2001 Denis Howe """ Alex From lijil at nortelnetworks.com Tue Jun 5 10:06:50 2001 From: lijil at nortelnetworks.com (JAY) Date: Tue, 5 Jun 2001 10:06:50 -0400 Subject: How to put a scrollbar to a frame? Message-ID: <9fip1t$5js$1@bcarh8ab.ca.nortel.com> Hi there, I am pretty new to python. My python script makes a frame in a widget to display some messages (UNIX system), it works fine. However, if the message gets too long, the frame will be extended and make the whole widget bigger than screen. To solve the problem, I want to put a scrollbar to the frame for the messages so that it's size won't change. But I don't know how. Could anybody tell me how to do it? Thank you in advance, JAY From jmarshal at mathworks.com Fri Jun 8 16:45:08 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 8 Jun 2001 20:45:08 GMT Subject: return from finally clause References: <9fr8u3$gj9$01$1@news.t-online.com> Message-ID: <9frdgk$pnd$1@news.mathworks.com> "J?rgen Hermann" wrote: > That means that if you (accidently?) return within a finally clause, you > effectively eat the exception. This should be documented, or fixed. That's unpleasant. I hope it's a bug. From giannozzo at arca.net Sun Jun 10 15:26:50 2001 From: giannozzo at arca.net (Maurizio Manetti) Date: Sun, 10 Jun 2001 21:26:50 +0200 Subject: Python Imaging Library on Win32 Message-ID: <3B23C9FA.D527D9D3@arca.net> HI, I am learning to code with Python both on platform Linux and Windows. I've got some problem with PIL on Windows. When I type "import Image" it works. But for every not dull operation I try to do with that module I get the following error: ImportError: The _imaging C module is not installed Where I have to put libraries? And which is the _imaging C module? Is it the _imaging.dll file? Are there some other file I have to install on my system? Thank you. Maurizio Manetti From clarence at netlojix.com Sun Jun 17 02:55:16 2001 From: clarence at netlojix.com (Clarence Gardner) Date: Sun, 17 Jun 2001 06:55:16 GMT Subject: Two minor syntactic proposals References: Message-ID: In article , Gareth.McCaughan at pobox.com (Gareth McCaughan) writes: > > Here are two things that would make Python feel a little > nicer for me. (Which is not necessarily the same as "better", > of course.) I'd be interested in comments. > > The proposals are extremely minor; they change the meaning > of no valid Python program and add no new semantics. > I conjecture that both would be easy to implement. > > * > > 1. Syntax for extending an existing class. > > Suppose you have a class and want to add a new method > to it. (Why? It's someone else's, you aren't allowed to > change the source, and subclassing won't do because > these things are created by code you don't control.) > > You can do it, thus: > > def new_method(self, x): > something_else() > return x+1 > Thing.new_method = new_method > > but that's rather ugly. I suggest that there be syntax > which does the same thing as the existing "class", but > updates an existing class instead of replacing it. > Two possibilities that don't require new keywords: > > in class Thing: > def new_method(self, x): > something_else() > return x+1 > > or > > class Thing continue: > def new_method(self, x): > something_else() > return x+1 > > I like the first of these much better than the second. > > * > > 2. Syntax for defining methods. > > Every now and then we get people complaining because it's > too easy for them to forget to include a "self" argument > in a method definition. Every now and then, I suspect that > most Pythonistas forget. (I certainly do.) Suppose there > were an alternative syntax, thus: > > class Thing: > def self.boring_method(): > return 0 > > That has two advantages: (1) it looks more the way that > the method will actually get used, and (2) it's harder > not to notice if you miss the "self." out. > > I'm sure this one must have been proposed before, but I > don't see a PEP for it and have no recollection of why > (if it was proposed before) it was disliked. > -- Clarence Gardner Software Engineer NetLojix Communications clarence at netlojix.com From bokr at accessone.com Fri Jun 1 12:51:27 2001 From: bokr at accessone.com (Bengt Richter) Date: Fri, 01 Jun 2001 16:51:27 GMT Subject: Against PEP 240 References: <3B1674D8.67690A5A@san.rr.com> <9f5v00$4li$1@panix2.panix.com> <3b16a154.9545695@wa.news.verio.net> <9f6lae$ddc$1@panix6.panix.com> Message-ID: <3b17ad88.40156281@wa.news.verio.net> On 31 May 2001 16:49:34 -0700, aahz at panix.com (Aahz Maruch) wrote: >In article <3b16a154.9545695 at wa.news.verio.net>, >Bengt Richter wrote: >>On 31 May 2001 10:28:32 -0700, aahz at panix.com (Aahz Maruch) wrote: >>> >>>One can have floating-point BCD, which is what I'm currently working on. >>>It's a real pleasure to write >>> >>> 1.2e2346257231235019862340987162305961293865 * 2.0 >>> >>>and get >>> >>> 2.40e2346257231235019862340987162305961293865 >>> >>>Note carefully the mantissa with its trailing zero. >> >>Just curious, is that based on something like [ , ] >>with the second being a decimal exponent, analogous to binary fp? >> >>Or, are you maintaining a decimal digit sequence representation >>with some decimal "digit" radix like 10^4 or 10^9 (with each "digit" >>represented in binary)? Or? > >The exponent is a long, but the digits are a tuple. See >http://starship.python.net/crew/aahz/ Interesting. I note that Cowlishaw's proposed single precision format fits exactly into the bit fields of a double. I'd bet you could get mileage out of that, but I don't have time to play with it now... At least sign tests, negate, absolute value, equality tests (ok, since all bits are accounted for). Ok, here's a thing to encode and decode a decimal tuple (v,x10) into a float, where v is an integer up to 15 digits and x10 is an exponent dec() decodes it back (well, I should have done a long() on the first return element). import math def enc(v,x10): "enc(v,x10) encode up to 15-digit integer signed v and 10-bit signed x10 in float" if v < 0: return math.ldexp(v-2L**52,x10) else: return math.ldexp(v+2L**52,x10) def dec(d): " decode float that was encoded with enc() above" z = math.frexp(d) # (f,x2) if d < 0: return z[0]*2L**53 + 2L**52, z[1]-53 else: return z[0]*2L**53 - 2L**52, z[1]-53 Maybe someone will find this a useful take-off point... No warranty, this is hot OTTOMH ;-) From skip at pobox.com Wed Jun 20 20:14:02 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 20 Jun 2001 19:14:02 -0500 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) In-Reply-To: References: <200106201855.OAA21119@panix3.panix.com> Message-ID: <15153.15434.385992.754443@beluga.mojam.com> Jeremy> It makes the most sense to me to include python-dev, because Jeremy> it's the advice-to-Guido-list and because most or all of the Jeremy> core developers subscribe to it. It seems that list is the most Jeremy> obvious place to discuss changes to the core language -- and it Jeremy> really irks me that conversations about the core are Jeremy> artificially move elsewhere. (Counterexample: Maybe we could Jeremy> take all the Unicode stuff and ban it from python-dev <0.9 Jeremy> wink>.) I agree with Jeremy. I wasn't keenly interested in python iterators from the get-go (you can't follow everything), so I missed all the discussion until PEP 255 was released. Then within a day or two it winds up in the head branch of CVS. That's not to say it doesn't deserve to be there, but it seems thtat the time from PEP to CVS was rather short. Skip From emile at fenx.com Sun Jun 24 19:50:00 2001 From: emile at fenx.com (Emile van Sebille) Date: Sun, 24 Jun 2001 16:50:00 -0700 Subject: How useful do you find the interactive interpreter? References: <4688f24b.0106231658.43d2c446@posting.google.com> Message-ID: <9h5uiv$c164d$1@ID-11957.news.dfncis.de> I generally work in a text editor, keeping an interpreter session available mainly for introspection purposes. Mostly I import modules and then dir or pydoc them. I rarely just try things first in the interpreter, as it tends to slow me down if I get anything more then just a couple of lines of code. I do keep *lots* of throwaway test.py files, and always have a couple of those open in my text editor. -- Emile van Sebille emile at fenx.com --------- "slaytanic killer" wrote in message news:4688f24b.0106231658.43d2c446 at posting.google.com... > Hi, > > I am looking at Python seriously, and I can see that the interpreter > would be really good for testing out ideas. Getting small things to > work and then switching over to a text editor to generalize what I've > learned. Is this how people generally use it? Or is it an even > deeper part of coding? > > Thanks. From paulp at ActiveState.com Mon Jun 11 01:47:44 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sun, 10 Jun 2001 22:47:44 -0700 Subject: Task Isolation in Python (was Re: How do you develop in Python?) References: Message-ID: <3B245B80.FB9D77F9@ActiveState.com> Glyph Lefkowitz wrote: > >... > > One idea which I've been kicking around (and finally even started a little > implementation of last night) is a Python interpreter in Python. > > ... > > * IDEs could safely execute/debug development code w/o a separate process Komodo runs code in a separate process and I'm pretty sure that your Python-in-Python wouldn't convince us to do otherwise because it would be difficult for you to *exactly* emulate every single behavior of the real Python interpreter especially when you consider that we an currently allow people to debug code on any Python interpreter including everything from 1.5.2 to experimental 2.2s. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From ryanmorillo at hotmail.com Thu Jun 14 04:57:03 2001 From: ryanmorillo at hotmail.com (Ryan) Date: 14 Jun 2001 01:57:03 -0700 Subject: Pure Python mini-DB and NCurses Message-ID: <4a7fde99.0106140057.1e2fb285@posting.google.com> I have been trying to figure out how to make a small database with the shelve module, but either the interface to update it is beyond me or I'm just not grocking some small attribute. I realize that a real DB would be more functional in most cases, but I just want to make a small contacts list program that I can run on the workstation and on a handheld, so I'm trying to make it so the db file can be imported from one to the other and updated. As for the ncurses I'm just trying to figure out why it would be used. If anyone has a reason other than novilty I would appreciate it as I can't understand what Guido was thinking when he put it in. From dsh8290 at rit.edu Tue Jun 26 15:39:09 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 26 Jun 2001 15:39:09 -0400 Subject: PEP 260: simplify xrange() In-Reply-To: ; from rnd@onego.ru on Tue, Jun 26, 2001 at 10:47:28PM +0400 References: <200106261759.f5QHxtH15045@odiug.digicool.com> Message-ID: <20010626153909.A16590@harmony.cs.rit.edu> On Tue, Jun 26, 2001 at 10:47:28PM +0400, Roman Suzi wrote: | On Tue, 26 Jun 2001, Guido van Rossum wrote: | | >PEP: 260 | >Title: Simplify xrange() | >Version: $Revision: 1.1 $ | >Author: guido at python.org (Guido van Rossum) | >Status: Draft | >Type: Standards Track | >Python-Version: 2.2 | >Created: 26-Jun-2001 | >Post-History: 26-Jun-2001 | > | >Proposed Solution | > | > I propose to strip the xrange() object to the bare minimum. The | > only retained sequence behaviors are x[i], len(x), and repr(x). | | What about str(x)? It's not needed : >>> class Example: ... def __repr__( self ) : return "Hello World" ... >>> str( Example() ) 'Hello World' >>> I have no problems with the PEP and I think that the reduced code size is a good thing. -D From thecalm at NOSPAM.btinternet.com Mon Jun 25 07:17:14 2001 From: thecalm at NOSPAM.btinternet.com (Gaz) Date: Mon, 25 Jun 2001 12:17:14 +0100 Subject: any idea how i could test if a variable is a floating point number? Message-ID: <9h76io$ht3$1@neptunium.btinternet.com> any idea how i could test if a variable is a floating point number? gaz. From donn at oz.net Sat Jun 2 00:34:34 2001 From: donn at oz.net (Donn Cave) Date: 2 Jun 2001 04:34:34 GMT Subject: Makefile I/O module? References: Message-ID: <9f9qcq$jm9$0@216.39.151.169> Quoth Bob Drzyzgula : | Does anyone know of a module providing classes for parsing | standard makefiles, sort of like what the rfc822 module | does for mail messages? I don't want to actually do the | make logic in Python, I just want to be able to filter | and assemble makefile fragments and templates into output | makefiles for later processing by make itself; I'm trying | to write a GUI configuration utility for a package with | tons of options. Like, from distutils import sysconfig sysconfig.parse_makefile('Makefile') ? I don't know if that will really do what you want, as it returns only the symbol assignments when I do it, but at worst it's a start. Python uses it to understand its own Makefile, to build itself (2.1 does not shrink from paradox.) Donn Cave, donn at oz.net From llewin at oreilly.com Mon Jun 11 21:16:01 2001 From: llewin at oreilly.com (Laura Lewin) Date: 11 Jun 2001 18:16:01 -0700 Subject: XML examples needed References: <3b1aa296.13311941@news.laplaza.org> Message-ID: <47d2cd7c.0106111716.6fa08818@posting.google.com> Hi, If you can wait a few months, we'll have a book entitled, Python & XML. It's under tech review at the moment. Hope you'll have a book budget by then. :-) Laura LLewin at oreilly.com xyzmats at laplaza.org (Mats Wichmann) wrote in message news:<3b1aa296.13311941 at news.laplaza.org>... > Sigh. Sometimes all this stuff makes me feel really stupid. > > I'm trying to figure out some really basic usage of XML in Python. I > have a document that I'd like to structure as XML and use Python to > generate an output file from it: the XML is for maintainability of the > "raw data", but it needs to be turned into something much more complex > eventually (a web page with embedded javascript). > > Problem is, the whole world seems to think you're going to use Java > for this sort of stuff. > > The Python XML docs (standard distro and PyXML) don't really have any > basic examples, and I'm not grokking. > > Books...there's McGrath's XML Processing with Python, but besides my > not having any book budget at the moment, the book seems to have come > in for quite a bit of criticism so I'm pretty doubful in any case. > > So where to go? Are there any useful low-level tutorials of the > "getting started" variety out there on the web that talk specifically > about Python usage? > > Mats > > Mats Wichmann > > (Anti-spam stuff: to reply remove the "xyz" from the > address xyzmats at laplaza.org. Not that it helps much...) From jm7potter at hotmail.com Fri Jun 29 11:04:45 2001 From: jm7potter at hotmail.com (Joe Potter) Date: Fri, 29 Jun 2001 11:04:45 -0400 Subject: Tkinter problem in sizing a frame Message-ID: Hello one and all, In the following code (adopted from "Python and Tkinter Programming") I find that I can set the minimum size for the root widget. However, I can not seem to tell Tk that I want two sub-frames each of which I want to take up half the parent frame. All I get is two sub-frames that take up as much room as need to display the label in each. Any ideas? Regards, Joe Potter ######## start code ################ from Tkinter import * root = Tk() root.title('Frame Size') root.geometry("600x300") f = Frame(root) xf = Frame(f, relief=GROOVE, borderwidth=5) jf = Frame(f, relief=GROOVE, borderwidth=5) Label(xf, text="You shot him!").pack(side=LEFT, pady=10, expand=YES, fill=Y) Label(jf, text='heck if I know !??').pack(side=LEFT, padx=10, pady=10) jf.pack(side=TOP) xf.pack(side=BOTTOM) f.pack() root.mainloop() From aleaxit at yahoo.com Mon Jun 11 04:55:53 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 11 Jun 2001 10:55:53 +0200 Subject: Global in multiple files References: Message-ID: <9g212o0260r@enews2.newsguy.com> "Roman Suzi" wrote in message news:mailman.992228330.22368.python-list at python.org... ... > >Mhm. It seems a little too much overhed for a simple list of users. > > What if one day you decide to use threads and userlist is to be shared. > How do you manage your list without breaking it then? But if some object > will be in charge of this resource, it will be much-much easier. You will > need blocking written only once. There is a serious risk in over-designing systems "because one day it might be handy". Yeah, right, but meanwhile you're paying the price of complexity *RIGHT NOW*!-) "Do the simplest thing that could possibly work", because "you ain't gonna need it" (where "it" is the rich, complex, over-engineered, over-designed very general solution:-). See http://c2.com/cgi/wiki?YouArentGonnaNeedIt ... Alex From rod_weston at yahoo.com Mon Jun 18 01:51:50 2001 From: rod_weston at yahoo.com (Rod Weston) Date: 17 Jun 2001 22:51:50 -0700 Subject: Upon reflection... References: <20010614163301.G18379@mail.coursepeek.com> Message-ID: I sympathize with your frustrations concerning my methods in my quest. And I agree that I may end up 'collecting' languages if I become frustrated with Ada, but I have made a serious effort to minimize the possibility. My initial selections were based upon what seemed to be the most profitable languages to learn and I came to the forums utilized by expert users of the various languages for further information. After all, it's here that you all complain about the shortcomings of your respective languages or, more constructively, query other expert users for ways to circumvent or resolve these limitations. It's here that I learned about the apparent slowness of Python - well, that and trying the Python Solitaire game. I'm open to hearing more and I'm not going to stop reading the newsgroup just because I've made a decision. Python is very, very popular - there's got to be a reason for the popularity and it's not going to be a bunch of hype as is the case with Java and C++. I initially assumed that I would be learning Java and C++ - after all, they are today's standard - but I decided to make a slightly educated leap rather than a totally blind one. I started looking into what other languages make the world go around... I've already stated my criteria. I'm not saying that I'm right or that I've made an exhaustive analysis (by the way, I chose not to pursue smalltalk because Ada has much more free and low-cost resources available) and I'm certainly not trying to persuade others to follow me, especially not to leave Python on my suggestion; I just wanted to provide my feedback to the excellent folk who have generously given of their time and expertise to my quest. Perhaps in a year I'll be lamenting my choice, but I have made a choice rather than risk the paralysis of analysis and I believe it is a good one. It will allow object-oriented programming, or not. It imposes structure which will improve my programming skills. It will stop those damned 'non-numeric data where numeric required' messages that I hate so much. It will trap errors during compilation on a multitude of platforms. It will run very fast, if I optimize for speed. It will compile to a small executable if I optimize for size. And it will be very readable which will be a pleasant change. I'll give you all some feedback in another six months, after I have some solid experience under my belt - though it will not be qualified comparison with Python nor will I represent it as such. Thanks again. Rod Weston From hs at cybertec.at Wed Jun 13 11:59:34 2001 From: hs at cybertec.at (=?iso-8859-1?Q?Hans=2DJ=FCrgen=20Sch=F6nig?=) Date: Wed, 13 Jun 2001 15:59:34 GMT Subject: PostgreSQL, Python and BLOBs References: <3B2775C0.D2460A6C@cybertec.at> Message-ID: <3B278D55.8A370BD5@cybertec.at> Thank you ... Do you know an easier example? I don't know how to insert BLOBs yet. It works for me with C but I think some information is missing in the Python docs. Hans From MarkH at ActiveState.com Sun Jun 10 22:22:39 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Mon, 11 Jun 2001 02:22:39 GMT Subject: Custom COM interface q. References: <9g013q$49r$1@news.inter.net.il> Message-ID: <3B242B95.4070606@ActiveState.com> Ian wrote: > Hi, > I have COM server for Nokia GSM suite that doesn't support IDispatch. > Makepy.py generates file from it's typelib but I don't know how to use > custom interfaces from this file and what I should write in the > CoCreateInstance function. > Thanks, > Ian At the moment you can not use these interfaces from Python. Mark. From root at rainerdeyke.com Sun Jun 24 19:58:14 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Sun, 24 Jun 2001 23:58:14 GMT Subject: Nested Scopes Question (exec) References: Message-ID: "Ryan LeCompte" wrote in message news:mailman.993417398.9618.python-list at python.org... > P.S. --- Aren't the following two calls the same: > > exec "print 'hello'" > exec "print 'hello'" in globals(), locals() No. Modifying the dictionary returned from 'locals' does not change the bindings of local names. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From DavidLNoSpammm at raqia.com Fri Jun 22 11:22:46 2001 From: DavidLNoSpammm at raqia.com (David Lees) Date: Fri, 22 Jun 2001 11:22:46 -0400 Subject: Is this a true statement? References: <9gvb8q$ssl$1@taliesin.netcom.net.uk> Message-ID: <3B3362C6.5F2781EB@raqia.com> Not necessarily. It might go faster if you were comparing a Python built-in operation (coded in C) with something inefficiently coded in C++. But the statement that "Python can do everything C++" is true, but a tautology. You can substitute nearly any language; Basic, C, Algol, Lisp,... and it is still a true statement. david lees MDK wrote: > > Python can do everything C++ can do but just slower. From BPettersen at NAREX.com Mon Jun 18 19:40:55 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Mon, 18 Jun 2001 17:40:55 -0600 Subject: nested classes Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D493@admin56.narex.com> > From: Mats Wichmann [mailto:xyzmats at laplaza.org] > > On Mon, 18 Jun 2001 13:23:33 -0500, Stefan Seefeld > wrote: > > >gbreed at cix.compulink.co.uk wrote: > > > >> > What am I doing wrong ? The above is possibly a bit driven > >> > by my C++ programming style. What is the python way of doing > >> > this ? > >> > >> You can get that to work in C++? It looks strange to me, I'm > >> sure you can't be trying to do what you think you're trying to > >> do. This is the nearest I can think of that works: > > > >uh, what do *you* think that I'm trying to do, then ? :) > > > >What I'm arguing about is a matter of name resolution. I sure > >can open a scope 'A' in C++, insert a new scope 'B' into it, > >and from within that access other symbols declared in scope 'A'. > >In fact, I don't need to qualify them (i.e. 'foo' instead of 'A::foo' > >for any symbol 'foo' in the scope 'A' is just fine) if I'm inside > >that scope, no matter how deeply nested (of course, as long as there > >are no ambiguities). > > Java and C++ are compiled. The class definition is instructions to > the compiler, and can be self-referential, because the /reference/ is > not going to happen until the class is loaded - no inconsistency. Not > so for Python, the class definition is code that is actually run to > build the class object, and before that object has been built, there's > nothing to refer to yet, as Alex said. But that's an implementation detail only, since it works perfectly for functions: def foo(): foo() insert-definition-of-letrec-vs-let-here'ly y'rs -- bjorn From uioziaremwpl at spammotel.com Wed Jun 20 16:05:06 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Wed, 20 Jun 2001 22:05:06 +0200 (CEST) Subject: Partially evaluated functions In-Reply-To: <9x6Y6.327563$oc7.32009573@news2.rdc2.tx.home.com> Message-ID: On Wed, 20 Jun 2001, Rainer Deyke wrote: > "Nick Perkins" wrote in message > news:VL5Y6.296349$eK2.60381920 at news4.rdc1.on.home.com... > > > > "Rainer Deyke" wrote... > > > > > ... > > > My version is superior in that it doesn't use named arguments. > Consider: > > > > > > def f(self): > > > print self > > > > > > curry(self = 5) # This will fail with the cookbook version. > > > > > > > ..Of course, you mean: > > > > curry(f, self=5) > > Yes. > > > .. which works fine with the cookbook version. > > ( why wouldn't it? ) > > Have you tested it? In Python 2.0: > > > >>> def f(self, **kwargs): > ... print self, kwargs > ... > >>> f(f, self=5) > Traceback (most recent call last): > File "", line 1, in ? > TypeError: keyword parameter redefined: self > >>> Probably you mean curry(f, self=5) and not f(f, self=5) But you are right that you get a TypeError due to the __init__ function in the class. Cheers, Carsten -- Carsten Geckeler From sandorlevi at yahoo.com Fri Jun 22 05:42:36 2001 From: sandorlevi at yahoo.com (Levente Sandor) Date: Fri, 22 Jun 2001 02:42:36 -0700 Subject: How to tell if interpreter is in interactive mode References: <9gl7ba07u8@enews2.newsguy.com> <9gv2s2$ao024$1@ID-59885.news.dfncis.de> Message-ID: <3b33133a.13483590@news.unbc.ca> On Fri, 22 Jun 2001 02:25:59 -0700, "Thomas Heller" wrote: > >"Alex Martelli" wrote in message news:9gl7ba07u8 at enews2.newsguy.com... >[John Copella asked how to tell if interpreter is in interactive mode] >> >> It IS pretty easy -- sorry, hadn't noticed your question earlier! >> Hoping the answer is still of interest despite the 5 days since >> you asked...: >> >> In module sys, an attribute named ps1 exists during interactive >> interpreter sessions. IDE's such as IDLE and PythonWin also set >> it (it's normally the string ">>> "). This attribute is *NOT* set >> if the interpreter is NOT interactive. >> > >The only catch is that this attribute is not yet >defined when sitecustomize is imported. > >Any other solutions? > >Thomas > Try this: import sys def IsInteractive(): try : if sys.ps1: return 1 except: pass return 0 print IsInteractive() Levi From dwelden at email.com Fri Jun 22 13:33:52 2001 From: dwelden at email.com (David Welden) Date: 22 Jun 2001 10:33:52 -0700 Subject: Python equivalent of CPAN Library modules References: Message-ID: I think a very nice contribution would also be guidelines/rules of thumb/examples even (!) of how one proceeds with converting Perl to Python. Syntax is easy, but what I am thinking of is the more esoteric stuff in Perl (don't get me started) like XSUB. For example, I have a vendor supplied Perl Module that connects to Hyperion Essbase. I would prefer to use it from Python instead, but don't know how to convert it. I suspect that I have all the pieces I need (DLL, header files, XSUB files, etc.) except how to get from jewel to snake. From m.faassen at vet.uu.nl Fri Jun 15 15:10:13 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 15 Jun 2001 19:10:13 GMT Subject: Python-list: the list with everything! References: Message-ID: <9gdmil$61k$1@newshost.accu.uu.nl> Bill Bell wrote: > Gotta love this list. > Brain teasers. Friendly discussion. Intellectual diversion. ... and > tips about newly available porno sites. And conspiracies! Don't forget about the conspiracies, like the PSU's plan to send a From aleaxit at yahoo.com Sat Jun 16 04:44:37 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 16 Jun 2001 10:44:37 +0200 Subject: slice-alias (was Re: New statement proposal for Python) References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> Message-ID: <9gf6fk0b9l@enews1.newsguy.com> "Andrew Henshaw" wrote in message news:tiljnnden7bc80 at corp.supernews.com... ... > For instance, one can alias (e.g. "lastName") a slice [16:32] of an Occam > array of bytes "byteArray" with: > > lastName IS [byteArray FROM 16 FOR 16]: > > and then use lastName as a new array name. Then the first byte can be > referrenced with: > > lastName[0] := 'a' > > This, of course, will change the 17th byte in byteArray to 'a'. ... > This would be nice on Python as well, particularly since naming a list slice > actually creates a copy (perhaps I've missed some capability here). Takes some work, and is untested, but...: import types,sys class ListSlice: def __init__(self, alist, start, stop=None): self.alist=alist self.start=start self.stop=stop def __stopper(self): if self.stop is None: return len(self.alist) else: return self.stop def __normindex(self, index, aslice=0): if index<0: result = self.__stopper()+index else: try: result = self.start+index except OverflowError: if aslice==2: return self.__stopper() raise if self.start<=result> base = list("prolegomena") >> slic=ListSlice(base,2,6) >>> ''.join(slic) 'oleg' >>> ''.join(base) 'prolegomena' >>> slic[:3] ['o', 'l', 'e'] >>> slic[2:] ['e', 'g'] >>> slic[1:4] ['l', 'e', 'g'] >>> slic[1:3] ['l', 'e'] >>> slic[1:3]=list("plop") >>> ''.join(base) 'proplopgomena' >>> ''.join(slic) 'oplo' >>> As you see, it itsn't perfect -- the slice should no doubt adjust its length in some more circumstances, the better to mimic a built-in sequence, specifically when it's subject to slice-assignment. But I hope it can get you started. Alex From jp at NOSPAMdemonseed.net Thu Jun 28 09:27:48 2001 From: jp at NOSPAMdemonseed.net (jason petrone) Date: Thu, 28 Jun 2001 13:27:48 +0000 Subject: [Mojonation-devel] need good entropy gathering under win32 (fwd) References: Message-ID: Eugene Leitl wrote: > Could some clueful win32 hacker, please see `randsource.py'[1] and give it a > strong source of randomness (we just need an initial seed of 160 bits). Here > is an article saying how to do it: [2] An easy way to cheat on this is to use urllib or corba to download hardware generated random numbers from www.random.org. jason From joshm at internetdiamonds.com Mon Jun 18 17:24:31 2001 From: joshm at internetdiamonds.com (Josh Marion) Date: Mon, 18 Jun 2001 14:24:31 -0700 Subject: Please SubScribe. Message-ID: <000a01c0f83d$10a0efd0$6f0210ac@bluenile.com> Thanks -josh www.bluenile.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From skip at pobox.com Thu Jun 14 12:29:39 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 14 Jun 2001 11:29:39 -0500 Subject: bsddb: must bsddb write a file ? In-Reply-To: <3B28D465.229D7BF7@netlcr.de> References: <3B28D465.229D7BF7@netlcr.de> Message-ID: <15144.58995.58566.928678@beluga.mojam.com> Florian> hi again.. Florian> the bsddb: class (binary tree, hash-table,..) Florian> needs to write its data to a file: Florian> db = bsddb.btopen('filename','c'); Florian> the file can be removed, but is there a way to avoid the file ? Well, you could just use a dictionary instead. If you don't want your key/value pairs saved to a file, why use bsddb? -- Skip Montanaro (skip at pobox.com) (847)971-7098 From chrishbarker at home.net Fri Jun 8 15:38:20 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 08 Jun 2001 12:38:20 -0700 Subject: How do you develop in Python? References: <050620011516094693%pecora@anvil.nrl.navy.mil> <9fjfer$gt0$1@nereid.worldonline.nl> Message-ID: <3B2129AC.90BA8650@home.net> Gerrit Muller wrote: > but I think that a more "cold" runscript > command in IDLE, which imports/reloads anything again (and maybe clears the > rest of the environment as well) would make IDLE even more accessible for > this type of programmers. Also the MacPython IDE, PythonWin, etc. I've been asking for this for a while, but I think it's harder than it sounds for two reasons: 1) I don't think the Python Interpreter has any kind of "clear all" facilities. 2) All three of these IDEs (and others, I'm sure) use the same interpreter to run the IDE as the program you are working on. If you were to "clear all" you'de wipe out the IDE as well. I'd lke to see an IDE that used a separate copy of the interpreter, but it would make writting a debugger (and other introspective tools) a lot harder. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From spamdropbox at myrealbox.com Sat Jun 30 17:17:03 2001 From: spamdropbox at myrealbox.com (Walter Hofmann) Date: Sat, 30 Jun 2001 23:17:03 +0200 Subject: MySQLdb module & error capturing References: <9hbube$ok1$1@newsreaderm1.core.theplanet.net> Message-ID: On Wed, 27 Jun 2001 08:25:23 +0200, Franz GEIGER wrote: > >Hi Paula, > >if you import _mysql you can catch the exceptions like so: There is no need to import this internal module. Just use "except MySQLdb.OperationalError" Walter From scarblac at pino.selwerd.nl Fri Jun 29 05:15:50 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 29 Jun 2001 09:15:50 GMT Subject: Augmented Assignment (was: Re: PEP scepticism) References: Message-ID: Paul Prescod wrote in comp.lang.python: > Bruce Sass wrote: > > ...what was a wart becomes a feature. > > That was a lot of effort to understand a typing shortcut. It's somewhat > unpythonic to trade a long explanation for a bit less typing. But augmented assignment isn't about a bit less typing. For one thing, A *= 2 can be implemented a lot more efficiently than A = A*2, in some cases. Also really_long_variable_name += 1 is more clear than really_long_variable_name = really_long_variable_name + 1. The difference between mutable and immutable types may look strange at first, but in my opinion it's exactly the right pragmatical choice. -- Remco Gerlich From gustafl at algonet.se Wed Jun 6 20:43:10 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 7 Jun 2001 00:43:10 GMT Subject: TypeError: object is not callable Message-ID: Why this error? I have done a class which is in placed in a directory within sys.path, and the class works as intended when I test it by adding some main() code in it. But when I call it from another module I get this strange error "TypeError: object is not callable". No way I can get the same error in Idle... >From the docs, it seems that it has something to do with the constructor, so here is the constructor: class Friend: def __init__(self, id, file): self.id = id self.name = "" self.emails = [] self.file = file self.load() Regards, Gustaf Liljegren From ljohnson at resgen.com Wed Jun 27 12:25:27 2001 From: ljohnson at resgen.com (Lyle Johnson) Date: Wed, 27 Jun 2001 11:25:27 -0500 Subject: python as plugin language References: <993529827.54981@newsmaster-04.atnet.at> Message-ID: > See below. I'm not interested in the main program requesting a service of > Python. I'm interested in Python requesting a service of the main program during > its servicing of a request from the main program. In other words: C calls Python, > which in turn calls C. So you need to use both extending *and* embedding: - Your C application can call out to Python because you've embedded a Python interpreter into the application, and - Python can call back into your C application because you've developed a C extension module that the Python code can import. > All the cases you cite miss the essential point - how does the Python > code call a function in the C language program it's embedded in? It's > relatively easy for the C program to call a pure Python function - it checks its > parameters, calculates a result, and returns it. > > I'm more interested in being able to expose a complete object model, with > real, working functions and data. In other words, what you can do with > Python in a Web browser under Windows using the Active Scripting interface, > although that's a specialized, Windows only implementation. I think your first task is to identify the object model that you want to expose to Python and then develop a C extension module that implements that. I like using SWIG (http://www.swig.org) for this, but you could also do it "by hand" or perhaps using CXX or Boost. Once you've done this, the big thing that's still missing (as you've pointed out) is a data-level link between your extension module and the currently-running C application. That's what I was recommending the use of one or more global "callback" objects for. As an example, imagine the C application's purpose is to keep track of the animals in a zoo. Your C application manages a single "Zoo" object that is more or less a container of "Animal" objects. Now you've decided that to enable end-user customization of the application, you'd like to embed a Python interpreter and let the user write Python scripts to manipulate the Zoo object. You might start by developing a Python extension module that exposes Zoo and Animal classes, as well as a method that retrieves the single, global "Zoo" instance from the C application. When the user's Python script makes method calls on that Zoo object, it's actually calling into your C extension module code, which manipulates the "real" Zoo instance living in the C application. SWIG calls this approach shadow classes; the Python Zoo instance "shadows" the C Zoo instance. From dsh8290 at rit.edu Fri Jun 8 18:22:39 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 8 Jun 2001 18:22:39 -0400 Subject: Use Jython to make true executable? In-Reply-To: ; from carlf@panix.com on Fri, Jun 08, 2001 at 07:05:00PM +0000 References: Message-ID: <20010608182238.B19076@harmony.cs.rit.edu> On Fri, Jun 08, 2001 at 07:05:00PM +0000, Carl Fink wrote: | I'm a Python beginner, so forgive me if this question is stupid. | | A common request on this group is a true compiler to convert a Python | script to a directly-executable program. (ELF for Linux, .exe for | Windows/DOS, etc.) This request comes from people who don't know that having a .py file (or .pyw) is just as good as having a .exe file. In fact, having a .py is better because it will work with newer (better) interpreters and can be fixed if it has some problem. The request comes more from Windows users who don't want to tell people they need to install python and who don't want to ship python with their program. Linux systems typically have python already, or it can simply be listed as a dependency in the package (apt-get will automatically install it then, if you are using Debian). | Couldn't you develop your program in Jython, "compile" it to Java | bytecodes, then run them through GCC? I haven't tried it, but I've | read that GCC can convert Java to direct executables. GCC (gcj, rather) can compile Java _source_ to native code (C++ object files) that ld links together with libgcj (Sun's jdk calls it "rt.jar" or in older versions "classes.zip") at runtime. | Now, I also am far from a Java expert. For instance, would Swing be | convertible using GCC given that it's not free software? If you have the source, then go right ahead. I don't think libgcj implements the AWT yet, though, and I know Kaffe doesn't (a free, open source JVM). OTOH there is PJA (Pure Java AWT) that can be used instead (it is most useful for headless servlets, etc). -D From jestes39 at yahoo.com Fri Jun 15 15:10:38 2001 From: jestes39 at yahoo.com (jestes39 at yahoo.com) Date: Fri, 15 Jun 2001 19:10:38 -0000 Subject: Do Nested try: ... except: 's work? Message-ID: <9gdmje+43md@eGroups.com> I am trying to use the try: ... except: structure as it is used in Oracle for flow control. I am nesting try/except blocks and raising named excepts. Each time it gets to a raise statement that is referencing an except outside the current block, it fails and gives me an error similar to 'there is no variable named '. Here is a short section to illustrate my point: import telnetlib try: try: tn = telnetlib.Telnet('xxx.xxx.xxx.xxx') except: no_connect_flag = 'TRUE' if no_connect_flag == 'TRUE': raise no_connect try: tn.set_debuglevel(100) except: print 'couldn''t set the debug level' except no_connect: print 'couldn''t open telnet connection' When I run this script through the debugger, I get the error: NameError: There is no variable named 'no_connect' Any help would be appreciated. Thanks. jestes3 at logicon.com From m.faassen at vet.uu.nl Sat Jun 30 06:20:09 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 30 Jun 2001 10:20:09 GMT Subject: PEP scepticism References: <3d1yo2nca4.fsf@ute.cnri.reston.va.us> <9hj3bb$bdu$8@newshost.accu.uu.nl> <9hjj0b$c55$1@panix3.panix.com> Message-ID: <9hk94p$cnu$1@newshost.accu.uu.nl> Aahz Maruch wrote: > In article <9hj3bb$bdu$8 at newshost.accu.uu.nl>, > Martijn Faassen wrote: >> >>The somewhat mysterious way to get accepted to the dev mailing list >>at all is a hurdle all by itself.. Perhaps this document could help >>there too. > It's not mysterious at all: Guido invites you (cadging an invite from > Guido is an option, of course). But it doesn't take all that much to > get an invitation; I'm on the list, and I still have not contributed any > code to Python, and I've only submitted one formal PEP. Well, when I wanted to know last year, I asked Gordon McMillan and he said the same thing but made it seem very mysterious. I wasn't in a hurry so I gave up on it; perhaps that was accomplishing the goal. :) It must be because Gordon is so high up in the PSU and all... Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From dougfort at dougfort.net Tue Jun 26 21:42:09 2001 From: dougfort at dougfort.net (Doug Fort) Date: 27 Jun 2001 02:42:09 +0100 Subject: An approach to building a networkable boardgame... References: <3b392559.9658458@news.lith.com> Message-ID: <3b3939eb_7@news5.uncensored-news.com> Israel wrote: > Hello... > > > I'm in the design phase of translating a Boardgame, my wife and our > exchange student made up this year, to a python app that people can > play over the internet. I was wondering what the best appoach to > this would be. I could make this a webrowser based thing where the > server does a lot of the work, or I could make this a downloadable > python distribution that has the ability to connect two players, one > of which would be the server and the other would be the client.. > > I'm really not sure as this is a challenge I'm setting myself to help > me to better understand not only Python but programming in General. > > > Any opinions, suggestions, free associations?? > > ~Israel~ > Peer-to-peer is very 'in' right now... perhaps you could use pyagent http://pyagent.sourceforge.net -- Doug Fort http://www.dougfort.net ______________________________________________________________________ Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com With Seven Servers In California And Texas - The Worlds Uncensored News Source From philh at comuno.freeserve.co.uk Fri Jun 15 07:07:07 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 15 Jun 2001 12:07:07 +0100 Subject: Any other Python flaws? References: <3B2914A0.6010902@erols.com> <1996b22d.0106142337.7b70484a@posting.google.com> Message-ID: On 15 Jun 2001 00:37:22 -0700, Martin Sandin wrote: >> ...I got an array with 100 elements, all 0. >> >> I think python is OK here. > >Except you didn't =) You got a list of 10 references to a list with 10 >references to the number 0. No, I didn't. (Replacing 10 with 3 for concision): philh:~> python Python 2.0 (#1, Jan 19 2001, 17:54:27) [GCC 2.95.2 19991024 (release)] on linux2 Type "copyright", "credits" or "license" for more information. >>> array = ([0] * 3) * 3 >>> array [0, 0, 0, 0, 0, 0, 0, 0, 0] >>> array[2] = 2 >>> array [0, 0, 2, 0, 0, 0, 0, 0, 0] If I'd got a list of lists, it would have looked like: [[0,0,0], [0,0,0], [0,0,0]] > That the inner list is a list of >references to the same object doesn't matter much, But it isn't. When I change one value, doesn't change the others. If i wanted a reference I could say something like: >>> a = [1]*3 >>> b =[a]*3 >>> b [[1, 1, 1], [1, 1, 1], [1, 1, 1]] >>> b[1][1]=2 >>> b [[1, 2, 1], [1, 2, 1], [1, 2, 1]] Note that if I now say: >>> c=a*3 >>> c [1, 2, 1, 1, 2, 1, 1, 2, 1] >>> c[2]=3 >>> c [1, 2, 3, 1, 2, 1, 1, 2, 1] -- ## Philip Hunt ## ## philh at comuno.freeserve.co.uk ## From ullrich at math.okstate.edu Sat Jun 23 09:12:44 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sat, 23 Jun 2001 13:12:44 GMT Subject: Is this a true statement? References: Message-ID: <3b34939b.410758@nntp.sprynet.com> On Fri, 22 Jun 2001 12:47:23 -0400 (EDT), "Steven D. Majewski" wrote: > > >On Fri, 22 Jun 2001, David Lees wrote: > >> Not necessarily. It might go faster if you were comparing a Python >> built-in operation (coded in C) with something inefficiently coded in >> C++. But the statement that "Python can do everything C++" is true, but >> a tautology. You can substitute nearly any language; Basic, C, Algol, >> Lisp,... and it is still a true statement. >> >> david lees >> >> >> MDK wrote: >> > >> > Python can do everything C++ can do but just slower. > >Wrong, David. >Turing completeness means that anything you can *COMPUTE* in one >language you can computer in another. Python, Lisp, C++, etc. >are all equivalent in that sense. > >But you can't *DO* all of the same things in all languages -- for >example: you can write a device driver in a language if you can't >specify interrupt vectors or hardware address pointers. ??? I thought a device driver was just a file, hence a finite sequence of bytes. You can certainly use Python to write an arbitrary sequence of bytes to a file. No doubt it's much easier in C++ (or rather in typical implementations of C++?) to decide _what_ sequence of bytes to write to that file, but if we're talking about what's literally possible and impossible I don't see how writing a device driver can be impossible in Python. Could well be that your distinction between what you can do and what you can compute makes sense, but I don't see how _writing_ a device driver is anything but "computation" (given the appropriate documentation.) Maybe I'm missing something. >-- Steve Majewski > > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From root at rainerdeyke.com Sun Jun 24 20:51:47 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 25 Jun 2001 00:51:47 GMT Subject: Nested Scopes Question (exec) References: Message-ID: "Tim Peters" wrote in message news:mailman.993425257.19425.python-list at python.org... > Warning: The contents of this dictionary should not be modified; > changes may not affect the values of local variables used by the ^^^^^^^ > interpreter. The wording here should probably be changed to "may or may not". Otherwise people might start to rely on the fact that dictionary usually doesn't affect the local variables and do stuff like this: def f(x): d = locals() d['x'] += 5 exec 'print x' in d -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From pariguayo at hotmail.com Wed Jun 27 13:34:06 2001 From: pariguayo at hotmail.com (Pariguayo) Date: 27 Jun 2001 10:34:06 -0700 Subject: make_obcallback(): could not import mod_python.apache Message-ID: apache error.log [Wed Jun 27 12:28:44 2001] [info] Server built: Jun 12 2001 13:50:30 make_obcallback(): could not import mod_python.apache. make_obcallback(): could not call init. my apache-python configuration was working without problems. Anyone with this error? apache httpd.conf AddHandler python-program .py PythonHandler mptest PythonDebug On system: Debian/testing Package: libapache-mod-python Status: install ok installed Priority: optional Section: interpreters Installed-Size: 1472 Maintainer: Kevin Lindsay Version: 1:2.7.3-1 Depends: libc6 (>= 2.2.3-1), libdb3 (>= 3.2.9-1), python2-base (>= 2.0), apache-common (>= 1.3.14-2) Package: apache Status: install ok installed Priority: optional Section: web Installed-Size: 767 Maintainer: Johnie Ingram Version: 1.3.20-1 Package: python2-base Status: install ok installed Priority: optional Section: interpreters Installed-Size: 4524 Maintainer: Gregor Hoffleit Source: python2 Version: 2.0.1-1 From dougfort at dougfort.net Mon Jun 25 15:14:21 2001 From: dougfort at dougfort.net (Doug Fort) Date: 25 Jun 2001 20:14:21 +0100 Subject: creating a matrix in python? References: <3B350DC7.748C3903@telocity.com> Message-ID: <3b378d88$1_5@news5.uncensored-news.com> Adonis wrote: > how do i go about this? > > i have looked into the tutorial 100+ times and cant get anything on > matrices out of it? > only thing i came up with was some thing like: > blah = ['buh', 'blah', 'wassah'] > blah[1][0] > 'buh' > > ??? > > any help would greatly be appreciated. > > Adonis > > Check out Numeric Python http://www.pfdubois.com/numpy/ -- Doug Fort http://www.dougfort.net ______________________________________________________________________ Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com With Seven Servers In California And Texas - The Worlds Uncensored News Source From vvainio at karhu.tp.spt.fi Mon Jun 25 01:37:20 2001 From: vvainio at karhu.tp.spt.fi (Ville Vainio) Date: 25 Jun 2001 08:37:20 +0300 Subject: Managing Python sources in CVS & whitespace References: <3B3247AC.620751B6@home.net> Message-ID: Chris Barker writes: > > Are there any issues with Python sources and CVS (I'm thinking of the > > whitespace thing here)? Do the diffs or merging branches get screwed > > up? Are there any special considerations? > > No. Why would there be? CVS handles any text file format just fine. I was mainly thinking of how CVS notices & merges differences between files. It may have been possible that it might have been too smart for it's own good and somehow "ignored" non-quoted whitespace as a thing that constitutes a "difference" (which is a valid strategy for most programming languages, anyway), which would obviously have broken it for python. Anyway, I'm glad to know it doesn't do this (and that there are no special options to tweak). -- Ville Vainio - http://www.tp.spt.fi/~vvainio - ICQ #115524762 Wild geese have no intention to cast a reflection Water has no mind to assume their form From colin at meeks.ca Wed Jun 27 09:01:07 2001 From: colin at meeks.ca (Colin Meeks) Date: Wed, 27 Jun 2001 13:01:07 GMT Subject: Web Application framework (python/java) References: Message-ID: You might want to have a look at http://www.programmedintegration.com. This site is generated entirely in Python. We developed our own solution as we couldn't find anything that worked the way we did. I'd be more than happy to answer any specific questions you have. Colin "prashant patel" wrote in message news:ef87e612.0106262052.5c9f068e at posting.google.com... > I am Intrested in created a web application famework, on which and > developer,a web novice and created his application. I also wanted to > make it in python. since i have my skill in java, it is also a > potential. but since python is more productive i would like to make it > in python, also the time constraint in which i have to devliver this > product. My question is java has a lot of web related > tools, since i am new to python i am not familair with the web > libraries in python,also going through core python programming quickly > to find out what i can do with it. i want to do it in python, can it > be a language to concieve the > "web application famework". please give your thought and suggestion. > prashant. From aleaxit at yahoo.com Sat Jun 2 13:50:43 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 2 Jun 2001 19:50:43 +0200 Subject: Why isn't Python king of the hill? References: <9fa5fi0fru@enews2.newsguy.com> <9fb5fl$26kf$1@agate.berkeley.edu> Message-ID: <9fb90m01koq@enews2.newsguy.com> "E. Mark Ping" wrote in message news:9fb5fl$26kf$1 at agate.berkeley.edu... ... > Really, floating point arithmetic has well-defined semantics; guessing > and treating them as if they have random components is the lazy and > error-prone way to use them. It's ONE lazy and error-prone way; another one is not keeping the possible errors and approximations always in one's mind (and there are others yet, but those are the main two, I think). I think they're widespread. I've been guilty of both (and yet others besides) at various points in my life and career, and I do not personally know anybody (who has done significant numerical programming) who can claim he has never been guilty of either while looking at me eye to eye and keeping a straight face (there must be such people somewhere, I'm sure -- just not in my circle of real life acquaintances). Alex From aahz at panix.com Mon Jun 18 21:45:52 2001 From: aahz at panix.com (Aahz Maruch) Date: 18 Jun 2001 18:45:52 -0700 Subject: fprintf(): Python Equivalent???? References: Message-ID: <9gmasg$po2$1@panix6.panix.com> In article , Prem Rachakonda wrote: > > Does python have some function which does a formatted file writing >functionality similar to C's > >fprintf(fp,"%s %s",string1, string2); Use the "%" operator: "%s %s" % (string1, string2) -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "It's not what you know, it's what you *think* you know." --Steve Martin From aleaxit at yahoo.com Sat Jun 9 13:19:03 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 9 Jun 2001 19:19:03 +0200 Subject: is c faster? References: Message-ID: <9ftlpv029hk@enews2.newsguy.com> "akhar" wrote in message news:bLiU6.8081$NU3.913665 at weber.videotron.net... > I have a script I wrote in python , I love the time it took me to devellop > it faster than i could have done it in C. however after full review of my > code I am not sure I can optimize it any more( it basicaly consist of > importing an image and tranforming into a matrix to perform some for-looped > operations on it) : I went from 20 seconds to 2. I can't seem to bring the > execution time down :( . would C code be faster? by what factor? can I Depending on several factors, recoding a good Pythonic design into a finely tuned C extension can give you a speed up as small as 20% (I've never seen anything less than that, though I guess it's possible) and as big as 1,000%, i.e., 10 times faster (again, I haven't seen anything more than that on real code, although in this case it's easy to do even better for code that a C optimizer can optimize down to nothing, as is true of many benchmarks:-). Does anybody have substantially different experiences...? Alex From aleaxit at yahoo.com Fri Jun 1 06:29:01 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 1 Jun 2001 12:29:01 +0200 Subject: Parameter passing in python References: <9f5nlm0286b@enews2.newsguy.com> <3B16C0C5.ABBBFA5C@hq.workspot.com> Message-ID: <9f7qpe02c4n@enews1.newsguy.com> "Jacob Hallen" wrote in message news:3B16C0C5.ABBBFA5C at hq.workspot.com... ... > However there is no mention at all of this in the Python Reference > Manual. I have checked both the 2.0 and 2.1 versions. It ought to > be in section 5.3.4, as far as I can understand. I think you're right, and the lack is still there in http://python.sourceforge.net/devel-docs/ref/calls.html I.e., it documents *args and **kwds for FORMAL parameters, but not the corresponding forms of ACTUAL parameters. I hope that CC'ing the doc-sig, as I've done, can do in lieu of filing a bugreport on sf.net (Fred, if you'd rather have me file a bugreport for this sort of things now and/or in the future, just let me know -- and thanks once again for the great job you've always been doing on the docs...!). Alex From paul at boddie.net Fri Jun 1 07:58:13 2001 From: paul at boddie.net (Paul Boddie) Date: 1 Jun 2001 04:58:13 -0700 Subject: Sequences/lists/enumerations in COM, Python 2.1, Windows 2000 References: <23891c90.0105310130.168e3255@posting.google.com> <3B163C9A.8020500@ActiveState.com> Message-ID: <23891c90.0106010358.38ab2cf@posting.google.com> Mark Hammond wrote in message news:<3B163C9A.8020500 at ActiveState.com>... > Paul Boddie wrote: > > > # Now, pay attention! > > > > third_sub_folder = second_folder.GetNext() > > > > # This will be the *same* object as the second_sub_folder! > > > I have no idea what this is all about. Hopefully someone with > experience in the object model will speak up here. Who knows. The Visual Basic examples that I have seen (everyone seems to explain it in VB) just iterate over the items collection, hence my iterator question later. > > first_folder = top_level[0] # Yields an exception - there is > > # no folder 0! > > first_folder = top_level[1] # Works - it's the first folder > > # alright! > > > > # This breaks all known Python idioms, surely... > > > It does. However, the Python COM extensions only know that we have an > "indexable" object. It knows nothing about the valid indexes. Some > applications index from zero, some from one. Blimey! I bet it's hard to make something sensible happen with this kind of behaviour. Just as it's necessary to indoctrinate beginners with the nastiness of floating point, so should there be a caveat on sequences having any involvement with COM. ;-) > > Given that the index notation can be used, I don't really care about > > the dubious GetFirst, GetNext methods, but what I would like to know > > is: why don't sequence indexes behave "normally" for Python? Is it a > > Python 2.1 issue, a win32com issue, or just something strange with > > Outlook and the Exchange server I'm using? > > > As above. Right. > > Also, would iteration over > > sequences be supported once iterator support is built in to Python? > > > If it can be done cleanly, then yes. Note that you can theoretically > iterate over these objects now, but that same problem will bite in this > case. I haven't checked out iterators in any detail, but I expect that > it will be simpler and cleaner. Great! Still, after much experimentation, things actually work in my dastardly scheme. Thanks for the help (and the COM stuff)! How about a code snippet library just for COM? (Or is there such a library with lots of COM examples in that I don't know about?) Regards, Paul From ullrich at math.okstate.edu Tue Jun 5 11:09:25 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Tue, 05 Jun 2001 15:09:25 GMT Subject: random References: Message-ID: <3b1cf00f.5441109@nntp.sprynet.com> On Mon, 4 Jun 2001 21:25:48 -0400, "Tim Peters" wrote: >[David C. Ullrich] >> Um, actually I'm pretty sure that Omega _is_ what I said it is, and >> is also what you say it is. > >I'm not . Posts crossed in the mail - I'm certain I was wrong. >> ... >> The first thing you need to note is that "probability that a random >> program halts" is _meaningless_ until we have specified how we are >> _choosing_ our "random program". > >Sure. > >> ... [my fascinating definition of "random program" that turned out not to be Chaitin's snipped] > >Chaitin's construction is actually based on the bit-length p of programs P. >A specific program P of bit-length p that halts contributes (additively) >1/2**p to Omega -- all programs of length p carry the same weight. You may >object that there are 2**p programs of length p alone, so that this isn't >well-defined (i.e., that the programs of length p alone *may* contribute >2**p*(1/2**p) = 1 to the total, and that the sum over all P may be >unbounded). Indeed, that was a long-standing hang-up! "The trick" is that >Chaitin's twist on universal Turing machines requires "self-delimiting" >programs: > > A key technical point that must be stipulated in order for Omega > to make sense is that an input program must be self-delimiting: > its total length (in bits) must be given within the program itself. > (This seemingly minor point, which paralyzed progress in the field > for nearly a decade, is what entailed the redefinition of > algorithmic randomness.) > ... > If programs were not self-delimiting, they could not be constructed > from subprograms, and summing the halting probabilities for all > programs would yield an infinite number. If one considers only self- > delimiting programs, not only is Omega limited to the range between > 0 to 1 but also it can be explicitly calculated ``in the limit from > below.'' > >IOW, there are slippery subtleties here (subtle enough to trip up serious >researchers for years) -- if you want to pursue this, it's better to stop >guessing at the gaps in popular overviews and go to the sources. The way he >actually approximates Omega from below is to compute the values of omega_n() >for increasing n, where for a fixed n omega_n() looks at all programs P of >bitlength <= n, and for each one that halts within n seconds, adds >1/2**len(P) to a running total (where len(P) is my spontaneous >notation for the bitlength of P). This gives, for increasing n, a >non-decreasing sequence of rationals that converge to Omega (but with a >non-computable convergence rate). > >The relation to coin-tossing is this: *each* time he flips a coin he >appends a 0 or 1 bit (depending on whether heads or tails comes up). The >coin-tossing stops when the program is complete; the "self-delimiting" >business is crucial here, else you couldn't know when to stop; then there >are technical details about strings that aren't well-formed programs, etc. >But the finer a point you want to draw the more the details become >important, and I think we're already beyond what Usenet is any good for. > >> ... >> The previous paragraph is a precise/rigorous >> specification of "Omega is the probability that >> a random program halts" > >It's some sort of probability measure, yes, but not Chaitin's. Yup. (Although whether it's Chaitin's measure or not it _does_ show that "Omega is the probabilty a random program halts" does _not_ imply that the n-th bit of Omega cannot be 1 iff the nth TM halts, as someone whose name I forget said.) >> (except it doesn't quite pin down what Omega _is_ since it does >> not specify exactly what order we put the Turing machines in at >> the start. To actually _define_ the sequence T1, T2,... we'd need >> to get into details of the syntax we were using to define TM's.) > >Yes, and "Chaitin's constant" too is really a function of the specific >universal Turing machine in question. Without qualification, it usually >refers to the Omega of a specific UTM he coded in Lisp and published. Indeed the exact value of Omega depends on the details of the encodings. What I'm wondering today is how many of his conclusions also depend on the details of the encoding. You say there are details regarding what to do when the next bit gives a syntax error. I'd assumed it was a magical encoding so that there were no syntax errors. You may be right about us having reached the limits of usenet. I'll give up soon. But I'm not going to take the time to actually learn all Chaitin's stuff (unless I do) and you're obviously much more familiar with it than I am (this follows from the fact that you're obviously somewhat famailar with it). Before I give up on accomplishing anything here answer me a question: Suppose I have a syntax where a valid program is precisely a sequence of 0's terminated by a 1. Any such string is a valid program. Does this count as "self-delimiting"? It seems to me that we can keep asking for one more bit - there are never any syntax errors, and as soon as we get a 1 we say we're finished, and then we ask whether the program halts. >However, Chaitin's defn doesn't involve a bijection between natural numbers >and machines, except in the incidental sense that programs are viewed as >bitstrings which *could* be viewed as integers -- but the defn makes no use >of that, only of the *lengths* of programs, and those are independent of >arbitrary orderings. Also depends on the particular syntax being used. (Which is not just a quibble - I do or do not have an interesting poiint here, depending on what the answer to the question in the previous paragraph is.) >> I don't think so. And in any case if you _do_ choose your program >> by flipping a coin as above that specifies a distribution, and with >> that distribution the probability that a random program halts _is_ >> a number with n-th bit = 1 if and only if the n-th TM halts. > >Can only repeat that it's a classic example, and, again, IIRC it doesn't >meet the criteria for randomness. Things must be crossing in the mail. No it does not meet the criteria for randomness, that was my point. > Could be I'm wrong about that, but this >is far enough removed from what I'm supposed to be doing right now that I'm >not going to go searching one way or the other. If you do, let me know what >you find out. > >> ... >> (And in fact when I think about how to do that >> and I think about how one would "naturally" >> order the TM's it's not clear to me that such >> non-randomness does not creep into Omega >> defined using a "natural" ordering...) > >As above, Chaitin's defn. is independent of ordering. > >> If I have the "definition" straight (and >> note that nothing I've said contradicts >> what you said about the definition!) then >> the bits of Omega are not going to be much >> use for an RNG. >> ... > >I agree with the conclusion regardless. > >> But it turns out that Omega _does_ solve a >> _different_ practical problem! What's the >> other pressing problem? Determining which >> reals have exact floating-point representations. >> >> Thm1. Omega does not have an exact representation >> in finite-but-unbounded-precision floating point. >> >> Thm2. Thm1 is all you can say about Omega, given >> the definition above: If x is any real (between >> 0 and 1) and x does not have an exact representation >> in finite-but-unbounded-precision floating point >> then there is an ordering T1, T2,... of our >> Turing machines that makes Omega = x. > >Since it's not a computable ordering, I'm not sure "solves" was the right >word . Note that recent results have shown that every non-computable >*random* real (in (0, 1)) is the (Chaitin-style) Omega for some >self-delimiting UTM. Where "random" means "normal", or at least implies normal? > That's a paraphrase. A precise statement requires >pages of defns, and again people interested enough should go the sources (I >gave a good link earlier in this thread). > >> ... >> (Devil's advocate: But if Omega can be 0.10101010... >> then how can it be incompressible? You're not actually >> saying Chatin's wrong about that, are you? > >No. I believe instead that there's no self-delimiting UTM (etc -- insert >paragraphs of defns here) s.t. 0.1010... is its Omega. All Omegas are known >to be random. Well right. It was a rhetorical question for myself, in a context where I was assuming things that turned out not to be so. (Note that the ordering that led to .10101010... was in fact non-computable.) ******************************** But this question is not meant to be rhetorical: We have a syntax where the valid programs are exactly finite sequences of 0's terminated by a 1. Does this count as "self-delimiting"? (On the one hand I don't see why not - we keep asking for bits until we get a 1. On the other hand Chaitin makes a remark about how these "self-delimiting" programs are not delimited by an EOF. But I don't see by what "natural" criterion "last bit is a 1" is not one of the allowable ways to looks at what we have so far and decide it's finished.) David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From emile at fenx.com Mon Jun 11 19:51:10 2001 From: emile at fenx.com (Emile van Sebille) Date: Mon, 11 Jun 2001 16:51:10 -0700 Subject: PEP 259: Omit printing newline after newline References: Message-ID: <9g3md2$73tb1$1@ID-11957.news.dfncis.de> This to save a comma? > >>> for line in open("/etc/passwd").readlines(): > ... print line, -- Emile van Sebille emile at fenx.com --------- "Guido van Rossum" wrote in message news:mailman.992290220.14360.python-list at python.org... > Please comment on the following. This came up a while ago in > python-dev and I decided to follow through. I'm making this a PEP > because of the risk of breaking code (which everybody on Python-dev > seemed to think was acceptable). From chrishbarker at home.net Fri Jun 8 17:37:14 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 08 Jun 2001 14:37:14 -0700 Subject: Newby question - Trimming spaces from a string References: Message-ID: <3B21458A.2B924908@home.net> Glen Mettler wrote: > I had to download "Lib.pdf" from the web > to find all the object model properties for "String" You'll find lib.pdf to be invaluable for many, everything. By the way, with Python 2.0 or 2.1 , you have access to most of the string functionality, so you don't need to import string, and can just do: s = " A sting with spaces " s.strip() This works for .split() an many others... -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From sholden at holdenweb.com Tue Jun 26 08:26:57 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 26 Jun 2001 08:26:57 -0400 Subject: Is this a mimetools/rfc822 bug? References: <15159.41247.812177.613322@anthem.wooz.org> Message-ID: "Sheila King" wrote in ... > On Mon, 25 Jun 2001 16:37:51 -0400, barry at digicool.com (Barry A. Warsaw) > wrote about Re: Is this a mimetools/rfc822 bug?: > > : > :>>>>> "SK" == Sheila King writes: > : > : SK> So far as I know, leading newline characters are not allowed > : SK> in the header. A newline character indicates the end of the > : SK> headers. > : > :Correct, and rfc822 is fairly strict about what it accepts. Leading > :empty lines in the text will toggle it over from "reading-headers" > :mode to "reading-body" mode. It's even worse if you have no headers, > :but your first body line has a colon in it! > > But, according to the RFC's a header is required. A message body is not > required. > > According to RFCs I recall: Your message header must have at least one > of the following headers: To, Bcc, or CC. I believe that is the minimal > header: any one of the To-type fields. No other headers are required, > and no message body is required. > You don't always get to deal with standards-conformant mail systems, though, so the classic Internet advice still stands: be precise in what you generate and tolerant about what you'll accept. I've had to deal with some mailers which will reject SMTP transactions because there was no Date: header! regards Steve -- http://www.holdenweb.com/ From donn at u.washington.edu Fri Jun 22 15:16:08 2001 From: donn at u.washington.edu (Donn Cave) Date: 22 Jun 2001 19:16:08 GMT Subject: Another Wart! string.find() [ was: namespace issue? ] References: <9gucf9$ruc$1@slb3.atl.mindspring.net> <3B337D2B.35F2FD47@home.net> Message-ID: <9h05ho$gto$1@nntp6.u.washington.edu> Quoth Chris Barker : | Andrew Dalke wrote: |> index(s, sub [,start [,end]]) -> int |> |> Return the lowest index in s where substring sub is found, |> such that sub is contained within s[start,end]. Optional |> arguments start and end are interpreted as in slice notation. |> |> Raise ValueError if not found. | | YEECCHHH!!! | | Never raise an exception for a perfectly normal, it will happen all the | time event. Sure, but always raise an exception if the caller isn't going to account for this perfectly normal event. Exceptions aren't about frequency. Similar exception usage is actually somewhat idiomatic in Python - try: i = x.find('#') x = x[:i] except ValueError: ... vs. try: v = x[k] except KeyError: ... Donn Cave, donn at u.washington.edu From pfortin at pfortin.com Fri Jun 1 17:03:42 2001 From: pfortin at pfortin.com (Pierre Fortin) Date: Fri, 01 Jun 2001 17:03:42 -0400 Subject: Interfacing GUI applications..? Message-ID: <3B18032E.21AF631E@pfortin.com> Hi, I've been searching for a couple of days now and must resort asking for help... Does anyone know if it's possible to interface to a GUI application via a Python script? I'm writing an application and would like to invoke Adobe's AcroRead (on Linux) and feed data to a "fill-in" PDF file. The minimum requirement is to make AcroRead think it's coming from the keyboard. Extra points for mouse events (or shortcuts, though not all menus items have shortcuts). Many thanks for any pointers, Pierre From nperkins7 at home.com Fri Jun 1 22:20:37 2001 From: nperkins7 at home.com (Nick Perkins) Date: Sat, 02 Jun 2001 02:20:37 GMT Subject: PIL speed and fear References: <16074dce.0106011402.14e4a491@posting.google.com> Message-ID: I would definitely run the filter in another thread, if it takes more than a fraction of a second. This will not make the filter run faster, but will simply keep the gui from 'freezing up' while the calculations are going on. From root at rainerdeyke.com Wed Jun 6 12:06:57 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 06 Jun 2001 16:06:57 GMT Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3B1B1825.8109BA83@lmf.ericsson.se> <2v4ohtgldvce84sn87kh1eg1lnes37getq@4ax.com> <3B1C9E65.B73A4FE@lmf.ericsson.se> <3B1DFD87.F3BFDB57@lmf.ericsson.se> Message-ID: "Attila Feher" wrote in message news:3B1DFD87.F3BFDB57 at lmf.ericsson.se... > Yep. But let's say I want to make a non-open-source stuff. Wrappers > are either GNU licenced or damn expensive to buy/make... SDL: Game API wrapper. LGPL, so it can be (and has been) used in closed-source commercial software. wxWindows: GUI API wrapper. LGPL with additional permission to redistribute in binary form without restriction, so it can be (and has been) used in closed-source commercial software. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From ken_chiba at hotmail.com Sun Jun 24 09:43:55 2001 From: ken_chiba at hotmail.com (Ken) Date: Sun, 24 Jun 2001 13:43:55 GMT Subject: How to install python on clean RH7.1 install References: <3b313462.13451051@news1.on.sympatico.ca> <3B33F025.D275AAB1@student.gu.edu.au> <3b35170a.268083173@news1.on.sympatico.ca> <3B353837.6A68A329@student.gu.edu.au> Message-ID: <3b35deb3.319196179@news1.on.sympatico.ca> On Sun, 24 Jun 2001 10:45:43 +1000, Joal Heagney wrote: > >*totally bewildered* Um. Have you checked to see if the libraries are on >your file system using ls? I'm suspecting that they would be. If they >are, it must be something to do with the dynamic loader, ld, but I've >never had to play with that seriously. If you get REALLY desperate, you >could always grab the source rpm and build using rpm --rebuild >python*src.rpm; rpm -U /usr/src/RPM/RPMS/i386/python*rpm. >-- > Joal Heagney is: _____ _____ > /\ _ __ __ _ | | _ ___ | > /__\|\ || ||__ |\ || |___|/_\|___] | > / \ \_||__ ||___| \_|! | | \ \ ! ... Two thoughts: Is there a particular place that the RPM is looking for these files - if so, are they in the right area (/usr/lib/)? Secondly - the output of the -vv on the install indicated that the presence of the other files was based on their presence in a db. I'm not completely familiar with RPMs, but I thought that might be referring to the RPM db. I tried doing a --rebuilddb, but that didn't change anything. I will try re-installing the openssl rpm, and see if that makes a difference. As to compiling the src rpm, I tried that - with less success than the RPM. It burns through compiling for about 5 minutes (P233MMX, 64mb), and then you see a LOT of "unrecognized file type" messages fly by, and eventually, the compile fails. Any other ideas? Thanks, kc From m.faassen at vet.uu.nl Sat Jun 9 12:49:53 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 9 Jun 2001 16:49:53 GMT Subject: Learning OOP... References: <9fm8ti$d92$1@newshost.accu.uu.nl> Message-ID: <9ftk3h$i7m$1@newshost.accu.uu.nl> Rod Weston wrote: > The reasons I feel a need to learn OOP languages are as follows: > 1. I feel that OOP offers the best conceptual fit for my programming > projects which are primarily business oriented. Okay, while a certain guy nickednamed 'topmind' over on comp.object would disagree, I like OO myself. It depends partially on how your mind works, though. > 2. Career choices - any programmer in today's market needs to be OOP > conversant and productive, preferably with a language that will be > recognized and used 'a lot', thereby generating profitable > opportunities. It's useful to be familiar with OO for this reason alone. > 3. I want to reuse code as much as possible. While OO techniques can help here, don't expect anywhere close to a silver bullet. Creating reusable code is *hard*. > 4. I want to reduce errors and take advantage of advanced debugging > tools. OO by itself doesn't help you there, I'd say. > 5. I want strong and flexible data typing - I know it sounds like an > oxymoron. I want the typing to be especially powerful (restrictive) > but I want to be able to define the constraints of the types myself. This isn't the case for Python. Python is flexible and powerful but doesn't do constraints very well. :) We like it that way. A language like Java or Ada or (perhaps especially) Eiffel is better suited for that. > 6. I want something relatively easy to use and to learn. That's Python, compared to most other languages. > 7. I want reduced development times and enhanced maintenance tools. I'm not sure if OO helps here. Depends mostly on the framework you use. > 8. I want portability and scalability. No OO involved here. > 9. I want a lot of open source code available. Lots of it in Python. > 10. I want source code that is easily read. Python helps here. OO by itself can hurt and help. Depends on how you apply it. > 11. I want good quality but free or inexpensive tools - especially a > validated compiler to properly optimize my code for the task at hand > and catch as many errors as possible at compile time. Python doesn't do any of this, except that it's completely free and excellent quality. I've worked with C++ which does attempt to do the catching of errors at compile time and optimization, and you see which newsgroup I'm posting in. :) Ada or Java or C++ would help for those things. (or say, Ocaml) > Not all the objectives relate to OOP, but most do. Just remember: OO is far from a silver bullet! Especially the whole 'reuse' advantage has been overdone in the beginning years. > From what I've > seen so far, Ada best meets my criteria but I have not done enough > research yet to be willing to gamble my future on it. Ada, or Java, or Ocaml or a lot of other languages out there. How'd you arrive at Ada? Ada's OO support was not as strong, I thought, though perhaps in recent versions of the language this changed. It was initially designed before OO was all the rage, though. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From no_spam..python at dstanek.com-NOSPAM Mon Jun 18 21:25:07 2001 From: no_spam..python at dstanek.com-NOSPAM (David Stanek) Date: Mon, 18 Jun 2001 21:25:07 -0400 Subject: Python Idioms? Message-ID: <9gm9fk$pfm$1@news.chatlink.com> In reading through the Python source code I came across some oddities. In some modules, specifically threading, the instance objects are created using a kind of factory method. e.g. class _X: pass def X(*tupArgs, **dicArgs): return apply(_X, tupArgs, dicArgs) When the class could just as easily been named X. Is there an advantage to doing things this way? Also I noticed in the same module: import sys _sys = sys del sys What does this do? You still have a reference to the module. What difference does it make what the name is. David Stanek From rnd at onego.ru Tue Jun 12 02:13:29 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 12 Jun 2001 10:13:29 +0400 (MSD) Subject: localisation of IDLE? Message-ID: Hello, it turned out that under Windows IDLE doesn't allow cyrillic to be print. People pointed me that the problem is with TK support for Unicode, which broke cyrillic support. Is there some edit-the-registry, tweek-Windows solution to this problem (that is, solution, which doesn't require to change files from Python distribution? (ActivePython not an option). Thanks! Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, June 12, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "My cat likes to play Hide-And-Go-Poop." _/ From aleaxit at yahoo.com Tue Jun 12 03:25:32 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 12 Jun 2001 09:25:32 +0200 Subject: NULL is your friend! (was Re: Basic gadfly question) References: <9e6V6.15027$lq1.4843531@typhoon.austin.rr.com> <#ub8hWv8AHA.277@cpmsnbbsa07> Message-ID: <9g4g5b029k@enews2.newsguy.com> "Steve Holden" wrote in message news:#ub8hWv8AHA.277 at cpmsnbbsa07... ... > column of each row must hold a value. In general it isn't necessarily sinful > to build databases holding NULL values, but the whole NULL idea, bringing > triple-valued logic in tow as it does, is full of pitfalls for the unwary. ...but the *LACK* of NULLs is even trickier! In the real world, you often may not (or not yet) know what value some entry has/will have for all of its attributes, yet need to add the entry anyway. Most forms on the web, for example, have some mandatory fields (the NOT NULL columns:-) and several optional ones. In practice, then, what people do when a database engine doesn't support NULL (or, more often, when they've been advised to avoid NULL for some didactical reason by well-meaning authors and teachers:-) is to pick out some "magical value" that (they think...) "just can't happen" in the real data, and *simulate* NULL with it. Without any intrinsic DB support -- slow, cumbersome, unsafe (no error checks...), tricky in the utmost. Sometimes for example the Price column is set to -1 to mean "price not known yet", where NULL should be used for the purpose -- since no real-world price can be <0, this is "safe", is it not...? Well... not really. One of these days somebody will query the AVG(Price) and get a misleadingly low value because all of the '-1's are being added and counted... if NULL had been used, AVG(Price) would intrinsically ignore all records with NULL Price. Who's going to guarantee that every writer of queries always keeps in mind the need to add the WHERE Price>0 qualification? Nobody, that's who. What IS inevitably connected to pitfalls (because of *intrinsic* complexity) is that fact that we NEED to have incomplete records in our DB -- records for which the data are not entirely known (or, not yet). Given that source of complexity, NULLs are the best way to handle it. Trying to do without NULLs is a very tiresome and unrewarding exercise. > You may find that you can use a null string ("") to represent no value. A ...which is exactly what you'd be very well advised not to do:-). Oh, you may HAVE TO, if you MUST do without NULLs, but it's just the start of your troubles. One day you'll join on that field and get a LOT of "very interesting" results... > lot depends on the application. As a matter of interest you can download > enough of the Jet engine to establish ODBC data sources without having to > buy and load Access itself. Jat, and also the MSDE engine, which IIRC comes > as a part of the Office suite and also as a part of VisualStudio, can be > freely redistributed if you have the right license. AFAIK (but IANAL), the EULA for Jet lets you freely redistribute it. http://support.microsoft.com/support/kb/articles/Q239/1/14.ASP (last update June 1, 2001, with info on Jet 4.0 SP5, the latest and maybe last-ever Jet release AFAIK) has all the details -- you need three different downloads for /2000, for /ME, and for all older OS's (/95, /98, /NT 4). Depending on your needs you may also want to add the "Jet compact" download, and/or MSDAC (the universal Data Access download, which doesn't bundle Jet any more), but all the links you need are on the above-mentioned URL anyway. For MSDE (the SQL Server engine), see the URL: http://msdn.microsoft.com/vstudio/msde/genfaq.asp There, you do need to have a valid Professional or Enterprise license for Microsoft Visual Studio, or Office 2000 Developer, to "distribute these solutions to end-users royalty free", as Microsoft puts it. If you do qualify, for downloading it see http://msdn.microsoft.com/vstudio/msde/download.asp. All of this refers to MSDE 1.0, equivalent to SQL Server 7. I have no personal experience yet with MSDE 2000 (equivalent to SQL Server 2000), but see URL: http://www.microsoft.com/sql/techinfo/development/2000/MSDE2000.asp The licensing seems very similar. I'm not sure where to download it from (we got it as part of an MSDN subscription). It does not support Windows/95 anymore. > Thanks to Alex Martelli for pointing some of this out to me. You're welcome! It's probably worth pointing out once again that any of these solutions DO lock you into a Microsoft operating system plaform for deployment, and that MySQL or PostgresSQL may therefore prove preferable if one is thinking of cross-platform deployment (either now or as a future possibility). SAP DB, Interbase, and others yet might allow similar ease and freedom of no-cost cross-platform development & deployment, but I have no personal experience with them whatsoever. For didactical purposes, I would also consider Ocelot, at http://ourworld.compuserve.com/homepages/OCELOTSQL/ -- they claim full SQL 92 compliance with several SQL 99 parts, and have a large array of didactical resources. Alas, their free product is Windows-only *AND* not freely redistributable (you'd have to direct your users to visit their site for free download, an often-impractical approach; or, negotiate with them for redistribution) -- so, didactical reasons are probably the only ones to recommend Ocelot (it IS good for that, for all I can judge so far, though). Alex From pj at sgi.com Thu Jun 21 10:01:03 2001 From: pj at sgi.com (Paul Jackson) Date: 21 Jun 2001 14:01:03 GMT Subject: PEP 255: Simple Generators References: Message-ID: <9gsumv$ib5r2$1@fido.engr.sgi.com> Certainly what Guido says about there being no chance of stackless in core Python carries serious weight here. Let me add that in my experience there are two places that typical single thread control is not adequate. In one case, there are two, maybe three, pieces of naturally looping code, each of which wants to own the outer loop, calling the others. Perhaps one piece of code wanting to loop on input, a second wanting to loop on a calculation being accomplished incrementally on the flow of data, and a third wanting to loop on output. Typically, all but one of them has to be recoded, as some sort of iterator with state. Seems like 'yield' is a natural for that case. Sweet, very sweet. In the other case, of more-or-less independent control flow, I fork a process and let them communicate, if need be, via a pipe or socket. Usually, I use a line oriented, ascii format across the pipe, not some binary encoded bits. This provides me with a natural way to trace activity. Transparent clarity of communication is usually (except for lower levels of protocol or very high usage) more important than squeezing the last byte out of the transmitted data. In college I studied synchronization methods via shared memory for large numbers of threads -- even published a paper in the ACM Journal on it. Since then, except for once coding some low level semaphore ops in an mp library, I've never had use for such. But perhaps I'm dating myself. Perhaps programmers trained in the 1990's (well, 1980's for Carnegie-Mellon) are more indoctrinated (yes, a biased choice of wording) in threads. There is a (meta) parallel thread to this, running on the Linux Kernel Mailing List (lkml) right now, where the old farts are casting dispersions at the youngins' for wanting the Linux scheduler to handle one to three orders of magnitude more threads than actual cpus. Sometimes the world gets into strange harmonics ... -- I won't rest till it's the best ... Manager, Linux Scalability Paul Jackson 1.650.933.1373 From sheila at spamcop.net Sat Jun 9 23:12:39 2001 From: sheila at spamcop.net (Sheila King) Date: Sun, 10 Jun 2001 03:12:39 GMT Subject: New guy question References: <9oBU6.128578$I5.32912060@news1.rdc1.tn.home.com> Message-ID: On Sun, 10 Jun 2001 02:59:17 GMT, "Glen Mettler" wrote in comp.lang.python in article <9oBU6.128578$I5.32912060 at news1.rdc1.tn.home.com>: :> Based on the '>>>' prefix It looks like you're entering this into the :> python interpreter. In that context, to get the same behaviour, you :> would probably want to do something like "execfile('alook.py')" Try :> running "python alook.py" from the shell/dos command prompt, instead. :> It might be helpful to work through a tutorial. The one at :> www.python.org/doc/tut is pretty good, imo. :> :> Alex. : :Actually, I am working thru a tutorial right now. I don't recall it saying :anything about the differences between the DOS window and the IDLE window. :In any case, I went to the DOS window and this is what I get: : :>>> python alook.py : File "", line 1 : python alook.py : ^ :SyntaxError: invalid syntax :>>> : :Glen You are not in a DOS window if you have the >>> which is what D-man was trying to tell you. If you went to the Start Menu, and then Programs, and then Python, and then DOS Window, that puts you in the Python Interpreter within a DOS Window. Do this: Go to the Start Menu Go to Programs Go to MS-DOS prompt This will open a small window with a mostly black background. You should not see the >>> Instead, you will see something like C:\Windows\Programs> or something like that at the prompt above, type python alook.py and then see what happens. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From glyph at twistedmatrix.com Mon Jun 25 19:50:17 2001 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: Mon, 25 Jun 2001 18:50:17 -0500 (CDT) Subject: PEP 255: Simple Generators In-Reply-To: <15158.45706.973100.272298@anthem.wooz.org> Message-ID: On Sun, 24 Jun 2001, Barry A. Warsaw wrote: > > >>>>> "GL" == Glyph Lefkowitz writes: > > GL> If python's answer to "what should we do with new feature X"? > GL> is "add a keyword" it will turn into Perl before too long. I > GL> think that most of us agree that print>> is a disturbing > GL> symptom of this already :) > > Why? No keywords were added. :) Neither are any keyword additions required to make _-__<<__+__>>__-_ a syntactically valid statement (in fact, it already is), but I still think it smacks somewhat of perl. Turning it into an interpreter-enforced idiom would be a bad idea :) ______ __ __ _____ _ _ | ____ | \_/ |_____] |_____| |_____| |_____ | | | | @ t w i s t e d m a t r i x . c o m http://twistedmatrix.com/users/glyph From tgos at spamcop.net Sat Jun 2 16:34:10 2001 From: tgos at spamcop.net (TGOS) Date: 2 Jun 2001 15:34:10 -0500 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> Message-ID: On Fri, 1 Jun 2001 13:46:15 -0400, "Bart Kowalski" wrote: >> I mean, how many webpages are there that say "You NEED IE 5.5 to watch this >> page"? Too many. The fact that this means 50% (or more) of all surfers will >> simply skip this page is a risk they are willing to take. > > More, actually. By doing such stupid things they are completely ignoring all of > the Unix world I know. Whenever I surf through the Net at University (Sun Ultra Spars Solaris PCs, SGI Irix PCs, HP-UX PCs or Intel Linux PCs), I'll have to realize how little people uphold official standards and how many pages won't work because of this. Instead of using lots of JavaScript, people can use simple CGI scripts. Instead of using most plugins that exist, people could simply use Java (I heard a rumor that there's even a Java FlashPlayer applet, which will render Flash animations in your browser without the help of any plugin). > and technologies far superior to anything that Windows users > could ever dream of using. To quote from my Unix book: "All operating systems are limited in one way - many even in more than one way - but Unix is standing above the other systems, since it's a reliably platform for beginners and experts like no other existing one. For more than 20 years, Unix got improved by over hundred thousands of people all over the world [...]" Often if a new technologies is introduced to Window PCs (either through Micro$oft or via a private company), it usually was developed and tested on Unix PCs several for years before. > It's amazing how some people are so easily influenced > by commercial propaganda. I'm not better than them. I store all my videos in RealVideo format, which is no open standard either (it belongs to RealNetworks). The problem is: There is no other video standard that would create decent videos with only 450 KBit/s ASF is worse in quality (both, picture and sound quality) and it's also a Micro$oft only standard, meaning it will never exist for other platforms (RealPlayer also exists for Linux and maybe also for other platforms). DivX is a hacked ASF version, which is even worse in quality (as it's a hacked version of an old ASF codec, not of the first one that was officially released). Despite that, when using DivX, I'll have to use MP3 for audio and MP3 with 64 KBit/s sounds worse than real audio with 32 KBit/s. The only open standards are MPEG1 and MPEG2, but both need a lot more bandwidth than 450 KBit/s to produce decent results. And since I must get 10 videos onto a single CD, I can't use more than 450 KBit/s for picture and sound together. MPEG4 will be the first open standard that will produce decent results with 450 KBit/s (DivX isn't really MPEG4, the final MPEG4 standard will not be compatible with DivX anymore), but right now it only exists in theory. What's left? Quicktime...but Quicktime is no audio/video codec, it's just a file/protocol standard like ASF or AVI and you'll still have to use some kind of codec. -- TGOS From alan.gauld at bt.com Wed Jun 20 07:58:32 2001 From: alan.gauld at bt.com (Alan Gauld) Date: Wed, 20 Jun 2001 12:58:32 +0100 Subject: Which IDE ? References: Message-ID: <3B308FE8.282BD41@bt.com> D-Man wrote: > On Tue, Jun 19, 2001 at 05:57:00PM +0100, phil hunt wrote: > | I think professional programmers often prefer simple tools (i.e. > | text editor and command line). > > Sounds like a reasonable guess to me (at least wrt Unix programmers, I > think more MS Windows programmers use Visual Studio and other similar > tools). Yeah, thats one of the big culture differences between the two groups. When we get a "Windoze guy" on contract who is freaked by the *nix approach I usually explain it by says that the OS *is* the IDE. Its just because Windows doesn't provide the basic tools built ij that you have to use an IDE to make up the difference. Stop thinking of the Unix tools as separate programs and see the whole system as a big textual based IDE and it starts to make sense. Alan G From haaserd at yahoo.com Fri Jun 8 19:00:55 2001 From: haaserd at yahoo.com (haaserd) Date: Fri, 08 Jun 2001 16:00:55 -0700 Subject: How do I serve an image from a python script? References: <9fos4p$3ms$1@ctb-nnrp1.saix.net> <3B2039DB.8884C4B4@yahoo.com> Message-ID: <3B215927.34945AF0@yahoo.com> Works! Thank you, thank you. Roger Haase piet at cs.uu.nl wrote: > >>>>> haaserd (h) writes: > > h> Hi, > h> I am trying to serve an image from a Python script using Apache under > h> Windows. My simple HTML statement: > > h> a picture > > h> ...and my simple script: > > h> #!c:/Python20/python.exe > h> import sys > > h> def pix(): > h> n = 'c:/My Pictures/Sample.jpg' > h> p = open(n,'rb') > h> apix = p.read() > h> p.close() > h> sys.stdout.write("content-type: image/jpeg\n\n") > import os, msvcrt > msvcrt.setmode(sys.stdout.fileno(),os.O_BINARY) > h> sys.stdout.write(apix) > h> sys.stdout.flush() > > h> if __name__ == '__main__': > h> pix() > -- > Piet van Oostrum > URL: http://www.cs.uu.nl/~piet [PGP] > Private email: P.van.Oostrum at hccnet.nl From piet at cs.uu.nl Fri Jun 8 08:50:24 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 08 Jun 2001 14:50:24 +0200 Subject: How do I serve an image from a python script? References: <9fos4p$3ms$1@ctb-nnrp1.saix.net> <3B2039DB.8884C4B4@yahoo.com> Message-ID: >>>>> haaserd (h) writes: h> Hi, h> I am trying to serve an image from a Python script using Apache under h> Windows. My simple HTML statement: h> a picture h> ...and my simple script: h> #!c:/Python20/python.exe h> import sys h> def pix(): h> n = 'c:/My Pictures/Sample.jpg' h> p = open(n,'rb') h> apix = p.read() h> p.close() h> sys.stdout.write("content-type: image/jpeg\n\n") import os, msvcrt msvcrt.setmode(sys.stdout.fileno(),os.O_BINARY) h> sys.stdout.write(apix) h> sys.stdout.flush() h> if __name__ == '__main__': h> pix() -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From max at alcyone.com Sun Jun 3 23:03:17 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 03 Jun 2001 20:03:17 -0700 Subject: random problem References: Message-ID: <3B1AFA75.A48CF01E@alcyone.com> Tim Peters wrote: > Somehow or other on your box the 1.71552776992141 is getting printed > as 1. > The value it's computing (2,82843) doesn't make sense either. Have > heard no > other report of this, although occasionally a bad platform C library > has > produced exp() and/or sqrt() results a *little* bit insane. What > you're > seeing is completely off the wall, and in more than one way. The one thing I noticed is the comma where a decimal point should be. Could the queer behavior be because of localized number issues? -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ A good indignation brings out all one's powers. \__/ Ralph Waldo Emerson Computer science / http://www.alcyone.com/max/reference/compsci/ A computer science reference. From ryanmorillo at hotmail.com Fri Jun 15 04:57:39 2001 From: ryanmorillo at hotmail.com (Ryan) Date: 15 Jun 2001 01:57:39 -0700 Subject: Parrot-0.2.6 released References: Message-ID: <4a7fde99.0106150057.69a89a23@posting.google.com> I like the syntax for this much better than the standard TK style for python, pretty amazing for a pre alpha. Looks like it should shorten the time for makeing a GUI by a factor of at least 10 for those of us that still have to pull out a book everytime we want to make one. Keep up the good work, and if I can comeup with anything I'll make sure to send it your way. anyone who is curious, it is deffinetly worth the time to check it out, very highly recomended! philh at comuno.freeserve.co.uk (phil hunt) wrote in message news:... > I have just released Parrot version 0.2.6. > > Parrot is a text-based GUI builder. It is intended to be used > by programmers writing GUI applications. Parrot is written in > Python. > > To use Parrot, you write a text file descriping your > application's GUI. Then you invoke the Parrot program, which > reads your file and produces output code implementing the GUI. > At the moment, Parrot can produce two sorts of output: > > * HTML containing the GUI > * a Python program which when run will implement the GUI > using Python's Tkinter interface to Tk. > > The current release contains modifications contributed by > Ludger Humbert () to > get radio buttons working correctly. > > Parrot is currently pre-alpha code, so don't expect to > do much useful work with it yet. > > Parrot is available from: > http://www.vision25.demon.co.uk/oss/parrot/intro.html > > Parrot is licenced under the GNU GPL. From alankarmisra at hotmail.com Fri Jun 29 09:13:47 2001 From: alankarmisra at hotmail.com (gods1child) Date: 29 Jun 2001 06:13:47 -0700 Subject: types.CodeType doesnt exist? Message-ID: <25b2e0d9.0106290513.3a2f4c71@posting.google.com> Platform: Win2000, Python 2.0 I was looking at the copy.py source and found this snippet ----------------------------------------------------- d = {} d[types.UnicodeType] = _copy_atomic try: d[types.CodeType] = _copy_atomic except AttributeError: pass d[types.TypeType] = _copy_atomic ----------------------------------------------------- under what circumstances will the types module not have attribute CodeType? From whisper at oz.nospamnet Tue Jun 5 04:34:45 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 5 Jun 2001 08:34:45 GMT Subject: Why doesn't this work as expected? Message-ID: <9fi5j5$pk6$0@216.39.170.247> I'm trying to build a directory walker, doing some work on each actual file found in each directory. However, when I run the below code snippet on a directory containing both sub-directories and files, it says that all are not dirs. What is not right? TIA, Dave LeBlanc import sys import os import dircache import re def getDirs(): print dircache.listdir("l:/languages/python") for dir in dircache.listdir("l:/languages/C"): if os.path.isdir(dir): print dir, "is a dir" else: print dir, "is not a dir" getDirs() From tim.one at home.com Sun Jun 3 21:53:57 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 3 Jun 2001 21:53:57 -0400 Subject: random problem In-Reply-To: Message-ID: [Alvaro Lopez Ortega] > I've a little problem with Python 1.5.2 (Debian Potato): > > === > import random > File "/usr/lib/python1.5/random.py", line 84, in ? > verify('NV_MAGICCONST', 1.71552776992141) > File "/usr/lib/python1.5/random.py", line 77, in verify > raise ValueError, \ > ValueError: computed value for NV_MAGICCONST deviates too much (computed > 2,82843, expected 1) > === > > Somebody knows how can I fix it? :-?? No clue -- this system is too broken to use. This is the code it's executing: def _verify(name, expected): computed = eval(name) if abs(computed - expected) > 1e-7: raise ValueError( "computed value for %s deviates too much " "(computed %g, expected %g)" % (name, computed, expected)) NV_MAGICCONST = 4 * _exp(-0.5)/_sqrt(2.0) _verify('NV_MAGICCONST', 1.71552776992141) Somehow or other on your box the 1.71552776992141 is getting printed as 1. The value it's computing (2,82843) doesn't make sense either. Have heard no other report of this, although occasionally a bad platform C library has produced exp() and/or sqrt() results a *little* bit insane. What you're seeing is completely off the wall, and in more than one way. From nas at python.ca Mon Jun 18 21:23:45 2001 From: nas at python.ca (Neil Schemenauer) Date: Mon, 18 Jun 2001 18:23:45 -0700 Subject: PEP 255: Simple Generators In-Reply-To: <20010618180807.A8534@glacier.fnational.com>; from nas@python.ca on Mon, Jun 18, 2001 at 06:08:07PM -0700 References: <9glhg7$dlk$1@nntp6.u.washington.edu> <20010618180807.A8534@glacier.fnational.com> Message-ID: <20010618182345.A8604@glacier.fnational.com> I wrote: > def f1(n): > for i in range(n): > yeild i ---------------^^ Yes, that is the way the keyword will be spelled. That's what Jeremy gets for not allowing me to use "suspend". :-) Neil From offer at sgi.com Fri Jun 1 13:59:17 2001 From: offer at sgi.com (Nhi Vanye) Date: 1 Jun 2001 17:59:17 GMT Subject: Python equivilent to dlopen/dlsym ? References: <9f8fos$cuh4d$1@fido.engr.sgi.com> Message-ID: <9f8l5l$cvh35$1@fido.engr.sgi.com> $ from mwh at python.net -#142634 | sed "1,$s/^/> /" > > >offer at sgi.com (Nhi Vanye) writes: > >> What would be the python equivilent of dlopen()/dlsym(). I'm trying to >> prototype some C code that will use dlopen to open a shared library and >> ldsym() to call a particular function in it. >> >> The python file that implements the functions is listed in a runtime >> configuration file. Because the configuration file will list multiple >> python modules that each have the same function defined (I'll will chain >> them when I call them) I don't want to pollute the name spaces. >> >> Any clues ? > >Does execfile do what you want: > >d = {} >execfile("/path/to/file.py",d,d) >sym = d[symbol_name] > >? If not, I'm not sure what you're after. Good enough. Thanks. > >Cheers, >M. > richard. -- Richard Offer Technical Lead, Trust Technology. "Specialization is for insects" __________________________________________http://reality.sgi.com/offer/ From chris.gonnerman at newcenturycomputers.net Mon Jun 11 22:13:34 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Mon, 11 Jun 2001 21:13:34 -0500 Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: <200106112007.f5BK7eW22506@odiug.digicool.com> <3B253031.AB1954CB@lemburg.com> Message-ID: <002001c0f2e5$4ce543e0$0101010a@local> I have to say, I'm strongly against this PEP... does anyone else agree with me? ----- Original Message ----- From: "M.-A. Lemburg" Subject: Re: [Python-Dev] PEP 259: Omit printing newline after newline > Guido van Rossum wrote: > > > > Please comment on the following. This came up a while ago in > > python-dev and I decided to follow through. I'm making this a PEP > > because of the risk of breaking code (which everybody on Python-dev > > seemed to think was acceptable). > > > > --Guido van Rossum (home page: http://www.python.org/~guido/) > > > > PEP: 259 > > Title: Omit printing newline after newline > > ... > > Scope > > > > This only affects printing of 8-bit strings. It doesn't affect > > Unicode, although that could be considered a bug in the Unicode > > implementation. It doesn't affect other objects whose string > > representation happens to end in a newline character. > > I guess I should fix the Unicode stuff ;-) > > > Risks > > > > This change breaks some existing code. For example: > > > > print "Subject: PEP 259\n" > > print message_body > > > > In current Python, this produces a blank line separating the > > subject from the message body; with the proposed change, the body > > begins immediately below the subject. This is not very robust > > code anyway; it is better written as > > > > print "Subject: PEP 259" > > print > > print message_body > > > > In the test suite, only test_StringIO (which explicitly tests for > > this feature) breaks. > > Hmm, I think the above is a very typical idiom for RFC822 > style content and used in CGI scripts a lot. I'm not sure whether > this change is worth getting the CGI crowd upset... > > Wouldn't it make sense to only use this technique in inter- > active mode ? > > -- > Marc-Andre Lemburg > CEO eGenix.com Software GmbH > ______________________________________________________________________ > Company & Consulting: http://www.egenix.com/ > Python Software: http://www.lemburg.com/python/ > > -- > http://mail.python.org/mailman/listinfo/python-list > > From kgmeyer at comundo.de Thu Jun 7 12:51:20 2001 From: kgmeyer at comundo.de (C. Meyer) Date: Thu, 7 Jun 2001 18:51:20 +0200 Subject: unicode, filenames and umlaut... Message-ID: <9fobmf$5ampi$1@ID-58571.news.dfncis.de> Hello, i am new to Python. I have a problem with umlaut in filenames. First a small sample which works fine: Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> from tkFileDialog import * >>> import fileinput >>> fn = askopenfilename() >>> fn 'C:/Berlin.txt' >>> print fn C:/Berlin.txt >>> open(fn) >>> for line in fileinput.input(fn): print line ... BERLIN, Berlin Same sample, but now "M?nchen.txt" selected in askopenfilename(): >>> fn = askopenfilename() >>> fn u'C:/M\374nchen.txt' >>> print fn Traceback (most recent call last): File "", line 1, in ? UnicodeError: ASCII encoding error: ordinal not in range(128) >>> open(fn) Traceback (most recent call last): File "", line 1, in ? UnicodeError: ASCII encoding error: ordinal not in range(128) >>> for line in fileinput.input(fn): print line ... Traceback (most recent call last): File "", line 1, in ? File "c:\programme\python20\lib\fileinput.py", line 158, in __getitem__ line = self.readline() File "c:\programme\python20\lib\fileinput.py", line 227, in readline self._file = open(self._filename, "r") IOError: [Errno 2] No such file or directory: 'C' Hm, if the filename contains umlauts, askopenfilename() returns an unicode. But print, open and fileinput.input don't like it? What ist the "correct" solution for this problem? A hint may help... (but fn.encode("LATIN-1") don't help) Another surprise (for me): If i use the new Option -U (Force Python to interpret all string literals as Unicode literals), i could not import any module!!?? C:\>python.exe -U Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> import string Traceback (most recent call last): File "", line 1, in ? ImportError: No module named string >>> from tkFileDialog import * Traceback (most recent call last): File "", line 1, in ? ImportError: No module named tkFileDialog Thanks From Denys.Duchier at ps.uni-sb.de Tue Jun 19 17:55:26 2001 From: Denys.Duchier at ps.uni-sb.de (Denys Duchier) Date: 19 Jun 2001 23:55:26 +0200 Subject: PEP 255: Simple Generators References: Message-ID: The one thing that rubs me the wrong way with this proposal is that it is not compositional. Unless I misread the PEP, the entire generation logic must be defined in a single function (because the `yield' keyword must statically occur within the body of the generator function). This makes it impossible to use higher-order programming to assemble complex generators from smaller blocks. One way to address this issue would be to make the dynamic bracketing explicit, for example as an annotation on the function which is intended to wrap the generator (this has been proposed by many, albeit for different reasons). I won't make a proposal of my own, but I'll just point out that the issue is very much related to the old duality control/prompt (Felleisen) or later shift/reset (Filinski) in the continuation world. Cheers, -- Dr. Denys Duchier Denys.Duchier at ps.uni-sb.de Forschungsbereich Programmiersysteme (Programming Systems Lab) Universitaet des Saarlandes, Geb. 45 http://www.ps.uni-sb.de/~duchier Postfach 15 11 50 Phone: +49 681 302 5618 66041 Saarbruecken, Germany Fax: +49 681 302 5615 From mwh at python.net Fri Jun 1 13:15:51 2001 From: mwh at python.net (Michael Hudson) Date: 01 Jun 2001 18:15:51 +0100 Subject: Python equivilent to dlopen/dlsym ? References: <9f8fos$cuh4d$1@fido.engr.sgi.com> Message-ID: offer at sgi.com (Nhi Vanye) writes: > What would be the python equivilent of dlopen()/dlsym(). I'm trying to > prototype some C code that will use dlopen to open a shared library and > ldsym() to call a particular function in it. > > The python file that implements the functions is listed in a runtime > configuration file. Because the configuration file will list multiple > python modules that each have the same function defined (I'll will chain > them when I call them) I don't want to pollute the name spaces. > > Any clues ? Does execfile do what you want: d = {} execfile("/path/to/file.py",d,d) sym = d[symbol_name] ? If not, I'm not sure what you're after. Cheers, M. -- Our lecture theatre has just crashed. It will currently only silently display an unexplained line-drawing of a large dog accompanied by spookily flickering lights. -- Dan Sheppard, ucam.chat (from Owen Dunn's summary of the year) From grante at visi.com Sun Jun 24 20:42:27 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 25 Jun 2001 00:42:27 GMT Subject: Is this a true statement? References: Message-ID: On Sat, 23 Jun 2001 14:38:24 -0400 (EDT), Steven D. Majewski wrote: >> > Writing TO a device driver is easy enough... the previous poster >> > was talking about writing the DRIVER in Python. No OS I'm aware >> > of takes device drivers in any languages other than assembler, C, >> > and/or C++. >> >> He's making a very finicky, nitpicking, and frankly silly point [...] > >I don't think the point was entirely silly! >It was a valid and interesting point (despite being finicky and >nitpicking!) Yes, it's trivially and obviously valid: a driver is a bit pattern, and you can write a bit pattern to a file with Python. If you show an example of how this is a useful and productive way to generate a device driver, _then_ it will be interesting. Until then, it's just somebody chattering to hear themselves talk. -- Grant Edwards grante Yow! YOW!!! I am having at fun!!! visi.com From JamesL at Lugoj.Com Fri Jun 1 14:06:49 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Fri, 01 Jun 2001 11:06:49 -0700 Subject: Obsolesence of <> (fwd) References: <9f6el30dv5@enews2.newsguy.com> <3B16D681.E12A4554@Lugoj.Com> <9f7pmt029se@enews1.newsguy.com> Message-ID: <3B17D9B9.E3CA8EC8@Lugoj.Com> Alex Martelli wrote: > The "pseudo-mathematical" ideas being those based on < and > which > Lulu just proposed? Well then, if those ideas have any worth, then, > GIVEN (as decided by the BDFL) that < and > don't apply, neither > must <>. The only "justification" needed for != is: SOME inequality > operator is needed, and it must definitely not be <>, which WRONGLY > suggests analogies to < and >. Shrug. You haven't made a specific case for "!=". I say that one may segue from "<>" as applied to simple numbers, to application to sets of other things where "<>"'s semantic historical origins aren't as valid. You seem to insist that any hint of properties in the notation used for real numbers should not be used for analogous operations on other sets or groups. I say that is contrary to how mathematical and programming notation evolves to best suit programmers. Consider for a moment multiplication. On real numbers the operation is commutative. On matrices it is not. (And it is computationally more involved.) Yet the same multiplication symbol or notation may be used in both cases. Even in Python a symbol like "*" may be applied to a number and a string with a non obvious meaning. But "+" may not be applied to a mix of strings and numbers. By the way, do you object to "+" used for string concatenation? (This WRONGLY suggests an analogy to numeric addition.) If not, why is it okay to take "+" or "*" and put them to use for things that are not numbers, but it is not okay for "<>"? I think you are biased and I'm afraid I'm going to have to report you to the "Less Than or Greater Than Liberation Front". We at LTGTLF may just have to introduce you to the COMFY CHAIR. Then maybe you will see reason! > Besides, given the existence of "print >> blah", we're suffering > from a serious surfeit of "order characters not meaning order" > already:-). Let's abate it wherever we can...:-) Hey, don't look at me. I'm still using 1.5.2. I have no idea what you are talking about. ;-) > "There should be one, and ideally only one, obviously correct way > to do something". Having two entirely synonymous operators is > unPythonic. It's an ideal, of course, not a practical reality -- > pow(x,y) vs x**y, apply(spam,args) vs spam(*args), etc, shows that > multiple ways to "do something" can and will survive in Python > (particularly for legacy/historical reasons). It's still a worthy > ideal to aim at, in my humble opinion. Then we are agreed that "!=" should be obsolete? Whew! glad that is settled. From loewis at informatik.hu-berlin.de Fri Jun 8 13:15:32 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 08 Jun 2001 19:15:32 +0200 Subject: python 2.1 install problem References: Message-ID: jorgenru at jeeves.stud.ntnu.no (J?rgen Ruud) writes: > I have downloaded python 2.1, and done a configure with the > --prefix=/local swotch. But I want to install python to another > directory than /local, because i'll will use it as a package to > distribute other to machines. With some MAKEFILES you can use: 'make > DESTDIR=directory install' (where DESTDIR, is the destinationdirectory) > to install it to another place. Is this possible with python? (I know > it dosn't use the DESTDIR option) For Python (and any autoconf-generated project), you do 'make prefix=directory install' It always helps to study the makefile to realize your opportunities. Regards, Martin From Eugene.Leitl at lrz.uni-muenchen.de Sat Jun 16 05:01:27 2001 From: Eugene.Leitl at lrz.uni-muenchen.de (Eugene.Leitl at lrz.uni-muenchen.de) Date: Sat, 16 Jun 2001 11:01:27 +0200 Subject: Suggestions for a Strange Project? References: <3b2abb77_1@news3> Message-ID: <3B2B2067.B60A6989@lrz.uni-muenchen.de> Mega Hurts wrote: > Some things never change. Too bad. > My current setup consists of four machines, running > Win98. I use a single monitor and infrared keyboard/ Good idea, wrong OS. Winders doesn't do networking very well -- but there's VNC, of course. And diverse remote administration packages, Back Orifice et al. > mouse, and switch from one machine to another with > a KVM switch. I connect to the internet on the first > machine, which runs a proxy, and the other machines > can run mail, FTP, news and web clients. I use a couple > of the boxes for compute-intensive MPEG recording, and > when they are busy, can switch to the others for office > activities. Soon I will change the fourth box to Linux. VNC is your friend here, again. Actually, I live on half a dozen boxes at work, all of them *nix (and one Winders box, via VNC), and it is really hard to tell where you are, as it looks so seamless. The bash shell versions differ, though (and I keep them that way), and of course the home directories do, and I've deliberately configured Netscapes to look different. > To switch from box to box, I press CTL-CTL-1, or > CTL-CTL-2, etc. The fun begins: I don't have to switch anything. All the different windows live on one or several virtual desktops. The clipboard works. The only problem is which Netscape gets the url pasted if I use KDE's smart clipboard, which knows the http://pattern. > [1] I use background colors and a labeled icon to remind > me which context I'm in. Things get fun when I am > working in a file, copy text or a graphic, switch to > another machine- AND FORGET THAT I CAN'T PASTE. You can't? That's just too bad, it's trivial with X. It's annoying being unable to paste from VNC, though. > [2] Or I'm using my beloved and vital graphics pad and > switch machines, only to be reminded that the cursor > on one machine and one only is under Wacom control. One word: X. Never no troubles no more. > [3] All the clocks lose and gain time at different > rates. This becomes important when recording off-air > scheduled events, and updating the clocks on four machines > is just another chore. Crontab an NTP server. Takes care of clock synching, without screwing anything up. > Well, Rochester... I'm thinking. All these boxes can > talk to each other via that zippy 100Mb LAN. Yeah, X is really a pleasure over Fast Ethernet. > Now, why can't machine #1 share its web-updated clock > info, and machine #2 share its graphics-tablet cursor > info when needed, and all of them write to a common > 'clipboard'? They can. > A lightweight task running on all machines should provide > the connectivity and clock awareness, cursor and mouse-key-awareness. Any > suggestions on where to start? http://www.linux.org After you're done with that, http://scyld.com . Then your diverse boxes really become a *single* computer. To make this less off-topic: anyone uses Python/MPI here? (Apart from Konrad, I mean). -- Eugen* Leitl ______________________________________________________________ ICBMTO : N48 10'07'' E011 33'53'' http://www.lrz.de/~ui22204 57F9CFD3: ED90 0433 EB74 E4A9 537F CFF5 86E7 629B 57F9 CFD3 From bedge at troikanetworks.com Mon Jun 4 12:48:45 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Mon, 04 Jun 2001 09:48:45 -0700 Subject: overriding /usr/lib and /usr/include directories References: <20010531.164958.1977648522.1900@mead.troikanetworks.com> <9f9s05$lgv$0@216.39.151.169> Message-ID: <20010604.094845.1432114613.30442@mead.troikanetworks.com> In article <9f9s05$lgv$0 at 216.39.151.169>, "Donn Cave" wrote: > Quoth "Bruce Edge" : | I'm building python for > an embedded environment, and it's apparently | picking up the library > names from /usr/lib. How do I tell it where to look | for shared libs, > like libreadline.so.4.2 for example? | > | My host has /usr/lib/libreadline.so.4.1, while in my target env my | > LD_LIBRARY_PATH points to a dir containing libreadline.so.4.2, and the | > python readline module as it's looking for the version it found in | > /usr/lib. > > Sounds like setup.py to me, though I haven't thought very hard about it > since you don't say what version of Python or provide much of any other > details about what you're doing. Anyway, in 2.1, setup.py builds the > dynamically loaded modules, and it has /usr/lib hard-coded. If you want > something else, you can just modify setup.py accordingly. I believe > it's fairly obvious; you may have to dive way down into the distutils > layer beneath setup.py for some things, but /usr/lib should be right > there in setup.py. > > Donn Cave, donn at oz.net I am using 2.1 I found I could do it by passing parameters to setup.py: %> python setup.py build_ext --help shows --library-dirs (-L) directories to search for external C libraries (separated by ':') Unfortunaely, Makefile.pre.in just involes it as: # Build the shared modules sharedmods: $(PYTHON) PYTHONPATH= ./$(PYTHON) $(srcdir)/setup.py build which build everything, but does not give you a chance to spec your own dirs. Also, when invoked with the "build" arg, the -L option is not available. By modifying it as follows, and building the build_ext section separately, you can get is to go look in a different dir. # Build the shared modules sharedmods: $(PYTHON) PYTHONPATH= ./$(PYTHON) $(srcdir)/setup.py build_ext -L lib PYTHONPATH= ./$(PYTHON) $(srcdir)/setup.py build Unfortunately, this is not an option that you can set via ./configure. So, I got it working, but it's be nice if you could just provide a --with-libdir option to ./configure. -Bruce. From r2d2 at mao.acc.umu.se Sat Jun 9 15:18:43 2001 From: r2d2 at mao.acc.umu.se (Niklas Frykholm) Date: Sat, 9 Jun 2001 19:18:43 +0000 (UTC) Subject: Python Shareware? References: <9fr2jm$16v$1@brokaw.wa.com> Message-ID: >Okay, here's my opinion on shareware: Don't do it, it's too much hassle. > >If you are interested in making software, you should be interested in >making it good. So you GPL the code, allow everyone to use it, and modify >it, and thus the software will become good/the best/whatever. > >If you are interested in making _money_, you have to have a product or a >service to sell. Software is not a good product, but *support* for the I have made some money from shareware, not fortunes, but some money. About 30 % of the money I made came from people who paid the shareware fees. 70 % came from comapanies who said: "hey, this shareware is nice, can we get the source and write our own version?". If I had GPLd I don't think I would have gotten any money. I love GPL, it's socialism that works in practice, but if you need the money... I would discourage you from putting nags and protection mechanisms in your shareware though (I never had any). Distrusting and annoying your customers is not the best way to make business. It is better to make paying as simple as possible than to make stealing as hard as possible. >There is another benefit to you of free software: If you are really good at >programming, you can show off with your GPL'ed code, and use that to get >into a company that is willing to pay you to code stuff for them. You can't >show off code that is closed-source, like code from, say, your previous >job. But you can show your shareware code to anyone you want to, so this argument isn't really relevant. (In retrospect, I'm kind of happy that not too many people has seen my old shareware code. Let's just say my coding has... erm... improved. :) >I think a steady income of $100,000 or more a year will benefit more than >the meager sales of a shareware piece of software. Plus, you get the >comfort of knowing your check shows up every month, and it's the same >amount each time. Agreed. But what is the price of freedom? To beat your wings rythmically under the open sky instead of riding the subway to the Corporation. Ah... maybe I should quit my day job... // Niklas From skip at pobox.com Thu Jun 21 08:29:51 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 21 Jun 2001 07:29:51 -0500 Subject: Codeobjects of Modules? In-Reply-To: <9gs7ou+ro76@eGroups.com> References: <9gs7ou+ro76@eGroups.com> Message-ID: <15153.59583.603980.192467@beluga.mojam.com> gunter> Now I want to run entire pyc-Files and/or modules. How do I get gunter> the bytecode from modules and what is the format of the gunter> pyc-files. I could not find any documentation. I believe you want to look at the code in marshal for marshalling and unmarshalling code objects and the code in the runtime that calls it (start with the import code). I'm not sure the format is well-documented outside of comments in the source code and the source code itself. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From sheila at spamcop.net Mon Jun 25 21:53:43 2001 From: sheila at spamcop.net (Sheila King) Date: Tue, 26 Jun 2001 01:53:43 GMT Subject: Is this a mimetools/rfc822 bug? References: <15159.41247.812177.613322@anthem.wooz.org> <673D8B1EC8@kserver.org> Message-ID: On Mon, 25 Jun 2001 16:53:32 -0400, barry at digicool.com (Barry A. Warsaw) wrote in comp.lang.python in article : :>>>>> "SK" == Sheila King writes: : : SK> But, according to the RFC's a header is required. A message : SK> body is not required. : : SK> According to RFCs I recall: Your message header must have at : SK> least one of the following headers: To, Bcc, or CC. I believe : SK> that is the minimal header: any one of the To-type fields. No : SK> other headers are required, and no message body is required. : :True, but the rfc822 module doesn't enforce any of these requirements, :AFAIK. So it's really much more of an issue of the rfc822.py module's :API than it is of the actual RFC. Sorry, I didn't make my point well. You stated that: Barry > It's even worse if you have no headers, Barry > but your first body line has a colon in it! My point, was that rfc822 requires a header, however minimal. (I know it technically requires one of the following: To, CC, Bcc..whatever, the point is a header is required.) The rfc822.py module really doesn't try to enforce RFC822 at all. It assumes that the programmer will be sufficiently knowledgeable in the RFCs to use the module correctly. I can't imagine why anyone would want to use rfc822.py if they only had a message body and no header. rfc822.py is really written for handling headers. I guess it is incumbent upon the programmer using the module to check his data first, and make sure it conforms to the assumptions that rfc822.py makes: namely, that it will be starting to read at a header, that there will be to newline characters in a row to mark the end of the headers, and that after that it will be pointing to the message body (if there is one). -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From rhystucker at rhystucker.fsnet.co.uk Wed Jun 6 20:18:24 2001 From: rhystucker at rhystucker.fsnet.co.uk (rhys) Date: Thu, 07 Jun 2001 01:18:24 +0100 Subject: How to change Pythonwin background colour? References: <3B1E8047.17E114FC@rhystucker.fsnet.co.uk> <3B1EBEF4.6080103@ActiveState.com> Message-ID: <3B1EC850.7655D790@rhystucker.fsnet.co.uk> Mark Hammond wrote: > > rhys wrote: > > > I need to change Pythonwin's background colour from bright white. I've > > managed to change a lot of it through the colour configuration options > > but not the interactive window. > > I'm afraid it can not be done short of hacking the code. > > Mark. Mark, Thank you for your reply. I attended your presentation at the accu conference and and am following your (excellent;) book. This is a real problem for me as I have a sensitivity to bright light. I've downloaded the Pythonwin source - is it just a matter of finding white_brush or something similar, changing it and recompiling? regards, rhys From glyph at twistedmatrix.com Mon Jun 4 16:28:44 2001 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: Mon, 4 Jun 2001 15:28:44 -0500 (CDT) Subject: I NEED to TEACH you something, QUICK! Message-ID: Good morning, Python Mailing List. > >You raped 10 women... > only 1 > >massacred children... > 13 year olds are not children in my culture > >And killed my Irish Setter on Saturday. > YOU PIG YOU PIG IT WAS AN IRISH WOLFHOUND!!!! I've got to say that I'm a little concerned by the fact that the first unsolicited posting (that I'm aware of) about our software comes along with a discussion of raping women, massacring children, and killing household pets. I suppose, having recently integrated more code that changes an instance's class at run-time, it was only to be expected. > Hej Twisted Matrix! Are you chaos wizards or order wizards or a mix? As to the alignment of the Twisted Matrix as a whole; personally, I'm a chaotic-neutral elven wizard. Other currently active party members include Moshe Zadka, an ordered-good dwarven warrior, Allen Short, a chaotic-good human Archeologist, and Chris Armstrong, a neutral-neutral thief. We have some in reserve of varying alignments and character classes. > Have you figured out yet that your hacks will go to hell if half of > you guys are doing `first we remove sufficient order in order to find > the creative heart of chaos' while across the street `first we tidy up > a bit, adding enough order until our eyes stop hurting'. Both of these seem misguided approaches to me. I don't search for the creative heart of chaos or my inner child while I'm programming; I look for an approach to solving the problem which works well. Doing that usually involves a blend of order and chaos, but also many other things which don't neatly fall into one category or other. In fact, *most* things it involves don't. In a general form, though, our process is something like eXtreme programming. Lots of unit tests, and issues get fixed as they come up. We try very hard never to have a CVS repository which is broken. We refactor all the time and consider the simplicity of the code a feature which we're always working towards. Functionality is an asset but code is a liability. Is this "chaotic" or "ordered"? We recognize that change (chaos?) is a necessary and good part of development, but we have a plan (order?) for managing it. Of course, we like everything to be just a little bit silly (as you may have noticed in our naming scheme), otherwise writing all this software for free would be no fun. > Unless the hack is `make the coolest party in the universe' guys handle the ordering of things, unless you like having to make a > musical production for a band that happens to have 37 trombones in it> I don't know if that's "the hack", but we certainly are 'the coolest party in the universe'. > you are better off with seprate namespaces. This is the most > important thing I learned in the last 10 years, so I hope you either The most important thing *I* learned in the last ten years was "don't use acetylene as cake frosting", which is probably a more important lesson (especially if you're baking the cake). However, in the interests of learning from your experience; separate namespaces for what? Given that we're using python, we have separate namespaces for every module and our coding standard forbids "from ... import *". > think that it is valuable time saved, or that you are all rolling > around the isles now laughing because you are way too cool for > limitations like that, and my problem is that I am not twisted enough > to make it work. Can I come over and talk sometime? Or is this a > no-old-farts sort of thing? You are certainly welcome to come over and talk sometime. We're on irc.openprojects.net #python almost 24 hours a day... Old farts are also not only allowed, but encouraged. Much of my design style was gleaned by listening to my father talk about the halcyon days of APL on the mainframe and Smalltalk in the enterprise, before all this Java and C++ nonsense took hold, as well as hanging around Lispers and listening to them wish, teary-eyed, that the lisp machine would make a comeback somehow. If you look carefully at the way 'twistd' works, and you replace "pickle" with "image", you'll note some startling similiarities between Smalltalk servers and Twisted ones. Thanks for the recognition; as they say, "no publicity is bad publicity". ______ __ __ _____ _ _ | ____ | \_/ |_____] |_____| |_____| |_____ | | | | @ t w i s t e d m a t r i x . c o m http://twistedmatrix.com/users/glyph From rsiebler at ibeam.com Thu Jun 21 21:26:57 2001 From: rsiebler at ibeam.com (Robin Siebler) Date: Fri, 22 Jun 2001 01:26:57 GMT Subject: Stop/Start Service in Win2k References: <%4vY6.9705$Up.285700@sea-read.news.verio.net> <3B329854.1050405@ActiveState.com> Message-ID: That's it. Thanks! PS: If I ever get good enough to write the patch, I'll be happy to do so. "Mark Hammond" wrote in message news:3B329854.1050405 at ActiveState.com... > Robin Siebler wrote: > > > win32service.SERVICE_QUERY_STATUS) > > api_error: (1060, 'OpenService', 'The specified service does not exist as an > > installed service.') > > > > > > Could someone tell me why this happens and how to fix it? > > > Probably because you need to use the "service short name" rather than > the "service description". Most UI tools display the description rather > than the shortname. You really need to look in the registry for the > short name (HKLM/System/CurrentControlSet/Services". > > A patch to win32serviceutil that tries to locate the short name given > the long name would be gratefully accepted :) > > Mark. > From chat at linuxsupreme.homeip.net Tue Jun 26 13:56:55 2001 From: chat at linuxsupreme.homeip.net (Chad Everett) Date: 26 Jun 2001 12:56:55 -0500 Subject: UserDict and setattr Message-ID: Using UserDict and overriding getattr, I can create dictionary wrappers that allow dictionary lookups via getattr. Using the example below: apple = Fruit( {'name':"apple",'color':'red'} ) carrot = Veggie( {'name':"carrot",'color':'orange'} ) apple.color # returns 'red' apple['color'] # returns 'red' apple['color'] = 'green' apple.color # returns 'green' apple['color'] # returns 'green' apple.color = 'brown' apple.color # returns 'brown' apple['color'] # returns 'green" !!!!!!!!! Obviously, setattr needs to be altered to also update the dictionary (via __setitem__) and not just the instance's attributes I cannot seem to find a way to override setattr so that I can get the get a __setitem__ called to update the dictionary. Please Help!!! Code sample follows: import UserDict class DictWrap(UserDict.UserDict): def __init__(self,initdict): self.data = initdict def __getattr__(self,name): return self.data[name] class Fruit(DictWrap): def __init__(self,initdict): DictWrap.__init__(self,initdict) class Veggie(DictWrap): def __init__(self,initdict): DictWrap.__init__(self,initdict) apple = Fruit({'name':"apple",'color':'red'}) carrot = Veggie({'name':"carrot",'color':'orange'}) -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From speedy911 at mindspring.com Fri Jun 22 11:17:47 2001 From: speedy911 at mindspring.com (Charles Harrison) Date: 22 Jun 2001 08:17:47 -0700 Subject: A recommendation on programming tutorials? References: <7417e9e.0106212115.20f3fafe@posting.google.com> Message-ID: <6f78b8b.0106220717.372d2329@posting.google.com> You might want to check out http://www.ibiblio.com/obp . This is a site maintained by my high school which has very good tutorials for begginers for many subjects including python. From guido at python.org Thu Jun 21 09:09:38 2001 From: guido at python.org (Guido van Rossum) Date: Thu, 21 Jun 2001 13:09:38 GMT Subject: PEP 255: Simple Generators References: Message-ID: Glyph Lefkowitz writes: > Generators a-la PEP 255 seem like a *very* bad idea to me. > > Generators can be implemented through continuations (as shown in > Stackless) or through microthreads (as shown in the various previous > implementations of generators which use *real* threads cooperatively). Yes, as the PEP says. > Neither microthreads nor continuations are implementable through > generators. I believe that generators (as described in PEP 255) are a > merely a convenience, but real cooperative multithreading could be very > useful and we would get generators *for free*. > > While I am heavily in support of stackless being integrated for many > reasons, I can understand the unfavorable sentiments that some harbor > towards continuations. They can be nastily abused. They are > confusing. They interact very poorly with operator overloading and > exception handling. It has nothing to do with "unfavorable sentiments". It has to do with the practicality of getting it implemented. Everything else you wrote would be relevant if there was a chance of getting Stackless implemented in core Python any time soon. But it's not going to happen -- Stackless has too many issues that would need to be resolved one way or another; it too has many seemingly arbitrary restrictions that make it impossible to just adopt Christian Tismer's code. --Guido van Rossum (home page: http://www.python.org/~guido/) From salnikov at inp.nsk.su Wed Jun 6 05:28:29 2001 From: salnikov at inp.nsk.su (Andy Salnikov) Date: Wed, 6 Jun 2001 16:28:29 +0700 Subject: Interesting speed benchmark References: <3B1D6FED.4070506@nospam.yahoo.com> <9fkh50$6e1$1@panix6.panix.com> Message-ID: <9fkt3u$1i0ub$1@sky.inp.nsk.su> "Aahz Maruch" wrote in message news:9fkh50$6e1$1 at panix6.panix.com... > My guess is that this represents a pathological case for Python's memory > management system. Each time through the outer loop after the first, > Python has to walk the chain of 10K objects, deallocating them > one-by-one I'd better say that it represents a pathological case for Java memory management, which does not bother to destroy unreachable objects and instead eats up memory like a pig:) Anyone compared memory usage in these two tests? Andy. From aleaxit at yahoo.com Fri Jun 1 15:55:44 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 1 Jun 2001 21:55:44 +0200 Subject: Python equivilent to dlopen/dlsym ? References: <9f8fos$cuh4d$1@fido.engr.sgi.com> Message-ID: <9f93pc21ioh@enews1.newsguy.com> "Nhi Vanye" wrote in message news:9f8fos$cuh4d$1 at fido.engr.sgi.com... > > What would be the python equivilent of dlopen()/dlsym(). I'm trying to > prototype some C code that will use dlopen to open a shared library and > ldsym() to call a particular function in it. > > The python file that implements the functions is listed in a runtime > configuration file. Because the configuration file will list multiple > python modules that each have the same function defined (I'll will chain > them when I call them) I don't want to pollute the name spaces. You may use __import__() to dynamically load a named module, and getattr() to obtain the named attribute from the module object (or the functions in standard module imp, if you need finer control, but __import__/getattr may mimic well the dlopen/dlsym distinction you need to prototype). Alex From m.faassen at vet.uu.nl Fri Jun 29 19:08:18 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 29 Jun 2001 23:08:18 GMT Subject: PEP scepticism References: <9hfg1n$du33c$1@ID-89274.news.dfncis.de> <3B3B59DA.35F6B71D@Lugoj.Com> Message-ID: <9hj1p2$bdu$3@newshost.accu.uu.nl> James Logajan wrote: > Bernhard Reiter wrote: >> >> This a general warning against the second system syndrom in Python. > [ Elided. ] > Thank you, Bernhard. I agree with your unease. I have the same unease. It would seem to me that the features that most trouble people are new syntax or changes to syntax. Semantic changes are strangely enough not seen as so troubling, as often it's an attempt to make the semantics more general (healing the type/class split, for instance). Perhaps it would be a good idea to consider a strategy to slow down the syntactic changes by saying we can only have new ones every other Python release (let's say the uneven ones, though no parallel with Linux stable/development kernel is implied). The even releases would focus on: a) tweaking with the interpreter (making it faster, fixing bugs, also perhaps 'generalizing' semantics such as type/class and the number system) b) *adding to the standard library*! The latter does not appear to get a lot of focus in the PEPs, though it may be my selective reading that does it. But a clear focus on the standard library by the core developers couldn't be bad, right? The even releases would have a moratorium on changes that would involve changes to the language syntax, and any change that really should require such a change (but we're submitting the PEP anyway as we want it so badly, and we'll just do a hackish application of the current syntax instead. This is of course bad too). What do people think about the general idea? Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From xyzmats at laplaza.org Sun Jun 3 17:18:08 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Sun, 03 Jun 2001 21:18:08 GMT Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> <3B1A5D10.A7139942@iinet.net.au> Message-ID: <3b1aa80b.14709421@news.laplaza.org> >If you're interrested in Software then I know of the following that's not in >the commercial arena: > >* I read the other day that the new version of dia (0.88.1) to some degree >supports UML for Python specifically! I downloaded it yesterday (from >Sourceforge I think) but haven't looked at it yet. > >* There are a couple of Python specific UML projects underway on sourceforge >but they seem to be pre-alpha. How about some pointers? =================================================== There's a kit floating around called ArgoUML. It seems pretty functional, but as far as generating anything, it's Java-based. (Surprise!). On their wishlist, though, is something like "add support for another language". Hmmm...there might be an opportunity there for someone with lots of time on their hands... As far as books, "UML Distilled" is supposed to be pretty good, but it's not going to go into the whole modelling/development methodology thing, just scratch the surface. Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From bsass at freenet.edmonton.ab.ca Thu Jun 28 17:03:14 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Thu, 28 Jun 2001 15:03:14 -0600 (MDT) Subject: Augmented Assignement (was: Re: PEP scepticism) In-Reply-To: <3B3B7842.E2DA92DB@ActiveState.com> Message-ID: On Thu, 28 Jun 2001, Paul Prescod wrote: > I think Python has been getting better and better as time goes on. But I > do have a concern about augmented assignment. How can a newbie > understand that tuples are "immutable" if this works: > > mytuple += (foo,bar) Ya, ok, it was a rhetorical question maybe this sequence would help explain it to someone... >>> a = 1,2 >>> b = a >>> a, b ((1, 2), (1, 2)) >>> id(a), id(b) (135055732, 135773292) >>> a = a + 3,4 Traceback (most recent call last): File "", line 1, in ? TypeError: can only concatenate tuple (not "int") to tuple >>> a = a + (3,4) >>> a (1, 2, 3, 4) >>> id(a) 135523340 >>> a += 5,6 >>> a, b ((1, 2, 3, 4, 5, 6), (1, 2)) >>> id(a), id(b) (135746564, 135773292) > Worse, once they've learned that this does NOT affect other references > to mytuple they are bound to be confused by > > mylist += [foo, bar] > > which does! >>> a = [1,2] >>> a [1, 2] >>> id(a) 135320620 >>> a += [3,4] >>> id(a) 135320620 > I've seen this confusion already -- in a draft of a book no less. Once they see that "adding" tuples creates a new object (it has to, tuples are immutable), and the alternative is manually concatenating the tuples yourself... ...what was a wart becomes a feature. - Bruce From dgoodger at bigfoot.com Tue Jun 19 22:39:15 2001 From: dgoodger at bigfoot.com (David Goodger) Date: Tue, 19 Jun 2001 22:39:15 -0400 Subject: ANN: reStructuredText: markup for docstrings Message-ID: reStructuredText on SourceForge: http://structuredtext.sf.net/ reStructuredText is an easy-to-read, what-you-see-is-what-you-get plaintext markup syntax and parser system. It is useful for in-line program documentation (such as Python docstrings), for quickly creating simple web pages, and for standalone documents. It is a candidate markup syntax for the Python Docstring Processing System (http://docstring.sf.net/). So far, the project consists mostly of the specification (written using reStructuredText, of course!), but I have started coding the parser. An example of fully marked-up Python docstrings can be found in the statemachine.py module (http://docstring.sf.net/dps/statemachine.py). It implements a finite state machine specialized for regular-expression-based text filters, and is being used by the reStructuredText parser. The best place to discuss reStructuredText and other documentation issues is on the Python Documentation Special Interest Group (Doc-SIG) mailing list: http://www.python.org/sigs/doc-sig/. -- David Goodger dgoodger at bigfoot.com Open-source projects: - Python Docstring Processing System: http://docstring.sf.net - reStructuredText: http://structuredtext.sf.net - The Go Tools Project: http://gotools.sf.net From tim.one at home.com Sun Jun 24 18:39:40 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 24 Jun 2001 18:39:40 -0400 Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: [Roman Suzi, on my gcomb example] > This implementation is cool, but how fast will be recursive generators? > How large is the overhead to defrost execution frame each time? Will it > be faster than functional gcomb? The high-order bit is that I couldn't care less: you can do generator implementations "like this" in your sleep once you're used to the idea, and it's extremely convenient -- meaning it's the least burden on *my* time to get from idea to working implementation. But if you're dead serious about machine time in Python, you don't use recursion of any flavor. That said, I'll attach a complete timing program below. Note that the structures of the generator and recursive versions are almost exactly the same. This isn't an accident: a "gather the elements into a giant list" algorithm can usually be transformed into a one-at-a-time generator very easily just by replacing the appends with yields, and a return of an empty list by stopping the generator (a raw "return"). On my box at the moment (Win98SE), the generator version below-- and on the test case shown --is about a 50% speedup over the recursive version (about .16 seconds for gcomb and .24 for rcomb). less-filling-and-tastes-great-ly y'rs - tim PS: In rcomb, a good speedup can be obtained by replacing for c in rcomb(rest, k): result.append(c) by result.extend(rcomb(rest, k)) Then gcomb's speed advantage fell to about 25%. But rcomb still has to materialize the memory for 3,432 7-element lists in one gulp, while gcomb's memory use is minimal. def gcomb(x, k): "Generate all combinations of k elements from list x." if k > len(x): return if k == 0: yield [] else: first, rest = x[0], x[1:] # A combination does or doesn't contain first. # If it does, the remainder is a k-1 comb of rest. for c in gcomb(rest, k-1): c.insert(0, first) yield c # If it doesn't contain first, it's a k comb of rest. for c in gcomb(rest, k): yield c def rcomb(x, k): "Return list of all combinations of k elements from list x." result = [] if k > len(x): return result if k == 0: result.append([]) else: first, rest = x[0], x[1:] # A combination does or doesn't contain first. # If it does, the remainder is a k-1 comb of rest. for c in rcomb(rest, k-1): c.insert(0, first) result.append(c) # If it doesn't contain first, it's a k comb of rest. for c in rcomb(rest, k): result.append(c) return result seq = range(1, 5) print "Sanity check for generator:" for c in gcomb(seq, 2): print c print print "Sanity check for recursive version:" for c in rcomb(seq, 2): print c print def timer(f, seq, k): from time import clock count = 0 start = clock() for x in f(seq, k): count += 1 finish = clock() return count, finish - start N = 14 seq = range(N) k = N / 2 print "Timing gcomb and rcomb on %d-combs of a %d-element list:" % (k, N) for trial in range(5): for func in gcomb, rcomb: count, time = timer(func, seq, len(seq)/2) print " %s returned %d results in %.3f seconds" % ( func.__name__, count, time) From glen at enabledventures.com Wed Jun 27 10:34:02 2001 From: glen at enabledventures.com (Glen Starchman) Date: Wed, 27 Jun 2001 14:34:02 GMT Subject: ARGH! Python2.1 build Message-ID: <3B39ED9F.9772B4E9@enabledventures.com> Perhaps I am in my own little problem domain, but I like to strip nearly every module out of the interpreter when I make builds for CGIs. Under 2.0 and below this was easy: comment nearly everything in Modules/Setup and build. Easy. Now, under 2.1 we are using DistUtils and it appears to me that the only way to *remove* a module from the build process is to add the module to disabled_modules_list in setup.py. What if I want nearly every module disabled? I *could* edit the Makefile directly, but it seems that there should be a better way. From Sibylle.Koczian at Bibliothek.Uni-Augsburg.de Fri Jun 15 07:19:27 2001 From: Sibylle.Koczian at Bibliothek.Uni-Augsburg.de (Sibylle Koczian) Date: Fri, 15 Jun 2001 13:19:27 +0200 Subject: Pmw installation problems Message-ID: <3B29EF3F.8E789A9@Bibliothek.Uni-Augsburg.de> Hello, I got Pmw.0.8.5.tar.gz and unpacked into c:\programme\python21\Lib\site-packages (Windows 2000 Pro SP 1, ActivePython 2.1). Reading the readme file in this directory and the comment in site.py I would have thought I could now use it from other directories simply putting "import Pmw" into my scripts - but that doesn't work ("No module named Pmw", I think). After reading "Installing python modules" in the Python documentation I looked for a script "setup.py" in the Pmw directory tree, but didn't find it. "Getting started with Pmw" didn't help either. Moreover, if I try to run tests/All.Py (from the tests directory) I get exactly the same error message as in the bug submitted 2001-03-12 - no answer to this bug, as far as I can see. Can anybody help? Thanks, Koczian -- ---- Dr. Sibylle Koczian Universitaetsbibliothek , Abt. Naturwiss. D-86135 Augsburg Tel.: (0821) 598-2400, Fax : (0821) 598-2410 e-mail : Sibylle.Koczian at Bibliothek.Uni-Augsburg.DE From missive at frontiernet.net Sat Jun 23 12:35:29 2001 From: missive at frontiernet.net (Lee Harr) Date: Sat, 23 Jun 2001 16:35:29 +0000 (UTC) Subject: adding instance methods after instantiation References: <9h1vg2$14cc$1@node21.cwnet.roc.gblx.net> <15156.42187.785702.181258@beluga.mojam.com> Message-ID: <9h2ggh$16k0$1@node21.cwnet.roc.gblx.net> On Sat, 23 Jun 2001 09:33:33 -0500, : > ----- Original Message ----- > From: "Skip Montanaro" >> Lee> Is there some way to make m2 an instance method so that it will >> Lee> automatically get passed c1 as its first argument? >> >> Check out the instancemethod function of the new module. > > Here is code based on Lee's sample: > > ###################################################### > ### adding an instance method after the fact > import new > > class c: > def __init__(self): > self.a1 = 1 > def m1(self): > self.a2 = 2 > > def m2(self): #note, outside of class c definition > self.a3 = 3 > > c1 = c() > c1.m2 = new.instancemethod(m2, c1, c) > > c1.m2() > print c1.a3 > > > > Thank you! That's exactly what I did after Skip's message. This is just what I was looking for. (Python and comp.lang.python continue to deliver!) From wart at softhome.net Mon Jun 4 11:50:29 2001 From: wart at softhome.net (Wartan Hachaturow) Date: 04 Jun 2001 19:50:29 +0400 Subject: Programming ASP with ActivePython [also a general Web question] Message-ID: <87lmn8fdmi.fsf@penguin.aktivist.ru> Hello. I've got one trouble with ASPs on Python -- they doesn't work ;) In fact, I did run pyscript.py, and it said that it has successfully registered python as a scripting engine. When I try to execute server-side scripts, they fail (saying 500 Server Error). In fact, client-side scripts does work in IE (even Calculator :) Since it's the first time I try to do anything on IIS/ASP, I can't even find the error logs (bye, bye /var/log/apache/error.log). Did anyone faced the same problem? I did included my try.asp in this message, just in case I'm wrong in the script: -- <%@ LANGUAGE=Python %> <% for i in range(3,8): Response.Write("Hello World!!
" % i) %> -- P.S. Can anyone advise me some nice Python web programming environment based on *nix? I've checked mod_python -- but it doesn't support sessions and persistent db connections, and I am too lazy to write them by myself. Zope seems to be too heavy and bloated (IMHO). In fact I'd like to have something really working in the production already (for example, WebWare doesn't seem to me being in that state), fast, and easy to write for (e.g. also supporting features such as mentioned sessions, persistent database connections). Maybe I didn't searched too long, but right now it seems to me (poor man I am) that ASP on Windows is the only solution. P.P.S. I am running IIS 5.0 on Win2k Advanced Server SP2, with ActivePython 2.1.0.210 -- Regards, Wartan. echo "Your stdio isn't very std." -- Larry Wall in Configure from the perl distribution From tgos at spamcop.net Thu Jun 7 15:21:10 2001 From: tgos at spamcop.net (TGOS) Date: 7 Jun 2001 14:21:10 -0500 Subject: best language for 3D manipulation over web ? References: <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3B1B1825.8109BA83@lmf.ericsson.se> <2v4ohtgldvce84sn87kh1eg1lnes37getq@4ax.com> <3B1C9E65.B73A4FE@lmf.ericsson.se> <3B1DFD87.F3BFDB57@lmf.ericsson.se> <9foeo8$fec$1@hadron.noos.net> Message-ID: On Thu, 7 Jun 2001 19:46:28 +0200, "Boyd Roberts" wrote: > "TGOS" a ?crit dans le message news: e03vhto1hehnstnnaj7ekru67lulnrme8v at 4ax.com... >> >> Now you can get Sendmail executing a command for you, like "bash" and this bash >> is then a root shell, because it was invoked by a root process. > > in your dreams. modern sendmails are very resistant to attack. I didn't say that this will still work today, I was just repeating what I found a page with a collection of (meanwhile fixed) Sendmail bugs. > it doesn't need to run as root, except to bind to port 25 and > then it can setuid to some 'mail' user. The fact that it doesn't have to root as root process is something I mentioned as well (actually I found a whole webpage about this topic). -- TGOS From sabren at manifestation.com Tue Jun 26 13:30:50 2001 From: sabren at manifestation.com (Michal Wallace) Date: Tue, 26 Jun 2001 12:30:50 -0500 (CDT) Subject: MSAccess databse from Linux box In-Reply-To: Message-ID: On Tue, 26 Jun 2001, michael montagne wrote: > In my effort to rebuild our intranet on a Linux box with Python I > need to retrieve information from several MSAccess databases. Is > there a way to do that with Python? Or Zope? Your best bet is probably to migrate the MSAccess data to something like MySQL. I believe there are tools that automate this process. (As a bonus, you can keep the MSAccess frontend and just talk to MySQL via MyODBC) Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.net www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ From phrxy at csv.warwick.ac.uk Fri Jun 29 16:00:58 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Fri, 29 Jun 2001 21:00:58 +0100 Subject: the center of the world (was Re: Check out O'Reilly's Open Source Convention Highlights) In-Reply-To: <9hhri7019jd@enews2.newsguy.com> References: <3B3AA82D.1A0FE860@seebelow.org> <3B3B2DED.5303198A@seebelow.org> <9hhri7019jd@enews2.newsguy.com> Message-ID: On Fri, 29 Jun 2001, Alex Martelli wrote: > "Grant Griffin" wrote in message > news:3B3B2DED.5303198A at seebelow.org... > ... > > But now that you mention it, the US Midwest *is* pretty centrally > > located on a "world" basis. [...] > An interesting exercise might be to define a *meaningful* > "central location" -- one based on population distribution [...] > Hmmm, if the coordinates were on a plane, finding the weighed > center would be trivial, but offhand I can't think of how to > do it on a sphere's surface -- I guess there must be some way > more suitable than just solving a generalized extremization > problem -- can anybody suggest one...? I remember noticing a book on the subject a while back, 'Circular Statistics', or something similar. Don't have the reference, though. All kinds of peculiar-looking expressions for means, moments, ANOVA, etc. on circles. Don't remember if it went into spherical coordinates or not. John From aleaxit at yahoo.com Sun Jun 3 13:29:00 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 3 Jun 2001 19:29:00 +0200 Subject: random References: <9fcu3601vet@enews2.newsguy.com> <3b1a564f.2986926@nntp.sprynet.com> Message-ID: <9fds6l01lo4@enews2.newsguy.com> "David C. Ullrich" wrote in message news:3b1a564f.2986926 at nntp.sprynet.com... ... > > but some would say the finite > >program is not "an algorithm" because it's not finite in time -- it > >may never halt > > Halting _is_ part of the standard definition of "algorithm"; > this is not what "some" would say. Sorry, you are simply wrong. Take for example (seems to be in Google's cache only, not at the originally referenced URL, so be fast in checking it:-): http://www.google.com/search?q=cache:2nixCLVhh-0:phobos.cs.unibuc.ro/mitecs/ work/dietrich_r.html+probabilistic+algorithm+terminate&hl=en """ First, mathematicians and computer scientists sometimes sharply restrict the definition of "algorithm." They take the definition of "algorithm" given here, and use it to define the notion of an effective procedure. Then they define an algorithm as an effective procedure which always halts or terminates. """ Note the "sometimes". I concur with this author. Many say "algorithm" without requiring absolute certainty of termination, while others use "effective procedure" for the general concept and only allow the use of the word "algorithm" when certainty of termination can also be proven. Once people stopped using "algorithm" to mean only what is today properly called "deterministic algorithm" and include also what is today called "probabilistic algorithm", it was, I think, quite proper that termination constraints fall also by the wayside. Consider just one example, http://www.di.unipi.it/~augusto/pub/selection/papers-pdf/dc.pdf the probabilistic algorithm it analyzes is by itself not necessarily terminating. "MOST OFTEN" it will terminate with a provably correct result quite a bit sooner than its deterministic brother, but quite possibly it might just keep going on and on instead. Not quite the exact kind of probabilistic algorithm most used today (e.g. for probabilistic testing of primeness) which does terminate in finite time BUT maybe with a wrong answer -- arguably more useful when applicable, since I _known_ where my algorithm hasn't terminated (yet) so that corrective action may be taken. Of course, _in practice_, as long as probability of non-termination (just like, probability of the answer being the wrong one for the more often used kind of probabilistic algorithm) can be set as small as desired by appropriate steps, the actual usefulness of the probabilistic approach is just as good as that of the deterministic one. > There's a _reason_ it's part of the definition. Elsewhere > you've claimed to be an engineer, seeming to imply you're > interested in practical matters. If you have a solution to > a problem but the "solution" takes infintely much time > does it really seem like a _useful_ solution in practical > terms? Sure, just like a solution that may not in fact be one (the answer from the other kind of probabilistic algorithm). On the practical plane, probabilities, when high enough, are amply sufficient -- in real life we ain't gonna get any certainty anyhow. > Like say we want to use Omega to give a "perfect" > arithmetic RNG. We can do that. Except that when > we call x = rand() the call _never_ _returns_. > If you're really interested in RNG's that never > return then I take back everything I've said, > yes, JVN was wrong, there's no problem with > arithmetic RNGeneration. I only need a high-enough probability of termination within a given finite time for one requested random bit. Say I monitor the process from the outside and if it's not done in (whatever) I raise an exception, take some corrective action, kill the runaway process. I don't request an infinite number of bits to be generated in finite time, OBVIOUSLY. I don't need infinitely many bits for whatever use I'm putting that random-number to -- just one bit at a time. > >So where's the "state of sin" in this arithmetical and almost-algorithmical- > >except-for-the-little-detail-of-finiteness approach to randomness? > > The quote from JVN was about someone _using_ arithmetic methods to > generate random numbers. If someone is "using" an RNG that _never_ > _returns_ then he is _not_ generating random numbers. (A fortiori > he is not using arithmetic methods to generate random numbers.) On those occasions when the algorithm (or effective procedure, or call it as you wish as long, as you don't call it late for dinner) is not terminating [within some needed time], detection of the fact and a back-up plan will be needed. So what? Aren't random bits still emerging -- one after the other -- in finite time on most occasions, with whatever probability we request if we can devote sufficient resources to the task? I strongly doubt this method is practical or can be made practical, differently from many other uses for probabilistic algorithms, though I would hardly be astonished if somebody more clever or lucky than me did manage to come up with a practical use. But, so what? Where was "practically useful" requested to avoid "a state of sin"? Alex From MarkH at ActiveState.com Wed Jun 20 22:53:19 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 21 Jun 2001 02:53:19 GMT Subject: makepy.py changed? References: <3b31f0bc.27273772@news.muenster.de> Message-ID: <3B31619A.4090906@ActiveState.com> Martin Bless wrote: > Again with the Activestate edition, now Python 2.1, makepy creates a > MUCH SHORTER source. The details of the spirit.ocx methods are > missing. I tried all the parameters - I couldn't convince makepy to do > 'better'. This was a bug introduced by adding "universal gateway support", causing some objects to not be correctly identified as supporting IDispatch. It should be fixed in ActivePython 211 or win32all-140. Please mail me if this is not the case. Mark. From tl_news at nexgo.de Sat Jun 30 09:54:15 2001 From: tl_news at nexgo.de (Tino Lange) Date: Sat, 30 Jun 2001 15:54:15 +0200 Subject: WinNT: Delete to recycle bin? References: <9hg04d$r9f$1@iocextnews.bls.com> Message-ID: <1fmrjt82k85818nngp0v0keo5blfgqeid1@4ax.com> On Fri, 29 Jun 2001 13:52:32 -0400 (EDT), you wrote: >thanks so much! >short of a python module, this is exactly what i'm looking for. Hallo John! today I played a bit with my compiler and Python. There must be a way to make the Recycler known to Python! Here's a "working version" of a Python module - not perfect, but it can do what you want: http://de.geocities.com/tinolange/python/pywindel.zip In this archive you find the dll together with the source code - you can modify it as you want and make it perfect for your application. If you have Python 2.1 on your windows machine, just copy the pywindel.dll in your (PYTHON)\DLLs - directory. If you have another version of Python or if you want to change things in the source code (I'm sure...) you have to re-compile the DLL with MSVC6 (Project file included). Example session in Python: (you want to delete t:\foo.bar) 0. [211738k] t:\>python ActivePython 2.1, build 210 ActiveState) based on Python 2.1 (#15, Apr 23 2001, 18:00:35) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import pywindel >>> pywindel.DelToRecycleBin('t:\\foo.bar') >>> print pywindel.LastStatus, pywindel.LastFile 0 t:\foo.bar >>> ^Z 0. [199135k] t:\> Remarks: * LastStatus 0 means sucessfully deleted, 1 means no success. You can always query this like above after a DelToRecycleBin call. * You can only give _one_ file to pywindel.DelToRecycleBin(). This filename has to be the _complete_ Path, not a relative one (if its relative, maybe the function will delete, but _not_ in the recycle bin!) It only deletes to recycle bin if you give the complete path! * You have to double \\ the backslashes like above. For the last two points you can easily write apython wrapper that preapares the DelToRecycleBin calls. Hope this helps! Have fun and a nice weekend! Ciao Tino From bob.hibberdine at ntlworld.com Tue Jun 12 05:01:34 2001 From: bob.hibberdine at ntlworld.com (Bob Hibberdine) Date: Tue, 12 Jun 2001 10:01:34 +0100 Subject: Help for Python newbie Message-ID: Hi, Any help with the following much appreciated. I want to convert a list of items into a tab separated string. According the Python manuals I can use join: I quote from the manual: join (words[, sep]) Concatenate a list or tuple of words with intervening occurrences of sep. The default value of sep is a single space character...... here's the output from the interpreter: PythonWin 2.0 (#8, Mar 7 2001, 16:04:37) [MSC 32 bit (Intel)] on win32. Portions Copyright 1994-2001 Mark Hammond (MarkH at ActiveState.com) - see 'Help/About PythonWin' for further copyright information. >>> >>> import string >>> mylist = ['1','2','3'] >>> mystring = '' >>> mystring = mystring.join(mylist) >>> print mystring 123 note there is no space between the items. Now, I try to use join as I want, I get: >>> mystring = mystring.join(mylist,'\t') Traceback (innermost last): File "", line 1, in ? TypeError: join requires exactly 1 argument; 2 given >>> I got my python form ActiveState and am working on Win98. Thanks in advance. Bob Hibberdine From mwh at python.net Sun Jun 10 10:17:59 2001 From: mwh at python.net (Michael Hudson) Date: 10 Jun 2001 15:17:59 +0100 Subject: Use Jython to make true executable? References: Message-ID: carlf at panix.com (Carl Fink) writes: > In article , Tomasz > Stochmal wrote: > > > for Windows just use py2exe http://starship.python.net/crew/theller/py2exe/ > > I actually knew that, but as I understand it py2exe just glues a > Python interpreter to your script. I was hoping that gcc/Jython > would create a non-interpreted version. That is, you could avoid > the processing overhead of interperting a script, and thus get a > much faster program. This is very unlikely to speed things up as much as you expect. I've never produced accurate numbers, but I'm fairly sure Python's runtime is dominated by locating applicable methods, not the dispatch loop in ceval.c. If you could analyse a program sufficently to compute (some of) these methods at compile time, *then* you might start to see a real speed up (especially if this let you unbox some integers & floats). Of course, this is intuition about performance, so probably wrong. Buyer beware. Cheers, M. -- The Oxford Bottled Beer Database heartily disapproves of the excessive consumption of alcohol. No, really. -- http://www.bottledbeer.co.uk/beergames.html From bernhard at intevation.de Thu Jun 7 06:18:11 2001 From: bernhard at intevation.de (Bernhard Reiter) Date: 7 Jun 2001 10:18:11 GMT Subject: WHY is python slow? References: Message-ID: <9fnkd3$56bjh$4@ID-89274.news.dfncis.de> In article , Steven Haryanto writes: > Although it is generally accepted that Python is slower than > Java/Perl/Ruby, Well, actually I do not accept this. :) Speed comparisons are always related to the task you want to solve. Anybody who really needs speed in execution will get it done with python or any other language. Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) FSF Europe (fsfeurope.org) From darkvaderx at usa.net Thu Jun 14 11:08:49 2001 From: darkvaderx at usa.net (Vyyk Draygo) Date: Thu, 14 Jun 2001 17:08:49 +0200 Subject: Free Wallpaper, Erotic Pics, Erotic games, Funnygames and much more Message-ID: <9gajs9$3el$15792@riker.addcom.de> Hello, on: http://www.chica24.de.vu you get : Free Erotic Pics Wallpapers Applications XXX Games Funnygames Handy-Logos and much more Have Fun Your Vyyk _____________________________________________________________ This message posted with trial version of Express News Poster From MarkH at ActiveState.com Thu Jun 7 07:46:54 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 07 Jun 2001 11:46:54 GMT Subject: Creating Typeinfo for Python COM servers? References: <9fnocb$550f3$1@ID-59885.news.dfncis.de> Message-ID: <3B1F69CD.5000704@ActiveState.com> Thomas Heller wrote: > Is it possible to (let python) create type-information for > a COM server written in python? Umm - yes and no :) Technically, yes. Everything needed has been exposed, and indeed some "concept" code has been done. Practically, the answer is no - there is no way to take a class definition and magically have a typelib pop out. This was discussed quite some time ago (10/99 and earlier) on the pythoncom developers list - http://mailman.pythonpros.com/mailman/listinfo/pycom-dev. It never went anywhere as no one came up with anything reasonable and, to be quite honest, I don't care enough about this particular issue as it has never affected me. I am however very happy to support any efforts to get this off the ground again. Mark. From tundra at tundraware.com Wed Jun 27 15:09:07 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: Wed, 27 Jun 2001 19:09:07 GMT Subject: Indexing Into A Tuple References: <3B3A0C32.EF179DAE@tundraware.com> Message-ID: <3B3A2F64.D35B94BA@tundraware.com> Steve Holden wrote: > > "Tim Daneliuk" wrote ... > > Hmm, it works, but I don't understand why. I have a tuple of tuples > > defined as follows: > > > > MyTuple = ( ("a", "b"), ("c", "d")...) > > > > Now, I want to iterate across it to print the pairs. This works as I > > would expect: > > > > for x in MyTuple: > > print x[0], x[1] > > > This says "take each value from MyTuple, assign it to x, and run the loop > body". > > > But so does this: > > > > for x, y in MyTuple: > > print x, y > > > This says "take each value from MyTuple, assign its first element to x and > its second element to y (and there'd better not be any other elements if you > don't want an exception), and run the loop body". > > > Intuitively (and, obviously, incorrectly) it seems to me that the 1st > > time through, the second example should return: > > > > x=("a", "b") and y=("c", "d") > > > > Instead, it returns x="a", and y="b" just like the first example. > > > > Why? > > -- > Basically, because it's mirroring Python's standard binding behavior: > > >>> a = 'one' > >>> b = 'two' > >>> a, b = b, a > >>> a > 'two' > >>> b > 'one' > > When there's a tuple on the left of the equals sign the interpreter expects > a tuple of equal length on the right, and performs element-by-element > binding in a way which makes the above value interchange possible. The > absence of parentheses doesn't mean you aren't using tuples... > > regards > Steve > -- > http://www.holdenweb.com/ Tnx, for the clarification... -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From goldbb2 at earthlink.net Sat Jun 9 00:19:43 2001 From: goldbb2 at earthlink.net (Benjamin Goldberg) Date: Sat, 09 Jun 2001 00:19:43 -0400 Subject: File Headers References: Message-ID: <3B21A3DF.29E5E316@earthlink.net> Austin wrote: > > Hello All, > > I would like to be able to have a user specify a document and have the > program return the files type. This cannot be determined via > extension, however it only needs to be able to distinguish between a > MP3 or a Zip file. > If it's neither, then it should return something along those lines. > > Please e-mail me directly at newwave at acmemail.net as I have limited > access to newsgroups. Thanks!!! How is this a perl, vb or python question? And if you ask to the group, we will respond to the group. PS this data is not stored in the filesystem's header info for the file. It is stored in the file itself. To learn how to open and read a file, read the documentation which you installation of came with. To learn how the first few bytes of zip and mp3 files differ, try opening one of each, and printing out the bytes. -- The longer a man is wrong, the surer he is that he's right. From paulp at ActiveState.com Wed Jun 6 21:24:54 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Wed, 06 Jun 2001 18:24:54 -0700 Subject: TypeError: object is not callable References: Message-ID: <3B1ED7E6.6981589C@ActiveState.com> Gustaf Liljegren wrote: > > Why this error? > > I have done a class which is in placed in a directory within sys.path, and > the class works as intended when I test it by adding some main() code in > it. But when I call it from another module I get this strange error > "TypeError: object is not callable". No way I can get the same error in > Idle... I'm going to guess that you have a class Friend in a module called Friend.py and then do this: import Friend f = Friend() You need to do this: f = Friend.Friend() If that isn't the answer, I'll need more info. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From paulo at mail.ddnet.es Fri Jun 1 17:37:51 2001 From: paulo at mail.ddnet.es (Paulo Jan) Date: Fri, 01 Jun 2001 23:37:51 +0200 Subject: Compile times? Message-ID: Hi all: I'm trying to compile Python 2.1 on a small Unix machine that I've set up at home to mess with it, learn, etc.. The machine in question is a Macintosh Quadra 610 (Motorola 68040 CPU), running OpenBSD 2.8 (I didn't install the Python port that came with it because it was 1.6), and the problem that I'm having is that, at a certain point, when it starts compiling the extensions, it just hangs there forever. The process is: 1) I type "./configure" and then "make". 2) The main Python binaries seem to compile correctly. 3) It starts to execute the "setup.py" script, gcc starts compiling the first extension (the regex one)... and it stays there for 4 or 5 hours, until I finally lose patience and kill it. The computer is not idle, because the load average increases, and I can see in "ps -auxw" several instances of "python" running. I am aware that my CPU is not the fastest in the world, but 4 or 5 hours for just one extension is ridiculous; it compiled the rest in just a couple of hours!!! Can anybody tell me if these compile times (assuming my slow CPU) are normal? Am I missing any library or something? How long does it take to compile for everybody else? Paulo. From db3l at fitlinxx.com Tue Jun 12 19:19:00 2001 From: db3l at fitlinxx.com (David Bolen) Date: 12 Jun 2001 19:19:00 -0400 Subject: [wxPython] Help with wxChoice! References: Message-ID: "SNYDER, BARRON F. (AIT)" writes: > That is what I'm doing and I don't get an error but the new value isn't > being appended either. > > Any help is appreciated! Could you perhaps post a snippet of the actual code being used and what version of wxPython you are using? I just tried 'Append'ing to a choice control on my system and it seems to be working fine (wxPython 2.2.1 with either Python 1.5.2 or 2.0) -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From ullrich at math.okstate.edu Sat Jun 2 10:22:54 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sat, 02 Jun 2001 14:22:54 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3B183CFF.A90213BA@san.rr.com> <9fa54s0fkb@enews2.newsguy.com> Message-ID: <3b18f368.2716029@nntp.sprynet.com> On Sat, 2 Jun 2001 09:39:23 +0200, "Alex Martelli" wrote: >"Darren New" wrote in message >news:3B183CFF.A90213BA at san.rr.com... >> > The quote above contains the premise "even given _complete_ >> > information". >> >> Except you snipped the end of the sentence, which is >> "complete information about how they're being generated." >> >> I can have complete information about exactly how many atoms of uranium >> I have in my sample, and still not be able to predict when the next atom >> will pop. I have complete information about how the numbers are being >> generated (watching a radioactive sample) without any information about >> what the next number will be. > >_Complete_ information about how the numbers are generated >requires complete information about the state of their generator. >This is a tautology, of course, but you seem to be denying it. > >"Exactly how many atoms" is NOT complete information about >the physical state of a system -- isn't that obvious, and, if so, >why are you making statements that appear to imply the reverse? > >Position and velocity vector for each of these atoms are part of >system's state. So, if Heisenber Principle holds, how are you >going to have complete information about this state? > > >> > > >A physical system that is macroscopic enough to escape >> > > >Heisenbergian conumdrums >> > > >> > > There is no such system. >> > >> > In this case, no physical computer is predictable, and all >> > we study about algorithms are abstractions -- since a >> > computer system IS a physical system, then ALL bits >> > coming out from it must be random in your sense of >> > the word. >> >> Nope. Because you have an infinite number of possible states, and you >> collapse some of those into a 0 bit and some into a 1 bit. It's because >> you're *classifying* states in your brain as 1 or 0, ignoring the >> reality that there's an infinite number of voltages that represent 0. > >So the system becomes "macroscopic enough" - yet the >discussant asserted there was no such system. Will you >guys please agree to ONE party line, or is Heisenberg >uncertainty affecting you too badly? I don't know why you assume that when two people are commenting on things you said they must be in complete agreement with each other. As far as what _I've_ said is concerned, the reason you seem to think I'm contradicting myself is that you seem to think I regard an _algorithm_ as a physical system. >If my physical system is designed and considered in ways >that are macroscopic enough to escape uncertainty effects, >then (given some possibly huge amount of bits of >information, which it may not be easy to obtain, of >course) its trajectory in state-space is predictable. There _is_ no such amount of information. It's _very_ unlikely, but regardless of _how_ much you know about your physical system it's always _possible_ that there a bunch of virtual particles is going to just happen to appear, all in just exactly the right places, so as to totally randomize the output of your machine. I mean things like transistors are not guaranteed to work. They work most of the time. >Is your claim, then, that "randomness" MUST be used ONLY >for systems which, at the level of observation under discussion, >ARE inevitably Heisenbergian? A roulette wheel, dice being >rolled, cards being well-shuffled, balls being drawn from an >urn -- we can enumerate all the classic devices used to obtain >randomness "from physical systems" without necessarily >encountering quantum effects in action. Chaotic effects may >well ensure that the number of bits of information that would >be needed to obtain prediction is higher than any practical >measure. This, apart from the mention of bits, is the classic >way probability theorists frame 'randomness'. I see nothing >wrong with it, nor any need to demand that the amount of >information needed for prediction be "actually infinite" (if that >sentence makes any sense:-) before the word "randomness" >can be used. Use of that word has never demanded such >"infiniteness", so why should it suddenly impose such demands >today? Who _has_ made such a demand? > I consider it perfectly correct and proper to treat (e.g.) >the results of good card-shuffling as random. Of course it is! That's because the word "random" means so many different things, in different contexts. >So what is so special, that distinguishes a computer system >from a deck of cards -- considering both systems at a >macroscopic enough level that quantum effects can be >ignored, But in fact the deck of cards is not macroscopic enough for this. It _could_ happen that at a given instant one of the cards just disappears and reappears on the surface of the Moon. Not likely, I'm not holding my breath. But particles do not have positions, they have _probable_ positions. > which is easier for the deck of cards I think but >is commonly done for well-designed computers too:-) -- >so that I *could* get randomness from one and not the >other? It seems more fruitful to me to consider the amount >of information, i.e., a quantitative assessment of randomness, >rather than claim that only if that amount is 'infinite' can >the word 'randomness' be properly used. The information >I _do not_ have, whether I don't because I _can't in >principle have it_ or, as is more likely at a macroscopic >level, because it's _impractical enough to determine it, >transmit it, store it, process it_. > >Card-shuffling can be treated this way, in finite terms, and >interesting results are obtained on how best to shuffle a >deck of cards -- what happens to the deck if you shuffle >algorithmically according to certain rules, and what one >player (seeing 1 card out of every 4 from the shuffled >deck) can determine about the other unseen hands. As >the _purpose_ of shuffling the cards at all can be framed >as minimizing the amount of information thus leaked, this >is theoretically important in studying card-play -- theoretically >only, these days, because in every important championship >the 'shuffling' is in fact obtained by computer instead, but >there is a separate theory about such shuffling and some >interest in trying to get roughly as much randomness as a >deck being shuffled would contain (which is less than a >perfect shuffling affords: players new to computer shuffling >used to complain all the time about the 'freak distributions' >that kept coming up:-). > >This sort of application requires finite-mathematics theories, >and I don't see why they shouldn't be, as they are, called >theories of randomness. The concept of "HOW MUCH" >randomness is practically and psychologically important, >and becomes useless if the only possible answers are >'infinite' or 'none'. Nobody said that the word "random" must only be used in this sense. The fact that someone asks a question in which he thought he made clear that he was using the word in some absolute sense does not imply that he's saying that that's the only way the word shall be used. >> > If, on the other hand, you maintain that the output >> > from a physical system CAN be predictable if that >> > system is a computer running your program, then >> > what makes you SO certain that NO other physical >> > systems can also be predictable in the same sense?-) >> >> Again, you're talking two diferent things. In the first, you're talking >> about "the output will be somewhere between 4.5v and 5.5v on this >> wire." The other you're talking about an exact number. > >Taking a set of states and deeming them equivalent can >perfectly well be done -- who ever gets an "exact" number >from physical measurement anyway?! It applies just as >well to the finite definition of randomness. For example, >when cards are dealt, we only deem significant the cards >that are received and not the sequence in which they >are received -- we collapse several possible states into >one significant state. So, 13! states are collapsed into >one (assuming the shuffling is such that all sequences are >possible -- a big assumption in fact, but I don't think >shuffling theory is what we're discussing here). Fine, no >problem, and an important consideration when measuring >_quantity_ of randomness of course. But of course we do >have exact (integer) numbers in finite mathematics -- why >shouldn't we? > > >> > quote talks generically about "random", without using >> > the word "perfect" you now insert, and without any >> > specification of infiniteness as a prerequisite, and, as >> > such and without the needed qualifications, it is not >> > correct. _with_ the qualifications you want to place, >> > it seems to become tautological ("I define X as being >> > something that requires infinities: no finite system can >> > reach X, it can only approach it") and therefore sterile >> > and uninteresting, unless there are hidden layers of >> > exoteric meaning nesting in it, I guess. >> >> I think "random" here means "unpredictable". Tossing dice will lead to >> random/unpredictable results, even if you know everything there is to >> know about the dice and the table. Generating numbers between 1 and 6 >> will not be unpredictable if you know the seed and algorithm. > >If you have COMPLETE information about the dice &c (taking >a HUGE number of bits, no doubt) you can predict their >trajectories, bounces (if allowed), rolls, AND final results. This is simply not true. No, I'm not claiming to have perfect knowledge here, as you implied elsewhere - I've inserted the appropriate qualifiers several times: Unless physics is simply _all_ _wrong_ it is simply not true that there is such a thing as enough knowledge of the initial state of those dice to be able to predict which number comes up with certainty. (That's assuming we're talking about actual physical dice, not the abstract dice in some discussion of proability.) >Why should these macroscopic-physics effect be inherently >unpredictable as you claim? VERY HARD to predict, yes >(LOTS AND LOTS of bits), but the dice are VERY massive -- >it seems to me a fine measurement system could give me >(in principle) the information I need for prediction, CONSIDERING >inter alia how many final states I collapse into one significant >one ('infinite' number of minutely different dice positions at >rest are all considered "a 3 throw" in the end -- just like the >computer-system example you posed). > >Among classical randomness-generating physical systems, >the ones of most interest to me are deck of cards, because >card-playing (bridge specifically) is my passion, and in that >case the finite-mathematics effects are even more in >evidence, of course -- there are only 52! distinct states >even before collapsing, after all. Yet randomness is there... > >If you have complete information about the algorithm and >the relevant part of the state of the computer where it >runs, again you have predictability. > >The only important issue is -- HOW MUCH information do >you need for prediction. If too little info suffices, then the >system is not random ENOUGH for a given application -- >fine, get a better system, one requiring more information >for prediction. It's important to quantify this, as I see >things. Trying to forbid the use of the word 'randomness' >whenever information amount is finite (deck of cards, >rolled dice, roulette wheels, algorithms...) seems totally >unproductive and fruitless. I wish you'd clarify who's been trying to forbid this, and where he did so. Again, I inserted the appropriate qualifiers many times: I was asking about "perfect" randomness - when I ask a question about that it does not follow that I think that that's the only sense in which the word may be used. >Alex > > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From greg at cosc.canterbury.ac.nz Wed Jun 20 02:17:09 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 20 Jun 2001 18:17:09 +1200 Subject: PEP 255: Simple Generators References: Message-ID: <3B303FE5.735A5FDC@cosc.canterbury.ac.nz> Tim Peters wrote: > > This is like saying that functions returning integers should be declared > "defint" instead, or some such gibberish. Not the same thing. If a function returns an integer, somewhere in it or in something that it calls there is a piece of code that explicitly creates an integer. But under PEP 255, there is *nothing* anywhere in the code that you can point to and say "look, here is where the generator-iterator is created!" Instead, it happens implicitly at some point just after the generator-function is called, but before any of its code is executed. You could say that the same thing is true when you call a class object -- creation of the instance happens implicitly before __init__ is called. But there is no secret made of the fact that classes are not functions, and there is nothing in the syntax to lead you to believe that they behave like functions. In contrast, the proposed generator syntax makes generators look so nearly like functions that their actual behaviour, once you get your head around it, seems quite bizarre. I just think it's going to lead to a lot of confusion and misunderstanding, among newcomers especially. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From lenny at squiggie.com Mon Jun 18 21:50:41 2001 From: lenny at squiggie.com (Lenny Self) Date: Mon, 18 Jun 2001 18:50:41 -0700 Subject: Sorting Apache Log Files References: Message-ID: Thanks for your help. This is what I ended up doing... It seems to work quite nicely and seems fast enough. Although, I'm not sure how fast its going to be with 20MB of logs :) #!/usr/bin/pyton import string # Reading file into list list = open("d:/work/access.log","r").readlines() def compare (line1,line2): # Nicely sucks out the apache date stamp datestamp1 = line1[string.find(line1,"[") + 1:string.rfind(line1,"]")] datestamp2 = line2[string.find(line2,"[") + 1:string.rfind(line2,"]")] # Compare the date stamps and return appropriate value if datestamp1 < datestamp2: return -1 elif datestamp2 < datestamp1: return 1 else: return 0 list.sort(compare) # Writing sorted list to new file open("d:/work/newfile.txt","w").writelines(list) Thanks. -- Lenny "Sheila King" wrote in message news:td3titkav6amrrfjimkjkf4kngp7u4ahpg at 4ax.com... > On 18 Jun 2001 15:55:53 -0700, lenny.self at qsent.com (Lenny) wrote in > comp.lang.python in article > : > > : I was planning on loading each of the log files > :into a list and then sorting the list. Unfortualy, I am unaware of > :how to do that when the value I wish to search on isn't at the > :beginning of the line. I need to search on Apache's date string. > > How about this? Create a list of tuples, where the tuple is: > > (datestamp, full_line) > > So, as you put each line from the log into the list, grab the datestamp > from the line, make a tuple and then sort the list on the first element > of each tuple? > > -- > Sheila King > http://www.thinkspot.net/sheila/ > http://www.k12groups.org/ > > From jm7potter at hotmail.com Thu Jun 28 11:07:02 2001 From: jm7potter at hotmail.com (Joe Potter) Date: Thu, 28 Jun 2001 11:07:02 -0400 Subject: newbie with major "lambda" problem (perhaps a scope problem as well) References: Message-ID: <37hmjtk186jsm8k8j0tcq9rvae37mpjb3s@4ax.com> On Wed, 27 Jun 2001 07:21:38 -0700, "John Roth" wrote: > >"Joe Potter" wrote in message >news:gkkjjts1msjq3ps19qs1aobi6m06jtscpc at 4ax.com... >> On Tue, 26 Jun 2001 22:00:52 -0700, "John Roth" >wrote: >> Thanks John, >> >> I think I see it. If I can get a look at the solution to the code example >> that I used in my reply to Chris Barker --- I'll have it made. >> >> Perhaps you can take a look at that example also? >> >> Thanks again. >> >> Regards, Joe > >You don't need to create a frame at all - the classes I write just go right >ahead and start loading widgets into the parent widget, which is passed in as a >parameter. > The code example came from Mark Lutz in his "Programming Python: 2nd Edition." Unfortunately for me, he loves to use classes in nearly all of his examples. I tried to "de-class" the code but failed to preserve functionality with my results. >Setting up your class as a frame is somewhat better for code reuse, but it >really depends on what you want to do with it If it's a one-shot, a frame is >redundant. If it's a group of controls you're likely to want to use >somewhere else, then putting it in a frame makes it much more portable. > >The following snippet shows one I wrote recently: > >class ADataEntryUI: > def __init__(self, parent, frame): > self.ParentClass = parent > self.DateType = "Gregorian" > self._DateVar = StringVar() > self._DateError = "" > self.TimeType = "AM" > self._TimeVar = StringVar() > self._TimeError = "" > >As you can see, it doesn't subclass anything! > >John Roth > John, I want to use the following code as an interface to learning to use Gadfly SQL in Python. It works (sort of) now if one does not mind the function buttons scrolling out of sight on even a small database. What would really help --- is if you could advise me how in the world to put the control buttons in the outer widget where they would not scroll ---- yet they would still work. If the work involved takes too much time and you do not care to look at it, that is fine. But, if you could look at it I would really appreciate it. In fact, if you could "de-class" the example it would be so much the better --- since I would prefer to put off learning the mysteries of classes for a few more weeks. Regardless, you have been very helpful and I thank you. Regards, Joe ###################### code start (note will need a little txt file ############################## import sys from Tkinter import * from tkMessageBox import askokcancel import Pmw class SumGrid(Frame): def __init__(self, parent=None, numrow=5, numcol=5): Frame.__init__(self, parent) self.numrow = numrow # I am a frame container self.numcol = numcol # caller packs or grids me self.makeWidgets(numrow, numcol) # else only usable one way def makeWidgets(self, numrow, numcol): self.rows = [] for i in range(numrow): cols = [] for j in range(numcol): e = Entry(self, relief=RIDGE) e.grid(row=i+1, column=j, sticky=NSEW) e.insert(END, 'xx') cols.append(e) self.rows.append(cols) Button(self, text='Print', command=self.onPrint).grid(row=0, column=0) Button(self, text='Clear', command=self.onClear).grid(row=0, column=1) Button(self, text='Load', command=self.onLoad).grid(row=0, column=2) def onPrint(self): for row in self.rows: for col in row: print col.get(), print print def onClear(self): for row in self.rows: for col in row: col.delete('0', END) col.insert(END, '') def onLoad(self): import string #from tkFileDialog import * #file = askopenfilename() file = "joe.txt" if file: for r in self.rows: for c in r: c.grid_forget() myfile = open(file, 'r') filelines = myfile.readlines() myfile.close() self.numrow = len(filelines) self.numcol = len(string.split(filelines[0])) self.makeWidgets(self.numrow, self.numcol) row = 0 for line in filelines: fields = string.split(line) for col in range(self.numcol): self.rows[row][col].delete('0', END) self.rows[row][col].insert(END, fields[col]) row = row+1 if __name__ == '__main__': root = Tk() root.title('test a button') sf = Pmw.ScrolledFrame(root, usehullsize = 1, hull_width = 600, hull_height = 300, ) sf.pack(side = "top", padx = 10, pady = 6, fill = 'both', expand = 1) # can we move the button calls to here, and hence --- pur them in root???? iframe = sf.interior() SumGrid(iframe).pack() mainloop() ######################## end code ########################## You need a "joe.txt" file --- the below is as good as any ############## 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 ######################## ######################## From robin900 at yahoo.com Wed Jun 13 18:06:23 2001 From: robin900 at yahoo.com (Robin Thomas) Date: 13 Jun 2001 15:06:23 -0700 Subject: PEP 259: Revise to remove context-driven magic from print Message-ID: <486de2.0106131406.5c0cbef9@posting.google.com> Feedback, please. If you all are positive about the proposal below, I'll work it up into a new PEP. Summary: PEP 259 should be reworked to remove contextual magic from print statement, which was the main demand made by the Python community when *rejecting* the PEP. Then it could be resurrected from rejection. Opinions: 0) We don't need another built-in function that echoes what print does. Please. 1) We can't get rid of "print". It is a very common idiom in many languages. 2) Python coders learn to avoid print because a print statement's behavior changes with a run-time context that the coder cannot necessarily control. To rehabilitate print, remove the context magic. 3) Whenever I have a string of bytes that I wish to write to sys.stdout, without any formatting magic such as space characters or newlines, I cannot use the print statement, because it offers me no way to "turn off" all the formatting magic. Thus I am required to absorb the conceptual overhead of the sys module, sys.stdout and "standard output", file objects, and the write() method, just so that I can avoid having Python prepend a space character to my output in certain cases. For a novice Python coder, that sucks. 4) "softspace" has always seemed to me quite a lame thing to be part of the official file object API. What should file objects care about some cheesy report-printing operation like "print"? 5) The "am i at the start of a line context" only helps me when I want print 1,2, print 3,4, print 5 to be equivalent to print 1,2,3,4,5 ...and I have never exploited that feature of Python print, even in lazy report scripting, the application for which the feature seems to be intended. 6) print-users and write-users operate at two different conceptual levels. print is a novice feature, for coders who may not yet know of sys, let alone "stdout" or even the concept of standard output. print is also a pretty formatting feature, so that the coder does not have to understand string concatenation, string format strings, string conversion, or even the newline escape sequence. Thus I think that it is OK for print and write() to have feature overlap, without violating the Pythonic principle of "there should be only one way to do it". Proposed "new" PEP 259 --------------------------------- 1) softspace attribute of file objects now ignored by print statement (and rest of Python core, if applicable). print statement no longer cares about "am i at the start of a line" context. Instead, the print statement writes the same bytes every time to the file object. If the file object wants to play softspace-style games, it can track its own context. Thus any write operation to the file object affects softspace context if the file object wishes to implement softspace context. However, Python core no longer cares about the softspace attribute, and no longer bothers to read it nor call softspace API functions. "softspace behavior" then becomes like any other encapsulated behavior of a stream writer, such as zlib compression or similar. If the file object wants to do that, fine, but callers to write() such as print are appropriately ignorant of it. 2) When commas separate expressions as in "print 'a','b','c'", the print statement writes a single space character " " for each comma. 3) Just to repeat from 1): softspace has no effect any longer. print will never print a leading space character for any statement "print foo". 3) If the print statement ends in a trailing comma as in "print 'a','b','c',", the trailing comma means "do not print either a final space character or a final newline character": "print 'a','b','c'," prints "a b c". And "print 'a',; print 'b'" prints "ab\n", not "a b\n". 4) If the print statement does not end in a trailing comma as in "print a,b,c", the print statement will print a single newline character after printing the result of all expressions: "print a,b,c" prints "a b c\n". The statement "print", with no printing operands, prints a single newline character. 5) It is suggested that the values for "space separator" and "newline" be system-dependent, settable at run-time, and available in modules sys or os. Your feedback is welcome on this issue. It is *not* suggested that file objects take on this aspect of print behavior, such as by implementing a method print(self, items, print_newline=1, softsep=' ', linesep='\n'), and if not implemented, falling back to stream.write(string.join(' ', map(str, items)) + "\n"). Again, print is not important enough to demand attention from designers of file-like objects. Examples ------------ 1) Just print a line with a newline at end, without messy newline escape: print 1 2) Print some stuff, and let commas put in nice separating spaces: print 1,2,3 3a) Print some stuff with nice spaces, but don't print a newline. Then continue with another print statement, making sure that nice spaces separate all strings on the same line: print 1,2,3, print "",4,5,6 (This is the workaround for code that exploits the current softspace context feature for "lazy report printing", but does the print statements in an order clear from the source code. This way, current lazy scripts can avoid code breakage with minor edits.) 3b) Print some stuff with nice spaces, and always make sure that when you print with a trailing comma, that there is always a nice space separating your strings in case you issue another trailing-comma print statement: print a,b,c,"", (Second workaround, for code that wants to print at will, without the coder having to think about things previously printed since the last newline. Only tradeoff: if the code wishes to end lines with an empty "print", the output lines will have trailing spaces, which changes the return value of split() on the line.) 4) Print a string of bytes, with no spaces or newlines added: print byte_string, 5) Print a series of objects with no space separators or newline, accepting the fact that string formatting has a performance cost: print "%s%s%s" % (a,b,c), 6) Print a list of objects with no space separators or newline, without string formatting cost, but with iteration cost: for i in a,b,c: print i, # or, to echo a file to sys.stdout... for x in open('foo').readlines(): print x, 7) Write bytes to a file object because you hate print: fileobject.write(str(object)) Implementation Notes ----------------------- - Something has to change in the bytecode to achieve the above. PRINT_ITEM and PRINT_ITEM_TO could take an oparg indicating whether to print a trailing space. Or new opcodes, PRINT_ITEMS and PRINT_ITEMS_TO, take an oparg indicating number of items on the stack to pop and print in sequence, printing a space between each. Or else two new opcodes PRINT_ITEM_SPACE and PRINT_ITEM_TO_SPACE, which would suck. - I don't see a problem in having an opcode like PRINT_ITEMS, which requires that all of the expressions to print are evaluated and put on the stack, and the print statement itself (minus the PRINT_NEWLINE) is a single opcode printing *all* of the items. If this is a problem, please enlighten me. (At the very least, it avoids all those DUP_TOP/ROT_TWO combinations preceding every PRINT_ITEM_TO.) - In fact, it might be best to refactor all print operations into a single opcode, PRINT_STMT, which takes an oparg indicating a vector of (num_items_on_stack, output_stream_also_on_stack_boolean, print_newline_at_end_boolean). You still get 14 bits to hold the amount of objects to print; we perhaps could bring in EXTENDED_ARG if we ever found the need to handle more than 2**14 expressions in a print statement in source code. :) All existing print opcodes can stick around unchanged, even with the softspace crap. PRINT_STMT will ignore all softspace crap. Or at least, while softspace must still be supported, PRINT_STMT will ensure that softspace is set to false after it completes printing. - "from __future__ import print_stmt" can handle the migration process. - Two system values, represented by os.softsep and os.linesep, or sys.softsep and sys.linesep, or whatever you think is good, could be used as the run-time values of the "space character" to separate print items and the "newline" character to terminate a line, respectively. These values, if changed at runtime by assigning to sys.xx or os.xxx, can be stored as system globals a la Py_None and others, for speed, to avoid constant attr lookups on sys or os. From chrishbarker at home.net Thu Jun 7 20:07:53 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 07 Jun 2001 17:07:53 -0700 Subject: Mutable class attributes are shared among all instances, is it normal ? References: <27vvht4uslv2ibq2q8ee4tovg86e7qempb@4ax.com> <3B201662.6DB35744@home.net> Message-ID: <3B201759.913E7D5A@home.net> Chris Barker wrote: OOPS, sorry, I accidentally left some erronos stuff in my example. It shuld be just: > Try this: > > >>> reload(cl) # it needs to be reloaded to get a clean copy of Y > > >>> > >>> print cl.X.val > None > >>> x1=cl.X() > >>> print cl.X.val # note: it hasn't changed. > None > > >>> print cl.Y.val > [None] > >>> y1=cl.Y() > >>> print cl.Y.val # note it has changed > [0.91001740255497787] Sorry about that. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From tim.one at home.com Sun Jun 17 17:48:20 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 17 Jun 2001 17:48:20 -0400 Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: [Robin Becker] > so the implication is that the state can't be got at explicitly and I > have to redefine the generator function part of the iterator to reset > it? can one copy a generator-iterator? Generator-iterators conform to the iterator protocol, and the latter has only a .next() method: no notion of reset, no notion of copy. PEP 255 doesn't go beyond that. Of course you can do, e.g., g1 = some_generator(x, y, z) g2 = some_generator(x, y, z) ... to get multiple independent generator-iterators. From phd at phd.fep.ru Wed Jun 13 05:17:39 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Wed, 13 Jun 2001 13:17:39 +0400 (MSD) Subject: Traceback output In-Reply-To: <3B272970.4BA5D01C@usa.net> Message-ID: On Wed, 13 Jun 2001, mixo wrote: > How can I catch output from "traceback.print_exc()"? I would > to be able to do is write the information in a file . The very module traceback has all neccessary things. Read its source and choose what you want. Probably format_exc() or something. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From jeff at ccvcorp.com Fri Jun 22 12:39:37 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Fri, 22 Jun 2001 09:39:37 -0700 Subject: NT Service and COM References: <9gu4nf$553$1@troll.powertech.no> Message-ID: <3B3374C8.D3EA315B@ccvcorp.com> Syver Enstad wrote: > Yes, but that ain't doesn't expose no COM server. If you ever find out > Duncan I'd be really pleased to hear what you've figured out. I've only come > so far as to look at the .py file that implements local servers for python. > Take a look at win32com.server.localserver.py to see how vanilla pythoncom > objects are exposed like a localserver. What would probably work best, is writing the COM server, then writing a Service that creates and makes use of the COMserver... though of course this depends on your exact requirements. I wouldn't *think* that there's any special tricks to combining these. Just have your SvcDoRun() instantiate the COM object before moving into its main loop.... Jeff Shannon Technician/Programmer Credit International From graham at coms.com Wed Jun 20 05:38:59 2001 From: graham at coms.com (Graham Ashton) Date: Wed, 20 Jun 2001 10:38:59 +0100 Subject: beginner ques: dir( ) does'nt list my instance methods? References: Message-ID: In article , "Unknown" wrote: > Both dir(t) and t.__dict__ print only foo and bar. They don't print the > func which is also a instance attribute (method reference)? > > But they are printed when i do test.__dict__ and dir(test)..ie > > why is it not getting printed in the earlier case?(wiht instance) I'm not sure about that one (I'm new to this too). > I might be required to do a look up from dir(instance) and if an > attribute happens to be of the type method i can invoke it? Have a look at getattr() for that. method = getattr(test, 'func') # untested method() From jp at ulgo.koti.com.pl Fri Jun 15 05:59:04 2001 From: jp at ulgo.koti.com.pl (Jacek =?iso-8859-2?Q?Pop=B3awski?=) Date: 15 Jun 2001 09:59:04 GMT Subject: Tkinter - centered window? Message-ID: I create window this way: self.window=Toplevel(parent) Is it a way to tell window manager, that I want this window to be in center of screen? -- Change comes slowly But this is what you'll be Somehow it snows in the summer And the sun is freezing me "Otherworld" - Ronnie James Dio From gustafl at algonet.se Mon Jun 11 17:15:53 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 11 Jun 2001 21:15:53 GMT Subject: Newbie References: <20010611151900.11318.00004174@ng-mp1.aol.com> Message-ID: justsurfn2004 at aol.com (Justsurfn2004) wrote: > Hello, im a newbie to all this programming stuff and i just downloaded > python and i want to know how to use it. Can anyone reccommend any > websites for me to go to on how to use it? It takes some *reading*. Download the Python documentation in PDF and start reading the tutorial. I'm a Python newbie too, but I have found it to be easy to learn thanks to the "interactive mode", which means that you write the code and see the result directly. It's great when trying things out, testing modules and functions and so on. And www.python.org have some other nice tutorials and "getting started" papers. Read, or hire a private mentor. :-) Regards, Gustaf Liljegren - Python powered! From wjdandreta at worldnet.att.net Tue Jun 12 14:28:51 2001 From: wjdandreta at worldnet.att.net (William Dandreta) Date: Tue, 12 Jun 2001 18:28:51 GMT Subject: BIG problem if readline strips newlines References: Message-ID: Hi Pete, >i've seen frequent mention of an option for readline() >to strip out newlines as each string is read. this sounds >like a great idea, but i realized its gonna be very >difficult to loop through a text file. the standard >python idioms will no longer work... > I don't think it means it changes the file, just the string(s) that are returned by readline(s)(). Blank lines will be empty strings. e.g., a file like: ------------- hello test ------------------- for lines = file.readlines(chomp=1) lines will be: ['hello','','test'] instead of the normal ['hello\n','\n','test\n'] The file will not be altered. Bill From bob at passcal.nmt.edu Fri Jun 8 11:28:33 2001 From: bob at passcal.nmt.edu (Bob Greschke) Date: Fri, 8 Jun 2001 09:28:33 -0600 Subject: Passing back an array from an extension module? Message-ID: <9fqqqo$1p3e$1@newshost.nmt.edu> Is this a job for NumPy? I have a C extension function that malloc()s an array of int32s, calls another C function which reads/decodes a file of data and fills in the array. Then I need to pass that back to the Python side for graphing the values. I initially thought I could just create a tuple and pass that back, since nothing is going to be done with the values except to draw a graph, but there is the possibility of there being 16,000,000 data points...that makes for a slightly large statement, doesn't it? It doesn't look like I can do this with arrays in stock Python, but it does look like I can do it with the NumPy arrays. Is that correct? Now what about Py_DECREF, INCREF and all of that stuff in these situations? I read through a number of posts on dejagoogle that were talking about this, but they only confused me more. :-) Thanks! Bob From new_name at mit.edu Sun Jun 10 18:11:23 2001 From: new_name at mit.edu (Alex) Date: 10 Jun 2001 18:11:23 -0400 Subject: Catching Errors References: <3B20E042.DA0AF3C1@usa.net> <9fqpii$5mk9n$1@ID-11957.news.dfncis.de> <9g0idm01lap@enews1.newsguy.com> <9g0o5i$6gp21$1@ID-11957.news.dfncis.de> Message-ID: urllib.py is making your life easier by catching the 301 and 302 errors -- they are redirects. Here are the relevant methods from FancyURLopener: def http_error_302(self, url, fp, errcode, errmsg, headers, data=None): """Error 302 -- relocated (temporarily).""" # XXX The server can force infinite recursion here! if headers.has_key('location'): newurl = headers['location'] elif headers.has_key('uri'): newurl = headers['uri'] else: return void = fp.read() fp.close() # In case the server sent a relative URL, join with original: newurl = basejoin("http:" + url, newurl) if data is None: return self.open(newurl) else: return self.open(newurl, data) def http_error_301(self, url, fp, errcode, errmsg, headers, data=None): """Error 301 -- also relocated (permanently).""" return self.http_error_302(url, fp, errcode, errmsg, headers, data) HTH. Alex. From tim.one at home.com Fri Jun 15 16:20:04 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 15 Jun 2001 16:20:04 -0400 Subject: idle BUG In-Reply-To: Message-ID: [Robin Becker] > I don't believe that blaming the other guy (Tcl) is the right way to go. In this particular case, people have spent countless hours examining the Python side of things without finding a problem: wagging fingers at Tcl wasn't a presumption, it was a conclusion. > I too can make Tk Apps go wrong, but in every case that this happened I > eventually traced the problem to a programming error in my tcl coding. > This is especially true in later Tcl's as they've found and fixed some > of the earlier problems and also introduced multithreading. There were > also some problems caused by win32 Tk apps interfering with each other > because of Tk's attempts at determining all existing Tk apps (to allow > the send command to work), but I think that is disabled in 8.3. > > I run complex Tcl code every day on the same box and it never locks up. Fredrick reproduced the problem with a simple Python-free Tcl app. > The reason for wanting to run Tkinter apps from a dos/cmd box is to see > the print outputs for debugging etc. Of course. But for now that doesn't work reliably on Win9x, and there's nothing new to be said about that. Instead of complaining with increasing bitterness, why don't you *help* debug it? I pointed you to the bug report: add something useful to it, or continue to wait for a miracle. You're just "blaming the other guy" too, but by presumption. From see at my.signature Tue Jun 12 22:18:10 2001 From: see at my.signature (Greg Ewing) Date: Wed, 13 Jun 2001 14:18:10 +1200 Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> <3b266270$1_7@news5.uncensored-news.com> <9g68os0cd9@drn.newsguy.com> Message-ID: <3B26CD62.F89E5FA0@my.signature> thinkit wrote: > > we all need a general > purpose base. decimal is that now, and hexadecimal would make a better choice. And if you use hands and feet, and exclude thumbs and big toes, you can even do it on your appendages if you really want. We need six more digit symbols, though. Borrowing letters was okay as an interim measure, but we need to move on. Any proposed designs? -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From bokr at accessone.com Fri Jun 1 14:18:00 2001 From: bokr at accessone.com (Bengt Richter) Date: Fri, 01 Jun 2001 18:18:00 GMT Subject: Against PEP 240 References: <3B1674D8.67690A5A@san.rr.com> <9f5v00$4li$1@panix2.panix.com> <3b16a154.9545695@wa.news.verio.net> <9f6lae$ddc$1@panix6.panix.com> <3b17ad88.40156281@wa.news.verio.net> Message-ID: <3b17d74e.50850969@wa.news.verio.net> On Fri, 01 Jun 2001 16:51:27 GMT, bokr at accessone.com (Bengt Richter) wrote: [...] >Ok, here's a thing to encode and decode a decimal tuple (v,x10) into >a float, where v is an integer up to 15 digits and x10 is an exponent >dec() decodes it back (well, I should have done a long() on the first >return element). > >import math >def enc(v,x10): > "enc(v,x10) encode up to 15-digit integer signed v and 10-bit >signed x10 in float" > if v < 0: > return math.ldexp(v-2L**52,x10) > else: > return math.ldexp(v+2L**52,x10) >def dec(d): > " decode float that was encoded with enc() above" > z = math.frexp(d) # (f,x2) > if d < 0: > return z[0]*2L**53 + 2L**52, z[1]-53 > else: > return z[0]*2L**53 - 2L**52, z[1]-53 > >Maybe someone will find this a useful take-off point... >No warranty, this is hot OTTOMH ;-) > Hm, replacing "z[0]*2L**53" by "math.ldexp(z[0],53)" would seem an improvement. Also, BTW, not just "==" but also ">" and "<" on encoded values should return valid results, (I think ;-) Note the __doc__ line wrapped in the mail. Note also, if you try to encode a v with decimals, it will effectively round it when it adds the 2L**52, e.g., >>> dec(enc(123.45,3)) (123.0, 3) >>> dec(enc(123.55,3)) (124.0, 3) >>> I guess if there was a third optional argument to enc() saying how many decimals were to the right, that could be taken care of. From grante at visi.com Mon Jun 25 11:33:11 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 25 Jun 2001 15:33:11 GMT Subject: Is this a true statement? References: <3b3745bd.2217895@nntp.sprynet.com> Message-ID: In article <3b3745bd.2217895 at nntp.sprynet.com>, David C. Ullrich wrote: >>>> He's making a very finicky, nitpicking, and frankly silly point [...] >>> >>>I don't think the point was entirely silly! It was a valid and >>>interesting point (despite being finicky and nitpicking!) >> >>Yes, it's trivially and obviously valid: a driver is a bit >>pattern, and you can write a bit pattern to a file with Python. >> >>If you show an example of how this is a useful and productive >>way to generate a device driver, _then_ it will be interesting. >>Until then, it's just somebody chattering to hear themselves >>talk. > >That's a truly remarkable attitude. Nothing is worth knowing >unless it solves a practical problem right now. Not true -- but using a Python program to write into a file a bit pattern that is known a-priori to be a device driver for a particular OS just isn't interesting (IMO). If you used a Python program to _generate_ the bit pattern from some higher level source, that would be interesting. >I actually learned something about device drivers from all >this. Not from something that anyone actually said - I learned >something about device drivers by assuming that people _must_ >be making much more sense than they _appeared_ to be making, >and trying to figure out what I could be misconceiving that >would make all those comments that must actually be sensible >appear like nonsense to me. > >"Chattering to hear themselves talk" indeed. I apologize -- I really thought that you knew what a device driver was and you were being intentionally obtuse. >Figured out the answers for myself last night, then this >morning the first thing I said was "no, of course in that sense >you cannot write device drvers in Python". Not using currently available tools. I do maintain that it wouldn't be terribly difficult to do, but for performance and resource reasons it would be largely an academic exercise. -- Grant Edwards grante Yow! I put aside my at copy of "BOWLING WORLD" visi.com and think about GUN CONTROLlegislation... From m.faassen at vet.uu.nl Fri Jun 1 03:15:37 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 1 Jun 2001 07:15:37 GMT Subject: New language References: <9dse3h$7s5$1@wanadoo.fr> <9er0s9$9i2$2@newshost.accu.uu.nl> <9err9a$aq0$1@newshost.accu.uu.nl> <9f10ta$eua$1@newshost.accu.uu.nl> Message-ID: <9f7fep$hb8$1@newshost.accu.uu.nl> In comp.object Topmind wrote: [snip] >> >> Another good example is for >> >> instance x, y coordinates you want to pass around, without going to the >> >> trouble of dealing with anything more complicated. >> >> > What keeps a dictionary from satisfying this role? >> >> They're too heavy, again. :) > Please clarify "heavy". I think I did elsewhere. Too heavy in syntax, and there are also implementation memory concerns. A hash table including keys is going to be significantly larger in memory usage than a tuple with two references in it. if you're going to have a lot of them, this may be a drag. However, as I said before, it's mostly a syntax issue to me. There is a case to be made for a kind of tuple-like dictionary, though the advantages of that are minimal in my opinion; for anything more complex I'd be inclined to use a full-fledged object anyway. Dictionaries are more for storage of many homogenous objects, while tuples and instances are more for collecting heterogenous objects into into a bundle/record/object. I know instances are dictionaries with some sugar, but I mean in programming idiom, which is important too. [snip] >> > I think that was my case, more or less. Touples, dictionaries, and >> > classes have too much *overlap* in Python. It just seems to me that >> > they could have factored the 3 into *one* thing. It keeps the >> > language cleaner and the learning curve shorter that way. >> >> I disagree; I think a distinction like this can help sometimes. Look at >> Perl and their scalars, which merges things like integers, floats and >> strings into 'one thing'. > I like that approach. It makes the code leaner and cleaner IMO. > Less casting, converting, and declaration clutter. It allows > you to look at raw business logic instead of diddling with > conversions, casting, and bloated declarations. You're confusing things here; you're confusing the effect of static type checking (declarations and casting) with that of having different datatypes. In Python, you don't need to declare or cast integers, only convert when necessary. You need to convert an integer to a string if you want to use integers in a string, for instance. Because of this, the program stops when you do something silly, instead of going on blindly and making a mishmash of your data. This is *not* the same argument as that for static type checking however; it is important to see the distinction. It's an argument for a light-weight dynamically checked type (or interface/protocol) system. What you seem to be describing as the benefits of the Perl scalar may instead be the benefits of the absence of statically checked types. Of course there are also the type inferencing systems which may combine the best of both worlds; I haven't had too much experience with these so I can't tell you if that's true, though. Ocaml has such a system, for instance. >> They also seem to merge lists and dictionaries >> (hashes) into one thing. I think that's bad; you want your programming >> language to complain if you're treating something as an integer when >> it's really a string (can't add "one" and "two"). > If this is degenerating into the age-old strong versus weak > typing battle, then I will leave it here. See above for what I think is the subtle but crucial distinction. I'll remain quiet about it now, though. :) > A jillion messages > are already devoted to that topic, with no "killer proof" > on either side. It may be subjective which is the "best". > I grew up on strong typing, but have gravitated toward > prefering dynamic typing over the years. Me too. >> It's funny you should compare tuples with dictionaries and say they >> should be conflated; most people complaining about tuples say they're >> too much like *lists* (arrays). They're right that they're very much >> like lists, > That too. Roll 'em all up. Requirements change. I hate recoding > from lists to touples to dictionaries to tables, etc. > Make the interfaces the *same*, and only swap the engine, NOT > the interface. Oh, I'd say make the interfaces different, use the same engine where possible. I changed my mind a little about dictionaries; in practice they're often used to store lots of homogenous values, not as a kind of datatype (in Python, class instances (objects) are used for that). I think it's a myth that having a universal rolled-into-one collection type helps your program deal with change more easily. In my Python programs, I use lists and tuples and dictionaries and tables in rather different places in different idioms. While it is possible I change one into the other on occasion, this is the exception, not the rule. When such changes do happen so many other changes tend to happen it doesn't really matter anymore anyway; the change in collection type is probably caused by such a larger change. With a universal collection type you lose some of the benefit of these separate idioms (which can help with the readability of the program). You also may increase errors, as due to the absence of different interfaces and idioms you run a higher risk the program will continue after an error and mangle your data in unpredictable and hard to track down ways. Anyway, as I said before, you're in the minimalist camp here, along with Smalltalkers (everything's an object with messages) and Lispers (everything's a list). I take the position that syntactic sugar can help with idioms, which can help with clarity, readability and error detection. >> except that they're immutable (like integers and strings >> in Python, but unlike lists and dictionaries and instances). Your >> desire to conflate them with dictionaries is in my opinion wrong as well, >> but you're more right than those who want to merge them with lists; > Show me "wrong". Wrong as in "I think there are arguments against this which you are missing and I disagree with your evaluation of the tradeoffs". This is a subjective issue. I imagine you can do empirical research about programming language effectiveness and these issues, but I'm not going to do it. Are you? If not, you'll have to accept that my efforts in trying to show you 'wrong' are as valid as your efforts to show me wrong and yourself right, here. The alternative is saying you're doing no such thing, in which case I wonder what we're doing. :) >> tuples are generally used as 'records' (heterogenous objects) and not >> as lists of homogenous objects. > Doesn't matter. Needs change. See above. Homo today, hetero tomorrow. > Micheal Jackson Collections, you could say. Heterogenous collections are not going to change into homogenous collection and vice versa in by far the most circumstances. If you disagree, you should name some cases; I can't think of any. By 'homogenous collection' I mean a collection of 'like' objects (English words, files, animals, records with address data, etc). By 'heterogenous collection' I mean a collection of significantly different objects ("an integer, a string and a list", "a first name, a middle name and a last name", "a word and the frequency of its occurance in a text", "an x coordinate and an y coordinate"). >> Anyway, you're in the LISP and Smalltalk camp here; do a lot with just >> a few syntactic (surface semantic) concepts. > As far as collections, yes you can say that. (Although Smalltalk's > collection API's are still too taxonomy-happy for my tastes.) >> A language like Python >> adds more syntactic sugar, and my theory is that this syntactic >> sugar *helps* programmers write and read programs. > Perhaps it depends on the programmer. Also, there is maintainability. > Having dedicated syntax for certain (false) categorizations of > collections may make *some* code easier to read, but still makes > it harder to change when collection needs grow, morph, or change. Yes, there are definitely tradeoffs there and I recognize those tradeoffs. I think the tradeoffs for collections weigh into a different direction, however. That's not to say I want a huge forest of collections that you can see in some statically typed languages, where they have arrays for integers, arrays for strings, arrays for floats, and so on ad infinitum. While arrays are usually for homogenous collections I think the strict specification and checking of such can bog down the programmer too much. It's also fine with me if collections share an underlying implementation in some cases, if this is easier or more efficient. But for me, the balance of the tradeoffs still leans towards more collection interfaces than just a single one. >> Too much syntactic >> sugar can result in messes (Perl is another good example here), but >> too little also has some disadvantages. People are sometimes a bit too >> focused on the conceptual purity and the ability to manipulate program >> code; in a pragmatic language the tradeoffs may sometimes favor more >> syntactic sugar, not less. > Having to re-code collections *is* a programatic concern. But as I tried to show before, such collections are often used in entirely different circumstances, so the necessity to recode a collection is minimal. And also as said before, even when a recode is necessary, this is usually a) not a huge deal to do and b) part of a larger change already and minimal work compared to that. > [snip] >> # okay, make a 'child dictionary'; the instance of the class >> a = A() # uses __init__ > Case sensitivity, YUK! In idiomatic Python code, classes start with a capital, and instances don't. It makes examples pretty clear. Let's not go into case sensitity issues here; it seems to be almost entirely based on personal preference, like C indenting styles. :) Anyway, is that the only response you had to my example? I showed you how Python was already doing more or less what you said it should be doing. An 'oh, cool' or 'huh?' or 'that's not what I mean' would've been worth my troubles. > [snip] >> >> > Besides, what is wrong >> >> > with regular by-reference parameters? >> >> >> >> Nothing at all, except that returning multiple values is far more clear >> >> by just about any measure you can come up with. :) >> >> > Which would be? >> >> > I suppose you could argue that under the old approach >> > one could not tell what was being changed and what was >> > not by looking at the caller. However, you might have to check >> > the bottom or middle instead of the top of a routine to >> > figure out the result parameter interface in Python. >> >> Usually the bottom, yes, unless you document it at the top in >> a docstring. Looking for 'return' statements isn't terribly >> difficult, either. > But harder than looking at the top. Yes, but the problem already exists in any dynamically typed language where any kind of heterogenous collection can be returned, and you said you prefer dynamic typing. It doesn't add to the problem therefore; it's just as hard if you're returning a record or dictionary. The advantage of tuples is that they can be instantly unpacked after the function call. >> > IOW, it might trade caller readability for callee >> > readability. At the most it is a wash IMO. >> >> I disagree; caller readability is not significantly effected and >> callee readability (in multiple places) is improved. A clear win, >> therefore. > I am not sure how you are doing your math here. I figure one > always has to go the the function definition and parameter > list *anyhow* to understand the function's interface. > Thus, having it defined in the heading is a one-stop deal. Without declarations, that's just a name in an argument, and the 'changeable reference' indicator. It's true that is a bit more explicit. > Having to also check return statements is a two-stop deal. > (I don't end up looking at return statements very often.) The other deal is that I don't have to go look up the function definition each time I see a function call I don't know about, just in case this may involve reference parameters! That's a huge deal in my opinion. :) >> > Having the entire interface defined at the top is >> > a good thing IMO. (Although "return" is rarely >> > at the top, but it is a single item if it >> > exists.) >> >> A single item of any kind of complexity, anyway, and a serious tradeoff >> in readability for the callee as there are now two different ways you can >> return values, one of which (reference parameters) is a hack. > Define "hack". Mathematical functions, which inspired functions in programming languages, don't have 'reference parameters'. They just have inputs. It can therefore be presumed originally computer language functions didn't have them either, and someone added them to languages in an early hack in order to support multiple output values. The hack makes sense if your language is statically typed, as you can then define the types of all the output values in the same way as you already defined the types of the input values. You don't have to think about extra syntax. It doesn't make a lot of sense in a dynamically typed language, though. (and of course in Python you can mutate mutable objects passed to a function and *any* variable in Python is a reference. But it's better style to avoid mutating input if possible, in my opinion. It encourages more independent functions which makes for easier to maintain and debug code). [snip] >> Come *on*, man! Harder at the callee *and* caller side, even in a language >> that constructs dictionaries as easily as Python. > You are assuming that you want to *split* them out when returned. What > if you want to keep them together as a record (dictionary)? Keep your tuple as it is. def foo(): return 1, 2 coord = foo() bar(coord) And unpack it sometime later: x, y = coord Note that the idiom for 'heterogenously used' dictionaries in Python is the class instance. For more complicated things than just a coordinate pair I'd generally use these. [snip] >> > Because I am not convinced it is significantly better. As a rule of >> > thumb, I say something has to be at least 15 to 30 percent better to >> > deviate from tradition. Perhaps if I saw more actual uses for >> > it besides foo-bar examples, but I have not. >> >> '15 to 30 percent better': failure to grok error. > Perhaps you grok differently than me. >> If you mean the amount >> of typing, I can see it's far more than 30 percent better. But you >> probably don't mean that, and it's fairly meaningless beyond that. So, how *do* you arrive at these 15 to 30 percent better figures? It implies somekind of objectively measured thing, did you? >> > Most "data structures" I deal with are more than 2 positions. >> > Thus, I use tables, and perhaps a dictionary-like thing to >> > interface to such records. (I prefer to use tables to store >> > data instead of dictionaries themselves, other than an interface >> > mechanism to specific records.) Perhaps some niches have lots of >> > "skinney collections" where touples may help, but not mine. >> >> Well, I tried to describe such a niche; returning multiple things from >> a function. Another niche is indeed the very light weight record >> niche; x, y coordinates for instance. Yet another niche, harder to >> describe is the 'make a new immutable object from other immutable >> objects' niche. > I meant industry domains, like business versus embedded systems versus > scientific computing, etc. I don't do a lot of X, Y coordinate work, BTW. European example for the industry domain is a 'year/weeknumber' tuple. In Europe industry often works with (ISO) weeknumbers. To calculate weeknumers back to a date (beginning of the week), you need the year as well, so it can make sense to pass these around as pairs in ones application. [swapping two values with tuples] >> But it *is* obvious what is going on as you already understand both >> tuple unpacking and tuple construction. > But it is just Yet Another Silly Trick To Understand. It's not a 'silly trick' like many Perl 'silly tricks' where the trick is merely in syntax and not the *consequence* of an orthogonal syntax. If your syntax is orthogonal you can reason about it, so it's not a silly trick you need to remember in isolation. That's a very different thing when you're learning a language. >> We're just doing both in a >> single line. There's nothing special case about this. It's not *hard* >> to understand tuple construction and unpacking. You're clinging to >> your traditions here just for argument's sake. :) > Nope! I am weighing utility versus complexity, and it flunks > in my book. Save the syntax complexity for the *common* > stuff. I tried to show you how this *is* common stuff. Not swapping variables, but collecting a bunch of things together and passing them around as a whole, and returning them as a whole, and easily separating them into pieces again. It happens frequently in software. When the amount of heterogenous objects you're packing together into a bundle is large or the situation is complicated (need to do many operations on them), it makes sense to use a record or a class. In many circumstances it is however not a complicated bunch and it's easier not to use such a thing and use the syntactically and semantically minimal tuple instead. Yes, a small record can grow into a large one, and you will have to adapt some code when it does (in a dynamically typed language, not a lot). There are many cases when this just doesn't happen, though; x, y coordinates are an example, so are year/weeknumbers, or 'year/month/day' pairs, or 'amount/currency_type' pairs, and so on. >> If this were the *main* reason for having tuples in a language, then of >> course I'd agree with you. But this is just a consequence of their >> presence. > Same issue. They don't add anything that a dictionary couldn't do. > They make save a few keystrokes here or there, but not worth > Yet Another Collection Type IMO. Yes, you're a syntactic minimalist and don't agree on the tradeoffs. :) [snip] >> and I haven't talked about using tuples to catch >> an arbitrary amount of arguments to a function yet, something which >> can be useful sometimes. For me, tuples are an optimisation of >> common stuff. > Well, I just like to limit collection types. Collection needs scale > all over the map, and too many interfaces makes for too many > code overhauls when collection needs change. As I tried to show, I disagree that many collections need to scale across the map. Heterogenous collections generally don't, and many small and/or throwaway homogenous collections don't either (let's say a registry of object types; you know you're not going to have millions but at most just dozens, or a list of the fields in your form). >> > Don't get me wrong, there are languages a lot worse than Python, >> > but the poor consolidation of the similar things I mentioned >> > kind of bug me. >> >> I see these syntactic issues in a somewhat different philosophil light, >> something which I tried to describe above. While I'm all in favor of >> semantic minimalism, I'm not a syntactic minimalist. If you're a >> syntactic minimalist these subtle differences make no sense, indeed. >> >> Anyway, if I were designing a new language I would indeed attempt to >> bring dictionaries and tuples closer together, so we're in agreement >> in that sense as well. I'm just defending the special syntax for tuples, though >> I also wonder about performance (but we'd just have to profile it) if >> all tuples were dictionaries. > Performance often only becomes an issue when stupid programmers play with > too many features. Thus, reduce the syntax features and you have less > playing around with wasteful things and cryptic tricks. The tradeoff here is that one thing often doesn't fit all. You sometimes need multiple things optimized for different situations. If you don't, you may end up with exactly the situation you describe here; cryptic tricks to make the 'one-size-fits-all' thing behave in a way it wasn't designed for. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From aleaxit at yahoo.com Sat Jun 16 05:16:35 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 16 Jun 2001 11:16:35 +0200 Subject: locking dictionaries (was Re: New statement proposal for Python) References: <9gao5s$8ft$7@216.39.170.247> <9gb41r0s6p@enews1.newsguy.com> <9gcslc05fc@enews1.newsguy.com> Message-ID: <9gf8990f5c@enews1.newsguy.com> "Nick Perkins" wrote in message news:oBwW6.245227$eK2.51902394 at news4.rdc1.on.home.com... > > "Alex Martelli" wrote in message > > > Tx for the 'excellent':-). > > One (IMHO) Python enhancement would be to give dictionaries > > some finer-grained control on their degree of mutability. > > The ability to selectively make SOME existing keys non > > rebindable and/or non removable _would_ come in handy in ... > now, that's an interesting idea. > how would that look, syntactically? Haven't thought about in PEP-sufficient details...:-) > dict['A']=1 > dict.lock('A') > > ..making the value unchangeable? Un-rebindable, to be precise -- i.e.: dict['A'] = list("ciao") dict.setlock(1, 'A') dict['A'].append("plip") print dict['A'] ciaoplip would work -- so the value is still changeable in the sense of 'mutable'. Sorry, this IS a pedantic distinction, but it can be important. What I (somewhat vaguely) had in mind was a .setlock() method (it may be important to have a .getlock one for introspection, too) able to associate 'lock-bits' with...: -- specific keys, -- all keys in the dictionary, -- all keys NOT in the dictionary and the lock-bits might inhibit one or more of: -- binding -- rebinding -- deleting -- changing the lockbits themselves and that's where it bogged down last time (before we got to the syntax) -- my correspondant was appalled at the idea of using 'bits' to overtly encode 'a set of options' and I could not find an alternative, as Python lacks 'sets'. Assuming one can stomach 'bits' (or some, e.g., encoding as string thereof, such as the mode parameter to 'open'), putting the bits first in setlock has the advantage that the other parameters to setlock can be optional. So...: dict.setlock(n) sets bits n as the lockbits for all keys not in the dictionary, dict.setlock(n, 'A') sets bits n as the lockbits for key 'A' (which must be in the dictionary right now, else KeyError is raised), dict.setlock(n, 'A', 'B', 'C') sets bits n for three keys, dict.setlock(n, *dict) sets them for all keys currently in the dictionary if a dictionary can be used as a sequence (as seems to be true in Python 2.2). A dictionary whose lockbits are set to forbid ANY rebinding, deleting, new-key binding, AND change to the lockbits, could suddenly and logically sprout hashability, since it becomes an acceptable key IF it has hashable values (much like a tuple -- if the items are changeable, the fact that the _container_ is not does not suffice). But that's an aside, I guess. > ..and would attempts to set the value raise an exception? Exactly -- that seems to be the only Pythonic approach. The key added-value of this hypothetical proposal would be to help you avoid accidental rebinding or deletion, or accidental addition of new keys, to a dictionary that you have decided must not be further changed in such ways. For example, sys.modules[__name__].__dict__.setlock(n) or if supported (if globals() WAS defined as equivalent...): globals().setlock(n) for an appropriate n would say "no more new keys can be bound in the current module's dictionary" -- giving much of the effect of optional "variable declarations" for the global variables of this module. Not the most crucial need in the world, but I think it WOULD be a helpful psychological crutch to know you COULD do that if needed, to get Python more widely accepted. And no special purpose machinery would be needed -- just an application of various useful mechanisms in orthogonal ways... very Pythonic IMHO. Easy to dress up in a function of course, as would be some other construct such as magic=23 globals().setlock(n,'magic') to make magic a non-rebindable "constant". Etc, etc. Alex From davygrvy at pobox.com Wed Jun 6 09:15:43 2001 From: davygrvy at pobox.com (David Gravereaux) Date: Wed, 06 Jun 2001 06:15:43 -0700 Subject: Is PyRun_String() broken? References: Message-ID: <70bshtod9tglkhnrqpp0m7v5jco7m1iavg@4ax.com> Martin von Loewis wrote: >This is the central problem. Your python::interp object should have >two commands: exec and eval. Ahh! D:\itcl_exp>tclsh84 % load tclpython20 % set i [python::interp new] python0 % $i exec {import sys} % $i eval {sys.version} 2.1 (#15, Apr 23 2001, 18:00:35) [MSC 32 bit (Intel)] % It works. I'm pleased. Now off to handle thread states and dictionaries, and should be close to something useable soon :) Thanks for the enlightenment (to both of you). -- David Gravereaux From whisper at oz.nospamnet Tue Jun 12 14:57:25 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 12 Jun 2001 18:57:25 GMT Subject: Has anyone used UML? References: <9flodi$32m$1@brokaw.wa.com> <3b228485.13884244@news.laplaza.org> <3B250921.F9F1D571@bt.com> Message-ID: <9g5oml$ird$6@216.39.170.247> In article <3B250921.F9F1D571 at bt.com>, alan.gauld at bt.com says... > Mats Wichmann wrote: > > Yes, it's kind of interesting that way. Three of the main > > practitioners of OO methodologies and modeling strategies all ended up > > working for Rational, leaving them with the odd situation of having > > the proponents of three different modelling schemes on staff. > > Not true! Rumbaugh and then Jacobson specifically joined > Rational to create the UML. By the time they joined they > already recognised the need for a unifying language. wellll.... actually Rational bought both Rumbaugh's and Ivarson's companies and they came along with the sale. From what I hear there is a good deal of not so cordial dislike between/among the "3 amigos" carefully hidden from the hoi poli of course. > Rational Rose(the CASE tool) already existed (indeed was at > version 2 at least) and was based on Booch's notation. The > first version to support UML still had Booch as default... > > > all... on the other hand, it may be that Rational Rose really is > > "that damn good" (personally, I have zero experience with it). > > When it first appeared (around 1992) it was the best thing > available - almost the only thing available - for "round > trip engineering". ie You could draw a design, generate code, > modify the code and then suck the code changes back into > your design. First time I saw that I was astounded at how > good it was. Nowadays several tools do the same tricks > - with pretty much equally unsuccessful results! But they > are all better than nothing for a significant sized project. > > Likewise they are all overkill for a small one! > > Alan g. > For all the ado about UML, there seems to be few competitors to Rose, at least that i'm aware of and, unlike most good innovations in the computer world, there has been little trickle-down of quality software to the generic small-shop programmer level. Perhaps that's due to little competition, the perception that one doesn't have the time to actually do decent design in today's competitive market and that abomination called XP (development by comittee - oh please - it's what the Japanese are working hard to get away from!) From xtian at hyperactive.co.nz Fri Jun 29 02:11:03 2001 From: xtian at hyperactive.co.nz (xtian at hyperactive.co.nz) Date: Fri, 29 Jun 2001 06:11:03 GMT Subject: SocketServer crash on my machine References: <9hdpu1$o1h$1@troll.powertech.no> <90CDDC8DCgmcmhypernetcom@199.171.54.155> Message-ID: <3b3c1606.28350415@news.supernews.com> On 28 Jun 2001 00:42:06 GMT, gmcm at hypernet.com (Gordon McMillan) wrote: >Syver Enstad wrote: > >>I was checking out the the SocketServer example in Mark Lutz rather >>excellent book Programming Python 2 edition, >>when > >[snip] > >> data = self.request.recv(1024) >> File "", line 1, in recv >>AttributeError: 'int' object has no attribute 'recv' > >The socket has already been closed. > >[more snippage] > >>class MyClientHandler(SocketServer.BaseRequestHandler): >> def handle(self): >> print self.client_address, now() >> print self.request >> time.sleep(5) >> while 1: >> data = self.request.recv(1024) >> if not data: >> break >> self.request.send('Echo=>%s at %s' % (data, now())) >> self.request.close() > >The code is wrong. It assumes that it is in charge of closing the >socket (or that a closed socket will yield no data - which is just >one way that you may find out a socket is closed). Actually, this problem is caused by a bug in the SocketServer module - the ThreadingMixin class overriding the process_request method means that the ThreadingTCPServer.process_request() call returns as soon as the Thread.start() call completes (instead of waiting for the request to be handled as it would in a single thread). Then the handle_request method on BaseServer closes the socket, which really should be closed by the RequestHandler in this case (because there's no way for the server to know when the thread finishes). It was quite confusing when I got bitten by it, because (due to the vagaries of thread scheduling) the error was occurring sometimes in the recv() call and sometimes at the send(). That error message doesn't help, although I guess that's happening at the OS level.. I fixed it by overriding handle_request like so: def handle_request(self): """Handle one request, possibly blocking.""" try: request, client_address = self.get_request() except socket.error: return if self.verify_request(request, client_address): try: self.process_request(request, client_address) except: self.handle_error(request, client_address) self.close_request(request) So handle_request won't close the socket unless it gets an exception... And made sure the RequestHandler.handle method has a try... finally block which closes the socket. More info at SourceForge: http://sourceforge.net/tracker/index.php?func=detail&aid=417845&group_id=5470&atid=105470 HTH, Xtian From sdm7g at Virginia.EDU Fri Jun 22 12:41:08 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Fri, 22 Jun 2001 12:41:08 -0400 (EDT) Subject: Another Wart! string.find() [ was: namespace issue? ] In-Reply-To: <9gvq7o$hm0$1@nntp6.u.washington.edu> Message-ID: On 22 Jun 2001, Donn Cave wrote: > > Given that you can't treat find or index as a boolean, there is > no fault I can see with its -1 failure return. In fact it would > be worse if it were false. Usage that doesn't work reliably > ideally shouldn't work at all, or it's all the harder to diagnose. > That last sentence above is just why I suggested None would be a better return value. You still can't do "if not string.find(..." because zero is still a valid return offset, but the problem with -1 is that it can slip thru since [-1] is a valid string index, it's valid in a slice expression, and can be added or subtracted as an offset to another index value, all without giving an exception anywhere near the error. If you try to use None as an index or add it to another offset, you get an exception right away. -- Steve Majewski From tdickenson at devmail.geminidataloggers.co.uk Tue Jun 12 09:04:21 2001 From: tdickenson at devmail.geminidataloggers.co.uk (Toby Dickenson) Date: Tue, 12 Jun 2001 14:04:21 +0100 Subject: Lost between urllib and httplib References: Message-ID: <8p4cito6nu1c26lecrtm497u1lt0rpc40o@4ax.com> On 10 Jun 2001 21:06:11 GMT, gustafl at algonet.se (Gustaf Liljegren) wrote: >I'm choosing between urllib and httplib, but have trouble with both. >urllib.urlopen() is hiding HTTP errors (hope this will be fixed in next >version!) urllib.urlopen is implemeneted using the class urllib.FancyURLopener. That class does lots of good things (such as transparently handing redirects) but its default behaviour is to swallow any errors it doesnt know how to handle. I suggest you derive a new class from FancyURLopener, and overide the http_error_default function. I often use this class to raise errors in exceptions..... class URLopener(urllib.FancyURLopener): def http_error_default(self, url, fp, errcode, errmsg, headers): return urllib.URLopener.http_error_default(self, url, fp, errcode, errmsg, headers) >and httplib.HTTP() doesn't seem to be able to access some pages >if you only supply a domain name. httplib is very low level, I suggest you stick with urllib. Toby Dickenson tdickenson at geminidataloggers.com From qrczak at knm.org.pl Mon Jun 18 15:57:24 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 18 Jun 2001 19:57:24 GMT Subject: substitute for c/java's ?: References: Message-ID: Thu, 14 Jun 2001 04:20:30 -0500 (CDT), Glyph Lefkowitz pisze: >> The ?: operator is overrated. For the time you save typing, you >> are wasting someone else's because they need to figure out what you were >> thinking. > > Trust me, this is true. Compare the following actual examples: You are cheating: the real difference was between ||'ed comparisons and in, not between ?: and if-statement. > def aan(name): > """Utility which returns 'a' or 'an' for a given noun. > """ > if string.lower(name[0]) in ('a','e','i','o','u'): > return 'an ' > else: > return 'a ' def aan(name): """Utility which returns 'a' or 'an' for a given noun. """ return if string.lower(name[0]) in 'aeiou' then 'an ' else 'a ' Is it really that bad? Now I cheated by using a string instead of a tuple :-) BTW, results are wrong for aan('university'), aan('hour'), aan('XMS'). -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From hinsen at cnrs-orleans.fr Fri Jun 29 10:19:32 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 29 Jun 2001 16:19:32 +0200 Subject: the center of the world (was Re: Check out O'Reilly's Open Source Convention Highlights) References: <3B3AA82D.1A0FE860@seebelow.org> <3B3B2DED.5303198A@seebelow.org> <9hhri7019jd@enews2.newsguy.com> Message-ID: markus at kepler.ibp.de writes: > Then find first the weighted average as a point in three-dimensional > space, i.e. as (an approximation to) the center of gravity of the > human population. This will be some point deep in the interior of the > Earth, which you could the project back to the surface. But that doesn't minimize the distance on the surface. Actually, we should minimize something even more pragmatic, such as travel cost, travel time, or some weighted combination. Konrad. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From gustafl at algonet.se Sun Jun 10 17:06:11 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 10 Jun 2001 21:06:11 GMT Subject: Lost between urllib and httplib Message-ID: Python 2.1: I'm choosing between urllib and httplib, but have trouble with both. urllib.urlopen() is hiding HTTP errors (hope this will be fixed in next version!), and httplib.HTTP() doesn't seem to be able to access some pages if you only supply a domain name. Here's the script I use for testing httplib: import urlparse import httplib import sys url = sys.argv[1] try: h = httplib.HTTP(urlparse.urlparse(url)[1]) h.putrequest('GET', urlparse.urlparse(url)[2]) h.putheader('Accept', 'text/html') h.endheaders() except: print "Host not found." sys.exit() print h.getreply()[0] On some websites, I get HTTP error 301, 302 or even 404. Try for example: http://www.webstandards.org (301) http://www.native-instruments.com (302) http://www.chaos.com (404) If using urllib however, these places are all accessed successfully. What is it in urllib.urlopen() that has to be added if using httplib? Regards, Gustaf Liljegren From skodela at hotmail.com Wed Jun 13 15:31:21 2001 From: skodela at hotmail.com (Sreekant) Date: 13 Jun 2001 12:31:21 -0700 Subject: Postgresql Woes Message-ID: <436ad7a4.0106131131.57bc1cd1@posting.google.com> Hi folks I have made a few web sites with postgresql but never needed to know the list of tables available in the database through pg module. I guess you can use psql and \dt command or os.popen('psql ... , to get the list of tables. But is there a decent way of finding out through python and postgresql [pg] module , all the tables in a database! eg: con=pg.connect("mydb") tbl=pg.query("show all tables from mydb") or something similar ?? Thanks a lot for your time sreekant From alankarmisra at hotmail.com Fri Jun 15 12:11:04 2001 From: alankarmisra at hotmail.com (gods1child) Date: 15 Jun 2001 09:11:04 -0700 Subject: str smarter than round? Message-ID: <25b2e0d9.0106150811.11efdd73@posting.google.com> What does str() know that round() doesnt in the following lines? >>> a = 1.69 >>> round(a,2) 1.6899999999999999 >>> round(a,1) 1.7 >>> str(a) '1.69' >>> How does str manage to get the accurate representation of floating points? I am using Windows 2000, Python 2.0 From jeff at ccvcorp.com Thu Jun 21 18:57:54 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Thu, 21 Jun 2001 15:57:54 -0700 Subject: Thread safety of UDP sendto References: <9gto69$ij2$1@murdoch.acc.Virginia.EDU> Message-ID: <3B327BF1.81BFB842@ccvcorp.com> "Jeffrey W. Collyer" wrote: > An odd question perhaps, but is Python's UDP socket.sendto() thread safe? > > I have a multi-threaded app that I would like to send off some UDP packets. > The data for the packets is gathered in each thread. If I get a socket > handle in each thread it will be less efficient than if I open one upon > program start and then have each thread just do an > ubersocket.sendto(data,ADDR). Or am I missing something more basic? > > What I really need is an atomic write function that handles threading, but > I'll settle for a cheap UDP solution. My initial thought would be to designate one thread to handle the socket, and have all of the other threads forward their data to the socket thread via some sort of queue. Variations in the queue could allow you to organize the data in whatever way was appropriate for your particular circumstance. Jeff Shannon Technician/Programmer Credit International From dan at webmind.com Wed Jun 27 00:48:04 2001 From: dan at webmind.com (Dan Tropp) Date: Wed, 27 Jun 2001 14:48:04 +1000 Subject: time module - is strptime available under NT? In-Reply-To: <270c68fe.0106262026.2c3fc12c@posting.google.com> Message-ID: <000b01c0fec4$5aaf0ac0$0601c10a@oz.intelligenesis.net> Is this function available in the windows (NT) version? If not is there a commonly used alternative? Or do people just parse things up themselves with re? dan Dan Tropp Dept Psychology, University of Melbourne, Australia From rnd at onego.ru Thu Jun 14 05:59:32 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 14 Jun 2001 13:59:32 +0400 (MSD) Subject: substitute for c/java's ?: In-Reply-To: Message-ID: On Thu, 14 Jun 2001, Glyph Lefkowitz wrote: >On Wed, 13 Jun 2001, Neil Macneale wrote: > >> In article <9g5fc4$m8u$01$1 at news.t-online.com>, "Jochen Riekhof" >> wrote: >> >> > I am missing something like the c/Java ?: operator. >> >> The ?: operator is overrated. For the time you save typing, you >> are wasting someone else's because they need to figure out what you were >> thinking. > >Trust me, this is true. Compare the following actual examples: > > public static final String aan(String s) > { > char x = s.charAt(0); > > return ((( x == 'a') > || > (x == 'e') > || > (x == 'i') > || > (x == 'o') > || > (x == 'u') > || > (x == 'A') > || > (x == 'E') > || > (x == 'I') > || > (x == 'O') > || > (x == 'U')) > ? "an " : "a " > ); > } > > >def aan(name): > """Utility which returns 'a' or 'an' for a given noun. > """ > if string.lower(name[0]) in ('a','e','i','o','u'): > return 'an ' > else: > return 'a ' > Even better: if string.lower(name[0]) in 'aeiou': ... Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Thursday, June 14, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Police Blotter: Energizer Bunny Charged with Battery!" _/ From awhite at techtrader.com Sat Jun 16 03:39:01 2001 From: awhite at techtrader.com (Abe) Date: 16 Jun 2001 00:39:01 -0700 Subject: Newbie Question: Naming Conventions Message-ID: I expect that this is a subject that has been beaten to death, but I haven't been able to find much info on it: I've experimented with many many computer languages, and I have to say that from what I've seen thus far of Python, it is probably the most elegant I've encountered. The combination of its clean syntax, OO nature, and functional aspects is excellent. HOWEVER, I'm very frustrated over the apparent lack of stylistic conventions for method names, etc in an otherwise consistent language. >From a search of the archives, it appears that Guido's stance on this is that developers should be free to choose a style that suits them. I don't think anyone would disagree with that, but can't we at least have some consistency for the standard packages and built in functions? The recent trend seems to be towards CapitalWords for classes and alllowercase for methods and packages... but then there are builtin throwbacks like has_key and raw_input mixed in that stick out like a sore thumb. Coming from the java world where the naming style is very consistent, having to use 'has_key' in the same code block as 'hasattr' drives me crazy! I could easily modify the C files to alias the 'haskey' and 'rawinput' names to the correct methods, but then my code wouldn't work on any other python runtime. So my question is: is there any proposal to standardize this sort of thing? Would such an initiative be welcome in the python community, or is it seen as not important? Does anyone see any obvious compatibility problems with providing an extra 'correct' version of nonconforming methods and classes until the originals can eventually be phased out? Or if this has all been covered before, please let me know where I can find the relevant discussion. Thanks! From pecora at anvil.nrl.navy.mil Wed Jun 6 08:16:40 2001 From: pecora at anvil.nrl.navy.mil (Louis M. Pecora) Date: Wed, 06 Jun 2001 12:16:40 GMT Subject: How do you develop in Python? References: <050620011516094693%pecora@anvil.nrl.navy.mil> Message-ID: <060620010818469790%pecora@anvil.nrl.navy.mil> In article , Michael Hudson wrote: > Lou Pecora writes: > > > I program in Python occassionally and would like to do more of it. But > > here's a development conundrum I run into a lot (there are more complex > > examples, but I'll give an easy one). I am developing module A.py > > which imports B.py in the IDE. I am running test code which is also in > > A.py as I incrementally develop A.py. Then I need to change B.py and, > > of course, the import does not import the new changes since import only > > works once. Hence, to "refresh" B.py I have to quit the IDE and > > restart, open A.py and run. This is clumsy. However, the above > > scenario is not uncommon and more complex interdependencies of modules > > appear to make it unavoidable. Anyone know a way to get around this > > "import" problem? I know there is a "reload", but then I have to > > import and change my modules' code to "reload" or something each time I > > work with them. Any help appreciated. > > If module A.py goes > > import B > ... uses B ... > > and then in the top-level you type > > >>> import A > >>> import B > > then change B.py > > then in the top-level typing > > >>> reload(B) > Let me try to rephrase your solution. I go into the "commandline" window and do a reload of the imported modules. I guess that would work. I will try it. I was looking for a more automatic way of reloading things as they changed rather than having to manually do it when I altered code in another module. Thanks. From thomas at gatsoft.no Wed Jun 20 02:49:13 2001 From: thomas at gatsoft.no (Thomas Weholt) Date: Wed, 20 Jun 2001 06:49:13 GMT Subject: Performance of asycore.py / BaseHTTPServer Message-ID: Hi, I'm thinking of writing a SOAP-server using asyncore or BaseHTTPServer. What kind of performance could I expect? Compared to implementing something using Apache/mod_python, Zope, webware or any other freely available webserver-framework?? How will the standard modules included in Python perform under heavy load, ie. lots of concurrent users? Would the size of the response slow the server down? Benchmarks would be nice. Thomas From Attila.Feher at lmf.ericsson.se Wed Jun 6 12:23:46 2001 From: Attila.Feher at lmf.ericsson.se (Attila Feher) Date: Wed, 06 Jun 2001 19:23:46 +0300 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3B1B1825.8109BA83@lmf.ericsson.se> <2v4ohtgldvce84sn87kh1eg1lnes37getq@4ax.com> <3B1C9E65.B73A4FE@lmf.ericsson.se> <3B1DFD87.F3BFDB57@lmf.ericsson.se> Message-ID: <3B1E5912.CBB0BCA9@lmf.ericsson.se> Rainer Deyke wrote: > > "Attila Feher" wrote in message > news:3B1DFD87.F3BFDB57 at lmf.ericsson.se... > > Yep. But let's say I want to make a non-open-source stuff. Wrappers > > are either GNU licenced or damn expensive to buy/make... > > SDL: Game API wrapper. LGPL, so it can be (and has been) used in > closed-source commercial software. > > wxWindows: GUI API wrapper. LGPL with additional permission to redistribute > in binary form without restriction, so it can be (and has been) used in > closed-source commercial software. Thanx! I have never payed enough attention than... So you use wxWindows? Last time I saw some important stuff was missing. I don't do games (YET) but could you post me (Email) a URL to this SDL? Who knows :-))) Do U think I could write a UML thing based on wxWindows? What OSs does it support? Is Apple in it? As far as I remember it supported X only, which is a trouble if you want to write sthg you whish to be used in high security places... (like Pentagon :-))) A From tundra at tundraware.com Tue Jun 26 14:50:02 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 26 Jun 2001 18:50:02 GMT Subject: Is this a true statement? References: <8NuZ6.362378$oc7.42924874@news2.rdc2.tx.home.com> <3B3788A2.3BD1D672@tundraware.com> <9qMZ6.368197$oc7.44797813@news2.rdc2.tx.home.com> <3B37A15D.DF05A331@tundraware.com> <3b386603.106141042@news> Message-ID: <3B38D856.C80E5459@tundraware.com> Brian McErlean wrote: > > > Output is not the same as computational ability. The interfaces with > which a program can output and interact with its environment have no > effect on its computational power. Postscript is turing complete, but > > can't even access files. Java is turing complete, and remains so when > > you limit what it can access through its security model. Right. The "limitation" of one T-C language compared to another is its *implementation* not the language itself. This is what I've been claiming throughout this thread because it sounded like people were claiming that one language could "do" more than another. One *implementation* can certainly do more or less. > > > >> All computer programs are deterministic. Any computer program that > > > >Nope. Not even close to true. The entire family of NP-Complete algorithms > >(Traveling Salesman, Knapsack Packing, et al) are NON-deterministic (that's > >what the 'N' stands for. > > This is incorrect. There is no such thing as an NP-Complete > algorithm, you mean NPC _problems_. This simply means that there is > no (currently known) deterministic algorithm that can solve the > problem in polynomial time. > > The non-deterministic part refers to the fact that it _is_ possible to > check whether a proposed solution is in fact correct, and so if you > have a non-deterministic step that 'guesses' a solution, or you check > all possible solutions in paralell, then you can potentially solve it > in polynomial time. > > The checking algorithm is still deterministic. The NP part only > refers to the time complexity of the problem, not the algorithm. The > problems are completely solvable with normal algorithms - they just > take a long time. I stand corrected. You're absolutely right. > > > > >> > 2) Have Python write out a set of machine code bits which > >> > are understood by the underlying implementation and > >> > hardware to be the correct handling of an interrupt. > > Actually, I don't think this is a valid solution to the problem. If > you define "writing a device driver in python" as equivalent to > "writing a program in python that writes a device driver", then you > violate the "purely in python" bit, because you're also writing it in > C ( because the python interpreter is written in C, and it > wrote/interprets a program (with your python program as input) that > wrote the program that generated the device driver ;-) > I am saying that there is some set of machine code bits which the underlying system will understand as a device driver once it is put in place (much like a C compiler compiles to loadable driver). The set of bits can be generated by a Python program and never again see the Python interpreter. > > > > >> > >> > 3) Add a native interrupt object to the language. > >> > > >> > 1) clearly takes us out of "pure Python" and is thus of no further > >> > interest (unless you actually want to *solve* this problem in the > >> > real world, in which case this is probably the best solution ;))) > >> > > >> > 2) Works just fine, but is kind of clumsy and unnatural to use. > >> > Note, however, that it is 2) that gives us the ability to do *anything* > >> > in Python which we can "do" in any other Turing-Complete language. > >> > > >> > 3) is where the rocks start to get thrown. If I do 3), have I "extended" > >> > the language to do something it could not previously? NO! I have > >> > implemented what I could already do with 2) in a more programmer-friendly > >> > manner, but I have not changed the net computational power of the > >> language. > > But I don't think you can define the language as "anything it might do > at some future point in time, after I've added something." > > If I add the complete possible C interfaces to postscript, I don't > think I can call it postscript anymore, (unless I want a lawsuit > whenever someone views a document that formats his hard drive). > > If by "Python" you are referring to all possible future > implementations of the language, then this is true, but you can still > say "There are things possible in implementation of C, that are > not possible with the standard distribution of python 2.1" The only point that I was trying to make (apparently not well) is that changes in implementation do not give a language new computational capabilites, as such, they merely make it easier for the programmer to do things that were impractical or limited by the implementation in the past. The *language* always has the ability to do these things somehow. ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From ngps at madcap.dyndns.org Fri Jun 1 11:40:15 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 1 Jun 2001 15:40:15 GMT Subject: M2Crypto and 2.1 References: Message-ID: <9f8d0v$gq4$1@dahlia.singnet.com.sg> According to Robin Becker : > I'm attempting to get M2Crypto to work with 2.1; there were many places > with sys.version[:3]=='2.0' which means that nothing gets done for 2.1. > > After changing several of these to read >=2.0 (ie use the 2.0 solution > for 2.0 and above) I can at least get the v2.1 ssl/https_cli to work > with the v2.0 server, but I can't seem to get v2.1 ssl/https_srv.py to > work right. > > Anyone managed this yet? Yes, I have! ;-) Tested for Pythons 1.5.2, 2.0, 2.1, https and xmlrpc-over-https, blocking and non-blocking servers. A new snapshot should be up over the weekend. Cheers. -- Ng Pheng Siong * http://www.post1.com/home/ngps Quidquid latine dictum sit, altum viditur. From tim.one at home.com Mon Jun 25 22:24:52 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 25 Jun 2001 22:24:52 -0400 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) In-Reply-To: <3B37E6B9.AD859344@cosc.canterbury.ac.nz> Message-ID: [Greg Ewing] > In Icon, there isn't any implementation *to* expose. Of course there is -- Griswold wrote a whole book about it. > There are no generator-iterators in Icon; the closest equivalent > is simply the activation record of a procedure. Some implementations of Icon work that way, but they've used several approaches over the years. In no case did they expose any of the internals, though. We didn't *have* to expose Python's generator-iterator object either, but doing so adds (IMO) significant power over Icon's generators -- and it's more Pythonic to do so anyway. From wware at world.std.com Fri Jun 1 15:33:08 2001 From: wware at world.std.com (Will Ware) Date: Fri, 1 Jun 2001 19:33:08 GMT Subject: more stupid stock quote tricks Message-ID: A couple years ago I noticed the Yahoo stock quote website had started making available lengthy historical data on prices and volumes of stock trading, so I posted some Python code to collect this data and buffer it locally: http://groups.google.com/groups?th=a8bda3c3bf7aac3b,6&rnum=1&ic=1 After badly burning my fingers in 2000 you'd think I'd learn something. For the amusement of other slow learners, here's more greed candy: http://groups.google.com/groups?rnum=3&ic=1&th=cb9ed376433ac9c3,3 Write extensions of the Experiment class, and you can comparatively back-test different stock-picking algorithms. As always, this is for entertainment only and is not a recommendation of any particular investment or investing strategy. Caveat sucker. -- -----------------------------------+--------------------- 22nd century: Esperanto, geodesic | Will Ware domes, hovercrafts, metric system | wware at world.std.com From john.thai at dspfactory.com Fri Jun 1 13:02:14 2001 From: john.thai at dspfactory.com (John) Date: Fri, 1 Jun 2001 13:02:14 -0400 Subject: spaces and arguements.. Message-ID: <3UPR6.243439$Z2.2750797@nnrp1.uunet.ca> Hi, Am I mistaken or is there a way to invoke a method with arguements that are separated by spaces instead of in brackets? Much like print x, y ? So if I had a method foo(x) can I call foo x ? Thanks, John From not.this at seebelow.org Wed Jun 27 22:53:45 2001 From: not.this at seebelow.org (Grant Griffin) Date: Wed, 27 Jun 2001 21:53:45 -0500 Subject: PEP 260: simplify xrange() References: <3B39480C.F4808C1F@Lugoj.Com> <9hc97q$rpt$1@slb6.atl.mindspring.net> Message-ID: <3B3A9C39.64C3E1C6@seebelow.org> Andrew Dalke wrote: > ... > As a double check, I did a google search for > +"import al" +def BTW, among its many other technological advances, Goggle frees you from having to put "+" in front of stuff. like-indents-for-bracing,-it's-yet-another-idea-that's-so-simple -that-nobody-else-thought-of-it-before--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From tim.one at home.com Sun Jun 24 17:30:47 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 24 Jun 2001 17:30:47 -0400 Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: [Glyph Lefkowitz] > If python's answer to "what should we do with new feature X"? is > "add a keyword" it will turn into Perl before too long. Since that's very rarely Python's answer, this is slippery-slope FUD shouted from a flat plane. > ... > And yes, we should wait indefinitely for microthreads. You're welcome to, but, e.g., I've wanted Python generators for 10 years, and have no pressing use for microthreads. I don't object to you getting the latter, but they're gross overkill for most things I want to do. Generators are much simpler and often suffice. > If generators are implemented as a syntax feature, then microthreads > are implemented as a module I see no logical connection there: whether microthreads grow new syntax is an independent issue. > (or should we have syntax for that too? 'task' anyone?) That's something for the microthreads PEP to stake out. You know that implementing the semantics efficiently in Jython too has been a severe impediment to Stackless adoption, right? You may very well *need* new keywords for any gimmick like these to get around that: Finn and Samuele cannot change the JVM, and last I heard even Christian gave up on that tack (which is saying something -- he routinely redefines truth ). > then we're again falling prey to a sin of perl; there will be more > than one way to do it. Generator semantics are simple and synchronous. Nobody in their right mind codes them "by hand" using a thread model instead (voice of experience there -- and, no, I haven't always been in my right mind ). For the same reasons, Python would retain "while" loops even if Guido added a "goto". BTW, you're missing the slippery slope argument that *may* have merit in real life: Just was almost certainly correct in predicting that the adoption of generators is the best thing that could possibly happen for Stackless's prospects. The audience for microthreads is enthusiastic but small, and the best shot it has is to ride in as a generalization of something else. > This is, after all, not a new *capability* of python per se, like the > ability to parse XML or display 3D objects using OpenGL; it's just an > attempt to build a particular idiom into the language, by providing a > convenience. The ability to resume a function, and efficiently, is a new capability -- and a powerful one, and a useful one. > ... > At least from my point of view, generators are a solution to a problem > which does not exist. There's nothing I can see which would be > *significantly* easier using generators. There's nothing I can see which would be significantly easier using microthreads: you could use real threads instead. If you're eager to ignore the *pragmatics* of generators, then I'm happy to repay the favor wrt microthreads. Reducing development time, increasing expressivity, increasing efficiency, and improving scalability aren't fundamentally new capabilities either -- they're "merely convenient" too, for sufficiently strained rhetorical distortions of "merely convenient". > In addition, the implementation side of this is just an efficiency hack. To the contrary, Neil's implementation is so elegant it makes me smile -- calling it a hack is at best in bad taste. If you looked into it instead of ranting about it, you'd discover that the things he did to the eval loop are necessary preconditions for implementing microthreads too -- the ability to suspend a frame in midstream is fundamental to all these gimmicks. This will be the end of the path for most, but it takes you closer to your goal. > It's not hard to make this work using threads; but since python doesn't > have real microthreads, generators won't be built on top of anything > except the interpreter itself; and they will hinder the future > implementation of microthreads should they happen To the contrary, they're probably microthreads' best hope. > and probably cause some pretty fruity interoperability issues (if it's > a syntax feature). Possibly, depending on how lame the microthread implementation is <0.9 wink>. > New users should not be using generators -- it's an advanced control > structure with some interesting uses, but neither would I try to explain > to a newbie how to write a task scheduler by putting hooks into ceval.c. > Programming is just hard sometimes. (This is one of the reasons I use > python and *NOT* icon; for me, generators are not an important enough > feature to worm their way into everything.) Generators aren't becoming central to Python; they're an especially powerful instance of 2.2's iterator interface (a point you should consider: generators live in the iterator world, not in the thread world, and iterators are ubiquitous in all kinds of apps; thread-like control flow has a much smaller audience, and smaller still if the "threads" block at synchronous I/O calls, and smaller still again if they don't act like "real threads" when running in foreign code). if-you-want-to-be-a-millionaire-you-only-have-to-collect-1000-dollars- 1000-times-ly y'rs - tim From jwolff at knoware.nl Thu Jun 14 17:24:11 2001 From: jwolff at knoware.nl (Jeroen Wolff) Date: Thu, 14 Jun 2001 23:24:11 +0200 Subject: sorting values in dict Message-ID: I want to display a dict sorted by value. This is my dict: total={} srcAS = a string which i wil take from a file.... Bytes = also a string which i wil take from a file... if total.has_key(srcAS): total[srcAS] = total[srcAS] + string.atoi(Bytes) else: total[srcAS] = string.atoi(Bytes) This is how i sort it by keys: keys = total.keys() keys.sort() for n in keys: print n, total[n] But i would like to have is sorted (on screen) by value.... Is this possible? Jeroen From philh at comuno.freeserve.co.uk Thu Jun 14 18:47:00 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Thu, 14 Jun 2001 23:47:00 +0100 Subject: Any other Python flaws? References: <3B2914A0.6010902@erols.com> Message-ID: On Thu, 14 Jun 2001 15:46:40 -0400, Edward C. Jones wrote: >Andrew Kuchling wrote: > >> ... Are there any other flaws that should be added? > > >It follows from some basic concepts of Python that > "array = ([0] * 10) * 10" >does not behave as usually intended. I didn't know what this did before typing it in. I *expected* it to produce an array with 100 elements, all 0, and when I typed it in... ...I got an array with 100 elements, all 0. I think python is OK here. -- ## Philip Hunt ## ## philh at comuno.freeserve.co.uk ## From ghockleyNOSPAM at home.com Mon Jun 18 17:40:12 2001 From: ghockleyNOSPAM at home.com (Glenn A. Hockley) Date: Mon, 18 Jun 2001 21:40:12 GMT Subject: Newbie Help on ODBC & Apostrophes Message-ID: <0zuX6.276651$eK2.57158115@news4.rdc1.on.home.com> Hi, I have a question that probably has a very simple answer. I am trying to use an Access database via the PythonWin ODBC modules to store a list of names. I get these names via a form on a web page through CGI. My problem lies with a name with an apostrophe in it, such as O'Brien for example. In this case, the ODBC statement doesn't seem to work. For example, if I try to do the following: myCursor.execute("SELECT * FROM MyTable WHERE Name='O'Brien'") it obviously doesn't work. However, the name is retrieved from the web site and is automatically insterted into this string. >From what I have read, to use a string in an ODBC execution statement requires that it be surrounded by single quotes. For example: myCursor.execute("INSERT INTO MyTable values ('glenn')") So is there a way to make it so that if the user enters name with an apostrophe, that this apostrophe doesn't cause my program to crash, and that the name is added to the database with the apostrophe in it? Hopefully that makes sense... thanks From knut737 at wxs.nl Fri Jun 29 04:48:43 2001 From: knut737 at wxs.nl (Lk) Date: Fri, 29 Jun 2001 10:48:43 +0200 Subject: zope en cmf Message-ID: <9hhfdh$5odi$1@reader02.wxs.nl> Hoi, Ben er niet zeker van of dit de goede groep is indien niet wie wil me verder brengen? Wie werkt er met zope en cmf en kan me helpen? Ben bezig om cmfsite te bouwen wat ik wil is: members kunnen de hoofdpagina zien en hun eigen map members kunnen niet naar andere members kijken admin kan toevoegen in ieders map volgens mij moet het simpel zijn maar ik zie in door de vinkjes het bos niet meer. En mijn tweede vraag is: Als ik een foto (bijv jpg) upload kan je deze bekijken met de werkbalk in beeld. Als ik een quicktime movie upload en je bekijkt hem krijg je een rood kruisje, hij ziet de .mov dus niet. In de adresbalk van de browser zie je dan ....../member/view als ik /view weghaal zie je de movie wel. Hoe los ik dit op? Ben van huis uit ontwerper en mijn doel is een goed werkende interface te maken via zope met vernieuwende vormgeving. lars From Randy.L.Kemp at motorola.com Thu Jun 7 16:46:10 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Thu, 7 Jun 2001 15:46:10 -0500 Subject: ???????????????? Message-ID: Oh, joy. Does this mean I can earn a degree in Python? -----Original Message----- From: email [mailto:email] Sent: Thursday, June 07, 2001 9:37 AM To: python-list at python.org Subject: ???????????????? IT Management Association UK University of Devonshire UK Any enquiry please contact Sunny Cheung Email: sunny at itma-uk.org URL: www.itma-uk.org Tel: 27108382 (Office hour) Add: Rm. 2103 Hollywood Plaza, 610 NAthan Rd., Mongkok, Lowloon. Open entry Anyone aged 17 or above is eligible to apply. No entry qualifications are required except for professional programs. Distance learning You will enjoy maximum flexibility through distance learning. You will learn through the printed materials, set texts and other materials that we suggest. Financial assistance Low-interest loans are available to help students with financial difficulties. Credit transfer You may transfer credits gained at local or overseas universities to our programs. It depends on your previous qualifications and their relevance to the program you wish to enroll. Recognition IT Management Association UK and University of Devonshire UK awards are widely recognized for employment?Bprofessional bodies, and further studies both in Hong Kong and overseas. Institutional credit transfer arrangements have been signed with institutions in U.K., Canada, Australia, USA and New Zealand. Assessment Our programs are widely recognized for its high quality. Your study will be assessed by subject paper throughout a course taken and no examination is required. Tuition Master Degree HK$42,000 Bachelor Degree Final Stage HK$18,000- Diploma -> Bachelor Degree Combination HK$48,000- Diploma -> Graduate Diploma Combination HK$38,000- Diploma -> Advanced Diploma Combination HK$28,000- Diploma, Advanced Diploma, Graduate Diploma HK$18,000- Entry to any level diploma / final year of Bachelor Degree with previous education qualifications or working experience Bachelor of Business Administration Course Contents 1. Introduction to Business 2. Fundamental Accounting Principles 3. Approach to Management 4. Introduction to Business Communication 5. Principles of Economics 6. Financial Accounting 7. Marketing 8. Organizational Behavior 9. Introduction to Corporate Finance 10. Financial Markets 11. Entrepreneurship 12. Business Administration 13. Introduction to Human Resource Management 14. Introduction to Law for Business 15. Contemporary Advertising 16. International Marketing Bachelor of Science in Computer Science Course Contents 1. Introduction to Business 2. Computer Studies 3. Fundamentals of the Internet and World Wide Web 4. Learning C++ 5. Introduction to Computer Science 6. Fundamental Accounting Principles 7. Introduction to Languages and Computation 8. Software Engineering with Java 9. Database Systems Concepts 10. Introduction to Business Communication 11. Classical and Object-Oriented Software Engineering with Java and UML 12. Database Management Systems 13. Problem Solving Using C 14. Computer Organization 15. Computer Architecture 16. Machine Vision Bachelor of Science in Management Information Systems and Technology Course Contents 1. Introduction to Business 2. Communication Networks 3. Corporate Information Systems Management 4. Learning C++ 5. Fundamental Accounting Principles 6. Building the Information-Age Organization 7. Competitive Advantage (IT) 8. Software Engineering with Java 9. Introduction to Information Systems 10. Information Technology for Management 11. Information Systems 12. Accounting Information Systems 13. Principles of Management 14. Managing Information Systems in the Information Age 15. Classical and Object-Oriented Software Engineering with Java and UML 16. Problem Solving Using C Students completing all required subjects can obtain a Bachelor Degree from The University of Devonshire. The Bachelor Degree can normally be completed within 16 to 48 months. Students enrolled in the Graduate Diploma will complete 12 subjects from the list. The Graduate Diploma can normally be completed within 12 to 36 months. Students enrolled in the Advanced Diploma will complete 8 subjects from the list. The Advanced Diploma can normally be completed within 8 to 24 months. Students enrolled in the Diploma will complete 4 subjects from the list. The Diploma can normally be completed within 4 to 12 months. Master's of Business Administration Course Contents 1. Corporate Finance Essentials 2. Managerial Economics 3. Principles of Management II 4. Marketing Management 5. Management Competition 6. Integrated Business 7. Modern Business Law 8. Advanced Financial Accounting 9. Business Communication in the Professional Setting 10. Consumer Behavior and Marketing Strategy 11. Global Marketing E-Commerce MBA Course Contents 1. International Business 2. Cases in Electronic Commerce 3. E-Business 4. Management Information Systems for the Information Age 5. Investment Experience 6. Security, Risk Management, and Control 7. E-Business: Roadmap to Success 8. Internet Marketing 9. E-Business Revolution 10. Accounting Information Systems 11. Global Marketing Master's in Computer Science Course Contents 1. Advanced Studies in Programming Languages 2. Database Systems 3. Computer Systems: Organization and Operating Systems 4. Advanced Studies in Algorithm Design and Analysis 5. Software Engineering 6. Computer Graphics 7. Network Design and Analysis 2 Students completing all required subjects could obtain a Master Degree from The University of Devonshire. The Master Degree can normally be completed within 9 to 24 months. 2 Students completing 2/3 required subjects from the list could obtain a Postgraduate Diploma. 2 Students completing 1/3 required subjects from the list could obtain a Postgraduate Certificate. ?M?~???? (Professional Diploma) ???{?G ?M?~???M?a???????{???b?????????????n?M?~???M???S?????~???N???????N?V?m?A???L???????q?????M?????~?????k???t?C???????????C ?????U?M?~???????{?????G ???????????????~?????|???^???????F?????????H?W?A ?????????~?{???????}?n?^?y?\?????g?@???O?A ???w?????????????{???|?????????A ??19???H?W???~?????A?????@?~?????u?@?g???C 2 ?q???t???????????N?????u?{?v?M?~???????{ Professional Diploma in Computer System & Network Support Engineer ?????{?????b???????????q?????{???q???q???t?????N?????H?h?A?????M?~?????????????|?A?????????????p?U?G 1. Hardware Introduction - I?]?q???w???@?^ Computer Keyboards, Data Processing, Electrical requirements of computer systems, Printer Management, Disk Management, Central Processing Units and Memory, Storage Systems, Input and Output Devices, Data Communications, Networking, Process Control. 2. Hardware Introduction - II ?]?q???w???G?^ Processors, Memory and Benchmarking, Buses and Interfaces, Mass Storage Devices, Input Output Devices, Power Supplies, Testing Procedures, Configuring Peripheral Devices. 3. Operating System ?]?q?????@?t???^?? What is an Operating System, Various parts of an Operating System, What is a Process, Operating System Load, File Management, Software Tools, Basic Features of Graphical Interfaces, Windows Objects and Components. 4. Windows 95/98 and MS-DOS Operating System ?]?????E?????E?K?????????@?t???^?? Why Windows 95/98, Basic Features, Starting Up, Using Applications, Managing Files and Folders, Managing the Desktop. 5. Introduction to Networking ?]?q???????^?? Network Concepts Components, Adapters, Wiring Guide, ELA TIA-568 Standard, Twisted Pair, Coaxial, Fiber, OSI Model, Network Segments, Spanning Tree Algorithm, Repeaters, Bridges, Routers, Hubs, Ethernet Switches, Virtual Networking Network Topology Bus, Bus-Physical Layout, Ethernet 802.3-CSMA/CD, 10Base2-Ethernet, 10Base5-Ethernet, 10BaseT-Ethernet, Bus-Physical Cable Limits, Ring, Ring-Physical Layout, IEEE 802.5 Token Ring, Ring-Physical Cable Limits, Star, FDDI, Logical vs Physical. Connecting Computers Peer to Peer, Workgroups, Workgroup Resources, Belonging to a Workgroup, Sharing Resources, Accessing Resources, Novell File and Print Services, Domains, User Accounts, Computer Accounts, Groups, Domain Models, Single Domain Model, Trust Relationships, Single Master Domain Model, Complete Trust Domain Model. Troubleshooting Cable Testing, General Troubleshooting Principles, Hardware Diagnostics, Using a TDR, Using a multi-meter. 6. Windows 2000 Server/NT Server 4.0 ?]???????????A???????????????D???^?? Operating Systems, Windows NT Services, Workgroups and Domains, Domain Name System, Active Directory, Administering Active Directory, Security and Permissions, Supporting Users, Managing S/W Applications, Managing Printers, System Recovery. 7. Introduction to Internet and Web Pages Development?]???p?????????????}?o?^?? Understand basic Internet concepts and terminology, Use a browser to explore the WWW, Locate information using search engines, Use FrontPage to create web sites, Use E-mail, Video and communication tools. 8. Linux Server Engineering ?]Linux ???????A???^ Hardware and Installation (x86 Architecture), Configuration and Administration, Alternate Installation Methods, Kernel Services and Configuration, TCP/IP Networking, Samba File Server Configuration, Apache Web Server Configuration, NFS Network File Service Configuration, X Window System, User and Host Security, Routers & Firewalls Configuration. 2 ?????}?o?????z???N?????u?{?v?M?~???????{ Professional Diploma in Web Site Development & Management Support Engineer ?????{?????b???????????q?????{???q?????????z?u?@???H?h?A?????M?~?????????????|?A?????????????p?U?G 1. Operating System ?]?q?????@?t???^?? What is an Operating System, Various parts of an Operating System, What is a Process, Operating System Load, File Management, Software Tools, Basic Features of Graphical Interfaces, Windows Objects and Components. 2. Windows 95/98 and MS-DOS Operating System ?]?????E?????E?K?????????@?t???^?? Why Windows 95/98, Basic Features, Starting Up, Using Applications, Managing Files and Folders, Managing the Desktop. 3. Introduction to Networking ?]?q???????^?? Network Concepts Components, Adapters, Wiring Guide, ELA TIA-568 Standard, Twisted Pair, Coaxial, Fiber, OSI Model, Network Segments, Spanning Tree Algorithm, Repeaters, Bridges, Routers, Hubs, Ethernet Switches, Virtual Networking Network Topology Bus, Bus-Physical Layout, Ethernet 802.3-CSMA/CD, 10Base2-Ethernet, 10Base5-Ethernet, 10BaseT-Ethernet, Bus-Physical Cable Limits, Ring, Ring-Physical Layout, IEEE 802.5 Token Ring, Ring-Physical Cable Limits, Star, FDDI, Logical vs Physical. Connecting Computers Peer to Peer, Workgroups, Workgroup Resources, Belonging to a Workgroup, Sharing Resources, Accessing Resources, Novell File and Print Services, Domains, User Accounts, Computer Accounts, Groups, Domain Models, Single Domain Model, Trust Relationships, Single Master Domain Model, Complete Trust Domain Model. Troubleshooting Cable Testing, General Troubleshooting Principles, Hardware Diagnostics, Using a TDR, Using a multi-meter. 4. Windows 2000 Server/NT Server 4.0 ?]???????????A???????????????D???^?? Operating Systems, Windows NT Services, Workgroups and Domains, Domain Name System, Active Directory, Administering Active Directory, Security and Permissions, Supporting Users, Managing S/W Applications, Managing Printers, System Recovery. 5. Introduction to Internet and Web Pages Development?]???p?????????????}?o?^?? Understand basic Internet concepts and terminology, Use a browser to explore the WWW, Locate information using search engines, Use FrontPage to create web sites, Use E-mail, Video and communication tools. 6. Internet Management?]???p?????z?^ Introduction to Internet Management, Networks Components, Network Topology and Cabling, Security, Management, Auditing, Intranets, Extranets, WAN's, Managing Users, Security of data, Clistering, UPS, Backup, Virus, Capacity Planning, Asset Management, Managing Web Sites, Log Files, Tracking Users. 7. Web Sites Development and Programming using JAVA Script ?]JAVA Script ?????}?o???{???s?g?^ What is JavaScript, HTML-Document, Frames Programming, Status bar and Timeouts Programming, Predefined Objects, Forms Programming, Image Object. _____________________________________________________________ This message posted with trial version of Express News Poster From ee_fhw at stu.ust.hk Sat Jun 30 12:33:25 2001 From: ee_fhw at stu.ust.hk (Calvin Fong) Date: Sun, 01 Jul 2001 00:33:25 +0800 Subject: Can I list the functions inside a module Message-ID: <3B3DFF55.2030701@stu.ust.hk> Greetings, I'm running Piggy 0.7 on my palm m100. Piggy is a python interperter for palm OS. As there is some platform specific modules for it, I want to know what function do they contain. Please, can anyone teach me how to show the function inside a modules. By the way, in case you have the passion to help me. Can you please send the solution to my email, because I don't have a very good internet connection for reading news Yours Calvin The Matrix is out there From dsh8290 at rit.edu Tue Jun 5 16:11:57 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 5 Jun 2001 16:11:57 -0400 Subject: How do I return binary data from a python CGI called from CGIHTTPServer? In-Reply-To: ; from mwright@pro-ns.net on Tue, Jun 05, 2001 at 12:30:58PM -0700 References: <9f96kb01mq8@enews1.newsguy.com> Message-ID: <20010605161157.A14062@harmony.cs.rit.edu> On Tue, Jun 05, 2001 at 12:30:58PM -0700, Mark Wright wrote: | "Alex Martelli" wrote in message news:<9f96kb01mq8 at enews1.newsguy.com>... | > "Mark Wright" wrote in message | > news:f9ff3f62.0106011427.6243e5e9 at posting.google.com... | > ... | > > But my original problem/question remains: how does a CGI program | > > return binary data on windows? Is it even possible? The problem is | > | > python.exe must be run with option -u, to have binary standard input | > and output streams, rather than text ones as it has by default. | | This works correctly for 0x0a, but it still gets upset about 0x1a - | a.k.a. ctrl-Z, a.k.a. end of file. If there's a ctrl-z in the output | of my CGI script CGIHTTPServer truncates the data. When I check 'man ascii' there is no EOF character. End-of-file is a condition, not a character, that is then simulated with a character when the input is a terminal because terminals have an "endless" flow of data. In MS-DOS terminals ctrl-z is used to indicate that you want to close the input stream (EOF). On Unix terminals it is ctrl-d instead. I think that the problem must be the sub-process thinks it is writing to a tty rather than a regular file, and thus is closing the output when you try and write ctrl-z. How is the sub-process started? What is the command for the sub-process? I don't know the details of Win32 process forking, but if you are using a *nix system you will have to change 'python' to 'python -u' when you exec in the child. (Or just adjust the string passed to popen) HTH, -D From volucris at hotmail.com Sat Jun 23 04:57:04 2001 From: volucris at hotmail.com (Volucris) Date: Sat, 23 Jun 2001 03:57:04 -0500 Subject: ConfigParser - ParsingError - escaping characters - evil colons Message-ID: <3b345a02$0$322$6e49188b@news.goldengate.net> I'm using ConfigParser and using filenames as keys. The problem being that the parser misinterprets the colons when reading the keys. I escaped the colons with dollar signs, but I'm still having problems. This is the raised exception: ParsingError: File contains parsing errors: Sipz.gdf [line 2]: 'c$\\sem\\test.txt = c$\\sem\\test.txt\n' [line 3]: 'c$\\sem\\bad.file = c$\\sem\\bad.file\n' These are the only two lines with full file paths in them, so I'm pretty sure that's the problem. Does anyone know what can be done with those evil colons? -- Volucris (a) hotmail.com "Eu n?o falo uma ?nica palavra do portugu?s." From arturs at iidea.pl Sun Jun 10 07:21:09 2001 From: arturs at iidea.pl (Artur Skura) Date: 10 Jun 2001 11:21:09 GMT Subject: Global in multiple files Message-ID: I'm not a fan of OO but I decided to give it a try. After all, Python makes it elegant. So I wrote a program usuing classes, methods etc. All nice. Then it grew up and I decided to split it in several files - one class into each class as Guido asked us to do. And then, I came across my first problem: I had had a global variable (just one!) and it wouldn't work anymore. At all. Any 'global' declarations wouldn't help, and without it I'm lost. So, I thought I might be smarter than it. I would pass this variable to where I need it, but... it stil obstinately refuses to work. But then, my ex-global is a list of instances of a class, and methods in instances of another class won't accept it as an argument. So, any ideas how I should cope with that and be able to use my global variable in different clases in different files? Regards, Artur -- http://www.wolneprogramy.org "Jakos nie kusi mnie perspektywa zostania wsiowym glupkiem znajacym sie tylko na komputerach i zarabiajacym mnostwo kasy" -- lcamtuf From njm at rectec.net Thu Jun 21 11:09:00 2001 From: njm at rectec.net (NJM) Date: Thu, 21 Jun 2001 10:09:00 -0500 Subject: critic this please Message-ID: I've just wrote this small program that calculates the length of a rafter for you(I'm a carpenter), but I didn't write it "properly". I can't seem to wrap my head around using classes. Does anyone have any input. import Tkinter def fig5(): a = float(Tkinter.Entry.get(feet)) b = float(Tkinter.Entry.get(inch)) Tkinter.Entry.delete(answer, 0, 20) Tkinter.Entry.insert(answer, 0, (b/12 + a)*13) def fig6(): a = float(Tkinter.Entry.get(feet)) b = float(Tkinter.Entry.get(inch)) Tkinter.Entry.delete(answer, 0, 20) Tkinter.Entry.insert(answer, 0, (b/12 + a)*13.42) def fig7(): a = float(Tkinter.Entry.get(feet)) b = float(Tkinter.Entry.get(inch)) Tkinter.Entry.delete(answer, 0, 20) Tkinter.Entry.insert(answer, 0, (b/12 + a)*13.89) def fig8(): a = float(Tkinter.Entry.get(feet)) b = float(Tkinter.Entry.get(inch)) Tkinter.Entry.delete(answer, 0, 20) Tkinter.Entry.insert(answer, 0, (b/12 + a)*14.42) def fig9(): a = float(Tkinter.Entry.get(feet)) b = float(Tkinter.Entry.get(inch)) Tkinter.Entry.delete(answer, 0, 20) Tkinter.Entry.insert(answer, 0, (b/12 + a)*15) def fig10(): a = float(Tkinter.Entry.get(feet)) b = float(Tkinter.Entry.get(inch)) Tkinter.Entry.delete(answer, 0, 20) Tkinter.Entry.insert(answer, 0, (b/12 + a)*15.62) def fig11(): a = float(Tkinter.Entry.get(feet)) b = float(Tkinter.Entry.get(inch)) Tkinter.Entry.delete(answer, 0, 20) Tkinter.Entry.insert(answer, 0, (b/12 + a)*16.28) def fig12(): a = float(Tkinter.Entry.get(feet)) b = float(Tkinter.Entry.get(inch)) Tkinter.Entry.delete(answer, 0, 20) Tkinter.Entry.insert(answer, 0, (b/12 + a)*16.97) root=Tkinter.Tk(className="/Rafter Lengths") frame=Tkinter.Frame(root, relief=Tkinter.RIDGE, borderwidth=2) frame.pack() label=Tkinter.Label(frame, text="This is a program that will calculate the rafter lengths for you") label.pack() frame2=Tkinter.Frame(root, borderwidth=0) frame2.pack() button=Tkinter.Button(frame2, text="'5-12'", command=fig5) button.pack(side=Tkinter.LEFT) button2=Tkinter.Button(frame2, text="'6-12'", command=fig6) button2.pack(side=Tkinter.LEFT) button3=Tkinter.Button(frame2, text="'7-12'", command=fig7) button3.pack(side=Tkinter.LEFT) button4=Tkinter.Button(frame2, text="'8-12'", command=fig8) button4.pack(side=Tkinter.LEFT) button5=Tkinter.Button(frame2, text="'9-12'", command=fig9) button5.pack(side=Tkinter.LEFT) button6=Tkinter.Button(frame2, text="'10-12'", command=fig10) button6.pack(side=Tkinter.LEFT) button7=Tkinter.Button(frame2, text="'11-12'", command=fig11) button7.pack(side=Tkinter.LEFT) button8=Tkinter.Button(frame2, text="'12-12'", command=fig12) button8.pack(side=Tkinter.LEFT) button9=Tkinter.Button(frame2, text="Quit", command=root.quit) button9.pack(side=Tkinter.LEFT) frame3=Tkinter.Frame(root, borderwidth=5) frame3.pack() labe=Tkinter.Label(frame3, text="Rafter Run to be calculated") labe.pack(side=Tkinter.LEFT) space=Tkinter.Label(frame3, width=5) space.pack(side=Tkinter.LEFT) label2=Tkinter.Label(frame3, text="Feet") label2.pack(side=Tkinter.LEFT) feet=Tkinter.Entry(frame3, width=5) feet.pack(side=Tkinter.LEFT) label3=Tkinter.Label(frame3, text="Inches", width=5) label3.pack(side=Tkinter.LEFT) inch=Tkinter.Entry(frame3, width=5) inch.pack(side=Tkinter.LEFT) frame4=Tkinter.Frame(root, relief=Tkinter.RIDGE, borderwidth=2) frame4.pack() label4=Tkinter.Label(frame4, text="Rafter Length in Inches") label4.pack(side=Tkinter.LEFT) answer=Tkinter.Entry(frame4) answer.pack(side=Tkinter.LEFT) frame5=Tkinter.Frame(root) frame5.pack() label5=Tkinter.Label(frame5, text="This length does not allow for \n the thickness of the ridge.") label5.pack() root.mainloop() From tim.one at home.com Sat Jun 9 23:14:55 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 9 Jun 2001 23:14:55 -0400 Subject: floating point in 2.0 In-Reply-To: <9fr0bv$la5$1@agate.berkeley.edu> Message-ID: [Tim] >> Ack -- if you folks haven't learned anything else from the 16 >> years of half-baked 754 support so far, believe me when I tell you >> that when it comes to f.p., most vendors see "strongly recommended" >> and think "OK, we can skip this one -- next.". [Edward Jason Riedy] > Hell, they do that if it's required. HW is key, because without near-universal HW support for a thing that thing will never become widely accepted. HW vendors used to punt on denorms because of the expense, but despite the expense everyone plays along with denorms now, and not because of user demand but simply because it's required. Very few play along with double extended, simply because it's not required. Getting language support is a different battle (or endless sequence of decade-long battles <0.5 wink>). > One of the good-and-bad points of 754 is that it's a _system_ standard. > It's good in that it can't be undercut by some portion of the system. > It's bad because each part simply points to the other parts for > compliance. > > For example, 754 requires single precision if double precision > is supported, but a certain relevant language doesn't provide > it. (Well, ok, you can use Numpy with a one-element array.) Python has no 754 story -- it doesn't try. This is a reflection of that std C classic has no 754 story, and C99's 754 story isn't implemented yet (and sorry to say I'm not sure it ever will be -- there too it's an optional thing). Without reliable semantics in the implementation language, it takes a battalion of platform experts to "fake it" via #ifdef tricks instead; there aren't enough platform experts to go around, and to the extent that users have been motivated enough to contribute #ifdef'ed f.p. code to Python, we ended up with the fpectl module (whose purpose is to fight 754 semantics by raising exceptions instead of returning NaNs and Infs). > ... > We also have to consider how we're getting this through the > IEEE process. If we come out and say C99 ain't 754 (it mandates > 6 digit output by default), well, I think some people will be > upset. You can be more creative than that <0.9 wink>. >> Vendors don't compete on mere "quality of implementation" f.p issues >> because their customers overwhelmingly can't tell the difference so >> don't care. > That's not entirely true. Consider IBM. They added fused > multipy-accumulate (being added to 754) and a ton of diagnostics > that are not required. It wasn't just out of the goodness of > their hearts. It certainly wasn't. Fusing the mul and add HW wasn't even suggested by 754, it was something they did to reduce chip real estate, and because they had clear ways in mind to speed math libraries by exploiting the resulting ability to get at the low-order 53-bits of f.p. products. Vendors do compete on chip cost and math library speed, and this was a brilliant way to improve both. > Similarly, Sun has a host of easy-to-use exception handling > libraries. So far, I'm the only confirmed user outside Sun. The > libraries aren't going away because the internal support folks use > them to diagnose client problems. Sun is an exception, and I'd guess more due to David Hough's influence and persistence than to anything else -- and I expect you just confirmed my impression of how much this is driven by user demand . >> That's why you have near-universal support for denorms and directed >> rounding modes today, [...] > Denorms, yes, but who supports directed rounding modes? Currently > only C99 is the only major language to give reasonable (arguable) > access to them. System standard, not hardware standard. Virtually all HW FPUs support them, and because they're required. Without that C99 wouldn't have even considered it (part of X3J11's mandate is not to require things that can't be done w/ reasonable efficiency, so w/o near-universal HW support already in place, they would have punted on this too). > Oh, and actually, _no one_ supports denorms as intended. There's > a clause (don't have it handy) that can be read a few different > ways. The author intended one reading, but all implementors took > another. ;) And it looks like there's actually a bug in one > reading where you can have an inexact answer without an inexact > flag. I seem to have lost my notes on it, which is rather upsetting. > Denorms will see some simplification as a result of all this; we're > not sure what yet. Bingo: They implement exactly what's written (to the best of their ability to read it), because it's required. Even if it doesn't make sense, even if nobody asks for it, just because it's required. Tossing "recommended" out the window is the best tool a std has. > ... > All decimal->binary conversions are correctly rounded. No matter how many digits are in the decimal string? For example, "0.5" + "0" * 1000000 + "1" In the +inf rounding mode, stop anywhere short of the full million and four digits and you get a wrong answer. This kind of thing isn't worth it to library writers, so go *too* far off the deep end and the standard will be ignored in favor of the old one. You said you're introducing a quad format, and I assume that's "the usual" 15-bit exponent + 113-bit mantissa one, so stop at required correct rounding to and from no more than 36 decimal digits, and everyone will be happy (this can be done with code much simpler than Gay's, and also without bigint arithmetic). > ... > Binary to decimal is constrained so that binary -> decimal -> binary > produces the same number if both binary numbers are in the same > precision. Users want that, but IIRC 754 already requires it. > Dealing with NaNs and infinities is the real problem. I want to > avoid specifying a textual representation to avoid the character > encoding mess. We'll see. C99 didn't back down from this, so I expect it's safe to leave this up to other stds (e.g., Fortran and C spellings may differ, but that's on their heads then -- more, each language has its own way of dealing with character encoding issues, and *can't* bend to anyone else's view). > ... > Python's default really should be single precision with at least > double precision for all intermediates. I expect there's no chance of single default, or of using more than double for intermediates, the latter simply because C doesn't support it x-platform. WRT single default, it doesn't have enough precision to avoid gross surprises -- newbies aren't forecasting the weather with one-digit inputs, they're calculating their retirement benefits based on 20% compound growth for 50 years . Seriously, single carries less precision than a one-dollar hand calculator, and the latter are the source of newbies' expectations. Single is a storage-efficiency gimmick for big problems with low-precision data. > ... > A widest-feasible evaluation scheme could get rid of the whole > right-method v. left-method v. coerce nonsense, too, "Mumber-like types" include things like Dates and Times in Python; there is no widest numeric type, and the set of numeric types isn't even known at compile-time (users can add new ones on the fly). Even restricted to floating types, at least two Python GMP wrappers exist now, at least one of which exposes GMP's unbounded (but dynamically specified) precision binary fp type. "Widest feasible" is something Python simply can't know -- that's a strategy from the world of statically typed languages, and it doesn't carry over cleanly. From romain.guy at jext.org Wed Jun 20 14:49:38 2001 From: romain.guy at jext.org (Romain Guy) Date: Wed, 20 Jun 2001 20:49:38 +0200 Subject: Which IDE ? References: Message-ID: <9gqr39$lo6$1@wanadoo.fr> I offer my Java code editor: Jext. Is is open source (GPL) and offers an embedded Python engine: Jython. You can run script, or exec them straight from the editor. Jext supports colorization of code, auto indentation and brings a class browser. Many parts of Jext are written in Python. See www.jext.org/dev.html -- Romain "Java Swinguer !" Guy romain.guy at jext.org www.jext.org "Now, don't you worry. The saucers are up there. The graveyard is out there. But I'll be locked up safely in there." - Paula Trent, Plan 9 From Outer Space "phil hunt" a ?crit dans le message news: slrn9iv12r.45t.philh at comuno.freeserve.co.uk... > On Mon, 18 Jun 2001 22:57:13 GMT, VanPopering wrote: > >Which IDE would you recommend for someone *just starting out* with Python? > > > >-I'm not a professional programmer but Im interested in learning Python > >-I want to use opensource whenever possible > >-For now I'm just here for the basics; some scripting etc. > > What OS are you using? I'm using Linux and I just use my favourite > text editor and the bash prompt. This is simple to use, because running > the program is just a matter of putting the mouse over the bash window > (making it active), then pressing up-arrow (bring up the last command, > likely to be ``python myprogram.py''), and [return] runs it. > > >I'd LOVE to use idle since its part of it and free, but I have heard that it freezes upand > >has other problems...is this really a problem that it happens a lot? Are there things I can > >do to avoid this - does it happen with larger more complex programs only? If it froze while > >running the script and that was the only potential problem, then I'd just save it first... > > I've never used IDLE or any other Python IDE so I couldn't say. My > system is the simplest, and therefore likely to be the most > bug-free way of doing it. > > > I am wondering if these were copmplaints by professional programmers who > >needed and expected more... > > I think professional programmers often prefer simple tools (i.e. > text editor and command line). > > -- > ## Philip Hunt ## > ## philh at comuno.freeserve.co.uk ## > > > From new_name at mit.edu Sat Jun 30 11:56:56 2001 From: new_name at mit.edu (Alex) Date: 30 Jun 2001 11:56:56 -0400 Subject: [TO]What's the big deal with EJB? [Re: PEP scepticism] References: <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> <3d8zib16g7.fsf@ute.cnri.reston.va.us> Message-ID: > Buggered if I know. Perhaps they provide a frictionless method for > transferring a business's money to consultants. Yeah, that's what everyone who's used them tells me, but it's hard to believe, given their ubiquity. :) Alex. From johnroth at ameritech.net Thu Jun 7 09:12:38 2001 From: johnroth at ameritech.net (John Roth) Date: Thu, 7 Jun 2001 06:12:38 -0700 Subject: WHY is python slow? References: Message-ID: "Steven Haryanto" wrote in message news:mailman.991900751.7603.python-list at python.org... > Although it is generally accepted that Python is slower than > Java/Perl/Ruby, a layman like me would be curious to know why > exactly this is so. In other words, why is the implementation > of a language like Ruby (which is on par with Python in terms > of 'everything is an object', strong reflection, dynamic > nature). > > My first guess would be the ubiquitous use of dictionaries? > > Steve > http://stevne.haryan.to/ I think this requires a slightly more thoughtful answer than the ones that have been given so far (at least, the ones that have propagated to my news server.) 1. Java is a strongly typed language that has been compared favorably to C++. As such, it has inherent advantages with respect to runtime storage allocation (always the big, and I mean really big, time consumer in any language implementation) and code generation. In addition, as one of the other responders said, a lot of money got thrown at it, and is still being thrown at it, to improve performance. 2. As far as Perl goes, Perl's code generation model is very different. Python generates byte codes, which, as you would expect, are single bytes. Perl generates relatively large structures where the execution sequence is explicitly handled by pointers from one code block to the next (somewhat similar to the very ancient IBM 650.) There are other very significant differences. Perl's function call syntax and semantics are very primative: there is no conception of either default or keyword arguements, so it has inherently less overhead in function calls. Whether this does anything favorable in terms of execution time is beyond me. Technically, it should as it reduced interpreter overhead - there are fewer iterations of the interpreter main loop for a given amount of functionality. 3. As far as Ruby goes, I'm going to have to confess total ignorance about how it handles things. 4. Any statement I made (at this point) about the major performance bottleneck in Python would be a guess. However, if I were to guess, I would look at storage allocation overall. Dynamic storage allocation and garbage collection have always been the Achilles heel of any object oriented implementation - that's why C++ allows you to specify your own storage allocator. Hopefully, this gives you something to chew on. John H. Roth Jr. > > From bbollenbach at homenospam.com Sat Jun 30 11:26:28 2001 From: bbollenbach at homenospam.com (Brad Bollenbach) Date: Sat, 30 Jun 2001 15:26:28 GMT Subject: Discussions and developing References: Message-ID: Though I haven't really followed the PEP discussions on c.l.p, realize that the development of any large software project involves spending most of one's time figuring out: a.) What the problem /is/ that you're trying to solve, making sure that you're solving the right problem and not, in fact, missing a potentially deeper issue. b.) An efficient, maintainable, solid and hopefully "correct" solution to the problem. If someone truly believes they have a strong argument either for, or against a PEP, they are being equally as productive in voicing that to the core developers as they would be hacking out their own programs. OTOH, the unproductive posts are those that continually ask things like: 1.) "Can Python be compiled?" (You mean, you didn't realize that an FAQ would probably answer this?) 2.) "What's the best GUI development environment for Python?" (The best answer you could possibly get would be subjective and again, this is obviously FAQ'ish) 3.) "Python vs. XYZ -- What should I chooose?" (Remember...you're asking that q to a /Python/ newsgroups, what do you THINK you should choose?) 4.) "Why use whitespace?" (Why use $'s, @'s, and %'s? Why use {}'s? Why use ;'s? Why not force functions to have prototypes? Why is the default pass by reference/value? Why is assignment a statement? Why doesn't VB have closures? Why use "."/"+" for string concatenation? Why didn't you read the FAQ before you asked?) 5.) etc. The "average" Python hacker is supposedly smarter than the "average" Perl/Tcl/VB/Delphi/Powerbuilder/ programmer. Yet I feel every time one of those threads starts (as in, 2-3 times/day) we're spinning our wheels. The more I read this newsgroup, the more I question the almost overly newbie-friendly attitude it takes. Worry about fixing those types of problems first, not about the PEP discussions. "Roman Suzi" wrote in message news:mailman.993850065.18441.python-list at python.org... > Hello, > > you, like myself, read (and write) to this mail-list/usenet group devoted > to our beloved Python. > > We generate several megabytes per month. > > Python code (src) is 15-20 Mb. > > So, we could type one Python per 2 months. (Well, if we count quoting, > probably in 6 months, but still impressive figure). > > Just why reacting to PEPs and accusations/opinions in newsgroup is more > attractive than writing good piece of code for library, for some > interesting Open Source project? (Am I alone or others also experience > this temptation?) > > Lets imagine that 1/3 of the letters to c.l.p is converted to useful > Python code. But no! It's far more interesting to react to yet another > PEP! > > And this happens because reacting/disputing/flaming/... is a (small) fight > between human beings and not between human being and dumb machine which > need to be coded. > > May be, with time some kind of subject-against-subject programming > technique will be invented, I dunno, and disputes will create not > only tryth but quality code. > > I do not know how to convert my recent c.l.p. addiction into something > useful for all. (if I only new how to be productive after full-time > work...) > > So, I personally decided to shut up and not to participate in prolonged > PEP discussions where no special protest must be expressed. This will > be better for everyone, including myself. > > Lets silence for 1 day in memory of Jim Ellis, one of the Usenet > creators, who died 28.6.2001. > > Sincerely yours, Roman Suzi > -- > _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ > _/ Friday, June 29, 2001 _/ Powered by Linux RedHat 6.2 _/ > _/ "I failed attitude in school." _/ > > > From bsass at freenet.edmonton.ab.ca Mon Jun 4 15:33:46 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Mon, 4 Jun 2001 13:33:46 -0600 (MDT) Subject: random In-Reply-To: <9fflob32q4r@enews2.newsguy.com> Message-ID: On Mon, 4 Jun 2001, Alex Martelli wrote: > > A: (P implies (not D)) > > "Given a powerful army, I could not defeat Napolean" > > > > B: (not (P implies D)) > > "Having a powerful army would not ensure that I could..." <...> > > The difference is that statement A is true if P is false, Nope. You can not say anything if P is false. If you know D is one thing or the other you can transpose (Q->R == ~R->~Q) the relationship and deduce something of P. > > whereas statement B can only be true if P is true. ditto > > Therefore, statement B implies that P is false. Try this instead... Q implies R == not Q or R not (Q or R) == not Q and not R not not Q == Q therefore B says... not (P implies D) == not (not P or D) == P and not D > I think I'm getting confused. From the truth table above, > AND for the immediately preceding statement, I would > deduce the _opposite_ conclusion than yours, i.e., "B > implies that P is _true_". How do you get the "implies > that P is _false_" instead? A: P->~D == ~PvD == P&~D B: P&~D A and B say the same thing, namely... P if, an only if, not D i.e., P <-> not D or, less succinctly, P implies not D and not D implies P So, neither statement implies anything about the other. All you can deduce is that it takes a powerful army to defeat Napolean. - Bruce From roedy at mindprod.com Mon Jun 4 18:41:08 2001 From: roedy at mindprod.com (Roedy Green) Date: Mon, 04 Jun 2001 22:41:08 GMT Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> Message-ID: <4f3ohtkoubdbfj0rk959unhe4thrukf3hh@4ax.com> On Sat, 2 Jun 2001 18:30:47 -0400, "Bart Kowalski" wrote or quoted : > embedded processors (watches, cell-phones, calculators, >etc) Most of the dramatic hardware evolution is in GAME machines. There backward compatibility is not as important. For more detail, please look up the key words mentioned in this post in the Java Glossary at: http://mindprod.com/gloss.html If you don't see what you were looking for, complain! or send your contribution for the glossary. -- Roedy Green, Canadian Mind Products Custom computer programming since 1963. Ready to take on new work. From sill at optonline.net Thu Jun 7 14:27:55 2001 From: sill at optonline.net (Rainy) Date: Thu, 07 Jun 2001 18:27:55 GMT Subject: Problems with Vaults of Parnassus References: <1108_991869141@ns.seowon.ac.kr> Message-ID: On Wed, 06 Jun 2001 23:12:21 GMT, Wolfgang Lipp wrote: > > readers, > > I am having a few problems with the vaults of parnassus > recently. the vaults are undisputedly *the* one-stop station > whenever you look for a python module. however, there > are three problems i can see: > > the current categorization is somehow less than > satisfying. i do not want to delve into an analysis > here; if nobody feels this way, ignore the point. > if someone agrees, perhaps this can be made > more concrete. > > more seriously, the search engine does not work > correctly. i have experienced this several times, > and i am sure it is not a mistake i make, it is a > malfunction. please go try for yourselves: on > http://www.vex.net/parnassus/apyllo.py/751771926.353274583 > you'll find jim fulton's extension classes (with > a sadly broken link, but that's more of dc's > problem). the author's name is in the field > titled 'owner'. now go to the search form below > and try to find 'jim', 'fulton', 'jim fulton', lowercase, > uppercase. restrict the search to 'any text', 'owners', > do what you will -- "No Parnassus records matching > your search criteria were found." is the sole answer. > then, try 'extensionclass' -- same, no results. only > thing that does yield results is 'extension class' (13 > records) and 'extension class' (87 records). it must > be admitted that 'extensionclass' is not in the text > of the page, but it's in the url. be that as it may, > the name of the owner does appear and is not > found. > > next, you say ok, those extensionclasses must be > somewhere, so you follow the download link to > fetch > http://www.vex.net/parnassus/download/Parnassus-Condensed-by-Category.html > which is sadly way behind time, and there, indeed! > you find a lot of hits for 'extension' (using the browser's > find-on-page function) plus one for 'extensionclass' (this > time, the url is, of course, found because it is included in > the listing). however, names of owners/authers do *not* > appear in the listing. > > in all, if i was asked 'please find out whether a guy named jim > fulton, who works for digital creations, has made available > a module called extensionclass', and i go searching, i sure > would have to answer in the negative, which is not correct. > obviously, we have a few problems that intertwine here, > and some of them are not within the vault's responsibility > (although it may be hard to communicate to executives > why links are not checked for validity and listings are not > updated nightly). > > does anyone have similar experiences? where is the > problem? > > > -wolf > > In addition, submissions and updates (reportedly) take up to more than a week to get posted. -- Jupiter and Saturn Oberon Miranda And Titania Neptune Titan Stars can frighten - Syd From jicondon at us.ibm.com Thu Jun 7 14:00:29 2001 From: jicondon at us.ibm.com (dW) Date: 7 Jun 2001 11:00:29 -0700 Subject: fyi - Two article on XML and Python. Message-ID: Revisiting XML tools for Python ---------------------------------- David Mertz looks at advances in XML tools for Python developers. http://www-106.ibm.com/developerworks/xml/library/l-pxml.html?open&l=912,t=grx,p=xpyth XML Matters #2 ---------------------------------- On the "Pythonic" treatment of XML documents as objects (II) http://www-106.ibm.com/developerworks/xml/library/xml-matters2/index.html?open&l=912,t=gr,p=xm2 From Glen.Mettler at home.com Sat Jun 9 19:28:51 2001 From: Glen.Mettler at home.com (Glen Mettler) Date: Sat, 09 Jun 2001 23:28:51 GMT Subject: New guy question Message-ID: I have a small script I entered from a Python book that works when I run it using F5. However, when I go to the console and enter python alook.py, I get an error message: >>> python alook.py SyntaxError: invalid syntax I am too new to this to know why. Glen From olafb+usenet at pvv.org Mon Jun 25 10:03:59 2001 From: olafb+usenet at pvv.org (Olaf Trygve Berglihn) Date: 25 Jun 2001 16:03:59 +0200 Subject: Scripts (running once) References: <3B37271F.759B0236@usa.net> <3B373C74.AA4284A4@snakefarm.org> Message-ID: Carsten Gaebler writes: > Olaf Trygve Berglihn wrote: > > [how to keep a program from running more than one instance simultaneously] > > > #!/usr/bin/env python > [...] > > if os.path.isfile(LOCKFILE): > > import sys > > sys.stdout.write("Already running myprog\n") > > sys.exit(1) > > else: > > fd = open(LOCKFILE, 'w') > > fd.close() > [...] > > This will not really work if the two processes are *started* at the same > time. I.e. process 1 calls isfile() which returns 0. Then the OS switches > to process 2 which also get a 0 from isfile(). You'll end up with two > processes running at the same time. > > Better really lock the file by calling fcntl.flock() right after open() > (blocking or nonblocking, whatever is suitable), or by storing the process > id in the lock file and checking if that process id is still hanging > around (e.g. via /proc on Unix). Good solution with fcntl.flock(), I forgot about race-conditions. Storing the PID does not really work since PIDs are recycled (on Linux PID is typically int). It is not highly likely that you will get the same PID on the same program, but it can happen. It is also wise to store the pid so that you can check for stale lock files on excecution of the program, i.e. if the PID in the lock file does not exist, then the lock file is stale and can be overwritten. Olaf -- Olaf Trygve Berglihn From new_name at mit.edu Tue Jun 12 18:08:44 2001 From: new_name at mit.edu (Alex) Date: 12 Jun 2001 18:08:44 -0400 Subject: Reference Counts & Extensions.. References: Message-ID: > You do have to! Oh, that's a pain. Thanks for correcting me. Alex. From rdsteph at earthlink.net Wed Jun 20 20:43:26 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Thu, 21 Jun 2001 00:43:26 GMT Subject: PythonCard mailing list References: <3b30f568.15994839@news.laplaza.org> Message-ID: <3B2FF40D.F4D66488@earthlink.net> I wonder if there is a way to contact the person who "owns" the existing SourceForge project called "PythonCard" and discussing with her/him whether she would consider opening up that project to a wider scope. There is no information on who the owner is that I know how to find, just an "empty" project. But it is such a cool name...... Mats Wichmann wrote: > On Wed, 20 Jun 2001 08:55:13 -0700, "Kevin Altis" > wrote: > > >My apologies, I forgot that Yahoo Groups (eGroups) apparently > >requires registration even to just read messages. At least one person > >has already brought this up here on comp.lang.python. > > > >If anyone has a suggestion for a forum where we can discuss, either > >your own listserv or a free listserv service where we can make > >individual messages and/or the archives available I would like to > >make the switch now rather than later. > > You could just go ahead and make a SourceForge project for this. That > gets you the ability to provide mailing lists, and saves you the > migration tasks should you decide to start coding. > > Bonus: the mailing list manager there is Mailman, a Python Project. > That means Barry will fix anything that goes wrong :-) (ahem) > > Mats Wichmann > > (Anti-spam stuff: to reply remove the "xyz" from the > address xyzmats at laplaza.org. Not that it helps much...) From pecora at anvil.nrl.navy.mil Fri Jun 8 08:21:32 2001 From: pecora at anvil.nrl.navy.mil (Louis M. Pecora) Date: Fri, 08 Jun 2001 12:21:32 GMT Subject: How do you develop in Python? References: <050620011516094693%pecora@anvil.nrl.navy.mil> <3B1FCFA5.BA4AF4A0@home.net> Message-ID: <080620010823418583%pecora@anvil.nrl.navy.mil> In article <3B1FCFA5.BA4AF4A0 at home.net>, Chris Barker wrote: > Michael Hudson wrote: > > This is exactly the same problem as you can get using PythonWin, and why > I desperately wish there was a way for the IDE to NOT share the same > interpreter as the code you are writing. Then you could just re-start > the second interpreter. > > Anyway, my solution is to use: > > import B > reload(B) > # and then, of required: > from B import * > > everywhere > > when I'm pretty confident that B is finished (maybe not untill I'm > giving the code to someone else) I get rid of all the reloads. It's a > little slower, but it makes sure I'm always using an up to date version > of all my modules that are under develoment. Chris, That I will try since it is a no-brainer -- something that workds best for me. > Just van Rossum wrote: > > > It's simple: if you modify B.py, _run_ B.py to refresh it (*). A.py will see > > the changes. It's hardly ever neccesary to quit the MacPython IDE. > > > > *) In other words: if B.py has already been imported, running it it will > > execute it in B's old namespace, effectively refreshing it for everybody > > to see. > > This is a classic, why didn't I think of that? solution. I think I will > still use my method for stuff I'm changing a lot, it is less likely that > I will forget to do the refresh. Just's solution works, but it has the problem that if you change B and C and D depend on B and are used in A, then C and D have to be run, too before you run A. I stumbled on that one. But it beats my stupid solution of quiting the IDE and restarting. Talk about doing it the hard way (see why I need a no-brainer? :-) ). I will try your reload/from technique. Thanks. From jared at difinium.com Wed Jun 20 14:25:50 2001 From: jared at difinium.com (Jared Lee Peterson) Date: Wed, 20 Jun 2001 11:25:50 -0700 Subject: Dynamically importing modules Message-ID: <3B30EAAE.1D8197BB@difinium.com> I have a quick question about importing modules. I would like to have a script that in sitting in a directory and in this directory I want to have sub directories that represent modules to that script. However I do not want this script to have any prior knowledge of what modules may exist. So I would like for the script to look at it current working directory and then try to load each module that does exist through the use of import. But I can not seem to figure out how to get import to work for me. Because I need to be able to loop through a list (os.listdir()) of the subdirectories/modules that the script has found and try to import them. Does anyone have any suggestions? Does this even make sense? thanks, Jared From emarkp at CSUA.Berkeley.EDU Sat Jun 2 17:28:45 2001 From: emarkp at CSUA.Berkeley.EDU (E. Mark Ping) Date: Sat, 2 Jun 2001 21:28:45 +0000 (UTC) Subject: Why isn't Python king of the hill? References: <9fb5fl$26kf$1@agate.berkeley.edu> Message-ID: <9fblqd$2f0u$1@agate.berkeley.edu> In article , Grant Edwards wrote: >On Sat, 2 Jun 2001 16:49:58 +0000 (UTC), E. Mark Ping > wrote: >>That's silly and just plain wrong. You should depend on >>understanding how FP works. And in this case, 1.0 + 2.0 == 3.0 >>every time on every platform that I've run into--I don't know that >>because I just happened to try it out, but rather I know how the FP >>works on those platforms and know that it is correct. > >So do I. But every time I've seen an application _depend_ on exact >representations, its caused problems. Perhaps the FP code you've >seen was better, but in my experience code that depends on exact >represention has caused problems. Ah, but your example was exact representation of *integers*, not just any value. >>You should definitely read Pete Becker's articles in the June, July >>and October 2000 issues of The C/C++ Users Journal. He explains why >>you're statement is insufficient and incorrect. For instance, two >>very large numbers might really be the same, but be off by a bit. > >Huh? They're the same, but they're not the same? Sorry I didn't state it very clearly. I meant that two values might have been arrived at by different computation paths and be different only because of limitations of FP. That is, had they not been limited by finite precision, they would be the same value. >>Checking the difference of the values will yield another large >>number, and a method like "IsCloseTo" will incorrectly fail. > >How can it fail? Either A is within X% of B or it isn't. What's the >problem? But your algorithm didn't specify %, rather you said: fabs((1.0 + 2.0) - 3.0) < [a small number] If it were percentage, you'd be adding a division operation too. That's getting to be a large amount of overhead. The point is to understand FP well enough to use it correctly in your particular code. Sometimes that may be exact representation, sometimes not. >>Really, floating point arithmetic has well-defined semantics; >>guessing and treating them as if they have random components is the >>lazy and error-prone way to use them. > >I'm not guessing. I know how IEEE floating point works and have >implimented various parts of it over the years. The applications >programmers I've dealt with would have been far, far better off if >they never depended on exact representation. The reason I said "guessing" was because you claimed that: >>>Of course it is not true. But if you pretend it is, you've got a >>>much better chance of producing working code. When your code should never have a "chance" of working. It should be correct and you should know why. Again, I realize that we've just about all knowingly taken chances in the past, but that's not the same as advocating it. -- Mark Ping emarkp at soda.CSUA.Berkeley.EDU From tjreedy at home.com Thu Jun 21 13:17:30 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 21 Jun 2001 17:17:30 GMT Subject: PEP 255: Simple Generators References: Message-ID: When I first read the PEP, I assumed that def'ed generators would somehow return the successive yielded values on successive calls (wrong). IE, yield would be like return but without tossing the in-process information (partly right, partly wrong). As I now understand it, putting 'yield' somewhere within a function body will *also* magically transform the function definition into syntactic sugar for an iteration factory function. IE def squares(n): for i in range(n): yield i*i will be an abbreviation for def squares(n): return make_iterator('squares', ''' for i in range(n): yield i*i ''') where make_iterator adds 'raise StopIteration' where appropriate. [Or even much more verbosely, it abbreviates (in this particular example) something like class squares: def __init__(self, n): self.i = 0 self.n = n def next(self): i = self.i if i < self.n: return i*i else raise StopIteration But note that simulating 'for' is slower and more error-prone.] The existing separation of function and code objects makes this magic behind-the-scenes swap neatly possible. Compile normally (with the addition of 'yield') up to the last step, but instead of attaching the compiled code object to the compiled function object, substitute a standard make_iterator code object that when called will attach the compiled code object to an instance of a standard iterator object as a next method. This *is* a bit mind-bending. I predict that at least some newcomers will react to it much the same way that even experienced Pythoneers react to metaclasses. Careful explanation will be necessary. Examples like that above might help. Question: am I correct in thinking that separating iterator-generation from iterator-first-use makes it possible to have multiple iterators from the same generator in simultaneous use, as in sq10 = squares(10) sq20 = squares(20) ... ? On def versus gen(erator) as the keyword: regardless of the word, the magic swap takes some thinking about. The bad of gen: it introduces another keyword, and one for a process that is identical to def up to the magic swap. The good of gen: it announces the swap right away. Alternative warning mechanism: a simple comment convention, as in def squares(n): # generator for squares from 0 to (n-1)**2 --or-- def squares(n): # make iterator for squares from 0 to (n-1)**2 On body lines having global effects: the proposed yield 'wart' is similar to the assignment-makes-local 'wart', as in i = 387 def nada: print i ... (many lines) i = 'haha' Lesson: function bodies are scanned globally to determine their final compilation and processing. Terry J. Reedy From robin at jessikat.fsnet.co.uk Wed Jun 6 05:08:16 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 6 Jun 2001 10:08:16 +0100 Subject: Dynamic class problem References: <9nie+IAgvTH7Ew4A@jessikat.fsnet.co.uk> Message-ID: In article , Fredrik Lundh writes yes I figured out that the try always excepted as Klass isn't visible in 2.0. My best guess for what I want is class WKlass(Klass): def __getattr__(self,name): try: return self.__class__.__bases__[0].__getattr__(self,name) except: return getattr(self._parent,name) ie I figure it safer to assume that the way to get to an instance's __bases__ is via its __class__ as the name WKlass will get re-used. The real intention here is to create a class that wraps an existing __getattr__ if that's present. If that fails or is absent use the attribute from the _parent (ie the default attribute holder). I think of it as chaining the __getattr__ methods. -- Robin Becker From dnew at san.rr.com Sun Jun 3 20:54:16 2001 From: dnew at san.rr.com (Darren New) Date: Mon, 04 Jun 2001 00:54:16 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3B183CFF.A90213BA@san.rr.com> <9fa54s0fkb@enews2.newsguy.com> <3B1A7FEB.E466824E@san.rr.com> <9fe5q302hbg@enews2.newsguy.com> Message-ID: <3B1ADC37.565AEA61@san.rr.com> Alex Martelli wrote: > > Yep. The fun thing about quantum physics is that *complete* information > > is available about the state of the generator, and you *still* don't > > Except it's not -- you can't be told position AND momentum > of the particles (either, but not both). But that's not the kind of information you get about the system. Understand that the problem is that you can't determine both momentum and position. The problem is that both don't exist at the same time. "Complete information about the system" is the probabilities that the particles are in certain states. Because the particles really aren't in any particular state, the "complete information" *is* the probabilities. That's 100% of the information. It's not that there's information there you can't get. The information just plain isn't there. Again, I can give you complete information on a fair die, and it doesn't give you any information that would allow you to predict which number comes up next. > The information isn't > (and presumably can't) be complete. No, the information *is* complete. It's just not sufficient to tell you what you want to know. That's the *reason* why it's random. > > No. The point I'm discussing is that an algorithm cannot generate > > randomness. > > Maybe it can't "generate" the randomness, but it can "unearth" > it if it's hidden in the underlying "deep truth of mathematics". > Which seems to be a way in which one can read C's thesis. If two people can each generate exactly the same sequence of bits, given a description of what to do to generate them, then the bits aren't random. > > No matter how much complexity you add to a mathematical > > formula, it's still 100% predictable if you know what the formula is. > > So the _amount_ of randomness is constrained by 'program > size'. Thus, it's finite for a finite-size program (program size > being an upper bound, and it being, it seems, impossible to > get a lower bound). Well, the way I'm using "random" means "predictable given complete information". If I can replicate what you do and get exactly the same results, then the results aren't random. I would imagine that's what JVN was talking about. > > This is untrue of physical random number generators. > > I.e., a physical RNG cannot be finitely described? Err, no. Your interspersing your own comments with mine. I said, no matter how complex it is, if you know a mathematical formula, the results of calculating its value are 100% predictable. (You may not be able to predict it without calculating the value, which is what C is talking about, but you can certainly predict what someone else will calculate.) This is untrue of a true (not pseudo) random number generator based on (say) quantum effects. I can build two RNGs that are identical 100%, and they'll generate different random numbers. > Dice that are massive enough may presumably be similarly > finitized -- give me the initial state (position & momentum) > accurately, and in principle I can apply classical mechanics > and compute the positions at rest. Except that quantum physics says this doesn't work. Sure, *if* the universe were Newtonian, then physical RNGs would be no better than algorithmic RNGs with lots of seed bits. But the universe isn't Newtonian. > Even if the dice are thus > predictable-in-principle, it doesn't mean they aren't a RNG -- > maybe not a 'perfect' one if you include the condition about > being given ALL information (or all AVAILABLE information > for a good-enough value of 'available':-). Again, you're missing the point of 'available'. It's not that you can't measure the value. It's that the value isn't there. That's the funky part of quantum physics. It's like, if you go to the sink and close your eyes and turn on one tap, you'd expect the water to be hot or cold. But in quantum physics, it's not. It's just luke warm. It's not that you don't *know* whether it's hot or cold. It's that the water doesn't behave like it's hot, and doesn't behave like it's cold, *unless* you stick a thermometer in it. > But that doesn't mean that suddenly card decks or dice > "aren't random" any more (or that they never were). For > all "finite-randomness generators", the interesting issue > becomes "how much randomness". They're random. They're physical systems. I don't know why you think they're not. What's not random is algorithms that take a seed value (or a key) and generate lots of hard-to-predict-without-the-seed numbers. > > In an algorithm, it's never going to be bigger than your seed. > > Not sure what you mean by "seed" in the general case of > any algorithm whatsoever. The "seed" is the part that's different the second time you run the algorithm. > Even assuming the algorithm > has to have an input and we must call the initial input > value 'seed', what can you predict if all I tell you is that > "the seed" is 32304823408349093? Nothing, it seems to > me, unless the information you receive also includes the > program that's going to much this "seed". That's not how you measure randomness. The way you measure randomness is to say "given as much output as I like, what's the probability that I can accurately predict the next output value." Hence, if you shuffle a deck of cards and deal out 51 of them, how random is the value of the last card? Answer: not at all. This is how "card counting" works at casinos, and why they shuffle the cards well before they're all used up. > So, why confuse > things by putting "seeds" into the picture? Let's just say > that amount of randomness (as measured in bits) can never > be greater than the size of the program -- it's easier to > account for any literal constants as part of the program's > size than vice versa, isn't it? Fine. Then you're counting the entire program as a "seed" for the computer it's running on. That's just another way to look at it. :-) Then the "seed" is the program and the "algorithm" is the microcode that's in the CPU. :-) > Well, Chaitin's approach boils > down to defining amount of randomness as _minimal_ > programsize to generate a sequence (which turns out to > be undecidable in general, if I understand him correctly: > any actual program that does the generation gives me an > upper bound on the randomness of its output, but in > general I have no way to prove a lower bound). But that's not the "randomness" that JVN was talking about. > > You don't get randomness from a deck of cards. You get randomness from > > *shuffling* a deck of cards. The randomness comes from not knowing > > exactly what the fingers were doing. > > Ah, from lack of information? The information is apparently > not-available because nobody bothered to notice it?-) > > So is lack of information randomness?-) No. > > If you shuffled the cards algorithmically (e.g., with a mechanical card > > shuffler that very reliably put them in the same order) then they > > wouldn't be random at all, *if* you knew exactly how the mechanical card > > shuffler worked. That's the equivalent of using an algorithm to generate > > pseudo-random numbers. > > And it turns out to be a good approximation of what happens when > a human being shuffles cards in practice -- he or she tends to give > a finite (and small) number of riffles that are rather predictable. Which is why cards are a *poor* source of randomness. > Saying that the resulting deck-order "isn't random at all if you > knew" again seems to consider randomness totally congruent to > lack of information. There are lots of meanings of the word "random". There are many ways for things to *not* be random. Knowing exactly the sequence of a deck of cards means the cards aren't in a random order, as far as you're concerned. On the other hand, with quantum physics, the lack of information is built into the system. There's no information there for you to discover if you just looked hard enough. Hence it's "truly random." > It isn't *perfectly* random, sure, but that's > a long way from saying it isn't random *at all*. Right. That means you have a greater-than-chance method for predicting the next card as you deal them out, but a less-than-perfect chance. On the other hand, if I know the program you're running, I have a perfect chance of predicting the next output from it, assuming your hardware correctly interprets the algorithm. > A shuffled deck of cards may be very far from your Platonic > ideal of "a physical RNG", but it's pretty physical, has been > used as a RNG for centuries, and (as any card-player can > attest) generates or unearths or whatever SOME amount of > randomness. Maybe those who shuffle card decks to get > randomness are "in a state of sin" (those who call that deck > "the Devil's Picture Book" would no doubt agree:-), but they > do get (finite amounts of) randomness, not 'none at all'. Again, I'm not sure why you think shuffling cards gives you no randomness. I don't think I ever said anything to imply this. > > > It seems more fruitful to me to consider the amount > > > of information, i.e., a quantitative assessment of randomness, > > > rather than claim that only if that amount is 'infinite' can > > > the word 'randomness' be properly used. > > > > It depends, again, on which meaning of "random" you want to use. For > > some folks, "unpredictable" and "random" are two different things. > > And "random" means instead...? Didn't you also define it as such? Errr, no. It's not the "amount of randomness" that's infinitely unpredictable. It's the size of the object being studied that is infinite. It's hard to talk about the randomness of a single finite string, because once you tell me what string you're talking about, it's not random any more. > I'm not particularly interested (in this thread) to understand JVN, > I _am_ interested in applying the word "randomness" to the > breaking of structure and *difficulty* of prediction that I can > study in finite systems, rather than have it reserved for some > kind of *impossibility* (infinite difficulty) of prediction. It's not "inifinite difficulty", but "infinite string". In other words, how random is the binary string "1001010010011100100"? How random is the binary string "0000000000000000000"? Such questions don't make any sense. > > > If you have COMPLETE information about the dice &c (taking > > > a HUGE number of bits, no doubt) you can predict their > > > trajectories, bounces (if allowed), rolls, AND final results. > > > > No. Quantum effects will screw that up. > > Aren't dice (by far) massive enough to avoid that? No. The die as a whole will not show quantum effects. The die as a whole is too big to ever expect it to disappear from one place and reappear at another. But every time it hits the table, it has a quantum interaction between the atoms in the die and atoms in the table. > > If you start with a pooltable with perfect spheres for poolballs, > > perfectly racked, you cannot sink all 15 balls with your eyes closed. > > The probability cloud for the location of the last ball will be larger > > than the pooltable. > > Interesting -- I can't refute this claim as I wouldn't know how > to go about it. Is this result independent of the masses and > diameters of the balls, temperature, &c, or does it specifically > hold for the actual average sizes/temperatures/&c as used in > pool? Unfortunately, pool is definitely not among my skills. I don't know. I wasn't the one that did the math. And it was a long time ago. If I recall correctly, it assumed normal poolballs perfectly manufactured. The trick is that since the balls are round, every little error is going to get magnified. > > > If you have complete information about the algorithm and > > > the relevant part of the state of the computer where it > > > runs, again you have predictability. > > > > And that's why VN said calling it "random" is sinful. > > Aha, I knew it would get to attaching sinfulness to the way one > uses words -- and, wouldn't you know it, exactly the word-use > I care about in the context of this thread: what's now being > directly attacked (by your interpretation of VN's words -- I do > not know how demonstrable this interpretation is) is the attempt > to measure the *amount* of randomness... the amount of > information that would minimally afford prediction about the > random phenomenon. If anything AT ALL predictable cannot > "by definition" be random AT ALL, then "amount of randomness" > becomes a meaningless, self-contradictory phrase. Which is > exactly what I think is unsupportable... Err, no. If you have complete information about the algorithm, including the seed, then the output of the algorithm is 100% predictable. That's kind of the definition of an algorithm. And I'd chance to say that anything that's 100% predictable is not "random" in any sense of the word at all. I'm not sure how you'd go about making a list of random predictable numbers. Now, if you *don't* tell me the algorithm, it's not the algorithm that's making the random numbers. It's you making up a random algorithm. But that's no more "random" than your age. The age you'll be five years from now is five years older than today. That I don't know how old you are today doesn't mean your age five years from now is "random". -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. This is top-quality raw fish, the Rolls-Rice of Sushi! From quinn at regurgitate.ugcs.caltech.edu Fri Jun 29 15:54:20 2001 From: quinn at regurgitate.ugcs.caltech.edu (Quinn Dunkan) Date: 29 Jun 2001 19:54:20 GMT Subject: Is this a true statement: Part II References: <9hiifr$sjs$1@taliesin.netcom.net.uk> Message-ID: On Fri, 29 Jun 2001 14:48:23 -0400, MDK wrote: >Anyway, of all the things that I'd learned from these readings the thing >that surprised me the most were the statements regarding C++. My impression >of C++ was that it was the end-all, be-all of languages and if you wanted to >write a serious program you wrote it in C++. However, I'd seen in the posts >at least once the word 'awful' to describe it. At least one person agreed >and no one rebelled. So here is my second question - and explain it in such >a way that I can explain it to my boss. You've lived a sheltered life, then :) >Why is C++ awful; what's wrong with it? Here's another hugely contentious flamewar-spawning question. See http://www.elj.com/cppcv3/ for a much more detailed (if not less biased) analysis than you are likely to get on usenet. From thomas at gatsoft.no Wed Jun 27 10:38:10 2001 From: thomas at gatsoft.no (Thomas Weholt) Date: Wed, 27 Jun 2001 14:38:10 GMT Subject: Python for Commercial Games? References: <9haoiv$jnv$1@mtc1.mtcnet.net> <3b39de57.103502578@news.iway.fr> Message-ID: "Emmanuel Astier" wrote in message news:3b39de57.103502578 at news.iway.fr... > On Tue, 26 Jun 2001 14:46:36 -0500, "Kevin Riggle" > wrote: > > >I *do* realize that I'm posting to comp.lang.python , so please humor me > >anyway... > > > >I am in process of designing a computer game; problem is, I want to at > >least have a snowball's chance in Hades of selling the game. My question: > >Would it be possible to write the dang thing in Python (PyWin), or is C/C++ > >the better option in the Windows-centric world of game development right > >now? Thanks in advance, > > > >Kevin > > > > > > > Most (ALL ?) commercial games that use Python only use it as a script > language. > Most of the real code ( display, 3D, Ia ) is made in C/C++ for > performance reasons. Python just use this code... > > It really depends on what your game looks like, but I don't think it > is really possible now to write a full real commercial game in python > without extend / embed it with C/C++. > > Then again; not all commercial games require the speed of C/C++. I mean, it's still possible to create great games that doesn't include display or 3D at all. ( I don't know if that's something I'd be playing, but still ... great games, content wise - possibly ) Thomas From aleaxit at yahoo.com Sat Jun 30 17:53:07 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 30 Jun 2001 23:53:07 +0200 Subject: newbie wants to eval() References: <3b3e3e81$0$88189$2c3e98f8@news.voyager.net> Message-ID: <9hlhkl02cu9@enews1.newsguy.com> "lynx" wrote in message news:3b3e3e81$0$88189$2c3e98f8 at news.voyager.net... > i want to iterate over a list of variable names, comparing each in turn > to a regexp match part, and if the comparison is equal, set the value of > the variable to the value given in another part of the same regexp > match; which seems most obviously done with eval(). If it so seems, appearances are deceptive. eval() evaluates an EXPRESSION, and variable binding and rebinding is normally done by assignment, which is a STATEMENT. In Python expressions and statements are separate concepts: an expression can always be used as a statement, but a statement cannot be used as an expression. You'd need to use the 'exec' statement (shudder), but fortunately you can easily do better than that, since...: > one little additional twist is that the variables i'm trying to set are > globals, defined outside the configuration-file-reading-function itself. > does this change some argument to the eval(), and if so, how? Global variables are really attributes of an object, the module object to be precise. Setting any object's attributes is most easily done via built-in function setattr(). So you need a reference to the object that's the module you want to affect. Assuming this is the module containing the function you're writing, simplest may be: import sys mymod = sys.modules[__name__] and now mymod is the reference you require. Now, if your variable x refers to a string that names the variable you want to set, and y refers to the value you want to bind your variable to, setattr(mymod, x, y) will do what you require. Alex From thomas at xs4all.net Fri Jun 29 20:21:31 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sat, 30 Jun 2001 02:21:31 +0200 Subject: Not enough Python library development [was PEP scepticism] In-Reply-To: <3B3D0B51.7F458525@ActiveState.com> References: <3dy9qalxii.fsf@ute.cnri.reston.va.us> <3B3D0B51.7F458525@ActiveState.com> Message-ID: <20010630022131.F8098@xs4all.nl> On Fri, Jun 29, 2001 at 04:12:17PM -0700, Paul Prescod wrote: > Consider this feature: > http://aspn.activestate.com/ASPN/Mail/Leaders/python-dev/ Aahh.. cute. Also scared me shitless; I couldn't believe I'm the 4th most spammy py-dev'er. And that's not so weird, because I'm not -- I'm just mail-address-monogamous, contrary to, apparently, most of python-dev :) I-always-suspected-that-Tim-bastard-of-polemailgamy-ly y'rs ;P -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From rnd at onego.ru Tue Jun 26 00:41:37 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 26 Jun 2001 08:41:37 +0400 (MSD) Subject: Please statement (Re: Is this a true statement?) In-Reply-To: <3B3807DD.B332F0C7@cosc.canterbury.ac.nz> Message-ID: On Tue, 26 Jun 2001, Greg Ewing wrote: >"Steven D. Majewski" wrote: >> >> ( And I DO wish more languages had adopted Intercal's "Please" >> statement -- it would make programs so much nicer to read! ) > >I can even think of a use for it in Python. Some >people feel that it would be useful to have some >sort of "directive" or "pragma" statement for >specifying compile-time options. > >Calling it "please" would be a nice way of >conveying that the implementation is free to >honour it or not, as is convenient. > >e.g. > > please: > call_del_methods_when_collecting_cycles > optimise_integer_variables > declare_generators_using_keyword("generator") # :-) > please, leave pragmas to other Python vendors Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, June 26, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "It is better to be brief than boring." _/ From qrczak at knm.org.pl Mon Jun 4 17:40:28 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 4 Jun 2001 21:40:28 GMT Subject: Why no 'elif' in try/except? References: <3B1A06EE.F484930A@snakefarm.org> <3B1A29DE.9876770D@accessforall.nl> <9fgiip$h48$1@neon.noos.net> Message-ID: Mon, 4 Jun 2001 15:36:35 -0400, D-Man pisze: > I think it is also related to Python's block structure. If it was > spelled "else if" in the same way C/C++/Java spell it, then your code > would have to look like > > if : > > else if : > > else if : 'else if' would mean exactly what 'elif' means today - it's still a special rule, but not an additional keyword. Currently a colon is always present after 'else', so there is no ambiguity. Double keywords are used anyway in other places, e.g. 'not in' and 'is not'. if : else if : else if : else if : else: -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From not.this at seebelow.org Wed Jun 27 23:22:10 2001 From: not.this at seebelow.org (Grant Griffin) Date: Wed, 27 Jun 2001 22:22:10 -0500 Subject: PEP 260: simplify xrange() References: <3B398BBE.A2D455C9@darwin.in-berlin.de> <9hclc1$qv5$1@panix2.panix.com> <3B3A08B5.3C142546@darwin.in-berlin.de> <3B3A1DC0.3583E9D8@ccvcorp.com> Message-ID: <3B3AA2E2.3536D36A@seebelow.org> Jeff Shannon wrote: > ... > To make a long story short, the discussion regarding FP boils down to the > fact that "1.0" cannot be exactly represented in FP. Eureka! Now I understand why the IEEE folks didn't bother to provide a bit for that! any-number-system-that-represents-zero-as-a-special-case-can't-be -all-good--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From winkler at abaqus-sn.com Tue Jun 19 11:57:54 2001 From: winkler at abaqus-sn.com (david winkler) Date: Tue, 19 Jun 2001 15:57:54 GMT Subject: paths: sleeping at the wheel Message-ID: <3B2F7682.D5C65F3@abaqus-sn.com> I have been using Python for a while and have just noticed that when accessing a script from the command line like this: "python scriptname.py", the path must be cwd or fully qualified. I have tried setting my system path without success. Is there a workaround to this limitation (or a clarification to my misunderstanding)? I already know how to avoid this type of situation by running the script like this: "scriptname". I also know how to access modules using PYTHONPATH. From bbollenbach at homenospam.com Sat Jun 30 15:02:49 2001 From: bbollenbach at homenospam.com (Brad Bollenbach) Date: Sat, 30 Jun 2001 19:02:49 GMT Subject: Discussions and developing References: Message-ID: "Eric Merritt" wrote in message news:mailman.993918166.28645.python-list at python.org... > Mr. Bollenbach > > your basic assumption here seems to be that python > does not need to worry about newbies, or that this > list is not the proper forum for their questions. The > first case not really feasible in the long term. As > you must realize Python needs new blood to grow and > mature, that is, unless you want it to become stagnant Of course...and that means that it's ok for the topic of compiling Python (and other far-to-FAQ questions) to come up daily in this newsgroup? I whole-heartedly disagree. The mere fact that one knows how to post to newsgroups implies at least a small degree of technical competency. Within that same degree of competency should be the understanding that one should at least make an attempt to find the FAQ for the relevant newsgroup before posting questions that have been asked over and over...and over. How many people would say "I learn much better from having somebody answer my questions -- even if they're often the same as what I've already asked -- than I do from actually trying to learn on my own and /understand/ why something works (or doesn't work) the way it does (or doesn't)." Nobody that I know. Even when one makes the argument (a bad one, to say the least) that "I was too lazy to search the FAQ", one should realize that this, in fact, is only false laziness. Since you actually will end up waiting longer for your answer, and encourage others to respond to topics whose answers are smattered all over the net (groups.google.com, The Python FAQ, etc). Promoting the idea that one should search the FAQ (and other relevant documentation) before asking very simple, very very commonly asked questions is a Good Thing. Also, it avoids insulting those who have done the thankless task of /writing/ the documentation to begin with. A google search for "compiling Python" brings up pages and pages and pages of answers. The argument that "it gives newbies confidence when they're able to answer simple questions like these" isn't enough either. It's just as gratifying to have a question and look in the FAQ and realize "cool! So THAT'S why Guido uses whitespace instead of {}'s!", the latter alternative alleviating more experienced users from having to even skim their eyes across the same topics day in and day out. My eyes and brain are too lazy to keep wanting to see the same topic daily. > like Common Lisp is now. The second case may be true, > the solution there may be that there needs to be a > python newbies list or some such, this seems to be a > common solution. In any case, you cannot just decide There already is, and has been for a long time. Go here: http://mail.python.org/mailman/listinfo/tutor to sign up for it. > that new users ask stupid questions and they need to > go away. Hmmm...you're the only one who uses the terms "stupid questions" and "go away". My (relevant to this topic) posts encourage the reader to take the small effort required to search the FAQ to find their answer before asking again. It allows them to be lazier, finding their answers much quicker. It's certainly hard to prove that it's actually /better/ to encourage them to ask FAQ questions in the newsgroup forum. > Are these types questions unproductive? it depends on > how you are looking at it. If the list is dedicated to > development of the python language, yes absolutely > they are unproductive. If the lists are dedicated to > python, then these questions, that help incubate new > users, are very productive. They help newbies get > familiar with python and get past the newbie stage to > the point that these once-newbies can start > contributing to the language. Ensuring pythons future > developer base is not counter productive. Questions that are already answered in the FAQ are rarely productive when asked again and again in comp.lang.python. For the compilation issue (the most repetitious thread in this newsgroup), question 6.13 of the FAQ (and it's answer of course :): http://python.org/doc/FAQ.html#6.13 give the reader as good an answer as any as to why it's difficult to compile Python and even goes into some detail about what python does to your source file so that it can interpret it, and why it isn't likely that you'll get that much quicker performance from compilation. As well (and in other parts of the FAQ) it points you to tools that show you how this is done. In fact, this answer is more complete than almost any answer that's usually posted in comp.lang.python everytime the thread comes up. From dnew at san.rr.com Mon Jun 4 13:07:06 2001 From: dnew at san.rr.com (Darren New) Date: Mon, 04 Jun 2001 17:07:06 GMT Subject: random References: <3b1b9dd5.5603777@nntp.sprynet.com> Message-ID: <3B1BC03C.27FFC2B2@san.rr.com> "David C. Ullrich" wrote: > If I have the "definition" straight (and > note that nothing I've said contradicts > what you said about the definition!) then > the bits of Omega are not going to be much > use for an RNG. If you have the definition right, then the hypothetical transilvanian dwarf's machine can't exist either. Excellent summary! -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. This is top-quality raw fish, the Rolls-Rice of Sushi! From python at commandprompt.com Mon Jun 4 15:24:25 2001 From: python at commandprompt.com (python at commandprompt.com) Date: Mon, 4 Jun 2001 12:24:25 -0700 Subject: Graphical Programming with Python: QT Edition Message-ID: <20010604122425.A19948@crazypenguins.commandprompt.com> Hello, OpenDocs has begun work on Graphical Programming with Python: QT Edition. The book, as the title sugggests teaches a developer how to create graphical application using the QT toolkit and Python. We have a sample TOC at http://www.opendocspublishing.com/sample-chapters/pyqt-toc.pdf and are requesting feedback. Any thoughts people may have would be great. We are aware that some things are missing, but what is in the TOC has been written and we are moving forward quickly. We will be releasing several chapters of the book in the next couple of weeks and will be requesting feedback throughout. Sincerely, Joshua Drake From johnroth at ameritech.net Thu Jun 14 18:49:43 2001 From: johnroth at ameritech.net (John Roth) Date: Thu, 14 Jun 2001 15:49:43 -0700 Subject: idle BUG References: Message-ID: "Robin Becker" wrote in message news:pkvruLAg7QK7Ewi3 at jessikat.fsnet.co.uk... > I think this must be a bug in Tkinter, but since no one ever responds I > thought I'd whine about idle instead. > > I run python2.1 Win95 OSR2. > Start a command window > run python idle.py It also happens when you try to execute from the DOS command line. > Kill the idle window using the mouse (click on the x). In some unknown > percentage of cases (like 50%) the process hangs and doesn't return to > the command window. It may be connected with exception handling. My purely subjective impression is that I get it irregularly when there has been an exception, and seldom (or never) if there hasn't been one. I also hadn't related it to the close button as opposed to the File|Exit command. I think that's a significant fact, since they have two very, and I mean very, different processing paths. > The hung process is very destructive and makes it impossible to reboot > the machine properly. This bug has been present for a very long time and > I'm fed up with it. I get rid of the command line with the three fingered salute (CTL-ALT-DELETE). Sometimes (not always) this causes Windows to hang on shutdown. Then it goes through a disk check on startup. > It's clearly some kind of race between python and Tcl/Tk. The problem > doesn't occur on win2k so I guess there's some difference between the > run times that helps. Technically, it can't be a "race" condition, since there is only one process (or thread). I suspect the difference is that Win 9x and Win 2k may post events in different orders, thus causing the confusion. They are, after all, completely different code bases, and Win 2K doesn't have the global lock that Win 9x has when it's accessing legacy 16bit functionality. > similar apps in pure tcl/tk don't show this behaviour although it's > possible to make them do stupid things. I remember running across a patch somewhere reasonably official to the Tk event handling kernel to allow Python to get a somewhat different set of conditions on waiting for events. Since I know nothing about the issues, it went in the eyeball and promptly migrated to random access memory, where it lost any association with a URL. Wish I could help more, but I'm not a windows developer, so I am very shakey on using the developer tools, like event traces. I'd like it fixed, but it's going to have to wait on someone who knows low level Windows development. > -- > Robin Becker John Roth From clpy at snakefarm.org Tue Jun 12 09:05:52 2001 From: clpy at snakefarm.org (Carsten Gaebler) Date: Tue, 12 Jun 2001 15:05:52 +0200 Subject: statically linking the entire runtime (HPUX Python2.1) References: <3b091a1c.0106120045.5f49191e@posting.google.com> Message-ID: <3B2613B0.7DE708FF@snakefarm.org> I went into exactly the same problem under Linux. I'd be glad if someone knew the answer. cg. cmkl wrote: > On HP-UX I'm trying to build python2.1 without building the C-modules found > in Modules/ as shared libraries. With the Version 2.0 this was the default. > I played around with configure, setup.py and Modules/Setup but I always > end up with a binary depending on various shared libraries. > I need this, bacause I want to freeze my pythons scripts as a single binary. > Distribution is much easier this way. > What is the trick to do that? From paulp at ActiveState.com Mon Jun 4 12:29:23 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Mon, 04 Jun 2001 09:29:23 -0700 Subject: Programming ASP with ActivePython [also a general Web question] References: <87lmn8fdmi.fsf@penguin.aktivist.ru> Message-ID: <3B1BB763.6B688DDB@ActiveState.com> Wartan Hachaturow wrote: > > Hello. > > I've got one trouble with ASPs on Python -- they doesn't work ;) > In fact, I did run pyscript.py, and it said that it has successfully > registered python as a scripting engine. > When I try to execute server-side scripts, they fail (saying 500 Server > Error). I think that this is a problem unique to Win2K. Mark Hammond has recently worked out a workaround. Run: pyscript.py --unregister then run pyscript.py again. If this does or doesn't work for you, please give a shout. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From roman at speeder.org Sun Jun 17 00:05:53 2001 From: roman at speeder.org (Roman Milner) Date: 16 Jun 2001 21:05:53 -0700 Subject: forcing python to build a static libpython2.1.a Message-ID: Is there an easy way to have the build process disable dynamic loading? I just want a plain old static libpython2.1.a. I've been able to build a static lib, but only by manually creating one after the python build process. I'm looking for a configure switch (that I haven't been able to find) or something similar, that will do this for me. Thanks, ^Roman From jm7potter at hotmail.com Wed Jun 27 08:27:32 2001 From: jm7potter at hotmail.com (Joe Potter) Date: Wed, 27 Jun 2001 08:27:32 -0400 Subject: newbie with major "lambda" problem (perhaps a scope problem as well) References: <3B38DC90.176CD7FD@home.net> Message-ID: On Tue, 26 Jun 2001 12:03:44 -0700, Chris Barker wrote: >Joe Potter wrote: >> >> # the "button" below works like a champ !! >> >> #Button(root, text='Fetch', >> >> #command=(lambda v=vars: fetch(v))).pack(side=LEFT) >> >> >> >> # the "button" below does not do anything ?????? >> >> Button(root, text='Fetch', command=(fetch(vars))).pack(side=LEFT) > >Because when the button is pressed, no parameters will be passed to the >command function, and fetch needs a list of variable to be passed in. >That's what the default parameter assignment does: my command_fun (or >the lambda function) does not need to have any parameters passed to it, >it will assign v to vars, and then pass that in to fetch. > >I'm not sure I made this very clear, but I tried > >-Chris > Chris, Yes, you helped a lot. Thanks very much. To clear up the matter, I would ask one more favor. Would you please look at the code below and tell me how to move the "button" calls out of the class and down into the " if __name__ == __main__" portion of the code? I think that will take care of any remaining problems I have. Thanks in advance! Regards, Joe ###################### code start (note will need a little txt file ############################## import sys from Tkinter import * from tkMessageBox import askokcancel import Pmw class SumGrid(Frame): def __init__(self, parent=None, numrow=5, numcol=5): Frame.__init__(self, parent) self.numrow = numrow # I am a frame container self.numcol = numcol # caller packs or grids me self.makeWidgets(numrow, numcol) # else only usable one way def makeWidgets(self, numrow, numcol): self.rows = [] for i in range(numrow): cols = [] for j in range(numcol): e = Entry(self, relief=RIDGE) e.grid(row=i+1, column=j, sticky=NSEW) e.insert(END, 'xx') cols.append(e) self.rows.append(cols) Button(self, text='Print', command=self.onPrint).grid(row=0, column=0) Button(self, text='Clear', command=self.onClear).grid(row=0, column=1) Button(self, text='Load', command=self.onLoad).grid(row=0, column=2) def onPrint(self): for row in self.rows: for col in row: print col.get(), print print def onClear(self): for row in self.rows: for col in row: col.delete('0', END) col.insert(END, '') def onLoad(self): import string #from tkFileDialog import * #file = askopenfilename() file = "joe.txt" if file: for r in self.rows: for c in r: c.grid_forget() myfile = open(file, 'r') filelines = myfile.readlines() myfile.close() self.numrow = len(filelines) self.numcol = len(string.split(filelines[0])) self.makeWidgets(self.numrow, self.numcol) row = 0 for line in filelines: fields = string.split(line) for col in range(self.numcol): self.rows[row][col].delete('0', END) self.rows[row][col].insert(END, fields[col]) row = row+1 if __name__ == '__main__': root = Tk() root.title('test a button') sf = Pmw.ScrolledFrame(root, usehullsize = 1, hull_width = 600, hull_height = 300, ) sf.pack(side = "top", padx = 10, pady = 6, fill = 'both', expand = 1) # can we move the button calls to here, and hence --- pur them in root???? iframe = sf.interior() SumGrid(iframe).pack() mainloop() ######################## end code ########################## You need a "joe.txt" file --- the below is as good as any ############## 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 From erlangen72 at hotmail.com Mon Jun 18 13:28:20 2001 From: erlangen72 at hotmail.com (Mark_Pryor) Date: Mon, 18 Jun 2001 17:28:20 GMT Subject: Win32com Item method does not return object Message-ID: Hi, New to Python, using Version 2.1 on Win95. I have a COM object that has been registered into the gen_py folder. As I drill down through the object, I issue the Item method of a collection, which should return another collection, but fails returning a " tuple ". # snip Portions Copyright 1994-2001 Mark Hammond (MarkH at ActiveState.com) - see 'Help/About PythonWin' for further copyright information. >>> import os >>> import sys >>> import win32com.client >>> om = win32com.client.gencache.EnsureDispatch( "xMp3.CxInfo" ) >>> a = "c:\\alienmp3" >>> f = os.listdir( a ) >>> fp = os.path >>> b = fp.join( a, f[5]) >>> print b c:\alienmp3\P. Bellinati - Serenata - 14 - Noite de Lua.mp3 >>> om.SongFile = b >>> print om.Tags.ColKeys 230 100 >>> c = om.Tags.Item(1) >>> c = om.Tags.Item(1) # unsnip c above, should be another collection or object, but is neither. Please help. Mark Pryor pgp KeyID: 0x1A966EC5 From finell at cenix-bioscience.com Fri Jun 29 02:55:17 2001 From: finell at cenix-bioscience.com (Jan Finell) Date: Fri, 29 Jun 2001 08:55:17 +0200 Subject: Python quicktime module Message-ID: <9hh8ol$dpjpj$1@ID-95680.news.dfncis.de> Hi! Does anybody know if there is a python module (running under Linux) that can handle quicktime movie files (.mov) ?? Thanks, Jan -- ---------------------------------------------------- Jan Finell Cenix Bioscience GmbH Student Software Engineer, IT-Unit Tel : +49 351 210 2683 Pfotenhauerstr. 108 01307 Dresden, Germany From altis at semi-retired.com Mon Jun 18 17:24:38 2001 From: altis at semi-retired.com (Kevin Altis) Date: Mon, 18 Jun 2001 14:24:38 -0700 Subject: Is anyone using CGIHTTPServer on a non-Unix/Windows platform? References: Message-ID: You might want to read two bug posts I've made to sourceforge https://sourceforge.net/tracker/?func=detail&aid=430160&group_id=5470&atid=1 05470 I think this is the issue you are seeing. https://sourceforge.net/tracker/?func=detail&aid=427345&group_id=5470&atid=1 05470 This one will take care of the binary issue. ka "Mark Wright" wrote in message news:f9ff3f62.0106181252.5a048fa1 at posting.google.com... > I'm having problems getting it to work. I'm running python CGI > scripts using the execfile() part of CGIHTTPServer (i.e. !has_fork and > !has_popen2), and it works like a charm when I do a GET. But when I > try to do a POST, the thing just hangs in telnet and I get the "Page > could not be displayed" error in IE and a blank page in Mozilla. > > (Techinically, I am running on Windows, but I've commented out the > popen2() section due to text/binary file conversion issues.) > > Is anyone else having this problem? The following script is an > example of one that fails (but works fine in Apache): > > import os > import sys > import cgi > > # ---------------------------------------------------------------------- > if __name__ == '__main__': > > # parse parameters > form = cgi.FieldStorage() > > out_file = sys.stdout > if os.environ['REQUEST_METHOD'] == 'POST': > out_file.write('Content-Type: text/html\n\n') > out_file.write("\n") > out_file.write(" Did this work? \n") > out_file.write("\n") > # keys = os.environ.keys() > # keys.sort() > # for key in keys: > # out_file.write("
" + key + ':' + cgi.escape(os.environ[key]) + > \ > # '\n') > out_file.write("Did this work?\n") > out_file.write("\n") > > else: > out_file.write('Content-type: text/html\n\n') > out_file.write("\n") > out_file.write(" Did this work? \n") > out_file.write("\n") > out_file.write( > """
>
try this out > >
""") > out_file.write("\n") From ullrich at math.okstate.edu Wed Jun 6 11:26:58 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Wed, 06 Jun 2001 15:26:58 GMT Subject: random References: Message-ID: <3b1e4a4f.3288589@nntp.sprynet.com> On Tue, 05 Jun 2001 14:06:03 -0500, Michael Chermside wrote: >David C. Ullrich wrote: > >> > >> > [An lengthy and EXCELLENT detailed description of Omega, how it's >> > defined, why it is/isn't "random", and how it all relates -- all >> > expressed in terms a layperson can follow.] >> > > >Well, it's certainly the case that you can still learn things on USENET. >Thanks! Glad you liked it. Not sure exactly what post this is referring to. You should note that several things I've said here have been just plain wrong. (A relatively unimportant example, where I said something utterly stupid and the person I said it too just payed no attention instead of explaining how ridiculous I'd just been: Someone said something about the size of the smallest algorithm to calculuate the first N bits of Omega. I butt in and said there was no such algorithm. Nonsense - there is an algoritm to calculate any sequence of N bits. What there isn't is a way to know _which_ algorithm calculates the first N bits of Omega. Thought about posting a retraction, couldn't easily find it a few days later, hidden among all the erroneous non-corrections. Been feeling like I was in a state of sin since then, now I feel better.) >-- Michael Chermside > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From ullrich at math.okstate.edu Sun Jun 24 09:22:46 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 24 Jun 2001 13:22:46 GMT Subject: Is this a true statement? References: <3b34939b.410758@nntp.sprynet.com> <9h2nuc$g6g$0@216.39.170.247> Message-ID: <3b35e8fa.311691@nntp.sprynet.com> On 23 Jun 2001 18:42:20 GMT, David LeBlanc wrote: >In article <3b34939b.410758 at nntp.sprynet.com>, ullrich at math.okstate.edu >says... >> On Fri, 22 Jun 2001 12:47:23 -0400 (EDT), "Steven D. Majewski" >> wrote: >> [...] >> >The reason why you can't write a device driver in pure Python is simple: >a device driver requires the ability to read to and write from specific >pre-determined locations in the processor's memory and/or I/O space. Yes, a device driver has to do this. But I don't see why a program that _writes_ a device driver has to do these things. >It would be possible, if best performance where not required, to extend >Python with C or ASM (and possibly C++, but not without some dificulty: >passing "this"pointers gets in the way when crossing memory management >and/or procsss thresholds. This is why you can't write, for example, a >multi-tasking OS in pure C++.) which would permit inserting driver start >addresses into trap (interrupt) vectors, reading and writing device >registers or calling device firmware entry points at specific locations >etc. > >Such systems have been written and probably do continue to exist, >particularly along the lines of the higher level parts of the device >driver being written in an HL language (even BASIC) and the >fast slippery parts written in LL language. I've done as much with >Smalltalk on a PC. > >Of course, with enough glue and the right scaffold, one could glue up >enough toothpicks to reach the moon. > >Dave LeBlanc David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From tom at peresys.co.za Sun Jun 10 08:39:56 2001 From: tom at peresys.co.za (Tomasz Stochmal) Date: 10 Jun 2001 05:39:56 -0700 Subject: Use Jython to make true executable? References: Message-ID: carlf at panix.com (Carl Fink) wrote in message news:... > I'm a Python beginner, so forgive me if this question is stupid. > > A common request on this group is a true compiler to convert a Python > script to a directly-executable program. (ELF for Linux, .exe for > Windows/DOS, etc.) There apparently used to be a python2c project > which was abandoned. > > Couldn't you develop your program in Jython, "compile" it to Java > bytecodes, then run them through GCC? I haven't tried it, but I've > read that GCC can convert Java to direct executables. > > Now, I also am far from a Java expert. For instance, would Swing be > convertible using GCC given that it's not free software? > > So, is this idea so obvious that it has to have a flaw? for Windows just use py2exe http://starship.python.net/crew/theller/py2exe/ From dsh8290 at rit.edu Fri Jun 1 12:34:25 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 1 Jun 2001 12:34:25 -0400 Subject: Problem installing Python2.1 on RH 7.1 In-Reply-To: <991402384.98784@nntp01.uskonet.com>; from hanna@chagford.com on Thu, May 31, 2001 at 03:34:20PM -0700 References: <991402384.98784@nntp01.uskonet.com> Message-ID: <20010601123424.A7521@harmony.cs.rit.edu> On Thu, May 31, 2001 at 03:34:20PM -0700, Hanna Joo wrote: | Hello | | I've been trying to install the newest version on RH 7.1. After millions of | dependency errors finally it is installed. | | Problem is, although it seems to have been installed correctly (all the | libraries are there, files have been copied etc), I cannot find python in | the path. I thought the -U option in rpm removed the older version - which | did not happen. All I can find in my path is 1.5.2. | | Any help will be appreciated $ find / -name "python*" -print will show where all the files whose name begins with python are on your system. I don't know where the rpms should/would have put the binary executable. It is possible that the binary is called python2 or python21. There is an option to rpm (-l maybe) to list the files that a package contains. You could try $ rpm -l python.rpm | less and look to see what files it puts where. -D From BPettersen at NAREX.com Tue Jun 26 16:28:52 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Tue, 26 Jun 2001 14:28:52 -0600 Subject: readline, python 2.1 and LFS Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D4BB@admin56.narex.com> > From: Andrew Kuchling [mailto:akuchlin at mems-exchange.org] > > > New Topic: I read a few posts back that you are doing stuff > > with the ZODB on a stand-alone basis. Do you have a paper, > > README, instructions or anything that detail the procedure of > > using it by itself? > > Closest thing is the programming guide at > http://www.amk.ca/zodb/guide/ . Any chance of a Windows version of your ZODB packaging? -- bjorn From thomas at cintra.no Wed Jun 6 18:15:26 2001 From: thomas at cintra.no (Thomas Weholt) Date: Wed, 06 Jun 2001 22:15:26 GMT Subject: Running mod_python on NT References: <1a18c6fa.0106060811.5f09477f@posting.google.com> Message-ID: <2YxT6.948$Q8.31005@juliett.dax.net> I've recently finished a project using these tools, allthough with a never version of Apache. When I had the same problem it was because I hadn't copied the contents of the lib-folder in mod_python-2.7.x into pythons lib-folder.The install-instructions for mod_python is pretty simple, but it doesn't work with ActivePython 2.1 yet. Hope this helps- thomas "Peter Nye" wrote in message news:1a18c6fa.0106060811.5f09477f at posting.google.com... > Has anyone been able to overcome the error message: > python_handler: make_obcallback returned no obCallBack! > and successfully run mod_python on NT. I have read all kinds of > postings of people having this problem but have not found any answers. > > Thank you for any help you can give. > > Running NT 4.0 > Apache 1.3.14 > Python 2.0 > mod_python 2.7.2 > > Peter Nye From geoff at homegain.com Thu Jun 14 21:51:49 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Thu, 14 Jun 2001 18:51:49 -0700 Subject: humans and logic Message-ID: <393D961EA4FCD311B03F00D0B746D65803275EAD@HQSXCH01> Hmm, this thread isn't an elaborate "all your base" joke, is it? --- Geoff Gerrietts Software Engineer, HomeGain.com 510-655-0800 x4320 From db3l at fitlinxx.com Thu Jun 14 01:12:41 2001 From: db3l at fitlinxx.com (David Bolen) Date: 14 Jun 2001 01:12:41 -0400 Subject: ftplib only posting 52 bytes? References: <9mcgitkhpmkcrql5uhk5bsi94q8nquo4em@4ax.com> Message-ID: Brent Stroh writes: > Today, I added the FTP step, figuring it would save me a few minutes to > kick the transfer off in the background. It appears the first 52 bytes of > each image is transferred to the server; what is sent appears to be the > beginning of a JPG file. One thought is that you're not opening the file in binary for the transfer. Although you're using a binary store store operation at the FTP level, that only notifies the server to process the incoming stream without conversion. The FTP module is still reading the file through your text mode file object, and probably stopping at what it thinks is an EOF when it sees the first ^Z (ASCII 26) in the file. E.g.: > def send_file(filename): > ftp = FTP('server', 'user', 'pass') > ftp.set_pasv(0) > ftp.cwd('/home/bmstroh/public_html/images') > print dest + filename > fp = open(dest + filename) Try changing this to: fp = open(dest+filename,'rb') -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From max at alcyone.com Sat Jun 16 17:36:10 2001 From: max at alcyone.com (Erik Max Francis) Date: Sat, 16 Jun 2001 14:36:10 -0700 Subject: in statement and namespace type ideas References: Message-ID: <3B2BD14A.1545DA9F@alcyone.com> Roman Suzi wrote: > I also thought about absent "with" operator and how it could be used > in Python. Maybe it is beneficial to have "with" syntax like in the > followin example: This gets suggested about once a month or so. Check Google Groups for reaseons why it's not a very good idea for Python. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ They have rights who dare defend them. \__/ Roger Baldwin Alcyone Systems' CatCam / http://www.catcam.com/ What do your pets do all day while you're at work? Find out. From Attila.Feher at lmf.ericsson.se Fri Jun 8 03:49:57 2001 From: Attila.Feher at lmf.ericsson.se (Attila Feher) Date: Fri, 08 Jun 2001 10:49:57 +0300 Subject: best language for 3D manipulation over web ? References: <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3B1B1825.8109BA83@lmf.ericsson.se> <2v4ohtgldvce84sn87kh1eg1lnes37getq@4ax.com> <3B1C9E65.B73A4FE@lmf.ericsson.se> <3B1DFD87.F3BFDB57@lmf.ericsson.se> <9fpra3$352$1@oslo-nntp.eunet.no> Message-ID: <3B2083A5.15B40637@lmf.ericsson.se> Thomas Hansen wrote: > > > >> Every user should have his/her own registry (and not just a sub-tree) > > > > > > TOTALLY agreed. > > > > See, we can agree to many different things ^__^ > > > > Not possible unless you want to install a billion ActiveX/COM components x > times where x is the number of users on that computer... Due to bad design... A From m.hadfield at niwa.cri.nz Wed Jun 13 16:59:33 2001 From: m.hadfield at niwa.cri.nz (Mark Hadfield) Date: Wed, 13 Jun 2001 20:59:33 +0000 (UTC) Subject: IDL and NetCDF References: Message-ID: <002c01c0f44b$babf7d10$d938a8c0@Hadfield> From: "Claus S?lvsteen" > Is there anyone out there who knows about using NetCDF in IDL programming - > or knows anybody who does? > I have recently started using this, and my problems are not answered > entirely from the IDL online manuals and the "basic" NetCDF homepage, > www.unidata.ucar.edu/packages/netcdf > For instance, I am in doubt about 1) how do I use (and when should I use) > unlimited variables, 2) is it possible to use structures as variables, and > 3) how do I most properly create my program so that it is easily seen which > variables belong together? These are really netCDF questions rather than IDL questions, and you might want to take them a netCDF newsgroup. (I think it's sci.data.formats. It's ages since I looked at that. I wonder if it's still active?) You could also look in the documentation, eg... http://www.unidata.ucar.edu/packages/netcdf/guidec/ ...from which you can extract (with some searching) information about netCDF concepts. But, to have a stab at your questions: 1) Unlimited variables (there can only be one per netCDF file) are used to represent dimensions, like time, whose size is not known in advance. 2) IDL structures can't be stored directly in netCDF variables, but you can break the structure up into its constituent tags and store each of these as a variable, unless the tag is itself a structure in which case you have to break it up, unless ... 3) netCDF has no explicit mechanism for recording the fact that certain variables belong with each other. But you can use naming conventions to make that fact clear. E.g. if you have a structure called "velocity" with tags "u", "v" and "w" you could store these in netCDF as "velocity_u", "velocity_v", "velocity_w". > I have a long set of observations of radar altimetry measurements og > significant wave heights and wind speeds. So all measurements are acquired > at different times. One measurement consists of information about > acquisition time (year, month, day, decimal hour), lat/lon, SWH, rms of SWH > measurement, wind speed and others). Note that some variables are integers, > some are doubles/floats - so I cannot just make a DblArr consisting all > measurements. > A file consists of several repeated tracks/cycles and the measurements have > been put into a grid - therefore several measurements within a file may > belong to a certain grid point though their acquisition times are different. > On the other hand, for some grid points there may be no data. > I hope that someone can help me. Hmmm. This may require some ingenuity on your part, and you may decide that netCDF is not the best format for you. It can almost certainly store the data, but it may not be able to represent all the relationships inherent in the data. (It's not clear to me exactly what those relationships are.) Perhaps you could make an unlimited dimension called "acquisition", then variables called time (Julian date) or "time_year", "time_month", ..., "lon", "lat", "swh", "swh_rms" etc all varying with "acquisition". The grid (if it's spatially fixed) can be stored in the same file, and then position on the grid for each acquisition can be described by one or more variables dimensioned as "acquisition". Hope this helps... --- Mark Hadfield m.hadfield at niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield National Institute for Water and Atmospheric Research -- Posted from clam.niwa.cri.nz [202.36.29.1] via Mailgate.ORG Server - http://www.Mailgate.ORG From philh at comuno.freeserve.co.uk Wed Jun 20 17:59:19 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Wed, 20 Jun 2001 22:59:19 +0100 Subject: Two minor syntactic proposals References: <16074dce.0106181057.528dfea@posting.google.com> <3b30ee5e.1008026215@wa.news.verio.net> Message-ID: On Wed, 20 Jun 2001 18:44:16 GMT, Bengt Richter wrote: >On 18 Jun 2001 11:57:59 -0700, jeff at ccvcorp.com (Jeff Shannon) wrote: > >>philh at comuno.freeserve.co.uk (phil hunt) wrote in message news:... >>> >>> I propose a different way of doing this: make 'self' implied in all >>> references to instance variables. This involves definiing 2 new keywords, >>> qclass and insvars. So: >I think I prefer just an easier way to type "self." >How about just the dot? I.e., ".x" means "self.x" That sounds a good idea. >>I much prefer having all member variables and member functions explicitly >>qualified. Having moved to Python from C++, where members can be referred >>to implicitly, it seems to me that the explicit requirement of Python makes >>code *much* easier to read--no more hunting about to try to figure out whether >>a given variable is a class member, or a parameter, or a global, or from some >>other scope... then there's also this problem (using your notation): >[...more reasons...] > >So what about a plain prefixed '.' as an abbreviation for 'self.' ? i wish i'd thought of it -- ## Philip Hunt ## ## philh at comuno.freeserve.co.uk ## From m.faassen at vet.uu.nl Mon Jun 4 19:36:09 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 4 Jun 2001 23:36:09 GMT Subject: Why isn't Python king of the hill? References: Message-ID: <9fh619$g1a$1@newshost.accu.uu.nl> Geoffrey Gerrietts wrote: > A further episode in the discussion between Martijn and myself: >> Or you can do evil and cool stuff with AccessRules (the whole >> SiteRoot stuff). >> [ ... quotes from me about controller-centered models ... ] >> What exactly do you mean by embedding controller elements in the >> view? I'm not entirely sure what you'd refer to as the >> controller here. > I'm not sure how to manipulate AccessRules; I think this might be > one of the Zope features that we currently hafta do without. AccessRules are voodoo. I've only played with them a little. Here is an example of what you can do; unfortunately written in DTML, but you can also write it in Python: http://www.zope.org/Members/4am/SiteAccess2/otheruse So, it can be used to embed variables in the URL path itself instead of as the argument; sometimes this can be clearer. > I think maybe I'm running along here under the assumption that > everyone more or less understands Model/View/Controller, and > understands it in the same way that I do. Let me try to define my > terms. I more or less understand it, but not the same way you do. :) [snip view description] Right, this was clear to me. Presentation, reporting. > The "Controller" element responds to user input and interfaces it > with the business objects of the model. The controller is in > some ways like glue code, but this is (or can be) where you might > have form validation logic, or where you translate your form > fields into the attributes of a data object. The controller > element is typically the center of your application; it might be > compared to the main() function in a C program. It presents > various views when required, retrieves model objects, and glues > them all together. I can't think of a good translation of this to Zope, as you said, in Zope control and view tend to be rather intertwined. This is not to say you can't use a pattern that does much like this, but it's less cleanly separated. [snip model] This part was clear to me too. I'm not sure why 'controller' wasn't clear to me, but it's always been the vaguest part of MVC to me... [snip] >> Hm, yes, I think this makes sense (though it could lead to horrible >> URLs). Of course you don't give the details here so I'm not >> entirely sure I get the entire picture right. > The URLs need not be any more "terrible" than in any other web > application, including any Zope application. If your main servlet > responds to all URLs that begin with '/myapp', any sub-path is > something that the servlet can switch on. The difference here is > that /myapp doesn't map to a folder object either on the > filesystem or in some content repository. Nor does it map to a method on some object, as what happens in Zope, really. The content repository is just something behind that, but not essential (just useful) to object publishing. > It's mapped in the > application server to mean "invoke this servlet"; additional path > information is passed on to the servlet. [snip] > Meanwhile, your controller has the request before anything else. > That means the controller can take action based on form values or > other request parameters. As far as I know, Zope provides a > solution for the most common application of this (user > authentication), but does not provide much in the way of a > toolkit for other similar problems. > An example might be a look-and-feel switch -- if you have a > cobranded application, you might serve from a different batch of > pages, or use decorations and stylesheets from a different > directory hierarchy. > You /can/ do these things in Zope, it just requires hacking > around the way Zope is set up to serve pages, not invoke > processing logic. For many of those things (look and feel switch for instance) you can use Acquisition. The alternative is to intercept the traversal at some point to do something special. Access Rules are one way to do that. Finally, if your URL end up at a Python script at some point in the path, the rest of the path coming after that can be processed by it and you can do whatever you like, I believe. [snip] [speed of view templates] > Or you could take your Zope objects and turn them into actual > python code objects that generate HTML and perform some actions > when called. It's not going to suddenly challenge C for > near-hardware speeds, but it's a significant step ahead of > doing the lexical parsing at runtime -- at least the Python > interpreter is written in C. Sure. In short, there are a ton of optimization opportunities here, if necessary. > I don't think it's a huge priority, but it's one of the things > the Java stuff does to reduce runtime load, which in turn > promotes better scaling and better overall peformance. True, though page generation could in general probably be easily distributed, so throwing more hardware at the problem is relatively doable. It's harder to scale controllers and models, I expect. >> > Your JSP pages have access to at least four levels of state >> > (there might be another I'm forgetting): application, session, >> > request, and page. The first three correspond to the same state >> > repositories managed by the servlet. The 'page' context is for >> > local objects. >> >> Right, in Zope you'd have 'acquired things', session object (if you >> have Core Session Tracking or something similar installed), REQUEST >> object and folder context, for these. I'm just trying to translate >> the concepts. > Almost. > I think the acquired things don't map onto application state > quite like you suggest. There's one repository, shared by all the > sessions running inside a single process. This isn't initialized > with web-content properties. It's a place to stick objects at > runtime. Hm.. I'm not sure about an exact equivalent this in Zope. Generally of course objects in Zope can always refer to runtime objects, and this frequently happens (I initialize a bunch of widget and validator singleton objects in my Formulator component for instance and any instance of a Formulator Form in the object database can use these). > I don't know what the session object gets you, or how it gets it > for you, but I assume that's correct. It's quite similar to REQUEST in that you can attach almost arbitrary Python objects to it. > The REQUEST object does map > to the request context. The page context maps more closely to the > namespace of a DTML document. >> > You can forward control to other servlets or JSP pages, and you >> > can also include pages. >> >> What do you mean by 'forwarding control'? Control of what? >> >> [ snip my explanations ] >> >> Ah, I think I more or less understand. I'm not sure what the use of >> forward is compared to include, though. Why'd you ever want to forward >> control and never come back? Generate half a page with one JSP page, >> and the other with another? > and RESPONSE.redirect() provide more-or-less > similar functionality in DTML, as compared with the use of > to include a method. Ah, okay, I see. Though RESPONSE.redirect() does a client-side forward. > My typical page processing paradigm is to submit form data to the > page that renders the form. If all the data are acceptable and no > processing errors arise, I forward on to another page. If all the > data are not acceptable, I redisplay the current page with error > messages. Others do it other ways. Plug: this type of thing becomes pretty easy to build with Formulator. :) >> > You can associate a bean with an object, and map form properties >> > onto the bean's attributes. I think that this is most useful when >> > you're programming pure JSP, but it's pretty useful when you're >> > not. >> >> Right, Zope's REQUEST object does this automatically (the >> 'form' subobject). > Except that your "form" subobject is one standard object, not an > object customized for your particular form. The servlet API > allows you to pick the attributes off the REQUEST object, too; > it's just somewhat more convenient to load up a bean. Formulator allows you to customize whatever ends up in your REQUEST, or can return a result dictionary. Of course that's my own component. I think form handling is something that can be done better in Zope, so I'm writing a component to do that. [snip] > The current solution is a reasonable solution, but it doesn't > scale well. Your front-end load balancing hasta be session-aware, > so it can redirect to the right instance of Zope. Does it? It just needs to transmit the changes to the session object database, right? That's similar to what it is already doing. Or do you mean such a setup without ZEO? > Using ZEO and Core Session Tracking could be The Right Thing. It > certainly seems like the two technologies could be combined > reasonably. Until it's arrived, though, you're still rolling your > own sessions if you deploy on more than one box. I think people already have setups running like that, though I'm not sure. >> > Servlets get a request and a response object passed to them. >> >> Like Zope's DTML pages, and of course you can pass those along >> to Python Scripts or other python code. > Yes, but the servlets ARE Java code, which means that you don't > NEED to stick a block of code at the top of every page, designed > to invoke them. True, it would be nice to have some way to do that more easily in Zope. It shouldn't be that hard to whip up, but someone has to come up with it and make it standard practice. >> Neat. With Zope exporting subfolders or simply copying >> Data.fs is relatively >> painless, but you need to copy over any external methods and special >> Python products manually, which isn't hard but an extra step. > Yeah, Zope isn't all that hard to roll out, as long as you do > everything in Zope. You can still get sync problems with the > external dependencies, though. If you use a lot of those (and I > suspect that you will in a logic-intensive app), then you're > likely going to hafta come up with some other deployment > mechanism. A benefit of Java's "We are the world" approach, I guess, which I usually dislike. [snip] > Well, except that we're not talking about just ZODB or ZEO here, > we're talking about distributing dynamic (by which I mean > run-time) state. That includes things like concurrent access > issues and synchronization of access, RMI techniques, and > whatever else it takes to implement these things. You mean that the whole system can switch to another server in the middle of handling a single request? > It's also not just Session stuff. If you could publish arbitrary > objects to the ZEO store and retrieve them by key -- something > I'm sure is possible, but not sure how difficult -- you'd be > close. That should be pretty trivial from Python. I mean, just use a persistent dictionary, or, to be more efficient, a BTree, stored in the ZODB. >> Sort of like ZEO with Core Session Tracking. :) Of course this >> is still being heavily developed, but it seems to be getting >> near offering equivalent features. > I can't speak to that, because I haven't used (and can't really, > at the moment) Core Session Tracking, let alone using it with > ZEO. I haven't worked with ZEO yet either, so I can't make too many claims about it. Core Session Tracking I've only used in its most simple form. Eventually I hope to get to using both, though. Let's call this discussion part of preparing for it. I learn about the issues this way. >> > The J2EE stuff makes deployment still one more step simpler, too. >> > It pushes parameters that might change during runtime out one >> > notch further, so that deployment configuration can be separated >> > from the details of servlet instantiation, URI mappings, and >> > other miscellany concerning the interaction of the app and the >> > app server. >> >> Hm, I'm not sure what this part means, exactly. I can't >> translate it to any Zope terms, which is how I tend to think >> about things, myself. > I might argue that trying to put everything into Zope terms is > part of what's limiting your comprehension. :) Zope is really a > very different animal. But does that mean this ability is important? I mean, if I can't think of a Zope equivalent (x exists in Zope *or* x is needed in Zope but we don't have it (yet))...but I can't think of the need here. > Still, if you were to take your Zope application, and all its > external methods, and all the little mini-servers that helped > distribute your backend processing job, and stuck them all in a > big tar file, then had one configuration file that detailled ALL > the configuration details that would vary from machine to machine > within an installation, and all the details that would vary from > installation to installation -- if you assembled that tarball and > that config file, you'd have the deployment mechanism used by the > Enterprise stuff. Okay.. there are vague sounds coming from Digital Creations that they want to move the source code into a ZEO database as well, later on (offering tools to temporarily export them to the filesystem). This sounds like what you're talking about. >> Yes, I'm not trotting them out so much to do 'see, we have that >> too!', though there is a component in that, but to learn more >> about both by comparing the two, and to see if there are >> interesting directions which Zope is missing. I think Java's >> system works better for model/view/controller type situations >> right now; Zope's framework for that is currently still in >> design phases. Java also has clear (standardized) interfaces >> for it, something which Zope needs a lot more of. > All of which I'll agree with. And I'm not trying to suggest that > Zope is a poor product, either. I realize that. It's just that Zope is my main experience with web application programming, which is why I talk about it so much here. :) > I just don't feel like it's a > good choice for a web-based application -- a website with some > dynamic elements, maybe, and I could even see it being used for > an online store. > And I confess that the more we talk about these things, the more > optomistic I am about the future. Java's solutions and toolkits > are great (or at least pretty good), but I would like a good, > solid alternative to all that wordy Java. I agree Zope still needs to grow. The interfaces are too vague right now, and that needs to become more solid. In my opinion that is the most important thing that Zope needs to do and Java has already done. All the rest is can be done by both with some creativity, perhaps excluding some of the enterprise style features. [snip] [object/relational database mapping] >> > Like I said once before, >> > maybe we can beat Java to the punch here. >> >> Python certainly has a lot of flexibility to work in its favor here, >> though I don't know if we have the development resources in the >> Python/Zope world to go fast on this. These discussions often seem to >> devolve into feature wishlists and pie-in-the-sky designing. > That's maybe true, but like I said, I started work on it at one > point, and probably put a few solid days of effort into it. What > I've arrived at might be less than perfect -- in fact, it IS less > than perfect -- but it was a running start at something that > would marshal a database table into an object. > Even at that level of utility, it's a very, very useful tool. Any chance you'll open source it? By the way, any useful documentation on this entire issue that I could browse through? >> [ snip lots, including a description of EOF's qualifiers ] >> Would this get translated into a query into a relational database? > Yes. EOF provides a couple different ways to do things -- you can > build up these qualifiers piecewise, or you can write out the > query string. But then EOF goes and traces it through its > internal mapping of entities to database elements, and produces a > SQL query that retrieves the appropriate object. Very interesting. [snip more very interesting stuff about this object to database mapping] > This is especially handy when you're building sequences of web > pages several pages deep before the final commit. You can nest > your editing contexts, and when the user hops back four pages, > you can either make the hop with him and toss the deeper changes, > or even just hop around with him and wait for him to commit the > whole lot of them. Is the whole set of changes somehow referred to by a session object? Extremely interesting. Definitely need to look a lot deeper into this. See if Python has something along these lines, and if not, see which people are interested in building such a beastie. [explicit interfaces] > I think I agree with you here. I've worked around the interface > issue in the past (subclass empty classes, then test to see if > my instance is a subclass of a particular empty class), but it > seems like being able to unambiguously promise to implement a > certain interface is much /clearer/. [zope UI can help beginners] > I think Zope's web UI is a mixed blessing. It cuts down on the > learning curve to get in and start making changes, but in the > end, it becomes an impediment to being able to work smoothly -- a > simple CVS archive of the DTML would be more practical later in > the game. Agreed that there are definitive negative tradeoff. Besides the great need for explicit interfaces of some kind in Zope (well documented), the secondmost important thing I see that Zope needs to add is the ability to smoothly transition from filesystem representation of object database contents such as DTML and Python code to ZODB object representation and back. Explicit interfaces would make learning and extending Zope a lot easier, and filesystem representation would suddenly enable a host of filesystem based development tools, from editors to version control systems; it would make the *process* of developing for Zope much easier. [snip] Thanks for your very interesting post. I'm learning quite a bit here. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From robin at jessikat.fsnet.co.uk Wed Jun 6 05:20:51 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 6 Jun 2001 10:20:51 +0100 Subject: need help inverting DerivVar array (Numpy/Scientific Python Quest ion) References: Message-ID: In article , PoulsenL at capecon.com writes > Are you trying to differentiate the inverse of a matrix? What are DerivVars? > I am having trouble inverting an array of DerivVar objects.? Here is > the code and error: > > ? > > >>> a = > Numeric.array([[DerivVar(-2.5,0,1),DerivVar(.45,1,1)],[DerivVar(5.5,2,1),DerivVar(-4.5,3,1)]]) > > >>> Numeric.sum(a) > > array([(3.0, [1, 0, 1]) , (-4.0499999999999998, [0, 1, 0, 1]) > ],'O') > > >>> Numeric.invert(a) > > Traceback (most recent call last): > > ? File "", line 1, in ? > > AttributeError: DerivVar instance has no attribute '__invert__' > > ? > > Any help would be greatly appreciated. > > ? > > Thanks, > > ? > > Loren Poulsen -- Robin Becker From cmkleffner at gmx.de Thu Jun 28 13:08:03 2001 From: cmkleffner at gmx.de (cmkl) Date: 28 Jun 2001 10:08:03 -0700 Subject: Problems with ./configure options (Python-2.1) on HPUX11 for 64bit ELF format Message-ID: <3b091a1c.0106280908.2b997f95@posting.google.com> Hi, I'm trying to compile python2.1 as a 64 bit binary on HPUX11. As stated from HP the 64bit ELF format is not recommended for 'usual' developments. However, I have to link against a 64 bit vendor library, so I want to build python with 64 bit. The problem is, that configure is not able to estimate some options correctly: i.e. SIZEOF_LONG and SIZEOF_VOID_P is set to 4 instead of 8. OPT=+DD64 ./configure --whatever or 'CC=cc +DD64' ./configure --whatever do not have en effect on the estimation of the SIZEOF constants. At least SIZEOF_FPOS_T also has set to 8. Anyone did that before ? Sincerly yours Carl From mlh at idi.ntnu.no Thu Jun 14 13:54:59 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Thu, 14 Jun 2001 19:54:59 +0200 Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> Message-ID: <9gatpj$4vr$1@tyfon.itea.ntnu.no> "David LeBlanc" wrote in message news:9gao5s$8ft$7 at 216.39.170.247... > One thing that bugs me about Python is that there's no really good way to > have named constants so that magic numbers can be avoided. Assigning to a > variable that (should) never changes is not the same (i.e. the "should > never" part). > > My proposal: > > alias httpport : 80 Hm. Unconventional use of the colon, isn't it? (For Python, I mean.) Anyway - what is it you want with this? Efficiency, on enforcing the non-changing state of the variables? I can't really see the need for this myself - but if something like it is ever implemented, I really hope we won't have similar solutions to those used to simulate private variables. I mean... >>> _const_httpport = 80 >>> _const_httpport = 90 Traceback (most recent call last): File "", line 1, in ? ConstError: constant '_const_httpport' is already defined > Dave LeBlanc -- Magnus Lie Hetland http://www.hetland.org "Reality is that which, when you stop believing in it, doesn't go away." -- Philip K. Dick From legere at adelphia.net Sun Jun 24 15:07:03 2001 From: legere at adelphia.net (Ronald Legere) Date: Sun, 24 Jun 2001 19:07:03 GMT Subject: algebraic datatypes References: Message-ID: Marcin and group: That is a neat way to do it! I posted this before I went away for the weekend, and was wondering if there was a way to do it with some kind of 'reflection' stuff. Seems like there is :). Thanks! "Marcin 'Qrczak' Kowalczyk" wrote in message news:slrn.pl.9j99ee.2mc.qrczak at qrnik.zagroda... > Sat, 23 Jun 2001 10:32:46 GMT, Ronald Legere pisze: > > > Essentially, > > datatype Tree = Node Tree Tree | Leaf Int > > should translate into a class structure like this: > > from __future__ import nested_scopes > import new, types > > From dalke at acm.org Thu Jun 28 01:12:55 2001 From: dalke at acm.org (Andrew Dalke) Date: Wed, 27 Jun 2001 23:12:55 -0600 Subject: PEP 260: simplify xrange() References: <3B39480C.F4808C1F@Lugoj.Com> <9hc97q$rpt$1@slb6.atl.mindspring.net> <3B3A9C39.64C3E1C6@seebelow.org> Message-ID: <9hef08$urt$1@slb3.atl.mindspring.net> Grant Griffin: >BTW, among its many other technological advances, Goggle frees you from >having to put "+" in front of stuff. Huh. Showing my heritage of using altavista for a couple years. If I had read the top of the results page I would have seen ] Google always searches for pages containing all the words in your ] query, so you do not need to use + in front of words Also, by reading the directions (fancy that!) ] Stop Words ] Google ignores common words and characters (known as stop words) as ] they tend to slow down searches without improving the quality of the ] results. Terms such as "where" and "how", as well as certain single ] digits and single letters, are not included in searches unless you ] indicate that they are essential. ] ] You can do this by using the "+" sign in front of the term. Be sure ] to include a space before the "+" sign, which can also be used in ] phrase searches. What happened was, I thought it did some sort of distance comparison, so given words "a b c d e f g" it would regard pages which didn't have "f" as being close enough. Thanks for pointing out the error of my ancient ways! Andrew dalke at acm.org From tgos at spamcop.net Sun Jun 3 13:44:05 2001 From: tgos at spamcop.net (TGOS) Date: 3 Jun 2001 12:44:05 -0500 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3B1A4DC3.4B6EBCE@worldnet.att.net> Message-ID: <6oqkhtsic8b17o1rqgfh2spe8vupjom0s1@4ax.com> On Sun, 03 Jun 2001 14:46:42 GMT, "Bruce G. Stewart" wrote: >> Do you think a nuclear power plant runs with Windows? Or maybe the software of >> an airport tower? If that's the case, how many people do you think would die >> during a blue screen error? > > Most computer systems, even in the nuclear power and air transport > industries, are not in life critical applications. Interesting, so when the tower control software (that paints those little dots onto your radar screen, including name and height of the airplane) all of a sudden crashes and your whole screen is black, it's not life critical? Oh wait, do you maybe want to tell me that those are no computer systems? There are little draws behind the screen that pull little paper points over the screen with their fingers, right? Why the hell do you think does Micro$oft literally say in their license agreement that you are not allowed to use their software in the two example cases I mentioned above? To avoid that people do this as this could kill people. >> Do you think the majority of worldwide banks use Windows? An easy to hack, >> insecure and not very stable operating system? A blue screen would mean loosing >> millions of dollars a minute and a single hack would make every hacker a rich >> man. > > Yet most do use it. Not exclusively, but for desktop client machines, > it's very pervasive throughout the financial industry. Not at the banks where my friend was working (he's system administrator for bank networks). The majority used OS/2 and Attila just told me about VMS, something I'll have to ask my friend about next week (maybe he also worked with that more often). >> At my university are over 2,000 PCs and not a single one runs with Windows. > > You are perhaps fortunate, but not typical. Oh, I checked that at other universities and it's not different there. They usually don't run Windows for lot's of reasons. > Surely some individuals or departments could benefit from some > commercial software that is only available for Windows. Which kind of software could this be? Provide an example. (and never forget that there's also commercial software for other platforms. Why do all people always assume that every non-Windows application is either for free or open source?) > Are your systems implemented in some proprietary, > non-cross-platform way? What do you mean by that? The OSes on those 2,000 PCs are regularly update and they are very up-to-date. >> On which planet are you living? >> You probably think that 99% of all CPUs currently in use are x86 CPUs, right? >> Well, that's damn wrong. Not even 40% of all CPUs are x86 compatible ones. >> (Source: Market Research of '99...not quite up-to-date, but there hasn't >> changed that much in the last 1 and half years) >> And with what OS do you think run the other 60%? Certainly not with Windows. > > A large percentage of CPUs aren't in personal computers. Never said they are. > Many toil away in microwave ovens, cd players, electric toothbrushes, etc. Don't forget: Refrigerators, TV set top boxes, web pads, cars, etc. > These aren't particularly relevent to questions about 3D > graphic maniplulation over the www. Let's assume your refrigerator has a WWW connection, so you could also surf webpages with it. Why shouldn't you be able to access a 3D data base with it, just because some shit-heads decided to use a Win32-only solution, instead of an already existing cross-platform solution (that easily could have been implemented into your refrigerator as well). Never thought about that? What if you want to browse with a web pad, your set top box or with the new mini computer in your new car in 5 years? Why do you want to exclude all those users right from the start, instead of using a solution that will work for everyone? Because you say that they won't want to access those 3D database? Who are you to predict that, how can you really know? Maybe people from a company want to access this database on their way to work and now they can't because you said that won't ever happen? And then the whole system must get rewritten for thousand of dollars, dollars that you can easily safe by writing a cross-platform solution right now. > [...] > > The main point of your post is well taken. A cross-platform interface > standard is preferable to a platform specific one, other things being > equal. Especially in cases where a cross-platform solution already exists. -- TGOS From bh at intevation.de Sun Jun 24 15:07:44 2001 From: bh at intevation.de (Bernhard Herzog) Date: 24 Jun 2001 21:07:44 +0200 Subject: PEP 255: Simple Generators, Revised Posting References: Message-ID: "Tim Peters" writes: > [Bernhard Herzog] > > With the current implementation that doesn't seem to be entirely true > > (CVS from somtime 2001-06-23 afternoon UTC): > > > > >>> def empty(): > > ... if 0: yield 0 > > ... > > >>> for i in empty(): > > ... print i > > ... > > Traceback (most recent call last): > > File "", line 1, in ? > > TypeError: iter() of non-sequence > > >>> import dis > > >>> dis.dis(empty) > > 0 SET_LINENO 1 > > > > 3 SET_LINENO 2 > > 6 LOAD_CONST 0 (None) > > 9 RETURN_VALUE > > >>> empty.func_code.co_flags > > 3 > > > > It seems that the mere lexical presence of the yield statement doesn't > > make a function a generator. The compiler apparently optimized the if > > statement away before testing whether it's a generator. > > Yes, it does. So don't do that. This is a general glitchlet, i.e. not specific > to generators; e.g. > > >>> k = 12 > >>> def f(): > ... if 0: > ... k = 3 > ... print k > ... > >>> f() > 12 > >>> > > That didn't yield "the expected" UnboundLocalError for the same reason I wasn't aware of that! For that matter, I wasn't even aware that the compiler removed "if 0" blocks. When was that introduced. It even "works" with 1.5.2. Anyway, I tried the example I gave because I wanted to see how to create an empty generator, i.e. the generator equivalent of an empty sequence. For a normal function it's simply def f(): pass or def f(): return but for a generator that obviously doesn't work; you need to introduce a yield statement and make sure that it's never executed. The following works: >>> def g(): .. if (): .. yield 0 .. >>> for i in g(): .. print i .. >>> The compiler apparently isn't smart enough to think of () as a constant (the bytecode confirms that). Being able to easily write a function that does nothing (in fact it's the most trivial function one can write) is very useful in practice, so as a generalization being able to write empty generators might be useful, too. I'm not sure about that, though, because I don't have enough experience with them. It seems to me that as it stands, empty generators are a bit too difficult to write, so I think we need an easier way to write them. One way to write them would be def g(): yield i.e. with a parameterless yield statement. Come to think of it, in generators, a yield without an argument could be equivalent to return. If generators weren't created with a def statement it would be a bit more obvious: generator g(): pass > affected blocks are actually removed by the *parser*, and "the > compiler" proper never knows they were there -- the "if 0" blocks > aren't even in the parse tree. That makes it difficult to repair, and > since nobody writes "if 0" in real life, that in turn makes the > cost/benefit ratio very high. In hand written code, "if 0" is indeed a bit unlikely, although I have sometimes changed the expression in an if statement to 0 for debugging purposes and if that can change the compiler's idea of local variables and other static aspects of the code it could lead to unexpected behavior. I've never run into this, though, so it may not be much of a problem in practice. Bernhard -- Intevation GmbH http://intevation.de/ Sketch http://sketch.sourceforge.net/ MapIt! http://mapit.de/ From aleaxit at yahoo.com Fri Jun 8 10:24:37 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 8 Jun 2001 16:24:37 +0200 Subject: Network access tying was(RE: Python Shareware?) References: Message-ID: <9fqn740ei5@enews1.newsguy.com> "Mike C. Fletcher" wrote in message news:mailman.991996993.4902.python-list at python.org... > But, but, isn't that the basic idea behind Windows and Office XP :o) . That > seems to require a constant connection to (the Microsoft version of) the > Internet to do even the most basic of things? Please tell me that this ... Let's see, wasn't it Microsoft that coined the motto "The Network *IS* the Computer"...?-) > Microsoft might be able to do network tying because their market share > approaches unity and they can spend hundreds of millions brainwashing people > into ignoring the problems, giving up their privacy etc. But most shareware Maybe. It does seem that they had to backpedal *VERY* fast from their original idea of Passport's license conditions (the ones which enabled them to freely use any intellectual property that you happened to store or transmit through their servers:-), so their brainwashing may not be quite as effective as all that. I think it's more likely that network tying can work for those products where being connected to the network is a clear added- value proposition -- which can be a fair amount, if one can structure things right (games can use a net connection to let you play with others, financial apps can use a net connection to get updated stock info, program-development tools can query an error/fixes/workarounds online DB for latest info, etc, etc). Presumably one would have to let the program have SOME use even without a connection if feasible, but a much higher utility when the connection is available -- and the access to that "higher utility" would require some form of payment to work. A subscription-model might work best -- a sales-model appears to offer better initial cash-flow, but, as your expenses to maintain and update the online service are mostly ongoing rather than up-front, it creates a cost/revenue models mismatch which spells eventual problems IMHO -- subscription is a better way to go, and it's *HARD* to *TRANSITION* to it if you start out with sales instead... though it's doable [we did it!-)], you're better off starting with the right business model at once... Alex From mwh at python.net Wed Jun 27 13:05:57 2001 From: mwh at python.net (Michael Hudson) Date: 27 Jun 2001 18:05:57 +0100 Subject: PEP 260: simplify xrange() References: <3B398BBE.A2D455C9@darwin.in-berlin.de> <9hclc1$qv5$1@panix2.panix.com> <3B3A08B5.3C142546@darwin.in-berlin.de> Message-ID: Dinu Gherman writes: > Aahz Maruch wrote: > > > > >PS: BTW, why not *add* something useful and make float > > > increments work "as expected" in range/xrange...? > > > > And how do you expect floating point increments to work? (Have you paid > > any attention to the extensive threads on FP over the past few months?) > > No, I haven't followed the discussion... but you asked > about an implementation; I'm using the one below. > >>> len(frange(0,1.,0.1)) 11 >>> len(frange(0,1.,0.2)) 5 Cheers, M. -- I have gathered a posie of other men's flowers, and nothing but the thread that binds them is my own. -- Montaigne From aleaxit at yahoo.com Wed Jun 6 18:47:17 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 7 Jun 2001 00:47:17 +0200 Subject: tokenizer.. References: Message-ID: <9foj3q01dic@enews1.newsguy.com> "John" wrote in message news:fhxT6.245523$Z2.2804247 at nnrp1.uunet.ca... > Hello, > > Is there a built in function or module which allows me to get tokens > from a string? The .split() method of strings is good for many purposes (but doesn't respect many definition of "tokens" -- still, it does work just as well as c's strtok:-). > I know there's the tokenize module but that needs a callable object and it > seems to loop forever... Is it so bad after all...? D:\py21>python Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. Alternative ReadLine 1.1 -- Copyright 2001, Chris Gonnerman >>> class ReadOneLine: ... def __init__(self,data): self.data=data ... def __call__(self): ... result = self.data ... self.data = '' ... return result ... >>> import tokenize >>> tokenize.tokenize(ReadOneLine('''"Hello", said Bill, "what's up?"''')) 1,0-1,7: STRING '"Hello"' 1,7-1,8: OP ',' 1,9-1,13: NAME 'said' 1,14-1,18: NAME 'Bill' 1,18-1,19: OP ',' 1,20-1,32: STRING '"what\'s up?"' 2,0-2,0: ENDMARKER '' >>> class Accum: ... def __init__(self): self.toks=[] ... def __call__(self, tp, st, *junk): self.toks.append(st) ... >>> ac=Accum() >>> tokenize.tokenize(ReadOneLine('''"Hello", said Bill, "what's up?"'''),ac) >>> ac.toks ['"Hello"', ',', 'said', 'Bill', ',', '"what\'s up?"', ''] >>> Alex From m.bless at gmx.de Mon Jun 4 08:55:55 2001 From: m.bless at gmx.de (Martin Bless) Date: Mon, 04 Jun 2001 12:55:55 GMT Subject: How to unpack data to unicode string? Message-ID: <3b1b7e04.5677574@news.muenster.de> How do I unpack pieces of data into unicode strings? Here's why: I'm doing a bit of analyzing TrueType files. (BTW, there's some good information at www.microsoft.com/typography). There can be chunks of unicode data inside truetype files which I can extract via slicing: rawText = data[start:end] Now, how do I do the transformation of rawText '\x00N\x00o\x00r\x00m\x00a\x00l' -> u'Normal' ? I don't have an idea of how to do it 'state of the art', so currently I'm using this little hack: def makeUnicodeString( s): result = u'' i = 0 while i u'Normal' ? Martin From emarkp at CSUA.Berkeley.EDU Tue Jun 19 14:01:32 2001 From: emarkp at CSUA.Berkeley.EDU (E. Mark Ping) Date: Tue, 19 Jun 2001 18:01:32 +0000 (UTC) Subject: paths: sleeping at the wheel References: <3B2F7682.D5C65F3@abaqus-sn.com> <9gnv9d017e3@enews2.newsguy.com> Message-ID: <9go41s$27k4$1@agate.berkeley.edu> In article <9gnv9d017e3 at enews2.newsguy.com>, Alex Martelli wrote: >If you want to write down the specifications for the new >requested features, it could go into a PEP How about: Same behavior as for 'perl -S' (use path to find scripts) -- Mark Ping emarkp at soda.CSUA.Berkeley.EDU From gherman at darwin.in-berlin.de Wed Jun 27 13:34:55 2001 From: gherman at darwin.in-berlin.de (Dinu Gherman) Date: Wed, 27 Jun 2001 19:34:55 +0200 Subject: PEP 260: simplify xrange() References: <3B398BBE.A2D455C9@darwin.in-berlin.de> <9hclc1$qv5$1@panix2.panix.com> <3B3A08B5.3C142546@darwin.in-berlin.de> Message-ID: <3B3A193F.AAFB31D5@darwin.in-berlin.de> Michael Hudson wrote: > > >>> len(frange(0,1.,0.1)) > 11 > >>> len(frange(0,1.,0.2)) > 5 So what? Dinu From ahenshawatapowerdotcom Fri Jun 15 23:10:43 2001 From: ahenshawatapowerdotcom (Andrew Henshaw) Date: Fri, 15 Jun 2001 23:10:43 -0400 Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> Message-ID: "David LeBlanc" wrote in message news:9gbsdv$8ft$9 at 216.39.170.247... ...snip... > > As for the distinction between const(ant) and alias: Perhaps it's a > matter of aesthetics, but somehow alias is more descriptive then const > since it suggests the substition that's happening. Further, it's > incorrect to call "alias true: not 0" a constant imho. To further > belabour (with a tip of the hat to the english cousins) the point, it > read so nicely to be able to say "if something is true" rather then "if > something is not 0" (saves on typing too :-)). > ...snip... Speaking of aliasing... I fondly recall Occam's method of aliasing. With Occam, one can alias array slices so that working with message packets is extremely easy. For instance, one can alias (e.g. "lastName") a slice [16:32] of an Occam array of bytes "byteArray" with: lastName IS [byteArray FROM 16 FOR 16]: and then use lastName as a new array name. Then the first byte can be referrenced with: lastName[0] := 'a' This, of course, will change the 17th byte in byteArray to 'a'. Multidimensional arrays can be sliced and aliased, also -- very convenient, efficient, and clear. Aliasing could significantly improve the efficiency of a program running on the Inmos Transputer, as its instruction set favored small index offsets, and the aliasing lets the compiler know how to do that. This would be nice on Python as well, particularly since naming a list slice actually creates a copy (perhaps I've missed some capability here). From see at my.signature Tue Jun 19 01:39:21 2001 From: see at my.signature (Greg Ewing) Date: Tue, 19 Jun 2001 17:39:21 +1200 Subject: New statement proposal for Python References: Message-ID: <3B2EE589.91065ED5@my.signature> Tim Peters wrote: > > Almost all Python code "spells a constant" via > > UPPERCASE_NAME = some_expression > > and in 10+ years of Python practice I've never rebound such a name by > accident -- or heard of anyone else doing so either. I second that. However, I think there's another issue related to this: sometimes I'm discouraged from using named values like this because of the relative inefficiency of looking up globals as opposed to locals. Having a "const" syntax would be one way of addressing this, since the compiler would have opportunities to optimise. Instead of introducing a new syntax, however, I'd rather see some work done on the implementation of module namespaces to make them more like local namespaces are now -- i.e. so that names the compiler knows about are accessed by indexing into an array instead of looking up a dictionary. I think this would be a much more worthwhile investment of effort, since it would benefit *all* accesses to globals, not just "constant" ones! -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From sill at optonline.net Thu Jun 14 05:26:41 2001 From: sill at optonline.net (Rainy) Date: Thu, 14 Jun 2001 09:26:41 GMT Subject: Pure Python mini-DB and NCurses References: <4a7fde99.0106140057.1e2fb285@posting.google.com> Message-ID: On 14 Jun 2001 01:57:03 -0700, Ryan wrote: > I have been trying to figure out how to make a small database with the > shelve module, but either the interface to update it is beyond me or > I'm just not grocking some small attribute. I realize that a real DB > would be more functional in most cases, but I just want to make a > small contacts list program that I can run on the workstation and on a > handheld, so I'm trying to make it so the db file can be imported from > one to the other and updated. > > As for the ncurses I'm just trying to figure out why it would be used. > If anyone has a reason other than novilty I would appreciate it as I > can't understand what Guido was thinking when he put it in. I'm not sure I got your question right, but ncurses are useful for all kinds of console applications where you need windows, such as irc clients, news clients, mail clients, text editors and so on. -- Lucifer Sam Siam cat Always sitting by your side Always by your side That cat's something I can't explain - Syd From whisper at oz.nospamnet Sat Jun 16 00:00:03 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 16 Jun 2001 04:00:03 GMT Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> <9gclvm02tte@enews1.newsguy.com> Message-ID: <9gelk3$324$2@216.39.170.247> Alex; Thanks for your response! In article <9gclvm02tte at enews1.newsguy.com>, aleaxit at yahoo.com says... > "David LeBlanc" wrote in message > news:9gbsdv$8ft$9 at 216.39.170.247... > ... > > alias where (argument) substition is done! At least conceptually the body > > of a function replaces it at invocation time.) > > Fortunately ***NOT***!!! Such a horrible "conceptual" > choice for a function-execution model would put pay to > any chance of *RECURSION*. Actually so, in fact some languages do just that as a performance enhancer, but not worth arguing - nor does it address the original point. Arguing against an aside isn't useful. BTW, i'm not english, but I believe the expression is "put paid to". I think it came from the days of wooden ships when seams in the hull where "paid" (stuffed) with oakum and tar. Hmmm.. maybe that's where the expression "get stuffed" came from but I digress ;-) (NOT meant personally .) > > read so nicely to be able to say "if something is true" rather then "if > > something is not 0" (saves on typing too :-)). > > Such "read so nicely" tests would of course not work as > expected (with or without alias). The object None, for > example, evaluates as false, but if you test its identity > with 0, you will of course find they're not *identical* > (how COULD they be -- they're different in every respect, > the ONLY thing they have in common is evaluating as false!). Introducing alias does not introduce immunity to incorrect programming. It does make easier to correct one line that's substituted 1,000 times then it is to substitute all 1,000 lines you did in error. > It seems to me that the LAST thing we need is encouraging > "read so nicely" forms that do NOT do what a naive newbie > might expect. It is absolutely fundamental that the > newbie learns to write his/her logical tests as: > if something: > ... > and > if not something: > ... > and *NOT* > if something is 1: > ... > or > if something is 0: > ... > or any "aliases" of these flawed forms. If "naive newbie" makes a programming error he/she is going to make a programming error whether or not alias is present. This helps, it does not guarantee that you won't make mistakes. > > Other suggestions to import large libraries or make modules instances are > > not things calculated to gladden the heart of a newbie who seeks > > simplicity, > > The module-instance (the const.py example I gave) would of course > be made by a NON-newbie, the newbie would just USE it. Why would > "a newbie who seeks simplicity" consider: > > const.magic = 23 > > less simple than > > alias magic : 23 It's not less simple - nor is it more complex. Your forgot the "import const" bit needed for your part unless one does what you suggest and manually add it to the default libraries (which then is loaded by every program - I don't know if Python does "lazy loading", so this might not be a valid arguement). What fun for a newbie! The thing that an alias does address that your method does not is that if the newbie does "const.magic = 23" and then he/she imports some nice module, he/she is not going to be confused by the imported module's changing the value of magic... > ?!?! The former uses exactly the same syntax as any other binding, > requiring the newbie to learn absolutely no new syntax. The latter > requires the newbie to learn one more "simple keyword-statement", with > a syntax totally different from that of all OTHER simple keyword > statements. It seems to me that your claim that all of the extra > conceptual and syntactical baggage FAVOURS simplicity, when common > sense suggests extra baggage REDUCES simplicity, is an extraordinary > claim, and thereby requires extraordinary proof. What "simple keword" syntax are you referring to? It does follow the idea of key : value in dictionaries and that many other statements have one part separated from another by a colon. > > nor would the code enlargement (my aren't I diplomatic ;)) > > win the approval of an experienced developer who doesn't want to search > > exteraneous lines when a bug pops up - which is statistically more likely > > What "code enlargement" are you talking about? Which "exteraneous" (?) > lines? In a script using "module const" there may or may not be a > single line > import const > for explicitness (the alternative is having it performed implicitly > at startup, e.g. by sitecustomize.py &c &c, placing const in the > __builtin__ module, of course). That's up to the "experienced > developer" who decides constants are necessary at his/her site. Heaven forefend the newbie using what is generally considered good programming experience from the start. Let them develop the bad habbit of using magic numbers and other obscurities and then, once the bad habbit is ingrained, introduce the idea of consts with meaningful names... Wow, wish i'd thought of that!. Maybe it was my mistake, but I was under the impression that one of Python's objectives was to be a teaching language. Better to teach good practice from the start isn't it? (Sorry, the word is "extraneous" - i'm a prgammer not a dictionary :). I actually do spend considerable time on longer posts proofing.) > > with more lines of code, not to mention the antics needed to do something > > that should be as simple as possible (imho). > > What "antics"? If you want 'const' to be activated by default > in every Python installation (e.g. in site.py), write a PEP > proposing just that. You DO realize, of course, that no matter > what little chance such a PEP may have, it IS going to be at > least a thousand times more likely to be adopted than anything > that will introduce a new keyword and thereby break perfectly > working code -- that's something that can *possibly* happen > only for really momentous developments (such as the new proposed > "yield" keyword-statement for generators) which DESPERATELY NEED > a new statement (can't POSSIBLY work halfway-decently without). Why? Is there something you know about how well new ideas are viewed by the core python team that I don't? I guess we'll never see the introduction of another Python keyword like... hmm... "do" since it might break perfectly working code? I'd be clever here and point out in Latin that languages that don't grow die... but I don't know Latin since it's dead! Frankly, while it might not be as DRAMATIC as GENERATORS, in it's own quiet way, *I* think it's just as momentuous. (As for "yield" - whatever does a generator need yield for? My understanding of generators is that they produce a new value based on retained state, not actually generate a huge sequence - oops, there I go digressing again.) I don't see this as anything as earthshaking as introducing nested scope which is going to cause far more problems in changing program structure (when it becomes the default) then changing the name of an identifier. Nor do I think that this is the first new keyword that was introduced since the inception of Python - of course, not having done the research to find 1.3 or earlier if they're publically available, I won't make such a bald statement. > > One can certainly argue that this is syntactical sugar. It does however > > serve a multitude of good purposes among which are: maintainability; > > clarity; consistancy; correctness; good programming habbits; - a not > > inconsiderable set of advantages for a little sugar. > > I fail to see ANY of these advantages when comparing your "alias" > with a "const" module installed by site.py. How is > alias magic : 23 > more maintainable, clearer, more consistent, more correct, or > a better programming habit than > const.magic = 23 > ?!?! Please bring SOME kind of argument for such extraordinary > assertions... your bald statements are not "support" for them! I suggest you read an introductory book on good programming practice. If you fail to see any of these advantages, then I shudder to think about your code quality. Seriously, please bring SOME kind of argument for saying that such notions are NOT a better programming habbit then... etc. How is your suggestion that a new user: 1. Figure out how to import a feature that's inherantly available in many other programming languages. 2. Make sure to not ever change any variable meant to be constant. 3. Figure out why the program won't work when const.magic magically changes because they imported a module that changed it without notice or warning. 4. How are you going to ensure that developers are going to indentify every "meant to be constant so don't use this identifier as a constant" constant that they create? Heck, you can't even get programmers to do comments reliably and that's built in now! Forstalling the obvious argument, of course there is nothing that ensures that any developer is going to practice safe programming and use an alias... this isn't meant to legislate against stupidity (who was that king that decreed that the tide not come in?) but rather to facilitate doing things more correctly. any better then what i've proposed? > > Finally, this wouldn't break any code, > > Puh-LEEZE. *ANY* use of 'alias' in existing code would be > broken. Let's not make such obviously-false assertions... Yeah, that was my error - of course anyone can use "alias" as an identifier. I refer you to my previous remarks with respect to changes in Python since the first version, above. At least, unlike the recent furor over changing the semantics of "print", this is new. > Alex Fred P.S If you're confused by "Fred", I changed my identifier - oops, did I forget to mention that in the docs? Dave LeBlanc From emile at fenx.com Thu Jun 14 19:24:27 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 14 Jun 2001 16:24:27 -0700 Subject: wrapping a C++ class References: <9gba7n$8jj$1@info1.fnal.gov> Message-ID: <9gbhao$89naj$1@ID-11957.news.dfncis.de> "Enrico Ng" wrote in message news:9gba7n$8jj$1 at info1.fnal.gov... > I am trying to wrap a simple C++ class like this: > I can't answer your question, but have you looked at http://www.boost.org/libs/python/doc/index.html -- Emile van Sebille emile at fenx.com --------- From dsh8290 at rit.edu Fri Jun 8 18:28:17 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 8 Jun 2001 18:28:17 -0400 Subject: How do you develop in Python? In-Reply-To: <3B2144C5.7FA3C7C4@home.net>; from chrishbarker@home.net on Fri, Jun 08, 2001 at 02:33:57PM -0700 References: <050620011516094693%pecora@anvil.nrl.navy.mil> <9fjfer$gt0$1@nereid.worldonline.nl> <3B2129AC.90BA8650@home.net> <9frc6v$b20$1@nereid.worldonline.nl> <3B2144C5.7FA3C7C4@home.net> Message-ID: <20010608182816.D19076@harmony.cs.rit.edu> On Fri, Jun 08, 2001 at 02:33:57PM -0700, Chris Barker wrote: ... | Gerrit, you and I are on the same page here, but for some reason, the | ability to run a program "from scratch" doesn't seem to be important | enough to the IDE developers for them to put the work into making it | possible. I think that's because it is a lot of work. Some people just use gvim and an xterm (or just emacs) and thus run a program "from scratch" all the time with no trouble. It might be easier for you to open a shell (MacOS X has one) and run your program from the shell, though do development in the IDE. Just a thought on another alternative... -D From michael at trollope.org Sat Jun 23 14:15:31 2001 From: michael at trollope.org (Michael Powe) Date: 23 Jun 2001 11:15:31 -0700 Subject: NT Service and COM References: <9gu4nf$553$1@troll.powertech.no> Message-ID: <87elsb2hbw.fsf@cecilia.trollope.org> >>>>> "Duncan" == Duncan Booth writes: Duncan> I have got a COM server working as a service now. The only Duncan> problem left is security. If the service runs under my Duncan> userid everything works fine, but if I install the service Duncan> as the local system user (i.e. the default) then Duncan> attempting to access the COM object throws a com error Duncan> 'Access is denied'. Give it its own userid and put it in the admin group or whatever lesser group might be appropriate. The local system user has limited rights, in order to protect system security. Duncan> I'm not sure how to get round this. I can use DCOMCNFG to Duncan> give access, but I feel I should be able to set the Duncan> security from inside the process. Unfortunately I cannot This would be a horrible security weakness if it is allowed. What's to stop somebody from cracking a process and having it reset its own security to, say, 'administrator' and having fun with the system? mp -- Michael Powe Portland, Oregon USA 'Unless we approve your idea, it will not be permitted, it will not be allowed.' -- Hilary Rosen, President, Recording Industry Association of America From hbn at imada.sdu.dk Sun Jun 3 11:11:09 2001 From: hbn at imada.sdu.dk (Henrik Berg Nielsen) Date: Sun, 3 Jun 2001 17:11:09 +0200 Subject: Copying files to multiple comp's on a lan References: <9f8k3v$1i04$1@news.cybercity.dk> <9fbmbk$2acl$1@news.cybercity.dk> <3B198B17.3060409@ActiveState.com> Message-ID: <9fdk22$1c99$1@news.cybercity.dk> Hi again, I got the win32all as Mark suggested and everything works like a charm now! Just one more question: Is it possible to cmd_string = "copy %s %s" % ("\\Machine1\C\temp\foo.txt", "\\Machine2\C\temp") os.system(cmd_string) when I am sitting and issuing the command from Machine0? I'd like to design the script so that it copies the file to/from multiple comps at one time, not just from the source to all the other machines one at a time seperately, but more like: Step 1: copy from comp0 to comp1 Step2: copy from comp0 to comp2 copy from comp1 to comp3 Step3: copy from comp0 to comp4 copy from comp1 to comp5 copy from comp2 to comp6 copy from comp3 to comp7 and so on and so on... where comp0 would be the initial source Is this possible at all? Doing it this way would make better use of the network, its switched, so collisions should be a problem, although the traffic will be immense if I'm disting a 700 MB file. All for now, Henrik Berg Nielsen "Mark Hammond" wrote in message news:3B198B17.3060409 at ActiveState.com... > Henrik Berg Nielsen wrote: > > > programming). So far I haven't been able to access file on the remote > > machines via the open() method. What should I write if I wanted to access > > the file called "foo.txt" located in the "temp" folder on the C drive of the > > machine named "Orion"? > > > In general, you need to know how the C:\TEMP directory is "shared" by > the machine "Orion". If you have administrator rights, you will > probably find that: > r"\\Orion\c$\temp" > > will work. In general, whatever string you can pass to the command > prompt's "dir" command to see the file can be passed to open(). > Remember that Python sometimes requires backslashes to be doubled - > hence my r"..." notation above - it uses raw strings which do generally > not need slashes doubled. ie, without raw strings, you would need to > say "\\\\Orion\\c$\\temp" > > If you don't have access to the 'C$' share, then you need to investigate > the specific settings for the specific server. There are some obscure > ways to determine this stuff programatically, but let's get the simple > things working first :) > > > > I like the approach more where I let os.system() do the copying for me, but > > it really doesn't work all that good if I can't assemble the proper network > > paths. > > > Experiment with assembling the paths from the command prompt. > > > On a side note; what does os.sytem() do specifically? > > > Executes the command - almost as if you typed the command from a DOS prompt. > > > Also I tried "import win32api, win32file, win32net" and it can't find > > neither of them, should I install these seperately or what? (plz don't laugh > > :)) > > > You probably need win32all from > http://aspn.activestate.com/ASPN/Downloads/ActivePython/Extensions/Win32all > > If you installed ActivePython itself, they should all be there already. > > Mark. > From b.e.n. at .r.e.h.a.m.e...c.o.m Mon Jun 11 03:15:30 2001 From: b.e.n. at .r.e.h.a.m.e...c.o.m (Ben) Date: Mon, 11 Jun 2001 17:15:30 +1000 Subject: import sys.argv[1] Message-ID: Hi all, this must have been a situation that lots of people have come across so there has to be a work around for it. If I define via a command line arg what module(s) needs to be imported how do i then pass this to the import statement without the import statement taking sys.argv[1] literally? Thanks Ben From see at my.signature Tue Jun 12 01:56:52 2001 From: see at my.signature (Greg Ewing) Date: Tue, 12 Jun 2001 17:56:52 +1200 Subject: Python Shareware? References: Message-ID: <3B25AF24.EAC22242@my.signature> Will Ware wrote: > > Publish an initial version for free and > place it in the public domain. But then there's a chance that other people will fix the bugs and add the new features that you would have done, so you won't get any money. It might be safer to release it with a "use-but-don't-modify" kind of license instead. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From phd at phd.fep.ru Sat Jun 2 07:00:27 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Sat, 2 Jun 2001 15:00:27 +0400 (MSD) Subject: Executing a shell command In-Reply-To: <9f901k$ffa$1@mtc1.mtcnet.net> Message-ID: On Fri, 1 Jun 2001, Kevin Riggle wrote: > Is there any way to take a command in a string in Python, execute it in the > shell, and read the output into a variable of some sort, like pipe = os.popen(command, 'r') data = pipe.read() pipe.close() Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From aleaxit at yahoo.com Fri Jun 15 07:47:39 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 15 Jun 2001 13:47:39 +0200 Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gb41r0s6p@enews1.newsguy.com> Message-ID: <9gcslc05fc@enews1.newsguy.com> "Nick Perkins" wrote in message news:GfeW6.237297$eK2.50503927 at news4.rdc1.on.home.com... > ..nicely done, Alex! Thanks! > ..but what is your opinion as to whether this functionality belongs in the > language itself? Neutral. I don't think it would do Python any irreparable harm if the standard site.py included 6 more lines to install a suitable instance in sys.module['const'], but it's hardly a key issue IMHO. > Those coming from other languages are likely to expect to have constant > values of some sort. Those coming from other languages expect all sort of things which their previous languages "offered" to them. Implicit scoping in methods (rather than explicit self.whatever references), magical calling of superclasses' __init__/__del__ (if from C++ -- not if from Java), ability to call functions without parenthesis (if from Visual Basic up to 6 included -- removed in VB 7), implicit change of strings to numbers and back (if from Perl or Visual Basic, not if from C++ or Java), mandatory and/or optional declarations of variables and/of their types, class methods (with very different semantic expectations if they come from Smalltalk or rather from C++ or Java), macros (again, very different expectations if from C, or Scheme, or Common Lisp), "reference" parameters (implicitly, if from Fortran or some versions of VB -- at least as an option, if from C++ or other versions of VB or Pascal), private and/or 'friendly' and/or protected members (if from C++ or Java or Eiffel, at least), a baseclass common to all objects (if from Java or Smalltalk, not if from C++), unnamed codeblocks (if from Smalltalk or Ruby), named break/continue (if from Java or Perl)... Oh, and, last but not least -- braces and/or begin/end, OF COURSE!-) I COULD go on writing for hours and hours, of course, just in listing all the things that those coming from other languages are "likely to expect". If Python had 1/10th of such variously "expected" features, it would be a bloated, unwieldly, unusable monster. Of course, every paladin of one such change resolutely refuses to look at the overall picture -- *HIS* change (or, in theory, "hers" -- but I have not witnessed female proponents of such changes, yet:-) is the one that matters. "Yeah, right". Guido has proved for over a decade that he does an insanely great job in triage of such risk-of-featuritis, so most sensible people have long given up on the Sysiphean task of explaining to the endless stream of change-proponents how and why their desires can already be well met in Python, or how and why they are best left unmet. Those which CAN be well met (a large majority) often involve some tiny device -- a few lines' worth of class or function -- and it is hopefully well known that any site can easily decide to make such things "built-in" by tiny mods to site.py (or, better, siteconfigure.py), while of course packages that are to be distributed which rely on such devices can in turn distribute the devices themselves as well. Only an EXTREME minority of such features could or should be mandated as built-in for ALL sites forever -- else, Python would again bloat, albeit not strictly speaking on the language-side of things. Special syntax-sugar (which is an extremely frequent request) for any such feature is, of course, MOST unlikely to get into the language -- thanks be. Any syntax sugar whatsoever for const.goo would be a total, utter, unrelieved, unPythonic horror, IMHO. Having 'const' bundled in the default site.py would be no horror. Probably not the wisest single thing to add out of all the huge list above (which is only a little and very partial list of typical desiderata stemming from other languages), but not the least-wise one either. One (IMHO) Python enhancement would be to give dictionaries some finer-grained control on their degree of mutability. The ability to selectively make SOME existing keys non rebindable and/or non removable _would_ come in handy in quite a few places ('constants' included), as would the related ones of locking a dictionary against addition of new keys. Since ALMOST all Python namespaces are in fact dictionaries (local-variables of functions being the signal exception), such locking would give the basic semantics for several desirable tricks. But that's a whole 'nother issue, would offer no new "pretty" syntax sugar anyway, and thus would most likely be of no interest whatsoever to most typical change-proponents. > Your solution looks great, but still you have to type "const.foo" instead of > just "foo". Right! That's what makes it *Pythonic*. No messing about with the semantics of identifiers. > How much run-time overhead does this involve? I suppose only a tiny amount, > and perhaps no more than even a 'language-level' implementation would have, > but I think I would probably not use this in my most-inner loops. If your innermost loops are in functions, copying whatever values you're using in the depth of the loop to local variables of your functions IS likely to offer you a pretty good speedup. This includes functions you are calling, by the way, as well as methods you're calling, &c. But -- don't optimize prematurely... it's a losing approach! > I suppose one could always bind a local name to the value.. > width = const.width > ..but then 'width' is no longer constant, and can be changed at will. Local variable 'width' never was constant, so 'no longer' is a strange word-choice (it seems to imply that once upon a time it was?-). But if you're talking of an inner-loop, you're talking of a few lines of code, so where's the risk? Alex From chris.gonnerman at newcenturycomputers.net Fri Jun 29 09:07:15 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Fri, 29 Jun 2001 08:07:15 -0500 Subject: PEP scepticism References: <3dels41dhs.fsf@ute.cnri.reston.va.us> Message-ID: <002501c1009c$70211900$0101010a@local> ----- Original Message ----- From: "Guido van Rossum" > Andrew Kuchling writes: > > > No it isn't. Adding language features does not improve the confusing > > and incomplete MIME modules currently in the standard library. > > Barry Warsaw is working on mimelib (http://mimelib.sourceforge.net/) > and I expect that this will be added to the 2.2 CVS tree soon! That's good news! > > My point is that users are not currently saying "Gosh, Python > > doesn't have generators, so I won't use it." They're saying "Wow, > > there's a lot of useful libraries for Java; I'd better use it to be > > able to use them." > > Point taken. I'll second this motion. List comprehensions, iterators, generators, etc. are all cool, but frankly I stopped *needing* new language features around 1.5.2 to 2.0, and most of the Python I write will run in 1.5.2 just fine. On the other hand, I'm always happy to find a Python module to do something for me so I don't have to, and I spend considerable time looking for them... From bob at passcal.nmt.edu Fri Jun 8 16:54:19 2001 From: bob at passcal.nmt.edu (Bob Greschke) Date: Fri, 8 Jun 2001 14:54:19 -0600 Subject: Passing back an array from an extension module? References: <9fqqqo$1p3e$1@newshost.nmt.edu> <9fr8mp$219g$1@newshost.nmt.edu> Message-ID: <9frdtl$25gh$1@newshost.nmt.edu> Hmmm...I was wrong. Creating a tuple object, then creating long objects and adding them to the tuple 1,600,000 times doesn't take very long. On the order of about 5 seconds (on a Sun Ultra10). But it takes it about 10 seconds if I do the same thing a 2nd, 3rd, 4th, etc. time. Is it leaking memory, or is it just taking that long to garbage collect the old tuple? There is a lot of more disk activity on the sebsequent runs than there is the first time through. Bob "Bob Greschke" wrote in message news:9fr8mp$219g$1 at newshost.nmt.edu... > "This" is an array, but it doesn't look like I can either pass an > array object to the C extension module, and pass an array back to the > Python code, or create an array in C and pass it back to the Python > code. I don't see anything in the Format Specifiers lists for > PtArg_Parse() or Py_BuildValue() functions to handle arrays. However, > I do see C functions (Low-Level Functions on Built-in Types, Python > Essential Reference, pg 261) for creating tuples in a C function, and > then functions for creating long integers, and then functions for > adding items (_SetItem) to a tuple, and then the ability to pass back > an 'any object' in Py_BuildValue (the "O" format specifier). Is that > a sensible thing to do? It feels like it would chew up too much time > given the amount of data involved. > > > "Martin von Loewis" wrote in message > news:j4ae3iev04.fsf at informatik.hu-berlin.de... > > "Bob Greschke" writes: > > > > > Then I need to pass that back to the Python side for graphing > > > the values. I initially thought I could just create a tuple and > pass > > > that back, since nothing is going to be done with the values > except to > > > draw a graph, but there is the possibility of there being > 16,000,000 > > > data points...that makes for a slightly large statement, doesn't > it? > > > It doesn't look like I can do this with arrays in stock Python, > but it > > > does look like I can do it with the NumPy arrays. Is that > correct? > > > > Not sure what 'this' is here. You certainly can create 'custom' > array > > types in Python, see Modules/arraymodule for an example of an array > > type that is implemented using a C memory buffer of primitive C > > values. > > > > I don't know whether you can use a NumPy array off-the-shelf; I > assume > > no since it probably manages its own memory. > > > > So you need to create a new type (see xxmodule.c for an example), > and > > implement its tp_as_sequence slot. > > > > > Now what about Py_DECREF, INCREF and all of that stuff in these > > > situations? I read through a number of posts on dejagoogle that > were > > > talking about this, but they only confused me more. :-) > > > > I recommend you read the "Embedding and Extending > > tutorial". Basically, you need to implement an array accessor, which > > creates and returns a PyInt_FromLong every time you access the nth > > element of your array. When the reference counter of your Python > > wrapper object drops to zero, you should free(3) the memory of the > > very large array. > > > > Regards, > > Martin > > > > From bokr at accessone.com Fri Jun 8 13:57:18 2001 From: bokr at accessone.com (Bengt Richter) Date: Fri, 08 Jun 2001 17:57:18 GMT Subject: floating point in 2.0 References: Message-ID: <3b20e8ea.134863833@wa.news.verio.net> On Fri, 8 Jun 2001 00:29:11 -0400, "Tim Peters" wrote: [...] >Very good advice indeed. What if they're accumulating in double instead? >Without reliable access to double-extended, I'm afraid we're left with >obscure transformations. For most Python users, I expect decimal f.p. with >user-settable precision is going to be much easier to use. > Perhaps too easy? ;-) I am not sure "user-settable precision" will be clear enough a concept for most. Will they understand exactly what is guaranteed by a given setting? Will you be able to explain it to them? E.g., will the setting say how many fractional decimals to carry, or how many significant digits in all? Will the implication be that inputs are to be considered as having possible errors of +/- 0.5 times a one in the least significant input digit position? Should interval arithmetic be used to track the bounds of possible errors through computation, and an optional exception be thrown if output formatting demands more figures than are accurately available? Or if an intermediate result becomes too imprecise? How many appreciate the difference between probable errors in data itself and errors in representation of data, and how the two are transformed and intertwingled in algorithms? Would (value,tolerance) be a more intuitive way to specify precision (indirectly) than decimal precision in some cases? Perhaps it would be useful to look at the problem in terms of actual assertions one might like to be able to write concerning values and their representations? E.g., something that says that printing "10.0" after computing the sum of 100 ".100" values is (barely) ok, but warns you that "10.0000" is illusory. BTW, I had another little idea ;-) tying this into formatting of objects: If class Quantity defined __str__ with an optional second argument, then the % operator could pass the relevant slice of the format string along with the object's "self" to the __str__ method and you'd have open-ended formatting capability. E.g., "%20.3.7s" % ( x,) would make the effective call x.__str__('20.3.7') to get the formatted representation. This example might be radix-7 printed 20 wide with 3 septimals(?). Or it could be 20 wide with 3 decimals verifying 7-digit precision of the representation. Or anything you might like to encode between the '%' and 's'. If you wanted to be able to pass about any control string, you could allow a quoting delimiter like "%'special stuff's ..." or maybe bracketing delimiters: "%[special stuff]s ..." etc. (Please excuse if I am re-inventing a Python wheel. This seems like one of those things you might already have done in some form to handle formatting). From aahz at panix.com Sun Jun 17 09:38:13 2001 From: aahz at panix.com (Aahz Maruch) Date: 17 Jun 2001 06:38:13 -0700 Subject: Any other Python flaws? References: Message-ID: <9gibs5$mee$1@panix2.panix.com> In article , Michael Chermside wrote: > >def __None(): > pass >None = __None() > >I guess I better start putting that at the top of all my modules as >defensive programming <1.0 wink>. import foo foo.None = 1 -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "It's not what you know, it's what you *think* you know." --Steve Martin From dsh8290 at rit.edu Fri Jun 1 16:56:26 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 1 Jun 2001 16:56:26 -0400 Subject: Iteration index In-Reply-To: ; from tim.one@home.com on Fri, Jun 01, 2001 at 04:46:31PM -0400 References: <20010601161843.A8040@harmony.cs.rit.edu> Message-ID: <20010601165626.A8085@harmony.cs.rit.edu> On Fri, Jun 01, 2001 at 04:46:31PM -0400, Tim Peters wrote: | [D-Man] | > What is the difference between a "vector" and an "array" in this | > context? (Not as in void[] or void* vs. std::vector< void* > ) | | Beats me -- what do those words mean to *you*? Then you can explain the | difference yourself . I usually use them as synonyms. I was also thinking of Object[] (array of objects) and java.lang.Vector. Now that I know you consider them as synonyms you won't confuse me any more by causing me to wonder what a vector in C is. | > I took a look at listobject.c and liistobject.h and I see that the | > list itself is just a PyObject** -- a pointer to a C array on the | > heap. I also noticed in the 'ins1' function that inserting an | > element (not at the end) causes all others elements to be moved. | > Isn't this pretty inefficient or is it such an infrequent | > operation that it matters less than the O(1) PyList_GetItem? | | Dozens and dozens of Kbs of discussions about this were posted to | c.l.py over the last 7 days. Oh, I missed that discussion. I kill-thread anything whose subject doesn't immediately strike me as interesting. Thanks, -D From jajvirta at cc.helsinki.fi Mon Jun 11 05:17:12 2001 From: jajvirta at cc.helsinki.fi (Jarno J Virtanen) Date: 11 Jun 2001 09:17:12 GMT Subject: What "Tim Peters" really looks like Message-ID: I've actually seen "Tim Peters" live. "He" was walking with Guido in the XXXXXXXXXXX park in XXXXXXXXXXX. I didn't have a camera with me, but I did do a drawing of the scene. For only a short period of time was "Tim Peters" visible, so all the nuts and bolts may not be exactly in their place. Here's the picture: http://www.hole.fi/jajvirta/gandtim.jpg (There's also the conversation I heard at the time of the scene.) Shortly after the incident I was captured and send to the XXXXXXXXXXX star system near the XXXXXXXXXXX star. I managed to send the above mentioned picture and this message by stealing some bytes from the stream they're sending from here to Earth. They seem to have some horrible and evil plan for From tgos at spamcop.net Tue Jun 5 18:51:06 2001 From: tgos at spamcop.net (TGOS) Date: 5 Jun 2001 17:51:06 -0500 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3B1B1825.8109BA83@lmf.ericsson.se> <2v4ohtgldvce84sn87kh1eg1lnes37getq@4ax.com> <3B1C9E65.B73A4FE@lmf.ericsson.se> Message-ID: On Tue, 05 Jun 2001 11:55:01 +0300, Attila Feher wrote: > TGOS wrote: >> On a WinNT system of a company (for that I was doing some network >> installation is part time job), it took me less than 24h. > > No SPs applied... I can't tell which SPs were applied and which ones not. It was not even a program of a cracker page, I got it from the webpage of a computer magazine. That was still some time ago, so maybe the SP was too new at that time and they had no time to apply it. But I can't remember that such a big security hole ever existed for any known UNIX system. But I'm afraid I'm talking about apples here and you about pears. Let's define what is meant by "OS". For me an OS is just the basic system, all that is needed to get the system run and no all that might be installed on a system. So when I say UNIX is more secure than Windows, I mean UNIX itself, which is the kernel, hardware driver, software drivers (like file systems) and the programs that are absolutely necessary. When installing a UNIX system that shall be secure, you should disable everything during installation that can be disabled (including server software, XServer, etc.). A XServer for example is such a big security hole, that you can push a whole elephant through it and nobody would recognize it ^_^ And exactly that's the problem. Even when you disable everything possible during Windows installation, you are still forced to install way too many stuff. Can you install WinNT without GUI? Since every GUI might be a security hole and every GUI wastes hardware resources (especially on servers that don't even have a monitor). I bet the standard settings of Win2000 installs DirectX as well and I was once told (from a usually very reliable source) that DirectX is allowed to circumvent many Win2000 security features to achieve higher speed. Isn't the InternetExplorer integrated into Win2000's system? And certainly also into WinXP. The InternetExplorer is full of security bugs and when it supports something like VBS, goodbye system. No browser is integrated into UNIX systems, every GUI is optional. Only looking at those facts, it should be clear that Windows is less secure. And you must be careful when speaking about UNIX security holes. One of the biggest security holes of all times was (or maybe still is) SENDMAIL. It needs root rights to run correctly and that is a danger. You can intentionally crash it (e.g. provoking a stack overflow and that way executing own code) and such a crash can result in a new shell with root rights. That was one of the easier ways to get root rights and immediately everyone said: "Look, UNIX isn't secure at all!" But those people seem to overlook that SENDMAIL is a program, not part of the kernel and not part of the UNIX OS. For this security hole are only programmers of SENDMAIL responsible, not the UNIX programmers. Despite the fact that I've seen alternatives to the standard SENDMAIL, I'm currently running a LINUX system without any SENDMAIL application at all. (That way programs can't send me notifications via mail, but I don't really care) Looking at a full featured UNIX system, it's of course not more secure than a Windows system. I'm only comparing two base systems where no third party software is installed and there, UNIX *is* more secure than Windows. > There are VMSes on universities and don't think > people don't try to get into them :-))) I don't know, but I think most people aren't interested into cracking an university server. I personally only try to get root access for the fun of it (I wouldn't even know what do with it). BTW, looks like today is a "happy day" for you. ( Lot's of ":-)))") > Same with NT. I have seen NT setup taking few thousand steps to make > and which was solid as a rock. See above, there are too many things you can't remove/exclude of a Windows installation that provide security holes. You simply can't remove things that are a permanent part of the system and when you compare Windows to UNIX under this point of view, a LINUX system can be tiny enough to fit onto a single floppy disc, a UNIX distribution might as well (when you have 2.88 MB floppies)...how about WinNT? So I guess now you understand my point of view and on what base I'm arguing when claiming that UNIX is more secure than Windows. > So the primary decision is: is my target group UNIX or Windows or both. If you get a UNIX version, you can also make it run on Linux. And the main difference between UNIX and Windows are the APIs. But for whatever you have an API call at UNIX, there's also an API call in Windows. I personally like the system of "wrappers". You neither use UNIX or Windows APIs directly. You create your own wrapper API, that in once case is wrapped around the UNIX/Linux APIs and once around the Windows APIs. That means you don't have to rewrite a single line of C++ code of your application, you must create wrapper APIs for every system you like to support. >> Yes and wanna bet that I can find someone who can crack such a terminal in less >> than two hours. I bet if this terminal would run with Linux or maybe with >> FreeBSD that wouldn't be that easy. > > And? You have cracked the terminal. No, I'm not good enough for that. But in my subway station is a ticket machine that runs with Windows and I know how to crash it, so it has to reboot (it's only Win9x and it's very easy to crash). If I would be a hacker, I'd be able to make use of this fact and print thousands of free tickets. Despite this machine accepts debit cards, so it must be connected to some bank ... ^___^ Unfortunately I can only crash it, it will reboot, start an autostart application and continue to work. Without keyboard I can't manipulate it (there's only touch screen and a few buttons). > So you can start up the UNIX/VAX > terminal window and try to log in :-))) I wouldn't be even able to crash it and if this application is running as single task (with respawn option), what can you do? > Blue Screen cannot come from user SW. You can produce a blue screen using DirectX for example. > Than you must have a real good luck. I use Solaris here and I know what > I am talking about :-))) Reboot is once per day on a test machine where > "badly behaving" SW can run. Poor configuration? Our Solaris machines are UltraSparcs, probably configured by a Sun employee. > I have no problem with the security manager, I have problem with the > Java VM code. It isn't "old enough" and mostly not open source to > convince a security-fanatic. Windows as a whole ins't open source, nevertheless you trust in its security, don't you? ^_- Despite that, some parts are open source. >> My post is about the fact that every user should be free to chouse his/her >> favorite OS according to his her personal needs and nobody should be forced to >> accept the flaws of a certain OS, just because some shit-head programmers left >> him/her no other choice. > > That is right. And I would say also that no shit-had programmer should > be forced to write cross platform code if he cannot. Can not or doesn't want to? > The point is that small businesses will never be able to > do the first versions of their product to be fully portable. I am > talking about GUI stuff. The GUI is actually the easiest part. There's a GDI wrapper for XServer systems (providing full featured Windows GDI support for XServer) and there are a XServer wrapper for Windows GDI. I would rather be worried about processor specific optimizing done in assembler that you can't port without rewriting them. > The only "good" point which I like in Win and _very_much_ miss in Unix is > the messaging opportunity. Unix has few signals, and that's it. Sad. And that's good! More message increase security holes and system compressibility. > :-)))) So Solaris 7 is apparently not UNIX. :-)) It does not crash > usually, simply stops working. Solaris is not the prototype of UNIX, it's just the UNIX of Sun. Can you still login via SSH when your Solaris 7 systems hangs? > Yep, Windows, it's registry, Don't mention it's registry, it's hell. Every application (including those provided with Windows) support 30% of hidden features that you can only enable with registry tweaks. No matter what you do, the registry keeps on growing bigger and bigger, it's full of unecessary entries and not very well organized. Despite that, I don't think it's a good idea to make a central registry for all applications and users. Every user should have his/her own registry (and not just a sub-tree) and only Windows should be allowed to use it (third party software shall store their configuration somewhere else). > it's changing (screwed up) APIs, Is there actually a list of all APIs that are included with Windows (or multiple list for different versions), as well as an explanation what functions are actually inside those APIs? > Nope. I did not. Let's say I design a very system specific thing, an > internet dialer for example. :-))) Let's not go into this. Everyone is > on his own to decide whether it is feasible to make 1st release cross > platform or not. If you don't start with a cross-platform solution, it will get harder and harder in the future to change that. An internet dialer is a very specific piece of SW, that can't be cross-platform. But office software, browsers, multimedia players, multimedia editors, rendering software, programming IDEs, Usenet clients, e-mail clients, database software, compilers, interpreters, file managers, picture editors, sound editors, music composers, Internet clients, encryption software, compressors, etc. > Max. size still working (talking about normal WS) Java > applet was around 70K. Then performance degraded so much, that is was > useless. The Java2D demo of sun is larger than 70 KB and not useless. And it's offering a lot more than you would need for a standard GUI. http://java.sun.com/products/java-media/2D/samples/java2demo/Java2Demo.html (You'll need a browser with Java 1.3 support, maybe it will also run on 1.2. So for most browsers you'll have to install a the Sun JRE) To compare with native methods in speed, set to "0 ms" and turn of "Anti-Aliasing" (as your native system doesn't support that). Also the sound abilities are pretty impressive (the techno tune is very good). Do you know their PostScript viewer? http://java.sun.com/products/java-media/2D/samples/postscript/PostscriptViewer.html For your GUI, look at the swing demo. Since Swing is 100% pure Java (it runs without any native support), you can also load the Swing classes on Java versions below 1.2 http://192.9.48.9/products/plugin/1.2.2/demos/jfc/SwingSet/SwingSetApplet2.html (don't forget to switch "skins" on the fly) > BTW I wanted to use Java, I have even installed it. But with my 64M > PII266 notebook it took 3 minutes to open a source file in the > Forte... Thx. Forte? Nah, I don't use Forte, I use JBuilder. [ QT ] > Tried. They don't have an unlimited trial version for Win and I have no > way now to install a Linux at home. :-((( Play around with it using Linux. If you release commercial software, you certain can apply a full version. > Qt is great is what I have heard. I wanted to learn it, but no bonus. > If I get a 30 days trial I may have 2 days when I can really look at it > :-((( But Qt is the proof that it is possible to create a GUI for various of systems. You don't have to use Qt, as your apps probably never use more than 10% of it's functions anyway. And that means you might as well create your own cross-platform wrapper API. > Yep. And I am also free to see 1 unhandled exception per minute Well, of course you must handle those, that's part of being a Java programmer. > - at least with the Java apps I have tried to use. :-((( I use plenty of Java software (because those are the only apps I can run at university without any problems on any system) and here I never have this problem. The only Java applet that permanently throws Exceptions is JavaICQ, but even though it throws exceptions, it runs very well (IOW you may simply ignore them). Considering that it's still BETA software (hasn't even reached version 1.0), it's forgivable. >> China, one billion people. Computer shops in China sell Linux 200 times more >> often than Windows. The Chinese government plans to increase the usage of Linux >> even more (they don't trust Micro$oft, open source rules, as they can make sure >> there's no spyware inside). BTW downloaded distributions aren't counted here. > > Why don't they trust MS? :-))) I cannot imagine... Must have something to do with being a communistic country. > Windows NT is not limited to x86... x86 and Alpha, but software must get recompiled to run on Alpha PCs. > About China - you should ask their government. They filter the Web > :-))) You can't really filter the web. You can try, but it will never be really effective. > Anyway I could > trust Java more if it would be a standard language like C++ and Sun > would have less influence on it... IBM is also writing JVMs and there machines are usually a lot better than the ones of Sun. Despite that Java is already a standard language. I'm studying computer science and we don't learn C++, we only learn Java and all programming we perform is done in Java. We've been told: "we expect you to learn the basics of C++ programming yourself and before you will leave this institution, we assume that you've seen more than thousand lines of C++ source code, but we will not teach it or use it for projects." >> Hasn't crashed my PC a single time and I use it daily. >> I currently develop exclusively in Java and my programming IDE is written >> itself in Java. Everything always runs fine and I have no idea what you mean by >> unstable. > > How much memory? 512Ms? Currently 256 MB. > Just curious. What CPU? What speed? AMD Athlon 1 GHz. But I already were developing in Java on my old PC, Pentium2 350 MHz, 128 MB RAM. And I can still run Java applications there, both under Windows and Linux, with acceptable speed. Take a lok at this page: http://www.javalobby.org/fr/html/frm/javalobby/features/jpr/part3.html Java is not so far away of C++. Take a look at the first picture and especially at "StrSort" and you'll see that IBM's JVM is more than 17% faster than Intel's C++ compiled code. The FpEmul of IBM's JVM is only ~15% slower than with native C++ Comparing IBM's JVM to the two of Sun, you'll see that IBM always wins. I admit, often Java is slower than C++, but whether your keystroke will get displayed after 10ms or 20ms within a text editor doesn't play any role, does it? | Java is dangerously close to C performance. | What used to be a dream propagated by Java advocates with blind faith, | is now a reality. The biggest proof that the Java platform is great (and its | performance issues have solutions) is to see how Microsoft is smartly | following the lead, and telling people do do basically the same thing | (only in a Windows-centric way). I suppose that a successful adoption | (by Windows app developers) of the Common Language Runtime will | mean that we won't need to explain to K&R-C dinosaurs that Java is not | evil thanks to p-code, garbage collector, JIT compilers, safer language rules, | objects, and so on. - To quote from this page He's speaking about C# here, right? And keep in mind, C++ compilers are very old, while Java compilers are very young (only 3 years), so there's still potential for improvements. Compare current Java compilers with the first generation, more than ten times faster. Think how fast a full featured Java optimizer might be in two years. In theory a JVM could reach a speed level that isn't possible for C++ code, because a static compiler will never be able to optimize code beyond a certain level (it simply can't predict what will go on once the program is running), while a JVM with dynamic compiler will be able to look at the program during runtime. Also have an eye on the fact that also Java is so extremely young, there are already more books about Java programming than about C++ programming. And as I said before, universities prefer the usage of Java over C++. Mainly for two reasons: Cross-platform development and the ability to have a running BETA program before C++ programmers even have a concept. Don't get me wrong, I don't say Java is better than C++, just different. There's the right time and the right place for everything and low level, highspeed or realtime applications will always depend on a language like C++, but 90% of all user applications that current exist on the market could as well be written in Java. And I know that I repeat myself, but you can always use native code in Java if you like. In that case you'll have to replace the native code for every platform you are supporting, but those native code is maybe 5-10% of your application. E.g. I've used a Java application that DIRECTLY accesses OpenGL (without Java3D) and the speed was just like native C++ code . Never forget, there's JavaQuake. That is not a real Java version of Quake. Just the game is in Java, the sound, graphic and 3D engine is still in native code and there's no speed difference to the 100% native version. The advantage for programmers: They only need to port the graphic, sound and 3D engine for all system they want to support. The game behind the engine (which makes Quake what it is) will run on every system, since it's Java. -- TGOS From nospam at newsranger.com Fri Jun 22 14:54:12 2001 From: nospam at newsranger.com (Norman Shelley) Date: Fri, 22 Jun 2001 18:54:12 GMT Subject: ?Multipack latest version? Message-ID: Where is the latest version of Multipack? I have found this site, http://pylab.sourceforge.net/ but previous posts mentioned a cvs only accessable site which did not look up-to-date. Norman Shelley From aleaxit at yahoo.com Fri Jun 8 04:52:51 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 8 Jun 2001 10:52:51 +0200 Subject: Python Shareware? References: Message-ID: <9fq3p1034u@enews1.newsguy.com> "Jian Chen" wrote in message news:fb8b5496.0106071617.509bf5c7 at posting.google.com... > I am considering writing some shareware in python. I got some > questions about it: > > 1. Is there any good shareware in python? where can I find? I've seen Parnassus described as "Python shareware", but it ain't -- it's free stuff. Python seems to be used for either free or commercial projects -- haven't seen shareware in it. > 2. Is python suitable to write shareware? as I konw, it is not easy to > pack python programs in standlone exe program? is there any tools for > the packing & installing of python software? http://starship.python.net/crew/theller/py2exe/ http://www.mcmillan-inc.com/install1.html Pythonworks, the commercial IDE which is at http://www.pythonware.com/products/works/index.htm also includes "deployment tools for Windows and Linux" but I don't know the details. A single license of Pythonworks is US $395, I believe. Anyway, it has a demo/evaluation, so you can try it out completely. > 3. How can I lock/secure my python shareware? I pass! I don't know of any way to 'secure' a program that's more than, say, a weekend's work to crack, for *ANY* programming language (I do not think there are any, but a negative is hard to prove:-). If you can rely on your users having internet access while running your program, the whole picture changes -- you can then place some key part of the whole operation on a site that is fully in your control, and only accepts requests (e.g. via SOAP or similar means) when it has validated the requestor as a holder of a valid license (it can track 'copied'/'pirated' licenses by noticing too-frequent access requests, etc). In most cases one would still be restricting one's market too much by making a program unusable without internet access. Not a programming-language issue... Alex From macias at bp.com.pl Wed Jun 27 01:57:18 2001 From: macias at bp.com.pl (Maciej Pilichowski) Date: Wed, 27 Jun 2001 05:57:18 GMT Subject: 'with' statement in python ? References: Message-ID: <3b397481.3041994@news.tpi.pl> On Tue, 26 Jun 2001 10:41:31 -0300, Carlos Ribeiro wrote: >In Python, the compiler/interpreter has no way >to tell beforehand if x is a member of a, a local variable, a module level >variable, or a global variable. This ambiguity makes the use of with in >Python impossible. Nope. Look below. >The compiler knows in advance everything about "a". What do you mean "in advance"? Compiler knows it at compile time -- what is possible at compile time is possible at runtime, but of course that would slow down performance /one thing more to search for/. But! I am not pro "with" -- I think that "with" clause causes code to read for people much harder. I just wanted to point out that even interpreting "with" at runtime is still possible to know where the variable came from. have a nice day bye -- Maciej "MACiAS" Pilichowski http://www.torun.pdi.net/~macias/ z a k u p i e : Wyklady Feynmana: tIIcz1; pisma Komputer: 3/86,4/87 From kwoeltje at mail.mcg.edu Fri Jun 1 08:26:42 2001 From: kwoeltje at mail.mcg.edu (Keith Woeltje) Date: Fri, 01 Jun 2001 08:26:42 -0400 Subject: docstrings References: <3B168092.75A840D2@mail.mcg.edu> Message-ID: <3B178A02.FD52B85B@mail.mcg.edu> OOPS The article I meant to post was: http://www.onlamp.com/pub/a/python/2001/05/17/docstrings.html But the first one was good too. >K "Keith F. Woeltje" wrote: > I think > > http://www.onlamp.com/pub/a/python/2001/04/18/pydoc.html > > may approach what you are looking for. > >K > > Laura Creighton wrote: > > > > Where is the most up to date documentation for how to use them, with > > all the conventions, all the itty bits that most people don't use > > and you don't really have to, and every sort of other really precise > > stuff? We don't want to invent something if there is already a > > convention, even if it is not that well known. Common-Practice > > but-not-a-real-standard yet counts here as well. Gratuituous > > non-conformity is vile. > > > > Laura From sholden at holdenweb.com Thu Jun 28 15:18:58 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 28 Jun 2001 15:18:58 -0400 Subject: exec "global" problem References: Message-ID: "Tim Peters" wrote in ... [ ... ] > > not-even-mother-earth-is-*that*-global-ly y'rs - tim > but-we-don't-have-a-'spherical'-keyword-yet-ly y'rs - steve From rnd at onego.ru Thu Jun 21 11:01:20 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 21 Jun 2001 19:01:20 +0400 (MSD) Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: On Thu, 21 Jun 2001, Guido van Rossum wrote: >Roman Suzi writes: > >> I've not been heard or commented. It seems that everybody is happy with >> simple generators (and discuss syntax) while I am not. >> >> I dare think that proposed gen/generator/def-yield thing is doomed to be >> phased out in some future Python version, because it creates frozen >> context for very narrow task of providing generators and in the future (I >> hope) there will be normal parallel programming in Python, which will >> solve the problem simply and efficiently. >> >> I am not against PEP 255. The feature is cool. But it is a feature which >> requires new keyword, new function class, etc. In one way or another, it >> modifies function and it implicitely lead to the same syntax beasts >> as in C++/Java/Pascal. >> >> PEP 255 is not Pythonish enough. > >To the contrary, PDP 255 is very Pythonic: it doesn't try to provide >the theoretically "best" solution, it provides something that is just >as usable in most cases and much easier to implement. This is the >essence of many of Python's "innovations" over languages like C++ or >Lisp. OK... It's my bad habit to overdesign raised it's head again. >Some "Zen of Python" (http://www.python.org/doc/Humor.html#zen) rules >that apply to the situation: > >- Simple is better than complex. >- Practicality beats purity. >- Now is better than never. >- If the implementation is easy to explain, it may be a good idea. :-) >(The importance of the latter becomes clear to anyone who has had a >look at Neil Schemenauer's code for generators.) > >> Let's better think about more general things like: >> * co-routines (which "generator" is an example, if I understand it >> correctly) >> * adding parallel programming paradigm (which is even better >> for long term), where objects live their lifes and could serve >> other objects as generators, gatherers, services, etc. >> >> OOP was made easy by python. I hope parallel programming >> to be added and made equally easy, without all those >> modifiers and zillion of new keywords and modifiers. >> >> Sincerely yours, Roman A.Suzi > >I personally don't believe that parallel programming will ever become >the most common way of programming. I know that *my* mind boggles as Mine too. That is why I want Python to have it, as always, in non-complicated form ;-) >soon as I try to figure out what a piece of code that uses parallel >programming features does, so I expect the same is true for, oh, 99% >of the programmers. I agree with the "Practicality beats purity." applied in this case. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Thursday, June 21, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Useless Invention: Motorcycle seat-belts." _/ From max at alcyone.com Mon Jun 11 21:56:05 2001 From: max at alcyone.com (Erik Max Francis) Date: Mon, 11 Jun 2001 18:56:05 -0700 Subject: PEP 259: Omit printing newline after newline References: Message-ID: <3B2576B5.690DA5AB@alcyone.com> Gustaf Liljegren wrote: > I like consistency, so I think either 'print' should add a newline, or > it > shouldn't. Whatever you choose, it shouldn't do things "behind the > scenes". > If it depends on the line before, it won't be so self-explanatory if > you > see a 'print' statement with no arguments. I agree. Consistency is what counts here, and what's more, there is a precedent -- namely all the Python interpreters out there already in the world. Changing this will break existing code which was relying on well-defined behavior (how much of course is another question), and will introduce a special case consistency. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Triumph cannot help being cruel. \__/ Jose Ortega y Gasset 7 sisters productions / http://www.7sisters.com/ Web design for the future. From ctavares at develop.com Tue Jun 12 18:55:31 2001 From: ctavares at develop.com (Chris Tavares) Date: Tue, 12 Jun 2001 22:55:31 GMT Subject: msvcrt.getch() overly receptive in idle? References: <9g5m7k$gu8$1@nntp6.u.washington.edu> Message-ID: "Frank Miles" wrote in message news:9g5m7k$gu8$1 at nntp6.u.washington.edu... > I'm trying to get getch() working in Windows (Python 2.0). It seems to > work fine outside of Idle, but inside Idle it immediately returns a > character with the value 255. > > Can anyone point me to the obvious solution? Thanks! > > -frank There isn't an obvious solution, but there is an explanation: msvcrt.getch() works with a windows console. Idle doesn't run in a console, so getch() won't work there. -Chris From alan.gauld at bt.com Wed Jun 13 18:56:29 2001 From: alan.gauld at bt.com (Alan Gauld) Date: Wed, 13 Jun 2001 23:56:29 +0100 Subject: Tkinter GUI Designer References: <8yRV6.2345$9r1.347361@e3500-atl1.usenetserver.com> Message-ID: <3B27EF9D.54ED6BB9@bt.com> Michael Davis wrote: > > I've found several GUI Designers for wxPython, but where are the TK > Interface builders? Try SpecTcl with specPy add in. Obsolete but functional. Its the only one I know of but the good news is that the documentation is very good, albeit in Tcl/Tk... Alan g From graham at coms.com Wed Jun 20 04:00:29 2001 From: graham at coms.com (Graham Ashton) Date: Wed, 20 Jun 2001 09:00:29 +0100 Subject: Loading select queries into objects References: <9gpgde02rc6@enews1.newsguy.com> Message-ID: In article <9gpgde02rc6 at enews1.newsguy.com>, "Alex Martelli" wrote: > Assuming you mean "on the current instance", there is absolutely no need > for eval & friends -- the following will do just fine: > > def applydict(self, adict): > for name, value in adict.items(): > try: method = getattr(self, name) > except AttributeError: print "Warning: no method",name else: > method(value) That's much cleaner, thanks. I'm struggling my way around the standard library at the moment trying to find out how things should be done; pointers like that are incredibly useful, especially for people who are used to doing it a different way in a different language (like me). Graham From dgoodger at bigfoot.com Fri Jun 29 20:37:00 2001 From: dgoodger at bigfoot.com (David Goodger) Date: Fri, 29 Jun 2001 20:37:00 -0400 Subject: Not enough Python library development [was PEP scepticism] In-Reply-To: References: Message-ID: on 2001-06-29 12:18 PM, Guido van Rossum (guido at python.org) wrote: > But what exactly is the point of adding it to the > standard library when you can get mxDateTime if you need it? Several points! (Impatient? See #6.) If a module is part of the standard distribution: 1. It gets wide exposure, hopefully resulting in bugs being found out and improvements being made. 2. Bugs reports and patches can be contributed to a much larger developer community than any solo module enjoys. 3. There's a greater chance of continuity if/when the module is abandoned by the original author. 4. There should be a regression test for the module. It therefore has a better chance of being kept up-to-date with the latest language features (i.e., the module won't break when feature X changes, is added, or is deprecated). 5. The module tends to have decent documentation, and that documentation is placed in a central location and indexed. 6. (perhaps most importantly:) C extension modules get compiled for every platform with a binary Python distribution. Not all of us have a C compiler at hand, want to use one, or have the knowledge & experience necessary to overcome code porting issues. (I used to know my way around a C compiler, but I've been spoiled by Python! :-) For example, I don't see any Mac builds of mxDateTime 2.0 on the net. I think "Batteries Included" is a great goal. Adding to and improving the standard library should be a goal of every release of Python. The more quality batteries the better! -- David Goodger dgoodger at bigfoot.com Open-source projects: - Python Docstring Processing System: http://docstring.sf.net - reStructuredText: http://structuredtext.sf.net - The Go Tools Project: http://gotools.sf.net From mlh at idi.ntnu.no Sun Jun 10 10:35:09 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Sun, 10 Jun 2001 16:35:09 +0200 Subject: Review my async socket server (Caution: 5 kB attachment) References: <9fma5s$bcn$1@brokaw.wa.com> <9fonn4$shm$1@brokaw.wa.com> Message-ID: <9g00iu$ktr$1@tyfon.itea.ntnu.no> "Jonathan Gardner" wrote in message news:9fonn4$shm$1 at brokaw.wa.com... > Jonathan Gardner wrote: [...] > One thing I was wondering how to do... is there an easy to print warnings? > In Perl you have warn "Something", but I didn't see anything that stuck out > in Python. Do you have to print to STDERR in order to do this? Have you seen this? http://www.python.org/doc/current/lib/module-warnings.html >>> from warnings import warn >>> warn('Something') __main__:1: UserWarning: Something -- Magnus Lie Hetland http://www.hetland.org "Reality is that which, when you stop believing in it, doesn't go away." -- Philip K. Dick From xyzmats at laplaza.org Fri Jun 22 18:51:03 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Fri, 22 Jun 2001 22:51:03 GMT Subject: [OT] MS EULA -- (will ActiveState become outlaws? ;-) References: <3B32F81F.259DBA46@chello.nl> <3B33644D.E32B4215@pfortin.com> <9gvtv3$n2e$1@216.39.170.247> Message-ID: <3b33ca1a.15203020@news.laplaza.org> On 22 Jun 2001 17:06:43 GMT, David LeBlanc wrote: :In article <3B33644D.E32B4215 at pfortin.com>, pfortin at pfortin.com says... :> This page was visible with NS4.77/Linux yesterday; now, it stalls for a few :> seconds, then presents a "page not found" screen... either they are shutting :> out NS and/or Linux, or they've removed it... : :Today MS IE 5.5 stalls and then puts up a "page cannot be found" 404 :page. I wonder if MS legal woke up and smelled the gathering litigation :clouds. I'm not a lawyer, but this smacks of restraint of trade or unfair :competition at least. Of course, that's par for the course at MS, but :even they are not usually so stupid as to hand the opposition a smoking :gun like this. No, it really is, as Marc-Andre just said, the "Slashdot Effect": get your page listed on Slashdot, especially for something negative-sounding, and two million people try to connect to your site at the same time. A performance problem. Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From treaves at silverfields.com Wed Jun 20 15:15:36 2001 From: treaves at silverfields.com (Timothy Reaves) Date: Wed, 20 Jun 2001 15:15:36 -0400 Subject: problem running program Loading font from preferences. Loading font from preferences. Loading font from preferences. Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] 'import exceptions' failed; use -v for traceback Warning! Falling back to string-based exceptions 'import site' failed; use -v for traceback Fatal Python error: could not import _gtk Aborted (core dumped) [treaves@double treaves]$ Message-ID: <3B30F658.4030207@silverfields.com> Hello. I have Python 2.1 installed. I can write python scripts and they run. However, when I try to run glimmer or gnucash, I get errors. For example, glimmer gives my the following. Do I haev python setup incorrectly? [treaves at double treaves]$ export PTYHONHOME=/usr/lib/python2.1/ [treaves at double treaves]$ glimmer Loading font from preferences. Loading font from preferences. Loading font from preferences. Loading font from preferences. Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] 'import exceptions' failed; use -v for traceback Warning! Falling back to string-based exceptions 'import site' failed; use -v for traceback Fatal Python error: could not import _gtk Aborted (core dumped) [treaves at double treaves]$ From x at x.com Fri Jun 1 09:53:56 2001 From: x at x.com (Abel) Date: Fri, 1 Jun 2001 14:53:56 +0100 Subject: a sample code References: <9f7dki$29n$1@diana.bcn.ttd.net> <9f7j2a01nu3@enews1.newsguy.com> Message-ID: <9f87pg$2gc$1@diana.bcn.ttd.net> Hi: Gracias. I'll work with that. Best, Alberto Alex Martelli escribi? en el mensaje de noticias 9f7j2a01nu3 at enews1.newsguy.com... > "Abel" wrote in message news:9f7dki$29n$1 at diana.bcn.ttd.net... > > HI: > > > > I'm looking for a sample of code of a simple HTTP Server in Python.(i want > > just the basic code) > > Where can I find it ? > > d:\Python21\Lib\SimpleHTTPServer.py, if d:\Python21 is the directory > to which you have installed Python 2.1 (adjust accordingly if you > have installed it elsewhere:-). You'll need to also look at the > class used as the base for class SimpleHTTPRequestHandler defined > in that source file, of course -- so, see Lib\BaseHTTPServer.py, > and you'll see that, in turn, subclasses stuff from the SocketServer.py > source in the same directory. I consider this setup in the Python > library an EXCELLENT simple example of object-oriented design, btw. > > > Alex > > > From aleaxit at yahoo.com Mon Jun 4 04:33:30 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 4 Jun 2001 10:33:30 +0200 Subject: I had a thought ... (I know, call the newspapers). References: Message-ID: <9fflo922q4r@enews2.newsguy.com> "Delaney, Timothy" wrote in message news:mailman.991618386.21127.python-list at python.org... > > Rather then stick to a particular character to denote that > > something is > > currency, this would be an ideal opportunity to internationalize. > > Further, by saving the unicode representation of the symbol used ($, > > Euro, Pound, Franc, Lire, Yen etc.) one has the potential for doing > > currency conversion with some to be specified __InfixOperator__. > > Hmm ... so does this mean that any currency manipulations would be dependent > on a working internet connection, and a working and correct currency > conversion site? Not ANY -- conversions between Euros, Francs (both Belgian and French variety, though not the Swiss) and Liras (the Italian kind -- not the Turkish one), as well as Marks, Pesetas, Florins (Dutch kind), Austrian Schillings (and I forget which other currencies if any) use fixed ratios that could be encoded as part of the program. Of course, out of all of these denominations only Euros will be in official use a year from now, so the time window of usefulness is limited (but probably some people will feel more comfortable computing in, e.g., Marks, for a good while, even after Euro is the only device they see on their banknotes, since they're intuitively familiar with Marks and not with Euros). Your point is well taken, it seems to me, for any denomination that is not simply a synonym for another, as all in the Euro zone now are. Alex From sdm7g at Virginia.EDU Sat Jun 23 14:38:24 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Sat, 23 Jun 2001 14:38:24 -0400 (EDT) Subject: Is this a true statement? In-Reply-To: Message-ID: On 23 Jun 2001, Carl Fink wrote: > In article , Chris > Gonnerman wrote: > > > Writing TO a device driver is easy enough... the previous poster > > was talking about writing the DRIVER in Python. No OS I'm aware > > of takes device drivers in any languages other than assembler, C, > > and/or C++. > > He's making a very finicky, nitpicking, and frankly silly point [...] I don't think the point was entirely silly! It was a valid and interesting point (despite being finicky and nitpicking!) > Essentially he's deliberately misunderstanding what "write" means, > using the "write to a file" meaning instead of "create a new program" > meaning. I just don't think that point had much to do with what the original poster wanted to know. ( I'ld like to think he just left off the smirking smiley at the end for better effect -- it's much funnier delivered deadpan! ) -- Steve Majewski From loft at m6.kom Thu Jun 14 07:57:01 2001 From: loft at m6.kom (Loft'sHorrible) Date: Thu, 14 Jun 2001 13:57:01 +0200 Subject: HREF to same server, different port References: Message-ID: <9ga8h3$1cs$1@norfair.nerim.net> Have a look to the "urlparse" module. It will be helpful for your problem. The solution will be obvious after you read this... http://www.python.org/doc/current/lib/module-urlparse.html --Gilles "Steve Holden" a ?crit dans le message news: OWi6PtJ9AHA.281 at cpmsnbbsa07... > Sorry this is off-topic, but I'm trying to create a relative url to a > different port on the same server (inheriting the server name or address > from the current URL). I've tried //:8081/ and :8081/ and neither works. > > ANyone tell me how? > > regards > Steve > -- > > http://www.holdenweb.com/ > From nperkins7 at home.com Mon Jun 4 16:48:42 2001 From: nperkins7 at home.com (Nick Perkins) Date: Mon, 04 Jun 2001 20:48:42 GMT Subject: random References: <9fflob32q4r@enews2.newsguy.com> Message-ID: You are right, and I promise not to try to do logic after 4 in the morning. My own truth table clearly shows that B implies that P is true. ( and that D is false ) I am the one who was confused, when I drew my conclusion. ( goes to show why explicit logical reasoning is better than statements in english -- no argument is necessary! ) Thanks, Alex. "Alex Martelli" wrote in message news:9fflob32q4r at enews2.newsguy.com... > "Nick Perkins" wrote in message > news:V7xS6.126372$eK2.29676821 at news4.rdc1.on.home.com... > ... > > A: (P implies (not D)) > > "Given a powerful army, I could not defeat Napolean" > > > > B: (not (P implies D)) > > "Having a powerful army would not ensure that I could..." > > > > truth table: > > P D A:(P implies (not D)) B:(not (P implies D)) > > 0 0 1 0 > > 0 1 1 0 > > 1 0 1 1 > > 1 1 0 0 > > > > The difference is that statement A is true if P is false, > > whereas statement B can only be true if P is true. > > Therefore, statement B implies that P is false. > > I think I'm getting confused. From the truth table above, > AND for the immediately preceding statement, I would > deduce the _opposite_ conclusion than yours, i.e., "B > implies that P is _true_". How do you get the "implies > that P is _false_" instead? > From wasp at linuxfreak.com Wed Jun 20 19:42:23 2001 From: wasp at linuxfreak.com (Piotr Waskiewicz) Date: Thu, 21 Jun 2001 01:42:23 +0200 Subject: Curses question References: <1462444.zMo0RvPX7a@mysiu-pysiu> <3d7kyff75v.fsf@ute.cnri.reston.va.us> <3B2A3007.7EB3A68F@ak-studio.com.pl> <3dithrdzo8.fsf@ute.cnri.reston.va.us> Message-ID: <1677247.b9nUPlyArG@mysiu-pysiu> Andrew Kuchling wrote: > "Use the ncurses docs and read the source code" is all that I can say. > OK, thx. From new_name at mit.edu Wed Jun 13 16:17:34 2001 From: new_name at mit.edu (Alex) Date: 13 Jun 2001 16:17:34 -0400 Subject: how to get teh path of a script References: <3B27C7A9.3B9D3F4B@free.fr> Message-ID: > I would like to get for exemple in my_script.py located at > /home/toto/my_script.py to get in my_script.py the value "/home/toto" Does import sys, os print os.path.join(os.getcwd(), sys.argv[0]) do what you want? Alex. From clpy at snakefarm.org Sun Jun 3 05:44:14 2001 From: clpy at snakefarm.org (Carsten Gaebler) Date: Sun, 03 Jun 2001 11:44:14 +0200 Subject: Why no 'elif' in try/except? Message-ID: <3B1A06EE.F484930A@snakefarm.org> Hi there! How about adding an 'elif' to try/except? I.e.: try: res = dosomethingnasty() except: complain() elif res == 1: behappy() instead of try: res = dosomethingnasty() except: complain() else: if res == 1: behappy() Any opinions? Regards Carsten. From aleaxit at yahoo.com Wed Jun 20 02:14:36 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 20 Jun 2001 08:14:36 +0200 Subject: Partially evaluated functions References: Message-ID: <9gpf5a0313h@enews2.newsguy.com> "Rainer Deyke" wrote in message news:csVX6.324433$oc7.30746857 at news2.rdc2.tx.home.com... > "Venkatesh Prasad Ranganath" wrote in message > news:m3sngw12ce.fsf at boss.dreamsoft.com... ... > > Is partially evaluated functions possible in python? If there has been a > > discussion about it, where can I find the jist of the discussion? > > > > def conv(a, b, c): > > return (a + b) * c > > > > faren2cel = conv(b = -32, c = 5 / 9) > > class curry: ... > faren2cel = curry(conv, b = -32.0, c = 5.0 / 9) The class-based solution is most idiomatic in Python, but closures are also possible -- in Python 2.2 (or 2.1 + 'from future import'): def curry(func, *args, **kwds): def callit(*moreargs, **morekwds): morekwds.update(kwds) return func(*(moreargs+args), **morekwds) return callit you may of course choose different strategies for combining the originally supplied plain & named arguments and those given at the point of call. In Python 2.0 (or 2.1 without 'from future'), it is not as easy when the function you want to call can have any signature whatsoever, as the generic signatures make it hard to inject names from curry down into callit's namespace explicitly, as needed. It's fine if don't need this total genericity, but if you do and also want to run on older Python versions, I'd stick with some class-based solution. new.function can also be useful, if, again, you don't need to support total genericity. Alex From aleaxit at yahoo.com Tue Jun 19 11:27:40 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 19 Jun 2001 17:27:40 +0200 Subject: nested classes References: <3B2E4725.535AB18E@sympatico.ca> <9gnn5c$b00$1@plutonium.compulink.co.uk> Message-ID: <9gnr1c0uqe@enews2.newsguy.com> wrote in message news:9gnn5c$b00$1 at plutonium.compulink.co.uk... ... > You could remember the parent, but that'd lead to a circular > reference (not such a bad thing for 2.x). Still, reference cycles may be best avoided -- module weakref (in 2.1) does that well! Alex From grumble at usa.net Thu Jun 14 16:20:41 2001 From: grumble at usa.net (jcm) Date: 14 Jun 2001 20:20:41 GMT Subject: Any other Python flaws? References: <3B2914A0.6010902@erols.com> Message-ID: <9gb6ap$p10$1@news.mathworks.com> Edward C. Jones wrote: > It follows from some basic concepts of Python that > "array = ([0] * 10) * 10" > does not behave as usually intended. This is a well-known "dark > corner" of Python; a place it is simply best to avoid. For this example, what would you say people would usually expect? From sdm7g at Virginia.EDU Sun Jun 24 11:00:12 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Sun, 24 Jun 2001 11:00:12 -0400 (EDT) Subject: Is this a true statement? In-Reply-To: Message-ID: On 24 Jun 2001, Carl Fink wrote: > "Writing a device driver", I repeat, is what the *programmer* does, > not what the *program that writes the actual file* does. Unless you're going to load the program on front panel switches, like I used to have to do on an old PDP-11, I don't think you can separate the program and the programmer so easily from this question. To give a different example, but one in the same spirit(*) as David's: [1] First write a high-level virtial machine emulation in Python. [2] Then write a device driver for it in Python. (*) That is reading the question as literal and theoretical. I have no idea whether the original posted intended it as practical or theoretical. He'll have to speak up and clarify. I was certainly intending a distiction between the theoretical "compute" and the practical "do" in my first answer. But David's clearly arguing from a theoretical POV, as he has already admitted that his solution may be impractical. -- Steve Majewski From reuter at Uni-Hohenheim.DE Tue Jun 26 04:12:15 2001 From: reuter at Uni-Hohenheim.DE (Daniel Reuter) Date: Tue, 26 Jun 2001 10:12:15 +0200 Subject: Numeric 20.0.0 and 19.0.0 crash Python 2.1 In-Reply-To: <3B33F409.A7092D2F@student.gu.edu.au>; from s713221@student.gu.edu.au on Sat, Jun 23, 2001 at 11:42:33AM +1000 References: <3B33F409.A7092D2F@student.gu.edu.au> Message-ID: <20010626101215.A15107@haselnuss> On Sat, Jun 23, 2001 at 11:42:33AM +1000, Joal Heagney wrote: > Chad Everett wrote: > > > > >Hello there, > > > > > >When I do the following: > > >import Numeric > > >Python 2.1 crashes with a segmentation fault. > > >This is on a Debian/GNU Linux system, Python is configured --with-pymalloc > > Here is the problem. Read up on the "What's New" of python2.1 about > pymalloc - basically it will crash certain third-party modules that > haven't quite followed the API. It didn't matter for previous releases > of python, but it matters for python2.1. Basically, if you want Numeric, > don't use --with-pymalloc on your python build. > As can be seen, the other poster was successful with is build, because > he didn't use pymalloc. Hello there, found out about this problem after several consecutive builds with different ./configure options and testing. Now I've build it with more conservative settings and it works. Seems I should read a bit more than just README and INSTALL ;-). Thanks for your replies. Regards, Daniel From dalke at acm.org Fri Jun 22 17:37:02 2001 From: dalke at acm.org (Andrew Dalke) Date: Fri, 22 Jun 2001 15:37:02 -0600 Subject: Is this a true statement? References: Message-ID: <9h0e5n$gks$1@slb6.atl.mindspring.net> Steven D. Majewski replied to David Lees: >Turing completeness means that anything you can *COMPUTE* in one >language you can computer in another. ... >But you can't *DO* all of the same things in all languages -- for >example: you can write a device driver in a language if you can't >specify interrupt vectors or hardware address pointers. My favorite counter example is allocating objects from different memory arenas (eg, shared memory). In C++ it's very easy. In Python it isn't possible. Andrew dalke at acm.org From skip at pobox.com Wed Jun 20 23:49:21 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 20 Jun 2001 22:49:21 -0500 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) In-Reply-To: References: Message-ID: <15153.28353.296007.85204@beluga.mojam.com> Tim> [Steven D. Majewski] >> I'm also an anti-list-splitter. >> I'ld rather filter than join or deal with cross postings! Tim> So would I, but one of the best ways to kill a PEP is to flood Tim> Python-Dev with postings about it, where they just annoy Guido <0.9 Tim> wink -- but that's what the PEP process was supposed to get away Tim> from, and I play along with faux enthusiasm so real it almost Tim> twinkles>. Seems to me the thing to do is wrangle new ideas on python-dev, write a PEP, announce it on python-list with followups there. No new mailing lists needed. Skip From ffp_randjohnson at yahoo.com Sat Jun 16 13:11:18 2001 From: ffp_randjohnson at yahoo.com (Mike Johnson) Date: Sat, 16 Jun 2001 10:11:18 -0700 Subject: Using the While Loop Message-ID: <20010616.101117.1469262009.1725@behemoth.miketec.com> Hello all, I don't see why this first code snippet won't work, but I can't find any pointers in the documentation. -------------------------------------- #!/usr/bin/python2.1 myfile = open ("/tmp/messages") while line = myfile.readline(): print line -------------------------------------- But this works fine: -------------------------------------- #!/usr/bin/python2.1 myfile = open ("/tmp/messages") line = myfile.readline() while line: print line line = myfile.readline() -------------------------------------- Thanks for any help! - Mike Johnson -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From bvdpoel at uniserve.com Sun Jun 3 13:14:38 2001 From: bvdpoel at uniserve.com (Bob van der Poel) Date: Sun, 03 Jun 2001 10:14:38 -0700 Subject: tkinter: refreshing frame fonts Message-ID: <3B1A707E.F6170D8@uniserve.com> Is it possible to change the fonts/sizes for things in the main window frame (like the menu bar)? I know I can change the font for future windows with root.option.add( '*font', ..), but this does not effect any windows which are currently active. And I can refresh the data in existing windows, but really don't know about 'recreating' entire menu bars, etc. -- Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: bvdpoel at uniserve.com WWW: http://users.uniserve.com/~bvdpoel From bh at intevation.de Sat Jun 23 14:01:41 2001 From: bh at intevation.de (Bernhard Herzog) Date: 23 Jun 2001 20:01:41 +0200 Subject: PEP 255: Simple Generators, Revised Posting References: Message-ID: <6qvglnvzwa.fsf@abnoba.intevation.de> "Tim Peters" writes: > The yield statement may only be used inside functions. A function that > - contains a yield statement is called a generator function. > + contains a yield statement is called a generator function. A generator > ? +++++++++++++ > + function is an ordinary function object in all respects, but has the > + new CO_GENERATOR flag set in the code object's co_flags member. With the current implementation that doesn't seem to be entirely true (CVS from somtime 2001-06-23 afternoon UTC): >>> def empty(): ... if 0: yield 0 ... >>> for i in empty(): ... print i ... Traceback (most recent call last): File "", line 1, in ? TypeError: iter() of non-sequence >>> import dis >>> dis.dis(empty) 0 SET_LINENO 1 3 SET_LINENO 2 6 LOAD_CONST 0 (None) 9 RETURN_VALUE >>> empty.func_code.co_flags 3 It seems that the mere lexical presence of the yield statement doesn't make a function a generator. The compiler apparently optimized the if statement away before testing whether it's a generator. Bernhard -- Intevation GmbH http://intevation.de/ Sketch http://sketch.sourceforge.net/ MapIt! http://mapit.de/ From opengeometry at yahoo.ca Wed Jun 13 14:34:37 2001 From: opengeometry at yahoo.ca (William Park) Date: Wed, 13 Jun 2001 14:34:37 -0400 Subject: VI In-Reply-To: ; from gwyoder@hotmail.com on Wed, Jun 13, 2001 at 11:28:55AM +0000 References: Message-ID: <20010613143437.A676@node0.opengeometry.ca> On Wed, Jun 13, 2001 at 11:28:55AM +0000, Pilgrim wrote: > Can someone tell me what "vi" is for a text editor to work with python? My goodness, how do we answer this. 'vi' is visual screen editor which superseded a line editor called 'ed'. There are many flavours, but 'vim' is the best. The main distinquishing features for beginners are that 'vi' has many command modes, so that keys do different things depending on which mode you are in. In "insert" mode, you type as normally; in "command" mode, you move about using normal ASCII keystrokes; so on. ESC/Ctrl keys are used only in special cases. In comparison, other editors are always in "insert" mode, so that you have to press ESC- or Ctrl- key sequences for editing commands since normal ASCII keys simply go into the file. > Where can I get this? -- William Park, Open Geometry Consulting, 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From matt at mondoinfo.com Sat Jun 16 16:57:49 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Sat, 16 Jun 2001 20:57:49 GMT Subject: Tkinter - centered window? References: Message-ID: On 15 Jun 2001 09:59:04 GMT, Jacek Pop?awski wrote: Jacek, >I create window this way: >self.window=Toplevel(parent) >Is it a way to tell window manager, that I want this window to be in >center of screen? Yes, there is. It requires that the window manager cooperate which I suspect that most will but some won't. You want something like this: window=Toplevel(root) l=Label(window,text="Hope I'm centered") l.pack() window.update_idletasks() # Make sure window is mapped w=window.winfo_width() h=window.winfo_height() extraW=window.winfo_screenwidth()-w extraH=window.winfo_screenheight()-h window.geometry("%dx%d%+d%+d" % (w,h,extraW/2,extraH/2)) Fredrik Lundh's excellent An Introduction to Tkinter at: http://www.pythonware.com/library/tkinter/introduction/index.htm gives more details about the calls and the code in the PmwBase module of Greg McFarlane's handy Pmw has a more sophisticated version. Pmw is at: http://pmw.sourceforge.net/ Regards, Matt From new_name at mit.edu Sat Jun 2 12:38:41 2001 From: new_name at mit.edu (Alex) Date: 02 Jun 2001 12:38:41 -0400 Subject: iterating over lists References: <1rsnhinct5.fsf@video.bsd.uchicago.edu> Message-ID: Try this: for x1, x2, x3 in zip(list1, list2, list3: print x1, x2, x3 > If I do: > > for i in range( 1, len(list1) ): > print list1[i], list2[i], list3[i] > > I assume the len(list1) call will only be evaluated once. Yes. Alex. From aleaxit at yahoo.com Fri Jun 15 06:37:11 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 15 Jun 2001 12:37:11 +0200 Subject: base converter References: <9ga0q902gl7@enews1.newsguy.com> Message-ID: <9gcohb01jd@enews1.newsguy.com> "Omni Permeable" wrote in message news:c7cebb43.0106141326.589577e3 at posting.google.com... ... > > > def BaseConvert(x, b): > > > "convert decimal number x to base b" ... > > def BaseConvert(x, b): > > import string > > digits = string.digits + string.uppercase > > if b>len(digits): > > raise ValueError, "base %s too large"%b ... > tracking down bug#2 : b==1 iterates forever! because : divmod (5,1) == (5,0) Good point! > any more elegant solution than this one : > > elif b==1: > return '0'*x That wouldn't be correct anyway. 1 is just not an acceptable base -- neither are 0 and -1; you can't represent whatever integer Z as a polynomial in base 1, 0, or -1. (I have not checked how BaseConvert behaves with other <-1 bases, or non-integer bases, or...:-). Just throw a ValueError with "base %s incorrect"%b for b<2, I'd say. Alex From guido at python.org Tue Jun 26 16:51:00 2001 From: guido at python.org (Guido van Rossum) Date: Tue, 26 Jun 2001 20:51:00 GMT Subject: PEP 260: simplify xrange() References: Message-ID: Roman Suzi writes: > But after PEP 260 xrange is sequence no more. Since there's no formal definition of a sequence, there's little basis on which to agree, but to me, as long as it supports len(x) and x[i], it's a sequence alright. > And also I think "x in xrange(...)" and > "x not in xrange(...)" should not be dropped, > because it is very near to > > for x in xrange(...) But unlike that one it has very few practical uses. > and has interesting use as in: > > if n in xrange(1, 101, 2): # odd number from [1, 100] > ... This is exactly the kind of odd usage that gave xrange() a bad name, and contained an off-by-one bug for a while. It also used to be real slow until we had __contains__ (because it would iterate over the items comnparing n to each one), and nobody missed it. --Guido van Rossum (home page: http://www.python.org/~guido/) From xyzmats at laplaza.org Mon Jun 11 14:28:34 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Mon, 11 Jun 2001 18:28:34 GMT Subject: Learning OOP... References: Message-ID: <3b25059c.5089017@news.laplaza.org> On Mon, 11 Jun 2001 10:40:46 +0200, "Alex Martelli" Whew, you sure get an education on this group. Pope Sylvester? Anyway, I'm anything but an OO theorist so a lot of the references in this thread have been unfamiliar to me. >> "Aggregate, not inherit". Especially in python, >Wrong, especially in Python. When needed semantics are exactly >those of Python's inheritance (which happens very often, because >Python is very well designed), it is an absurd obfuscation >exercise to rebuild the same mechanism, slowly and unreadably, >on top of _other_ Python building-blocks, in the name of some >abstract and inapplicable principle. I've heard a number of folks claim that while inheritance is powerful, it's often used where it need not to be, and that perhaps one should think composition first. I tend to read that as particularly a problem with compiled languages (I think Java, since that's the closest comparison that I have any competency with), where you have to give all the information to the compiler up front, and not so much with Python where everything's dynamic. Will you please fill in the blanks on your statement above, Alex? "When the needed semantics are exactly those of Python's inheritance".... Thanks, Mats From jbellprj at iinet.net.au Sun Jun 3 11:51:44 2001 From: jbellprj at iinet.net.au (John Bell) Date: Sun, 03 Jun 2001 23:51:44 +0800 Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> Message-ID: <3B1A5D10.A7139942@iinet.net.au> Hi Frank, I've used a couple of formal methodologies in my time and am just getting into UML. The book that I'm reading is by the authors of UML: "The Unified Modeling Language User Guide" Grady Booch, James Rumbaugh and Ivor Jacobsen; Addison Wesley Longman; ISBN 0-201-57168-4. This is a decent starting point. They also do a UML Reference Manual (ISBN 0-201-30998-X) which I haven't bought. They're both part of a HUGE series (about 60 books) by AWL on the topic. An important point is that UML is only part of the overall methodology they recommend. All three authors work for Rational Software (the people who make Rational Rose, the leading commercial UML product) who recomend an approach documented in "The Unified Software Development Process" (Same authors ISBN 0-201-57169-2) which I also haven't read. If you're interrested in Software then I know of the following that's not in the commercial arena: * I read the other day that the new version of dia (0.88.1) to some degree supports UML for Python specifically! I downloaded it yesterday (from Sourceforge I think) but haven't looked at it yet. * There are a couple of Python specific UML projects underway on sourceforge but they seem to be pre-alpha. * When I bought the Workstation Deluxe version of Redhat 7.0 there was some S/W called metaedit+ included that is a major league UML kit. See www.metacase.com. Note that this was 7.0. I haven't got my 7.1 set yet and don't know if it's included. The key site to look at (if you haven't already) is www.omg.com (click on the UML icon. As I said I'm pretty early in the process of looking at all this. I've gone through the tutorial that comes with Metaedit+ and I'm about half way through the UML User Guide. My first impressions are that this is a GOOD THING. I gave up seat of the pants programming when I left uni but have found my normal methodologies don't work so well with Python. I'm always retrofitting classes rather than designing from a class based approach. This often leads to massive rewrites that are wasteful. Luckily my Python work is for my own business rather than for a customer! I'm hopeful that UML will lead to me writing better Python the first time. John Frank Millman wrote: > After 15 years of designing applications using the good old "seat of the > pants" method, I have decided that, if I am to move forward, I need a more > formal methodology. > > I have recently read about UML (Unified Modelling Language), a > standards-based method of designing and documenting any software project. It > looks interesting, but it seems to have a steep learning curve. > > Does anyone have any knowledge or experience of UML that they would like to > share? > > TIA > > Frank Millman -- Regards, John Bell From annis at biostat.wisc.edu Wed Jun 6 10:36:07 2001 From: annis at biostat.wisc.edu (William Annis) Date: 06 Jun 2001 09:36:07 -0500 Subject: Vaults of parnassus not accepting new submissions? References: Message-ID: sill at optonline.net (Rainy) writes: > I tried to submit a program to vaults of parnassus, and it doesn't > show up (it's been about a week). I also didn't get reply to my > email. What's the story here? Is there some secret illuminati rite > of passage to get a submission accepted there? :-) Nope. I don't know the mechanism by which new entries are verified, but it does sometimes take a week - or a bit longer - for my updates or new code to appear. It always does eventually. I assume the maintainer has a real job, too. :) -- William Annis - System Administrator - Biomedical Computing Group annis at biostat.wisc.edu PGP ID:1024/FBF64031 Mi parolas Esperanton - La Internacian Lingvon www.esperanto.org From jajvirta at cc.helsinki.fi Sat Jun 9 18:07:55 2001 From: jajvirta at cc.helsinki.fi (Jarno J Virtanen) Date: 9 Jun 2001 22:07:55 GMT Subject: Why should i use python if i can use java References: Message-ID: Thu, 7 Jun 2001 00:43:57 -0500 (CDT) Glyph Lefkowitz wrote: > Since we're on the topic; other design patterns that lurk around > unobtrusively in Python include the "for" keyword, which is really the > "Observer" pattern, the notion of classes as callable, which is the > "Factory" pattern universally applied, and the Strategy pattern > masquerading as first-class functions. Modules moonlight as the "Facade" > pattern when they're not playing Singleton. Did guido use the time > machine to get a copy of the GoFBook before he started working on the > first version of Python, or are Patterns just a transparent attempt to > cover for chronically inexpressive languages like C++ and Java which can't > generally implement these mind-numbingly simple constructs in code? > Inquiring minds want to know. In this book I'm reading, "Object book" by Koskimies (available in Finnish only, "Oliokirja"), the author states that Design Patterns are actually very vague concept and that the whole computer science is for great deal identifying and abstracting some general "patterns". This means that, for example in programming languages some form (or pattern, for that matter) that is used generally is "raised" and so given own name and construct in the language. Further, he states that for example data types and control structures (if, else, while, so on) have been "developed" (or evolved) this way; some decades ago they could have been called "design patterns". He raises the question of how many and which design patterns are found in language "core" in the "object oriented languages of the future" (sounds like the __future__ mechanism to me ;-). So the essential thing about design patterns is not the concept of some design pattern itself, but the "know-how" and design experience which has been collected under the specific title. I'm not an expert on this subject, but I'm really interested in it and I'm going to study it in detail once I get other projects done (such as my graduate thesis :-). From lac at cd.chalmers.se Mon Jun 4 02:24:01 2001 From: lac at cd.chalmers.se (Laura Creighton) Date: Mon, 4 Jun 2001 08:24:01 +0200 (MET DST) Subject: What do you use the cat > /dev/null window for? Typing practice? Message-ID: <200106040624.IAA13631@boris.cd.chalmers.se> Well, when i first got to Sweden and had to learn to use a Swedish keyboard (ick! Yuk!) it did get used for that and not its usual function yes. HEJ Does anybody have a linux keyboard mapping that does { as well as swedish well? The standard method of one mapping for code and one for writing Swedish text goes to hell when you want to write Swedish language labelled Widgets. I am losing a lot of time here. We don't wabnt to waste a day coming up with the one true way to layout a keyboard on Tuesday, but knowing us we will if we have to. If somebody has one laying around, can we have it? Laura From loewis at informatik.hu-berlin.de Mon Jun 25 10:30:21 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 25 Jun 2001 16:30:21 +0200 Subject: Is this a true statement? References: <3b35e9b7.501104@nntp.sprynet.com> Message-ID: ullrich at math.okstate.edu (David C. Ullrich) writes: > It wasn't supposed to be a "point" at all. Various explanations have > been given for why you can't write a device driver in Python. I > see why a device driver has to do various things that Python > cannot do, but I don't see why a program that _writes_ a device > driver has to do these things. The point is that a program that writes a device driver is not the device driver itself. Instead, the program that writes a device driver is typically called 'compiler' or 'linker'. You can certainly write compilers and linkers in Python, and some people have actually done so. However, 'writing a program that generates a device driver' is not at all the same as 'writing a device driver'. Regards, Martin From whisper at oz.nospamnet Sun Jun 3 16:47:50 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 3 Jun 2001 20:47:50 GMT Subject: Sourceforge break-in and Python 2.1 security References: Message-ID: <9fe7pm$qf5$3@216.39.170.247> In article , andres at mail.mamey.com says... > Hello, > > I've been reading the reports of the break-in into SourceForge with > increasing alarm and I'm wondering if there is a security protocol in > place that guarantees the integrity of the Python code being developed > there. > > That is, should I worry that "Fluffy Bunny" claims that he broke into > SourceForge 5 months ago and I downloaded Python 2.1 after that? > > -- > ------------------------------------------------------ > Dr. Andres Corrada email: andres at mamey.com > Mamey - Internet Programming http://www.mamey.com > ------------------------------------------------------ > -- > > I just want to meet Fluffy Bunny! From zamri at sun1.ftsm.ukm.my Thu Jun 21 01:07:36 2001 From: zamri at sun1.ftsm.ukm.my (Mohd Zamri Murah) Date: Thu, 21 Jun 2001 13:07:36 +0800 Subject: python & LEDA Message-ID: <20010621130735.A11663@sun1.ftsm.ukm.my> I am interested in linking python with LEDA (Library of Efficient Data Types and Algorithms in C++, more info at http://www.mpi-sb.mpg.de or http://www.algorithmic-solutions.de ). With Linux SuSe distribution, you get the library, not the source code. any hint on how to proceed, or better, has anyone create a module to link LEDA with python. have read swig and cxx from numpy but still lost. I have plan to use LEAD for some data mining research ideas (association rules, clustering, classification, etc). zamri From aleaxit at yahoo.com Thu Jun 7 05:37:47 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 7 Jun 2001 11:37:47 +0200 Subject: Error checking for 'raw_input( )'? References: <7b515e0f.0106060455.4093daa0@posting.google.com> <9flcus01b04@enews2.newsguy.com> <7b515e0f.0106061427.2386067f@posting.google.com> Message-ID: <9fni1a012nk@enews2.newsguy.com> "eric_brake" wrote in message news:7b515e0f.0106061427.2386067f at posting.google.com... ... > > Is this the sort of thing you want to do...? Of course, ... > not really, I was hoping there was a way like when I use a "input()" > field and someone tries to enter a letter or word. Of course a error > occurs then I can catch them with try/except statements. but since But it's not necessarily an error -- if the 'letter or word' they enter happens to be the name of a variable in current scope, for example. input() accepts any valid expression and such a 'letter or word' may well be a valid expression. > "raw_input()" can accept any string, letters or numbers, it doesn't > error. So check the string that you've just been given, e.g. by such approaches as I just mentioned. Or, if you want the string you're given to be a correct representation for an integer, for example, the check is trivial: thestring = raw_input() try: thenumber = int(thestring) except ValueError: diagnose_mistake() for example. Is THIS what you want to do...? I'm having a somewhat hard time understanding your specs, I'll admit, so making them clearer might help. Alex From dan at eevolved.com Mon Jun 18 10:37:52 2001 From: dan at eevolved.com (dan) Date: Mon, 18 Jun 2001 10:37:52 -0400 Subject: getting a reference to a class inside its definition Message-ID: <9noX6.14930$uR5.1138042@news20.bellglobal.com> I think I could communicate my question better with code ;) class SomeClass: clsref = SomeClass # raises NameError clsref = self # also raises NameError I understand why those two don't work. The first one because SomeClass isn't added to the locals namespace until the interpreter is finished reading the class definition. The second one doesn't work because 'self' isn't a special keyword, it's just a convention that everybody uses it as the first arg in a class method (and even then, many don't). Still, I want to be able to reference a class inside it's own definition. Is this possible or am I going to have to do class SomeClass: pass SomeClass.clsref = SomeClass because that's what I'm doing now... Thank you! Dan From aleaxit at yahoo.com Fri Jun 15 06:10:01 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 15 Jun 2001 12:10:01 +0200 Subject: WxPython questions. References: Message-ID: <9gcmue02uqj@enews1.newsguy.com> "Omri Schwarz" wrote in message news:octofrqcedk.fsf at mint-square.mit.edu... ... > So my question is, is there a more interactive way to > play around with wxPython? Sure! Just remember that an EMPTY line typed to the interactive interpreter tells the interpreter that the compound-statement is finished, as witness the change of prompt...: > >>> class MyFrame(wxFrame): > ... def __init__(self, parent, ID, title): > ... wxFrame.__init__(self, parent, ID, title, > ... wxDefaultPosition, wxSize(200, 150)) > ... self.CreateStatusBar() > ... self.SetStatusText("This is the statusbar") > ... Here you presumably entered an empty line, and so...: > >>> menu = wxMenu() ...the def and class statements are finished, as evidenced by the prompt being back to >>>. Just avoid empty lines except when you *ARE* finished with a compound statement! It will be difficult to edit errors &c when working this way. I suggest you keep two texboxes/terminal-emulator windows/commandboxes/dosboxes/whatever. Use one to write small textfiles with your editor of choice, the other to hold the interactive session in the same directory, and use Python function execfile to 'gobble' into the interactive session the textfiles you're editing... Alex From jurberg at my-deja.com Tue Jun 12 15:35:02 2001 From: jurberg at my-deja.com (John Urberg) Date: 12 Jun 2001 12:35:02 -0700 Subject: Integrating a Python GUI into a PowerBuilder App Message-ID: <49624b0b.0106121135.61b6bd6c@posting.google.com> Hi all, We are looking into languages to replace PowerBuilder in our shop. The kicker is that we need to slowly migrate to the new language so the choice would have to be able to integrate into a PowerBuilder MDI application. I'd really like to push Python as the new language, but I need to find a way to seemlessly integrate a Python GUI into the PowerBuilder app (i.e. as child windows of the MDI). I would expect we would want to use wxPython being as that is the closest to standard Windows look and feel. Any ideas on how I can accomplish this? Thanks in advance, John Urberg From gustav at morpheus.demon.co.uk Thu Jun 21 16:36:50 2001 From: gustav at morpheus.demon.co.uk (Paul Moore) Date: Thu, 21 Jun 2001 21:36:50 +0100 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) References: <90C6E61F5gmcmhypernetcom@199.171.54.154> Message-ID: <5em4jtko8c5sag1ap7o0rhtsh1636sf2t6@4ax.com> On 21 Jun 2001 02:48:42 GMT, gmcm at hypernet.com (Gordon McMillan) wrote: >James Althoff wrote: > >>.... Meanwhile, does anyone know where to find python-iterators and >>how to read or subscribe? Is there an archive? > >Yes, yes and yes. Are there downloadable archives? For python-iterators, and also python-sets and python-numerics? I haven't the time or inclination to read web-based archives online, but I'd like to grab an archive and read up offline... Paul. From Tom_Good1 at excite.com Wed Jun 13 13:54:17 2001 From: Tom_Good1 at excite.com (Tom Good) Date: 13 Jun 2001 10:54:17 -0700 Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> Message-ID: thinkit wrote in message news:<9g5d3p0f0p at drn.newsguy.com>... > humans should use a power of 2 as a base. this is more logical because it > synchs with binary, which is at the very heart of logic--true and false. it is > more natural perhaps, to use decimal--but logic should, and will, win out. I'm amused by the idea that "humans should [do something] because . . . it is more logical." Ah yes, we humans are so extremely logical. That's why advertisers -- whose livelihood depends on getting us to do things -- inevitably appeal to our highly refined sense of logic, and never play to our emotions or baser instincts ;-) From LOLLYRB at aol.com Mon Jun 25 11:16:55 2001 From: LOLLYRB at aol.com (LOLLYRB at aol.com) Date: Mon, 25 Jun 2001 11:16:55 EDT Subject: Post on Click-i.com: Need some advice! Smile <> Message-ID: <1e.17a141f0.2868afe7@aol.com> Need some advice! Smile <> When training any animal I like to work in some fun things in too. I'm training a young male Australian Shepherd who on occasion will gives me, a bright and beautiful smile. I'd love to encourage him to smile when I when I ask him to. My problem is: I don't know what brings this action on so it's hard predict. Clicking and treating is the answer if I can catch it in time. If anyone enjoys a good dog smile and has any ideas on this, I'd like to hear from them. - Ruth - with Assises From writeson at earthlink.net Tue Jun 19 23:30:15 2001 From: writeson at earthlink.net (Doug Farrell) Date: Wed, 20 Jun 2001 03:30:15 GMT Subject: Python 2.0 and wxPython 2.0 References: Message-ID: Robin, Thanks for your help, I created the symbolic link to the directory you mention and wxPython took off! This will be a big help to me as I'm trying to win people over at work to make Python (and wxPython) our scripting language at work on the Sun machines we use there. I'll probably be posting here again looking for help getting Python and wxPython to compile in that environment. Again, thank you very much, for the help and for wxPython! Doug "Robin Dunn" wrote in message news:nIxX6.475$%2J.19005461 at news.randori.com... > "Doug Farrell" wrote in message > news:C%fX6.14660$Kq4.1461586 at newsread2.prod.itd.earthlink.net... > > Hi all, I have Mandrake 8.0 installed on my system and I'm a little > > confused. I went to try and install wxPython (which I downloaded from the > > website) and the system tells me it's already installed, which is great! > > However, I downloaded the demo and I can't seem to run any thing there. > Does > > anyone know what's going on and how I might fix this? I'm a relative linux > > newbie... > > The RPMs for wxPython were built on a system in which Python 2.0 was > installed under /usr/local. IIRC, the Python 2.0 packages that are > available for Mandrake 8.0 install under /usr, so wxPython ends up being > installed in a place that Python is not looking. > > There are a few possible solutions for you. > > 1. Set an environment varaibale named PYTHONPATH to > /usr/local/lib/python2.0/site-packages > > 2. Move or link /usr/local/lib/python2.0/site-packages/wxPython to > /usr/lib/python2.0/site-packages/wxPython > > 3. Get the wxPython source RPM and rebuild it on your system. It will use > your installed Python as part of the build process and will then get the > paths right. If you do this you'll also need the wxGTK-devel RPM installed. > > -- > Robin Dunn > Software Craftsman > robin at AllDunn.com Java give you jitters? > http://wxPython.org Relax with wxPython! > > > > > From ffp_randjohnson at yahoo.com Sun Jun 17 13:17:07 2001 From: ffp_randjohnson at yahoo.com (Mike Johnson) Date: Sun, 17 Jun 2001 10:17:07 -0700 Subject: Data Structure Question References: <20010617.090337.1987231011.7258@behemoth.miketec.com> Message-ID: <20010617.101706.1987231011.12267@behemoth.miketec.com> In article , "Rainer Deyke" wrote: > Try the other way around, i.e. a dictonary of lists: > > key_value_pairs = [('key1', 'value1'), ('key2', 'value2'), ('key2', > 'value3')] > > dict = {} > for key, value in key_value_pairs: > dict.setdefault(key, []).append(value) This works very well! Thank you! - Mike Johnson -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From glyph at twistedmatrix.com Mon Jun 11 22:22:54 2001 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: Mon, 11 Jun 2001 21:22:54 -0500 (CDT) Subject: [Python-Dev] PEP 259: Omit printing newline after newline In-Reply-To: <002001c0f2e5$4ce543e0$0101010a@local> Message-ID: I'm for it. In fact, we should do things like this more often -- if the semantics of "print" change once per release, everyone will stop using it, the keyword/bytecode will vanish, and people will use a function for writing to standard out, as it should have been all along! :) On Mon, 11 Jun 2001, Chris Gonnerman wrote: > I have to say, I'm strongly against this PEP... does anyone else agree with > me? ______ __ __ _____ _ _ | ____ | \_/ |_____] |_____| |_____| |_____ | | | | @ t w i s t e d m a t r i x . c o m http://twistedmatrix.com/users/glyph From loewis at informatik.hu-berlin.de Tue Jun 5 04:15:49 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 05 Jun 2001 10:15:49 +0200 Subject: Can Python be used for UTF/Double Bytes/Asian Characters? References: <5f28b650.0105310946.1298918b@posting.google.com> <9f91i6$qf5$0@216.39.170.247> Message-ID: David LeBlanc writes: > I don't know about DBCS or Asian characters, but Unicode is a standard > feature in Python 2.0 (and maybe also Python 2.0, but i'm only sure about > 2.1). To process DBCS or Asian characters, you need a codec that converts your encoding into Unicode, then proceed with processing Unicode strings. Python 2.0 does not include any DBCS codecs (unless you count UTF-16 as DBCS also), but there are a few codecs available in the CVS of http://sourceforge.net/projects/python-codecs. > I don't know if the regular expression stuff has been made unicode > aware or not. It is unicode aware since Python 1.6. Regards, Martin From volker.dobler at vivastar.com Mon Jun 25 06:45:56 2001 From: volker.dobler at vivastar.com (Volker Dobler) Date: Mon, 25 Jun 2001 11:45:56 +0100 Subject: BLT throug Pmw Message-ID: <3b37079e$1@news01.datazug.ch> Hello, I would like to use BLT 2.4u throug Pmw 0.8.5 from Python 2.1 on an Windwos box but Pmw cannot find the BLT package. I installed the BLT package from the self extracting Windows installer found on the BLT home page in various locations but none worked. As I am unfamiliar with the tcl/tk-directory organisation I do not know wether all files are in the right place. Does anyone have any experince with this setup? Where should the BLT libraries be (relativily to the Python21 or Tcl diretory)? The demos included in the BLT distribution do not work either, they suffer from the same problem: "Can't find BLT package" Thanks a lot in advance for any idea. Volker Dobler From katz at Glue.umd.edu Sat Jun 16 23:43:56 2001 From: katz at Glue.umd.edu (Roy Katz) Date: Sat, 16 Jun 2001 23:43:56 -0400 Subject: Two minor syntactic proposals In-Reply-To: References: Message-ID: Hello Gareth, I am interested to know what you find inelegant about the existing define-a-function-and-bind-it-to-a-class (d-b-c) idiom? Look at it this way: The "in .. def" statement's only usable purpose is to implement something which can already be done.. There was a similar proposal to add 'aliasing' to Python with a "alias X: existingVar" statement, but Alex M. very nicely stated that a simple '=' is elegant enough. With regards to your latter proposal, again: having 'self' as the first argument is *so* critical. Say class C has a method foo, and an instance c. When one calls 'c.foo()', the interpreter calls C.foo(c)'. That is why 'self' is the first argument to a method. I suppose.. one could modify the interpreter to allow statements like these: class C: def self.x(...): pass # method def C.x(...): pass # static or class method but then, 'self' was never a special keyword... Roey (note also that static methods can be implemented in modules instead of in classes. I like this approach because I hate my CompSci instructors, who like C++ and /insist/ on being able to define class methods (imbecilic concept IMHO. print>>^H^H ). But that's just me. From Attila.Feher at lmf.ericsson.se Tue Jun 5 09:55:31 2001 From: Attila.Feher at lmf.ericsson.se (Attila Feher) Date: Tue, 05 Jun 2001 16:55:31 +0300 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3B1B1825.8109BA83@lmf.ericsson.se> <3b1ce1f7.5642@bolder.com.co.za> Message-ID: <3B1CE4D3.18F99168@lmf.ericsson.se> goose wrote: > [SNIP] > this can be done as long as cross-platform means that actuall PC's will > be used, if u tell me make my sw run on ce, then u might as well ask me to run > it on toasters ... [SNIP] U C people with Windows CE stuff might not agree with you. They don't care if the SW runs on toasters or not, but they want it to run on CE - that is the reason they bought it. :-))) CE is unline toasters: it has a GUI in 99% of the cases, and of course an interactive SW will support only the GUI. BTW it is unicode and Win32 so what runs on NT as UNICODE (and carefully written) will run on this one, too. Let's suppose it does not need 1/2G RAM :-)) A From rnd at onego.ru Wed Jun 20 07:43:47 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 20 Jun 2001 15:43:47 +0400 (MSD) Subject: [Tutor] cgi FieldStorage __str__ problem - I think... In-Reply-To: <31575A892FF6D1118F5800600846864D78BD69@intrepid> Message-ID: On Wed, 20 Jun 2001, Simon Brunning wrote: > I'm having a bit of a problem with my first CGI script. The idea is to end > an email based on a form. > > I set up a template for the email as follows: > > mailtemplate = '''From: %(email)s > Subject: %(subject)s > Email from %(name)s > %(comments)s''' > > Then I substitute the data from the form into the template as follows: > > form = cgi.FieldStorage() > mailtext = mailtemplate % form This is because instead of form["email"] you need form["email"].value I do not know why it was made in module cgi, but it works this way. I am using this: def addnames(namespace_dict,NAMES=[],DEFAULT=None,SANITIZE=str,**defaults): import cgi form = cgi.FieldStorage() dict = {} for i in NAMES+defaults.keys(): if form.has_key(i): fval = SANITIZE(form[i].value) else: if defaults.has_key(i): fval = defaults[i] else: fval = DEFAULT dict[i] = fval namespace_dict.update(dict) To add names to dict. (Usually, I add them stright to globals()) addnames( globals(), ["email","name"], "", str, # you can use some other function to check input email="defaul at email", name="Mr. Default" ) > Trouble is, the mailtext field ends up looking like this: > > From: MiniFieldStorage('email', 'a at b.c') > Subject: MiniFieldStorage('subject', 'Spam') > Email from MiniFieldStorage('name', 'Fred') > MiniFieldStorage('comments', 'Egg and chips...') > > Looks to me like the FieldStorage object's values are instances of some > MiniFieldStorage class, and the __str__ method of that class is just > returning the __repr__. Is this correct? > > If so, what do I do about it? > > Cheers, > Simon Brunning > TriSystems Ltd. > sbrunning at trisystems.co.uk > > > > > > ----------------------------------------------------------------------- > The information in this email is confidential and may be legally privileged. > It is intended solely for the addressee. Access to this email by anyone else > is unauthorised. If you are not the intended recipient, any disclosure, > copying, distribution, or any action taken or omitted to be taken in > reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot > accept liability for statements made which are clearly the senders own. > > _______________________________________________ > Tutor maillist - Tutor at python.org > http://mail.python.org/mailman/listinfo/tutor > Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From slobin at ice.ru Tue Jun 12 23:42:20 2001 From: slobin at ice.ru (Cyril Slobin) Date: 12 Jun 2001 20:42:20 -0700 Subject: Python for MS-DOS (was: Re: RS232 support for DOS on 486?) References: Message-ID: Oleg Broytmann wrote in message news:... > Do you know you can put this into init.py (I hope your Python executes > init.py upon interactive startup) and have history load/save automatically? > import rlcompleter, readline Unsafe. I have three different python executables floating around, one of them haven't readline at all and one have old-styled readline. So my startup.py have a lot of try/except's to catch all the possible cases. > histfile="%s/.python-history" % os.environ["HOME"] Unportable. Use os.path.join instead; From landauer at apple.com Tue Jun 5 21:39:26 2001 From: landauer at apple.com (Doug Landauer) Date: Tue, 05 Jun 2001 18:39:26 -0700 Subject: integers References: <9fjd8q$qb6$1@charm.magnus.acs.ohio-state.edu> <9fjgqf$rp0$2@brokaw.wa.com> Message-ID: > It's also a pain in the butt writing someint += 1 [...] > What is the reason that python doesn't have increment or decrement > operators? IMHO, it is 100 [*] times more important to make your code readable than it is to make it writeable. So in order for a feature to pull its weight, it has to improve writeability by 100 times more than it impairs readability and maintainability. IMHO, "++" does not fare well in this tradeoff. [*] I-didn't-say-what-radix-to-use-ly, -- Doug Landauer landauer at scruznet.com (not-work) From gebbers at gebbers.com Sun Jun 24 21:51:37 2001 From: gebbers at gebbers.com (Matthew Gebski) Date: Mon, 25 Jun 2001 01:51:37 GMT Subject: Windows Messaging in Python Message-ID: <3b369797.62658481@news-server.bigpond.net.au> Hi, I was wondering if there is a Python module that performs various windows messaging tasks (i think the one in perl is WIN32:GUI) thanks From Attila.Feher at lmf.ericsson.se Wed Jun 6 05:53:11 2001 From: Attila.Feher at lmf.ericsson.se (Attila Feher) Date: Wed, 06 Jun 2001 12:53:11 +0300 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3B1B1825.8109BA83@lmf.ericsson.se> <2v4ohtgldvce84sn87kh1eg1lnes37getq@4ax.com> <3B1C9E65.B73A4FE@lmf.ericsson.se> Message-ID: <3B1DFD87.F3BFDB57@lmf.ericsson.se> TGOS wrote: [SNIP] > I can't tell which SPs were applied and which ones not. > It was not even a program of a cracker page, I got it from the webpage of a > computer magazine. That was still some time ago, so maybe the SP was too new at > that time and they had no time to apply it. But I can't remember that such a > big security hole ever existed for any known UNIX system. Actually there was a week when many (10+) Linuces has been cracked and defaced in Hungary - due to a security hole like this. Of course, one _can_ install (as far as I remember) eg: NT w/o DirectX... Maybe I am wrong. > But I'm afraid I'm talking about apples here and you about pears. Let's define > what is meant by "OS". > > For me an OS is just the basic system, all that is needed to get the system run > and no all that might be installed on a system. Let's pray to god that someone at MS.commmmmmercial will understand this... > So when I say UNIX is more secure than Windows, I mean UNIX itself, which is > the kernel, hardware driver, software drivers (like file systems) and the > programs that are absolutely necessary. And what can you do with it? :-))) Having a UNIX usually means to people: sendmail, awk, egrep, cat, etc. etc. many-many little utilities: which are great and which make UNIX tick... > When installing a UNIX system that shall be secure, you should disable > everything during installation that can be disabled (including server software, > XServer, etc.). A XServer for example is such a big security hole, that you can > push a whole elephant through it and nobody would recognize it ^_^ Uhhhh. This I did not know. Why is it so? > And exactly that's the problem. Even when you disable everything possible > during Windows installation, you are still forced to install way too many > stuff. Can you install WinNT without GUI? Since every GUI might be a security > hole and every GUI wastes hardware resources (especially on servers that don't > even have a monitor). Actuall Win31/311 Win95/8/me can be installed w/o GUI... I mean not connected to the NET, install and then do some hack and U can remove the whole GUI. Of course: good luck with it, since every admin tool is GUI based :-))))) > I bet the standard settings of Win2000 installs DirectX as well and I was once > told (from a usually very reliable source) that DirectX is allowed to > circumvent many Win2000 security features to achieve higher speed. I guess you can ask it not to install it... I hope :-))) > Isn't the InternetExplorer integrated into Win2000's system? And certainly also > into WinXP. The InternetExplorer is full of security bugs and when it supports > something like VBS, goodbye system. No browser is integrated into UNIX systems, > every GUI is optional. Don't even mention it. When I install a Windows there are certain steps I make immediately, like enabling of all extensions, showing hidden files etc. Just to make sure nothing is hidden from me and nothing is done automatically, w/o asking me (like autorun...) > Only looking at those facts, it should be clear that Windows is less secure. I am not talking about a default install. I guess the default install for a RedHat has it own nice things, too. > And you must be careful when speaking about UNIX security holes. One of the > biggest security holes of all times was (or maybe still is) SENDMAIL. It needs > root rights to run correctly and that is a danger. You can intentionally crash > it (e.g. provoking a stack overflow and that way executing own code) and such a > crash can result in a new shell with root rights. That was one of the easier > ways to get root rights and immediately everyone said: > "Look, UNIX isn't secure at all!" How can U get a root shell when you crash sth? (I am not a cracker). I mean shouldn't the kernel/shell/whatever realize that the setuid stuff is out and simply return back? Isn't it so that the shell start up and it exec-s the setuid stuff, so there is no shell at all with root effective user? Sorry if I am too dumb :-) > But those people seem to overlook that SENDMAIL is a program, not part of the > kernel and not part of the UNIX OS. For this security hole are only programmers > of SENDMAIL responsible, not the UNIX programmers. Despite the fact that I've > seen alternatives to the standard SENDMAIL, I'm currently running a LINUX > system without any SENDMAIL application at all. (That way programs can't send > me notifications via mail, but I don't really care) OK, but we all know that a UNIX system _does_ include sendmail and all the other stuff in people's mind. I mean having a web server which cannot notify me of events (alarms) is not that good. :-( > Looking at a full featured UNIX system, it's of course not more secure than a > Windows system. I'm only comparing two base systems where no third party > software is installed and there, UNIX *is* more secure than Windows. OK, it is. :-))) Exclude RedHat? :-)) > I don't know, but I think most people aren't interested into cracking an > university server. I personally only try to get root access for the fun of it > (I wouldn't even know what do with it). They do it just for fun, and to test their limits. There is nothing on that server. > BTW, looks like today is a "happy day" for you. > ( Lot's of ":-)))") Yep, I "signal" you that I am not trying to argue, but discuss. As far as I see we 99% agree and the rest 1% we did not talk about. Wrap up: there is _no_ world domination of Windows (THX GOD!) and no such thing for unices either. If your resources let you, you must seriously consider releasing a multiplatform product. If your target is the Web, you MUST find the resources for it. (MUST is the same here as in an RFC :-))) Or you shall work for MS :-))) > > Same with NT. I have seen NT setup taking few thousand steps to make > > and which was solid as a rock. > > See above, there are too many things you can't remove/exclude of a Windows > installation that provide security holes. You simply can't remove things that > are a permanent part of the system and when you compare Windows to UNIX under > this point of view, a LINUX system can be tiny enough to fit onto a single > floppy disc, a UNIX distribution might as well (when you have 2.88 MB > floppies)...how about WinNT? If you have enough floppies :-))) Actually the WinNT base system is also small. The problem is: it is closed (you cannot say that my UI is now not GDI(32?) but WGS (made up: White's Graphic System, Feher=White) etc. Also the whole stuff for use (admin tools etc.) is GUI only. In NT4 the only one which is not GUI is the one (route table whatever) which cries out to be at least SAA on CUI or something, because it is pain in the ass to use it from command line. > So I guess now you understand my point of view and on what base I'm arguing > when claiming that UNIX is more secure than Windows. Yep. > > So the primary decision is: is my target group UNIX or Windows or both. > > If you get a UNIX version, you can also make it run on Linux. > And the main difference between UNIX and Windows are the APIs. But for whatever > you have an API call at UNIX, there's also an API call in Windows. Sure. > I personally like the system of "wrappers". You neither use UNIX or Windows > APIs directly. You create your own wrapper API, that in once case is wrapped > around the UNIX/Linux APIs and once around the Windows APIs. Yep. But let's say I want to make a non-open-source stuff. Wrappers are either GNU licenced or damn expensive to buy/make... However careful C++ (OO) design _can_ provide an initial abstraction layer below which one can later change the logic to use a wrapper - when he had enough sales: whether or not the sales are UNIX or Windows. I am talkign here about a non-Web based game for example. Once one identified the basic building objects, and designed their interface... who cares later if MessagingSocket uses BSD or Winsock to implement its operations? > That means you don't have to rewrite a single line of C++ code of your > application, you must create wrapper APIs for every system you like to support. Yes, I like the idea, I even wanted to start a portable UML design tool project of mine (of course first some trial'n'error) based on this idea... but I gave up until now: no time and waaay too many questions. (Eg: creation of a portable icon format - probably as a sort of portable metafile. Now I have to do a serious internet search to find if one already does exist, so I don't reinvent the wheel and create a propriatery solution...) [SNIP] > > Than you must have a real good luck. I use Solaris here and I know what > > I am talking about :-))) Reboot is once per day on a test machine where > > "badly behaving" SW can run. > > Poor configuration? > Our Solaris machines are UltraSparcs, probably configured by a Sun employee. I doubt it. NIS going down, development SW running there... Anyways some patches had to be applied for my WS behaves very nicely nowadays. It is only the ancient X which sometimes decides to give up. > > I have no problem with the security manager, I have problem with the > > Java VM code. It isn't "old enough" and mostly not open source to > > convince a security-fanatic. > > Windows as a whole ins't open source, nevertheless you trust in its security, > don't you? ^_- > Despite that, some parts are open source. Yep. And it does has a Java VM(?) installed with IE... :-)))) That's why you need to know a lot to make the secure install. > > That is right. And I would say also that no shit-had programmer should > > be forced to write cross platform code if he cannot. > > Can not or doesn't want to? Cannot. No money, no time, no experienced designers. Don't want... I mean it is not the designer/developer/system architects job to have a whish list - it's the customer's :-))) [SNIP] > The GUI is actually the easiest part. > There's a GDI wrapper for XServer systems (providing full featured Windows GDI > support for XServer) and there are a XServer wrapper for Windows GDI. I would > rather be worried about processor specific optimizing done in assembler that > you can't port without rewriting them. Anyone making assembly optimizations should be aware of that he creates _highly_ nonportable code. If one goes with C++ (and C) it is many times unnecessary, even evil. A well written C/C++ code will provide the same ASM stuff. And if one has to talk to a HW device or whatever - on UNIX there are the /dev files, on WinX you have other ways... but anyways that will be just another "wrapper" or "driver", which is of course system/platform dependent. One has to be very-very convincing in a project (part) I am involved in to be allowed to use ASM... > > The only "good" point which I like in Win and _very_much_ miss in Unix is > > the messaging opportunity. Unix has few signals, and that's it. Sad. > > And that's good! > More message increase security holes and system compressibility. Why does it increase security that everyone in need of a protocol should go for streams, (sockets) make its own protocol stack (and at that point probably make serious mistakes in something which might run with "higher" right than the user has) and so on... No scheduler, no callback point or event loop... Not every program is 2 letters command line tool :-((( And once you need something seriously event driven you end up buying ACE for a lot of money or get 5 people to write a framework. :-((( > > :-)))) So Solaris 7 is apparently not UNIX. :-)) It does not crash > > usually, simply stops working. > > Solaris is not the prototype of UNIX, it's just the UNIX of Sun. > Can you still login via SSH when your Solaris 7 systems hangs? When the X goes home, yes. I did not try the other one though, which crashes a lot. > > Yep, Windows, it's registry, > > Don't mention it's registry, it's hell. Nope. Hell is good for something: you can frighten bad people with it. The concept of the common Windows registry is plain evil. > Every application (including those provided with Windows) support 30% of hidden > features that you can only enable with registry tweaks. No matter what you do, > the registry keeps on growing bigger and bigger, it's full of unecessary > entries and not very well organized. And once it crashes you have to reinstall _everything_, probably including nice data loss... > Despite that, I don't think it's a good idea to make a central registry for all > applications and users. Every user should have his/her own registry (and not > just a sub-tree) and only Windows should be allowed to use it (third party > software shall store their configuration somewhere else). TOTALLY agreed. This was the WORSE thing MS could make. Not to mention their "fantastic" idea of installing everything under c:\windows (like app DLLs), installing every user prog under program files, _and_ give them this as working dir... Some C++ wanted me to start my projects in c:\program file\whatever\whatever\projects... Oh my god! And this is based on MS recommendations... > > it's changing (screwed up) APIs, > > Is there actually a list of all APIs that are included with Windows (or > multiple list for different versions), as well as an explanation what functions > are actually inside those APIs? Yep and no. There is MSDN, there is Win32, which is a platform with its APIs, Win16, WinSock (1.1, 2.0), Telephony, IE etc. Millions of APIs. One API for network drivers, one API for mailing (MAPI, I wonder if it still exists or renamed), than the OLE, ActiveX stuff etc. Windows has one bad thing: it is waaay too difficult and complex. Win16 messages and services one could keep in my - and it was organized. But nowadays with the new APIs, abandoned but kept-for-compatibility APIs, GUI only APIs, "copied" (I am trying to get not sued here :-) and changed APIs (WinSock) etc. There are too many. Of coursem you can learn them and I am sure that the MSDN is better for learning than the man pages... but still. [SNIP] > If you don't start with a cross-platform solution, it will get harder and > harder in the future to change that. An internet dialer is a very specific > piece of SW, that can't be cross-platform. Not necessarily. If the original OO design is good, there _are_ abstraction layers and you don't depend on _anything_ but the ("implementable", or possible to port) functionality/interface of the abstraction layer (which is not necessarily a platform abstaction layer) later you can easily add the other layer below it. > But office software, browsers, multimedia players, multimedia editors, > rendering software, programming IDEs, Usenet clients, e-mail clients, database > software, compilers, interpreters, file managers, picture editors, sound > editors, music composers, Internet clients, encryption software, compressors, > etc. Yep :-))) > > Max. size still working (talking about normal WS) Java > > applet was around 70K. Then performance degraded so much, that is was > > useless. > > The Java2D demo of sun is larger than 70 KB and not useless. > And it's offering a lot more than you would need for a standard GUI. OK. Will check it out. > http://java.sun.com/products/java-media/2D/samples/java2demo/Java2Demo.html > (You'll need a browser with Java 1.3 support, maybe it will also run on 1.2. > So for most browsers you'll have to install a the Sun JRE) Mine tells it has Java 2 - I suppose this is 1.3... > To compare with native methods in speed, set to "0 ms" and turn of > "Anti-Aliasing" (as your native system doesn't support that). > Also the sound abilities are pretty impressive (the techno tune is very good). > > Do you know their PostScript viewer? > http://java.sun.com/products/java-media/2D/samples/postscript/PostscriptViewer.html Nope, will check it out. > For your GUI, look at the swing demo. Since Swing is 100% pure Java (it runs > without any native support), you can also load the Swing classes on Java > versions below 1.2 > > http://192.9.48.9/products/plugin/1.2.2/demos/jfc/SwingSet/SwingSetApplet2.html > (don't forget to switch "skins" on the fly) THX! > > BTW I wanted to use Java, I have even installed it. But with my 64M > > PII266 notebook it took 3 minutes to open a source file in the > > Forte... Thx. > > Forte? > Nah, I don't use Forte, I use JBuilder. Can one get one to learn for free? > [ QT ] > > > Tried. They don't have an unlimited trial version for Win and I have no > > way now to install a Linux at home. :-((( > > Play around with it using Linux. > If you release commercial software, you certain can apply a full version. No Linux at home :-((( Desktop is too old, notebook is too notebook :-((( gcc is too not standard STL :-(( [SNIP] > Well, of course you must handle those, that's part of being a Java programmer. :-))) I guess nowadays some "Java programmer" may not even fit to the programmer category. They do guesswork... Like those Clipper programmers who gave a bad name for Clipper years ago. [SNIP] > Must have something to do with being a communistic country. Or simply knowing them? :-)))) > > Windows NT is not limited to x86... > > x86 and Alpha, but software must get recompiled to run on Alpha PCs. Yep. But as far as I know this is only different with Java and only if one did not make it machine code... > You can't really filter the web. You can try, but it will never be really > effective. Simple. One allows only few addresses/IPs to be reached :-))) Opposite filtering :-))) [SNIP] > IBM is also writing JVMs and there machines are usually a lot better than the > ones of Sun. > > Despite that Java is already a standard language. I'm studying computer science > and we don't learn C++, we only learn Java and all programming we perform is > done in Java. > > We've been told: "we expect you to learn the basics of C++ programming yourself > and before you will leave this institution, we assume that you've seen more > than thousand lines of C++ source code, but we will not teach it or use it for > projects." Sad. [SNIP] > Currently 256 MB. [SNIP] > AMD Athlon 1 GHz. Ah yeah. PII-266/64MB :-((( Desktop is P-166 (YES, really) with 80MB. > But I already were developing in Java on my old PC, Pentium2 350 MHz, 128 MB > RAM. And I can still run Java applications there, both under Windows and Linux, > with acceptable speed. Hm. RAM will be the issue here. And Forte :-))) > Take a lok at this page: > http://www.javalobby.org/fr/html/frm/javalobby/features/jpr/part3.html Will do. [SNIP] > I admit, often Java is slower than C++, but whether your keystroke will get > displayed after 10ms or 20ms within a text editor doesn't play any role, does > it? Nope. But in the system I do now there are no keystrokes :-))) > He's speaking about C# here, right? Loox like. I would like to see C# to be an independent std language. I don't trust MS... They have dropped waaay to many things people invested into... > And keep in mind, C++ compilers are very old, while Java compilers are very > young (only 3 years), so there's still potential for improvements. Compare > current Java compilers with the first generation, more than ten times faster. > Think how fast a full featured Java optimizer might be in two years. In theory > a JVM could reach a speed level that isn't possible for C++ code, because a > static compiler will never be able to optimize code beyond a certain level (it > simply can't predict what will go on once the program is running), while a JVM > with dynamic compiler will be able to look at the program during runtime. May be so. I know that when I worked with CA-Clipper the actual Clipper code (thanx to pcode and the very well optimized engine) was usually faster and smaller than a C code written for the same task. Reason: the Co code was _bad_ code, many thing repeatedly implemented etc. Since it was big and complex. > Also have an eye on the fact that also Java is so extremely young, there are > already more books about Java programming than about C++ programming. And as I > said before, universities prefer the usage of Java over C++. Mainly for two > reasons: > Cross-platform development and the ability to have a running BETA program > before C++ programmers even have a concept. Now if U have a C++ programmer (experienced, with his nice libraries) I guess he will do a better quality work before the new Java guy learn what is an array :-))) But yes, for people not knowing enough a very high level language like Java is very good. Also the concept of the Java platform is not bad. Altough I am sure that applications, which receive very different kinds of loads and demands during their runtime will be better optimized by a compiler which _does_ optimize _everyting_ to full extent... > Don't get me wrong, I don't say Java is better than C++, just different. Yep. C++ is a "low level" programming language (one hairline above assembly, with OO capabilties) and Java is a programming platform. > There's the right time and the right place for everything and low level, > highspeed or realtime applications will always depend on a language like C++, > but 90% of all user applications that current exist on the market could as well > be written in Java. Actually there is a self optimizing Java esp. for realtime... One friend of mine loves it. > And I know that I repeat myself, but you can always use native code in Java if > you like. In that case you'll have to replace the native code for every > platform you are supporting, but those native code is maybe 5-10% of your > application. Aha. > E.g. I've used a Java application that DIRECTLY accesses OpenGL (without > Java3D) and the speed was just like native C++ code . Never forget, there's > JavaQuake. That is not a real Java version of Quake. Just the game is in Java, > the sound, graphic and 3D engine is still in native code and there's no speed > difference to the 100% native version. Wow. > The advantage for programmers: > They only need to port the graphic, sound and 3D engine for all system they > want to support. The game behind the engine (which makes Quake what it is) will > run on every system, since it's Java. And still on suggestion: before start programming in Java: learn what goes on behind the scenes! Otherwise you are lost when you encounter a problem. This is not meant to you, but those who think they became the ultimate programmer if they can do things in Java. Attila Ps: Maybe we should go on in private? I am just waiting in fear for the first guy from some NG to say: this is not a discussion forum :-(( From bill-bell at bill-bell.hamilton.on.ca Tue Jun 19 11:24:52 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Tue, 19 Jun 2001 11:24:52 -0400 Subject: Help, pls: COM local server factory class In-Reply-To: <992938357.431.64086.l9@yahoogroups.com> Message-ID: <3B2F3684.627.33CEDE8@localhost> Mark Hammond wrote, in part: > You should register your server for debugging. eg "MyServer.py > --debug". Then startup Pythonwin's "Tools->Collect Remote Debugging > Output" option. You should then see a complete traceback pointing to > the specific line that fails. Thank you. In response to your suggestion I've started on a different tack. Having lent your Win32 book to a colleague I grabbed its Chapter 12 "Final Sample" code from the O'Reilly site. I launched the Python code from within PythonWin and got "Registered: PythonDemos.Parent (for debugging)"--which was encouraging. Then I launched the VBA code (minus the comments since I never use 'em) from within MS Excel and it croaked on the first line (ie, Set ParentObj = CreateObject("PythonDemos.Parent")) with "Unexpected Python Error: exceptions.SystemError: NULL result without error in call_object". Any chance that the code on the web site is somehow broken or is this just one more embarrassment for me (in a life that has been much too full of them already)? Thanks for your help! From alan.gauld at bt.com Mon Jun 4 13:28:41 2001 From: alan.gauld at bt.com (Alan Gauld) Date: Mon, 04 Jun 2001 18:28:41 +0100 Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> <3B1BA00A.398E905B@damaru.com> Message-ID: <3B1BC549.82F639E6@bt.com> Michael Davis wrote: > I can't easily find the answer in the Nutshell > book. > > It lacks a quick guide to the notation, which is a serious flaw. > > The 'Distilled' book is okay. I haven't yet come across a truly great > book on UML yet. Having said I like the nutshell book I have to say the Distilled one is the best I've found. Definitely the best of the two. The Wrox book on 'Instant UML', now thats truly bad... :-) Alan G From just at letterror.com Thu Jun 21 14:27:41 2001 From: just at letterror.com (Just van Rossum) Date: Thu, 21 Jun 2001 20:27:41 +0200 Subject: PEP 255: Simple Generators References: Message-ID: <3B323C9B.85838BF7@letterror.com> Terry Reedy wrote: > When I first read the PEP, I assumed that def'ed generators would somehow > return the successive yielded values on successive calls (wrong). [ ... ] and further: > Question: am I correct in thinking that separating iterator-generation from > iterator-first-use makes it possible to have multiple iterators from the > same generator in simultaneous use, as in > > sq10 = squares(10) > sq20 = squares(20) > ... > ? That, but it's also to ensure thread-safety and allow recursion, just like with "normal" functions. When you call a normal function, a stack frame is created which is immediately executed. When you call a generator function, a stack frame is created, which is returned immediately, wrapped in an iterator object. Just From alf at leo.logilab.fr Thu Jun 28 09:12:59 2001 From: alf at leo.logilab.fr (Alexandre Fayolle) Date: Thu, 28 Jun 2001 13:12:59 +0000 (UTC) Subject: Unicode and print with python 2.1 Message-ID: Hello, This is probably going to sound stupid, but here I go anyway. Please refer me to TFM if this is what I deserve. Is it normal to get UnicodeError when I try to print a unicode string with Python 2.1? >>> s=u'?t?' >>> s u'\xe9t\xe9' >>> print s Traceback (most recent call last): File "", line 1, in ? UnicodeError: ASCII encoding error: ordinal not in range(128) Alexandre Fayolle -- http://www.logilab.com Narval is the first software agent available as free software (GPL). LOGILAB, Paris (France). From tim at stravinsky.jhuapl.edu Wed Jun 13 12:26:26 2001 From: tim at stravinsky.jhuapl.edu (R. Timothy Edwards) Date: Wed, 13 Jun 2001 12:26:26 -0400 Subject: Dynamically-linked version of Python-2.1 for linux Message-ID: <200106131626.MAA13411@stravinsky.jhuapl.edu> To the python developers: I am the author of "xcircuit", into which I embedded python for use as a scripting language (very successfully, I might add). The only problem I had with Python was that the source always compiled a static ".a" library, and this would enlarge the size of the xcircuit executable from 1.5MB to more like 4.5MB---i.e., the python interpreter was twice the size of the program it was embedded in! Because I am a traditional programmer who actually believes in saving disk space and removing redundancy where warranted, I worked out how to get a libpython2.1.so under linux, and made some reasonable effort to make sure that this would not affect other architectures. Would someone please check my code and make sure that it doesn't break the compile process on other OS's (including Linux versions other than RedHat)? Thanks. Regards, Tim Edwards ------------------------------------------------------------------ Source version: Python-2.1c2 Summary of changes: 1) Add LDCONFIG to the makefile so that the install process can update the ld.so cache (LDCONFIG = /bin/true on non-linux systems. Do any other systems use an ld.so cache?). 2) Export LD_LIBRARY_PATH to python during the build process so that it will link correctly before doing make install 3) Change LDLIBRARY to libpython$(VERSION).so for Linux 4) Add a rule to generate libpython$(VERSION).so for Linux (is the same as for unixware) 5) Add a few lines to the make install process to check for /etc/ld.so.conf, and if it exists, append $(LIBRARY) to it and run LDCONFIG to rebuild /etc/ld.so.cache. 6) The install process currently installs LDLIBRARY into LIBPL and then runs RANLIB on it; this would appear to be an error based on the fact that most systems set LDLIBRARY to be the same as LIBRARY, so that it is actually a static library. I would argue that this install should be changed to LIBRARY, not LDLIBRARY, so that it really is the static library that is installed here, and therefore it is not an error to run RANLIB on it. It is around here, though, that I get a bit fuzzy on the intended use of the directory structure created by the install process, so there may be a difference of opinion. But I am confused why the library needs to be installed both in $(LIBDIR) and in $(LIBPL), which is a subdirectory of $(LIBDIR). One would think that one or the other would suffice. Patch files (diff -c original_file new_file) ------------------------------------------------------------------ 1) Changes to Makefile.pre.in ------------------------------------------------------------------ *** Makefile.pre.in.orig Sat Apr 14 13:57:07 2001 --- Makefile.pre.in Tue Jun 12 16:12:30 2001 *************** *** 94,99 **** --- 94,100 ---- # Symbols used for using shared libraries SO= @SO@ LDSHARED= @LDSHARED@ + LDCONFIG= @LDCONFIG@ BLDSHARED= @BLDSHARED@ DESTSHARED= $(BINLIBDEST)/lib-dynload *************** *** 282,288 **** # Build the shared modules sharedmods: $(PYTHON) ! PYTHONPATH= ./$(PYTHON) $(srcdir)/setup.py build # buildno should really depend on something like LIBRARY_SRC buildno: $(PARSER_OBJS) \ --- 283,290 ---- # Build the shared modules sharedmods: $(PYTHON) ! PYTHONPATH=export LD_LIBRARY_PATH; LD_LIBRARY_PATH=$(srcdir); \ ! ./$(PYTHON) $(srcdir)/setup.py build # buildno should really depend on something like LIBRARY_SRC buildno: $(PARSER_OBJS) \ *************** *** 309,315 **** $(AR) cr $@ $(MODOBJS) $(RANLIB) $@ ! # This rule is only here for DG/UX, UnixWare, and BeOS!!! libpython$(VERSION).so: $(LIBRARY) case `uname -s | tr -d '/ ' | tr '[A-Z]' '[a-z]'` in \ *dgux*) \ --- 311,317 ---- $(AR) cr $@ $(MODOBJS) $(RANLIB) $@ ! # This rule is here for DG/UX, UnixWare, Linux, and BeOS libpython$(VERSION).so: $(LIBRARY) case `uname -s | tr -d '/ ' | tr '[A-Z]' '[a-z]'` in \ *dgux*) \ *************** *** 320,325 **** --- 322,330 ---- unixware*) \ $(LDSHARED) -o $@ $(LIBRARY_OBJS) \ ;; \ + linux*) \ + $(LDSHARED) -o $@ $(LIBRARY_OBJS) \ + ;; \ beos) \ $(AR) so $(LIBRARY) $@ \ ;; \ *************** *** 534,539 **** --- 539,548 ---- $(INSTALL_PROGRAM) $(PYTHON) $(BINDIR)/python$(VERSION)$(EXE) if test -f libpython$(VERSION).so; then \ $(INSTALL_DATA) libpython$(VERSION).so $(LIBDIR); \ + if test -z `grep $(LIBDIR) /etc/ld.so.conf | uniq`; then \ + echo $(LIBDIR) >> /etc/ld.so.conf; \ + fi; \ + $(LDCONFIG) $(LIBDIR); \ else true; \ fi if test -f "$(DLLLIBRARY)"; then \ *************** *** 659,667 **** else true; \ fi; \ done ! @if test -d $(LDLIBRARY); then :; else \ ! $(INSTALL_DATA) $(LDLIBRARY) $(LIBPL)/$(LDLIBRARY) ; \ ! $(RANLIB) $(LIBPL)/$(LDLIBRARY) ; \ fi $(INSTALL_DATA) Modules/config.c $(LIBPL)/config.c $(INSTALL_DATA) Modules/$(MAINOBJ) $(LIBPL)/$(MAINOBJ) --- 668,676 ---- else true; \ fi; \ done ! @if test -d $(LIBRARY); then :; else \ ! $(INSTALL_DATA) $(LIBRARY) $(LIBPL)/$(LIBRARY) ; \ ! $(RANLIB) $(LIBPL)/$(LIBRARY) ; \ fi $(INSTALL_DATA) Modules/config.c $(LIBPL)/config.c $(INSTALL_DATA) Modules/$(MAINOBJ) $(LIBPL)/$(MAINOBJ) ------------------------------------------------------------------ 2) Changes to configure.in for autoconf ------------------------------------------------------------------ *** configure.in.orig Wed Apr 11 16:56:19 2001 --- configure.in Tue Jun 12 16:09:58 2001 *************** *** 273,278 **** --- 273,281 ---- LDLIBRARY='libpython$(VERSION).dll.a' DLLLIBRARY='libpython$(VERSION).dll' ;; + linux*) + LDLIBRARY='libpython$(VERSION).so' + ;; unixware*) LDLIBRARY='libpython$(VERSION).so' ;; *************** *** 546,551 **** --- 549,555 ---- # Set info about shared libraries. AC_SUBST(SO) AC_SUBST(LDSHARED) + AC_SUBST(LDCONFIG) AC_SUBST(BLDSHARED) AC_SUBST(CCSHARED) AC_SUBST(LINKFORSHARED) *************** *** 561,566 **** --- 565,583 ---- esac fi AC_MSG_RESULT($SO) + # LDCONFIG is the command used to create the ld.so cache in + # /etc/ld.so.cache. Linux only. + AC_MSG_CHECKING(LDCONFIG) + if test -z "$LDCONFIG" + then + case $ac_sys_system/$ac_sys_release in + Linux*) + LDCONFIG="ldconfig";; + *) + LDCONFIG="/bin/true";; + esac + fi + AC_MSG_RESULT($LDCONFIG) # LDSHARED is the ld *command* used to create shared library # -- "ld" on SunOS 4.x.x, "ld -G" on SunOS 5.x, "ld -shared" on IRIX 5 # (Shared libraries in this instance are shared modules to be loaded into From sdm7g at Virginia.EDU Wed Jun 20 20:50:33 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Wed, 20 Jun 2001 20:50:33 -0400 (EDT) Subject: Dynamically importing modules In-Reply-To: <6957F6A694B49A4096F7CFD0D900042F27D4A2@admin56.narex.com> Message-ID: > > From: Jared Lee Peterson [mailto:jared at difinium.com] > > > > I have a quick question about importing modules. I would > > like to have a > > script that in sitting in a directory and in this directory I want to > > have sub directories that represent modules to that script. However > > I do not want this script to have any prior knowledge of what modules > > may exist. So I would like for the script to look at it > > current working You don't want the current working directory -- unless you've changed it with os.chdir, that is just the cwd for the user's shell when they ran python. You want the path of the module you're importing. Consider making it a package so that you can use the __path__. [ See: ] That would mean that you couldn't run it as a __main__ module from the command line, but you could make another module that imports the package and serves as a main module. > > directory and then try to load each module that does exist through the > > use of import. But I can not seem to figure out how to get import to > > work for me. Because I need to be able to loop through a list > > (os.listdir()) of the subdirectories/modules that the script has found > > and try to import them. Does anyone have any suggestions? Does this > > even make sense? On Wed, 20 Jun 2001, Bjorn Pettersen wrote: > > you can use the __import__ function to import a module based on it's > name (as a string), ie. the following two statements are equivalent: > > mymodule = __import__('mymodule') > > and > > import mymodule If you don't know the value of mymodule (i.e. it's a variable and not a literal) you might have to do something like: globals()[mymodule] = __import__( mymodule ) If you use __import__, that path has to be in sys.path ( and also the submodule directories. ). You can also use the routines in imp or ihooks if you want to customize things on a lower level. ( For example, you can give an explicit path to imp.load_module if you don't want to mess with sys.path. ) [ read up on those modules in the Library reference manual. ] -- Steve If you use packages, you might do something like this for the package __init__ file: (Sorry about going overboard with the list comprehension -- I'm trying to use them every chance I get until they seem natural!) ## __init__.py ## "Sample __init__ module for dynamic loading of package modules" import os,sys sys.path.extend( __path__ ) __modules__ = {} # keep a list of all the modules for _module in [ _file[:-3] for _file in os.listdir( __path__[0] ) if _file[-3:] == '.py' and _file[0] <> '.' and _file[:2] <> '__' ]: __modules__[_module] = globals()[_module] = __import__( _module ) for _file in __path__: sys.path.remove( _file ) del os,sys,_module,_file From goringe at avaya.com Thu Jun 7 00:02:38 2001 From: goringe at avaya.com (Chris Goringe) Date: 6 Jun 2001 21:02:38 -0700 Subject: Why should i use python if i can use java References: Message-ID: <3e7e9334.0106062002.368d5e0a@posting.google.com> I'm just completing my first significatn project in python (previously worked in Java). Productivity gain in python has been significant. However, python doesn't strong typing (love it or hate it...) interfaces (ditto) an elegant way of implementing singletons (or does it? anyone?) a comparable development and debugging environment to JBuilder but most of all, it doesn't have J2EE J2ME So it still lags Java for seriously scalable enterprise solutions and for portable device deployment. Chris From jason-dated-993239378.209f87 at mastaler.com Thu Jun 14 15:49:37 2001 From: jason-dated-993239378.209f87 at mastaler.com (Jason R. Mastaler) Date: 14 Jun 2001 13:49:37 -0600 Subject: Redhat 7.1 and Python 2.1 In-Reply-To: <20010524235013.K690@xs4all.nl> (Thomas Wouters's message of "Thu, 24 May 2001 23:50:13 +0200") References: <20010524235013.K690@xs4all.nl> Message-ID: Thomas Wouters writes: > > > - Why doesn't Redhat ship with Python 2.1? The 1.5.2 it ships with > > > is a little dated isn't it? > > Yes, totally. > > > The reasons according to a couple RedHat developers are: > > > "Compatibility - the newer versions aren't compatible with 1.5, and > > they don't even store modules in the same location." > > > "Binary compatibility issues. We don't break binary compatibility in > > a minor release, and the binary format for python modules has > > changed." > > I find it terribly amusing how those two 'problems' cancel each > other out. Binary compatibility shouldn't be an issue because > modules are stored in different locations anyway! It's really not > that hard to ship both python1.5 and python2.0 (and python2.1, and > python2.1.1, and ... ;) Apparently what they meant was that a module built for python on Red Hat Linux 7.x needs to work on all 7.x releases. Thus, the primary python can't be upgraded during the cycle. -- (TMDA - http://tmda.sourceforge.net) (Python-based SPAM reduction system) From qrczak at knm.org.pl Wed Jun 20 17:38:24 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 20 Jun 2001 21:38:24 GMT Subject: PEP 255: Simple Generators References: <3B303FE5.735A5FDC@cosc.canterbury.ac.nz> <90C65699Dgmcmhypernetcom@199.171.54.194> Message-ID: Wed, 20 Jun 2001 11:42:08 -0700, David Eppstein pisze: > I'm wondering if it wouldn't make sense to allow a non-empty return > statement in a generator, with the semantics that the object being returned > is itself some kind of iterator that is used to continue the sequence. > > i.e. > def integers(i): > yield i > return integers(i+1) I like it. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From dougfort at downright.com Thu Jun 7 16:53:23 2001 From: dougfort at downright.com (Doug Fort) Date: 7 Jun 2001 21:53:23 +0100 Subject: Review my async socket server (Caution: 5 kB attachment) References: <9fma5s$bcn$1@brokaw.wa.com> <9fonn4$shm$1@brokaw.wa.com> Message-ID: <3b1fe9c3_4@news5.uncensored-news.com> Jonathan Gardner wrote: > Jonathan Gardner wrote: >> I wrote an asycnchronous socket server based loosely off of something I >> found off the net created by Sam Rushing's Asyncore. I want general >> opinions on everything about the code. I have been doing Python for about >> a week now, so I want to make sure I am coding properly. If there are any >> hints or tips anyone would like to give, I am glad to accept them. >> >> The attachment is tarred and gzipped. The stuff is only meant to run on >> Linux, I don't have a Windows box to test it on... and frankly, Scarlet, >> I don't give a darn. =) >> > > One thing I was wondering how to do... is there an easy to print warnings? > In Perl you have warn "Something", but I didn't see anything that stuck > out in Python. Do you have to print to STDERR in order to do this? > http://asynchttp.sourceforge.net -- Doug Fort Senior Meat Manager Downright Software LLC http://www.downright.com ______________________________________________________________________ Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com With Seven Servers In California And Texas - The Worlds Uncensored News Source From rnd at onego.ru Sun Jun 24 09:20:03 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 24 Jun 2001 17:20:03 +0400 (MSD) Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: On Sun, 24 Jun 2001, Tim Peters wrote: >natural. For example, "how do I generate the elements of a list taken k at >a time?" is almost a c.l.py FAQ, and generators are ideal for that kind of >thing: > >def gcomb(x, k): > "Generate all combinations of k elements from list x." > >This *kind* of example doesn't appeal to everyone, of course, but I already >covered my butt by saying it depends on the audience and the author . This implementation is cool, but how fast will be recursive generators? How large is the overhead to defrost execution frame each time? Will it be faster than functional gcomb? Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, June 24, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Ok, I pulled the pin. Now what? Where are you going?" _/ From sholden at holdenweb.com Sat Jun 9 11:50:19 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sat, 9 Jun 2001 11:50:19 -0400 Subject: Keyword argument parsing in error in 2.0? References: Message-ID: Many thanks. Seems to be fine now. regards STeve "Tim Peters" wrote in message news:mailman.992039114.3451.python-list at python.org... > [Steve Holden] > > ... > > c.UNION(c.SELECT(["l.beer", "l.drinker", ["count(distinct s.bar)", > > "nbars"]], > > FROM=[["likes", "l"], ["serves", "s"]], > > WHERE="l.beer=s.beer", > > REST="group by l.beer, l.drinker"), > > c.SELECT("distinct beer, drinker, 0 as nbars", > > FROM="likes", > > WHERE="beer not in (%s)" % > > c.SELECT("beer", > > FROM="serves")), > > REST="order by 3 desc") > > > > This validates fine in PythonWin, but when the module containing it is > > executed I get: > > > > Traceback (most recent call last): > > File "alltest.py", line 396, in ? > > REST="order by 3 desc"), > > TypeError: keyword parameter redefined: REST > > If you count your parens , I think you'll discover that the indentation on > the final REST is misleading; clearer is: > > WHERE="beer not in (%s)" % > c.SELECT("beer", > FROM="serves")), > REST="order by 3 desc") > > and that explains why it thinks you specified REST twice: you did . > PythonWin (or IDLE) should have shown you that when you hit ENTER on the > preceding line, though (they use the same auto-indent algorithm under the > covers, and it aligns the new line under WHERE). > > > From michael at stroeder.com Fri Jun 1 07:46:22 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Fri, 01 Jun 2001 13:46:22 +0200 Subject: Problem using SocketServer.ThreadingTCPServer on Windows? References: <3b15725e.157061953@news.supernews.com> <3B165150.B92A406E@stroeder.com> <3b16b6bb.1015937@news.supernews.com> Message-ID: <3B17808E.2078BD76@stroeder.com> xtian wrote: > > >If it's Python 2.1 it could be this one: > >http://sourceforge.net/tracker/index.php?func=detail&aid=417845&group_id=5470&atid=105470 > > > [..] > So is the solution to have the child thread call > server.close_request() after the loop, and modifiy the server class to > only call close_request if there's been an exception? IMHO the thread should have a try: finally: statement to make sure the socket is closed as suggested by "xlagraula" at the URL above. I reported the bug two times in this news group at 2.1beta and gamma. It could have already been fixed for 2.1 release. Unfortunately no one did care maybe due to the tight release schedule. :-( Ciao, Michael. From salvatore.didio at wanadoo.fr Wed Jun 6 10:41:29 2001 From: salvatore.didio at wanadoo.fr (Salvatore DI DIO) Date: Wed, 6 Jun 2001 16:41:29 +0200 Subject: Grail Python2.1 Message-ID: <9flevu$495$1@wanadoo.fr> I'm running Python2.1 on Solaris2.6 with Tkinter. I can't launch Grail. I have a socket error in MyHTTP module Did anybody experienced the same problem Thank you very much. BTW : All is fine with Python 1.52 From gzeljko at sezampro.yu Sat Jun 9 03:47:22 2001 From: gzeljko at sezampro.yu (gzeljko) Date: Sat, 9 Jun 2001 09:47:22 +0200 Subject: spell method chaining? References: <19l8IVAAgJI7EwAk@jessikat.demon.co.uk> <3B2111FF.D998EEE4@letterror.com> Message-ID: <007901c0f0b8$88fc03c0$ecbe6ac2@zko> From: Robin Becker > > from __future__ import nested_scopes > def gen(B): > class W(B): > __base = B > def __init__(self): > self.__base.__init__(self) ^^^^^^^^^^^^^^^^ > return W > > class C: > def __init__(self): > pass > > gen(gen(C))() > > recurs infinitely. Yes, 'cos You are searching __base always from self (instance object), and found always the same __base. So You can't bind __base to class object and achieve desired recursion, but ... > > > from __future__ import nested_scopes > def gen(B): > class W(B): > def __init__(self): > B.__init__(self) > return W > > class C: > def __init__(self): > pass > > gen(gen(C))() .... You can bind __base to metod what You effectively did here. You can get it without nested scopes, with temporary variable: import g # empty module, for globals def gen(B): g.temp = B class W(B): def __init__(self, base = g.temp): base.__init__(self) del g.temp return W I-didn't-proposed-that-ly gzeljko > > -- > Robin Becker > -- > http://mail.python.org/mailman/listinfo/python-list > From aleaxit at yahoo.com Tue Jun 19 12:59:52 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 19 Jun 2001 18:59:52 +0200 Subject: Python version of IQ has been updates (IQ v0.34.python) References: <505.566T11T1243597threeseas@earthlink.net> <3B2A7F5E.MD-1.4.4.padf@ihug.com.nz> <3871.567T2214T9794928threeseas@earthlink.net> <87puc3ao42.fsf@pooh.honeypot> <2509.568T2823T9766233threeseas@earthlink.net> <9gkftm026v9@enews2.newsguy.com> <87k829ai6y.fsf@pooh.honeypot> <9gnkp00o7f@enews2.newsguy.com> <87g0cwqxzu.fsf@pooh.honeypot> Message-ID: <9go0e7018g9@enews2.newsguy.com> "Kirk Strauser" wrote in message news:87g0cwqxzu.fsf at pooh.honeypot... > > At 2001-06-19T13:40:46Z, "Alex Martelli" writes: > > > "Kirk Strauser" wrote in message > > >> Perl's RE syntax is designed by and for people who have pretty much > >> mastered the subject elsewhere. > > > And where would that "elsewhere" be? > > College, for starters. I had a solid grip on RE's before I ever met Perl. Well, so did I, but that's because I was programming long before Perl was invented, and I _happened_ to use Unix systems (where RE's were widespread). I've worked with people of huge experience who spent their professional lives on such operating systems as DEC's and IBM's and never truly "mastered RE's":-). > Note that I'm not asserting that *my* experience implies similar results for > anyone else. No, but you did state that the RE syntax (that Perl and Python more or less share) IS designed for people who have already "pretty much mastered the subject elsewhere". This may be true, but in that case it underlines the existence of a problem. Not that I can think of any easy solution, mind you:-). > >> Then again, I'm more experienced with C, C++, Java, and other similar > >> languages. > > > More experienced than whom? > > You read that wrong - the proper question is "more experienced than at > what?", to which the answer would be myself at Ada, FORTRAN, Lisp, ML, etc. Oh, that. Yes, I, too, had more experience with C and C++ (not Java yet: it had not been invented at that time), when I met Perl, than with the other languages you list (with the possible exception of Fortran, which I DID use rather extensively -- not quite as much as C, but, by that time of my life, more than C++, which was still rather young and unstable, although clearly an 'emerging language'). > Perl was comfortable to me because of my particular background. I picked it Funny, since our backgrounds seem similar, yet, while I did use Perl extensively and productively, it never was *comfortable* to me. The idea of not being able to easily build complex data structures (we're talking of times well before Perl 5!-), for example, made me just as uncomfortable as it did in Fortran -- yeah, yeah, I used all the usual workarounds and kludges, but it was UNcomfortable to say the least:-). > up because 1) it's what we use at the office, and 2) for whatever reason, it > was an easy step for me. Oh, I know very well why *I* picked it up -- at the time, I was not aware of any real alternative (awk came "close, but no cigar", and I had not heard about Python yet -- I don't think it had yet been published on Usenet, or if it had it must have escaped my notice at the time). It surely beat sh in terms of speed, functionality, etc (don't even get me STARTED about those black souls who write scripts in *csh*...!-). > >> You can write C in Perl if you feel comfortable with it. > > > Not really, since for example in Perl all your variables need > > a leading '$' which C does not require... > > I understand what you're saying, and I wouldn't hope to imply that Perl is > exactly like C. However, the following (working) code snippet should be > transparent to the casual C coder: > > $seconds = time(); > printf("%d seconds since the epoch!\n", $seconds); > > Sure, there are fundamental differences, but a non-Perl coder could probably > maintain the lines above if they had to. If the original author had the discipline to stick to such constructs, eschewing all idiomatic Perl, then, maybe. I _think_ any Perlist would probably write printf "$seconds since the epoch!\n"; I guess the equivalent Python code might be found to have less surface similarity to C: import time seconds = time.time() print "%d seconds since the epoch!"%seconds given the 'import' and the %-operator for the substitution (the ending semicolons are optional, but it's definitely NOT idiomatic Python to use them, and I don't think it makes sense to use a language in strongly anti-idiomatic ways). > Honestly, Alex, I never meant to disparage Python in any way. Although I > haven't personally used it, people I trust claim that it's a great > language. I just happened to have a lot of Perl experience, and someone > asked a question for which my answer was "try Perl!". I respect that your > answer is different, just as mine may very well be in the future. I think I understand you well, and thanks for the clarification. I might probably have said "try Perl" myself just a couple years ago (I *did* use Perl for a huge morass of scripts to run some very serious computational tasks, with significant success -- but I think those thousands of Perl lines were what finally broke my Perl tolerance forever... *thanks be* I found Python then!-). Alex From loewis at informatik.hu-berlin.de Tue Jun 5 04:37:47 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 05 Jun 2001 10:37:47 +0200 Subject: How to get the size of an object? References: Message-ID: Michael Hudson writes: > stain at prigioniero.it (Nicola S.) writes: > > > Is there a way to get the size of an object in Python? > > I mean something like 'sizeof' C operator... TIA > > Roughly speaking, no. To put that differently: the size of an instance object is 16. Regards, Martin From rnd at onego.ru Wed Jun 27 01:48:49 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 27 Jun 2001 09:48:49 +0400 (MSD) Subject: PEP 260: simplify xrange() In-Reply-To: <3B39480C.F4808C1F@Lugoj.Com> Message-ID: Maybe we also want to add: from __past__ import full_xranges ;-) Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From kwoeltje at mail.mcg.edu Tue Jun 12 09:16:16 2001 From: kwoeltje at mail.mcg.edu (Keith Woeltje) Date: Tue, 12 Jun 2001 13:16:16 GMT Subject: Newbie References: <20010611151900.11318.00004174@ng-mp1.aol.com> <3A9V6.11832$Dd5.3141345@ruti.visi.com> Message-ID: <3B261661.4CBE90DB@mail.mcg.edu> While Beazley is indeed an "essential reference," it's really intended as just that--a reference. Someone completely new to programming would have a hard time getting started. with that. Complete newbies need a lot of words--they need to have concepts explained in multiple ways until one clicks. Clearly there needs to be two type of Python "beginners" books--one for programmers who are new to Python (Learning Python and The Quick Python Book both good in this category, although they make some concessions to the programming newbie. Core Python even tries a bit harder to ease in those new to programming), and the other type for those new to programming who are using Python as their first language (a good choice, I think most on this newsgroup would agree. Gauld's book is the only one that really makes an effor to approach this, although there are also some web sites that try.) I think the tutorial falls more into the first category. Probably not the best source for the true newbie. On a different note, and forgive me for being unkind, but one can only imagine that someone with e-mail addresses of pcgamesrule at hotmail.com and justsurfn2004 at aol.com is headed towards a career of being a l33t scriptkiddie. Hopefully learning Python will keep him on the light side of the force ;-) . >K "Kurt B. Kaiser" wrote: > Amazon says June 13, you can pre-order. Definitely worth > getting the 2nd ed. > > Most of the "beginner" books are *way* too wordy! It > would be better to be concise like Beazley and take > the space to teach more general programming ideas. From sill at optonline.net Sun Jun 17 04:55:21 2001 From: sill at optonline.net (Rainy) Date: Sun, 17 Jun 2001 08:55:21 GMT Subject: qt or gtk? References: <9ggof8$gmd$1@brokaw.wa.com> <9ghg8c$teo$1@brokaw.wa.com> Message-ID: On 17 Jun 2001 05:46:52 GMT, Elf Sternberg wrote: > In article <9ggof8$gmd$1 at brokaw.wa.com> > Jonathan Gardner writes: > >>Courageous wrote: >>> Do recall that Qt is only *half* free. It is free for Linux development, >>> but costs an arm and a leg on Windows. > >>Now I feel stupid. I thought Qt was free to use if your software is >>free, but costs money if you plan to sell it. > > Qt is distributed under the GNU Public License and TrollTech's > Commercial License. What this means is that if you write a program > using Qt, you have two choices: you can distribute your program in the > whole, source code and all, or your can pay TrollTech's licensing > contract and keep your source code secret. Is this true for both qt for X and qt for windows or only for X qt? [snip] -- Shine on you crazy diamond - Roger From tim.one at home.com Fri Jun 15 17:02:33 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 15 Jun 2001 17:02:33 -0400 Subject: PEP 255: Simple Generators In-Reply-To: <9gdmdb$3c4$1@nntp1.ba.best.com> Message-ID: [David S. Harrison, on c.l.py] > This is an awesome PEP. I have used Icon extensively in the past > and I have found generators to be very useful and elegant. It was > not exactly clear in the proposal, but will it be possible to > enumerate elements outside of the "for" idiom? The ability is implicit in the PEP's: Instead a generator-iterator object is returned; this conforms to the iterator protocol[6], ... [6] The concept of iterators is described in PEP 234 http://python.sf.net/peps/pep-0234.html I'm afraid PEPs aren't tutorials, though, and it's a Positive Good not to repeat info across them. For a very simple example, def genid_func(i): while 1: yield i i += 1 getid = genid(5).next print getid() # prints 5 print getid() # prints 6 print getid() + getid() # prints 7 + 8 = 15 > Sometimes it is useful to get elements out of a generator in different > parts of a program. For example, the first few elements might be > consumed by one function, and the next by another. Is this possible > under PEP 255? Yes. Curiously, though, it's *not* possible in Icon: generators are tied to control context there. In Icon you have to use full-blown co-expressions if you want to get the ability independent of generative control structures. PEP 255's generators are more capable than Icon's in this respect (but possibly less capable than Icon's co-expressions). From duncan at NOSPAMrcp.co.uk Thu Jun 21 06:54:39 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Thu, 21 Jun 2001 10:54:39 +0000 (UTC) Subject: NT Service and COM Message-ID: Has anyone got a simple example of doing an NT service that also acts as a COM server? It looks as though it shouldn't be too hard, but if someone else has already done it I wouldn't mind copying. Pedants note that the newsgroup title is supposed to imply the choice of implementation language which therefore goes without saying. -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From jeff at ccvcorp.com Fri Jun 1 20:06:02 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: 1 Jun 2001 17:06:02 -0700 Subject: Copying files to multiple comp's on a lan References: <9f8k3v$1i04$1@news.cybercity.dk> Message-ID: <16074dce.0106011606.4a7b987d@posting.google.com> Hm, I'd probably use the os.system() call in preference to reading the source and then creating new destination files, as D-Man's example does, though the choice is probably trivial and entirely personal opinion. Example: --------------------- import sys import os # note Win32 uses \, not / :) machines = [ "\\Mach1\C" , "\\Mach2\C" , "\\Mach3\C" ] source_file_path = sys.argv[1] dest_path = sys.argv[2] for machine in machines: # always use os.path.join() when building paths.... dest_fullpath = os.path.join(machine, dest_path) cmd_string = "copy %s %s" % (source_file_path, dest_fullpath) os.system(cmd_string) --------------------- You'd probably be better off if the machine/drive specs were built using the functions in os.path as well, but that's a minor detail. I'd also, if I were writing this script for my own use, add a few print statements to report on the current status, etc.... I'd also probably put the os.system() call within a try/except block, just in case. And of course, this all presumes that you do have write permission on all of these machines. :) Jeff Shannon Technician/Programmer Credit International From scarblac at pino.selwerd.nl Mon Jun 25 18:27:27 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 25 Jun 2001 22:27:27 GMT Subject: How to determine if something is hashable? References: <3B377987.4010304@cbmi.upmc.edu> Message-ID: Andrew Post wrote in comp.lang.python: > Hello, > > I want to write a function that takes a list of keys and a list of > values and returns a hash. I want to test, however, that all of the > items in the list of keys are hashable. How do I do this? The only way > that I've come up with so far is to do: > > try: > myDict[ keyList[ i ] ] = valList[ i ] > except (TypeError): > print keyList[ i ], 'is not hashable' > > TypeError isn't specific to finding a non-hashable key, though, right? In that case, I don't see what else could raise TypeError though. But you can try more explicitly with: try: hash(valList[i]) except TypeError: ... -- Remco Gerlich From missive at frontiernet.net Sat Jun 23 11:03:41 2001 From: missive at frontiernet.net (Lee Harr) Date: Sat, 23 Jun 2001 15:03:41 +0000 (UTC) Subject: adding instance methods after instantiation References: <9h1vg2$14cc$1@node21.cwnet.roc.gblx.net> Message-ID: <9h2b4c$fpq$1@node21.cwnet.roc.gblx.net> On 23 Jun 2001 14:28:34 GMT, Marcin 'Qrczak' Kowalczyk : > Sat, 23 Jun 2001 11:45:06 +0000 (UTC), Lee Harr : > >> Is there some way to make m2 an instance method so that >> it will automatically get passed c1 as its first >> argument? > > You are putting it in a concrete instance. In this case you know > the instance to pass: > c1.m2 = lambda *args, **kwargs: m2(c1, *args, **kwargs) > > Note that it requires 'from __future__ import nested_scopes' if used > inside a function. Without that feature m2 and c1 would have to be > passed using the default argument trick and the function could not > be fully general (these default arguments would not be available > in kwargs). > > It creates a reference cycle. Newer Python versions garbage collect > this, although not immediately; older don't. > > If the function is used only in one instance, you could as well refer > to self as c1 in its body instead of through the argument, and > the above would not be needed. > > If you put the method in a class instead of in the instance > (i.e. c.m2 = m2), it will be passed the instance implicitly > (and it will be available from all instances). Thank you. I think this is going to do what I want: class c: def __init__(self): self.a1 = 1 def m1(self): #outside of class definition self.a2 = 2 c1 = c() c.m1 = m1 c1.m1() c1.a2 So, if I were then to pickle c1 (or put it in to ZODB) it would still have the m1 method when it came back out of storage? Does this make sense, or should I really be looking for a way to subclass c and then copy over any data from c1 to a new instance of the new subclass? > > -- > __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ > \__/ > ^^ SYGNATURA ZAST?PCZA > QRCZAK From tdickenson at devmail.geminidataloggers.co.uk Tue Jun 5 10:40:11 2001 From: tdickenson at devmail.geminidataloggers.co.uk (Toby Dickenson) Date: Tue, 05 Jun 2001 15:40:11 +0100 Subject: suggestion: swap function in Python References: <3B150A65.5D4986FC@europem01.nt.com> <20010530173327.C690@xs4all.nl> Message-ID: Skip Montanaro wrote: > If you need it to be atomic (the >only possible reason I can see for implementing this idea), you'd have to >define a new opcode for the Python VM. I dont think it is possible to implement an atomic swap in Jython. If you are happy with a CPython-only solution, use bytecodehacks. Toby Dickenson tdickenson at geminidataloggers.com From matt at mondoinfo.com Sun Jun 10 13:45:07 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Sun, 10 Jun 2001 17:45:07 GMT Subject: bind keys References: Message-ID: On Sun, 10 Jun 2001 14:43:09 +0200, Gorny wrote: >How do I bind keys to my menubaroptions with TkinteR? I can't figure >out anything on the web. Nowhere is a good tutorial with that >informatioin in it.. Gorny, It turns out that in order to make Tkinter menus respond to alt-keys, you need to create them with the somewhat unintuitive option, underline=0. There's an example of that in the Demo directory of the standard distribution, specifically in: Demo/tkinter/matt/menu-simple.py and I'll append another in case you don't have that handy. But I suspect that you might find using the menu widgets from Pmw (Python megawidgets) easier. I certainly do. Pmw is at: http://pmw.sourceforge.net/ Regards, Matt from Tkinter import * import sys class mainWin: def __init__(self,root): myMenubar=Menu(root) myMenu=Menu(myMenubar) myMenu.add_command(label="Do something", command=self.doSomething,underline=0) myMenu.add_command(label="Quit",command=self.quit,underline=0) root.config(menu=myMenubar) myMenubar.add_cascade(label="Foo",menu=myMenu,underline=0) return None def doSomething(self): print "foo" return None def quit(self): sys.exit(0) def main(): root=Tk() mainWin(root) root.mainloop() if __name__=="__main__": main() From slinkp23 at yahoo.com Mon Jun 4 23:00:09 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Tue, 05 Jun 2001 03:00:09 GMT Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3B1B1825.8109BA83@lmf.ericsson.se> <2v4ohtgldvce84sn87kh1eg1lnes37getq@4ax.com> Message-ID: <3B1C4A16.1FAAA786@yahoo.com> > On Mon, 04 Jun 2001 08:09:57 +0300, Attila Feher > wrote: > > You imply that Unices are used in banks and secure places > > which is not true either, at least not for most. Counterexample: a friend of mine worked at a Fleet data center where they used HP-UX. Fleet is one of the largest banks in the northeast USA. I'd say that's a pretty big counterexample. Now, remind me what any of this has to do with python? --PW From chrishbarker at home.net Mon Jun 18 18:58:24 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 18 Jun 2001 15:58:24 -0700 Subject: csv-0.3 released References: <3B2E5BFB.F0EAB859@home.net> Message-ID: <3B2E8790.8A047186@home.net> Skip Montanaro wrote: > Chris> This appears to mean that the CSV parser is slower that > Chris> string.split, and as far as I can tell, does pretty much the same > Chris> thing. What am I missing? > > CSV files can be syntactically more complex than simply inserting commas > between fields. For example, if a field contains a comma, it must be > quoted: > > 1,2,3,"I think, therefore I am",5,6 Ahh, I figured I was missing something! As it happens, I've been intending to write something similar...I was going to call it quoted_split, or something like that. IMHO, Python should have something like this in it's native string methods, it is a pretty common thing to need, and there it would be pretty slow in native Python. Dave, I suggest you put a more complicated example on your web site, so that people (lke me) will have a better idea what a valuable thing you are offering! -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From edcjones at erols.com Thu Jun 14 12:27:28 2001 From: edcjones at erols.com (Edward C. Jones) Date: Thu, 14 Jun 2001 12:27:28 -0400 Subject: How to get reference ownership infomation in C? Message-ID: <3B28E5F0.4000106@erols.com> Suppose ppo is a PyObject*. Is there some way to find out who owns the reference counts for ppo. Put another way, listing who is responsible for making the various Py_DECREF calls that will be needed? Thanks, Ed Jones From yozh at niit.ru Wed Jun 13 02:24:34 2001 From: yozh at niit.ru (Stepan Koltsov) Date: Wed, 13 Jun 2001 06:24:34 +0000 (UTC) Subject: Recursive algorithms anyone? References: <1f0uhtgmhb0vlud6pof6i4mctqjdq8l2eu@4ax.com> Message-ID: <9g70v2$24ho$2@proxy.niit.ru> Nick Perkins wrote: ...skipped > from __future__ import nested_scopes > def additem(k,L): > def _additem(x): > if type(x) is type([]) : return map (_additem,x) > else : return x+k > return _additem(L) IMHO more proper is import types ... type( x ) is types.ListType because less operations performed (e. g. creating new list)... -- mailto:yozh at mx1.ru ICQ:26521795 http://www.mx1.ru/ ... ??? ???? ????? ? ????????? ? ??????? ???? ????? ? ???? ????... From tgos at spamcop.net Wed Jun 6 23:57:02 2001 From: tgos at spamcop.net (TGOS) Date: 6 Jun 2001 22:57:02 -0500 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3b1cdc84.5514@bolder.com.co.za> <9fleid$3rp$1@oslo-nntp.eunet.no> <3B1E4951.7F36D4E4@alcyone.com> <3B1E50E1.35AE59C@lmf.ericsson.se> Message-ID: On Wed, 06 Jun 2001 18:48:49 +0300, Attila Feher wrote: > Erik Max Francis wrote: > [SNIP] >> Either that or you like playing games. Competent computers users and >> programmers play games too, you know. > > If they have time and no headache :-((( > > BTW some competents I know play games... really... although I have never > seen an original box of any game they play :-))) So OK they do play. > But do they buy? Oh, I like playing games, especially Java multiplayer games that I can play directly from within my browser on all the different UNIX system we have at university. ^__^ -- TGOS From James_Althoff at i2.com Fri Jun 15 15:28:58 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Fri, 15 Jun 2001 12:28:58 -0700 Subject: Inner classes Message-ID: Samuele Pedroni wrote: >I hope you know that you can do the following in jython: > >class StupidExample: > > def butAAction(self,e): > .... > > def butBAction(sel,e): > ... > > def __init__(self): > self.butA = JButton("A",actionPerformed=self.butAAction); > self.butB = JButton("B",actionPerformed=self.butBAction); > >or even lambdas instead of bounded methods if your code is short enough > > Samuele Pedroni. Absolutely. We have done a couple hundred thousand lines of Jython/Swing code here and the idiom above is one of our favorites! Jython Rocks! Jim From dsh8290 at rit.edu Tue Jun 19 14:49:00 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 19 Jun 2001 14:49:00 -0400 Subject: Which IDE ? In-Reply-To: ; from philh@comuno.freeserve.co.uk on Tue, Jun 19, 2001 at 05:57:00PM +0100 References: Message-ID: <20010619144900.B7032@harmony.cs.rit.edu> On Tue, Jun 19, 2001 at 05:57:00PM +0100, phil hunt wrote: | On Mon, 18 Jun 2001 22:57:13 GMT, VanPopering wrote: [Which IDE?] | | I think professional programmers often prefer simple tools (i.e. | text editor and command line). Sounds like a reasonable guess to me (at least wrt Unix programmers, I think more MS Windows programmers use Visual Studio and other similar tools). I use vim + bash also. I have tried some other environments, but I haven't found any that I like as much. I do sometimes use some IDE for a debugger interface (DDD, JBuilder, NetBeans, whatever - depends on what machine I'm at and what I'm working on). -D From timr at probo.com Sun Jun 3 02:40:49 2001 From: timr at probo.com (Tim Roberts) Date: Sat, 02 Jun 2001 23:40:49 -0700 Subject: random References: Message-ID: <3omjhtc1j82ot6fdsgnlnqi17kuqspfdsc@4ax.com> Lulu of the Lotus-Eaters wrote: > >But if you are not happy with mere physical/empirical impossibility, it >works equally well for mathematical impossibles: > > <2+2=5> IMPLIES <2+3=6> > >works fine by application of Peano arithmetic. This brings to mind an old joke. A philosophy professor lecturing his class states, "given any false statement, I can prove any other statement." A student stands up and challenges "OK, given 3 equals 8, prove you are the pope." The professor thinks for a moment. "All right, 3 equals 8. Adding 2 to both sides, we get 5 equals 10. We divide both sides by 5, and get 1 equals 2. Now, I think everyone will acknowledge that the pope and I are two people. Since we have shown that 1 equals 2, we conclude that the pope and I are one person." -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From dsh8290 at rit.edu Mon Jun 18 14:17:46 2001 From: dsh8290 at rit.edu (D-Man) Date: Mon, 18 Jun 2001 14:17:46 -0400 Subject: why is there no class (static) methods in Python ? In-Reply-To: <3B2E31A6.9A5B378@intraware.com>; from rgruet@intraware.com on Mon, Jun 18, 2001 at 04:51:53PM +0000 References: <3B2D114E.7B39D954@intraware.com> <3B2D6669.7DEFD13F@intraware.com> <3B2E31A6.9A5B378@intraware.com> Message-ID: <20010618141746.B4516@harmony.cs.rit.edu> On Mon, Jun 18, 2001 at 04:51:53PM +0000, Richard Gruet wrote: | Martin von Loewis wrote: | | > Richard Gruet writes: | > | > > But the reason to choose to define a function as a class method | > > rather than a mere (static) function is -obviously- when this | > > function is closely related to the class itself, not to one of | > > its instances. | > | > Depending on how exactly it is related, provinding a module function might | > *still* be the better solution - even if class methods were available. | | Only if the module contains only one class.. That depends on how you name your function and what purpose they serve and what arguments they take. | > > In fact, constructors (and destructors) are class methods, not | > > instance methods, but they are handled specially in the language | > > so they appear as instance methods.. | > | > No, constructors (at least as available in Python, C++, and Java), | > are really initialization methods, and thus instance methods. This | > is easily seen as they get an object as implicit argument. | | Yes, I agree that the concrete purpose of constructors is to | initialize instances. But more generally, and from a semantical | point of view, calling a constructor *creates* a new instance, even | if the programmer gains control only on the init part. Then I'd say | that a constructor belongs to the class as well as to the instance | being created. Actually, the ctor doesn't create a new object. In C++ and Java it is the 'new' _operator_ that creates the object, then passes it as an argument to the implicitly called ctor. Calling, ex, super() doesn't create another new object, but simply calls a method on the current object. In Python calling the class object will create a new instance, and then implicitly call __init__ handing that instance as an argument. The __init__ can then call P.__init__( self ) (assume a parent class 'P' and the instance is named 'self') which simply invokes a function and doesn't create another new instance. | > > Typical examples of class methods: | > > loadInstanceFromStream(aStream) # Create an instance from its | > > # persistent | > | > That is a factory function, something that should be separate from | > the class itself. | | Yes, I read the GoF too. But a class is a factory of instances, no ? People in this group have noticed that many of the GoF patterns are built in to Python, while in C++/Java they are patterns that are much more involved. I think it is no coincidence that Python is flexible and not class-based (but rather object-based with modules being a significant type of object) whereas C++ and Java are inflexible (certainly less flexible than Python) and class-based. | > > getInstanceCount() # returns the number of instances | > > getInstanceList() # returns the list of instances | > > getClassName() or getAnyInfoOntheClass() ...... | > | > These ought to be globl functions, taking the class as an | > argument. Some of these are really easy to implement in Python: | > | > def get_class_name(x):return x.__name__ | | No, I completely disagree. WHY should they be *global* functions | rather than *class* functions (since they are strictly related to | the class) ? You provide no arguments ! Using the class namespace | rather than the module namespace for class-related functions seems | more natural (and object oriented) to me. They should be global because (maybe) all classes should support that interface. It would certainly be useful for profiling. Those functions are related to the class you are putting them in, but are much more general. | And finally, I wonder why they are class methods in Java ? They Java has class methods becuase the Java designers don't believe in classes as the end-all. They don't believe in all objects, just the objects that are instances of classes, and the classes themselves (for example functions aren't objects, nor are "primitive" variables). Java doesn't have modules, so they must fake it by using the 'class' construct and adding the 'static' keyword to some methods. A class is a template for instance objects. The template shouldn't contain extra stuff in it that isn't for the objects being templated. Modules are nice containers that restrict the "globalness" of functions and other objects while providing a cohesiveness wrt the class object. Modules and classes complement each other very nicely, and should be used as such. The 'class' shouldn't be the "only" construct in a language. BTW, there has been some discussion recently on adding meta-classes to Python. I haven't followed it too closely yet (as I still need to understand exactly how the concept works), but it may provide the facilities you are seeking (given your reference to Smalltalk's metaclasses). -D From graham at coms.com Sun Jun 24 12:37:42 2001 From: graham at coms.com (Graham Ashton) Date: Sun, 24 Jun 2001 17:37:42 +0100 Subject: Choosing SAX parsers Message-ID: I've just started playing with xml.sax and the XML HOWTO. I had to recompile python to include expat as I didn't have any other parsers available (python 2.1, built from source, Debian Linux). This is fine, and xml.sax works nicely with expat now that I've recompiled, but I was a bit surprised that expat was the only parser availble after the docs had been telling me how I could choose between parsers, etc. Am I missing some stuff? What I'd really like is a parser that knows how to enforce DTDs, which I know expat-1.x doesn't. Speed isn't an issue for me as my documents are very small. What's my best bet? Installing PyXML? If I do, will it overwrite the xml.* module tree that I've got already? Are there any issues installing it over the top of the stuff in the standard library (some of which I believe is the same codebase)? Any pointers would be much appreciated. Thanks. -- Graham From llothar at mailandnews.de Sat Jun 30 10:15:25 2001 From: llothar at mailandnews.de (Lothar Scholz) Date: Sat, 30 Jun 2001 16:15:25 +0200 Subject: GUI Builder for Python ? Message-ID: Is there something other then "Black Adder" which is behind an alpha version ? From MarkH at ActiveState.com Thu Jun 21 20:59:02 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Fri, 22 Jun 2001 00:59:02 GMT Subject: Stop/Start Service in Win2k References: <%4vY6.9705$Up.285700@sea-read.news.verio.net> Message-ID: <3B329854.1050405@ActiveState.com> Robin Siebler wrote: > win32service.SERVICE_QUERY_STATUS) > api_error: (1060, 'OpenService', 'The specified service does not exist as an > installed service.') > > > Could someone tell me why this happens and how to fix it? Probably because you need to use the "service short name" rather than the "service description". Most UI tools display the description rather than the shortname. You really need to look in the registry for the short name (HKLM/System/CurrentControlSet/Services". A patch to win32serviceutil that tries to locate the short name given the long name would be gratefully accepted :) Mark. From m.faassen at vet.uu.nl Sat Jun 16 07:18:01 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 16 Jun 2001 11:18:01 GMT Subject: Any other Python flaws? References: <9gbe4e$gla$2@newshost.accu.uu.nl> <3b2a80ed.326615828@news1.on.sympatico.ca> Message-ID: <9gff99$eag$1@newshost.accu.uu.nl> Robert Roy wrote: > On 14 Jun 2001 22:33:50 GMT, m.faassen at vet.uu.nl (Martijn Faassen) > wrote: [snip] >>This may be considered a minor quibble; the mandatory use of () in >>case of multiple arguments to the % string interpolation operator: >> >>"%s" % "foo" >> >>"%s %s" % "foo", "bar" # doesn't work right >> >>"%s %s" % ("foo", "bar") > Would that not allow for more ambiguities than its worth? It would > make nested tuples would be extremely dangerous. Oh, sure; I'm not saying the mandatory ( and ) aren't there for reasons. It's just something that could be considered a wart. The reason is that of operator precedence; the % binds more strongly than the ',' which tries to construct a tuple. Therefore: "foo %s" % "bar", "baz" Will get us: ("foo bar", "baz") And not an error like: "foo %s" % ("bar", "baz") > This is clear > ('this', '%s %s' % ('foo', 'bar'), 'that') > If I change my format string to '%s %s %s' the interpreter will yell > at me if I do not add an element to my tuple > This is not > ('this', '%s %s' % 'foo', 'bar', 'that') > If I change my format string as above and fail to add the appropriate > element to the tuple, I have an extremely hard to find bug. Um, for the % operator it goes that far, and 'magic' behavior probably wouldn't be desirable, so the parens may be the best bet, but tuples in Python in general can exist without surrounding (), as long as things aren't ambiguous. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From mertz at gnosis.cx Fri Jun 1 10:40:41 2001 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Fri, 01 Jun 2001 10:40:41 -0400 Subject: Obsolesence of <> Message-ID: "Alex Martelli" wrote: >> In the end, spelling is arbitrary, of course. But having families >> of corresponding spellings for corresponding semantics makes it >> easier to remember a language, and to teach it. |Exactly. Teaching (and teachees' remembering:-) is my focus |on such issues. "lesser/greater" is the WRONG suggestion to |impart syntactically when desired semantics is "not equal", |given that "ab" and "a <> b" behave differently. Not |that != is ideal, of course, but at least it avoids such |specific "subliminal misinformation" I entirely agree with Alex that the subliminal message of "<>" has gotten much worse in 2.1. OTOH, I really can't see how to construe the loss of universal inequality operators as a good thing. I'm starting to believe it a sin on the order of "print >> file" :-(. Spelling is just spelling, of course, but some spelling is better than other spelling (as the Orwell thread reminds one). However--hopefully not belaboring the point--my problem with "!=" is that it contains much stronger subliminal misinformation, even still, than "<>" does. "!=" just plain LOOKS like it should be an augmented assignment. Admittedly, *this* only "broke" in 2.0. But I think I can make a strong argument that there are more users of 2.0+ than there are of 2.1+. What-the-heck-is-wrong-with-.NE.-ly yours, Lulu... From scarblac at pino.selwerd.nl Thu Jun 28 04:06:34 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 28 Jun 2001 08:06:34 GMT Subject: list of dictionaries References: <3B3A4B97.5F4EB1F1@cc.gatech.edu> <9hdjmt$dk0ki$1@ID-11957.news.dfncis.de> <3B3A58A1.AE09529@cc.gatech.edu> <9hdme5$di2n4$1@ID-11957.news.dfncis.de> <3B3A8F20.71F0DE04@cc.gatech.edu> Message-ID: George Thomas wrote in comp.lang.python: > That makes sense. However, to make sure I understand completely, I'll > list the steps in question. > Given: A single dict object, call it dict (how original!) > 1. Start with empty list > 2. Update fields of dict > 3. append dict to list. > 4. Update fields of dict. > 5. append dict to list. > The thing I can't understand is: even though dict reflects the change in > (4), the append() operation seems to ignore it completely, giving me a > copy of the previous contents. Why does this happen ? You append the same dictionary every time. There is no copy. The list just stores references to objects - all elements of the list are just references to the same dictionary. When you do dict_entry = {} in between, you make a new dictionary, fill that, then add it to the list, so that there are different dicts in the list. Alternatively, you could use sample_list.append(dict_entry.copy()) to explicitly make a copy of the dictionary (but I think you want a new one each time, conceptually). (Oh, Emile already said that). Lesson learned: all variables are just references in Python, it never makes a copy implicitly, everything is done by handing references to objects around. -- Remco Gerlich From brian at rk-speed-rugby.dk Thu Jun 7 03:59:23 2001 From: brian at rk-speed-rugby.dk (Brian Elmegaard) Date: Thu, 07 Jun 2001 09:59:23 +0200 Subject: Windows editor? References: <3af2c38f.341431824@News.CIS.DFN.DE> Message-ID: <3B1F345B.4E04FDE9@rk-speed-rugby.dk> Mike Read wrote: > > > > > > > > >What's a good Python editor for programming under Windows, specifically > > > > >Windows 2000? According to Google archives it seems this IMHO, Nothing beats emacs. -- Brian (remove the sport for mail) http://www.et.dtu.dk http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug \TeX, tak From aleaxit at yahoo.com Tue Jun 12 18:17:38 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 13 Jun 2001 00:17:38 +0200 Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> <9g5h4c01rba@enews2.newsguy.com> <9g5ink015sb@drn.newsguy.com> Message-ID: <9g64uu0j8j@enews1.newsguy.com> "thinkit" wrote in message news:9g5ink015sb at drn.newsguy.com... ... > um...? see, this is exactly what i'm talking about. binary is simple...this is > not. i don't really care about a bunch of old men who wanted to argue over the > number 0. Right. You don't care that they INVENTED logic -- the word, the concept, AND the principles you still revere, of course. > maybe they just got tired of jerking off and decided to spew some > garbage to sound smart and score more chicks. just my guess. Is your knowledge of Classic Greek culture REALLY so poor that you think they went for *CHICKS*?! > and i suggest a look at lojban, a logical language. you can learn it without I see it claims "hundreds of supporters" with a "What's New" page last updated over a year ago... very impressive success indeed! > referring to a bunch of old dead farts. http://www.lojban.org . What an abyss of poor taste you display here. Dr. James Cooke Brown, the inventor of Loglan (from which the Lojlan project split -- and despite the acrimony over the years, they do *NOT* deny their debt to him, nor his genius), died last year, of course. Alex From emile at fenx.com Tue Jun 19 10:54:32 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 19 Jun 2001 07:54:32 -0700 Subject: Indentation References: <9gnoom$cpn$1@bob.news.rcn.net> Message-ID: <9gnpbe$9vl3t$1@ID-11957.news.dfncis.de> Comments interspersed below. -- Emile van Sebille emile at fenx.com --------- "GWYoder" wrote in message news:9gnoom$cpn$1 at bob.news.rcn.net... > I'm still trying here is what I'm getting... > > Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 > Type "copyright", "credits" or "license" for more information. > IDLE 0.8 -- press F1 for help > >>> y = 1900 > >>> leap = "no" > >>> if y % 400 == 0: idle automatically indents the next line > leap = "yes" hit the backspace key before entering this line to return to the prior indentation level > elif y % 100 == 0: python wil indent the next line, but you haven't entered one. > > SyntaxError: invalid syntax > > "Chris Gonnerman" wrote in message > news:mailman.992955149.25097.python-list at python.org... > > ----- Original Message ----- > > From: "Pilgrim" > > > > > > > I'm new to programming so take it easy on me :-) > > > > > > I'm going through a book by Ivan Van Laningham and have gotten to > > > indentations. In the example I'm trying duplicate he as written three > > lines > > > from the command prompt. After the third line is a new indentation and > > then > > > the next line starts back at the beginning without the command prompt > >>> > > > and starts with an "elif" statement. According to his tip to start a > new > > > line you just hit return twice when you are done with the indentation. > OK > > > that works fine and starts me at a new prompt >>> but when I type the > next > > > line starting with a "elif" statement it gives me a SyntaxError: invalid > > > syntax. What I'm I missing? > > > > You've got it *almost* right. When you are typing a control-flow > > structure at the interactive prompt, you *don't* press enter twice > > before the next control-flow keyword. To wit: > > > > Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 > > Type "copyright", "credits" or "license" for more information. > > Alternative ReadLine 1.4 -- Copyright 2001, Chris Gonnerman > > >>> t = 1 > > >>> if t == 1: > > ... print "one" > > ... elif t == 2: > > ... print "two" > > ... else: > > ... print "something else" > > ... > > one > > >>> > > > > What you are doing is this: > > > > >>> if t == 1: > > ... print "one" > > ... > > one > > >>> elif t == 2: > > File "", line 1 > > elif t == 2: > > ^ > > SyntaxError: invalid syntax > > >>> > > > > Pressing Enter twice ends the code block, but the if ... elif ... else > > structure must not be broken up this way. > > > > > > From tim.one at home.com Sat Jun 23 14:28:19 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 23 Jun 2001 14:28:19 -0400 Subject: PEP 255: Simple Generators, Revised Posting In-Reply-To: <6qvglnvzwa.fsf@abnoba.intevation.de> Message-ID: [Bernhard Herzog] > With the current implementation that doesn't seem to be entirely true > (CVS from somtime 2001-06-23 afternoon UTC): > > >>> def empty(): > ... if 0: yield 0 > ... > >>> for i in empty(): > ... print i > ... > Traceback (most recent call last): > File "", line 1, in ? > TypeError: iter() of non-sequence > >>> import dis > >>> dis.dis(empty) > 0 SET_LINENO 1 > > 3 SET_LINENO 2 > 6 LOAD_CONST 0 (None) > 9 RETURN_VALUE > >>> empty.func_code.co_flags > 3 > > It seems that the mere lexical presence of the yield statement doesn't > make a function a generator. The compiler apparently optimized the if > statement away before testing whether it's a generator. Yes, it does. So don't do that. This is a general glitchlet, i.e. not specific to generators; e.g. >>> k = 12 >>> def f(): ... if 0: ... k = 3 ... print k ... >>> f() 12 >>> That didn't yield "the expected" UnboundLocalError for the same reason: the affected blocks are actually removed by the *parser*, and "the compiler" proper never knows they were there -- the "if 0" blocks aren't even in the parse tree. That makes it difficult to repair, and since nobody writes "if 0" in real life, that in turn makes the cost/benefit ratio very high. If you disagree, submit a patch . it's-way-over-my-threshold-ly y'rs - tim From maug at kopnet.gliwice.pl Thu Jun 7 03:42:28 2001 From: maug at kopnet.gliwice.pl (Marek Augustyn) Date: Thu, 7 Jun 2001 09:42:28 +0200 Subject: Pythonwin problem Message-ID: <9fnb9h$429$1@zeus.polsl.gliwice.pl> Hello! Strange things begin to happen after starting Pythonwin on my system (win me, python 2.1, win32all-139). For first few minutes everything's ok, but after that period, part of windows gui slows down (looks like 10 times slower) - windows moving, menus opening, alt-tabbing; but scrolling in window works fine. It's enough to start Pythonwin and do nothing. After exiting Pythonwin all problems disappear instantly except menus opening - still slow (little faster than with Pythonwin running). No such phenomenons with IDLE. Have anybody noticed such behavior (and maybe know the cure)? Regards, August. From paulp at ActiveState.com Sun Jun 17 16:44:25 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sun, 17 Jun 2001 13:44:25 -0700 Subject: Any other Python flaws? References: Message-ID: <3B2D16A9.770F0CCD@ActiveState.com> Samuel Schulenburg wrote: > > I see a problem that only occurs in the IDLE, or > Winpython environment. I am not having any luck reproducing this problem in pythonwin. Are you sure that it doesn't matter *what* file you open? Maybe it only happens for large files. Or binary files. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From seefeld at sympatico.ca Mon Jun 18 12:32:58 2001 From: seefeld at sympatico.ca (Stefan Seefeld) Date: Mon, 18 Jun 2001 11:32:58 -0500 Subject: nested classes Message-ID: <3B2E2D3A.75F329D@sympatico.ca> hi there, I'd like to provide a hierarchy of config data by means of nested classes and static variables, such as: class A: prefix='usr/local' class B: datadir = A.prefix + '/share' ... however, I get a NameError: name 'A' is not defined What am I doing wrong ? The above is possibly a bit driven by my C++ programming style. What is the python way of doing this ? Thanks, Stefan From jh at web.de Wed Jun 6 21:44:48 2001 From: jh at web.de (Jürgen Hermann) Date: Thu, 7 Jun 2001 03:44:48 +0200 Subject: tokenizer.. References: Message-ID: <9fmm7a$nu3$01$1@news.t-online.com> "John" schrieb im Newsbeitrag news:fhxT6.245523$Z2.2804247 at nnrp1.uunet.ca... > Is there a built in function or module which allows me to get tokens > from a string? > I know there's the tokenize module but that needs a callable object and it > seems to loop forever... See http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/52298 for an example. From aleaxit at yahoo.com Tue Jun 19 07:17:01 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 19 Jun 2001 13:17:01 +0200 Subject: COM method with pointer args References: <8b5e42a6.0106171630.43a3303a@posting.google.com> <9gkek6024kl@enews2.newsguy.com> <8b5e42a6.0106181007.187e176d@posting.google.com> Message-ID: <9gncbc068k@enews1.newsguy.com> "Levente Sandor" wrote in message news:8b5e42a6.0106181007.187e176d at posting.google.com... > "Alex Martelli" wrote in message news:<9gkek6024kl at enews2.newsguy.com>... > > > > Is there a possibility to use a COM method which requires pointer > > > arguments? > > > > Sure, as long as you have a type library that is correct. Make This "as long as you" is a CRUCIAL prereq. Clearly, from the symptoms you indicate below, such as: > "TypeError: This COM object can not automate the makepy process - ...there IS no correct type library connected to the "CorelDraw Automation" objects you're trying to drive. Without a typelib, you're in trouble in several ways -- and [out] and [in,out] arguments are the start of your problem ("requires POINTER arguments" is most likely *NOT* the issue -- a pointer arg can be declared [in], but then normal Automation dispatching normally fixes things; the problem is, rather, with args that are [out] or [in,out], which will always be pointer ones). I have a hard time believing CorelDraw doesn't distribute a correct typelibrary in SOME form or other -- a .TLB file, or an .IDL one to be compiled, or (most usual) a resource in some .DLL, .EXE or .OCX. Apparently their objects' IDispatch interfaces don't support GetTypeInfo, which is *VERY* bad already, and an almost-unbelievable degree of misbehavior when coupled with rarely-used idioms such as [out] or [in,out] arguments in Automation objects. Hmmm, let's see, in what form do they document their Automation facility? If they give you instructions for using it from Visual Basic, there is likely to be some information about what you're supposed to hook from Project/References... -- that information is likely to be the typelibrary so-called "friendly name", and you can use that with makepy. Or if they give you instructions for using it from Visual C++, it's probably couched in terms of #import -- the file that you're supposed to use with #import is or contains the tlib, so you could use *THAT* with makepy... Remember to start afresh by deleting the gen_py directory every time you want to rebuild the Python wrappers for a type library or part thereof, or halfway-succeded previous attempts may play havoc with the current ones... Alex From gardner at cardomain.com Fri Jun 15 15:47:30 2001 From: gardner at cardomain.com (Jonathan Gardner) Date: Fri, 15 Jun 2001 12:47:30 -0700 Subject: VI References: <3B278900.5828FB59@Lugoj.Com> <9gaunm$mth$3@brokaw.wa.com> Message-ID: <9gdol3$8i7$1@brokaw.wa.com> Jim Hill wrote: > In <9gaunm$mth$3 at brokaw.wa.com>, > Jonathan Gardner wrote: >>James Logajan wrote: >>> "vi" is the first and last word in visual editors. Every editor written >>> before or after it are irrelevant. ;-) >> >>Amen. > > And since the expected editor war hasn't broken out, I'll launch a > different offensive by proclaiming absolutely and without room for > disagreement that it is pronounced "vee eye" and those who say "vye" > are bloody peasants who should be repressed by the violence inherent > in the system. > > > Jim Does this mean "Vim" is "vee eye em" or "vim"???? My coworker who thinks emacs is the one to end all operatings systems pronounces it "vye" which is why he never uses it. "vye" is much less cool than "vee eye". From andy.pevy at nokia.com Tue Jun 19 05:15:11 2001 From: andy.pevy at nokia.com (andy.pevy at nokia.com) Date: Tue, 19 Jun 2001 09:15:11 GMT Subject: Function lookup using a directory. References: <29pX6.14682$cF.320097@news1.nokia.com> <3B2E4CA6.AF9C5D84@accessforall.nl> <3B2F14F5.9582C9F0@accessforall.nl> Message-ID: Hi Again Ype Kingma wrote: > andy.pevy at nokia.com wrote: >> >> Hi Ype >> >> Ype Kingma wrote: >> > Andy, >> >> > In addition to the earlier replies: >> >> > Your run() method seems to be checking for >> > presence of arguments, so you might >> > consider defining it with an extra '*' as: >> >> > class Help0: >> > def run(self, *which): >> > if len(which) == 1: >> > print 'Help no args' >> > else: >> > print 'Help args' >> >> > This will give you a tuple with the passed arguments, >> > in your case an empty tuple. >> >> The argument passed to thee run method is a list, so does this still necessary ??. > That depends on what you want to check in the method. > Your own code (below) calls the method without arguments: >> >> h.run() # Call the run method of the selected class. > This would cause 'which' to be set to an empty tuple for > the execution of the method. My mistake, I should have called the function wih the user entered data split into a list. > Calling it as: > h.run([]) > would cause 'which' to be set to a tuple containing an empty list. > In case you want the empty list to be the default value > define the method as: > def run(self, which=[]): > This would cause the invocation > h.run() > to have 'which' bound to an empty list during execution. > Good luck, > Ype I am now calling f.run(command) and I get the following error message :- TypeError: unbound method must be called with class instance 1st argument I still have a lot to learn about Python me thinks.. -- We were always told that a million monkeys typing for a million years would eventually produce the works of Shakespeare. Now, thanks to the Internet, we know this is not true. From chris.gonnerman at newcenturycomputers.net Tue Jun 26 08:59:44 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Tue, 26 Jun 2001 07:59:44 -0500 Subject: File name from file descriptor? References: <3B335A1E.809B3FF7@snakefarm.org> Message-ID: <004501c0fe3f$e4e547c0$0101010a@local> ----- Original Message ----- From: > >>>>> Carsten Gaebler (CG) writes: > > CG> The problem is this: I have a script that is called like > > CG> ./myscript.py < somefile > > CG> where somefile is a text file which may or may not be gzipped. To > CG> determine whether or not the data is gzipped I read in one byte via the > CG> gzip module. If that raises an exception I know the data is not gzipped. > CG> But I'd miss the first byte if it is gzipped. Yes, I could store this byte > CG> somewhere and then pass it around somehow, but ... you know? :-) So I'd > CG> like to open a second 'instance' of the file for reading but I only have > CG> sys.stdin's file descriptor. > > If you are sure that stdin will be a real file you can use: > > sys.stdin.seek(0,0) Somewhere around here I have an old C program I wrote that does something like this (translated): fp = sys.stdin try: fp.seek(0) except IOError: tmp = open("tempfile", "w+b") tmp.write(fp.read()) tmp.seek(0) fp.close() fp = tmp but then you have to remember to clean up the tempfile afterwards. If you are on a Unixoid OS you can add: os.unlink("tempfile") right after the open() call, and the file will be "garbage collected" by the OS after the interpreter exits. Don't try that on any OS from Redmond! From aleaxit at yahoo.com Sun Jun 17 08:14:20 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 17 Jun 2001 14:14:20 +0200 Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> <9geiir$324$1@216.39.170.247> Message-ID: <9gi6rk01986@enews1.newsguy.com> "Remco Gerlich" wrote in message news:slrn9ip10q.88g.scarblac at pino.selwerd.nl... ... > Adding a way to block rebinding of a name would be a horribly inconsistent > wart on the language. I think this is a slight overbid. It is perfectly possible in Python to "block rebinding" of an object's attribute (__setattr__ easily allows that), after all, yet the sky hasn't fallen. One could similarly allow blocking the rebinding of a container's item (you can do that for a user-defined container, with __setitem__, though not on dictionaries or lists -- tuples do "block the rebindinding" of their items). Such 'blocking' is occasionally useful to help avoid accidental rebinding of things that are not meant to be rebound. Thus, I do not believe it would at all be "a wart of the language" if Python was very slightly extended to either allow a user-defined mapping object to be set as the __dict__ attribute of a module (where now a bona fide dictionary must be used instead), or to make builtin dictionaries slightly more powerful (adding a method that let them block rebinding of some of their items). With either of these slight extensions, there WOULD then most naturally emerge "a way to block rebinding of a name" in every case in which the namespace is a dictionary (not necessarily for local variables of a function -- the local-namespace optimization impedes many generalizations of this kind, of course, although it's apparently indispensable for performance reasons). And what would be wart-y about it *at all*? Isn't it rather a small wart that a user-defined mapping CANNOT be used for any role for which a real-dictionary can...? Alex From steven at haryan.to Thu Jun 7 04:34:39 2001 From: steven at haryan.to (Steven Haryanto) Date: Thu, 07 Jun 2001 15:34:39 +0700 Subject: the definition of "strong" (was Re: Why isn't Python king of the hill?) In-Reply-To: <3B0D8321.17AC1F42@wag.caltech.edu> References: Message-ID: <4.3.2.7.2.20010607153406.034a2e40@bdg.centrin.net.id> Sorry for bringing back an oldish post, but how does one define "strong typing" and "weak typing" vs "static typing" and "dynamic typing"? I've always thought that Python has _strong_ typing, but it is not static. So it is unlike Perl which has weak and dynamic typing (although under -w Perl will issue warnings if you try to mix string and numeric in expressions). I would say _static_ typing is the one that will make me sleep better, because once I tell the compiler that my foo variable is an int, it will stay an int through the course of execution. Steve http://stevne.haryan.to/ At 25/05/2001 04:54, Richard P. Muller wrote: >Something about preaching to the choir comes to mind, here... > >In any case, most of the people in this newsgroup (myself very much >included) would agree with you on improved productivity in Python. > >That being said, there are some advantages to Java. It's built into >almost every web browser on the net. Hard to overstate the importance of >being everywhere. Jython is getting close to putting Python everywhere >that Java is, but (IMHO) one loses some of the simplicity of Python >along the way. Moreover, Java is strongly typed. Sure, you can staple >strong typing into Python, but having it there all the time occasionally >lets one sleep better. Finally, and probably most importantly, managers >who know nothing about programming have some vague feeling that Java is >a good thing. > >Rick From m.huet at online.fr Sun Jun 10 06:27:49 2001 From: m.huet at online.fr (Maurice HUET) Date: Sun, 10 Jun 2001 10:27:49 GMT Subject: ODBC and date Message-ID: Hello, I want transfert data from a progress database to a MySql database with python and the ODBC module. (Win plateform) How can I specify date selection in the SQL order ? The date data cause problem (dbidate type) when i want write tem in a text file between then two database ? Someone have a solution ? Thanks a lot m.huet at free.fr From gustafl at algonet.se Thu Jun 7 17:09:07 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 7 Jun 2001 21:09:07 GMT Subject: PortableUnixMailbox problem References: Message-ID: Joe Murray wrote: >Try using a file-like object as the argument to the PortableUnixMailbox >function: >>>> from mailbox import PortableUnixMailbox >>>> mb = PortableUnixMailbox(open('nsmail/Sent')) >>>> m = mb.next() >>>> m > Yes, it works! Thank you very much! Gustaf From MarkH at ActiveState.com Sun Jun 3 01:19:04 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sun, 03 Jun 2001 05:19:04 GMT Subject: Win32 Debug API References: Message-ID: <3B19C963.9030907@ActiveState.com> Tim Roberts wrote: > The Win32 debugging API is not all that complicated. Has anyone created a > Python wrapper for the APIs like WaitForDebugEvent, ContinueDebugEvent, > DebugActiveProcess, and the symbol manipulation tools in IMAGEHLP.DLL? Not that I am aware of. > > Barring that, I assume there are several automated tools for creating Win32 > API/DLL wrappers. Suggestions? I would suggest you look at SWIG, and the .i files used in my Win32 extensions. The extensions themselves provide some good sample code. All this, including the version of SWIG I use can be found via http://starship.python.net/crew/mhammond/cvs.html Mark. From kamikaze at kuoi.asui.uidaho.edu Thu Jun 21 18:04:51 2001 From: kamikaze at kuoi.asui.uidaho.edu (Mark 'Kamikaze' Hughes) Date: 21 Jun 2001 22:04:51 GMT Subject: qt or gtk? References: Message-ID: Sat, 16 Jun 2001 05:52:12 GMT in , Rainy spake: > I want to learn python gui programming in linux. I think tk looks too > ugly, so You might want to take a second look at Tkinter. The default appearance is fairly bland, but it's easy to change that on an application-wide basis... See the screenshots for Umbra, my Python/Tkinter RPG, for instance: > I narrowed down the choice to two main contenders, qt and gtk. Which of these > has more complete and up-to-date python bindings? Are there other reasons > to prefer one of these over another for python gui work? I like Tkinter for ease of programming - it's the simplest and most pleasant GUI API I've ever used (and I've used X, GEM, OS/2 PM, and Java AWT and Swing). It's also well documented, both with Fred Lundh's tutorial and John Grayson's really excellent book _Python and Tkinter Programming_. --
Mark Hughes "I will tell you things that will make you laugh and uncomfortable and really fucking angry and that no one else is telling you. What I won't do is bullshit you. I'm here for the same thing you are. The Truth." -Transmetropolitan #39 From jeff at ccvcorp.com Fri Jun 1 18:02:53 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: 1 Jun 2001 15:02:53 -0700 Subject: PIL speed and fear References: Message-ID: <16074dce.0106011402.14e4a491@posting.google.com> "akhar" wrote in message news:... > What if I thread the gui and the image filters? will that get me a speed > boost? As I understand it, (though I'm *far* from being an expert), threading will only give speed advantages in a few situations-- 1) Each thread spends a fair amount of its time waiting for an external resource, such as disk access, serial/network i/o, etc, or 2) Multiple processors are available, and each thread can run on a different processor. If you have multiple threads that are all CPU-bound, then you're not going to be running any faster than with a single thread--possibly slower, due to the cost of the context switch (and possibly virtual memory paging.... ) The advantage of multithreading (at least, on a single CPU) is that, while thread A waits for input, thread B can make use of the CPU's free cycles. Well, there's also the arguable advantage that multithreading makes code more understandable by separating different logical units, but it also creates complications with thread-safety and race conditions and such, so ease of comprehension could favor either multi- or single-threading, depending on your POV ....... In your specific case, I'd presume that the filtering would be CPU bound, and I'd *guess* that your gui would be as well, so multithreading will probably not gain you too much, speed-wise, unless you've got multiple processors. Of course, my guess may well be wrong, so maybe you should test it out yourself. :) Jeff Shannon Technician/Programmer Credit International From aleaxit at yahoo.com Fri Jun 15 07:51:01 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 15 Jun 2001 13:51:01 +0200 Subject: Any other Python flaws? References: Message-ID: <9gcsro05ka@enews1.newsguy.com> "Tony J Ibbs (Tibs)" wrote in message news:mailman.992601984.7190.python-list at python.org... > The one thing I *really* hate in Python is the fact that starting a > number with a zero suddenly magically changes its base - yuck. One thing > we could have done with *not* keeping from the C family. Hear, hear! Sigh... > quilting tradition (which may originate from the Amish) - every quilt > should contain a deliberate mistake, since only God can create something > perfect). Nah, that's what print>>blah is for:-). Alex From thomas.hansenNOSPAMORILLSUEYOURASS at entermatch.com Thu Jun 7 03:51:34 2001 From: thomas.hansenNOSPAMORILLSUEYOURASS at entermatch.com (Thomas Hansen) Date: Thu, 7 Jun 2001 09:51:34 +0200 Subject: best language for 3D manipulation over web ? References: <9f7eqe$gvd$1@oslo-nntp.eunet.no> <9fldqf$2bo$1@oslo-nntp.eunet.no> <7rutht85arahtvh10eqlel8lpp81f4o9kh@4ax.com> Message-ID: <9fnba7$irt$1@oslo-nntp.eunet.no> [snip] I saw the link given further up to the "Burning Metal" game, and it was quite impressing, but it wasn't even in the nearby of WTGD... From scarblac at pino.selwerd.nl Fri Jun 15 02:28:55 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 15 Jun 2001 06:28:55 GMT Subject: PEP 259: Revise to remove context-driven magic from print References: <486de2.0106131406.5c0cbef9@posting.google.com> <9gamor$8ft$6@216.39.170.247> <9gap8i0fss@enews1.newsguy.com> Message-ID: Alex Martelli wrote in comp.lang.python: > "David LeBlanc" wrote in message > news:9gamor$8ft$6 at 216.39.170.247... > ... > > makes sense to me. I also liked someone's idea of __print__ - if that > > The 'someone' was me ("was I"...?). > > > idea was in respect of giving objects the power to (as it where) print > > themselves (return their string representation - so call it asstring()). > > How would that differ from the existing __str__ and __repr__ methods? > > No, __print__ would rather underlie the print statement just like > __import__ underlies the import (and from) statements. But I guess > I gotta write a PEP about it... I'm missing the point, I think. What would be useful about that function? I suppose you could override it if you wanted to change print's behavior by assigning to __builtin__.__print__ or so, but then you have a global magic function! And if you override it locally, I don't see how print would use it. Overriding the way print works globally sounds like Perl to me. __import__ is useful if you want to do call it with a string, or do something with it other than assign it to a name in the local namespace. But I don't see any equivalent things with __print__. -- Remco Gerlich From new_name at mit.edu Sat Jun 2 16:21:04 2001 From: new_name at mit.edu (Alex) Date: 02 Jun 2001 16:21:04 -0400 Subject: Sockets References: <3B193770.30999EAC@telocity.com> Message-ID: > how can i check for errors when using the socket module? errors like: > unable to connect; insufficient memory etc. Can you show us some example code that you need extra error checking for? Alex. From seefeld at sympatico.ca Fri Jun 15 13:22:46 2001 From: seefeld at sympatico.ca (Stefan Seefeld) Date: Fri, 15 Jun 2001 12:22:46 -0500 Subject: importing modules: bug or not ? Message-ID: <3B2A4466.7492D9A1@sympatico.ca> hi there, I'v come across a (pretty particular) situation that appears to reveal a bug in python's import mechanism. Please correct me if I'm wrong... Please consider this tiny script (let's call it bug.py): #!/usr/local/bin/python import sys import os import Synopsis __old_dir = os.getcwd() os.chdir('html') import Synopsis.Formatter os.chdir(__old_dir) ----------------------------- it results in ImportError: No module named Formatter even though Formatter is a valid module inside Synopsis. This happens only in this particular context: imagine my PYTHONPATH variable to be 'home/stefan/synopsis'. 'synopsis' contains (among others) the 'Synopsis' module which I want to use for the imports in the script, as well as the script itself. This means that when running the script, the sys.path variable will contain the directory part of argv[0] (i.e. '..' if I called the script like '../bug.py'), as well as home/stefan/synopsis. This is important since when I copy the script to a different place, The path that is used for the import is the second entry in sys.path, and everything works fine. Only if the script is in the same directory as the Synopsis module I get the error. Second, the problem goes away if I don't import 'Synopsis' on top of the script. This sounds like a caching problem, i.e. some internal representation of module/module-paths getting invalidated through the use of chdir. Any clarification would be highly appreciated, as I need to find a workaround for this. Thanks, Stefan From gustafl at algonet.se Sat Jun 16 01:06:55 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 16 Jun 2001 05:06:55 GMT Subject: ASCII decoding error with xml.dom.minidom Message-ID: Still got a problem with encoding/decoding errors when working with xml.dom.minidom. I have run into something I didn't ask for. The DOM module continues to output everything as Unicode strings, even if the file is a typical 'plain text' XML file with an ISO 8859-1 encoding attribute in the XML declaration! The input data comes from two directions: one XML file, where the input takes the form of Unicode strings as described above, and a mailbox file, in Latin 1. Content from these two sources should be mixed together in an XML output file. Now everything works (without any encoding/decoding in either direction) until it's time to save it in XML. This gives an error: f = open('e:/test/catalog.xml', 'w') f.write(doc.toxml()) # Error! f.close() And here's the full message: Traceback (most recent call last): File "etest.py", line 59, in ? f.write(doc.toxml()) File "E:\python\_xmlplus\dom\minidom.py", line 87, in toxml return writer.getvalue() File "e:\python\lib\StringIO.py", line 160, in getvalue self.buf += ''.join(self.buflist) UnicodeError: ASCII decoding error: ordinal not in range(128) Ideally, I'd like the output XML file in Latin 1. I wonder if there's an easy way to decode everything in the DOM object to Latin 1, so that this won't happen? Regards, Gustaf Liljegren From geoff at homegain.com Fri Jun 1 16:53:30 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Fri, 1 Jun 2001 13:53:30 -0700 Subject: Why isn't Python king of the hill? Message-ID: <393D961EA4FCD311B03F00D0B746D65803275E55@HQSXCH01> I think a little easier to keep myself on target this time, but watch out! I bet I start to ramble near the end. :) Martijn writes: > How does Zope interact with the business objects? Through > external methods? > > I suppose this could be somewhat comparable with running CORBA > servers, right? I don't have much experience in this area, though > I'm very curious to hear more about how you integrate Zope with > this. I don't want to get into a position where I'm spilling too much proprietary information, so I'll be a little vague. I apologize in advance for that. The answers to these questions are related. We don't have a really clean MVC separation in our app, though we're trying to make it cleaner. The "Model" portion of the architecture consists of an Oracle database and lots of small object servers. We try to keep the business logic at this layer of the app, with varying degrees of success. These servers publish their availability through ILU. The "Controller" portion of the architecture consists of external methods. The external methods should ideally handle little more than convert and validate input, then pass it off to the "Model" part of the app, through ILU. The "View" portion of the app is DTML in Zope, served from a ZEO database. One of the nice features we have working for us is a "Service" product that holds a cache of connected ILU clients. These clients can be accessed from Zope or from our (slightly modified) external methods, though access from DTML is frowned on. I'm not sure where we got the Service product, or whether it would even work with current revs of Zope. I think Digital Creations might have had a hand in developing that. I think that answers the question without getting me in trouble? :) Martijn writes (quoting me): > > I've looked at ZODB and ZEO some for my personal edification. If > > I'm not mistaken, they provide a great mechanism for object > > persistence with key-based retrieval. My evaluation suggested > > that ZODB and ZEO were not very good at handling arbitrary > > retrieval, or even retrieval at the level of a SQL select > > statement. > > What do you mean with 'arbitrary retrieval'? I'm meaning something more along the lines of a real indexing and retrieval engine here. A query might be something like "I want all objects that have the word 'spam' in any of their attributes". This compares to key-based retrieval which says "I want the object with the key 'spam'" or the SQL-style retrieval which says "I want the objects that contain the word 'spam' in the column 'eggs' in the table 'bacon'." Our application doesn't require arbitrary retrieval in its current incarnation. Martijn writes (quoting me): > > Some of the features are either lacking or hidden to my limited > > vision in Python, notably decimal math and PDF generation. > > Python has reportlab for PDF, which seems to work pretty well: > > http://www.reportlab.com And Aahz contributes: > Not quite. There's currently a PEP for making the default *rational* > arithmetic; I'm currently working on a module based on the ANSI standard > for decimal floating-point arithmetic. There's already Tim Peters's > FixedPoint for fixed-point decimal arithmetic. It would appear "hidden to my limited vision" is the appropriate answer here. :) I didn't know about FixedPoint, which would address most of my concerns. And I look very forward to Aahz's implementation of decimal FP arithmetic. :) To answer an un-quoted question, fixed point or decimal math is required because dollars are involved. Binary FP's approximations show up in odd places when you're doing decimal math, which makes people uncomfortable when dealing with money. Martijn writes (quoting me): > > There's a certain draw to being able to take a single webapp and > > deploy it on any of a dozen different app servers that know how > > to handle the content, though it's small. > > What do you mean by this, exactly? Are you referring to the whole > Enterprise JavaBeans framework (sorry if I confuse any of the > terminology here) that's been implemented by various vendors? I've > always been skeptical about how well that actually works, but here > I'm skeptical without any actual real knowledge. :) I can't speak to how easy it is to move from one app server to another. I /can/ speak for how much of the "hard work" is done for you by some of these enterprise containers -- a whole lot! I'm not sure how Python and the Python community as it currently exists could actually /do/ the servlet thing. It's an API, but it's also a specification of a standard; Sun can get away with declaring The Standard because they have such tight control over Java. Python's more open community proves something of a weakness here -- Zope is "standard" in a de facto sense, but everyone who sets out to develop a templating language or a content server or an app server sets out to do it in their own way, with their own set of interfaces in mind. That means moving between servers requires a layer of adaptor code in the best case, or a total rewrite in worst. Martijn writes (quoting me): > > But the biggest draw is that someone who's proficient with > > Java is not too hard to find. > > Are you sure about this? I mean, sure, lots of people are being > cranked out that can use Java to a certain extent, but is it > really true that it's not hard to find someone *good* at it? > > > Someone who's proficient with Python is considerably harder to > > lay hands on. > > But I'd think that anyone who's actually good at Java would be > retrainable to use Python in a matter of days. Java programmers are more numerous than Python programmers. "Good" is relative. I think "able to work on an app I wrote" is a decent measure of goodness, and I think it's pretty safe to say that someone who knows enough Java to pass a programming class taught in Java could find his way around most of the Java apps I write. A person coming out of school with a class taught in Python might not have too much trouble with most of what I do in Python, either -- but while I know plenty of people who passed their Java classes, I don't know of anyone who has even taken a Python class. I agree that a person could be retrained to use Python, and could learn Zope. Python's not a terribly difficult language to learn, and it's a language that keeps on giving the longer you use it. But I do think that it would be difficult for someone hired as a consultant to walk in cold and learn enough Python and Zope to make sense of how the app worked. My office here is filled with C programmers who learned python on the job, PHP programmers who learned Zope on the job, Java programmers who came in cold. They all got up to speed in very short order. On the other hand, if the site had been less successful, and the company could not afford to bring on full-time staff and pay to have them trained -- if the company needed to hire a couple contract programmers to come in and change a few things, add a few things -- the company would have looked a very long time for someone proficient enough in Zope and Python to come in cold and make the changes they needed. And it was a fierce struggle for several months, with three or four programmers who knew nothing of Python or Zope. Those days are spoken of with awe and terror; it was difficult enough for someone like me, who knew his way around Python, to come in and figure out Zope and our architecture. I can't even imagine what it must have been like for people who didn't even know the language. If the app were done in Java, it would be a lot easier to hire people who knew at least a little Java and could find their way around the servlet API and JSP, whether as permanent employees or temporary contractors. That's just because of the demographics. Meanwhile, it's also a lot easier -- at least in our area -- to send your employees off to a three day class on Java or JSP and servlets, and it's easier to learn all three topics from any number of widely-published, well-written books. Zope training involved flying Matt out here from Digital Creations, and the documentation is scarce. Martijn (quoting me): > > Furthermore, while performance isn't a huge deal to those folks, > > their app did show signs of growing to cover a lot more terrain. > > It's conceivable that once the app was turned loose, it really > > would need to worry about the kind of massive load that starts to > > show off Python's seams. > > Are Java's seams that much tighter? I know it's faster, on average, > though it does seem to consume oodles of memory. And then there's the > question about closing the seams; it would seem to me that this would > be easier to do in Python in many situations, because it's just a lot > more flexible. Good point and maybe a tough call. I think it's easier to scale Java, because it's easier for good programmers to write scalable apps and harder for bad programmers to write apps that don't scale. Java's got its warts, too, though. It's a long way away from a Perfect Language, and it's a resource-hungry monster. Martijn writes: > Any larger app will have to grow and change over time, so I > consider this as well for my Zope/Python/relational database > apps, which is why I'm interested in your ideas about what > makes Java more suitable for these purposes. Not so I can go > and use Java, but for stealing some ideas. :) Probably the sanest thing either of us could be doing in this discussion. :) Let's see if we can come up with a short list -- I don't think these belong in the PEPs, really, maybe just ideas for people's projects? Maybe the first idea is some kind of formalized community that would provide support for these kinds of discussions? I don't know. But the ideas. It would be very good if you could take an object, instantiate it in the context of a container, and basically have proxies propagated to all other applications that have instantiated that container. Let's put it a different way, more abstract and less tied to implementation. It would be very good if you could write an object that conforms to a reasonable interface, and in so doing "gain" the ability to use the object in a distributed fashion. Currently, you've got to do it all by hand, and you can't count on the way you do it one time being re-usable the next time. There's no /standard/ way of doing it, and there's more than one way to do it. That's treading into Perl's territory, there.... Here's something I like about the servlet containers (app servers) that I haven't seen in Zope yet (maybe it's there?): managed sessions via cookies OR URL rewriting. Some of the servlet containers even support persistent sessions and sessions shared across multiple app servers. When you have fault-tolerance at that level of the application, that's powerful juju. This is actually three features in one: managed sessions, persistent sessions, and distributed sessions. Managed sessions means providing session tracking mechanisms (preferably configurable). Persistent sessions means that the sessions can survive a crash and restart of the server. And distributed sessions means that the same session can be accessed regardless of which server process is handling the current request. The last two depend on the first, but sessions could be either distributed or persistent without also being the other. Here's another one, one we can beat Java to the punch on: it would be nice if you could do object storage and retrieval into a relational database using a simple management framework. The upcoming Java Data Objects spec is an easy example to look at, but also consider looking at Apple/NeXT's Enterprise Objects Framework. I started working on something like this using metaclasses, and was reasonably successful, but it's a complex undertaking, and time consuming.... Martijn writes (quoting me): > > For more modest ambitions, the factors that weigh heavy on me may > > seem irrelevant or even overweening. :) > > Many people are using Python for rather less modest ambitions, > however. > I'm certainly planning to. :) And I think that HomeGain is using Python in a pretty significant application, too. We've got a lot of traffic and a whole bunch of data. It can work! It just doesn't seem to have all the tools to facilitate it, and it's not nearly as ubiquitous as other solutions. Speaking for myself again, --G. ---- Geoff Gerrietts From dwig at advancedmp.net Wed Jun 6 12:48:20 2001 From: dwig at advancedmp.net (Don Dwiggins) Date: 06 Jun 2001 09:48:20 -0700 Subject: Numeric Programming for Everybody In-Reply-To: "Steven D. Majewski"'s message of "Tue, 5 Jun 2001 20:51:46 -0400 (EDT)" References: Message-ID: Steven D Majewski writes: > The best way to cater to both the beginner and the specialist is to > leave floating point entirely to the specialist. The problem is that, > because computers were originally designed for specialists, they > happen to have been designed with fast specialized floating-point > hardware, and absolutely no specialized rational arithmetic hardware. Unfortunately, even beginners (or occasional users) need to deal with fractional values from time to time. Here's a strawman proposal: the "default" number system for the language will be like that of Unix "bc": fixed point (the user must declare how many fractional places), no limit on size. Yes, of course it's inefficient, but it's a good fit to the beginner's mental model. The introductory documentation will describe this system, and mention the others available, and why one might want to use them. Where speed and/or size is an issue, the more sophisticated programmer will move to integer, rational, or floating point, as appropriate (and of course, the documentation will include -- or point to -- descriptions of the consequences of the choice). -- Don Dwiggins "Solvitur Ambulando" Advanced MP Technology dwig at advancedmp.net From strombrg at seki.acs.uci.edu Mon Jun 4 17:58:03 2001 From: strombrg at seki.acs.uci.edu (Dan Stromberg) Date: 4 Jun 2001 21:58:03 GMT Subject: input() is a security problem? Message-ID: <9fh09b$bdp$1@news.service.uci.edu> In the following program: #!/dcs/packages/python-2.1/bin/python var=12345 n=input('enter a number, or a variable name like "var": ') print n If one enters "var" at the prompt, one sees 12345. This seems to be a problem for setuid python scripts that may have access to data, stored in variables, that the user isn't supposed to be able to see. Yes, I know, use sys.stdin.readline() instead. I do. But... is there really a good reason for input to access variables this way? It seems an unnecessary pitfall. -- Dan Stromberg UCI/NACS/DCS From mac4-devnull at theory.org Thu Jun 14 02:35:54 2001 From: mac4-devnull at theory.org (Neil Macneale) Date: Wed, 13 Jun 2001 23:35:54 -0700 Subject: substitute for c/java's ?: References: <9g5fc4$m8u$01$1@news.t-online.com> Message-ID: <3b2859da$0$329$8eec23a@newsreader.tycho.net> In article <9g5fc4$m8u$01$1 at news.t-online.com>, "Jochen Riekhof" wrote: > I am missing something like the c/Java ?: operator. The ?: operator is overrated. For the time you save typing, you are wasting someone else's because they need to figure out what you were thinking. > if elif else is not a proper substitute for switches, as the variable in I have found that using a dictionary of function pointers sometimes gives the switch statement feel. For example, point to constructors... cases = {"dog": Dog, "cat": Cat, "rabbit": Rabbit} def createPet(type="cat"): if casses.has_key(type): return casses[type]() #Good input... else: return None # bad input, or 'default' in C/java The above code is generally hard to read, so use sparingly and comment well. The thing I like about it is that the keys can be of any type. One problem is that all the functions called are going to need similar parameters, but sometimes its a usefull trick. > Otherwise, one of the coolest languages I learned so far!! > I agree! I have found very few people make an effort at python and then end up saying it sucks. I can't say the same for my effort with perl. Neil Macneale -- To reply to me via email, remove the '-devnull' from my address. From graham at coms.com Wed Jun 20 13:25:29 2001 From: graham at coms.com (Graham Ashton) Date: Wed, 20 Jun 2001 18:25:29 +0100 Subject: Loading select queries into objects References: <9gpgde02rc6@enews1.newsguy.com> <9gq7ek0lpa@enews1.newsguy.com> Message-ID: In article <9gq7ek0lpa at enews1.newsguy.com>, "Alex Martelli" wrote: > "Graham Ashton" wrote in message > news:xKYX6.1456$h45.9220 at news.uk.colt.net... > > there should be a linebreak after ',name' and before 'else:' -- sorry if > the error was in my post, can't understand how it got there... Probably my fault. Pan's text wrapping isn't the most intelligent. > I agree, and the best connection of such pointers about the standard > Python library is IMHO Fredrik Lundh's "Python Standard Library" It is sitting next to me as I type... -- Graham From rnd at onego.ru Tue Jun 26 11:03:48 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 26 Jun 2001 19:03:48 +0400 (MSD) Subject: 'with' statement in python ? In-Reply-To: <9ha5h5$cn58u$1@ID-11957.news.dfncis.de> Message-ID: On Tue, 26 Jun 2001, Emile van Sebille wrote: If you ask, "dirty"*150 hack is here: def with(me, **args): me.__dict__.update(args) class test: def __init__(self, ln, wd): with(self, ln = ln * 25.4, # keep in mm wd = wd * 25.4) with(self, area = ln * wd) >How could this be sorted out? > >-- > >Emile van Sebille >emile at fenx.com (Everybody else, please, do not flame me ;-) Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, June 26, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "It is better to be brief than boring." _/ From mertz at gnosis.cx Mon Jun 25 02:10:39 2001 From: mertz at gnosis.cx (Dr. David Mertz) Date: Mon, 25 Jun 2001 02:10:39 -0400 Subject: Is this a true statement? Message-ID: Peter Hansen wrote: |"Write a device driver [in language X]" means to use |language X as the *source language*, and with existing |(i.e. not theoretical) tools, turn that source into |an output file (usually "machine code") capable of |performing the functions typically defined as requiring |"device drivers". For more of us it does, anyway. This requirement is simultaneously asking way too much and way too little. This has nothing whatsoever to do with what a language can do, and only with what actually existing tools can do. For example, let's say (maybe I'm wrong) that there are no currently available C++ compilers for CPM. Seems plausible at least, given the dates of the various technologies. Does that mean that C++ *cannot* be used to write a device driver? Or even that it cannot be used to do so on CPM? I think the answer is a self-evident "no." Or even if one finds some odd way to answer "yes", that is surely a fact about what has been ported where and about operating systems... NOT about languages. Similarly, let's say that there is currently no way to write a device driver for WinME using ActiveState's Python 2.1 distribution for Win32, with no extension modules not included with the distribution. Well, of course there *is* a way in Ulrich's trivial and therefore important sense of writing a bunch of machine-code bytes. But exclude that, and claim there is no way "that naturally maps the program constructs to the memory accesses involved." The last is probably something true... but it is only true as long as no one writes a devicedriver.py extension module that contains some functions like "access_memory_address()." For that matter, this module might turn out to be standard in 2.2 (anyone want to write a PEP? :-)). Yours, Lulu... From robin at jessikat.fsnet.co.uk Wed Jun 13 03:42:24 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 13 Jun 2001 08:42:24 +0100 Subject: PEP 259: Omit printing newline after newline References: Message-ID: <8F8+WnAglxJ7Ewqw@jessikat.fsnet.co.uk> Add me to the nay sayers this isn't broken and doesn't need fixing. -- Robin Becker From gardner at cardomain.com Fri Jun 22 14:47:18 2001 From: gardner at cardomain.com (Jonathan Gardner) Date: Fri, 22 Jun 2001 11:47:18 -0700 Subject: weakrefs and things that point to each other References: <9gu4eg$838$1@brokaw.wa.com> Message-ID: <9h03qa$8f7$1@brokaw.wa.com> Duncan Booth wrote: > Jonathan Gardner wrote in > news:9gu4eg$838$1 at brokaw.wa.com: > >> Okay, here''s the idea. Object A can have many things of Class B. >> Object B can be had by many things of Class A. When A is destroyed, it >> wants to let B know that it no longer has it. When B is destroyed, it >> wants to let A know it no longer should have it. >> >> But, because of circular references, we need to use weak refs on at >> least half of the equations. However, I want the B to destroy itself >> even when there is one or more A's pointing to it. So I will implement >> weakrefs on both sides. > > If you have weak references on both sides then are you sure something is > going to keep all those bees alive? Yes, the bees will be kept alive by other references. I just don't want them to be kept alive by each other when they are no longer referenced by something else. This is actually going to be a simple signal/slot thingy like Qt. You'd do something like this to use it: from sigslot import * def doit(*args): print "Did it." def dothis(*args): print "Did this" a = signal() b = slot(doit) a.connect(b) # or b.connect(a) a.emit() # prints "Did it." c = slot(dothis) a.connect(c) a.emit() # print "Did it." then "Did this." The only thing that should keep a signal or slot alive is a reference to it. When a, b, or c falls out of scope, they should all individually be completely destroyed and all traces should be removed. That means when a is gone, b and c will forget it ever existed. When b or c is gone, a should forget about them as well. -- Jonathan Gardner "Infinity isn't all that large - except at the end." -- Uncle Al Please don't take anything I say seriously, even if you are really gullible. From akuchlin at mems-exchange.org Fri Jun 29 14:34:00 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 29 Jun 2001 14:34:00 -0400 Subject: [TO]What's the big deal with EJB? [Re: PEP scepticism] References: <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> Message-ID: <3d8zib16g7.fsf@ute.cnri.reston.va.us> Alex writes: > What's EJB got going for it, anyway? Buggered if I know. Perhaps they provide a frictionless method for transferring a business's money to consultants. --amk From etcamarg at unioeste.br Thu Jun 21 15:50:14 2001 From: etcamarg at unioeste.br (Edson Tavares de Camargo) Date: Thu, 21 Jun 2001 16:50:14 -0300 Subject: brazil Message-ID: <447FB9569769D411973E00A024B3573012550B@cac-pdc.unioeste.br> hello! There are somebody of Brazil in list?? Edson From chrishbarker at home.net Wed Jun 20 15:18:57 2001 From: chrishbarker at home.net (Chris Barker) Date: Wed, 20 Jun 2001 12:18:57 -0700 Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: <73PX6.317$zE1.418988@news.uswest.net> <3B2FE2BD.F210FA8A@home.net> Message-ID: <3B30F721.8BB487A7@home.net> Robin Dunn wrote: > But arguably not a *Good Thing*. Mainly it just reduces complexity enough > that one single ordinary human can develop, enahance, maintain, and find/fix > bugs in the package and still have time for a real job and a bit of a life. > SWIG doesn't generate the best code, but it means that there is around a > quarter of a million lines of code that I don't have to maintain and debug > by hand! > > > It is a bad thing because you end up writing > > Python code that is not natural (pythonic), and a whole lot more verbose > > and complex than it needs to be. > > Since I have a strong C++ background I look at the world with an intermixed > C++/Python view, so I often have a hard time seeing the "non-pythonic" > issues with wxPython but I know they are there. I've addressed many of them > at the SWIG layer and there have been a few contributions for the > wxPython.lib package for some more pythonic things at the Python layer. > I'll accept all contributed code that makes things easier. Well, I'm one of the folks that have complained, and even suggested improvements, but not yet contributed anything... > I've recently had some ideas and added items to my todo list that will > probably help out in this area, so I think this will become less of an issue > over time. On the other hand, for a large majority of things wxPython is > used for it is fast enough already. That's quite true. The one place we have problems is with drawing code: passing LOTS of stuff to a DC within a Python loop is just too slow. Klass' wxCanvas may help that out lot, I've been talking to him about it quite a bit, and I'm looking forward to using it. For those interested, check out: http://www.xs4all.nl/~kholwerd/wxstuff/canvas/ It is a high level vector drawing canvas... it has a lot of promise. > > wxWindows and Python also share a lot of duplicate > > functionality: sockets, database access, process control, file system > > manipulations, etc. etc. > > Much of which can be turned off when compiling wxWindows, but there probably > will always be some overlap with the current architecture. Well, sure, it just seems redundant, and I think it would be hard to decide which to use, particularly in a mixed C++/Python App. The current architecture is really pretty darn good. It works. It works better than any of the other alternatives that I know of (QT looks pretty procicing, but the not quite open source issue is a problem, and they don'thave any intention of supporting MacOS Classic) I just think a truly integrated toolkit would be so much better, but there is no way Robin (or any one person) could do it all himself, so the current solution is a good one. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From gmcm at hypernet.com Fri Jun 1 17:02:40 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 01 Jun 2001 21:02:40 GMT Subject: How to find the package a module belongs to ? References: Message-ID: <90B3AAB72gmcmhypernetcom@199.171.54.155> Jeff Sandys wrote: ... [Sasa Zivkov] >> I have a package containing several modules. >> Is is possible, within a module, >> to say "give me the package I belong to" ? Strictly speaking, no, not automatically, because module x within package p may be loaded as p.x or just as x. [Jeff] >It would sure be nice to pull this information from some >secret variable without having to explicitly name them. But every module has a __file__ attribute that will tell you (whether the module is loaded as x or p.x) that it came from some/path/p/x.py. - Gordon From dsh8290 at rit.edu Thu Jun 7 12:22:33 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 7 Jun 2001 12:22:33 -0400 Subject: Why should i use python if i can use java In-Reply-To: <9fngvl011jg@enews2.newsguy.com>; from aleaxit@yahoo.com on Thu, Jun 07, 2001 at 11:19:50AM +0200 References: <9fngvl011jg@enews2.newsguy.com> Message-ID: <20010607122233.E14752@connecticut.cs.rit.edu> On Thu, Jun 07, 2001 at 11:19:50AM +0200, Alex Martelli wrote: Ditto to all the Dynamic, but still strong, typing and the Design Patterns discussion explaning why Java is _still_ a very low level language even though it is bytecode-compiled and interpreted. | > > but most of all, it doesn't have | > > | > > J2EE | > > J2ME | > | > Actually it does! With Jython, you can access any Java API from Python. | > Neat, huh? | | Absolutely! But does any commercial IDE, as you earlier | referenced, support Jython yet? I don't know of any. Not commercial, but (g)vim supports this! Version 6.0 is nearly finished and has some really cool new features including "folding" (the ability to collapse a block of text into a single line on the display). -D From mikael at isy.liu.se Tue Jun 12 02:33:45 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Tue, 12 Jun 2001 08:33:45 +0200 (MET DST) Subject: [Python-Dev] Feedback on new floating point info in tutorial In-Reply-To: Message-ID: On 12-Jun-2001 Delaney, Timothy wrote: > Well, that's true, but large numbers of people forget that "many" itself is > a number ... > > 1, 2, many, many 1, many 2, many many, many many 1, many many 2, many many > many, lots! No, no! This is base many, so you should say 1, 2, many, many 1, many 2, 2many, 2many 1, 2many 2, many^2 ... and maybe many^2 is pronounced lots. And-I'm-many^many-many-1-years-old-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: 12-Jun-2001 Time: 08:28:00 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From zen at shangri-la.dropbear.id.au Thu Jun 28 19:13:36 2001 From: zen at shangri-la.dropbear.id.au (Zen) Date: 29 Jun 2001 10:13:36 +1100 Subject: Python embebbed with Oracle SQL*Plus References: <9hebu5$12lo$1@news.idiom.com> Message-ID: <3b3bc830@mercury.its.rmit.edu.au> olavb at yahoo.com (Olav) writes: >This is a very simple Cygwin/NT example: >*************** >PLUS33 scott/tiger at prod_sa <select COU_NAME from M1_countries >/ >quit >eof >******************** >So it is not simply building an SQL-string and calling >some function. This method can be done using the popen2 module to open pipes to a SQL*Plus process (or os.popen if you don't need to parse the output). >It is really like SQL embedded in the script. >There are also mechanism for passing variables back and forth. >(I can easily write a script that takes a sql-statement as an arguments >from the command line, something like osql select "*" from M1_countries) If you havn't looked at the DB API documentation I suggeset you do so (http://www.python.org/topics/database/DatabaseAPI-2.0.html). It is much nicer to work in this interface rather than deal with piping things too and from sqlplus. >I guess the mechanism is to build a temporary file, and call sqlplus >with this. >I think it might be more difficult with Python because it is actually >precompiled and because there is no equivalent of pipes. import popen2 (to_sqlplus,from_sqlplus) = popen2.popen2('PLUS33.EXE scott/tiger at prod_sa') print >> to_sqlplus,''' set pagesize 0 select COU_NAME from M1_countries where COU_NAME = '%s'; exit; ''' % ('Austria') for l in from_sqlplus.readlines(): print l, The equivalent using the DB API import DCOracle try: connection = DCOracle.Connect('scott/tiger at prod_sa') cursor = connection.cursor() cursor.execute('select COU_NAME from M1_countries where COU_NAME = :p1', ['Austria']) for row in cursor.fetchall(): print row[0] except DCOracle.error: print 'Argh!' From aleaxit at yahoo.com Fri Jun 1 12:16:19 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 1 Jun 2001 18:16:19 +0200 Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> Message-ID: <9f8f4l0hss@enews1.newsguy.com> "David C. Ullrich" wrote in message news:3b17a2f1.411766 at nntp.sprynet.com... ... > Could you give us a hint regarding exactly what work > of Chaitin's shows we can get "truly random" numbers from > arithmetic algorithms? I think his latest book, "Exploring Randomness" published by Springer-Verlag, is probably 'it'... gotta order it one of these days (it's been out a month and I yet haven't... sigh, my sloth's getting worse... to my excuse, the UK branch of Amazon claims it's not there yet, and Chaitin's page mentions a Springer-Verlag special offer on all 3 of his books but Springer-Verlag seem to never have heard of it, and...). > A physical RNG can have the property that one cannot make > any prediction about the value of the next bit even given > _complete_ information about how the numbers are being "From impossibilia sequitur quodlibet". *IF* you could have complete information, *THEN* you could predict all you want. Problem is, you CANNOT have complete info due to that Heisenberg fellow, therefore you cannot predict (precisely). From what I know of Chaitin's life work, it started with just the idea of defining randomness in terms of minimal amount of information (in bits) you need for prediction. If YOUR definition of 'randomness' is something that needs INFINITE number of bits to predict, go ahead and have fun, but you're unlikely to get some constructive results out of it. Chaitin, Martin-Loef, and Solovay, do have various definitions that ARE of some use, and apparently they all turn out to be equivalent (and "Exploring Randomness" includes, inter alia, proofs of the equivalence that a layman DOES have a chance to follow -- I'm told). A physical system that is macroscopic enough to escape Heisenbergian conumdrums could also be describable in a finite number of bits, in terms of enabling somebody to predict the 'next outcome'. That was, if I'm not mistaken, Laplace's take on probability (and not his only), all the way up to Einstein's in this century -- that it's all about hidden variables, information that we do not happen to have, rather than information that intrinsically CANNOT be had. Measuring randomness in terms of amount of information seems like it works nicely. More when I _have_ managed to get and study "Exploring Randomness", if it's not too far over my head...! Alex From aetodd at wm.edu Tue Jun 26 16:05:22 2001 From: aetodd at wm.edu (Andrew Todd) Date: Tue, 26 Jun 2001 16:05:22 -0400 (EDT) Subject: Python on BeOS In-Reply-To: References: Message-ID: <993585922.3b38eb029288b@webmail1.wm.edu> Hey, I haven't found much on the net concerning Python on the BeOS. I think Python v2.1 has been released for it, but I'm not sure. Anyway, I was just wondering if anyone had any experience with the language in this OS. Is the language just as solid as it is in most of the other platforms? Are there any sites concerning Python with the BeOS I could check out? -Andrew From Craig.Massey at oxygenforbusiness.com Thu Jun 21 21:22:12 2001 From: Craig.Massey at oxygenforbusiness.com (Massey, Craig) Date: Fri, 22 Jun 2001 13:22:12 +1200 Subject: Security on NTFS files Message-ID: <2408B6871730D511881100B0D0AB59AA013B24@MFORTOK1> Some old posts refer to the ability to read NTFS permissions on files and directories as not being implemented yet in Win32all. Before I try and figure out how to do it, is that still correct? From john.thai at dspfactory.com Tue Jun 12 16:49:05 2001 From: john.thai at dspfactory.com (John) Date: Tue, 12 Jun 2001 16:49:05 -0400 Subject: Reference Counts & Extensions.. Message-ID: <6fvV6.248430$Z2.2868464@nnrp1.uunet.ca> Hi, I'm writing an extension module and in my functions I return something like: return Py_BuildValue("i", 1); Will this cause a memory leak? Should I be doing this: PyObject *pyObj = PyBuildValue("i", 1); Py_INCREF(pyObj); return pyObj; Also, what if I make pyObj a global variable, can I then use the first method since the reference will be borrowed, like so: return pyObj; Thanks, John From phd at phd.fep.ru Thu Jun 7 04:21:58 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Thu, 7 Jun 2001 12:21:58 +0400 (MSD) Subject: WHY is python slow? In-Reply-To: <4.3.2.7.2.20010607144657.042f8328@bdg.centrin.net.id> Message-ID: Q: Why is python slow? A: Why is the sky so green? Why is water so dry? Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From gry at ll.mit.edu Wed Jun 6 14:59:04 2001 From: gry at ll.mit.edu (George Young) Date: Wed, 06 Jun 2001 14:59:04 -0400 Subject: print foo, adds a space to beginning of next line? Message-ID: <3B1E7D78.53A5BE30@ll.mit.edu> [python 2.1, intel linux] def f(): print 'what is your name: ', x=sys.stdin.readline() print 'what is your age: ', y=sys.stdin.readline() f() what is your name: mememe what is your age: 48 Why does it print a space at the beginning of the second line? If I use sys.stdout.write('what is your name: ') instead, it works fine. -- Your mouse has moved. Windows NT must be restarted for the change to take effect. Reboot now? [OK] From sandipb at bigfoot.com Sat Jun 16 01:45:38 2001 From: sandipb at bigfoot.com (proxy) Date: Sat, 16 Jun 2001 11:15:38 +0530 Subject: Text Widget toolkit Message-ID: <20010616111538.A1585@proxy.dsf> Hi! I am looking at a text widget toolkit for use in console applications. I took a look at the anaconda sources which revealed that they were using snack as their toolkit. Snack as I am told is a wrapper around Newt. Now Newt had been considered an "unstable" interface by some folks. My question is : What are the various python text based toolkits available? TIA, Sandip From tundra at tundraware.com Sun Jun 24 14:29:41 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 24 Jun 2001 18:29:41 GMT Subject: Is this a true statement? References: Message-ID: <3B362FA3.F3A01482@tundraware.com> "Steven D. Majewski" wrote: > > On Fri, 22 Jun 2001, David Lees wrote: > > > Not necessarily. It might go faster if you were comparing a Python > > built-in operation (coded in C) with something inefficiently coded in > > C++. But the statement that "Python can do everything C++" is true, but > > a tautology. You can substitute nearly any language; Basic, C, Algol, > > Lisp,... and it is still a true statement. > > > > david lees > > > > > > MDK wrote: > > > > > > Python can do everything C++ can do but just slower. > > Wrong, David. > Turing completeness means that anything you can *COMPUTE* in one > language you can computer in another. Python, Lisp, C++, etc. > are all equivalent in that sense. > > But you can't *DO* all of the same things in all languages -- for > example: you can write a device driver in a language if you can't > specify interrupt vectors or hardware address pointers. > Not so, Steve. If something is Turing-Complete you CAN do everything in that language - it just may be ugly. All Turing-Complete languages (like C, BASIC, Assembler, C++, Python...) can compute *exactly* everything which is computable and therefore exactly what each of the other T-C languages can compute. They will do so with different degrees of effectiveness (which corresponds to their suitability for the problem at hand) and efficiency (which corresponds to Turing machines of different computational complexity) but they are all *equivalent* in functionality. As to the objection that one cannot write device drivers in Python - this is nonsense. Someone already gave the counterexample of having Python *generate* such a driver and this is entirely valid. Another counterexample would be to wire the OS kernel with an embedded Python interpreter runtime (which, after all, Python was designed to do) and then write the driver as native Python code. The reason this is not done is not because it is impossible. This is not done because it is inefficient. So, to the original question, yes, Python and C++ *CAN* do exactly the same things (as can all other Turing-Complete languages), but they are not suited equally well for all problems. As far as speed goes, there is no clear answer. In this GUI-driven world in which we live, code speed is very often/rarely the issue - the machine spends all its time waiting for keystrokes and mouseclicks. Even on heavily loaded servers, the performance is more usually bounded by I/O than CPU. Clearly there are counterexamples - code efficiency is critical in modeling and numerical analysis problems. For the most part, though, expecially in commercial applications, *correctness* and *programmer* efficiency are way more important than code size or speed. Python is ideal for a very large class of programs because it allows programmers to quickly create large amounts of correct code. If, in fact, performance does become an issue, if the code is well designed in the first place, it is relatively trivial to do a "hotspot analysis" and replace the performance impeding code with hand-coded C, Assembler, or what have you... -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From philh at comuno.freeserve.co.uk Fri Jun 15 08:21:55 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 15 Jun 2001 13:21:55 +0100 Subject: Parrot-0.2.6 released References: <4a7fde99.0106150057.69a89a23@posting.google.com> Message-ID: On 15 Jun 2001 01:57:39 -0700, Ryan wrote: >I like the syntax for this much better than the standard TK style for >python, That's partly why I worte it -- writing Tkinter code is more time-consuming than necessary. It's inspired by the book "Motif Tools" which includes a similar system fro the Motif GUI. > pretty amazing for a pre alpha. Looks like it should shorten >the time for makeing a GUI by a factor of at least 10 for those of us >that still have to pull out a book everytime we want to make one. That's the idea. Later this year, I'm likely to be writing some Python GUI code myself, so I'll be updating Parrot to work with it. Parrot *does* need work doing to it be be fully useable, but I think the basic idea is sound. -- ## Philip Hunt ## ## philh at comuno.freeserve.co.uk ## From ykchew at hotmail.com Mon Jun 11 21:02:09 2001 From: ykchew at hotmail.com (ykchew) Date: Tue, 12 Jun 2001 09:02:09 +0800 Subject: How to get current date Message-ID: <3b256b54.0@news.tm.net.my> Hi there, I'm newbies and i want to know to get current date from python2.0 and merge it with string thanks From akuchlin at mems-exchange.org Thu Jun 14 14:27:59 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: Thu, 14 Jun 2001 14:27:59 -0400 Subject: Any other Python flaws? Message-ID: I was updating my page of possible Python design flaws (http://www.amk.ca/python/writing/warts.html) last night to take 2.1 into account. 2.1's nested scoping fixes one major wart, and the other major one, the type/class dichotomy, might get fixed in 2.2 if the descr-branch in CVS turns out well. (It's neat that the two largest ones may both get fixed before 2001 is out.) That leaves the remaining warts as minor wibbling about 'do' statements, print >>, and the like. Are there any other flaws that should be added? --amk From samschul at pacbell.net Fri Jun 22 11:50:31 2001 From: samschul at pacbell.net (Samuel Schulenburg) Date: 22 Jun 2001 08:50:31 -0700 Subject: [OT] MS EULA -- (will ActiveState become outlaws? ;-) References: <3B32F81F.259DBA46@chello.nl> Message-ID: I work for a company that has a license from Microsoft to use Windows2000 as the OS for one of our products. As a result of the licenseing agreement, I can not use Python on any of these products, even for internal testing, as the company is worried that their is a slim chance that a copy may get shipped with a unit. I can not write software that links in any public domain libraries, i.e Zlib. This means that I have to write my own compression routines. WHAT A WAIST OF TIME!!! Sam Schulenburg Roeland Rengelink wrote in message news:<3B32F81F.259DBA46 at chello.nl>... > "Steven D. Majewski" wrote: > > > > Is this the next stage of Microsoft's war against Open Source ? > > > > Discussion of this on SlashDot : > > > > ( Right before the article on the Monty Python Action Figures! ) > > > > If this spreads to all of Microsoft's EULA's, will this make > > ActiveState illegal ? They don't specifically mention Python's > > license, but they do mention Perl's ( and the "similar to any > > of the following" clause would seem to include Python's. ) > > > > Does anyone know if this should be taken seriously ? > > > > -- Steve Majewski > > > > > > Ironically, NS under Linux refuses to display that ;) > > > > > Well, as I see it the GPL licence is morally equivalent to > > 1. This is raging commie stuff > 2. You can't use raging commie stuff in conjunction with evil empire > stuff > > and this microsoft licence is morally equivalent to > > 1. This is evil empire stuff > 2. You can't use evil empire stuff in conjunction with raging commie > stuff > > For once the free software movement and microsoft seem to agree on > something > > More seriously, the lack of a definition of ''use'' under (ii), and the > misleading definition of Potentially Viral Software gives the impression > that this was written by their PR department, rather than their lawyers. > > But then, I know as little about law as I do about PR. > > Roeland From yatima at konishi.polis.net Sat Jun 16 17:59:06 2001 From: yatima at konishi.polis.net (Yatima) Date: Sat, 16 Jun 2001 21:59:06 GMT Subject: TableIO installation woes Message-ID: Hi Folks, I feel like an idiot but I'm having trouble installing the TableIO package written by Michael Miller (http://php.iupui.edu/~mmiller3/python/). There are instructions provided but they don't seem to work for me. I'm using Python 2.0 on linux (debian). If anyone has any pointers it would be greatly be appreciated. -- yatima From sholden at holdenweb.com Tue Jun 26 08:16:45 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 26 Jun 2001 08:16:45 -0400 Subject: DCOracle: platforms? References: <2hJZ6.16808$g4.471561@e420r-atl2.usenetserver.com> Message-ID: Gerhard: Thanks. I'd already located DCOracle2 thanks to Oleg, but I wasn't aware of the cxOracle package. I've downloaded it, and I'm taking a look. regards Steve -- http://www.holdenweb.com/ "Gerhard H?ring" wrote in message news:slrn9jes0d.fo2.gerhard.nospam at lilith.hqd-internal... > On Mon, 25 Jun 2001 12:06:48 -0400, Steve Holden wrote: > >Cam anyone tell me if they have the DCOracle module working on Windows? The > >distribution's web page claims all platforms, but I don't see any Windows > >installation instructions, and haven't done enough C development in that > >environment to be confident of tackling this without assistance. > > DCOracle2 is currently in beta testing stage, Windows/Python 2.1 binaries are > available. There is also an alternative Oracle module: cxOracle. If you really > want the old DCOracle, I have a Python 2.0 binary at my homepage. > > DCOracle2: http://www.zope.org/Members/matt/dco2 > cxOracle: http://www.computronix.com/utilities/ > > HTH > > Gerhard > -- > mail: gerhard bigfoot de registered Linux user #64239 > web: http://highqualdev.com public key at homepage > public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 > reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From nde at comp.leeds.ac.uk Wed Jun 20 07:07:49 2001 From: nde at comp.leeds.ac.uk (Nick Efford) Date: Wed, 20 Jun 2001 11:07:49 GMT Subject: beginner ques: dir( ) does'nt list my instance methods? References: Message-ID: On Wed, 20 Jun 2001 08:55:12 -0000, karthik_guru at rediffmail.com wrote: > Both dir(t) and t.__dict__ print only foo and bar. > They don't print the func which is also a instance attribute (method > reference)? func is a class attribute because it is defined within the class; foo and bar are instance attributes because they are defined when an instance of the class is created. func is effectively inherited by the instance because, when you do t.func(), Python will look for the name 'func' in the namespace of t's class if it fails to find the name in t's namespace. Nick From mlunnay at bigpond.net.au Wed Jun 6 00:05:27 2001 From: mlunnay at bigpond.net.au (Michael Lunnay) Date: Wed, 06 Jun 2001 04:05:27 GMT Subject: How to save the Graph on Tkinter.canvas? References: <3B1CEBEF.C178EA22@ccsr.cam.ac.uk> Message-ID: Write a function that saves the data the graph is drawn from, this would be the best, and probably easiest method. Michael From root at rainerdeyke.com Fri Jun 22 21:13:56 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Sat, 23 Jun 2001 01:13:56 GMT Subject: PEP 255: Simple Generators References: Message-ID: "Tim Peters" wrote in message news:mailman.993249814.17014.python-list at python.org... > If you're only interested in the first 100 nanoseconds of a generator's > life, that's true . But when you write a generator, or analyze a > generator, or think about a generator, or step thru a generator in a > debugger (etc), they're just resumable functions; much like class methods > are just functions with a magical first argument. We spell class methods > with "def" to emphasize the similarities; ditto for generators. That > doesn't mean differences don't exist, but that the similarities are so deep > that harping on the differences is more distracting than helpful. Another faulty analogy. 'def' inside a class creates a function This function is automagically converted into an unbound method by the class constructor. The unbound method is then automagically converted into a bound method when accessed through an instance. Both of these conversions are messy (especially since they are based on concrete types and therefore non-polymorphic), but they happen after 'def' has already created a totally normal function object. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From ben.hutchings at roundpoint.com Thu Jun 28 03:01:55 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 28 Jun 2001 00:01:55 -0700 Subject: Interpreter hangs after calling my extension Message-ID: I'm trying to write a Python extension that wraps the DLL interface to CVS that's included with WinCvs. This is my first Python extension so it's not clear to me whether the error is in my use of the Python/C API or my use of the CVS DLL. Since the former is less obscure I'm trying to check that first. The CVS DLLs (there are several versions built with different options) export a dllglue_main function, which works roughly like the main function of a normal CVS executables, and several functions whose names begin with 'dllglue_set', which are used to set a call-back that replaces getenv and call-backs that replace console input and output. My extension module 'cvsdll' has a function called main that is a wrapper for dllglue_main. It takes a sequence of command arguments, copies them and passes them to dllglue_main. It has call-back functions for console input and output that make use of file-like objects stored as the 'stdin', 'stdout', and 'stderr' attributes of the module. As the code stands now, the module user is supposed to set these. When I enter 'cvsdll.main([])' at the Python console, my extension function is called; it runs and returns as expected (checked in the VC++ debugger), but the Python interpreter never prints a new prompt or reacts to input. Further, if I set cvsdll.stderr = sys.stderr first, the error message that is successfully written to sys.stderr (checked in the VC++ debugger) never appears in the console. So, are the errors in my use of the Python/C API, or the way I'm compiling my code, or are they elsewhere? --- begin code --- #include #include "cvsgui/common/dll_glue.h" #undef getenv /* dll_glue.h #defines getenv for use in the DLL */ #define WIN32_LEAN_AND_MEAN #include PyObject * cvsdll_main(PyObject *, PyObject *); /* Pointer to DLL's dllglue_main function */ int (*real_dllglue_main)(char const *, int, char **); /* The call-back functions for the CVS DLL */ long consolein(char *, long); long consoleout(char *, long); long consoleerr(char *, long); /* Common code for consoleout and consolerr */ long consolewrite(char * file_attr_name, char * buf, long len); static PyObject * module_dict; __declspec(dllexport) void initcvsdll() { PyObject * module; HMODULE dll; FARPROC func; static PyMethodDef methods[] = { {"main", cvsdll_main, METH_VARARGS, "CVS main function"}, {NULL, NULL}, }; dll = LoadLibrary("cvs2ntslib.dll"); if (dll == NULL) PyErr_SetString(PyExc_WindowsError, "Failed to load CVS DLL"); else { /* Omitted code to get real_dllglue_main and set call-back functions, since it's not Python-related. This leaves func == NULL if and only if it fails. */ if (func == NULL) { PyErr_SetString( PyExc_WindowsError, "Did not find expected functions in CVS DLL"); } else { /* All OK - so go ahead and create the module */ module = Py_InitModule("cvsdll", methods); module_dict = PyModule_GetDict(module); } } } static PyObject * cvsdll_main(PyObject * self, PyObject * args) { PyObject * result = NULL; PyObject * main_args; if (PyArg_ParseTuple(args, "O", &main_args)) { long argc; /* Add one for the "cvs" in front */ argc = 1 + PySequence_Length(main_args); if (argc >= 1) { char ** argv; long argi; /* Add one for the NULL at the end */ argv = calloc(argc + 1, sizeof(char *)); /* Convert all arguments into C strings. Make copies since C programs are allowed to modify their argv. */ argv[0] = strdup("cvs"); argv[argc] = NULL; for (argi = 1; argi < argc; ++argi) { PyObject * arg; PyObject * arg_str; arg = PySequence_GetItem(main_args, argi - 1); if (arg == NULL) break; arg_str = PyObject_Str(arg); Py_DECREF(arg); if (arg_str == NULL) break; argv[argi] = strdup(PyString_AsString(arg_str)); Py_DECREF(arg_str); } /* Check that all arguments were successfully converted */ if (argi == argc) { /* dllglue_main takes a path name to change the current directory to. I'm not sure why, since the caller can easily do that. For now, avoid changing it. */ result = PyInt_FromLong(real_dllglue_main(".", argc, argv)); } while (--argi >= 0) free(argv[argi]); free(argv); } } return result; } /* Omitted code for consolein since it isn't being called */ static long consoleout(char * buf, long len) { /* Call cvsdll.stdout.write(buf) */ return consolewrite("stdout", buf, len); } static long consoleerr(char * buf, long len) { /* Call cvsdll.stderr.write(buf) */ return consolewrite("stderr", buf, len); } static long consolewrite(char * file_attr_name, char * buf, long len) { long result = 0; PyObject * file; file = PyDict_GetItemString(module_dict, file_attr_name); if (file != NULL) { PyObject * buf_obj; PyObject * result_obj; buf_obj = PyBuffer_FromMemory(buf, len); result_obj = PyObject_CallMethod(file, "write", "O", buf_obj); Py_DECREF(buf_obj); if (result_obj != NULL) { result = len; Py_DECREF(result_obj); } } return result; } --- end code --- This is being compiled with the command line: cl /Zi /LD /MD pycvs.c /I "c:\program files\python20\include" /I ".." "C:\Program Files\Python20\Libs\python20.lib" /link /out:c:\progra~1\python20\dlls\cvsdll.pyd /debug The options should cause the compiler and linker to (a) build a DLL, (b) include debugging information in it, and (c) make it use the multi-threaded DLL run-time library. From grante at visi.com Mon Jun 4 11:09:30 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 04 Jun 2001 15:09:30 GMT Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> Message-ID: In article <991550033.146 at nntp01.uskonet.com>, Frank Millman wrote: >After 15 years of designing applications using the good old "seat of the >pants" method, I have decided that, if I am to move forward, I need a more >formal methodology. > >I have recently read about UML (Unified Modelling Language), a >standards-based method of designing and documenting any software project. It >looks interesting, but it seems to have a steep learning curve. > >Does anyone have any knowledge or experience of UML that they would like to >share? I took a 3 day class on UML once. My impression: yet another "silver bullet" that doesn't work in real life. I do have friends who've worked on projects that used UML, and they thought it was marginally useful, but like any other form of documentation, if it's not maintained (and it never is, AFAICT) it becomes worse than useless. -- Grant Edwards grante Yow! Wait... is this a FUN at THING or the END of LIFE in visi.com Petticoat Junction?? From matt at mondoinfo.com Wed Jun 20 12:43:01 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Wed, 20 Jun 2001 16:43:01 GMT Subject: Tkinter & Text object References: <3B30CBD8.B836A9CC@telocity.com> Message-ID: On Wed, 20 Jun 2001 12:14:17 -0400, Adonis wrote: >anyone know how to set color to a line after it was added to a Text >object? >ive looked into the Tkinter documents and found text.mark_set("string", >pos) >but have no idea how to use it. a teeny example is all im looking for >afterwards i can pick up from that point. Tkinter is much less frustrating if you keep a copy of Fredrik Lundh's excellent An Introduction to Tkinter nearby. It's at: http://www.pythonware.com/library/tkinter/introduction/index.htm But here's an example that I think does what you want: >>> from Tkinter import * >>> r=Tk() >>> t=Text(r) >>> t.pack() >>> t.insert(END,"Wibble\n") >>> t.insert(END,"Qux") >>> t.tag_add("t1","1.0","1.end") >>> t.tag_configure("t1",foreground="green") >>> t.tag_add("t2","2.2","2.3") >>> t.tag_configure("t2",background="blue") Regards, Matt From mikael at isy.liu.se Fri Jun 1 07:43:37 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 01 Jun 2001 13:43:37 +0200 (MET DST) Subject: who coined the term "real numbers" (was Re: Against PEP 240) In-Reply-To: <9f7m9i020v2@enews1.newsguy.com> Message-ID: On 01-Jun-2001 Alex Martelli wrote: > "Complex" is due to Gauss, 1831, specifically at first for numbers > of the form a+bi with a and b both integers -- "Tales numeros > vocabimus numeros integros complexos, ita quidem, ut reales > complexis non opponantur, sed tamquam species sub his contineri > censeatur". Earlier, they were called "imaginary". Today, numbers of the form a+bi with a and b both integers are called Gaussian integers. If you wish, you can say that the set is generated by i, which is normally written . This is also a square lattice in the complex field. If you instead use a hexagonal lattice in the complex field, you get the so called Eisenstein integers. This set is generated by a third root of unity, i.e. e**(2pi/3). yet-another-off-topic-science-thread-ly yr's /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: 01-Jun-2001 Time: 13:34:12 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From adsharma at sharmas.dhs.org Tue Jun 5 21:10:06 2001 From: adsharma at sharmas.dhs.org (Arun Sharma) Date: Wed, 06 Jun 2001 01:10:06 GMT Subject: Dynamic scoping Message-ID: I've searched the archives of this group as well as the net, about the advantages and disadvantages of lexical vs dynamic scoping. I'm convinced by the arguments that lexical scoping is what people want most of the time. However, under some circumstances, people might want to use dynamic scoping. Is there a reason why python doesn't support it ? (Unlike perl ?). -Arun From jurberg at my-deja.com Thu Jun 14 09:05:40 2001 From: jurberg at my-deja.com (John Urberg) Date: 14 Jun 2001 06:05:40 -0700 Subject: Integrating a Python GUI into a PowerBuilder App References: <49624b0b.0106121135.61b6bd6c@posting.google.com> Message-ID: <49624b0b.0106140505.79851658@posting.google.com> > We are looking into languages to replace PowerBuilder in our shop. > The kicker is that we need to slowly migrate to the new language so > the choice would have to be able to integrate into a PowerBuilder MDI > application. I'd really like to push Python as the new language, but > I need to find a way to seemlessly integrate a Python GUI into the > PowerBuilder app (i.e. as child windows of the MDI). I would expect > we would want to use wxPython being as that is the closest to standard > Windows look and feel. > > Any ideas on how I can accomplish this? Should I assume from the lack of response to this and other tries that integrating a Python GUI into a PowerBuilder app is an impossible task? Time to give in and settle for Java or VB? Regards, John Urberg From res04o20 at gte.net Mon Jun 18 01:08:18 2001 From: res04o20 at gte.net (Dave Wald) Date: Mon, 18 Jun 2001 05:08:18 GMT Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? References: <3B2B60AD.942719AE@earthlink.net> Message-ID: <21gX6.10599$mQ2.631518@paloalto-snr1.gtei.net> "bradclark1" wrote in message news:ePZ#Y669AHA.266 at cpmsnbbsa07... > > "Paul Prescod" wrote in message > news:mailman.992809646.24580.python-list at python.org... > > res04o20 wrote: > > > > > >... > > > > > > And lastly, ActiveState has announced "Visual Python". Only problem is, > you > > > gotta have MS .Net. (shudder) (Yet another implementation of Python. > This > > > time in C#. Another learning curve to be ultimately successful.) > > > > You are conflating two different things. Visual Python [1] and Python > > .NET [2] are completely unrelated (but interoperable, of course) > > > > [1] http://aspn.activestate.com/ASPN/Downloads/VisualPython/ > > [2] http://aspn.activestate.com/ASPN/NET/ > > -- > > Take a recipe. Leave a recipe. > > Python Cookbook! http://www.ActiveState.com/pythoncookbook > > > > Am I missing something here? From what I read at the above it says for .net. > I didn't see anything else about it? > > Brad > I had to go back and read it again closely. "Visual Python" is hosted in the Visual Studio .Net, but still uses CPython. Just requires VS.Net. "Python.Net" is the experimental implementation of Python in C#, which also requires .Net, for the unified run-time system, AFAIK. Bottom line: Ya gotta have .Net either way. So, we'll probably just set up a .Net beta machine and play with it. Bout time we looked into it anyway... I've just been evading the subject while "strategically re-deploying our legacy code base". ;-) Regards, Dave From aleaxit at yahoo.com Tue Jun 12 03:55:57 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 12 Jun 2001 09:55:57 +0200 Subject: Global in multiple files References: <3B255CAC.E373C5B7@home.net> Message-ID: <9g4i0k04r3@enews2.newsguy.com> "Chris Barker" wrote in message news:3B255CAC.E373C5B7 at home.net... ... > As far a OO design is concerned, a module used in this way is very much > like a class with only one instance. It's just a little less code. IN > fact, it may make sense to put accessor functions in your globals > module, like: > > globals.getUserList() > > rather than explicity accessing the global value itself. Actually, and at least in Python 2.1, if one is willing to get a LITTLE bit tricky:-), there's an alternative... Suppose we want to obtain this effect: D:\py21>python Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. Alternative ReadLine 1.4 -- Copyright 2001, Chris Gonnerman >>> import fakemod >>> fakemod.goodies.extend("batman robin superman".split()) >>> fakemod.baddies.extend("luthor penguin iceman".split()) >>> fakemod.allofem ['batman', 'robin', 'superman', 'luthor', 'penguin', 'iceman'] >>> i.e., fakemod exposes "plain lists" -- but appends & other mods to lists goodies and baddies of module fakemod also become available for access through attribute allofem -- no "accessor functions" to complicate the life of client-code programmers. How could we achieve this? Well, we COULD have in fakemod.py something like...: class _fakemod: def __init__(self): self.goodies = [] self.baddies = [] def __getattr__(self, name): if name=='allofem': return self.goodies+self.baddies raise AttributeError, name import sys sys.modules[__name__] = _fakemod() And, indeed, when this is fakemod.py we can see in the above-copy&pasted-interactive session that: >>> fakemod >>> The trick is that an entry in sys.modules need not be a module-object... an instance-object will do, AND if it's a module object then we can play all of the usual tricks with __getattr__, etc, etc. This is just a "proof of concept", of course, and we'd really need to expose a UserList derivative as 'allofem', in order to catch any attempts to modify it directly and either disallow them or translate them appropriately into modifications to the real underlying lists, etc, etc. But, it's a start. Whatever special-method trickery we want to do on an object that client-code obtains with an import, just like a module, we can (mostly, I guess, in __getattr__ __setattr__ and __delattr__), by using an instance as the "fake module" in this way. Is this "obfuscated Python" and not to be mentioned in polite company? I don't know. I have not yet had any occasion to use this in anger -- AFAIK it wasn't in 2.0, it's a 2.1 innovation -- so I have no direct personal experience on what effect this has on maintenance and similar chores. Offhand, however, this does NOT strike me as horrid, to-be-avoided black magic. Sanity checks on module attributes, ease of access to them, avoidance of cumbersome accessor-function syntax, etc -- all of these seem to be applicable to 'modules' (or objects accessed as such) just as much as they do to instances. Rather than giving __setattr__, etc, to module objects directly, the same power (or more) has been obtained by relaxing the check that used to ensure that any entry in sys.modules had to be a module-object (a check which one could see as a violation of signature polymorphism in favour of strict typechecks -- the less typechecks we have lying around, the more the simplicity and power of signature polymorphism will be available to us!). I guess the main danger might be with *C* code in a Python extension accessing "module" (ha:-) objects with PyImport_ImportModule or thereabouts, and then accessing the returned object directly with concrete PyModule_* calls rather than polymorphically with PyObject_* calls. A danger specifically for older existing Python extensions, I guess -- and how many of those use PyImport_* etc, after all? Once one is aware of the possibility that PyImport_* yields a non-module object (polymorphic with a module -- no doubt an instance object in most such cases), it should be easy enough to account for this possibility (no personal experience yet...). Alex From sholden at holdenweb.com Tue Jun 26 09:28:12 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 26 Jun 2001 09:28:12 -0400 Subject: Aargh! Function takes exactly x arguments, y given.. References: <9gkrud$pru$1@news.inet.tele.dk> <3B2E1C02.109197B5@alcyone.com> <3b2f3759.467766@nntp.sprynet.com> <%AdY6.24501$Kq4.2305781@newsread2.prod.itd.earthlink.net> Message-ID: "Chris Tavares" wrote in ... > "David C. Ullrich" wrote in ... > > On Mon, 18 Jun 2001 08:19:30 -0700, Erik Max Francis > > wrote: > > > > >Anders And wrote: > > > > > >> I am a happy pythoneer using a combination of C++ and Python for my > > >> everyday > > >> work. > > >> Usually, debugging is easy but every now and then, I get the "function > > >> takes > > >> exactly x arguments, y given" error message, clearly due to some other > > >> problem than what Python thinks. Does anybody have any experience with > > >> this > > >> particular error message? I don't know what triggers it and thinking > > >> back, I > > >> think I have solved most of my problems with this message with a major > > >> code > > >> rewrite. > > > > > >The error means just what it says: You are calling a function with too > > >many or too few arguments. Why you're doing that exactly is something > > >we couldn't tell you without code examples that actually give you the > > >error. > > > > > >Only thing I can think of is that you've got a confusion with bound and > > >unbound methods; if you call an unbound method (C.f where C is a class > > >and f is a method), then you need to provide an instance of C as the > > >first method (the implicit self method becomes explicit). > > > > Or he's not calling the function that he thinks he is, possibly > > because of an "import *". > > > > (I refrained from guessing at first cuz I didn't want to leave > > anything out. Is there a natural third possibility?) > > > > The problem I still hit quite often is this: > > class Foo: > def MyMethod( x, y ): > pass > > > foo = Foo() > foo.MyMethod(1, 2) > > Boom! Called with three args, expected two. > This is one advantage of "self": using that name reminds you it's an implied argument. regards Steve -- http://www.holdenweb.com/ From crj003 at yahoo.com Thu Jun 21 17:40:08 2001 From: crj003 at yahoo.com (Rich J) Date: 21 Jun 2001 14:40:08 -0700 Subject: Bitwise 'AND' error? Message-ID: <5c8ecb0b.0106211340.59aeee39@posting.google.com> Could someone please explain to me why this is giving these results. This is taken directly from the python interpreter. >>> long = 0x2964619C7L >>> mask = 0xFFFFFFFF >>> ling = long & mask >>> print 'new number = %#x' % ling new number = 0x2964619c7 >>> ling 11111111111L >>> long 11111111111L >>> Why would 'anding' with this mask give back the same number? It should have given back 0x964619C7, right? Or am I losing my mind? From andreas at digicool.com Fri Jun 15 12:43:24 2001 From: andreas at digicool.com (Andreas Jung) Date: Fri, 15 Jun 2001 12:43:24 -0400 Subject: question about threads Message-ID: <013601c0f5ba$4bc49330$3e17a8c0@SUXLAP> "Alan Tsang" schrieb im Newsbeitrag news:9gdc68$fhs$1 at news.hk.linkage.net... > > > Hi > > Is it possible to explicitly tell a thread to pass execution to another > thread in Python? Any help is much appreciated. Not really - except you working the locks, semaphores or other methods for thread synchronisation. Andreas From none at none.com Thu Jun 7 23:00:40 2001 From: none at none.com (none) Date: Thu, 07 Jun 2001 20:00:40 -0700 Subject: PalmOS Desktop Interface For Python? References: <3B1FB7E4.2F5D2FE3@tundraware.com> Message-ID: <3B203FD8.9030206@none.com> Try www.pyrite.org Tim Daneliuk wrote: > Is anyone aware of a Python module set which allows the > PalmOS 4.0 desktop files (addressbook, todo, etc.) to be read and > written? They only reference to something like this I've been able to > find is dated several years ago and presumably now out of date. > > TIA, > From deltapigz at telocity.com Mon Jun 4 13:55:51 2001 From: deltapigz at telocity.com (Adonis) Date: Mon, 04 Jun 2001 13:55:51 -0400 Subject: Python Threading (win32) Message-ID: <3B1BCBA6.638F14D7@telocity.com> ive looked over the Python documentation about threading, but its all hebrew to me, anyone care to shed the light on how to thread? just a simple start/stop thread example, ill get it after that. thanks in advance, Adonis From emile at fenx.com Thu Jun 21 19:01:44 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 21 Jun 2001 16:01:44 -0700 Subject: Getting actual name of passed arg References: <3B3272DD.4000308@canterburycrest.org> <3B327450.8060305@canterburycrest.org> <3B327B1D.9020107@canterburycrest.org> Message-ID: <9gtuk0$b94md$1@ID-11957.news.dfncis.de> You could also perhaps start with: def debug(**kwargs): print kwargs a,b,c = ('test',123, [1,2,3]) debug (a=a,b=b,c=c) HTH, -- Emile van Sebille emile at fenx.com --------- "Ross Brattain" wrote in message news:3B327B1D.9020107 at canterburycrest.org... > Nope not quite. traceback.print_stack() doesn't quit work either. > > I will settle for this for now > > def debug(a): > print a > eval(a) > > > Ross Brattain > netmgr at canterburycrest.org > From boud at rempt.xs4all.nl Sun Jun 17 08:41:43 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 17 Jun 2001 12:41:43 GMT Subject: qt or gtk? References: Message-ID: <9gi8i7$qc8$1@news1.xs4all.nl> D-Man wrote: > On Sat, Jun 16, 2001 at 05:52:12AM +0000, Rainy wrote: > | > | I want to learn python gui programming in linux. I think tk looks too ugly, so > | I narrowed down the choice to two main contenders, qt and gtk. Which of these > | has more complete and up-to-date python bindings? Are there other reasons > | to prefer one of these over another for python gui work? > Personally I like GTK better. I don't like the way Qt tries to look > like MS Windows. Funny that. For me, Qt does a very creditable job looking like MacOS 9... Or like a a sheet of tinfoil, for those who like that. In my forthcoming book on PyQt programming I even have a chapter detailing how to write your own pluggable look & feel for PyQt - the example being based on the first version of MacOS. >Glade+libglade make a great combination for rapid > coding. Use glade (a gui) to build the static parts of the interface, > then load them at runtime with libglade. You simply write the event > handlers and connect them to the events in your code. You can > completely change the look of the UI without changing any code as long > as the names of widgets and their type match (ie you don't change from > a tree to a list). I wouldn't work with any toolkit that didn't support that style of working. The details may be different - with Designer and PyQt you don't create XML files that are parsed runtime, but compile the XML user interface definition to Python code. You can either use the generated class immediately, or create a subclass that does the event handling and initialisation. It's even possible to create standard functionality (like pressing the OK button closes the dialog) in the Designer module. So, with Designer and PyQt, you can do the same: generate the interface, and write a bit of code that keeps on working when you change the interface, as long as the widgets don't disappear or have their names changed. -- Boudewijn Rempt | http://www.valdyas.org From paulp at ActiveState.com Wed Jun 13 19:08:02 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Wed, 13 Jun 2001 16:08:02 -0700 Subject: Inner classes References: <3b27a1aa.6747983@news.laplaza.org> Message-ID: <3B27F252.3BFA498C@ActiveState.com> Mats Wichmann wrote: > > Java provides inner classes. They have some interesting properties, > but mostly smell to me like a hack to get around things being too > strongly typed in Java. Probably I'm missing some great point here. Actually, Java inner classes are mostly a hack to work around the fact that Java doesn't have first-class functions. So in Python I can do something like this: but = Button() def _onclick(): ... but.onclick = _onclick In Java all of the code would have to be in a class and _onclick would have to be defined in *another* class (because you can't pass references to functions/methods). Thus you need inner classes. In some languages without first-class classes, you hack classes through function "closures". In languages without first-class functions, you hack functions through "one-method classes". Python has both and you don't have to hack! -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From pmoscatt at bigpond.net.au Sun Jun 24 02:15:24 2001 From: pmoscatt at bigpond.net.au (Peter Moscatt) Date: Sun, 24 Jun 2001 06:15:24 GMT Subject: Calling TIX in PYTHON ? References: <3b33f0e2.6490158@nntp.ix.netcom.com> Message-ID: <0AfZ6.154911$ff.1191163@news-server.bigpond.net.au> Hi Mike, I don't seem to have the demo's under Python 2.1. Are you able to send me one ?? Pete Mike Clarkson wrote: > On Thu, 21 Jun 2001 11:23:07 GMT, Peter Moscatt > wrote: > >>Ok.... I have finally got used to using Tkinter widgets within Python. >>Now I want to use a couple of Tix widgets, namely the tixDirList. >> >>I have used the "import Tix" command but unsure how I actually write the >>code to actually show the Directory list. >> >>Can anyone help me out here ? >> >>Pete > > Take a look at the Demos/Tix directory in the Python 2.1 source > distribution. Run tixwidgets.py or take a look at the Samples > directory. > > Mike. > From phd at phd.fep.ru Fri Jun 8 12:10:53 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Fri, 8 Jun 2001 20:10:53 +0400 (MSD) Subject: Reraising exceptions "intact" In-Reply-To: <3B20F235.1FC3A9A@argo.es> Message-ID: On Fri, 8 Jun 2001, Jesus Cea Avion wrote: > try : > func() > except exceptions.KeyboardInterrupt : > raise exceptions.KeyboardInterrupt > except : > pass > > Here we keep "func" running except if the user press CONTROL+C. But in > this case I'd like to see a traceback for the original interrupt point, > not the "artificial" "raise". try : func() except exceptions.KeyboardInterrupt : import traceback; traceback.print_exc() except : pass Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From tim.one at home.com Wed Jun 20 22:09:37 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 20 Jun 2001 22:09:37 -0400 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) In-Reply-To: Message-ID: [Steven D. Majewski] > I'm also an anti-list-splitter. > I'ld rather filter than join or deal with cross postings! So would I, but one of the best ways to kill a PEP is to flood Python-Dev with postings about it, where they just annoy Guido <0.9 wink -- but that's what the PEP process was supposed to get away from, and I play along with faux enthusiasm so real it almost twinkles>. > Also, as another former Icon-er, I tend to lean with Tim on the syntax > issue. Heh. If you had only finished *your* generator implementation 9 years ago instead of getting sucked into the continuation pit, we could be using sdm f(i): suspend i+1 today . From sill at optonline.net Tue Jun 5 16:05:28 2001 From: sill at optonline.net (Rainy) Date: Tue, 05 Jun 2001 20:05:28 GMT Subject: Vaults of parnassus not accepting new submissions? Message-ID: Hello, I tried to submit a program to vaults of parnassus, and it doesn't show up (it's been about a week). I also didn't get reply to my email. What's the story here? Is there some secret illuminati rite of passage to get a submission accepted there? :-) -- Delay not, Caesar. Read it instantly. -- Shakespeare, "Julius Caesar" 3,1 Here is a letter, read it at your leisure. -- Shakespeare, "Merchant of Venice" 5,1 [Quoted in "VMS Internals and Data Structures", V4.4, when referring to I/O system services.] From MarkH at ActiveState.com Thu Jun 21 04:38:44 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 21 Jun 2001 08:38:44 GMT Subject: explicitly close an application in windows References: <9grsp1$s0i$1@bob.news.rcn.net> Message-ID: <3B31B291.9050001@ActiveState.com> Christian Reyes wrote: > Is there a method that one can use to explicitly close an application in > windows? > The following script will close Microsoft Word, and _may_ work for other apps :) Of course, if you really want to close MSWord, then COM it a better solution, but I assume the app you want to close does not support COM. Further, this will only close Word if Word would itself close manually - ie, Word will still prompt to save changed files, etc. Anyway, for what it is worth... import win32con, win32gui def Callback(hwnd, ignored): if win32gui.GetWindowText(hwnd).find("Microsoft Word")>=0: print "Closing hwnd", hwnd win32gui.PostMessage( hwnd, win32con.WM_CLOSE,0,0) win32gui.EnumWindows(Callback, None) Mark. From avv at quasar.ipa.nw.ru Tue Jun 12 20:11:26 2001 From: avv at quasar.ipa.nw.ru (Alexander V. Voinov) Date: Tue, 12 Jun 2001 17:11:26 -0700 Subject: wxCombobox question Message-ID: <3B26AFAE.B9BFEE71@quasar.ipa.nw.ru> Hi Vadim and Robin (et al.), Is it possible in wxPython/wxWindows to tell if the drop-down list really _dropped_ down (i.e. visible to the user) or not? In the MS API there are a CBN_ notification events, which allow to intercept, process this information (and behave differently depending on this). But I do not see anything like this on the wx* levell. Thank you in advance Alexander From bos at hack.org Wed Jun 6 00:48:28 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Wed, 06 Jun 2001 06:48:28 +0200 Subject: .pyc files References: <9fk9gk$5uo$1@charm.magnus.acs.ohio-state.edu> Message-ID: <3B1DB61C.E6FD4A98@hack.org> Locke wrote: > > When I run my python scripts by pressing F5 in IDLE, it makes a .pyc file in > whatever directory the script is in. This file doesn't appear when I run > python from the command line. What is this? Why do I want this? http://python.org/doc/FAQ.html#6.13 -- Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From sholden at holdenweb.com Fri Jun 29 07:32:34 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 29 Jun 2001 07:32:34 -0400 Subject: Terminating a local process COM server References: Message-ID: "Duncan Booth" wrote in ... > "Steve Holden" wrote : > > > For efficiency reasons I am implementing a credit-card checking > > algorithm as a COM LocalServer object. > > > > For debugging purposes I would like to be able to terminate the current > > instantiation (i.e. process), so I can start another one with revised > > Python code. It would also be nice, in production, to have some way to > > terminate the LocalServer process so that the next instantiation of the > > COM object restarts the server in a new process. > > > > I'm aware that this would invalidate references to any objects created > > by the process, but for testing it *would* be "comvenient" not to have > > to kill the COM server process manually. > > > > Anyone help? Or at least explain where I'm mistaken if this isn't a > > sensible goal... > > [ ... ] > > Another option would be to put the COM object into an NT service. That way > you can simply stop and start the service at will. I recently wrote a > service containing a COM object, let me know if you want a copy of the > code. The downside to this is that it makes it harder to debug the service > when things go wrong. > Hadn't thought of that. Yes, please mail me a copy of your code. As we both know, things never go wrong when you program in Python ;^) regards Steve -- http://www.holdenweb.com/ From phd at phd.fep.ru Thu Jun 14 09:14:15 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Thu, 14 Jun 2001 17:14:15 +0400 (MSD) Subject: kjbuckets for Python 2.0 Message-ID: Hello! This is modified version of kjbuckets by Aaron Watters. Modifications are: -- updated for Python 2.0 (Berthold Hoellmann ) -- Makefile.in/Setup for old-style compilation/configuration -- setup.py for new-style (Distutils) compilation/configuration (Oleg Broytmann ) -- kjbuckets.pyd Windows DLL for Python 2.0 -- sqlsem.py patch to use it with kjbuckets.pyd (Adnan Merican ) Download: http://phd.pp.ru/Software/Python/#kjbuckets http://phd.pp.ru/Software/Python/misc/kjbuckets.tar.gz Fatser mirrors: http://phd2.chat.ru/Software/Python/#kjbuckets http://www.crosswinds.net/~phd2/Software/Python/#kjbuckets Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From greg at cosc.canterbury.ac.nz Thu Jun 7 22:11:36 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 08 Jun 2001 14:11:36 +1200 Subject: Why no 'elif' in try/except? References: <3B1A06EE.F484930A@snakefarm.org> <3B1A29DE.9876770D@accessforall.nl> Message-ID: <3B203458.835AE30F@cosc.canterbury.ac.nz> Marcin 'Qrczak' Kowalczyk wrote: > > Ok, so why elif exists in the first place at all? It's redundant. > It can be replaced by 'else: if' and more indents. > > Answer: convenience, to avoid those indents. The convenience is worth the extra complexity in this case, because it's quite common to have long sequences of nested if-elses, and without it you'd quickly run out of screen width. But I can't imagine long sequences of nested try-except-else-ifs turning up very often... -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From phd at phd.fep.ru Tue Jun 12 18:08:59 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Wed, 13 Jun 2001 02:08:59 +0400 (MSD) Subject: Python for MS-DOS (was: Re: RS232 support for DOS on 486?) In-Reply-To: Message-ID: On 12 Jun 2001, Cyril Slobin wrote: > So, weekend passes, and Python 2.1 is successfully compiled with DJGPP. > Very similar to Python-DX, but with less built-in modules (yet). I myself Congratilation! > use it instead of standart Python for Windows because of better readline Do you know you can put this into init.py (I hope your Python executes init.py upon interactive startup) and have history load/save automatically? # From Bruce Edge, http://groups.yahoo.com/group/python-list/message/128961 import rlcompleter, readline #readline.parse_and_bind("tab: complete") readline.parse_and_bind("tab: menu-complete") import os histfile="%s/.python-history" % os.environ["HOME"] readline.read_history_file(histfile) def savehist(): global histfile readline.write_history_file(histfile) import atexit atexit.register(savehist) > support (faster, working history file save/load). You can get it from: > > ftp://ftp.ice.ru/pub/slobin/python/ Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From sheila at spamcop.net Sun Jun 10 10:24:50 2001 From: sheila at spamcop.net (Sheila King) Date: Sun, 10 Jun 2001 14:24:50 GMT Subject: New guy question References: Message-ID: On Sun, 10 Jun 2001 13:04:35 GMT, "Glen Mettler" wrote in comp.lang.python in article : :OK...I went back to the beginning and discovered that the author of the :tutorial showed me three windows. :One with a black background that he described as the Python prompt (>>>) :(title is Python) :One with a white background that he described as IDLE - also with a Python :prompt (title is Python Shell) :One with a black background that he described as the "command" window that :in fact is the DOS window (title MS DOS Prompt) : :I went to the MS DOS Prompt ("Command") and typed in python alook.py and got :an error message: Bad command or file name. This sounds like Python is not in the PATH for your computer. (When it says, "Bad command or file name" it is basically telling you that it doesn't understand how to execute the command that you gave it. The reason it doesn't understand, is because it doesn't know where your "python" executable is.) You can fix it this way: Go to the Start Menu. Click on "Run". Under "Run" a little dialog box should pop up with a little box to type in the name of something. Type in msconfig and click on "OK". When it pops up a window, choose the tab that says "Autoexec.bat". Somewhere in there you need to add a statement. So pick the button that says "New". Type SET PATH = C:\Python\Python20;%PATH% except that instead of C:\Python\Python20 you need to put the path to Python on YOUR COMPUTER. I would also use the Move Down button and put this lower in the list of commands to your Autoexec.bat file. Reboot your machine and then try bringing up a DOS window and typing python alook.py at the DOS prompt. Hopefully it should work now. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ :"Glen Mettler" wrote in message :news:TiyU6.127784$I5.32725119 at news1.rdc1.tn.home.com... :> I have a small script I entered from a Python book that works when I run :it :> using F5. :> However, when I go to the console and enter python alook.py, I get an :error :> message: > :> >>> python alook.py :> SyntaxError: invalid syntax :> :> I am too new to this to know why. :> :> Glen :> :> : From pfortin at pfortin.com Thu Jun 21 18:08:58 2001 From: pfortin at pfortin.com (Pierre Fortin) Date: Thu, 21 Jun 2001 18:08:58 -0400 Subject: namespace issue? References: <87k825ljrz.fsf@elbereth.ccraig.org> Message-ID: <3B32707A.F03344D5@pfortin.com> Michael Powe wrote: > > >>>>> "Christopher" == Christopher A Craig writes: > > Christopher> Michael Powe writes: > >> >>> def GetNum2(): ... AC = raw_input("Area Code: ") ... PN = > >> raw_input("Phone Number: ") ... if not PN : PN = '000-0000' > >> ... if not AC : AC = '503' ... if len(PN) < 8 and not > >> string.find(PN,'-'): ... Ph = PN[:3] + '-' + PN[3:] ... return > >> Ph > > Christopher> string.find(PN, '-') succeeds (since PN contains a > Christopher> '-'), so len(PN)<8 and not string.find(PN,'-') > Christopher> returns false, meaning that Ph = PN[:3] + '-' + > Christopher> PN[3:] is never executed, and Ph is not defined when > Christopher> the return statement is reached. > > Actually, it doesn't contain the dash. The dash is only inserted if I > press the enter key, leaving the PN string empty. In the case of an > empty string, the default string of zeroes is put into the variable. > But, the error persists even if I take that conditional out. However, > you pointed me in the right direction. The 'not string.find(PN, '-')' > part of the conditional is returning false when there is no dash in > the string. If I take that part of the conditional out, and just use > the first part, it works as designed. > > So now the question is, 'why'? Am I misusing the string.find() > function? Okay, string.find() returns -1 when the string is not found, > which would seem to be what I expected, a false result. Maybe python > doesn't treat -1 as false? Well, I'll try being explicit and testing > for -1 return. I probably have just confused myself hopelessly. Sometimes -1 is used for failure; BUT -1 is NOT false... in those cases, you can simply add 1 to the return to force a failure to return 0 (false)... HTH, Pierre > Thanks for the ... clue. I saw a great line in an email today -- "Is > that the clue phone ringing? I think it's for you." And I think I'll > go answer it. > > Christopher> So, yes, it is because of the conditional, but no it > Christopher> has nothing to do with namespaces. (unlike in C or > Christopher> C++, in Python not all blocks get their own > Christopher> namespaces, only functions, modules, and classes (and > Christopher> probably something I forgot)) > > Christopher> Also, yes, raw_input returns a string. > > Okay, thanks. > > mp > > -- > Michael Powe > looie at aracnet.com michael at trollope.org > "All we are basically are monkeys with car keys." > -- Northern Exposure -- Support Linux development: http://www.linux-mandrake.com/donations/ Last reboot reason: 01/03/27: winter storm 6hr power outage From gritsch at iue.tuwien.ac.at Thu Jun 21 10:38:42 2001 From: gritsch at iue.tuwien.ac.at (Markus Gritsch) Date: Thu, 21 Jun 2001 16:38:42 +0200 Subject: How to call cleanup code in a Python extension module Message-ID: <9gt0sd$lfc$1@news.tuwien.ac.at> Hi! I am writing an extension module in C and I need to make some initializations when the module is loaded and some cleanup before exiting the interpreter. Initialization can be done in the extensions initxxx() function, but I wonder where to put the cleanup code when the module is unloaded since I have not found a delxxx() function. Currently I a using a work-around by forcing the user to use a Python class to communicate with the extension, and the initialization and cleanup functions are called by the classes __init__() and __del__() methods. Anyway, if an exception occures, the cleanup code is not executed. Thanks for comments in advance, Markus From Emmanuel.Viollet at mail.dotcom.fr Thu Jun 14 04:26:46 2001 From: Emmanuel.Viollet at mail.dotcom.fr (Emmanuel Viollet) Date: Thu, 14 Jun 2001 10:26:46 +0200 Subject: Embedding and threads Message-ID: <3B287546.60302@mail.dotcom.fr> Hi. I'm very new to Python and am trying to embed Python in a multi-threaded application. What are the steps to do this? I've found information all over the place (on-line help, various FAQs) but I can't manage to make everything stick together. Can someone please give me step by step examples of how to get threading work, please? In advance, thanks. PS: I suppose this has been asked hundreds of times but I can't find where... :-( -- Emmanuel Viollet Software engineer Webdyn e-mail : Emmanuel.Viollet at mail.dotcom.fr Tel : +33 (1) 39 04 29 55 From paulp at ActiveState.com Fri Jun 22 18:57:45 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 22 Jun 2001 15:57:45 -0700 Subject: cmdline.py not working in ActiveState Python 2.1 References: <3B339168.9D7A9094@raqia.com> Message-ID: <3B33CD69.7F71EC0D@ActiveState.com> I think it would help to look at sys.argv and compare the values on Windows and Linux. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From JamesL at Lugoj.Com Wed Jun 27 11:58:54 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Wed, 27 Jun 2001 08:58:54 -0700 Subject: PEP 260: simplify xrange() References: Message-ID: <3B3A02BE.21039365@Lugoj.Com> Tim Peters wrote: > > [James Logajan] > > Design mistakes one has made do tend to weigh on one's soul (speaking > > from more than two decades of programming experience) so I understand > > the primal urge to correct them when one can, and even when one > > shouldn't. > > Is this a case when one shouldn't? That is, is it a specific comment on PEP > 260, or just a general venting here? Just a general bit of silly "" venting. Insert some non-zero fraction in the wink. I tried to insert some obvious absurdities to indicate I was not being very serious. (Yes, I know that one shouldn't try that in mixed company.) From aleaxit at yahoo.com Thu Jun 14 05:56:58 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 11:56:58 +0200 Subject: History substitution on dos References: <3B285D25.3D9B9851@rk-speed-rugby.dk> Message-ID: <9ga1pl02hko@enews1.newsguy.com> "Brian Elmegaard" wrote in message news:3B285D25.3D9B9851 at rk-speed-rugby.dk... > Hi, > > (I think) I have been through the faq, but I can't find out how to make > use of the command history when running python interactively from a > dos-prompt. Can it be used? It depends on your OS, how Python was built, and the optional modules you may have installed. Given that you mention a "dos-prompt" I'll assume you are in some version of Windows rather than Unix or Mac or... On NT and 2000 (using cmd.exe), it just works with any Python -- being halfway-decent operating systems (albeit not wartless:-), NT and 2000 supply a minute but useful amount of help to interactive text-mode programs like python.exe:-). I suspect Windows/XP will be similar, since it stems from /NT roots. On /95, /98 and /ME, using command.com, the OS does not help (one might say, it hinders). Those sorry excuses for an imitation of an OS have this among their uncountedly many other warts. Alas, sometimes you still HAVE to use one of them (e.g., my nifty new ultralight laptop only has sleep/freeze/and other typically laptopish powersaving features under /98 -- no support for either /2000, /XP, Linux, BSD, etc etc -- so I'm stuck with /98 there, *URGH*). Fortunately, there *IS* still (a glimmer of) hope!-) Cygwin (making it all look almost as good as Unix) is one possibility. If you DO have to work within command.com for some reason, *all is not lost yet*! http://newcenturycomputers.net/projects/readline.html is where Chris Gonnerman has placed this lifesaver for us poor lost souls. Simplest is just to download (a single-line long URL, it's probably going to be split by some software or other, beware!-): http://newcenturycomputers.net/cgi-bin/download.py/projects/downloads/Readli ne-1.4.win32-py2.1.exe run this self-installing executable, and be happy. There is also a version for Python 2.0, with an identical url except py2.1 is replaced with py2.0 towards the end. Or, get the full source+prebuilt-binaries archive at http://newcenturycomputers.net/cgi-bin/download.py/projects/downloads/Readli ne-1.4b.zip it includes a distutils setup.py so your life is easy anyway on any Python >= 2.0. If you have an older Python you can still get distutils for it, I think, but I have no experience in the matter. Alex From pmoscatt at bigpond.net.au Fri Jun 1 06:30:41 2001 From: pmoscatt at bigpond.net.au (Peter Moscatt) Date: Fri, 01 Jun 2001 10:30:41 GMT Subject: Python 2.0 Patch ??? Message-ID: I currently using Python 2.0 I am led to believe that there is a patch available for this - where is it obtainable ?? Pete From bokr at accessone.com Fri Jun 15 20:19:38 2001 From: bokr at accessone.com (Bengt Richter) Date: Sat, 16 Jun 2001 00:19:38 GMT Subject: Any other Python flaws? References: <3b296534.514160393@wa.news.verio.net> Message-ID: <3b2a94a6.591842855@wa.news.verio.net> On 15 Jun 2001 18:11:48 +1200, Paul Foley wrote: >On Fri, 15 Jun 2001 04:01:49 GMT, Bengt Richter wrote: > >> The guiding star would be having a platform-independent abstract >> hierarchical name space to virtualize access to various >> containers and sources and destinations of stuff. Mapping >> access to a particular platform's file systems would be one use. >> Mapping to unix could be pretty transparent as far as usage >> is concerned. > >> One benefit would be that Python could have its _own_ standard >> hierarchical file-and-such-entities-as-my-be-desired name space >> independent of platform, or at least more independent. > >http://www.xanalys.com/software_tools/reference/HyperSpec/Body/chap-19.html > Thanks for the link, although ISTM it focuses on regularizing path expressions relative to _existing_ file systems without creating a _new_ hierarchy, which is a key part of what I was trying to describe. Defining a standard abstract tree of names is more akin to the LSB/FHS effort found at: Linux Standard Base: http://www.linuxbase.org/ Filesystem Hierachy Standard: http://www.pathname.com/fhs/ _EXCEPT_ that they are trying to standardize _actual_ file systems whereas I was saying that you could define an _abstract_ tree of/for names totally independently, and then attach/mount things to standard places in that tree so that they can be accessed in known abstract tree locations irrespective of their actual file system tree locations or the pathnaming conventions of the particular OS/file system. As far as files go, on unix you could do virtually the same thing by creating a tree of your own and populating it with links to the things you are interested in having appear in your standard tree. But all platforms do not support this, nor can you link in python objects etc., since you are not in python there. Having an abstract tree would also make possible laying out python package and module relations in terms of their standardized abstract tree locations without worrying about where they were actually installed on disks or networks, or indeed whether they were hooked-in python objects playing proxy roles. Also, switching experimental stuff in and out would be made more flexible, I would anticipate, since changing a few lines in a configuration file could determine what shows up where. From aleaxit at yahoo.com Thu Jun 14 07:23:55 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 13:23:55 +0200 Subject: Embedding: Problem with CallObject References: <20010613.174914.1793282088.6934@bender.nowhere.non> Message-ID: <9ga6sp02mjg@enews1.newsguy.com> "James Turner" wrote in message news:20010613.174914.1793282088.6934 at bender.nowhere.non... ... > func = PyDict_GetItemString(flist,PyString_FromString("out")); PyObject* PyDict_GetItemString(PyObject *p, char *key) Note the second argument's type... you're passing a PyObject* where a char* is required. Probably running your C compiler with suitable flags will tell you about such errors. -Wall -WError -pedantic is the needed incantation on gcc, for example, if I recall correctly (it HAS been a while since I last used it:-). Alex From f91-men at nada.kth.se Thu Jun 7 06:41:14 2001 From: f91-men at nada.kth.se (Mattias Engdegård) Date: 7 Jun 01 10:41:14 GMT Subject: Question re local bindings in nested scopes References: <8gdnht4as9mg09un8vu2ci2re80p2ujssq@4ax.com> <1104_991864564@ns.seowon.ac.kr> <3e7e9334.0106062022.2ce58a46@posting.google.com> Message-ID: In <3e7e9334.0106062022.2ce58a46 at posting.google.com> goringe at avaya.com (Chris Goringe) writes: >So, is there an analogue of global for nested scopes? No, there doesn't seem to be any. This annoys me somewhat, and the restriction feels arbitrary and stupid for someone used to languages with real block structure (Scheme, Common Lisp, Perl, Dylan, and even old Pascal with all its other problems). PEP-227 (http://python.sourceforge.net/peps/pep-0227.html) discusses this to some extent but hints on technical problems (without mentioning anything specific) and that someone called Guido doesn't like it. It also suggests that classes are a better way to solve it, but I don't agree: sometimes it is, but often it is much to clumsy to even think of. For example, when you factor out a common repetitive pattern in a lengthy subroutine, it is natural to modify the variables in the surrounding scope since the helper procedure is part of the scope. The PEP suggest the workaround of using containers which is workable but confusing to read, and I would say it's against the spirit of python. If anyone knows what technical problems there would be to implement rebinding in enclosing scopes, please tell me. Syntactically it could be done with ":=" as a non-binding assignment operator, or with a new keyword analoguous to "global", perhaps "nobind", "outer", or "enclosing". From guido at digicool.com Wed Jun 13 12:16:42 2001 From: guido at digicool.com (Guido van Rossum) Date: Wed, 13 Jun 2001 12:16:42 -0400 Subject: PEP 259: Omit printing newline after newline Message-ID: <200106131616.MAA17468@cj20424-a.reston1.va.home.com> OK, OK, PEP 259 is dead. It seemed a nice idea at the time. :-) Alex and others, if you're serious about implementing print as __print__(), why don't you write a PEP? --Guido van Rossum (home page: http://www.python.org/~guido/) From guido at python.org Thu Jun 28 17:02:55 2001 From: guido at python.org (Guido van Rossum) Date: Thu, 28 Jun 2001 21:02:55 GMT Subject: PEP 260: simplify xrange() References: <3B3AA1AE.AC965683@seebelow.org> Message-ID: Grant Griffin writes: > I like it, but I can think of two questions that might be answered > within the PEP. I'm not sure these need to be answered in the PEP, but the answers are trivial. > 1) What is the effect on speed? Presumably speed will increase (or at > least stay the same), but, heck--who knows? The xrange object becomes one C long smaller, and creating an xrange() object will be a tad faster -- the creation routine is simplified. Indexing may or may not become faster; the common path through that code is the same, but there's a jump over less code now. (Hm, I could speed it up some more by a small code rearrangement.) > 2) How do the functions from xrange relate--semantically speaking--to > the functions of "xreadlines()"? It seems to me that the two should > have a similar "user interface" because they work about the same way, > and solve similar problems. xreadlines() already follows the new xrange() philosophy. Even better, xreadlines() allows you to loop over it only once, and you have to use the natural indexing sequence. This makes it easier to turn xreadlines() into a pure iterator -- this can't be done with xrange(), because of the following common idiom: r = xrange(1000000) for i in r: f1() for i in r: f2() --Guido van Rossum (home page: http://www.python.org/~guido/) From whisper at oz.nospamnet Thu Jun 14 12:19:08 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 14 Jun 2001 16:19:08 GMT Subject: New statement proposal for Python Message-ID: <9gao5s$8ft$7@216.39.170.247> One thing that bugs me about Python is that there's no really good way to have named constants so that magic numbers can be avoided. Assigning to a variable that (should) never changes is not the same (i.e. the "should never" part). My proposal: alias httpport : 80 alias astring : "Strings are ok too!" alias alist : [a, b, c] alias atuple : {one : 1} #etc. alias aconstant : can be anything not containing an explict nl or # alias true: 1 # create an alias for 1 alias true: not 0 # this is ok too, but not after the previous # declaration! >> error: redefinion error! alias false: is zero # everything up to the nl or octothorpe is the # replacement text A reoccurance of the same label to the left of the colon in the same scope (or should this be global?) is a redefintion error. The occurance of a newline in the replacement text to the right of the colon is an error _even_if_escaped_. Encoded newlines: "\n" are acceptable but are not converted by the alias statement. In fact no processing at all of the replacement text is ever done, although the resulting text may be evaluated by the python parser. There is no possiblity of substitution in these (what are essentially) macros, nor should there ever be - this is not an analog for #define foo(a,b,c) where one can expect a, b and c to be substituted within the body of the define! The only purpose is to assign invariant labels to constant values. Of course, there might be other hidden gotchas that I haven't thougt of... Dave LeBlanc From cjensen at bioeng.ucsd.edu Fri Jun 15 11:29:39 2001 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Fri, 15 Jun 2001 08:29:39 -0700 Subject: VI References: <9g7pch$7dr3g$1@ID-11957.news.dfncis.de> Message-ID: <3B2A29E3.8E2FBE77@bioeng.ucsd.edu> Historicaly, one of the major advantages to vi is that vi uses a basic set of keyboard characters. No F? keys, no Ctrl, no Alt, no Home, etc. It managed to do this without losing any functionality. Now days this isn't as useful (at least not for the same reasons). In the past, when terminal communication wasn't as standard, not every terminal sent it's special characters in the same way. Further more, not every keyboard had the same control keys. For example, not everyone had F? keys, and if they did they might have only had 10 of them not 12. So, vi was able to be used on any platform, as long as you had the standard typewritter keys. It origanly gained a large user base because of this. Fortunatly, vi has survived even with the advent of fancy text editors. -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From x at x.com Fri Jun 1 03:34:33 2001 From: x at x.com (Abel) Date: Fri, 1 Jun 2001 08:34:33 +0100 Subject: a sample code Message-ID: <9f7dki$29n$1@diana.bcn.ttd.net> HI: I'm looking for a sample of code of a simple HTTP Server in Python.(i want just the basic code) Where can I find it ? Alberto From tjg at hyperlinq.net Mon Jun 25 18:24:04 2001 From: tjg at hyperlinq.net (Timothy Grant) Date: Mon, 25 Jun 2001 15:24:04 -0700 Subject: Windows Printing using win32print Message-ID: <20010625152404.A6504@trufflehunter.hyperlinq.net> I'm not much of a windows programmer, but I am in a situation where I need to write a test programme that does a lot of very small print jobs from a Windows box. I have downloaded win32all, and cobbled together a little app that I think should, maybe work, but doesn't. In my first iteration, I simply wrote a text file, then used os.system('copy filename lpt1:') to print it. This worked just fine, but one of the variables I need to test is how an interaction with the actual Windows printers works. To that end I started reading up on win32print. I was able to come up with the following... import win32print text2print = """ This is a test to see if I can get this text to actually print\n It will be multiple lines...\n Watch and see\n """ printer = win32print.OpenPrinter('Tektronix Phaser 600 Extended') jid = win32print.StartDocPrinter(printer, 1, ('TEST DOC', 'c:\\test\\test.tjg', 'RAW')) bytes = win32print.WritePrinter(printer, text2print) win32print.EndDocPrinter(printer) win32print.ClosePrinter(printer) print bytes Now this is where my understanding of how things should work gets a bit shaky. I have read that the WritePrinter() function should send printer ready data. So since text2print is not in ps or pcl native format, I'm curious as to whether I'm even close. If I do need to send printer ready data, how do I create the printer ready data from my print string? Thanks for any assistance you might be able to provide. -- Stand Fast, tjg. Timothy Grant www.hyperlinq.net Chief Technology Officer tjg at hyperlinq.net HyperLINq Technologies, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 20 days 22:08 hours ago<< From rnd at onego.ru Fri Jun 29 17:25:20 2001 From: rnd at onego.ru (Roman Suzi) Date: Sat, 30 Jun 2001 01:25:20 +0400 (MSD) Subject: Discussions and developing Message-ID: Hello, you, like myself, read (and write) to this mail-list/usenet group devoted to our beloved Python. We generate several megabytes per month. Python code (src) is 15-20 Mb. So, we could type one Python per 2 months. (Well, if we count quoting, probably in 6 months, but still impressive figure). Just why reacting to PEPs and accusations/opinions in newsgroup is more attractive than writing good piece of code for library, for some interesting Open Source project? (Am I alone or others also experience this temptation?) Lets imagine that 1/3 of the letters to c.l.p is converted to useful Python code. But no! It's far more interesting to react to yet another PEP! And this happens because reacting/disputing/flaming/... is a (small) fight between human beings and not between human being and dumb machine which need to be coded. May be, with time some kind of subject-against-subject programming technique will be invented, I dunno, and disputes will create not only tryth but quality code. I do not know how to convert my recent c.l.p. addiction into something useful for all. (if I only new how to be productive after full-time work...) So, I personally decided to shut up and not to participate in prolonged PEP discussions where no special protest must be expressed. This will be better for everyone, including myself. Lets silence for 1 day in memory of Jim Ellis, one of the Usenet creators, who died 28.6.2001. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Friday, June 29, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "I failed attitude in school." _/ From mal at lemburg.com Fri Jun 22 13:00:14 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 22 Jun 2001 19:00:14 +0200 Subject: [OT] MS EULA -- (will ActiveState become outlaws? ;-) References: <3B32F81F.259DBA46@chello.nl> <3B33644D.E32B4215@pfortin.com> Message-ID: <3B33799E.5BF65967@lemburg.com> Pierre Fortin wrote: > > Roeland Rengelink wrote: > > > > "Steven D. Majewski" wrote: > > > > > > Is this the next stage of Microsoft's war against Open Source ? > > > > > > Discussion of this on SlashDot : > > > > > > ( Right before the article on the Monty Python Action Figures! ) > > > > > > If this spreads to all of Microsoft's EULA's, will this make > > > ActiveState illegal ? Oh, I guess they could even rule out using GPLed (or any other license type) programs on their OSes... it's all a matter of the EULA they put on their software. Seriously, I think this is FUD -- somebody at MS probably didn't get the meaning of the GPL right and now thinks that by having someone redistribute their SDK together with an e.g. GPLed program *they* might be confronted with having to release the complete source code of their SDKs. > > > They don't specifically mention Python's > > > license, but they do mention Perl's ( and the "similar to any > > > of the following" clause would seem to include Python's. ) > > > > > > Does anyone know if this should be taken seriously ? > > > > > > -- Steve Majewski > > > > > > > > > > Ironically, NS under Linux refuses to display that ;) > > This page was visible with NS4.77/Linux yesterday; now, it stalls for a few > seconds, then presents a "page not found" screen... either they are shutting > out NS and/or Linux, or they've removed it... Same on Windows... plus the server often repsonds with "Server overloaded" -- the /.-effect. You can find the wording of the "Open Source" clause on slashdot.org though. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From jwelby at waitrose.com Thu Jun 7 13:52:49 2001 From: jwelby at waitrose.com (Julius Welby) Date: Thu, 7 Jun 2001 18:52:49 +0100 Subject: urllib proxy question Message-ID: At work I'm running Python 2.1 on W2k and using IE5.5 as my web browser. To access the web I have to go through a proxy server, which requires authentication. Problem: For a particular project, I want to access URL's on our *local* network, not on the web. If I have a proxy set in IE5.5, I cant use urllib.urlopen to connect to a local resource, even though I've set IE not to use the proxy for local addresses, and specified the servers concerned in the "Do not use proxy server for addresses begining with:" field. (Belt and braces? Probably.) To sucessfully use Python to access local pages I have to turn off the "Use proxy server" setting in IE5.5, so I can't use the web while I'm working with Python. This is becoming more of a problem as I want to be able to run Python based web services off my PC. Can anybody give me any guidance how I can stop IE5.5 settings affecting urllib.urlopen, or even getting Python to recognise all of the settings (so not trying to use the proxy for local URLs)? From nas at python.ca Thu Jun 21 11:31:53 2001 From: nas at python.ca (Neil Schemenauer) Date: Thu, 21 Jun 2001 08:31:53 -0700 Subject: PEP 255: Simple Generators In-Reply-To: ; from glyph@twistedmatrix.com on Thu, Jun 21, 2001 at 02:18:43AM -0500 References: <3B318449.2492CAD2@cosc.canterbury.ac.nz> Message-ID: <20010621083153.A19734@glacier.fnational.com> Glyph Lefkowitz wrote: > Disadvantages to the PEP 255 approach: > > * we'll probably want microthreads eventually; this feature will bloat > the language unnecessarily then. How so? It would still be nice to have some syntax on the language to support generators. If the implementation supports continuations then implementing PEP 255 will be easy. > * less pythonic: once we've implemented generators this way, what about > simulation loops? Do we need syntax support for those too? I don't know what you mean by simulation loops. > The one advantage to the PEP 255 way of doing things is that it > looks like it might be slightly easier to implement. Make that "much easier". Stackless is wizard code. Christian did an amazing piece of work there. Hopefully those ideas can be integrated into mainstream Python. Its still going to take a lot more work though. So far no one has stepped forward to do it. Neil From sholden at holdenweb.com Fri Jun 29 08:13:50 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 29 Jun 2001 08:13:50 -0400 Subject: getopts confusion References: Message-ID: "Rob Brown-Bayliss" wrote in ... > Hi, I have a problem with getopt on a linux system. > > I have two python progs, one works and one does not. Both import: > string, sys, getopt > > > This one WORKS: > [ unreadable program which works ] > > > This one FAILS with: > > Error on option -s: unknown option. > Run './gearbox.py --help' to see a full list of available command line > options. > > The code is: > > global wTree, GearBox, Status, showsum > try: > opts, args = getopt.getopt(sys.argv[1:], "hsz", ["help", "summary", > "zoo"]) > print getopt.getopt(sys.argv[1:], "hsz", ["help", "summary", "zoo"]) > except Error, msg: > # print help information and exit: > usage() > sys.exit(2) > for o, a in opts: > if o in ("-h", "--help"): > usage() > sys.exit() > if o in ("-s", "--summary"): > showsum = 1 > print "ssss" > if o in ("-z", "--zoo"): > zoo = 1 > > > The one that fails fais for all opts, but if I give args rather than > options it passes ok (as in I can print the args out) > > > Any one know whats going on? Any clues are welcome > Rob: Sorry, but the combination of your tabs and my mailreader makes it somewhat difficult to ensure I got the indentation correct. However: import getopt, sys try: opts, args = getopt.getopt(sys.argv[1:], "hsz", ["help", "summary", "zoo"]) print "opts:", opts, "\nargs:", args except Error, msg: print "Got error:", msg seems to work fine for me: > cd D:\Steve\Projects\Python > python optest.py -s -h --zoo D:\Steve\Projects\Python>python optest.py -s -h --zoo spam eggs spam opts: [('-s', ''), ('-h', ''), ('--zoo', '')] args: ['spam', 'eggs', 'spam'] I therefore suspect (**warning**: psychic Python debugging in action here) an indentation problem in your code. Do I presume correctly that the error message you report is actually generated by your code? If I try the example above with an invalid option it actually complains about the Error exception type (you should really be checking for getopt.GetoptError there): D:\Steve\Projects\Python>python optest.py -x -h --zoo spam eggs spam Traceback (most recent call last): File "optest.py", line 5, in ? except Error, msg: NameError: There is no variable named 'Error' I conclude that the getopt code is working correctly, but your application is somehow failing to test for the options. Hope this helps. regards Steve -- http://www.holdenweb.com/ From ack at nethere.com Tue Jun 26 14:38:38 2001 From: ack at nethere.com (Michael Ackerman) Date: Tue, 26 Jun 2001 11:38:38 -0700 Subject: python2.1 and RedHat7.1 Message-ID: <3B38D6AE.BEC652DF@nethere.com> Hello. I tried to install the python2.1 rpm for RedHat7.0 on my 7.1 system but got a "failed dependency" message saying that it wants: libcrypto.so.0.9.6, libssl.so.0.9.6 But these files are present, in /usr/lib. So what's going on? Any help will be appreciated. Thanks, Michael From montagne at boora.com Tue Jun 26 12:00:21 2001 From: montagne at boora.com (michael montagne) Date: Tue, 26 Jun 2001 16:00:21 GMT Subject: MSAccess databse from Linux box Message-ID: In my effort to rebuild our intranet on a Linux box with Python I need to retrieve information from several MSAccess databases. Is there a way to do that with Python? Or Zope? -mjm From skip at pobox.com Mon Jun 18 20:12:55 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 18 Jun 2001 19:12:55 -0500 Subject: Sorting Apache Log Files In-Reply-To: References: Message-ID: <15150.39175.371647.917021@beluga.mojam.com> Sheila> I need to search on Apache's date string. Sheila> How about this? Create a list of tuples, where the tuple is: Sheila> (datestamp, full_line) That will work, as long as you convert the string representation into something that will sort chronologically (e.g. mxDateTime). I missed the beginning of this thread, so perhaps this was already discussed, but I'm a bit unclear why you should need to sort an Apache log file by date/time, since it should already be in chronological order. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From loewis at informatik.hu-berlin.de Sat Jun 16 14:56:01 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 16 Jun 2001 20:56:01 +0200 Subject: BUG? Unicode and Python 2.0 References: <9gg48t$8tkqu$1@ID-58571.news.dfncis.de> Message-ID: "C. Meyer" writes: > The reason is (i think), that askopenfilename surprisingly returns > unicode string instead of string. Exactly, that's the problem. > If functions return sometimes unicode strings, how should this be done? Depends on what kind of processing you want to do. _tkinter will return plain strings if the string is all-ASCII, or if the conversion from the Tcl UTF-8 representation failed (which really indicates a Tcl bug), and Unicode strings otherwise. If you know that you sometimes get Unicode, your best bet is to do str = unicode(str) This will do nothing if str is already unicode, and convert from ASCII to unicode if it isn't. Then you can uniformly process Unicode strings. Perhaps _tkinter should be changed to return uniformly Unicode, but that may hurt performance in cases where the string is *known* to be ASCII-only (e.g. configuration parameters representing numbers or color names). IMO the best thing would be if methods that return arbitrary text always return Unicode strings, but that is hard to analyse, and will require loads of changes. > Is this a bug or a design problem, or do i misunderstand this? It's certainly a bug in the demo, please report it to sf.net/projects/python. I don't think there is a design problem anywhere, but perhaps a large number of bugs. Regards, Martin From see at below Thu Jun 14 21:13:58 2001 From: see at below (Paul Foley) Date: 15 Jun 2001 13:13:58 +1200 Subject: Python grammar.. References: <9g7nrv$nnb$1@news.mathworks.com> Message-ID: On 14 Jun 2001 07:00:09 GMT, Remco Gerlich wrote: > Why wouldn't that parse as (Spam (scramble eggs)) (ham) ? > If you're going to make the parentheses mandatory everywhere you've just > taken a step back to Lisp... In what way would this be a step back? [Besides, Python already requires the parens; it just wants them in the wrong place...] One-small-step-for-Python-one-giant-leap-for-mankind-ly y'rs, -- Nomina stultorum in parietibus et portis semper videmus. -- Cicero (setq reply-to (concatenate 'string "Paul Foley " "")) From gregj at pdxperts.com Tue Jun 26 00:06:48 2001 From: gregj at pdxperts.com (Greg Jorgensen) Date: Tue, 26 Jun 2001 04:06:48 GMT Subject: Should I use a dictionary? References: Message-ID: As you pick the messages you want store the message objects in a list (you are actually just making a list of references to the message objects, so don't worry about making copies of messages). For example: messages = [] # get a message m = rfc822.Message(file) if m_is_an_interesting_message: messages.append(m) When you want to sort the messages, use your own sort function to compare the message date/time: def cmp_msg_time(m1, m2): "compares time header from two message objects, returns -,0,+ compatible with sort" import time t1 = time.mktime(m1.getdate('Date')) t2 = time.mktime(m2.getdate('Date')) return t1 - t2 then sort the list with that comparison function: messages.sort(cmp_msg_time) I'm haven't tried this on actual email messages but I think you get the idea. Greg Jorgensen PDXperts LLC Portland, Oregon USA "Gustaf Liljegren" wrote in message news:Xns90CCC3D73603gustaflalgonetse at 194.213.69.148... > I have an object type for e-mail messages based on the rfc822 module. After > picking out some messages from several sources, I want to sort them in > order of the date property of the message object (as far as I understand, > everything in this process needs to be kept in memory). Anyway, the problem > is that I need some hints about how to sort the messages, as they are not > sorted in way I get them. > > One idea I came up with was to put the date property of the message object > as a key in a dictionary, and let the rest of the message be the value! But > even if it would work, I think it's ugly. If someone can convince me that > it's not ugly, or give a better (i.e. faster) solution, I'd be happy. > > Regards, > > Gustaf Liljegren From max at alcyone.com Wed Jun 6 22:41:07 2001 From: max at alcyone.com (Erik Max Francis) Date: Wed, 06 Jun 2001 19:41:07 -0700 Subject: Why should i use python if i can use java References: <9flu5i$c61$1@news.tudelft.nl> Message-ID: <3B1EE9C3.A16C2437@alcyone.com> mik wrote: > i' m a python newbie but I've this prob. i have seen Jython .. > > what has python dat java does not????????? No one's forcing you to use Python. If you prefer Java, so be it. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Life is something to do when you can't get to sleep. \__/ Fran Lebowitz Official Omega page / http://www.alcyone.com/max/projects/omega/ The official distribution page for the popular Roguelike, Omega. From dwig at advancedmp.net Tue Jun 26 12:55:11 2001 From: dwig at advancedmp.net (Don Dwiggins) Date: 26 Jun 2001 09:55:11 -0700 Subject: MS SQL Server In-Reply-To: Ben's message of "Tue, 26 Jun 2001 17:10:47 +1000" References: <51dgjtsbuureuugfcubid11tldg7077sfa@4ax.com> Message-ID: Ben writes: > Unfortunately I have to upload data to a MS SQL server ... Can anyone > recommend a tool for doing this or docs\examples :] ... is it ANSI > SQL compliant like MySQL and therefore can use the same commands? > greatly appreciate any advice To add to the previous replies: I've successfully used Python to drive SQL Server using the SQL-DMO objects, including the BulkCopy object, which can handle CSV-type files, etc. Take a look at the MS documentation to get an idea whether it'll do what you want. (In general, I've found it quite easy to translate the Visual Basic example code in the MS documentation to Python.) Happy hunting, -- Don Dwiggins "Solvitur Ambulando" Advanced MP Technology dwig at advancedmp.net From MarkH at ActiveState.com Sat Jun 23 23:10:52 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sun, 24 Jun 2001 03:10:52 GMT Subject: win32all - which exception? References: Message-ID: <3B355A40.6040005@ActiveState.com> Robert Pyron wrote: > I'm using win32 extensions to enumerate top-level windows. > For each window, I call win32gui.GetParent(). > If the window has no parent, the function raises an exception. > So, I have two questions: > > 1. What exception is raised by this function? I'm using > try:/except: to catch all exceptions, but I would like to > be more specific. > > 2. In general, for other win32 functions, how can I tell which > exception is being raised? The win32 extensions generally raise the _same_ exception for all functions. However, this exception has a number of aliases. eg, if using win32gui, then win32gui.error is probably good style. However, almost all modules ".error" attribute is identical to the others. The "canonical" exception is pywintypes.error (as it is defined in this DLL, which is used by all win32 exceptions.) eg: >>> win32gui.error >>> win32api.error >>> pywintypes.error >>> ie, all the exact same error. Mark. From cyberlync at yahoo.com Tue Jun 26 11:17:32 2001 From: cyberlync at yahoo.com (Eric Merritt) Date: Tue, 26 Jun 2001 08:17:32 -0700 (PDT) Subject: Mutable Strings? Message-ID: <20010626151732.31061.qmail@web13005.mail.yahoo.com> Guys, I am somewhat new to python and I have a bit of a question (as a side note, at work, I am a java programmer mostly). In python, as in java, strings are immutable objects (types in python I know). In any case, Java has provided a StringBuffer class that is basically a mutable string. Allowing you to append, insert etc without creating a new object. This saves quite a bit of object creation when any string processing is required. I have been looking for similar functionality in python and have yet to find it. I tried searching the archives but any search for terms relating to strings returns an enormous amount of hits. In any case, are any of you aware of a anything in python that provides this type of functionality? I am willing to write my own I just don't want to reinvent the wheel. __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ From tim.one at home.com Sat Jun 16 08:46:59 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 16 Jun 2001 08:46:59 -0400 Subject: New statement proposal for Python In-Reply-To: <9gf434089d@enews1.newsguy.com> Message-ID: [Alex Martelli] > ... > I think the proposed 'yield' is the first new keyword that stands > a chance of making it into Python in MANY years -- it does meet both > key criteria (truly major, no real semi-decent alternative). I like to repeat this every two years or so : four keywords have been added to Python, but only one after 1.0 was released (in January of 1994), and very few knew that another one existed. First "exec" was changed from a builtin function to a statement. This was done because exec can create new local vrbls, and it was impossible to get the scoping straight in all cases without letting the compiler know exactly when an exec could happen (BTW, a similar argument applies to yield wrt Jython, although Guido lacked the foresight to make yield a builtin function before 1.0). "lambda" was added for the 1.0 release. Guido still regrets it <0.9 wink>. "access" was added sometime or other, but it was never documented, never advertised, rarely admitted, and eventually went away again(!). It was a gimmick for adding piles of visibility controls to class and instance attributes; the implementation was terribly complicated, so failed the "if the implementation is hard to explain, it's a bad idea" test, and Guido never felt happy enough with it to admit its existence in public. That leaves the only post-1.0 addition, "assert". It took years to get that in -- although it's hard now to remember exactly why. The primary reason it's a keyword is so the compiler can eliminate it under -O. Guido should have made "keyword" a keyword too. Then we could have had a keyword statement at the top of each module, identifying all the post-1.0 keywords your code wants to use <0.9 wink>. > 'alias', IMHO, has _less_ chance than a snowball in hell (the latter > *might* happen to end up in one of the _frozen_ circles, after all!). > But note that channeling Guido is NOT my specialty -- gotta ask the > timbot for that. I'm not sure that the Dutch vision of hell coincides with Dante's, so in the interest of not ruffling any international feathers, I'll just say it stands about as much chance as a drunken virgin in Amsterdam. Almost all Python code "spells a constant" via UPPERCASE_NAME = some_expression and in 10+ years of Python practice I've never rebound such a name by accident -- or heard of anyone else doing so either. This isn't C, and e.g. we don't have the if (OOPS = 3) flavor of accidental rebindings. Neither does Python have pointers or an address-of operator, nor a call-by-reference mode, etc. You just can't put a name in a binding context by accident in Python, except for stumbling into the except ValueError, OverflowError: wart, and UPPERCASE_NAME is very unlikely to appear in that context. "const frameworks" get invented routinely, but their inventors appear to drop them after the heat of argument fades. Why bother? A universal convention supplies all of maintainability, clarity, consistency, and a foundation for good programming habits too. What it doesn't do is insist that you follow it against your will. That's Python! Guido once said that protection mechanisms in Python are like bicycle locks in Amsterdam: they're advisory. If you're not working with reasonably mature consenting adults, look into the rexec and Bastion modules for ways to *really* frustrate your errant coworkers. If you can't trust *yourself* to adhere to simple conventions, though, Python isn't your language. otoh-keep-using-it-and-you'll-change-so-that-it-is-ly y'rs - tim From gustafl at algonet.se Thu Jun 7 04:24:56 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 7 Jun 2001 08:24:56 GMT Subject: TypeError: object is not callable References: Message-ID: Paul Prescod wrote: >You need to do this: > >f = Friend.Friend() > >If that isn't the answer, I'll need more info. > Right! Obvious when you know it. :-) Gustaf From aleaxit at yahoo.com Tue Jun 19 06:08:51 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 19 Jun 2001 12:08:51 +0200 Subject: instance as fake module (Re: why is there no class (static) methods in Python ?) References: Message-ID: <9gn8bj0186@enews1.newsguy.com> wrote in message news:mailman.992898207.28586.python-list at python.org... ... > >As Alex Martelli has demonstrated a few times, you can substitute a > >class instance that implements __setattr__ and __getattr__ in place of > >the module object in sys.modules. > > How would such an approach work with "import", "from", "__import__", etc.? Pretty well, thanks (it DOES give problems with 'reload', though, if that is what you mean by 'etc':-). Why not give it a try -- it *IS* as simple as a crystal-clear spring, after all. Here's a toy example: :: fake.py class _fake: __all__ = [] def __getattr__(self, name): if name.startswith('__'): raise AttributeError, name else: return 'fake_'+name import sys sys.modules[__name__] = _fake() :: end of fake.py D:\py21>python Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. Alternative ReadLine 1.4 -- Copyright 2001, Chris Gonnerman >>> import fake >>> fake.pop 'fake_pop' >>> fake.plap 'fake_plap' >>> from fake import foopi >>> foopi 'fake_foopi' >>> fakefake = __import__('fake') >>> fakefake >>> fakefake.ploppy 'fake_ploppy' >>> fakefake is fake 1 >>> > Is it really viable to try to create a class whose instances "fake" module > objects? Sure! It's not just viable, it's EASY -- as long as client code does no type-tests, of course, just as for any other application of Python's signature-based polymorphism. (The "Protocol Adaptation" PEP is my personal big hope for a really powerful way to wean people who write client-code off doing rigid type-tests, which break all of the niftiest polymorphic tricks:-). > And use this as the standard idiom for modules? I'll pass on this one. I suspect that by-far-MOST modules have no need for __getattr__ and __setattr__, so I don't really see why having a module replace its entry in sys.modules would ever become "THE standard idiom". But when I *DO* need a "module __getattr__" etc, it seems to work pretty well today. I'll pass on metaclasses, "true class methods", etc, too -- it does not appear to me that the instance-as-a-fake-module idea gives anywhere near ALL the power that such deep concepts might yield. But I haven't done nearly enough Smalltalking to feel the need for such specific packaging-of-power deep in my bones. Specifically, my personal gut feeling is that classes are nice but vastly overrated in most OO literature, and other tools and mechanisms may be preferable for several tasks -- so, by instinct rather than by reason, I feel suspicious of attempts to load yet more power and functionality on classes' backs and sympathetic to ideas of "off-loading" tasks now entrusted to classes to other simpler entities (e.g., "interfaces"). But that's guts, not reason - mostly an impression that comes to me from comparing _previous_ attempts to "do it all with classes" (e.g. the class==interface identification in C++ or Eiffel, the class==namespace in old C++ versions, &c) with ones to separate concepts (the class/interface split in Java, the class/namespace split in modern C++). It may well be that my instincts are operating on inappropriate foundations when it comes to judging specific class-related ideas in the specific context of Python's future developments. Alex From philh at comuno.freeserve.co.uk Fri Jun 29 19:29:48 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Sat, 30 Jun 2001 00:29:48 +0100 Subject: PEP scepticism References: Message-ID: On Fri, 29 Jun 2001 17:43:34 -0400, Tim Peters wrote: > >> It seems to me that optional-pass is obvious in its meaning, > >Sorry, I have no idea what it means. Like you want to be able to use "pass" >in more places, but optionally? Or want not to have to use pass in some >places where you must use it now? Or ...? It means where now you have to say: class myClass: pass or def myfun(): pass when you create an initially-empty construct, you will in future be able to say: class MyClass: def myfun(): and the pass keywords will be implied by the compiler. Perhaps implied-pass is a better name? >> but multi-liner comments aren't. There are three issues: >> >> 1. what should be the character sequences to begin/end multi >> line comments > >What do you have against the existing method? That is, > > """This is a multi-line comment. > this part of the same comment. > so is this.""" > >It's truly a comment: a statement consisting of just a string is thrown >away by the compiler, unless it's in a docstring position (is the first >non-comment statement in a module, def or class). I don't like this, because it just doesn't feel right to me. A Comment should look different, syntactically, from a string literal. Also, I suspect that docstrings are a source of inefficiency (OK, I admit that's not a real problem when you have a short python program and 128M of RAM). >Or the other existing method: > > # This is a multi-line comment. > # Although it sure looks like a sequence of > # single-line comments . This is truly bad, because it makes it harder to add new lines; you have to type "# " repeatedly when adding new comment text, which breaks the flow of thought -- at least it dores for me. >There's really no point answering these questions on c.l.py: that they've >been *asked* means the proposals are already controversial, so need PEPs to >lay out all sides of the case. I don't know what "optional pass" means, but >the multi-line comment business has come up many times, so it would be >especially good to PEP that one, in order to lay it to rest (one way or >another) for good. I wasn't aware that you could just plonk a string literal around anywhere and it get ignored, thus forming a comment. In the light of that, my multi-line comment proposal may seem a bit pointless. So here's what I will do: write a PEP for it if at least 2 people on this newsgroup say they support the idea. -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From robin at jessikat.fsnet.co.uk Fri Jun 29 15:05:55 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 29 Jun 2001 20:05:55 +0100 Subject: PEP 260: simplify xrange() References: Message-ID: In article , Guido van Rossum writes >Here's another sweet and short PEP. What do folks think? Is >xrange()'s complexity really worth having? > ... yes, if it works now and has been used, put in some tests to ensure it doesn't break in the future and leave alone. Needless minimalism is as bad as excessive maximalism. -- Robin Becker From tundra at tundraware.com Wed Jun 20 05:34:57 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 20 Jun 2001 09:34:57 GMT Subject: ANN: tdir Message-ID: <3B306D5A.7F9D92D3@tundraware.com> I wrote a semi-useful utility in the course of getting comfortable with python. It's patterned after an ancient MS-DOS util that sorted and displayed files based on their extensions that I wrote ages ago. I always wanted a version for Unix, but I didn't feel like converting the old assembler into anything like 'C' - so I rewrote from scratch. The new python version does all kinds of nifty stuff) and you may have a copy for your very own self (plus laugh hysterically at my python code) at: http://www.tundraware.com/Software/tdir/tdir-1.5.zip ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From rusha at data-tech.com Fri Jun 1 12:45:00 2001 From: rusha at data-tech.com (Rush) Date: 1 Jun 2001 09:45:00 -0700 Subject: Help: Capturing COM events References: <9c4a6c75.0105311112.85a330d@posting.google.com> <16074dce.0105311736.3f186cfe@posting.google.com> Message-ID: <9c4a6c75.0106010844.7b9f165c@posting.google.com> > In essence-- > > Create a class that, for every event you're interested in, has a > method named MyClass.On > > Call DispatchWithEvents, passing it the CLSID/ProgId of the COM server you're > interested in, *and* the event-handling class object. > > DispatchWithEvents will return an object that (effectively) inherits from both > the COM server and your event-handling class, and this object's proper > methods should be called when the COM object fires an event. > > This is a simplification, of course, as the framework scheme that supports > this seems to be *very* complex. Digging through the docstrings and comments > in win32com.client should help explain more details. But hopefully this > general overview will be helpful. :) > > Jeff Shannon > Technician/Programmer > Credit International Jeff, Thanks for your response. Yours was a most succinct, understandable reply. I'll be trying to implement this this afternoon. From dnew at san.rr.com Mon Jun 4 12:56:25 2001 From: dnew at san.rr.com (Darren New) Date: Mon, 04 Jun 2001 16:56:25 GMT Subject: random References: Message-ID: <3B1BBDB9.AAC4DE95@san.rr.com> Tim Peters wrote: > > [Darren New] > > how random is the binary string "1001010010011100100"? How > > random is the binary string "0000000000000000000"? Such questions > > don't make any sense. > > BTW, you can find attempts to answer such questions in Knuth, Vol 2. The > questions not only make sense, but finding non-trivial answers is important > in real life: even if you have a theoretically perfect physical RNG, how > can you have confidence in a specific real implementation? This is a different question. The point is that the two strings above are equally probable if they're both generated randomly. Hence, asking which is "more random" is asking a different question. They're both equally probable, and they're both equally random (i.e., not at all, because I just told you what they are). As far as "testing for randomness", the point is that a machine generating a long string of zeros is more likely broken than randomly generating zeros. If my random number generator started outputting the ASCII of the Linux kernel sources, I'd start wondering too. If it started outputting the ASCII of the Linux kernel XOR the source of the GNU CC compiler, I should be equally worried, yes? But since I might not notice *that* one, I'd not be worried. Should I be worried if it outputs exactly the secret message I was about to encrypt, so that the *cypher* text is all zeros? Sure, informally speaking, the first string is "more random" than the second. Or, put another way, the second string is "less random" than the first, as there are more ways to generate the second string with non-random generators than there are ways to generate the first string. It's not "less random", it's "less unusual" or "less surprising". But that's not a measurement of the string, but rather its relationship to the people looking at it. > the hypothesis that the source is truly random. Saying "well, *any* > sequence of N bits is equally likely from a truly random source, so they > both look random enough to me!" should leave you at least a little > uncomfortable, if not downright embarrassed . Indeed, if you block out the possibility of using a long string of zeros, you weaken the security of a one-time pad encryption mechanism. It's no longer perfectly secret. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. This is top-quality raw fish, the Rolls-Rice of Sushi! From robin at stop.spam.alldunn.com Mon Jun 18 21:15:00 2001 From: robin at stop.spam.alldunn.com (Robin Dunn) Date: Tue, 19 Jun 2001 01:15:00 GMT Subject: Python 2.0 and wxPython 2.0 References: Message-ID: "Doug Farrell" wrote in message news:C%fX6.14660$Kq4.1461586 at newsread2.prod.itd.earthlink.net... > Hi all, I have Mandrake 8.0 installed on my system and I'm a little > confused. I went to try and install wxPython (which I downloaded from the > website) and the system tells me it's already installed, which is great! > However, I downloaded the demo and I can't seem to run any thing there. Does > anyone know what's going on and how I might fix this? I'm a relative linux > newbie... The RPMs for wxPython were built on a system in which Python 2.0 was installed under /usr/local. IIRC, the Python 2.0 packages that are available for Mandrake 8.0 install under /usr, so wxPython ends up being installed in a place that Python is not looking. There are a few possible solutions for you. 1. Set an environment varaibale named PYTHONPATH to /usr/local/lib/python2.0/site-packages 2. Move or link /usr/local/lib/python2.0/site-packages/wxPython to /usr/lib/python2.0/site-packages/wxPython 3. Get the wxPython source RPM and rebuild it on your system. It will use your installed Python as part of the build process and will then get the paths right. If you do this you'll also need the wxGTK-devel RPM installed. -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! From jmarshal at mathworks.com Mon Jun 11 17:49:55 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 11 Jun 2001 21:49:55 GMT Subject: Python grammar.. References: Message-ID: <9g3ee3$dcq$1@news.mathworks.com> John wrote: > Hi, > I previously asked whether Python accepts function arguments without the > opening/closing brackets and commas, like so: foo(x,y) would become foo x > y. The answer to this was no. So, I am wondering if it would be easy to > modify the source and rebuild the interpretor to accept this format? I > tried modifying the Grammar file but that didn't seem to work... This introduces an ambiguity: how do you parse "f(1,2)"? Is it the function f called with 2 arguments or is it f called with one argument--the tuple (1,2)? I don't think there's any way to disambiguate using parens. This issue doesn't come up in SML (the only other language I know that uses concatenation for function application) because all functions in SML take exactly one argument. From aleaxit at yahoo.com Fri Jun 15 12:27:37 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 15 Jun 2001 18:27:37 +0200 Subject: Integrating a Python GUI into a PowerBuilder App References: <49624b0b.0106121135.61b6bd6c@posting.google.com> <49624b0b.0106140505.79851658@posting.google.com> <9gahru048k@enews1.newsguy.com> <49624b0b.0106150407.626295ca@posting.google.com> Message-ID: <9gdd1r0pde@enews1.newsguy.com> "D-Man" wrote in message news:mailman.992616086.24867.python-list at python.org... > On Fri, Jun 15, 2001 at 05:07:24AM -0700, John Urberg wrote: > ... > | Sorry if I was unclear in my previous post. I can use a Java or VB > | GUI by making ActiveX controls from GUI panels done in those languages > | and placing them on a blank PowerBuilder MDI child window. Since I > | can't do that in Python, I have to find some other way (making a > > I find it hard to believe that you can't do that in Python. For one > thing, Jython is an implementation of Python that runs on top of the > JVM (as opposed to having its own VM implemented in C). Through the > use of Jython, Python code can access anything that Java code can. > Thus if you can use Java, you can use Jython to achieve the same 100%-right. Specifically, though -- if you can use *UP-TO-DATE* Java. If you're stuck with Java 1.0, I don't think Jython will necessarily run there (e.g. on some old browser that you cannot upgrade with a recent sunsoft plugin). But I don't think that's a problem for ActiveX-controls-made-in-Java (it definitely was NOT a capability with Java 1.0 and its AWT:-). > result. I'm not familiar with ActiveX at all, but if it is related to > COM, I know that CPython has good COM support. Yes, but I don't think it directly implements ActiveX controls with a visual interface (just good ol' plain COM servers). No problem, of course, since that's exactly what HTML Scriptlets are for -- letting you make an ActiveX control out of *ANY* language supporting the ActiveScripting protocol (as Python does, with the win32all extensions or in the ActivePython build). People who dislike Internet Explorer just don't really understand what an INCREDIBLE wealth of reusable COM and ActiveX stuff it's composed of... more even than Mozilla, and that *IS* saying something:-). Alex From thomas.hansenNOSPAMORILLSUEYOURASS at entermatch.com Wed Jun 6 10:22:06 2001 From: thomas.hansenNOSPAMORILLSUEYOURASS at entermatch.com (Thomas Hansen) Date: Wed, 6 Jun 2001 16:22:06 +0200 Subject: best language for 3D manipulation over web ? References: <9f7eqe$gvd$1@oslo-nntp.eunet.no> Message-ID: <9fldqf$2bo$1@oslo-nntp.eunet.no> [snip] > > PS! > > It's an ActiveX object, > > Ergo it won't work in my browser, nor in any other browser except IE. > Who cares if they're making games since EVERYBODY that play games on something else then a Sony, GameBoy (or similar) sits in front of a PC... > > wraps around DirectX to make scripting 3D games > > possible. > > Ergo it won't work on any plattforms except Windows. Same as above, except exchange PC with WIN32 system... > > We are talking about Java here, not C++ and the main advantage of Java is > plattform indepency. Why destroying that if it's not necessary? > > There's Java3D available for quite some time now. It's a plattform independend > Java plug-in that makes use of OpenGL for displaying 3D animations with > hardware support. It's support for nearly all propagated PC plattforms which > can also support OpenGL (in case of Windows, there are even two versions: one > version running on top of OpenGL and one running on top of Direct3D; I'd choose > the OpenGL version, because if you have a GeForce or Rendeon graphics adapter, > you'll have a lot better performance thanks to hardware T&L). DirectX have had hardware acc. T&L since version 6 or seven I think... > > > I've seen it with a "need for speed" kind of game and it really works (on a > > PII 300mHz, ATI RAGE PRO 8MB) > > I've seen that too and it even works without hardware acceleration. > http://www.minatrix.com/burningmetal2.html It was very nice, and I was actually very impressed, but it's not even in the same league as the WTGD... > > But with Java3D you'll also have texture filtering and real shading. > http://java.sun.com/products/java-media/3D/index.html > > Plattform support: > Solaris (Sparc), Windows (x86), Linux (x86), HP-UX, AIX, SGI Irix > > -- > TGOS From tim.one at home.com Tue Jun 19 19:57:28 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 19 Jun 2001 19:57:28 -0400 Subject: PEP 255: Simple Generators In-Reply-To: <4DLX6.320220$oc7.29444949@news2.rdc2.tx.home.com> Message-ID: [Rainer Deyke] > ... > Consider: > > def f(): > return > yield 'Never reached.' > > > Is this function a generator? Yes, but a pretty useless one. Python's not going to prevent you from writing useless code, else 99% of programming jobs would vanish . > Yes, but only if nobody removes the seemingly redundant 'yield' > statement. If they think it's redundant, they don't understand the language well enough that sticking "gen" on it instead of "def" is magically going to give them an education. > Or consider a case like this: > > def f(x): > if x == 0: > do_something() > elif x == 1: > do_something_else() > # ... > elif x == 99: > yield 5 Why? That is, it's obviously contrived. Play with the feature and find a problem that actually bites you. I'm not concerned if a determined newbie with bad programming habits ("Here we have a very long function that doesn't fit on the screen all at once") can get themself confused. it's-called-"simple-generators"-not-"idiot-proof"-ly y'rs - tim From grante at visi.com Sun Jun 24 20:37:30 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 25 Jun 2001 00:37:30 GMT Subject: Is this a true statement? References: <3b34939b.410758@nntp.sprynet.com> <9h2nuc$g6g$0@216.39.170.247> Message-ID: On 23 Jun 2001 18:42:20 GMT, David LeBlanc wrote: >The reason why you can't write a device driver in pure Python >is simple: a device driver requires the ability to read to and >write from specific pre-determined locations in the processor's >memory and/or I/O space. So you write a few trivial extension modules in C to handle direct access of physical memory and I/O. That shouldn't take more than an hour or two. The real work is getting a Python byte-code interpreter running in kernel-mode. >It would be possible, if best performance where not required, to extend >Python with C or ASM (and possibly C++, but not without some dificulty: >passing "this"pointers gets in the way when crossing memory management >and/or procsss thresholds. The same problems happen when passing C pointers around. >Of course, with enough glue and the right scaffold, one could glue up >enough toothpicks to reach the moon. I don't think it would be quite that hard. :) -- Grant Edwards grante Yow! I just got my PRINCE at bumper sticker... But now I visi.com can't remember WHO he is... From sorular at netscape.net Sat Jun 30 02:42:29 2001 From: sorular at netscape.net (sorular) Date: Sat, 30 Jun 2001 06:42:29 GMT Subject: How to create Python executable Message-ID: <3b3d73cd.48834029@news-server.bigpond.net.au> A simple question I should've learnt long ago! How to make an executable from a python program? The code is made up from several python scripts and files in a directory. It requires ActiveState to run but I want to run it on any machine as an executable (*.exe) that don't necessarily have python. thanks ~sor From steve.menard at polyester.com Tue Jun 26 15:27:34 2001 From: steve.menard at polyester.com (Steve Menard) Date: Tue, 26 Jun 2001 15:27:34 -0400 Subject: python2.1 and RedHat7.1 References: Message-ID: <9hanjr$a27$1@newsmaster.axxent.ca> Yeah I giot the same problem. I force the install since I dont use SSL anyway ... "Michael Ackerman" wrote in message news:mailman.993580729.681.python-list at python.org... > Hello. > I tried to install the python2.1 rpm for RedHat7.0 on my 7.1 system but > got a > "failed dependency" message saying that it wants: > libcrypto.so.0.9.6, libssl.so.0.9.6 > But these files are present, in /usr/lib. So what's going on? > Any help will be appreciated. > > Thanks, > Michael > > From akhar at videotron.ca Fri Jun 1 17:16:45 2001 From: akhar at videotron.ca (akhar) Date: Fri, 1 Jun 2001 14:16:45 -0700 Subject: PIL speed and fear References: Message-ID: What if I thread the gui and the image filters? will that get me a speed boost? Pete Shinners a ?crit dans le message : sPOR6.63746$154.20716453 at typhoon.we.rr.com... > "akhar" wrote > > I noticed that it tries to open > > a dos session and then shows me the image in paint. I am afraid that for > > phase two when I start using streams of images directly from the camera that > > their will be an enormous lag. Is it only because of windows? should I be > > using something else for realtime video streams like pySDL? or is it windows > > and I should use freebsd to do this? > > the problem is that the Image.show() command is pretty much a hack > to make life easier. it saves the image as a temporary file, then > launches a standard image browser in a separate process. > > this will not do at all for any kind of realtime system. > > your best bet is to use PIL's interface to Tkinter and make your own > small gui, then i believe you can display the PIL images directly in > the gui. (saving the save, launch process, load steps) > > i still don't know if that is going to be fast enough? not because > PIL or python are too slow, but because thats a lot of image data to > be analyzing and processing realtime > > From dsh8290 at rit.edu Thu Jun 7 16:13:24 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 7 Jun 2001 16:13:24 -0400 Subject: RS232 support for DOS on 486? In-Reply-To: ; from phd@phd.fep.ru on Fri, Jun 08, 2001 at 12:02:28AM +0400 References: <20010607142730.B17494@harmony.cs.rit.edu> Message-ID: <20010607161324.A17786@harmony.cs.rit.edu> On Fri, Jun 08, 2001 at 12:02:28AM +0400, Oleg Broytmann wrote: | On Thu, 7 Jun 2001, D-Man wrote: | > Does Python even run under MS-DOS? | | Under DOS Extender - no problem. I used Python 1.5.2 quite successfully! That's good to know. What is "DOS Extender" anyways? -D From aleaxit at yahoo.com Tue Jun 5 12:41:54 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 5 Jun 2001 18:41:54 +0200 Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> <3b19393d.703539923@news.okstate.edu> <9fgkci0gdu@enews2.newsguy.com> <3b1ce391.2243151@nntp.sprynet.com> Message-ID: <9fj24r01hpj@enews1.newsguy.com> "David C. Ullrich" wrote in message news:3b1ce391.2243151 at nntp.sprynet.com... ... > [c] > >> A perfect RNG is one with this property: > >> If you use it to generate N bits then each > >> sequence of N bits appears with probability > >> 1/2^N. It has this property for _every_ N. ... > The property you're talking about is that > all sequences of N bits appear in the > sequence with frequency 2^(-N) (asymptoticaly). Thanks! > This is not the same as [c]. I fail to see the difference, when I use my hypothetical normal-but-computable number (thanks for informing me that pi is not known to be, just so hypothesized, but that there are others that are known to be -- and the vaguely Cantorian construction of just writing the integers in sequence one after the other, that you use later, sounds quite a simple example and rings some vague bell...) as a 'generator', by asking about its next N bits each time. I agree there need be nothing random or non-compressible about the hypothetical number -- (c) didn't mention anything about that, just "normality" (normalness?) of the bitsequence. Now that we agree that normalhood (normalance?) of a bitsequence is achievable by arithmetic generators, we can presumably lay this sub-sub-sub-part of the discussion aside (but meanwhile I have refreshed my dim memories and thereby benefited -- thanks). > >But isn't that the reason we have Turing machines, > >their infinite tape?-) > > Um, you're absolutely right about this. I guess > I was assuming a bounded amount of storage in If you look at the way disk prices are going, we might be there: place a sum in a bank, each time the disk is close to running out take some of the interest and use it to go buy a new disk... as long as you only use a finite amount _at a time_, you're approaching UTM's unboundedness:-). (hot-swap RAID controllers assumed of course:-). > I still suspect it's true that given anything > which I would call an arithmetic RNG there > exists a "randomness test" that the RNG will > fail, which a "perfectly random" RNG would pass. > But the proof above is nonsense, because I do > mean to allow unbounded storage (otherwise > things are boring). And we still need the "perfectly random RNG" definition to allow us to see if we can prove we can't do it arithmetically, since [c], while part of that definition, is not sufficient for such proof (nor, in fact, to meet what _I_, with my much-weaker intuitive criteria, would deem 'random enough for me' -- pi, or whatever normal number must take its place, being all too predictable). > To put it another way: Consider the number > > 0.0123456789101112131415161718192021222324... > > consisting of all the natural numbers written > one after the other (took decimal to make > the pattern more clear). This _is_ a normal > number, which is to say that the digits of > this number _are_ "random" in the sense > that we're assuming the digits of pi are > random. It doesn't really look like a > "random" number, does it? Seems kind of > easy to predict the next digit. Yep, it has lot of structure and can in fact be generated by a very small program (as can pi, but this one looks like I can make an even smaller program). So what is "perfect" in a "perfectly random" normal real number? I realize you don't want to talk about random NUMBERS (or sequences) but random GENERATORS, but if I have a number I can make a generator and vv from the actual sequence of bits a generator gives me I can make a number -- say there is no "rewind", no time machine (Guido has the only one and he ain't gonna lend it to us), so that all we can do is ask the generator, a black box, for "N more bits please" and it will comply, now couldn't we biject between generators seen this way and real numbers? Maybe we can't, but if so I fail to see why. How should we define a "generator" in a way that's general enough to let us study under the same hat very different- nature ones (so we can't peek under the hood, just look at the output) if not as a machine that gives me "N more bits" when I ask for them? Now we can maybe devise a test that we can prove the machine will fail if it is generating by using arithmetic while the "perfect" generator will pass? I don't think it needs to be a finite-time test, either (else the 'perfect' part seems to have little use:-). Compressibility looks nice to me here. No compressibility in the 'perfect' generator, surely. But is this the definition of 'perfect' you want to use? Or just a CONSEQUENCE of how you really want to define it...? Alex From fdrake at beowolf.digicool.com Fri Jun 22 14:31:44 2001 From: fdrake at beowolf.digicool.com (Fred Drake) Date: Fri, 22 Jun 2001 14:31:44 -0400 (EDT) Subject: [maintenance doc updates] Message-ID: <20010622183144.C6A5428927@beowolf.digicool.com> The development version of the documentation has been updated: http://python.sourceforge.net/maint-docs/ Lots of smallish updates and corrections, moved the license statements to an appendix. From winterdk at hotmail.com Wed Jun 13 04:45:04 2001 From: winterdk at hotmail.com (Christer Østergaard) Date: Wed, 13 Jun 2001 10:45:04 +0200 Subject: All functions from self and inherited classes References: Message-ID: <1KFV6.110$Qo.373723164@news.euroconnect.net> "Skip Montanaro" wrote in message news:mailman.992379799.20401.python-list at python.org... > > >> And a dir(self.__class__) returns methods, but only methods defined > >> in B. > > Alex> Someone posted this code here ages ago.... [snipped] > > The (new) standard module inspect has a getmembers function (output wrapped > for readability): [SNIP] -- > Skip Montanaro (skip at pobox.com) > (847)971-7098 > Very interesting... i'm currently working v. 2.0, and no module "inspect" seems to be part of my pakage... do you know if there any possibility of me fetching the module, and thereby not being forced to upgrade the full monty? Christer From nperkins7 at home.com Fri Jun 1 18:18:37 2001 From: nperkins7 at home.com (Nick Perkins) Date: Fri, 01 Jun 2001 22:18:37 GMT Subject: Fwd: Tkinter: image handling: bug or feature? References: <3B17C053.323EEF7@artenumerica.com> Message-ID: <1xUR6.111254$eK2.25794773@news4.rdc1.on.home.com> I am not surprised that you have to at least call Tk() ( initializes Tk ) before creating the PhotoImage. I wouldn't call that voodoo or anything. I suppose that is done 'behind the scenes' when you instantiate 'TopLevel'. OTOH, I agree that it does seem slightly inconsistent that you have to keep a reference to the PhotoImage. I will keep your experience in mind if try to use PhotoImage. Thanks for the info. From donod at home.com Sun Jun 24 11:54:56 2001 From: donod at home.com (Don O'Donnell) Date: Sun, 24 Jun 2001 15:54:56 GMT Subject: the indentaion for grouping thing References: <3b33d9d6$1_1@anonymous> Message-ID: <3B360D77.C84BC723@home.com> Anonymous wrote: > > ... I gather that someone > has written a preprocessor that allows you to use delimiters with python. > Is this true? If so, where can I find it, I would like to use it. > As others have pointed out in past threads, you don't need a preprocessor, just use #{ and #} As in: if x > 12: #{ dosomething() #} else: #{ dosomethingelse() #} Although, IMHO, it just adds to the noise and clutter. Of course, this could also be written as: if x > 12: #{ dosomething() #} else: #{ dosomethingelse() #} Which just points out two more problems with explicit block delimiters: 1. The multitude of coding styles. 2. The egregious waste of screen space. I use a Python aware editor, set to use four spaces for tab. It automatically indents the lines after 'class', 'def', 'if', 'else', 'while', 'for', etc. To dedent at the end of a block, just hit the backspace key once, it couldn't be simpler, and I've never had any of the problems of mixing tabs with spaces which you warn against. I just can't imagine why anyone would want to fool around with opening and closing braces in addition to indenting and dedenting, when an editor, configured to recognize Python syntax can make life so much easier. Give it a try for a while, I bet you'll get to like it. Cheers, -Don From rnd at onego.ru Tue Jun 19 01:14:43 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 19 Jun 2001 09:14:43 +0400 (MSD) Subject: PythonCard - was Re: Event-driven GUIs ... In-Reply-To: Message-ID: On Mon, 18 Jun 2001, Neil Hodgson wrote: > Ron Stephens: > > Perhaps if someone could do a PythonCard for event driven gui programs, > > using the Python syntax and the Hypercard container model, it would be a > > big hit > > ;-)))) > > The feature I loved in HyperCard was that persistence was built-in. Probably PythonCard should be database-powered to provide fast object retrieval and persistant storage. > Actually it was better than built-in - it permeated the whole paradigm. It > was a great environment for people who didn't see themselves as developers > as it could be used on several different levels with scripting not being > needed for many tasks. Many were able to build applications even though they > did not wish to spend a lot of effort on learning or developing. > > However, the market, which was given several HyperCard like products to > choose from, has decided against this form of development environment. The market ways are unpredictable, because decisions are made not on the basis of technical merits but with some strange reasoning behind. For Freeware project it is not necessary to look at what market has or does, because if somebody will ever implement PythonCard it will be made with self-satisfaction in mind. This is how emulator for old computers are made and maintained: because people have nostalgic feelings about them. > Neil Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From not.this at seebelow.org Wed Jun 27 23:17:02 2001 From: not.this at seebelow.org (Grant Griffin) Date: Wed, 27 Jun 2001 22:17:02 -0500 Subject: PEP 260: simplify xrange() References: Message-ID: <3B3AA1AE.AC965683@seebelow.org> Sorry to come in on this so late... Guido van Rossum wrote: > > Abstract > > This PEP proposes to strip the xrange() object from some rarely > used behavior like x[i:j] and x*n. I like it, but I can think of two questions that might be answered within the PEP. 1) What is the effect on speed? Presumably speed will increase (or at least stay the same), but, heck--who knows? 2) How do the functions from xrange relate--semantically speaking--to the functions of "xreadlines()"? It seems to me that the two should have a similar "user interface" because they work about the same way, and solve similar problems. thus-the-'x'---whatever-*that*-means--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From crombie88 at yahoo.com Fri Jun 22 19:05:26 2001 From: crombie88 at yahoo.com (crombie) Date: Fri, 22 Jun 2001 16:05:26 -0700 (PDT) Subject: (no subject) Message-ID: <20010622230526.88321.qmail@web14201.mail.yahoo.com> newbie question: trying to type this in: >>> a, b = 0, 1 >>> while b < 1000: ... print b, ... a, b = b, a+b ... 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 but result is this: >>> while b< 10 SyntaxError: invalid syntax >>> while b < 10: ... print b IndentationError: expected an indented block (line 2) >>> while b < 10: print b a, b = b, a+b ... SyntaxError: invalid syntax >>> while b < 1000: ... print b, IndentationError: expected an indented block (line 2) >>> while b < 1000: ... print b, SyntaxError: invalid syntax >>> anyone know why? much thx, tc __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ From herth at netcologne.de Thu Jun 7 17:15:29 2001 From: herth at netcologne.de (Peter Herth) Date: 07 Jun 2001 23:15:29 +0200 Subject: Interesting speed benchmark References: Message-ID: <87elswq9e6.fsf@netcologne.de> msoulier at storm.ca (Michael P. Soulier) writes: > On Thu, 7 Jun 2001 10:40:04 +1000, Delaney, Timothy > wrote: > This makes sense, but if Python is doing less allocation, that should also > be a time saver, no? Or did the performance increase in lazy GC just so far > outweight the benefits of less malloc() calls that it didn't matter here? > > Mike Well that depends very much on the kind of program at hand: If, as in the example, the allocated pieces of memory have a very short living and get only referenced once, a reference-counting implementation of a GC is perhaps the fastest solution. But reference-counting has 2 big drawbacks: any referencing of an object has an additional cost of the reference count bookkeeping, and it cannot deal with cyclic references. Furthermore, memory might fragment, and this makes malloc() a rather expensive operation. Other garbage collection techniques do not have the extra cost at referencing objects, but cleaning them up usually involves inspecting part or even the whole heap to determine what can be collected. This is of course a very time-intensive operation, but depending on the requirements of the program can still be much faster than reference counting. One common approach taken in modern garbage collectors is generational collection: objects on the heap are put into "generation" depending on their age, garbage collection runs mostly look only at the youngest objects, so all the short-living temporary objects can be cleared with very low overhead. If the collectors do some compacting of the heap in the process, the speed of allocation can be *greatly* increased, to the point where heap allocation is as fast as stack allocation. (In my experience, most of the impressive speed-up of Hotspot comes through the generational GC) Peter -- Dawn of the Ages http://dawn.netcologne.de From pythoneer at diganet.com Wed Jun 13 15:12:00 2001 From: pythoneer at diganet.com (John Tobler) Date: 13 Jun 2001 12:12:00 -0700 Subject: Python Development: San Diego Message-ID: <711a10e7.0106131112.19f51017@posting.google.com> I am compiling a list of companies doing Linux software development in the San Diego, CA, area. If you know of any, please let me know. John Tobler grepninja at diganet.com http://cyberjet.tripod.com/grepninjalog/ From owen at astrono.junkwashington.emu Tue Jun 5 12:15:31 2001 From: owen at astrono.junkwashington.emu (Russell E. Owen) Date: Tue, 05 Jun 2001 09:15:31 -0700 Subject: How to get a unicode degrees symbol? Message-ID: <9fj0j6$e7m$1@nntp6.u.washington.edu> I'm obvious missing some important bit of documentation, but I looked through the manuals and can't seem to figure out how to get unicode character constants into python strongs. For instance I'd like to create a string that contains a degree symbol (that would show up correctly on all platforms). Right now I'm generating a character constant whose contents are set differently depend on the platform. It works but is rather lame. Any documentation pointers or other suggestions would be appreciated. -- Russell From hgg9140 at cola.ca.boeing.com Mon Jun 25 13:03:54 2001 From: hgg9140 at cola.ca.boeing.com (Harry George) Date: Mon, 25 Jun 2001 17:03:54 GMT Subject: tools for visual basic --> python? Message-ID: We want to convert VB code to python. It is small enough we could do it by hand, but a few tools would help. Even a crude hack with line-oriented regular expressions would help. I'm about to write something myself, but I'd hate to reinvent the wheel. Searching google and groups-google didn't turn up anything. -- Harry George E-mail: harry.g.george at boeing.com The Boeing Company Renton: (425) 237-6915 P. O. Box 3707 02-CA Everett: (425) 266-3868 Seattle, WA 98124-2207 Page: (425) 631-8803 From m.bless at gmx.de Wed Jun 20 14:47:41 2001 From: m.bless at gmx.de (Martin Bless) Date: Wed, 20 Jun 2001 18:47:41 GMT Subject: calldll: given a longint (=pointer) - howdoi access the data? References: <3b30d4f2.21236779@news.muenster.de> <90C657DA0gmcmhypernetcom@199.171.54.155> Message-ID: <3b30ec78.26180817@news.muenster.de> [Gordon McMillan] >calldll.read_string(address, length) Thanks a lot! That's exactly what I've been looking for, and it works! Amazing! It's a pity there's so little documentation about the 'calldll' and 'npstruct' stuff. What I really mean is: I didn't find ANY doc at all - not counting the c-source itself which I do not understand (yet). Q: IF there's some documentation about 'calldll' and 'npstruct' - what's the hiding place? Martin From philh at comuno.freeserve.co.uk Tue Jun 19 12:57:00 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Tue, 19 Jun 2001 17:57:00 +0100 Subject: Which IDE ? References: Message-ID: On Mon, 18 Jun 2001 22:57:13 GMT, VanPopering wrote: >Which IDE would you recommend for someone *just starting out* with Python? > >-I'm not a professional programmer but Im interested in learning Python >-I want to use opensource whenever possible >-For now I'm just here for the basics; some scripting etc. What OS are you using? I'm using Linux and I just use my favourite text editor and the bash prompt. This is simple to use, because running the program is just a matter of putting the mouse over the bash window (making it active), then pressing up-arrow (bring up the last command, likely to be ``python myprogram.py''), and [return] runs it. >I'd LOVE to use idle since its part of it and free, but I have heard that it freezes upand >has other problems...is this really a problem that it happens a lot? Are there things I can >do to avoid this - does it happen with larger more complex programs only? If it froze while >running the script and that was the only potential problem, then I'd just save it first... I've never used IDLE or any other Python IDE so I couldn't say. My system is the simplest, and therefore likely to be the most bug-free way of doing it. > I am wondering if these were copmplaints by professional programmers who >needed and expected more... I think professional programmers often prefer simple tools (i.e. text editor and command line). -- ## Philip Hunt ## ## philh at comuno.freeserve.co.uk ## From robin at jessikat.fsnet.co.uk Fri Jun 1 11:51:10 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 1 Jun 2001 16:51:10 +0100 Subject: M2Crypto and 2.1 References: <9f8d0v$gq4$1@dahlia.singnet.com.sg> Message-ID: <1vjcsIAun7F7EwpQ@jessikat.demon.co.uk> In article <9f8d0v$gq4$1 at dahlia.singnet.com.sg>, Ng Pheng Siong writes .... great >> Anyone managed this yet? > >Yes, I have! ;-) > >Tested for Pythons 1.5.2, 2.0, 2.1, https and xmlrpc-over-https, blocking >and non-blocking servers. > >A new snapshot should be up over the weekend. > >Cheers. > -- Robin Becker From scarblac at pino.selwerd.nl Tue Jun 5 04:38:18 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 5 Jun 2001 08:38:18 GMT Subject: input() is a security problem? References: <9fh09b$bdp$1@news.service.uci.edu> Message-ID: Dan Stromberg wrote in comp.lang.python: > > In the following program: > > #!/dcs/packages/python-2.1/bin/python > > var=12345 > > n=input('enter a number, or a variable name like "var": ') > > print n > > > > If one enters "var" at the prompt, one sees 12345. > > This seems to be a problem for setuid python scripts that may have > access to data, stored in variables, that the user isn't supposed to > be able to see. > > Yes, I know, use sys.stdin.readline() instead. I do. But... is > there really a good reason for input to access variables this way? It > seems an unnecessary pitfall. That's what input() does - take input and eval() it. You could pass it Enter a number: __import__("os").system("rm -rf /") So use raw_input() in most cases. And don't make setuid scripts, there are other security problems with that (the file might change while the kernel is calling the interpreter from the #! line). input() is mostly a convenience for absolute newbies, to enter a number and use it as a number in Python. Raw_input() is better, os sys.stdin.readline() which is almost the same thing. -- Remco Gerlich From ullrich at math.okstate.edu Thu Jun 21 08:44:03 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Thu, 21 Jun 2001 12:44:03 GMT Subject: Properties in Python References: Message-ID: <3b31ebb9.553666@nntp.sprynet.com> On Wed, 20 Jun 2001 02:04:33 GMT, "Peter Caven" wrote: >I'm sure that many people reading this newsgroup are aware that the C# >(C-Sharp) language has a syntax for 'Properties' that allows a class >implementor to hide the implementation of an instance's attribute behind a >'get'/'set' interface. It's curious, the guy who wrote C# seems to be a fan of Object Pascal, aka Delphi... (maybe there's a simple explanation for that) David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From johnroth at ameritech.net Tue Jun 26 11:57:11 2001 From: johnroth at ameritech.net (John Roth) Date: Tue, 26 Jun 2001 08:57:11 -0700 Subject: python as plugin language References: <993529827.54981@newsmaster-04.atnet.at> Message-ID: "Lyle Johnson" wrote in message news:tjh5isq58hk8dc at corp.supernews.com... > > could someone please enlighten me! I want to embed python in my app > > as a scripting language... I have succeeded in extending python via swig. > > Not what I want, because main() has to come from my c-app. > > > > Then i can embed python in a c program with things #include "Python.h" > > and Py_Initialize(), etc. but that is still not what i want, because i > have no > > idea how I can call C-Funktions with this approach... clear what i mean? > > I fear not... > > > > From my app I want to load a plugin (a python script) and from this script > > I want to access functions of my app. > > > > Some pointers would be _very_ welcome!! > > If you've already learned how to develop C extension modules (using SWIG, or > "by hand") you've gotten past the biggest hurdle. And it sounds like you've > got the idea w. r. t. embedding Python in your application. I know of two > books that do a pretty good job of explaining the "big picture" for > embedding Python as an application-scripting language. One is "Programming > Python", by Mark Lutz; the other is "Internet Programming with Python", by > Aaron Watters, Guido van Rossum and James C. Ahlstrom. The latter may be out > of print, but if you run across it you'll probably be able to get it for > cheap. A good general approach, though, is: > > 1. Develop one or more C extension modules that expose some subset of your > application's functionality, > i.e. the stuff you'd like to be able to access from a Python script. > > 2. Embed the Python interpreter in your application, initialize it by > calling Py_Initialize(), etc. > > 3. At some selected point(s) during your application's execution, pass the > user's "plugin" script > to the embedded Python interpreter. Within that script, the user will > presumably import your > extension module(s) and make application-specific calls back into your > application. > > Hope this helps, > > Lyle As someone who may need this in a couple of months, I'd like to ask for a bit of clarification. There may be a real obvious answer, but how do you get the application and the separately compiled and linked extension module to talk to each other when you can't pass a communication parameter? Let's say I've got an application called "foo.exe" In that application, I've included and initialized the interpreter, and the user running it wants to execute a Python script named "spam.py". Presumably, the script has these two statements (among lots of others): import foo foo.bar() On a first scan, "Programming Python" doesn't deal with this issue at all. It deals with a lot of other stuff, but if it deals with this, I missed it. It looks like the PyImport_ExtendInittab(struct_inittab *newtab) function is what is needed. If I'm reading the Python/C API reference manual correctly, it will add the module to Python's list of built-in modules, where it will be availible for the Python script when it wants it. John Roth > > From missive at frontiernet.net Sat Jun 23 07:45:06 2001 From: missive at frontiernet.net (Lee Harr) Date: Sat, 23 Jun 2001 11:45:06 +0000 (UTC) Subject: adding instance methods after instantiation Message-ID: <9h1vg2$14cc$1@node21.cwnet.roc.gblx.net> This is what I am hoping to do: class c: def __init__(self): self.a1 = 1 def m1(self): self.a2 = 2 def m2(self): #note, outside of class c definition self.a3 = 3 c1 = c() c1.m2 = m2 c1.m2() a3 Is there some way to make m2 an instance method so that it will automatically get passed c1 as its first argument? Is this a reasonable thing to want to do? From aleaxit at yahoo.com Thu Jun 14 12:29:38 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 18:29:38 +0200 Subject: substitute for c/java's ?: References: <9ga8ue$7aj$07$1@news.t-online.com> <9gai91052m@enews1.newsguy.com> <9galsa$ssh$07$1@news.t-online.com> Message-ID: <9gaopq0fb2@enews1.newsguy.com> "Jochen Riekhof" wrote in message news:9galsa$ssh$07$1 at news.t-online.com... > >return ("a","an")[name[0].lower() in "aeiou"] > > Yeah, this is the method I found out for myself (see one of my above posts > in this thread). > Still has the drawback to evaluate both values of choice and much less > readable than ?: IMO. For this example case, "evaluating" both values is absolutely no drawback -- such "evaluation" being just about no-cost here. As for comparing this to a hypothetical return (name[0].lower() in "aeiou")?"an":"a" I personally think they're both so absurdly unreadable that trying to deem either "more readable" border on the ridiculous. On a scale of 0 (Perl) to 100 (idiomatic Python), I would call the former a 0.5 and the latter a 0.3 -- at least the former shows immediately between WHAT values the choice is going to happen, and only later the vastly-more-complex choice-condition. Alex From johnroth at ameritech.net Sun Jun 3 13:33:07 2001 From: johnroth at ameritech.net (John Roth) Date: Sun, 3 Jun 2001 10:33:07 -0700 Subject: Tabs and spaces (style) References: <9cn2a20j24@news1.newsguy.com> <3B1A41CA.CCE5197A@mail.verizon.net> Message-ID: "Lloyd Hugh Allen" wrote in message news:3B1A41CA.CCE5197A at mail.verizon.net... > Fredrik Lundh wrote: > > > > Alex Martelli wrote: > > > > What is the consensus about mixing tabs and spaces in a Python script? > > > > > > I don't think there is one. Guido's style guide recommends using both, > > > with a tabsize of 8, so I expect most Pythonistas follow that style. Yet, > > > for what it counts, I personally prefer setting my editors to always save > > > with spaces only > > > > note that the standard distribution uses spaces throughout. guess > > GvR hasn't gotten around to update the style guide... > > > > Cheers /F > > I thought that that was so that I could have a use for my old (paper) > Fortran program templates. Guido's style guide, from http://www.python.org/doc/essays/styleguide.html says, and I quote via cut and paste: Indentation Use the default of Emacs Python-mode: 4 spaces for one indentation level. For really old code that you don't want to mess up, you can continue to use 8-space tabs. Emacs Python-mode auto-detects the prevailing indentation level used in a file and sets its indentation parameters accordingly. Tabs or Spaces? Never mix tabs and spaces. The most popular way of indenting Python is with spaces only. The second-most popular way is with tabs only. Code indented with a mixture of tabs and spaces should be converted to using spaces exclusively. (In Emacs, select the whole buffer and hit ESC-x untabify.) When invoking the python command line interpreter with the -t option, it issues warnings about code that illegally mixes tabs and spaces. When using -tt these warnings become errors. These options are highly recommended! The common wisdom is that since you cannot trust tools to implement tabs consistently, they should be avoided. Otherwise, you wind up with real inconsistent indentation when you try to print, or otherwise process a program. John Roth From egroups at sevtech.com Tue Jun 19 00:14:20 2001 From: egroups at sevtech.com (Jim Severino) Date: 18 Jun 2001 21:14:20 -0700 Subject: What's the best way to implement a real-world SOAP server? Message-ID: <23422f46.0106182014.6218d2ef@posting.google.com> Hello everyone I see that Actzero's SOAP.py provides a SOAPServer class that implements a request handler which handles object and function registration as well as the network side of things through the imported BaseHTTPServer class. This works for development and testing, but what about real-world implementations, where a SOAP server may be expected to handle hundreds of requests per second? Doesn't the BaseHTTPServer only execute one request at a time? I would like to know what people think would be a suitable SOAP server (that works with Python modules, of course) for a "real-world" environment. The ideal server would implement simultaneous processing of multiple requests, database connection pooling.... all of the things that a good webserver setup implements. I was looking at mod_python + Apache, but I don't see how one can go about using SOAPServer with them, since SOAPServer provides its own HTTP server. I may be missing something obvious. Please tell me if I am. thanks jim From dougfort at downright.com Thu Jun 14 18:33:11 2001 From: dougfort at downright.com (Doug Fort) Date: 14 Jun 2001 23:33:11 +0100 Subject: Simple example of BaseHTTPServer use References: <3B2928F0.A467C8B6@raqia.com> Message-ID: <3b293b80_1@news5.uncensored-news.com> David Lees wrote: > I would like to use the BaseHTTPServer class to handle a PUT and send > back some http. I am sending the headers back correctly I think, but no > data appears to be going back. I am probably using the wfile instance > variable incorrectly. Here is sample code I am working on. > > def do_PUT(self): > self.send_response(200,'\n') > self.send_header("Content-type", "text/html") > self.wfile.write('junker goes\nout here\n') > self.end_headers() > > > > Thanks in advance. > > David Lees > I believe you need to call end_headers() before attempting to send any data. end_headers() writes a blank line which is followed by the data. I recommend Frederik Lundh's book "Python Standard Library" from O'Reilly, it has good clear examples and list lists at US$29.95 unlike the bloated $50 books that line the shelves. -- Doug Fort Senior Meat Manager Downright Software LLC http://www.downright.com ______________________________________________________________________ Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com With Seven Servers In California And Texas - The Worlds Uncensored News Source From olavb at yahoo.com Wed Jun 27 09:01:57 2001 From: olavb at yahoo.com (Olav) Date: 27 Jun 2001 06:01:57 -0700 Subject: Python embebbed with Oracle SQL*Plus Message-ID: Some time ago I did some Oracle SQL*Plus on UNIX, and I was able to write quite powerful scripts embebbed in ksh (Korn Shell). Is something similar possible with Python? Also I have seen that that there is a special Perl version for Oracle. Is there something similar for Python (and would it be necessary to make a special Python for this?). Generally, what is the best way to script Oracle with Python, and how does it compare to the two above? Thanks Olav From bh at intevation.de Mon Jun 25 04:57:25 2001 From: bh at intevation.de (Bernhard Herzog) Date: 25 Jun 2001 10:57:25 +0200 Subject: PEP 255: Simple Generators, Revised Posting References: Message-ID: <6qvgll2ayy.fsf@abnoba.intevation.de> Neil Schemenauer writes: > Bernhard Herzog wrote: > > It seems to me that as it stands, empty generators are a bit too > > difficult to write, so I think we need an easier way to write them. One > > way to write them would be > > > > def g(): > > yield > > > What is wrong with: > > def g(): > return [] If I have another function f that expects g to return an iterator this wouldn't work. > > If you really want an iterator object you can do: > > def g(): > return iter([]) Although this would, of course. > I don't know why anyone would care though. The only reason would be consistency, I guess, which in practice is not necessarily important. > > If generators weren't created with a def statement it would be a bit > > more obvious: > > > > generator g(): > > pass > > I don't think Guido will be convinced that we need a new keyword just > because it makes it easy to write silly code. I wouldn't say it's silly. Just as a normal function that does nothing is not silly either. With regard to the generator keyword, I actually think that using def for generators is correct, because even if the function contains yield, the object created by the def statement is a function object. An of course, a generator is pretty similar to a function. Bernhard -- Intevation GmbH http://intevation.de/ Sketch http://sketch.sourceforge.net/ MapIt! http://mapit.de/ From gherman at darwin.in-berlin.de Wed Jun 27 03:31:11 2001 From: gherman at darwin.in-berlin.de (Dinu Gherman) Date: Wed, 27 Jun 2001 09:31:11 +0200 Subject: PEP 260: simplify xrange() References: Message-ID: <3B398BBE.A2D455C9@darwin.in-berlin.de> Guido van Rossum wrote: > > Proposed Solution > > [...] > > By implementing a custom iterator type, we could speed up the > common use, but this is optional (the default sequence iterator > does just fine). This reduces xrange effectively to a more efficient iterator, and I wonder if keeping 'xrange' as its name is any good, apart for historical reasons? Sounds like people will ask: but why is it called 'x*range*', if I cannot even say this: for i in xrange(10) + xrange(20): print i Well, ok, you can't even now... (in range you can, though). Maybe keeping xrange as a built-in *name* for an iterator might seem ok, before getting rid off it entirely? Dinu PS: BTW, why not *add* something useful and make float increments work "as expected" in range/xrange...? From rnd at onego.ru Fri Jun 1 06:59:26 2001 From: rnd at onego.ru (Roman Suzi) Date: Fri, 1 Jun 2001 14:59:26 +0400 (MSD) Subject: continue loop without iteration... In-Reply-To: Message-ID: On 1 Jun 2001 kasper37 at caffeinedreams.com wrote: > basically, this is what I need to do: > > x=1 > y=x > > while x <= y: > if something: > x=x+1 > y=y+1 > continue > dosomething > x=x+1 x = y = 1 while x <= y: if something: y=y+1 else: dosomething x=x+1 is much clearer, IMHO. > therefore, if the if statement is always true, it should never end, > but as soon as it's false, dosomething will happen and it will stop. > > Dan Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From phawkins at spamnotconnact.com Sun Jun 24 22:26:40 2001 From: phawkins at spamnotconnact.com (phawkins at spamnotconnact.com) Date: 24 Jun 2001 22:26:40 -0400 Subject: Question about profiling References: Message-ID: >>>>> "TW" == Thomas Weholt writes: TW> When I profile my code I get a lot of TW> :1(?) TW> that takes up alot of time. What does that mean? Are you doing exec on a string somewhere? I see tracebacks with when I have a error in a string that I exec. -- Patricia J. Hawkins Hawkins Internet Applications, LLC From thomas at cintra.no Sun Jun 3 10:22:56 2001 From: thomas at cintra.no (Thomas Weholt) Date: Sun, 3 Jun 2001 16:22:56 +0200 Subject: CGI : getting selected values in a select-object Message-ID: <6LrS6.4732$vu4.493136@news3.oke.nextra.no> Hi, I got a form in a web-page that uses a select-multiple box. I need to pass several selected items to the server. I'm using mod_python and when I look at the posted data I only see the latest selected item. Where did the rest go? How can I get them? Thomas From aahz at panix.com Sat Jun 30 00:02:19 2001 From: aahz at panix.com (Aahz Maruch) Date: 29 Jun 2001 21:02:19 -0700 Subject: PEP scepticism References: <3d1yo2nca4.fsf@ute.cnri.reston.va.us> <9hj3bb$bdu$8@newshost.accu.uu.nl> Message-ID: <9hjj0b$c55$1@panix3.panix.com> In article <9hj3bb$bdu$8 at newshost.accu.uu.nl>, Martijn Faassen wrote: > >The somewhat mysterious way to get accepted to the dev mailing list >at all is a hurdle all by itself.. Perhaps this document could help >there too. It's not mysterious at all: Guido invites you (cadging an invite from Guido is an option, of course). But it doesn't take all that much to get an invitation; I'm on the list, and I still have not contributed any code to Python, and I've only submitted one formal PEP. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Nothing fails like prayer" --bumper snicker From d_krause at pixelpark.com Thu Jun 28 05:26:28 2001 From: d_krause at pixelpark.com (Dirk Krause) Date: 28 Jun 2001 02:26:28 -0700 Subject: How to grab HTML files behind authentification Message-ID: Hi, I've put together some code the python community might find useful. You can use this script to automatically spider web pages beyond the www-authenticate Dialog Box. Regards, Dirk ---snip--- import httplib, string, base64 # How to grab HTML files behind authentification # author: Dirk Krause, 06/28/2001 # change these entries below!! base = 'http://www.something.com' path = '/secret/index.html' u_name = 'myName' u_pwd = 'myPassword' # ok, here goes hlink = httplib.HTTP(base) hlink.putrequest('GET', path+' HTTP/1.0') hlink.putheader('Host', base) hlink.putheader('Accept', 'text/html') hlink.putheader('Accept', 'text/plain') temp = "%s:%s" % (u_name,u_pwd) temp = base64.encodestring(temp) temp = "Basic %s" % string.strip(temp) hlink.putheader("Authorization",temp) hlink.endheaders() errcode, errmsg, header = hlink.getreply() content = hlink.getfile().read() print content print errcode, header From aleaxit at yahoo.com Sun Jun 17 16:04:27 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 17 Jun 2001 22:04:27 +0200 Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> <9geiir$324$1@216.39.170.247> <9gi6rk01986@enews1.newsguy.com> Message-ID: <9gj2h502f0g@enews1.newsguy.com> "phil hunt" wrote in message news:slrn9iplq1.64s.philh at comuno.freeserve.co.uk... ... > >I think this is a slight overbid. It is perfectly possible in Python to > >"block rebinding" of an object's attribute (__setattr__ easily allows ... > It's just occurred to me that using this facility, you could > implements constants in python withoput having to change the > language, by having a CONST function: > > CONST("PI", 3.14159) > > this will put a new item in the current environment's dictionary, If user objects were allowed as a module's __dict__, and/or if built-in dictionaries allowed selective locking of entries, you could do that (if by "current environment" you mean the GLOBAL one -- a function cannot add entries to its caller' LOCAL namespace, in general... only a statement can do that). In Python 2.1 at least, you can do that in a dedicated "module" (let's call it 'const' for definiteness), actually implemented as an instance -- I showed similar ideas repeatedly in this thread. Things could be set up as to allow a more natural const.PI = 3.14159 to be completely equivalent to your hypothetical CONST function (if your CONST could bind and lock a variable in its caller's global namespace, so could const.__setitem__, of course). > >mapping object to be set as the __dict__ attribute of a module > >(where now a bona fide dictionary must be used instead), > > Ah -- does that mean my idea won't work? In Python 2.1 at least (and I doubt this will change in 2.2) it is not yet possible to use a user-object as a module's dictionary, nor do builtin dictionaries support selective locking. I suspect the former stricture WILL eventually fall (as part of the long slow march to overcome the type/class chasm), but I would not venture a guess/prediction about the latter. Alex From budr at sirinet.net Sun Jun 24 15:35:13 2001 From: budr at sirinet.net (Bud Rogers) Date: Sun, 24 Jun 2001 14:35:13 -0500 Subject: Python scripting [was: Re: emacs speedbar for python mode?] References: Message-ID: Roman Suzi wrote: > On Sun, 24 Jun 2001, Bud Rogers wrote: >>I have had similar thoughts. Imagine a programmer's editor of the >>calibre of [x]emacs that used python as a built in extension language >>in the same way that emacs uses lisp. > > Did you mean Cool Edit? Wow. It definitely has possibilites. I'll have to get better acquainted. Thanks. -- Bud Rogers http://www.sirinet.net/~budr All things in moderation. And not too much moderation either. From tundra at tundraware.com Sun Jun 24 19:10:01 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 24 Jun 2001 23:10:01 GMT Subject: Why sys.ps2 after interactive #-line? References: <3b34d6cc.89984150@wa.news.verio.net> Message-ID: <3B3672A4.70C785F7@tundraware.com> Michael Hudson wrote: > > bokr at accessone.com (Bengt Richter) writes: > > > >>> > > >>> # comment > > ... # why ... at beginning of this line? > > ... # and this, and the next? > > ... > > >>> > > > > Why not a fresh sys.ps1 prompt after each #-line ? > > Because That's The Way It Is. The heuristics the Python prompt uses > to decide whether a statement typed interactively is finished are a > bit hairy. They seem to work most of the time though. > > > Just curious :) > > Well, if you're *really* curious, you should probably read the > source... > > Cheers, > M. > > -- > 41. Some programming languages manage to absorb change, but > withstand progress. > -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html Incidentally, IDLE does NOT do this... -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From sill at optonline.net Tue Jun 12 17:41:59 2001 From: sill at optonline.net (Rainy) Date: Tue, 12 Jun 2001 21:41:59 GMT Subject: Python & vim References: <9g60a4$24t$1@news.mch.sbs.de> Message-ID: On 12 Jun 2001 21:07:16 GMT, Christian Schaller wrote: > Dear Pythoners, > > I've seen already some threads about configuring vim that it is > comfortable editing Python programs, so let's get one step further! Use > the following script to be able moving up and down the same indentation > level of the line the cursor is on (just press F10 for down and > Shift-F10 for up). > > Have fun! > > bye > Chris... > > """ > fu! Block(indent, dir) > let line = getline(".") > let blankCount = matchend(line, a:indent) > let nr = line(".") > let lastPos = nr > let maxLine = line("$") > while nr <= maxLine && nr > 0 > let nr = nr + a:dir > let curr = getline(nr) > if curr == "" > continue > endif > if matchend(curr, a:indent) == blankCount > break > elseif matchend(curr, a:indent) < blankCount > let nr = lastPos > break > endif > endw > exe nr > endfu > > map :call Block("^[ ]*", 1) > map :call Block("^[ ]*", -1) > """ Thanks for the post - but it's not working fully here. F10 works fine but S-F10 seems to capitalize current character and jump few characters to the right. I'm using 6.0z version. I tried changing it to F11 but it does some other odd things.. Ok, now I tried F10 for down, F11 for up and it works perfectly well. I guess this is something to do with 6.0 beta status. -- True sailing is dead - Jim From todd at designsouth.net Fri Jun 8 23:17:34 2001 From: todd at designsouth.net (Todd Smith) Date: Sat, 09 Jun 2001 03:17:34 GMT Subject: File Headers References: Message-ID: "Austin" wrote in message news:wjfU6.47832$V5.846183 at typhoon.columbus.rr.com... > Hello All, > > I would like to be able to have a user specify a document and have the > program return the files type. This cannot be determined via extension, > however it only needs to be able to distinguish between a MP3 or a Zip file. > If it's neither, then it should return something along those lines. > > Please e-mail me directly at newwave@@@acmemail.net (remove the extra @ > signs) as I have limited access to newsgroups. Thanks!!! > use the unix command "file" $file_info = system "file", "$file"; but of course there's lots of security problems when you rely on outside programs ... -todd From tim.one at home.com Wed Jun 6 15:09:42 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 6 Jun 2001 15:09:42 -0400 Subject: floating point in 2.0 In-Reply-To: <9fls21$h0f$1@panix2.panix.com> Message-ID: [Aahz] >>> Quite the contrary! The sooner people realize that floating point is >>> broken, the better off they are! [Kurt B. Kaiser] >> What we're talking about is the unformatted output representation. >> Until Python computes (with reasonable speed) in BCD or some such, >> I think most people would want good old "print". [Aahz] > What people want isn't necessarily what's good for them. > > more-channeling-of-uncle-timmy-ly y'rs If there were an easy way to let people who want str(float) behavior at the prompt get it, I wouldn't object. Heck, I'd use it myself most of the time. But there isn't, and *everything* printed by the prompt loop passes thru repr() first, and repr(float) must produce "overly precise" strings else eval(repr(x)) == x will fail. So "the problem" isn't that repr() changed: repr(float) behavior was simply wrong before. Part of the real problem is that the prompt loop does pass everything through repr(); this is a PITA for many reasons, incl. e.g. that a function returning a list with a million elements (of any type(s)) generates megabytes of interactive output. While somebody may want that on rare occasions, it's questionable default behavior. sys.displayhook was introduced so that everything printed by the prompt loop need not pass thru repr() first. That's a hammer for beating down this part of the problem. The other part is that sys.displayhook isn't enough on its own: for objects O of builtin container types (list, tuple, dict), str(O) ends up applying repr() to the objects O contains. So the str/repr distinction isn't consistently applied. For non-Americans, this is a PITA even for something as simple as a short list of strings: instead of seeing their native character set, where it goes beyond 7-bit ASCII they see a bunch of gibberish \xnn escapes instead. Alas, for reasons that have been covered many times before, this isn't easy to repair -- and even if it could be, *any* change would break code relying on the current behavior. So I only see one practical possibility: use the display hook, *and* write a non-trivial amount of supporting code to format builtin containers differently (for example, start with the existing pprint module, but suck the *current* one out of CVS as it's much faster than 2.1's when dealing with the builtin container types). This has been possible since the display hook was introduced. A challenge the community hasn't yet risen to is to write a really great display hook that's all things to all people . rigid-float-display-is-just-a-symptom-ly y'rs - tim From dgallion1 at yahoo.com Fri Jun 1 15:07:37 2001 From: dgallion1 at yahoo.com (Darrell) Date: 1 Jun 2001 12:07:37 -0700 Subject: Why isn't Python king of the hill? References: Message-ID: pdb: Don’t need to use it much. When I crossed over from C++ the lack of a beautiful graphical debugger worried me. That worry was a waste of time. Performance: Slower than Java? I don’t believe it. Of course it depends on how you frame the test. cPython has access to code that runs directly in ‘C’ more readily than Java. IMO Although pure Python statements likely run more slowly than Java. Notice how slow regular expressions are in Jython compared to cPython. I haven’t compared them lately though. PDF: http://www.reportlab.com Multiprecision math: http://sourceforge.net/projects/gmpy/ Finding developers: I’ve had great luck training Python developers. If they can read newsgroups, write some form of code and download examples. Then they are perfect Python candidates. Now they can focus on the high level view of what is this thing supposed to do? How can we test it? Not to mention they can get help because the code is readable. If it’s not then they have a problem. --Darrell Geoffrey Gerrietts wrote in message news:... > > Some of the features are either lacking or hidden to my limited > vision in Python, notably decimal math and PDF generation. > There's a certain draw to being able to take a single webapp and > deploy it on any of a dozen different app servers that know how > to handle the content, though it's small. But the biggest draw is > that someone who's proficient with Java is not too hard to find. > Someone who's proficient with Python is considerably harder to > lay hands on. > > Furthermore, while performance isn't a huge deal to those folks, > their app did show signs of growing to cover a lot more terrain. > It's conceivable that once the app was turned loose, it really > would need to worry about the kind of massive load that starts to > show off Python's seams. > From thomas.heller at ion-tof.com Tue Jun 12 03:43:05 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Tue, 12 Jun 2001 09:43:05 +0200 Subject: metaclasses -- aka Don Beaudry hook/hack (was RE: Why should i use python if i can use java) References: Message-ID: <9g4h3p$6s1m3$1@ID-59885.news.dfncis.de> wrote in message news:mailman.992305397.17770.python-list at python.org... > > Before I head too deeply into Zope dependencies, I would be interested in > knowing whether or not "type(MyClass) == types.ClassType" and > "isinstance(myInstance,MyClass)" work for classes derived from > ExtensionClass. (And if so, why do these work for C extension classes > using the Don Beaudry hook but not for Python classes using the same hook?) Actually there are two different hooks (lets call them the "Don Beaudry hook" and maybe "Guido's hook". Don Beaudry's hook calls the type of the base object if it is callable. Guido's hook calls the __class__ attribute of the base object if it is callable. See the source in Python/ceval.c for details. type(MyClass) == types.ClassType is false for ExtensionClass.Base derived classes, but isinstance() works (at least in Python 2.0, I'm not sure for 1.5.2). BTW: There are no further 'Zope dependencies' except for ExtensionClass itself. Thomas From hemmi at crc.co.jp Tue Jun 19 20:50:17 2001 From: hemmi at crc.co.jp (HEMMI Shigeru) Date: Wed, 20 Jun 2001 09:50:17 +0900 Subject: Extremely strange problem with httplib/urllib References: Message-ID: <3B2FF349.DE4BF886@crc.co.jp> Gustaf Liljegren wrote: > > Python 2.1 on Win98SE: > > I have got some experience with httplib and urllib by now, but suddenly > both are causing "invalid page fault" errors in Windows. Here's all I need > to do: > > import urllib > f = urllib.urlopen('http://www.google.com') > > And the nasty error looks like this: > > PYTHON caused an invalid page fault in > module KERNEL32.DLL at 017f:bff7b992. (snip) I am using Python 2.1 on Win98. I was able to use urllib from my computer. # This example is slightly modified that in http://www.gembook.org/python/ # which is written by Mr. Atuso Ishimoto. import urllib # def gethtml(url): try: f = urllib.urlopen(url) except: print 'Unable to connect ',url return None return f.readlines() def main(targeturl): html = gethtml(targeturl) for i in range (5): print html[i], if __name__=='__main__': main('http://www.python.org') And I get: C:\>python downloadURL.py regards, -- HEMMI Shigeru From nell at skrzynka.pl Thu Jun 14 16:30:59 2001 From: nell at skrzynka.pl (Justyna =?iso-8859-2?Q?Bia=B3a?=) Date: 14 Jun 2001 20:30:59 GMT Subject: entering password Message-ID: Hi. I want to ask, how can i create an entry field to input a password, what means for me that the text won't be seen directly, but it will be masked by asterisks e.g. Thanks in advance nell ps. I am using python 1.6.1 and Tkinter (and Pmw also is possible) From alan.gauld at bt.com Wed Jun 20 08:18:21 2001 From: alan.gauld at bt.com (Alan Gauld) Date: Wed, 20 Jun 2001 13:18:21 +0100 Subject: The Scoop on Python Input? References: Message-ID: <3B30948D.CFC26C37@bt.com> GulickDO at uReach.com wrote: > disappointed how poorly the concept of "input" was covered in the > books! So maybe someone here can send me in the right direction. The concept of "input" is that the program reads values from the externaln environment. Exactly how that is done depends a lot on what the external environment is. > Is there a Python input function that will get just one character > from the keyboard without waiting for enter to be pressed? There are several ways depending on the platform thers the msvcrt module for windows or the curses one for unix. > (like getch () in C++?) I don't think getch() is a standard C/C++ function. getc() is but reads a character atva time from a stream getchar() is just getc(stdin) and needs a return at the end. getch() tends to be provided by compiler vendors for specific platforms and takes advantage of platform specifics to do its job. For the same readon Python can't realistically provide a portable getch() equivalent - what would it do for a user using a teleprinter? Or even a 3270 terminal? Alan g From bernhard at intevation.de Fri Jun 29 04:52:21 2001 From: bernhard at intevation.de (Bernhard Reiter) Date: 29 Jun 2001 08:52:21 GMT Subject: PEP scepticism References: <9hfg1n$du33c$1@ID-89274.news.dfncis.de> <3B3BB077.1E51F2C9@ActiveState.com> Message-ID: <9hhfk5$e50ak$1@ID-89274.news.dfncis.de> In article , barry at digicool.com (Barry A. Warsaw) writes: >>>>>> "PP" == Paul Prescod writes: > > PP> It annoys me when people equate the PEP process with the > PP> adding of features. True. In general I like the PEP process. As Barry continues to explain its value as a documentation of the debate and the decisions is also high. My general warning has something do to with the process though, as a non-technical reason exist why people participating in the processes will have higher chances to vote for inclusing of features, because being exceptional python programmers. I want the people participating to aware of this situation so they can have it in the back of their mind and be more conservative about some feature request namely complicated syntactic sugar. > The other purpose for PEPs -- IMO more important and often overlooked > -- is to provide a concrete historical record for decisions made > I have a nagging feeling that `creeping featurism' is like pork-barrel > politics. In one breath people will decry the special interests that > they don't like or don't care about, while in the next, ask for their > own pet project to be funded. My motivation to raise the issue came after discussing my unprecise feeling about this with Bernhard Herzog. I track python language development for quite a bit of time and generally we all do a good job. However I can't help that I feel we should resist a bit more against feature additions which does not mean there should not be any. Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) FSF Europe (fsfeurope.org) From aleaxit at yahoo.com Fri Jun 1 05:12:17 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 1 Jun 2001 11:12:17 +0200 Subject: who coined the term "real numbers" (was Re: Against PEP 240) References: Message-ID: <9f7m9i020v2@enews1.newsguy.com> "Tim Peters" wrote in message news:mailman.991357681.5817.python-list at python.org... ... > > Those wacky reals. Makes you wonder how they got the name. > > Probably some Dutch guy; heck, they even name languages after snakes. Nope, a French one -- Rene Descartes. In "La Geometrie", 1637: """ tant les vrayes racines que les fausses ne sont pas tousiours r?elles; mais quelquefois seulement imaginaires """ (the spelling looks strange, but it's apparently the way they did spell French in the 17th century:-). "Complex" is due to Gauss, 1831, specifically at first for numbers of the form a+bi with a and b both integers -- "Tales numeros vocabimus numeros integros complexos, ita quidem, ut reales complexis non opponantur, sed tamquam species sub his contineri censeatur". Earlier, they were called "imaginary". An excellent site where you can get these fascinating tidbits, and many others, is "Earliest Known Uses of Some of the Words of Mathematics", http://members.aol.com/jeff570/mathword.html, whose maintainer, Jeff Miller, I've courtesy-copied. The sense of fascination for history, "word trivia", etc, is wonderfully well communicated by his several sites on such issues. Sharing such fascination and interests, I envy his students!-) Alex From tony at lsl.co.uk Fri Jun 15 10:49:32 2001 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Fri, 15 Jun 2001 15:49:32 +0100 Subject: Any other Python flaws? In-Reply-To: <9gcsro05ka@enews1.newsguy.com> Message-ID: <012c01c0f5aa$634c15b0$f05aa8c0@lslp7o.int.lsl.co.uk> Alex Martelli wrote: > Nah, that's what print>>blah is for:-). Ah, but (erm, you *are* in Italy[1], aren't you?) I quite like "print >>"... Tibs [1] i.e., a long way away and thus not within reach (of course, you *might* be in the PSU and then even distance wouldn't prevent me from bein -- Tony J Ibbs (Tibs) http://www.tibsnjoan.co.uk/ Well we're safe now....thank God we're in a bowling alley. - Big Bob (J.T. Walsh) in "Pleasantville" My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.) From gustafl at algonet.se Tue Jun 19 18:30:08 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 19 Jun 2001 22:30:08 GMT Subject: Extremely strange problem with httplib/urllib Message-ID: Python 2.1 on Win98SE: I have got some experience with httplib and urllib by now, but suddenly both are causing "invalid page fault" errors in Windows. Here's all I need to do: import urllib f = urllib.urlopen('http://www.google.com') And the nasty error looks like this: PYTHON caused an invalid page fault in module KERNEL32.DLL at 017f:bff7b992. Registers: EAX=00000000 CS=017f EIP=bff7b992 EFLGS=00010206 EBX=00f8f044 SS=0187 ESP=0096fbc8 EBP=007b157c ECX=00f8f028 DS=0187 ESI=00f8f044 FS=4f37 EDX=81943200 ES=0187 EDI=00000000 GS=516e Bytes at CS:EIP: 80 3e 04 74 0f 33 c0 50 50 50 68 05 00 00 c0 e8 Stack dump: 00f8f028 1000be7e 00f8f044 00000000 00f8f028 007f5d80 1000b96c 007b2850 007f5d80 76003481 0096fbf8 007b1570 007f5d80 7600265e 00000000 007b1570 Same thing happens with httplib, and it doesn't the web page. I have reinstalled Python, restarted the computer, and re-established connections, but I still have it! It seems like the code is always run to the last line, then this happens. Also, if I write the above script in Idle or on the command line, this error don't appear. It's no first time problem -- I have used these modules extensively before. Any ideas? Regards, Gustaf Liljegren From jp at ulgo.koti.com.pl Fri Jun 15 11:14:31 2001 From: jp at ulgo.koti.com.pl (Jacek =?iso-8859-2?Q?Pop=B3awski?=) Date: 15 Jun 2001 15:14:31 GMT Subject: destroying window in __init__ Message-ID: I use Tkinter, my __init_ looks like this: self.window=Toplevel(parent) (...) if (something_bad): self.window.destroy() it works, but I see error message, how to fix it? -- Same story, different eyes Here's where the hero never, never dies "Hollywood Black" - Ronnie James Dio From rcstadheim at scarabweb.com Thu Jun 7 12:52:04 2001 From: rcstadheim at scarabweb.com (RCS) Date: Thu, 7 Jun 2001 18:52:04 +0200 Subject: HTTPSHandler ??? (where is it) Message-ID: In the documentation of the ActiveState distribution for Python 2.1 there is listed as one of the objects of urllib2 the HTTPSHandler (for https requests). On the Python prompt (>>>), the list for dir(urllib2) gives me a reference to the HTTPHandler (among various other objects), but the HTTPSHandler there is not. Does anyone know something about this? Tia, Rolf C Stadheim From sill at optonline.net Tue Jun 19 06:11:22 2001 From: sill at optonline.net (Rainy) Date: Tue, 19 Jun 2001 10:11:22 GMT Subject: VI References: <9g9f1v$7oqr5$1@ID-11957.news.dfncis.de> <9gaul7$mth$2@brokaw.wa.com> <52e5ab5f.0106182325.4d1fe0d0@posting.google.com> Message-ID: On 19 Jun 2001 00:25:39 -0700, Michael Robin wrote: > I just downloaded vim - wow! (I'm going to catch up on vim in the > c.l.p archives and see what she can do python-wise. Don't suppose > there's a VI mode for Scite, PythonWin or Komodo??) > > It's like riding a bike! I'd forgotten how much sense a "modefull" > editor made, and how fast you can edit by keeping your hands where > they belong. > I always thought a pointing device was great to draw pretty pictures > with - how did it get thrust upon us to perform every possible > function? Certainly a keystroke or two is more preferable than > "navigating" to a toolbar hieroglyphic that needs to be looked up > anyway? (If not WIMPS, what would have prevailed??) That depends on how experienced the user is. I think the idea to have a toolbar with few most useful commands is great, and when you've got more mileage under your belt, you learn shortcuts.. OTOH, it may be that users get lazy and stick to buttons so it would be better not to give them the 'lazy' option... I guess we'd have to have some research on that to be sure. > > It must be late... > ZZ (works the same as :wq when you're tired...) > > mike > > > > Jonathan Gardner wrote in message news:<9gaul7$mth$2 at brokaw.wa.com>... >> Emile van Sebille wrote: >> > I always liked the description that vi has two modes: one beeps at you, >> > and the other destroys your file. ;-) >> >> When I was first learning vi, I found the beeps quite common. What was even >> more mystical is the way it would mangle your text with ease. A great way >> to learn how to use vi is to go to normal mode, and type a random letter. >> That's how I learned about and . Cool feature. >> >> > Actually, I use it daily. I'd just prefer something (oh, ok, _anything_) >> > else. >> >> I am addicted to vi. I can't imagine editing text any other way. If only I >> could get those little textboxes in web forms to use vi instead of basic >> textedit stuff... oh well. -- "Your password must be at least 18770 characters and cannot repeat any of your previous 30689 passwords. Please type a different password. Type a password that meets these requirements in both text boxes." (Error message from Microsoft Windows 2000 SP1) From rparker at lynx.dac.neu.edu Fri Jun 8 07:16:59 2001 From: rparker at lynx.dac.neu.edu (Rich Parker) Date: Fri, 08 Jun 2001 11:16:59 GMT Subject: Freezing problem with shared libraries in python2.0 under RedHatLinux 7.1 Message-ID: Hello all, I am new to python but I have a simple program hello.py include cPickle print "hello world" And if i try to freeze it under RedHat Linux 7.1, it will create the source files, which compile after running make, leaving the executable 'hello' however, when i run hello i get the following error Traceback (most recent call last): file "hello.py", line 1, in ? ImportError: /usr/local/lib/python2.0/lib/lib-dynload/cPickle.so: undefined symbol: PyExec_IOError ........................ (/usr/local/lib/python2.0/lib/lib-dynload/cPickle.so exists on the hard drive) This will be the same for other programs, just other files, for emple ImportError:/usr/local/lib/python2.0/lib/lib-dynload/arrayumodule.so and what not. I looked in the FAQ, and saw 3.34: I cant load shared libraries under Python 1.52, Solaris7, and gcc 2.95.2 answer configure should make the following variable in the Makefile created by freezing LINKFORSHARED=-Xlinker -export-dynamic but wasnt for version 1.52, but when i checked in my Makefile, that variable IS there. Can anyone help me? Thank you very much RichP From laurent.szyster at q-survey.be Fri Jun 29 15:19:33 2001 From: laurent.szyster at q-survey.be (Laurent Szyster) Date: Fri, 29 Jun 2001 21:19:33 +0200 Subject: threadpool References: Message-ID: <3B3CD4C5.8D5940CE@q-survey.be> Yirong Shen wrote: > > Can anyone suggest a good threadpool implementation for Python? The one in Medusa: http://www.nightmare.com/medusa/ Laurent Szyster From aleaxit at yahoo.com Fri Jun 1 15:47:25 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 1 Jun 2001 21:47:25 +0200 Subject: spaces and arguements.. References: <3UPR6.243439$Z2.2750797@nnrp1.uunet.ca> Message-ID: <9f93pa11ioh@enews1.newsguy.com> "John" wrote in message news:3UPR6.243439$Z2.2750797 at nnrp1.uunet.ca... > Hi, > > Am I mistaken or is there a way to invoke a method with arguements that > are separated by spaces instead of in brackets? Much like print x, y ? > So if I had a method foo(x) can I call foo x ? No. The ability (and sometimes necessity) to avoid parentheses in calls _used to be_ a hallmark of Visual Basic, not Python. *Used to* because, moving from VB6 to VB7 aka VB.NET, Microsoft has introduced many incompatible changes in Visual Basic, the main ones being: a. no more default properties on objects and set/let distinction in assignment b. all calls now require parentheses () c. and/or now short-circuit d. addition of += &c e. passing by value now default f. optional arguments must now have defaults g. added "return value" statement h. arrays now always start indexing from 0, no more fancy non-0-starting indices i. array-assignment gives assignment of *reference* to shared array-object -- you call an explicit method to copy the array if you want a copy instead j. no more automatic conversion between numbers and strings k. no more fixed-length string variables l. Default True is 1, not -1 any more m. generic type isn't Variant any more -- it's Object, which is now a *reference* to any kind of data n. try/catch & finally rather than 'onerror' Interestingly enough, each one of these decisions takes VB closer to Python in syntax and/or semantics...:-). Alex From dougfort at downright.com Wed Jun 6 16:45:31 2001 From: dougfort at downright.com (Doug Fort) Date: 6 Jun 2001 21:45:31 +0100 Subject: htmllib question References: <91928a98.0106060911.108cec61@posting.google.com> Message-ID: <3b1e966a_3@news5.uncensored-news.com> Content-Transfer-Encoding: 8Bit Rob Deker wrote: >Is there an easy way to > modify the HTML one is parsing while it's being parsed? For example, > if I wanted to change absolute links to relative links. > We modify links in our website load testing application. We use sgmllib to process the html, it's much more flexible than htmllib. I f you're interested in that sort of thing, I strongly recommend the new 'Python Standard Library' by Frederik Lundh from O'Reilly. It has a high signal to noise ratio with many examples, including sgmllib and htmllib. I've attached one of our parsers from http://www.stressmy.com, FWIW it may be too incoherrent to be of use to you. -- Doug Fort Senior Meat Manager Downright Software LLC http://www.downright.com -------------- next part -------------- A non-text attachment was scrubbed... Name: filteringparser.py Type: text/x-java Size: 38461 bytes Desc: not available URL: From grumble at usa.net Wed Jun 20 15:19:55 2001 From: grumble at usa.net (jcm) Date: 20 Jun 2001 19:19:55 GMT Subject: Pythoin MUD (PyMUD?) References: <9gqq3t$hvs$1@brokaw.wa.com> Message-ID: <9gqt0r$1q$1@news.mathworks.com> Jonathan Gardner wrote: > I was tinkering around and I got the base skeleton for a python MUD working > (you can LOOK and LOOK at something... cool.) > 1) Is there any existing python muds out there? > 2) Is there any mud hackers out there with advice or ideas? This thing is > as fresh as it gets, I want crazy and wacky ideas you've been mulling about > in your mind for the past 25 years, and I want this mud to be truly unique. > 3) Any newbies want to watch a mud being created? (OR - should I put this > on sourceforge? Or will you throw rotten eggs at me?) I've been working on one for a bit. Python's an ideal language to use--it's dynamicness allows easy updating of areas and such while the mud is running. I'd tell you to take a look at varium.com or at bluemud (bluesock.org), but there's not much to see yet. From missive at frontiernet.net Tue Jun 26 17:34:19 2001 From: missive at frontiernet.net (Lee Harr) Date: Tue, 26 Jun 2001 21:34:19 +0000 (UTC) Subject: [OT] Is there any tutorial for those who learn Java after Python ;-) References: Message-ID: <9hav4r$177s$2@node21.cwnet.roc.gblx.net> On Tue, 26 Jun 2001 21:23:20 +0400 (MSD), Roman Suzi wrote: > > I want to learn Java (Not that I am dissatisfied with Python, > but this seem to be "the must" to find a job ;-) > > * > > The question is, has anybody tried to write tutorial (even joking!) for > those who wants to learn Java _after_ Python? > Check out _Thinking_In_Java_ at www.BruceEckel.com From aleaxit at yahoo.com Sat Jun 9 16:40:21 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 9 Jun 2001 22:40:21 +0200 Subject: WHY is python slow? References: <992110734.956795@rexx.com> Message-ID: <9fu1j802orv@enews2.newsguy.com> "Dave Kuhlman" wrote in message news:992110734.956795 at rexx.com... ... > It takes a long time for reality and facts to dislodge generally > accepted beliefs, if for no other reason than that lots of people > have a vested interest in the preservation of those beliefs. There's more to it than that -- HOW does those beliefs become 'generally accepted', if counterfactual? I recommend Timur Kuran's masterpiece, "Private Truths, Public Lies: The Social Consequences of Preference Falsification". Cfr> http://www.hup.harvard.edu/catalog/KURPRI.html and Jon Elster's penetrating critique thereof in "Acta Sociologica", reprinted online at http://www.geocities.com/hmelberg/elster/ar96rkur.htm Alex From qrczak at knm.org.pl Sat Jun 23 10:21:03 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 23 Jun 2001 14:21:03 GMT Subject: algebraic datatypes References: Message-ID: Sat, 23 Jun 2001 10:32:46 GMT, Ronald Legere pisze: > Essentially, > datatype Tree = Node Tree Tree | Leaf Int > should translate into a class structure like this: from __future__ import nested_scopes import new, types def data(con, con_args): if isinstance(con_args, types.StringType): con_args = (con_args,) def __init__(self, *args, **kwargs): i = 0 for arg in con_args: if kwargs.has_key(arg): self.__dict__[arg] = kwargs[arg] del kwargs[arg] else: try: self.__dict__[arg] = args[i] except IndexError: raise 'Too few arguments of %s provided' % con i += 1 if i < len(args): raise 'Too many arguments of %s provided' % con if kwargs: raise 'Unknown keyword arguments of %s' % con globals()[con] = new.classobj(con, (), {'__init__': __init__}) # Perhaps it should be put in a different namespace? # Example of usage: data('Node', ('l', 'r')) data('Leaf', ('anint')) tree1 = Node(Leaf(1), Leaf(2)) tree2 = Node(l = Leaf(3), r = Leaf(4)) if isinstance(tree1, Node) and isinstance(tree1.r, Leaf): print tree1.r.anint # Types of fields, as well as the type of the tree itself, # are implicit in Python. # Exceptions should be better; I'm not familiar with existing # conventions. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From scarblac at pino.selwerd.nl Sun Jun 10 17:24:57 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 10 Jun 2001 21:24:57 GMT Subject: list-display semantics? References: <9g0dhl$if1$1@news.nsysu.edu.tw> Message-ID: jainweiwu wrote in comp.lang.python: > Hi all: > I tried the one-line command in a interaction mode: > [x for x in [1, 2, 3], y for y in [4, 5, 6]] ^ This is not the way to do what you want anyway, but it's the comma that gives the strange result; "[1, 2, 3], y" is a tuple of two elements. > and the result surprised me, that is: > [[1,2,3],[1,2,3],[1,2,3],9,9,9] > Who can explain the behavior? What you wrote there means: [x for x in ([1, 2, 3], y) for y in [4, 5, 6]] So first x is [1, 2, 3], and it prints that for y=4, 5, 6 (the value of y doesn't have any effect, so it just prints [1, 2, 3] three times). Then x becomes y; and I *think* y was 9 before you wrote the list comprehension, so it wrote that. That's the only explanation I can think of there. > Since I expected the result should be: > [[1,4],[1,5],[1,6],[2,4],...] You write that like this: [[x, y] for x in [1, 2, 3] for y in [4, 5, 6]] -- Remco Gerlich From fictitious at bogus.moc Fri Jun 15 22:01:13 2001 From: fictitious at bogus.moc (Mega Hurts) Date: Fri, 15 Jun 2001 19:01:13 -0700 Subject: Suggestions for a Strange Project? Message-ID: <3b2abb77_1@news3> One computer has never been enough for me. Even back in the olden days of Z80 S-100 machines (pre IBM PCs), I used TurboDOS with multiple SBCs, and a strange multiple MicroAngelo graphics setup of my own design. Some things never change. My current setup consists of four machines, running Win98. I use a single monitor and infrared keyboard/ mouse, and switch from one machine to another with a KVM switch. I connect to the internet on the first machine, which runs a proxy, and the other machines can run mail, FTP, news and web clients. I use a couple of the boxes for compute-intensive MPEG recording, and when they are busy, can switch to the others for office activities. Soon I will change the fourth box to Linux. To switch from box to box, I press CTL-CTL-1, or CTL-CTL-2, etc. The fun begins: [1] I use background colors and a labeled icon to remind me which context I'm in. Things get fun when I am working in a file, copy text or a graphic, switch to another machine- AND FORGET THAT I CAN'T PASTE. [2] Or I'm using my beloved and vital graphics pad and switch machines, only to be reminded that the cursor on one machine and one only is under Wacom control. [3] All the clocks lose and gain time at different rates. This becomes important when recording off-air scheduled events, and updating the clocks on four machines is just another chore. Well, Rochester... I'm thinking. All these boxes can talk to each other via that zippy 100Mb LAN. Now, why can't machine #1 share its web-updated clock info, and machine #2 share its graphics-tablet cursor info when needed, and all of them write to a common 'clipboard'? A lightweight task running on all machines should provide the connectivity and clock awareness, cursor and mouse-key-awareness. Any suggestions on where to start? Thanks From root at rainerdeyke.com Fri Jun 29 00:55:37 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 29 Jun 2001 04:55:37 GMT Subject: list of lists, object doesn't support item assignment? References: Message-ID: "Manfred Bartz" wrote in message news:m2vglfkitn.fsf at reddwarf.xix.net... > > >>> xy = (1,2),(2,2) > >>> print xy, xy[0] > ((1, 2), (2, 2)) (1, 2) > >>> xy[1]=(3,4) > TypeError: object doesn't support item assignment > > Is there a way to assign the list (3,4) That's not a list. > to an element of xy? No. > What am I missing? The difference between lists and tuples. Lists use are written '[1,2]' and are mutable. Tuples are written '(1,2)' or just '1,2' and are immutable. This work: xy = [[1, 2], [2, 3]] xy[1] = [3, 4] This also work: xy = [(1, 2), (2, 3)] xy[1] = (3, 4) -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From rob at jam.rr.com Sun Jun 24 09:06:15 2001 From: rob at jam.rr.com (Rob Andrews) Date: Sun, 24 Jun 2001 13:06:15 GMT Subject: How useful do you find the interactive interpreter? References: <4688f24b.0106231658.43d2c446@posting.google.com> Message-ID: slaytanic killer wrote in message news:4688f24b.0106231658.43d2c446 at posting.google.com... > Hi, > > I am looking at Python seriously, and I can see that the interpreter > would be really good for testing out ideas. Getting small things to > work and then switching over to a text editor to generalize what I've > learned. Is this how people generally use it? Or is it an even > deeper part of coding? > > Thanks. Even if I lost interest in programming all together, I'd keep using the the interactive interpreter for day-to-day tasks. It's extremely handy for figuring out complex math problems, demonstration of abstract ideas to easily-confused executives, and about anything else I throw at it. Remarkably free of bloat for such a handy tool around the office! Rob -- Useless Python: More fun than underwater frisbee! http://www.lowerstandard.com/python From rnd at onego.ru Sun Jun 10 22:56:26 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 11 Jun 2001 06:56:26 +0400 (MSD) Subject: Learning OOP... In-Reply-To: Message-ID: On Sun, 10 Jun 2001, Glyph Lefkowitz wrote: >> "Interface segregation principle", "dependency inversion principle", >> etc. Again, www.objectmentor.com has good papers on this:-). > >I hardly think that object orientation has a monopoly on this approach :). >The reason that I don't think that these are really OO principles is that >the most successful component architecture and reuse framework that I've >ever seen is UNIX, which says nothing about objects; only executables, >files, and streams. But Microsoft is (desktop) monopoly and their systems are OO. >The most revolutionary development in software engineering was the >subroutine, closely followed by the data structure. The notion of >"objects" has been a useful tool to think with, but much more of a small >incremental improvement than the revolution of the subroutine :) Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Monday, June 11, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Useless Invention: Fur sink." _/ From shredwheat at mediaone.net Sat Jun 2 13:28:12 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Sat, 02 Jun 2001 17:28:12 GMT Subject: Embedded 'C' problem? References: Message-ID: "Samuel Schulenburg" wrote > File "", line 1 > print """EB70:|30 E8 8A 17 00 00 66 89 04 9F 83 C4 08 43 3B 5C > 0.....f......C;\""" > > ^ > SyntaxError: invalid token > > The problem is final "\" in the origional string is interfering with > the final tripple quote forming a \""" which is interprited as an > escape sequence. for this problem, just use a double backslash at the end. you could also place an r at the front of the string, which will treat it as a raw string, giving backslash no special meaning. r"""5c 0......f.....C:\""" From rekla_ma_ at publicist.com Fri Jun 29 06:28:10 2001 From: rekla_ma_ at publicist.com (E-Mail Reklama) Date: Fri, 29 Jun 2001 14:28:10 +0400 Subject: =?windows-1251?Q?E-mail_-__=F0=E5=EA=EB=E0=EC=E0?= Message-ID: <543320016529102810488@publicist.com> ????????????! ? ?????? ??????? ??????? ?? ????? ?? ?????? ??????????? ??????? ???? ???????, ? ??????? ?? ????? ???????????. ??? ????? ???????? ??????????? ???????? ????? ????????? ?????????? ?? ????????? ??????? ??????? (?? 30???. ?? 1???., ??? ?? ??????, ??? ? ?? ???? ?????? ? ???). ??????????? ?????????/?????? ??? ???? ????? ????? ??????. ?? ??????????????? ?????????? ???????????? ?????????? 4 ????. ???? ?????????? ??????? - ?????????? ????????? ????????, ??????? ????? ??????, ??? ????????????? e-mail ???????? ??-?? ?????? ?????? ????????? ?????????? ???? ? ???????? ?? ??????????? ???????????! ???????, ?????????? ???????? ???? ???, ?????????? ? ??? ????? ? ?????. ?????? ?????? ??????? ?????? e-mail ???????, ?? ??????????? ????? ?? ?? ??????????? (???, ??????, ? ???? ????????) ?? ????? ? ?????????? ????????? ??? ???????????????, ??? ??? ?? ????? ????? ? ??????????? ????????? ??? ????????????? ???????????????? ????????. ? ?????? ??????, ??? ???????? ????????? ?????? ????????? ?????????? ?????, ??? ???? ????? ???? ????? ? ?????????? ???????? ?? ?????? ????????????. ?? ????? ??? ??? e-mail ??????? ? ????? ??? ??? ????, ????? ???????? ??? ???????? ?? ???? ?????? ??? ?????????. ??? ??????? ???? ??????????????????? ??????????? ? ???????????????? ?????? ??????? ? ???????? ? ?????????? ??????, ??????????? ???????? smtp-??????? ?? ???????, ? ????? ??????????? ???????????? ????????? ? ???-??? ? ???? ???????. ?? ????? ?????? ???????? ???, ??? ??? ????? ?? ???????? ?????? ??????. ???? ?? ??????????????? ? ????????? ? ?????? ???????? ?? ??? ????? ?????? ??????????, ???????? ?????? ? ???????????? ????? ? ???? ??????, ????? ? ????? ???????? ????????? "????????", ??? ?? ??????: reklama at publicist.com. ??? ???? ? ???? "???? ?????????" ??????????? ???????: "????????". From atsang at hk.linkage.net Tue Jun 12 01:54:06 2001 From: atsang at hk.linkage.net (Alan Tsang) Date: Tue, 12 Jun 2001 13:54:06 +0800 Subject: performance of python threads Message-ID: <9g4ap8$1mh$1@news.hk.linkage.net> Hi I am going to code for a small system that will invoke multiple threads and process data concurrently. Has any body done some sort of benchmark on the performance of python threads? Any reference or URLs would be much appreciated. thanks From barry at digicool.com Mon Jun 18 10:17:06 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Mon, 18 Jun 2001 10:17:06 -0400 Subject: Two minor syntactic proposals References: <9gkcsn0229c@enews2.newsguy.com> Message-ID: <15150.3426.808544.741800@anthem.wooz.org> >>>>> "AM" == Alex Martelli writes: AM> FWIW, I'd *LOVE* it if there was some relaxation of the AM> current constraint that binding-statements (except assignment, AM> and package-related import) can only affect 'bare' AM> (unqualified) identifiers. That's a good idea, and if I write up a PEP on the subject, I'll start with the expanded scope. Thanks, -Barry From glyph at twistedmatrix.com Sun Jun 24 16:25:38 2001 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: Sun, 24 Jun 2001 15:25:38 -0500 (CDT) Subject: PEP 255: Simple Generators In-Reply-To: <3B32FE58.ACBC2401@letterror.com> Message-ID: On Fri, 22 Jun 2001, Just van Rossum wrote: > The other good news is that if "all" we want is microthreads and > coroutines, and forget about multi-shot continuations, stackless would > become quite a bit simpler, as quite a bit of code and quite a bit of > the overall design of stackless came from Christian's desire for > multi-shot (reusable) continuations. This is *exactly* what I want :-). (Well, that and efficient task isolation.) ______ __ __ _____ _ _ | ____ | \_/ |_____] |_____| |_____| |_____ | | | | @ t w i s t e d m a t r i x . c o m http://twistedmatrix.com/users/glyph From careye at spamcop.net Wed Jun 6 04:59:30 2001 From: careye at spamcop.net (Carey Evans) Date: 06 Jun 2001 20:59:30 +1200 Subject: Running an AS/400 CL program via ODBC References: <285T6.2595$Jg4.368004@news1.telusplanet.net> Message-ID: <87elsyrnkd.fsf@psyche.dnsalias.org> "Aaron Fransen" writes: > The other problem is where the callproc procedure would really be handy, > which isn't implemented in the Win32 stuff from ActiveState. I actually need > to (a) call a program, (b) give it parameters, and be able to (c) read back > two of the parameters, which the AS/400 program would have modified. To do this via ODBC, I would use an SQL "DECLARE PROCEDURE" first to set the types of the parameters, and whether they're IN, OUT, or INOUT. I don't think I ever actually got OUT or INOUT working with our AS/400 and the standard odbc module, though. There's a couple of options using OLE/COM/ActiveX/whatever to call programs on the AS/400, using the free parts of Client Access Express. You can use the "standard" ADO/OLE DB support, or go direct to the Client Access ActiveX Automation APIs. I might be able to find some examples of this, but I can't test it at the moment, since I run Linux here at home. You could also install Java, Jython and JTOpen, and use JDBC. I haven't had any trouble with that approach. -- Carey Evans http://home.clear.net.nz/pages/c.evans/ "Quiet, you'll miss the humorous conclusion." From tundra at tundraware.com Tue Jun 26 14:40:01 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 26 Jun 2001 18:40:01 GMT Subject: Is this a true statement? References: <8NuZ6.362378$oc7.42924874@news2.rdc2.tx.home.com> <3B3788A2.3BD1D672@tundraware.com> <9qMZ6.368197$oc7.44797813@news2.rdc2.tx.home.com> <3B37A15D.DF05A331@tundraware.com> Message-ID: <3B38D606.DA5886BE@tundraware.com> Rainer Deyke wrote: > > > > Nope. *All* computation (including graphics generation) is reducable to a > > Turing Machine. > > Which part of the Turing machine can emmit light? None of them can - Including C++. You are begging a ridiculous point. To generate graphics there has to be the preceding computation and then the actual analog event. All T-C languages are equally able, in principle, to to the former. None can do the latter. ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From wilson at visi.com Thu Jun 7 23:04:04 2001 From: wilson at visi.com (Tim Wilson) Date: Thu, 7 Jun 2001 22:04:04 -0500 Subject: Any Python 10 info available? Message-ID: Hi everyone, Is there any word on dates and location for the upcoming Python 10 conference? -Tim -- Tim Wilson | Visit Sibley online: | Check out: Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/ W. St. Paul, MN | | http://slashdot.org/ wilson at visi.com | | http://linux.com/ From tjreedy at home.com Sat Jun 30 12:33:14 2001 From: tjreedy at home.com (Terry Reedy) Date: Sat, 30 Jun 2001 16:33:14 GMT Subject: Not enough Python library development [was PEP scepticism] References: <3dy9qalxii.fsf@ute.cnri.reston.va.us> Message-ID: >. One good example of > what our web team has put together is here: > > http://aspn.activestate.com/ASPN/Python/Mail > > I find these archives to be better than other Python archives available > on the Web. Consider this feature: > > http://aspn.activestate.com/ASPN/Mail/Leaders/python-dev/ Interesting if accurately done. The Python community is small enough that almost all names are unique. This list needs to combine numbers for people posting under multiple e-addresses (Guido has use 4). If this is done, Guido wins with 1829 (654+557+383+235) and Tim is second with 1531 (860+671) [no counting any eaddresses with <64 posts that are not on the list. From greg at cosc.canterbury.ac.nz Tue Jun 26 23:56:27 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 27 Jun 2001 15:56:27 +1200 Subject: PEP 255: Simple Generators References: <9h1tt9$16i$1@slb1.atl.mindspring.net> <3B37E7B4.AA2A1095@cosc.canterbury.ac.nz> Message-ID: <3B39596B.D7450A54@cosc.canterbury.ac.nz> Paul Prescod wrote: > > Others seem > to want to teach them alongside other flow control keywords. You might get away with teaching generators without mentioning iterator objects if you say that they can only be called in a special context, i.e. for x in g(): and that each time you hit a yield, the value gets bound to x and the for-loop body is executed, then execution resumes after the yield. You'll have to emphasise that they should never call a generator outside of such a context -- or at least if they do, they're not allowed to come running to the teacher for an explanation of wtf is going on! -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From SBrunning at trisystems.co.uk Tue Jun 12 09:29:31 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Tue, 12 Jun 2001 14:29:31 +0100 Subject: New to python Message-ID: <31575A892FF6D1118F5800600846864D78BD2B@intrepid> > From: Karim [SMTP:katiki at kodak.com] > I'm a new beginner to python. > In fact, I'll have to use itfor a next project. > But I don't know antything about python. > > Can someone write me in few lines why Python has been created ? > What for ? > For what kind of applications ? The home of Python is . All your questions will be answered here. If you haven't programmed before, check out Alan Gauld's 'Learning to Program' at . This teaches Python to complete beginners. If you have programmed before, try 'Dive into Python at . Links to *loads* of tutorials can be found at . And don't forget the Python tutor mailing list, at . Well worth joining if you are learning Python. Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From dsh8290 at rit.edu Thu Jun 28 15:55:26 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 28 Jun 2001 15:55:26 -0400 Subject: WinNT: Delete to recycle bin? In-Reply-To: <9hg04d$r9f$1@iocextnews.bls.com>; from jhoerr@resnet.gatech.edu on Thu, Jun 28, 2001 at 03:15:47PM -0400 References: <9hg04d$r9f$1@iocextnews.bls.com> Message-ID: <20010628155526.A19895@harmony.cs.rit.edu> On Thu, Jun 28, 2001 at 03:15:47PM -0400, John Hoerr wrote: | hi! | i'm relatively new to python and am wondering if there's a way to remove | files to the windows recycle bin instead of deleting them outright. First, I have never tried to do that, nor do I know how it is done. Now my incliniation is that in the Win32 API there is some sort of "delete" function that (maybe) provides the "Are you sure" dialog (I'm thinking of using explorer here) and does the necessary bookkeeping to remove it from the filesystem and add it to the recycle bin. I suggest looking through the win32all extensions and see if you find anything there. Also check other Windows devel sites and see if you can find what the underlying (C++?) API is. I don't think that os.system( "del foo" ) does what you want ;-). HTH, -D From tdelaney at avaya.com Thu Jun 14 01:22:09 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Thu, 14 Jun 2001 15:22:09 +1000 Subject: Python grammar.. Message-ID: > "Delaney, Timothy" wrote: > > > > a 1 ' OK > > a(1) ' memory leak > > The "memory leak" part of that sounds like a bug in the > implementation. It doesn't say anything about the merits > or otherwise of the syntax. Oh no question that IMO it's a bug in the implementation - but that doesn't appear to be Microsoft's opinion ... The (lack of) merits are that there are multiple ways to call something (fine - I don't like it, but I can live with it in a language), and that in two particular circumstances (zero and one parameter) the syntax allows you to call a function one way (with parentheses, no "call"), but if you have more than one parameter this is disallowed by the syntax. The fact that calling functions in this manner is documented as causing a memory leak as just sheer arrogance. I'm merely holding up VB as an example of what *not* to do with a language. I believe even MS has finally seen the error of this, and VB7 will not be at all backwards compatible ... Tim Delaney From aahz at panix.com Sat Jun 2 21:56:47 2001 From: aahz at panix.com (Aahz Maruch) Date: 2 Jun 2001 18:56:47 -0700 Subject: Against PEP 240 References: Message-ID: <9fc5gv$ak1$1@panix6.panix.com> In article , Tim Peters wrote: >[Roman Suzi] >> This said, what is the right way to deal with>currencies in Python >> right now? > >[Aahz] >> Tim Peters's FixedPoint.py: >> >> >nt.py> >> >> You *probably* want to set the precision to three or four places >> so that rounding errors don't propagate. > >Hmm. It's important to note that + and - on FixedPoints never suffer >rounding errors. Add up, say, a million dollars-and-cents FixedPoint >quantities each of precision 2, and the computed result is *exactly* >correct. The problems with using binary f.p. in "the naive" way for >financial calcuations only start with that most dollars-and-cents inputs >can't be represented exactly; subsequent additions are also subject to >rounding errors; FixedPoint suffers neither problem. Right. I was assuming because of the plural that Roman was likely to want to do currency conversions, which involves multiplication at the very least. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 I surf faster than you do, monkey boy. (My take on Netscape vs. Lynx) From dgoodger at bigfoot.com Wed Jun 13 00:37:54 2001 From: dgoodger at bigfoot.com (David Goodger) Date: Wed, 13 Jun 2001 00:37:54 -0400 Subject: PEP 256: Docstring Processing System Framework Message-ID: I am posting this PEP to comp.lang.python for greatest community exposure. Please direct replies to the Python Documentation SIG's mailing list: mailto:doc-sig at python.org. There's a wide ASCII diagram near the end, which will probably be folded beyond recognition. Please downloads from one of the following sources for a clean view. In addition to the master copy at http://python.sf.net/peps/pep-0256.txt (HTML at http://python.sf.net/peps/pep-0256.html), a working copy is kept at the project web site, http://docstring.sf.net/. -- David Goodger dgoodger at bigfoot.com Open-source projects: - Python Docstring Processing System: http://docstring.sf.net - reStructuredText: http://structuredtext.sf.net - The Go Tools Project: http://gotools.sf.net PEP: 256 Title: Docstring Processing System Framework Version: $Revision: 1.1 $ Last-Modified: $Date: 1935/06/06 05:55:51 $ Author: dgoodger at bigfoot.com (David Goodger) Discussions-To: doc-sig at python.org Status: Draft Type: Standards Track Requires: PEP 257 Docstring Conventions PEP 258 DPS Generic Implementation Details Created: 01-Jun-2001 Post-History: Abstract Python modules, classes and functions have a string attribute called __doc__. If the first expression inside the definition is a literal string, that string is assigned to the __doc__ attribute, called a documentation string or docstring. It is often used to summarize the interface of the module, class or function. There is no standard format (markup) for docstrings, nor are there standard tools for extracting docstrings and transforming them into useful structured formats (e.g., HTML, DocBook, TeX). Those tools that do exist are for the most part unmaintained and unused. The issues surrounding docstring processing have been contentious and difficult to resolve. This PEP proposes a Docstring Processing System (DPS) framework. It separates out the components (program and conceptual), enabling the resolution of individual issues either through consensus (one solution) or through divergence (many). It promotes standard interfaces which will allow a variety of plug-in components (e.g., input parsers and output formatters) to be used. This PEP presents the concepts of a DPS framework independently of implementation details. Rationale Python lends itself to inline documentation. With its built-in docstring syntax, a limited form of Literate Programming [2] is easy to do in Python. However, there are no satisfactory standard tools for extracting and processing Python docstrings. The lack of a standard toolset is a significant gap in Python's infrastructure; this PEP aims to fill the gap. There are standard inline documentation systems for some other languages. For example, Perl has POD (plain old documentation) and Java has Javadoc, but neither of these mesh with the Pythonic way. POD is very explicit, but takes after Perl in terms of readability. Javadoc is HTML-centric; except for '@field' tags, raw HTML is used for markup. There are also general tools such as Autoduck and Web (Tangle & Weave), useful for multiple languages. There have been many attempts to write autodocumentation systems for Python (not an exhaustive list): - Marc-Andre Lemburg's doc.py [3] - Daniel Larsson's pythondoc & gendoc [4] - Doug Hellmann's HappyDoc [5] - Laurence Tratt's Crystal [6] - Ka-Ping Yee's htmldoc & pydoc [7] (pydoc.py is now part of the Python standard library; see below) - Tony Ibbs' docutils [8] These systems, each with different goals, have had varying degrees of success. A problem with many of the above systems was over-ambition. They provided a self-contained set of components: a docstring extraction system, an input parser, an internal processing system and one or more output formatters. Inevitably, one or more components had serious shortcomings, preventing the system from being adopted as a standard tool. Throughout the existence of the Python Documentation Special Interest Group (Doc-SIG) [9], consensus on a single standard docstring format has never been reached. A lightweight, implicit markup has been sought, for the following reasons (among others): 1. Docstrings written within Python code are available from within the interactive interpreter, and can be 'print'ed. Thus the use of plaintext for easy readability. 2. Programmers want to add structure to their docstrings, without sacrificing raw docstring readability. Unadorned plaintext cannot be transformed ('up-translated') into useful structured formats. 3. Explicit markup (like XML or TeX) has been widely considered unreadable by the uninitiated. 4. Implicit markup is aesthetically compatible with the clean and minimalist Python syntax. Early on, variants of Setext (Structure Enhanced Text) [10], including Digital Creation's StructuredText [11], were proposed for Python docstring formatting. Hereafter we will collectively call these variants 'STexts'. Although used by some (including in most of the above-listed autodocumentation tools), these markup schemes have failed to become standard because: - STexts have been incomplete: lacking 'essential' constructs that people want to use in their docstrings, STexts are rendered less than ideal. Note that these 'essential' constructs are not universal; everyone has their own requirements. - STexts have been sometimes surprising: bits of text are marked up unexpectedly, leading to user frustration. - SText implementations have been buggy. - Some STexts have have had no formal specification except for the implementation itself. A buggy implementation meant a buggy spec, and vice-versa. - There has been no mechanism to get around the SText markup rules when a markup character is used in a non-markup context. Recognizing the deficiencies of STexts, some people have proposed using explicit markup of some kind. There have been proposals for using XML, HTML, TeX, POD, and Javadoc at one time or another. Proponents of STexts have vigorously opposed these proposals, and the debates have continued off and on for at least five years. It has become clear (to this author, at least) that the "all or nothing" approach cannot succeed, since no all-encompassing proposal could possibly be agreed upon by all interested parties. A modular component approach, where components may be multiply implemented, is the only chance at success. By separating out the issues, we can form consensus more easily (smaller fights ;-), and accept divergence more readily. Each of the components of a docstring processing system should be developed independently. A 'best of breed' system should be chosen and/or developed and eventually included in Python's standard library. Pydoc & Other Existing Systems Pydoc is part of the Python 2.1 standard library. It extracts and displays docstrings from within the Python interactive interpreter, from the shell command line, and from a GUI window into a web browser (HTML). In the case of GUI/HTML, except for some heuristic hyperlinking of identifier names, no formatting of the docstrings is done. They are presented within

tags to avoid unwanted line wrapping. Unfortunately, the result is not pretty. The functionality proposed in this PEP could be added to or used by pydoc when serving HTML pages. However, the proposed docstring processing system's functionality is much more than pydoc needs (in its current form). Either an independent tool will be developed (which pydoc may or may not use), or pydoc could be expanded to encompass this functionality and *become* the docstring processing system (or one such system). That decision is beyond the scope of this PEP. Similarly for other existing docstring processing systems, their authors may or may not choose compatibility with this framework. However, if this framework is accepted and adopted as the Python standard, compatibility will become an important consideration in these systems' future. Specification The docstring processing system framework consists of components, as follows:: 1. Docstring conventions. Documents issues such as: - What should be documented where. - First line is a one-line synopsis. PEP 257, "Docstring Conventions" [12], documents these issues. 2. Docstring processing system generic implementation details. Documents issues such as: - High-level spec: what a DPS does. - Command-line interface for executable script. - System Python API - Docstring extraction rules. - Input parser API. - Intermediate internal data structure: output from input parser, input to output formatter. - Output formatter API. - Output management. These issues are applicable to any docstring processing system implementation. PEP 258, "DPS Generic Implementation Details" [13], documents these issues. 3. Docstring processing system implementation. 4. Input markup specifications: docstring syntax. 5. Input parser implementations. 6. Output formats (HTML, XML, TeX, DocBook, info, etc.). 7. Output formatter implementations. Components 1, 2, and 3 will be the subject of individual companion PEPs, although they may be merged into this PEP once consensus is reached. If there is only one implementation, PEPs for components 2 & 3 can be combined. Multiple PEPs will be necessary for each of components 4, 5, 6, and 7. An alternative to the PEP mechanism may be used instead, since these are not directly related to the Python language. The following diagram shows an overview of the framework. Interfaces are indicated by double-borders. The ASCII diagram is very wide; please turn off line wrapping to view it: +========================+ | Command-Line Interface | +========================+ | Executable Script | +------------------------+ | | calls v +===========================================+ returns +---------+ | System Python API |==========>| output | +--------+ +===========================================+ | objects | _ writes | Python | reads | Docstring Processing System | +---------+ / \ ==============>| module |<===========| | \_/ +--------+ | input | transformation, | output | +--------+ | +-------------+ follows | docstring | integration, | object | writes | output | --+-- consults | docstring |<-----------| extraction | linking | management |===========>| files | | --------->| conventions | +============+=====+=====+=====+============+ +--------+ / \ +-------------+ | parser API | | formatter API | / \ +-------------+ +===========+======+ +======+===========+ +--------+ author consults | markup | implements | input | intermediate | output | implements | output | --------->| syntax spec |<-----------| parser | data structure | formatter |----------->| format | +-------------+ +-----------+-------------------+-----------+ +--------+ Project Web Site A SourceForge project has been set up for this work at http://docstring.sf.net. References and Footnotes [1] http://python.sf.net/peps/pep-0216.html [2] http://www.literateprogramming.com/ [3] http://www.lemburg.com/files/python/SoftwareDescriptions.html#doc.py [4] http://starship.python.net/crew/danilo/pythondoc/ [5] http://happydoc.sf.net/ [6] http://www.btinternet.com/~tratt/comp/python/crystal/index.html [7] http://www.lfw.org/python/ [8] http://homepage.ntlworld.com/tibsnjoan/docutils/ [9] http://www.python.org/sigs/doc-sig/ [10] http://www.bsdi.com/setext/ [11] http://dev.zope.org/Members/jim/StructuredTextWiki/FrontPage/ [12] http://python.sf.net/peps/pep-0257.html [13] http://python.sf.net/peps/pep-0258.html Copyright This document has been placed in the public domain. Acknowledgements This document borrows text from PEP 216 "Docstring Format" by Moshe Zadka [1]. It is intended as a reorganization of PEP 216 and its approach. This document also borrows ideas from the archives of the Python Doc-SIG. Thanks to all members past & present. Local Variables: mode: indented-text indent-tabs-mode: nil End: From dsh8290 at rit.edu Tue Jun 12 12:55:03 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 12 Jun 2001 12:55:03 -0400 Subject: New guy question In-Reply-To: <9g4ik305pa@enews2.newsguy.com>; from aleaxit@yahoo.com on Tue, Jun 12, 2001 at 10:07:31AM +0200 References: <3B255439.DFD33F59@home.net> <9g4ik305pa@enews2.newsguy.com> Message-ID: <20010612125503.C26086@harmony.cs.rit.edu> On Tue, Jun 12, 2001 at 10:07:31AM +0200, Alex Martelli wrote: | "Chris Barker" wrote in message | news:3B255439.DFD33F59 at home.net... | > Glen Mettler wrote: | > > I forgot to ask - what is the purpose of the Python window and the | Python | > > Shell window? | > > | > > Can I NOT run a series of scripts from these windows? Must I go to the | DOS | > > window to check my program? | > | > You've gotten your answer, but I'll add one more comment. I mostly use | > Linux, and run Python from a shell all the time. Windows does not give | > you a decent shell by default, so you will be a lot happier using an | > IDE, like IDLE or PythonWin (check out PythonWin, it's pretty nice). | | Some of us old crufties actually stick with consoles, but I | guess we're dinosaurs. You're surely right that the default | shell is sub-decent (on Win/95, /98, /ME; it's semi-decent on | /NT & /2000), but... Some dinosaurs aren't all that old ;-). I don't think the shell on NT/2000 is any better, except maybe the screen drawing is less buggy (helps for bash, vim, less, man, mutt, etc.). | > By the way, I havn't used windows much since 3.1, Does it really still | > have all that "add it to your PATH in autoexec.bat" stuff? Isn't there | > any kind of standard directories for executables, and some way to put a | > symbolic link in for your application? It makes for a Much cleaner | > system! (I suppose the above file association stuff is why they havn't | > bothered) | ... | | So, yeah, it IS a mess:-). I use bash as my shell (cygwin is ESSENTIAL on any windows system IMNSHO) and I have my own $HOME (not the one 'doze thinks it should stuff my Start Menu, etc) where I base everything from. My system is kinda messy, but that's becuase '\' and ';' are special characters that M$ had a sick urge one time to use for path separators. -D From gehrmab at ifh.de Sat Jun 9 09:02:17 2001 From: gehrmab at ifh.de (Bernd Gehrmann) Date: Sat, 9 Jun 2001 15:02:17 +0200 Subject: Python support in KDevelop Message-ID: Maybe this is interesting for some people here :-) http://dot.kde.org/992083107/ Bernd. From jimhill at meldrick.swcp.com Fri Jun 15 11:05:20 2001 From: jimhill at meldrick.swcp.com (Jim Hill) Date: 15 Jun 2001 15:05:20 GMT Subject: VI References: <9g9f1v$7oqr5$1@ID-11957.news.dfncis.de> <9gaul7$mth$2@brokaw.wa.com> Message-ID: In , Damian Menscher wrote: >Jonathan Gardner wrote: >> Emile van Sebille wrote: >>> I always liked the description that vi has two modes: one beeps at you, >>> and the other destroys your file. ;-) > >> When I was first learning vi, I found the beeps quite common. What was even >> more mystical is the way it would mangle your text with ease. > >Ahh, yes. Who hasn't accidentally bumped the caps lock key and >then attempted to scroll down? ;) I do believe I may have done that a time or two in my past...then I got an OS that lets me tell the machine "I don't care if the key has 'Caps Lock' printed on it, it's a Control -- the way God intended it to be." That one simple change has made me ever so much happier, especially since I often use The Other Editor as well as vim. >I've learned a fair bit from random banging and watching what >happened. One of these days I should actually read the docs and >learn all the features.... Steve Oualline just finished a book on vim (called "vim") which is now available from New Riders. Since I'm an O-C wretch I'm reading it sequentially but I find myself looking for excuses to use the new features just because they look cool. >--==## Grad. student & Sys. Admin. @ U. Illinois at Urbana-Champaign ##==-- Have lunch at Papa Del's and spare a moment for all the happy children of the past stranded in places like northern New Mexico. Jim -- jimhill at swcp.com http://www.swcp.com/~jimhill/ "Let me preface my remarks by saying that I have absolutely no love for Barry Manilow in my heart." -- Jason Lempka From wesc at deirdre.org Sun Jun 24 05:43:08 2001 From: wesc at deirdre.org (Wesley Chun) Date: Sun, 24 Jun 2001 02:43:08 -0700 (PDT) Subject: Simple example that won't work! Message-ID: > I posted this to the Python Tutor list, but wasn't really satisfied with > my result. I'll just repaste it here, and hope for better luck ;-) jay, sorry to hear about that. the Tutor list is usually very responsive! > Hello to all my fellow Python lovers. I'm only learning Python right now > (after a few years working with the comparatively terrible C/C++) and I am > absolutely loving it. To learn the language, I am using Wesley Chun's > "Core Python Programming". It's a very good book with some really good > examples, but it's with one of the examples that I'm having difficulty. thanks for the kudos. i'm glad to hear it's working out for you. > The example is a simple web-based example. All it does is retrieve an HTML > document, and print out the first and last non- blank lines of the page. > The error, though, occurs with the urlretrieve( ) call. When I call it, I > get the following exception message: > > Traceback (most recent call last): > File "C:\Program Files\Python20\Pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript > exec codeObject in __main__.__dict__ > : > File "c:\program files\python20\lib\httplib.py", line 330, in __init__ > self._set_hostport(host, port) > File "c:\program files\python20\lib\httplib.py", line 336, in _set_hostport > port = int(host[i+1:]) > ValueError: invalid literal for int(): like some of the others on the list, i have not been able to reproduce your problem. the URL listed in your example points at a dead server anyway, so if we try it on something live, we see something like this: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % python Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. IDLE 0.8 -- press F1 for help >>> from urllib import urlretrieve >>> url = 'http://www.yahoo.com:80/' >>> pair = urlretrieve(url) >>> pair ('C:\\WINDOWS\\TEMP\\~-259995-0', ) >>> f = open(pair[0]) >>> data = f.readlines() >>> f.close() >>> print data[-1] Advertising

Copyright © 2001 Yahoo! Inc. All rights reserved.
Privacy Policy >>> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - based on the error message, it looks like the problem occurs when it is trying to convert the port number, i.e., "3600" in your example into an integer. check out this example... >>> from urllib import splithost, splitport, splittype >>> >>> splithost(url) # removes path from URL (None, 'http://www.yahoo.com:80/') >>> splittype(url) # removes scheme from URL path ('http', '//www.yahoo.com:80/') >>> splithost(splittype(url)[1]) # pulls out host:port pair ('www.yahoo.com:80', '/') >>> splitport(splithost(splittype(url)[1])[0]) # splits host and port ('www.yahoo.com', '80') if you get a valid integer string, such as 80 in the above example, then the call to the built-in function int() should not fail: >>> int(splitport(splithost(splittype(url)[1])[0])[1]) 80 hope this helps! -wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python Programming", Prentice Hall PTR, December 2000 http://starship.python.net/crew/wesc/cpp/ wesley.j.chun :: wesc at baypiggies.org cyberweb.consulting :: silicon.valley, ca http://www.roadkill.com/~wesc/cyberweb/ From just at letterror.com Fri Jun 29 02:25:40 2001 From: just at letterror.com (Just van Rossum) Date: Fri, 29 Jun 2001 08:25:40 +0200 Subject: PEP 260: simplify xrange() References: <3B3AA1AE.AC965683@seebelow.org> Message-ID: <3B3C1F61.F904199B@letterror.com> Grant Griffin writes: > 2) How do the functions from xrange relate--semantically speaking--to > the functions of "xreadlines()"? It seems to me that the two should > have a similar "user interface" because they work about the same way, > and solve similar problems. Guido van Rossum wrote: > xreadlines() already follows the new xrange() philosophy. Even > better, xreadlines() allows you to loop over it only once, and you > have to use the natural indexing sequence. This makes it easier to > turn xreadlines() into a pure iterator -- this can't be done with > xrange(), because of the following common idiom: > > r = xrange(1000000) > for i in r: f1() > for i in r: f2() Erm, now that "for line in file" works (in 2.2 that is), doesn't that mean that xreadlines() is superfluous? Or: what does xreadlines() offer that "for line in file" doesn't? Just From valb at vtek.com Thu Jun 21 15:11:12 2001 From: valb at vtek.com (Val Bykoski) Date: Thu, 21 Jun 2001 15:11:12 -0400 Subject: a problem with codeplot.py Message-ID: <9gtgud$b3rbp$1@ID-62387.news.dfncis.de> i was trying to run codeplot.py, an interesting code fingerprinter, but didn't succeed.. Both command line and PythonWin IDE give the same result. The output (ActivePython 2.1, build 210, win2K Prof.), follows: D:\>python d:\_val\mydoc\val_doc\research\codeplot.py Module: d:\_val\mydoc\val_doc\research\codeplot.py - Generating PDF code plots from source files . Usage: python d:\_val\mydoc\val_doc\research\codeplot.py [ [ ...]] Testing now with d:\_val\mydoc\val_doc\research\codeplot.py... Traceback (most recent call last): File "d:\_val\mydoc\val_doc\research\codeplot.py", line 195, in ? readAndPlotFile(arg0) File "d:\_val\mydoc\val_doc\research\codeplot.py", line 179, in readAndPlotFile makePlot(lines, inPath, outPath) File "d:\_val\mydoc\val_doc\research\codeplot.py", line 126, in makePlot canvas.saveGraphicsState() AttributeError: PDFCanvas instance has no attribute 'saveGraphicsState' With PythonWin IDE, canvas instance shows weird list of methods (two times save, no single saveGraphicsState) Any help from experts? thanx, val From bos at hack.org Tue Jun 19 06:05:45 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Tue, 19 Jun 2001 12:05:45 +0200 Subject: Simple example that won't work! References: Message-ID: <3B2F23F9.365B6390@hack.org> Jay Parlar wrote: > My exact call was > retval = urlretrieve(url)[0], where url is any web address. Some more code would be appreciated, so we don't have to spend time to guess anything. -- Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From cmkleffner at gmx.de Tue Jun 12 04:45:38 2001 From: cmkleffner at gmx.de (cmkl) Date: 12 Jun 2001 01:45:38 -0700 Subject: statically linking the entire runtime (HPUX Python2.1) Message-ID: <3b091a1c.0106120045.5f49191e@posting.google.com> Hi ! On HP-UX I'm trying to build python2.1 without building the C-modules found in Modules/ as shared libraries. With the Version 2.0 this was the default. I played around with configure, setup.py and Modules/Setup but I always end up with a binary depending on various shared libraries. I need this, bacause I want to freeze my pythons scripts as a single binary. Distribution is much easier this way. What is the trick to do that? Carl From m.faassen at vet.uu.nl Mon Jun 4 13:59:42 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 4 Jun 2001 17:59:42 GMT Subject: I NEED to TEACH you something, QUICK! References: Message-ID: <9fgiae$av0$3@newshost.accu.uu.nl> Laura Creighton wrote: > This always happens. Trust me, been here many times. This is way > more cool that congratulating each other on how smug, er, kind you > are, but things are about to get nasty. What is wrong with this > picture:? [snip] > YOU PIG YOU PIG IT WAS AN IRISH WOLFHOUND!!!! > Now 12 people chime in with the complete Book of dogs detailing > exactly how to tell the difference between those two breeds, and > one person reports being scared by a wolf once. Now that I can make sense of your post (there must be some kind of attribution problem somewhere; I didn't see the thread you're responding to)... Note that this actually a good anti-flame technique by itself; divert the discussion from flame topics like war and massacres to something innocuous like discussing dogs. Happens frequently in comp.lang.python; I've seen outright trolls being defused and rerouted instantly into an interesting discussion on, say, old computer displays, or whatever. It nips flamewars in the butt. So while you can refactor your answer to the main point and tell the poster to go away, you can also refactor the thread into something useful, instead. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From cfelling at iae.nl Tue Jun 19 20:04:02 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 20 Jun 2001 02:04:02 +0200 Subject: graceful version detection? References: <3B2D2F44.50007@red-bean.com> <3B2F864A.9000306@collab.net> Message-ID: <9gop9i$h33$1@animus.fel.iae.nl> Ben Collins-Sussman wrote: > Paul Prescod wrote: >> try: >> import main >> except SyntaxError: >> print "This program requires Python 2.0" > Thanks, I'll try this solution. Now I just need to hunt down a 1.5 > interpreter... The downside of this approach is that it makes all syntax errors look like missing Python 2.0 features:( Why not something similar: ====wrapper module import sys try: # sys.version_info is a python 2.x goodie sys.version_info[0] except AttributeError: # you could extract and test from sys.version here like # if sys.version[0] == "1": print "This program requires Python 2.0" sys.exit(1) import realProgram -- groetjes, carel From cheong at msc.cornell.edu Mon Jun 25 13:08:21 2001 From: cheong at msc.cornell.edu (Siew-Ann Cheong) Date: 25 Jun 2001 17:08:21 GMT Subject: [Q] Rotated Text in Tkinter? Message-ID: <9h7r65$oqp$1@news01.cit.cornell.edu> Hi, I am trying to program a board game in python/tkinter. For that purpose it would be nice to be able to have a label in which the text is rotated by 90/180/270 deg. I have looked through the documentation for tkinter, but does not seem to find anyway to do this. Is this possible in tkinter? Or do I have to switch to another GUI module? Thanks in advance! Cheong Siew Ann From stuander at halcyon.com Sun Jun 10 01:03:25 2001 From: stuander at halcyon.com (Stuart L. Anderson) Date: Sat, 9 Jun 2001 22:03:25 -0700 Subject: floating point in 2.0 In-Reply-To: References: Message-ID: On Sat, 9 Jun 2001, Tim Peters wrote: > HW is key, because without near-universal HW support for a thing that thing > will never become widely accepted. HW vendors used to punt on denorms > because of the expense, but despite the expense everyone plays along with > denorms now, and not because of user demand but simply because it's > required. None of the SGI boxes I've seen support denorms. Also, the IBM mainframes and the Classic Crays don't use IEEE 754 in any form. And then, there are the Alpha boxes running in VAX mode. --Stu Anderson ______________________________________________________________________ Stu & Karen Anderson Renton, Washington, USA That's Washington State, not Washington DC stuander at halcyon.com http://www.halcyon.com/stuander/ From pedroni at inf.ethz.ch Wed Jun 13 16:25:37 2001 From: pedroni at inf.ethz.ch (Samuele Pedroni) Date: Wed, 13 Jun 2001 22:25:37 +0200 Subject: Inner classes References: Message-ID: <3B27CC41.994D767D@inf.ethz.ch> Bjorn Pettersen wrote: > > From: Samuele Pedroni [mailto:pedroni at inf.ethz.ch] > > > > Andrew Kuchling wrote: > > > > > xyzmats at laplaza.org (Mats Wichmann) writes: > > > > Nonetheless, I was challenged by someone to describe how > > it isn't a > > > > shorcoming in Python that classes don't work this way and didn't > > > > convince the guy so I'm looking for a more erudite comparison. > > > > > > Work *what* way? It's perfectly legal to do this: > > > > > > class C: > > > class inner: > > > ... stuff for inner class > > > ... stuff for class C > > > > > > --amk > > > > Yes, but that's basically a static inner class, you can do > > > > C().inner() but the created inner instance will not contain any > > implicitly created reference to the C instance. > > > > To have that you must be explicit: > > c=C() > > i=C.inner(c) > > Not true... > > from __future__ import nested_scopes > > class Outer: > def foo(self): > class inner: > def bar(this): > self.foo() > this.bar() > > bar can now reference both it's own class (inner) and the Outer class. > Not that this code is doing anything particularly useful though . > > -- bjorn You're right, let it turn it in a useful pattern : from __future__ import nested_scopes class Outer: def inner(self): class _inner: def bar(this): self.foo() this.bar() return _inner() now Outer().inner() will work (but being inner a factory and not a class will defeat introspection). regards. From llothar at mailandnews.de Fri Jun 8 11:13:07 2001 From: llothar at mailandnews.de (Lothar Scholz) Date: Fri, 08 Jun 2001 17:13:07 +0200 Subject: gc issues References: <655abd4a.0106080504.66a9d6a0@posting.google.com> Message-ID: On 8 Jun 2001 06:04:23 -0700, etoffi at bigfoot.com (e toffi) wrote: >hello > >lets say i wanted to integrate 2 languages with gc's (lua, >[small]eiffel, python, javascript). > >how do i keep the gc's from eating each other? > >i know this will require some *very* careful prgramming techniques. >can anyone point me in the right direction? Normally it shouldn't be a big problem as long as every language does only collect there own objects, so integrating Smalleiffel and Ruby/Python should be no problem. Of course this gives you a loss in performance if both collections must can the whole heap space twice. But Python has no GC, it has reference counting so this is not a problem at all. By the way : if you want to integrate python in a smalleiffel program please let me know, because i also want to do this. From Tom_Good1 at excite.com Tue Jun 19 19:08:15 2001 From: Tom_Good1 at excite.com (Tom Good) Date: 19 Jun 2001 16:08:15 -0700 Subject: How can I format the string according to its length at runtime? References: Message-ID: ed_tsang at yahoo.com wrote in message news:... > How can I format the string but according to the length it has? > > I have the following code: > > l = 6 - len(str(values)) > printwrite(trcfile, "Rx value = %-5s (0x%-6X)- OK\n"%(str(values), > values),tag ) > > Currently I displays: > > Check : TPreason = 120 (0x78) Rx value = > 120 (0x78 )- OK > > function printwrite is just a wrapper function of sys.file.write and > print that prints the info to the screen, or a trace window and to a > file accordingly. The string formmating is he same as the python doc. > > values in the above code is a integer number. > The above statement tries to diplay the input string [ from str > (values ] and convert values to be displayed as hexadecimal. > > My problem is when it displayed in hexadecimal, there are extra > spacing because it of the statement 0x%-6X when the lengeth of values > is 3. But I will no know in advance what is the length of values, it > can reach 6. How can I dynmically alter the number of spaces in this > case? > Try something like this: lengthOfHexString = len("%x" % values) padding = " " * (6 - lengthOfHexString) print "Rx value = %-5s (0x%X)%s- OK\n" %(str(values), values, padding) From matthewm at zebrasoft.co.nz Wed Jun 27 23:18:07 2001 From: matthewm at zebrasoft.co.nz (Matthew Miller) Date: Thu, 28 Jun 2001 15:18:07 +1200 Subject: win32com question Message-ID: <3B3AA1EF.DCC35D04@zebrasoft.co.nz> hi, i'm trying to figure out how to use the win32com interface. i haven't yet figured out how to 'phrase' optional arguments within a python expression. given something in vba like:- Workbooks.Open "spam.xls", ReadOnly:=true, Password:="password" how do you phrase this in python/win32. i got this far xlapp=win32com.client.Dispatch("Excel.Application") xlapp.Workbooks.Open("spam.xls") but can't figure out how to pass in the named args for the required functions . any help would be great. Thanks... -- Matthew Miller Zebra Software Ltd. E-mail: matthewm at zebrasoft.co.nz Ph: 03-3848990 FAX: 03-3842397 Mobile: 025-2920625 From d_krause at pixelpark.com Fri Jun 29 11:21:15 2001 From: d_krause at pixelpark.com (Dirk Krause) Date: 29 Jun 2001 08:21:15 -0700 Subject: Python for Commercial Games? References: <9haoiv$jnv$1@mtc1.mtcnet.net> <52e5ab5f.0106270823.599f61ae@posting.google.com> Message-ID: Hi, my advice #1 always is to focus on the idea first, and start the development then. The programming language used should follow the requirements of the idea. In most cases the requirements mean fast graphics so you're in with C/C++. But usually you will look for libraries first (or complete engines). But that doesn't mean you have to start with a certain programming language. Indeed I can imagine that it can be worthwhile to start with Pygame to prototype and then switch to SDL because you used this library anyhow under the hood, and got familiar with it via Python. Maybe it is even possible to write a pygame2sdl converter (could this be? Pete?) Dirk PS: Btw, the script language of choice for some professionals seems to be LUA (http://www.lua.org), because it's small and fast. From cfelling at iae.nl Tue Jun 19 20:29:35 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 20 Jun 2001 02:29:35 +0200 Subject: How can I format the string according to its length at runtime? References: Message-ID: <9goqpf$het$1@animus.fel.iae.nl> ed_tsang at yahoo.com wrote: > How can I format the string but according to the length it has? ... > l = 6 - len(str(values)) > printwrite(trcfile, "Rx value = %-5s (0x%-6X)- OK\n"%(str(values), > values),tag ) ... > My problem is when it displayed in hexadecimal, there are extra > spacing because it of the statement 0x%-6X when the lengeth of values > is 3. But I will no know in advance what is the length of values, it > can reach 6. How can I dynmically alter the number of spaces in this > case? I'm not sure I understand your problem, wouldn't simply leaving out the field widths work? like: >>> value = 30 >>> "Rx value = %d (0x%X)- OK\n" % (value, value) 'Rx value = 30 (0x1E)- OK\n' -- groetjes, carel From mwh at python.net Thu Jun 28 09:09:13 2001 From: mwh at python.net (Michael Hudson) Date: 28 Jun 2001 14:09:13 +0100 Subject: PEP 260: simplify xrange() References: <3B39480C.F4808C1F@Lugoj.Com> <9hc97q$rpt$1@slb6.atl.mindspring.net> <3B3A9C39.64C3E1C6@seebelow.org> <9hef08$urt$1@slb3.atl.mindspring.net> <9hf5ru$5el$1@animus.fel.iae.nl> <6qg0ckydud.fsf@abnoba.intevation.de> Message-ID: Bernhard Herzog writes: > Michael Hudson writes: > > > Carel Fellinger writes: > > > > > Michael Hudson wrote: > > > ... > > > > Google confuses me; if you search for "michael hudson" my page is the > > > > third hit - but my name doesn't actually appear anywhere on the linked > > > > page! > > What was your exact query (I guess you omitted the quotes)? If I query > for "michael hudson" (including the quotes!) your CV is the first entry > in the result list. Yes, without the quotes. With the quotes I see my CV first too (which needed updating - a fairly unlikely way of getting reminded...). I wonder what I did for google to think I'm the most significant Michael Hudson on the web... > > > probably it's in a hidden field, like > > > > Nope. These are my web pages we're talking about here! My name > > appears on various bits of my pages (my CV, the python-dev summaries), > > but definitely not on the page google points you to. > > Google also looks at text of the links pointing to a website. E.g. if > there's a link Michael > Hudson on a website, google takes that as a hint that the page > pointed to is about "Michael Hudson". Yes, I presume this is what's going on. Google's "link:" searches don't show too many of these, so I still rate it a pretty impressive deduction. And what's more google use Python, so this post is clearly on topic! Cheers, M. -- I hate leaving Windows95 boxes publically accessible, so shifting even to NT is a blessing in some ways. At least I can reboot them remotely in a sane manner, rather than having to send them malformed packets. -- http://bofhcam.org/journal/journal.html, 20/06/2000 From rnd at onego.ru Wed Jun 6 16:13:27 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 7 Jun 2001 00:13:27 +0400 (MSD) Subject: Has anyone used UML? In-Reply-To: <9flodi$32m$1@brokaw.wa.com> Message-ID: Disclaimer: I have not used UML I think, UML to OOP is no more/no less useful than block diagrams structural programming uses to visualise algorithms. Block diagrams were more standardized though... Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Wednesday, June 06, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Why is the cat sitting on my head?" _/ From loewis at informatik.hu-berlin.de Tue Jun 5 04:43:57 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 05 Jun 2001 10:43:57 +0200 Subject: Wadda ya mean it's not defined? Impossible Error? References: <3B1C2727.D9E746CB@dsl.ca> Message-ID: David Gilbert writes: > I'm getting what appears to be an impossible error. That sounds like a bug to me. What Python version? If possible, please submit a complete test case to sf.net/projects/python. > snippet: > > def parseLogs(paths, custs): > > ipfRecord = re.compile("^([0-9]+)[ ]+([0-9]+)[ > ]+([0-9a-z]+)([+-])") > > last = {} > for i in range(len(paths)): # Create start times > ... and so on. > > Here's the error snippet: > > File "../devel/ditty/bandsaw2.py", line 37, in parseLogs > for i in range(len(paths)): # Create start times > UnboundLocalError: local variable 'paths' referenced before assignment > > Just when should "paths" be assigned? There is, of course, a possible completion of this program that would produce such an error. What if the rest of the module read: def parseLogs(foo, bar): return paths # line 37 I.e. are you sure you are executing the Python code you are looking at? Regards, Martin From DavidLNoSpam at raqia.com Thu Jun 14 17:13:20 2001 From: DavidLNoSpam at raqia.com (David Lees) Date: Thu, 14 Jun 2001 17:13:20 -0400 Subject: Simple example of BaseHTTPServer use Message-ID: <3B2928F0.A467C8B6@raqia.com> I would like to use the BaseHTTPServer class to handle a PUT and send back some http. I am sending the headers back correctly I think, but no data appears to be going back. I am probably using the wfile instance variable incorrectly. Here is sample code I am working on. def do_PUT(self): self.send_response(200,'\n') self.send_header("Content-type", "text/html") self.wfile.write('junker goes\nout here\n') self.end_headers() Thanks in advance. David Lees From zeitlin at seth.lpthe.jussieu.fr Wed Jun 13 15:20:17 2001 From: zeitlin at seth.lpthe.jussieu.fr (Vadim Zeitlin) Date: 13 Jun 2001 19:20:17 GMT Subject: wxCombobox question References: <3B26AFAE.B9BFEE71@quasar.ipa.nw.ru> Message-ID: [f2 comp.soft-sys.wxwindows as this doesn't have much to do with Python] On Tue, 12 Jun 2001 17:11:26 -0700, Alexander V. Voinov wrote: >Is it possible in wxPython/wxWindows to tell if the drop-down list >really _dropped_ down (i.e. visible to the user) or not? No, I don't think so. You're right, we should really process CBN_DROPDOWN and generate the appropriate event for it - it may be quite useful. The trouble is that I don't know how to do it with GTK+ and looking at the code it doesn't seem to generate any signals when it pops down the list. OTOH, GTK+ combobox is so brain dead that it will probably be replaced with a generic (i.e. written in wxWin itself) version which is already written and is waiting to be merged into the main wxWin branch and for which it will be trivial to generate such event. But, of course, this won't happen before 2.3.2... Regards, VZ -- GCS/GM d? H+ s++:-- p2 au--- a- w+ v C+++ UBLS+++ P- L++ N++ E--- W++++ M? V-- -po+ R++ G`` !tv b+++ D--- e++++ u++ h--- f+ r++ n- y? From frank at chagford.com Sun Jun 3 02:36:32 2001 From: frank at chagford.com (Frank Millman) Date: Sun, 3 Jun 2001 08:36:32 +0200 Subject: Has anyone used UML? Message-ID: <991550033.146@nntp01.uskonet.com> After 15 years of designing applications using the good old "seat of the pants" method, I have decided that, if I am to move forward, I need a more formal methodology. I have recently read about UML (Unified Modelling Language), a standards-based method of designing and documenting any software project. It looks interesting, but it seems to have a steep learning curve. Does anyone have any knowledge or experience of UML that they would like to share? TIA Frank Millman From dsh8290 at rit.edu Wed Jun 6 16:13:27 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 6 Jun 2001 16:13:27 -0400 Subject: Why should i use python if i can use java In-Reply-To: <9flu5i$c61$1@news.tudelft.nl>; from karmen2001@hotmail.com on Wed, Jun 06, 2001 at 08:52:34PM +0200 References: <9flu5i$c61$1@news.tudelft.nl> Message-ID: <20010606161327.J14632@harmony.cs.rit.edu> On Wed, Jun 06, 2001 at 08:52:34PM +0200, mik wrote: | i' m a python newbie but I've this prob. i have seen Jython .. | | what has python dat java does not????????? Modules. Function objects. _Completely_ OO (int, boolean, modules, classes, and functions are all objects, not just class instances). Easier syntax. High level of design in the language and runtime libraries. No casting when using containers. Edit-run as opposed to edit-compile-run cycle. In short, Python has a _lot_ that Java doesn't have. Jython is an implementation of Python written in Java so that it runs in a JVM and provides nice integration between Python and Java similar to what CPython does for C and Python. -D From NOSPAM_vtm at NOSPAM_libero.it Thu Jun 28 04:37:13 2001 From: NOSPAM_vtm at NOSPAM_libero.it (Lello Mele) Date: Thu, 28 Jun 2001 08:37:13 GMT Subject: [ANN] the first Italian newsgroup on python language Message-ID: With great pleasure and after a difficulty pregnancy, i am pleased to announce the creation of free.it.python, the first Italian newsgroup on python language. We beg all the italian experts to support the newgroup . Thanks. -- ---------- Lello Mele HOMEPAGE: http://www.lellomele.it eMAIL: vtm at libero.it mele at programmazione.it From johngrayson at home.com Fri Jun 1 05:48:50 2001 From: johngrayson at home.com (johngrayson at home.com) Date: Fri, 01 Jun 2001 09:48:50 -0000 Subject: Fwd: Tkinter: image handling: bug or feature? Message-ID: <9f7oe2+hft1@eGroups.com> --- In python-list at y..., Jose' Sebrosa wrote: >> Hi, >> >> I just figured out that this code >> >> I like to use local names to everything I can (so the names are not >>available when mainloop is called) >> >> Or I'm simplly messing it all... Yes, you're messing it up... :-) If you insist on using local variables, then python is happily decrementing their reference count as your 'constructor' goes out of scope and they get garbage collected... The convention is to make images instance variables. If you are paranoid about seeing the variables, mangle their names: self.__secret_image = .... John From gardner at cardomain.com Sat Jun 16 19:02:36 2001 From: gardner at cardomain.com (Jonathan Gardner) Date: Sat, 16 Jun 2001 16:02:36 -0700 Subject: qt or gtk? References: Message-ID: <9ggof8$gmd$1@brokaw.wa.com> Courageous wrote: > Do recall that Qt is only *half* free. It is free for Linux development, > but costs an arm and a leg on Windows. Now I feel stupid. I thought Qt was free to use if your software is free, but costs money if you plan to sell it. There are two versions - commercial and free software, and you have to buy a license if you want to use the commercial version. I assumed the difference between the two is only in name and license, and the source is the same, however. From kamikaze at kuoi.asui.uidaho.edu Fri Jun 8 21:46:47 2001 From: kamikaze at kuoi.asui.uidaho.edu (Mark 'Kamikaze' Hughes) Date: 9 Jun 2001 01:46:47 GMT Subject: WHY is python slow? References: Message-ID: Fri, 8 Jun 2001 22:42:02 +0100 in , John J. Lee spake: > *Are* there any good (as opposed to 'good enough') operating systems in > existence? > Completely off-topic, I know: just ignore me... No. It's been proven that all operating systems suck, all languages suck, all software sucks, and all hardware sucks. There are degrees of suckiness for any particular purpose, but none are sans suckage. Once people learn to accept this and abandon their unrealistic beliefs in *good* software or hardware, they become much more content. -- Mark Hughes "I will tell you things that will make you laugh and uncomfortable and really fucking angry and that no one else is telling you. What I won't do is bullshit you. I'm here for the same thing you are. The Truth." -Transmetropolitan #39 From charles at aspen.sweetshade.net Sat Jun 16 14:45:57 2001 From: charles at aspen.sweetshade.net (Charles Allen) Date: 16 Jun 2001 18:45:57 GMT Subject: os.statvfs on FreeBSD References: Message-ID: >> For some reason the default installation of python-1.5 and Python-2.0 >> on FreeBSD(From the ports collection) does not include the >> os.statvfs() routine. Does anyone know A. Why? and B. How to fix it? I > access to a FreeBSD system. E.g. post some code snippet, and show what > error it produces. aspen$ python Python 2.1 (#1, May 7 2001, 21:01:18) [GCC 2.95.3 [FreeBSD] 20010315 (release)] on freebsd4 Type "copyright", "credits" or "license" for more information. >>> import os >>> os.statvfs("/") Traceback (most recent call last): File "", line 1, in ? AttributeError: 'os' module has no attribute 'statvfs' >>> -- Charles Allen From nhodgson at bigpond.net.au Mon Jun 18 19:56:21 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Mon, 18 Jun 2001 23:56:21 GMT Subject: PythonCard - was Re: Event-driven GUIs ... References: <3B2D3A65.B052808E@earthlink.net> Message-ID: Ron Stephens: > Perhaps if someone could do a PythonCard for event driven gui programs, > using the Python syntax and the Hypercard container model, it would be a > big hit > ;-)))) The feature I loved in HyperCard was that persistence was built-in. Actually it was better than built-in - it permeated the whole paradigm. It was a great environment for people who didn't see themselves as developers as it could be used on several different levels with scripting not being needed for many tasks. Many were able to build applications even though they did not wish to spend a lot of effort on learning or developing. However, the market, which was given several HyperCard like products to choose from, has decided against this form of development environment. Neil From mwh at python.net Thu Jun 7 13:18:21 2001 From: mwh at python.net (Michael Hudson) Date: 07 Jun 2001 18:18:21 +0100 Subject: WHY is python slow? References: Message-ID: mitchell.morris at cingular.com (Mitchell Morris) writes: > My second observation is that constructing a group of languages that > includes Java, Perl, and Ruby as members but doesn't include Python > must be using a very fine discriminant indeed . Braces as block delimiters? not-too-serious-ly y'rs M. -- I really hope there's a catastrophic bug insome future e-mail program where if you try and send an attachment it cancels your ISP account, deletes your harddrive, and pisses in your coffee -- Adam Rixey From dsh8290 at rit.edu Wed Jun 13 13:39:57 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 13 Jun 2001 13:39:57 -0400 Subject: VI In-Reply-To: <20010613144609.43005.qmail@web14505.mail.yahoo.com>; from j_f9@yahoo.com on Wed, Jun 13, 2001 at 07:46:09AM -0700 References: <20010613144609.43005.qmail@web14505.mail.yahoo.com> Message-ID: <20010613133956.E27218@harmony.cs.rit.edu> On Wed, Jun 13, 2001 at 07:46:09AM -0700, F. Tourigny wrote: | > From: "Chris Gonnerman" | > 13 Jun 2001 07:53:54 -0500 | > "Too basic?" How so? I've got hundreds of | > thousands of lines of C and probably several | > more thousands of lines of Python written using vi, | > vim, etc. I find most everything other than emacs | > too basic" (and emacs is a religion I've never | > converted to). | | As I said, I'm rather fond of the old endearing beast, | but I don't know if I would write thousands of lines | of code with it (not that I could: I'm still a | newbie). Hey, the thing won't even debug software in | your place:) >From the vim website : ~~~~~~~~~~~~~~~~~~~~~~~~~~ There are some things that Vim does not try to be: <...> * Vim is not a compiler. <...> * Vim is not an operating system. * Vim is not another Emacs. ~~~~~~~~~~~~~~~~~~~~~~~~~~ It doesn't explicitly say it in this section, but vim is a _text editor_, not a debugger. IMO it works exceptionally well :-). -D From duncan at NOSPAMrcp.co.uk Tue Jun 26 04:14:50 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Tue, 26 Jun 2001 08:14:50 +0000 (UTC) Subject: 'with' statement in python ? References: Message-ID: asgard wrote in news:mailman.993497019.14391.python- list at python.org: > could be written as > > with self: > a=1 > b=2 > > ? Of course it would work with other names too. > Does this mean "self.a=1; self.b=2" or are either of a and b local or global variables? There are two main uses for with. In your example you are using with simply to avoid writing 'self.' in front of each member reference. The problem is that in Python you cannot tell until runtime whether self has attributes a and b. You could assume that all variable references inside the 'with' became prefixed with 'self.', but then you couldn't access any values that weren't in your object. So simply as a way to save yourself typing 'with' won't work. The other use for with is to precalculate some complicated reference: with some.thing[or](other): foo = 5 * bar bar += 1 Python already has an equivalent way to do this: t = some.thing[or](other) t.foo = 5 * t.bar t.bar += 1 -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From castor at snafu.de Wed Jun 6 18:33:13 2001 From: castor at snafu.de (Wolfgang Lipp) Date: Wed, 06 Jun 2001 22:33:13 GMT Subject: is this a python bug? References: <6564c76c.0105302046.2f24ab47@posting.google.com> Message-ID: <1105_991866793@ns.seowon.ac.kr> Mike, thanks for the hints. The very last line says it all, > > [should] any code [...] be able to blow up the interpreter? > No. This is (as code like yours demonstrates) surprisingly hard to > achieve, though. That's what I'm after. BTW, > [...] but if I was up to this level of __getattr__ > hackery, I'd have serious thoughts about the design of my application. I am having serious thoughts, believe me >frantic laugh< -- no, seriously, the point is here that i try to separate "public" and "private" attributes, so you can have things like (1) vc = VC() vc.foo = 42 vc.keys = 123 print vc[ 'foo'], vc['keys'] and still do, eg, (2) print vc._.keys() without the public 'keys' in (1) being an obstruction to the private (administrative) 'keys' in (2) (see http://home.snafu.de/castor/projects/pylon/). This is especially practical when you can additionally do (3) class Y( VC ): pass y = Y( foo = 42 ) because then the difference between 'instances' and 'mappings' gets blurred (I admit) to the degree where the decision between using either a class instance or else a mapping for a given purpose turns out pointing towards a merger between the two concepts in a great many cases, which makes VC quite ubiquitious in my code. Yes, perhaps there could be a more obvious implementation... -wolf From MarkH at ActiveState.com Thu Jun 14 10:44:26 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 14 Jun 2001 14:44:26 GMT Subject: Office's Access XP ODBC DBI from PythonWin References: <9ga6cd02m44@enews1.newsguy.com> Message-ID: <3B28CE04.3090009@ActiveState.com> Alex Martelli wrote: > "Steve Holden" wrote in message > news:OJj8WlH9AHA.185 at cpmsnbbsa07... > ... > >>Has the Win32 odbc module been updated at all since 2.0? I have a feeling >>you might find it less than satisfactory for extended use - I've certainly >>had problems myself. >> > > Hmmm, I did send you my partially-fixed version, yes...? Hrm - I wouldn't be surprised if either I have asked this before, or you have sent it before, but what fixes do you have? I just checked in a fix to the username and password fields when not specified as part of the connection string. It missed ActivePython 211 and win32all-140 tho :( Thanks, Mark. From aleaxit at yahoo.com Wed Jun 6 10:02:51 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 6 Jun 2001 16:02:51 +0200 Subject: 2 language applications References: <9fk6ll$4ln39$1@ID-44371.news.dfncis.de> <9fkubv0i48@enews2.newsguy.com> <33476bef.0106060529.98d247f@posting.google.com> Message-ID: <9fld6d01bc7@enews2.newsguy.com> "Cristian Echeverria" wrote in message news:33476bef.0106060529.98d247f at posting.google.com... > That is what I call "AN EXPLANATION"... > ...Thank you very much You're welcome! I'm not good at concision, but I _can_ be reasonably complete if I spend my energy that way rather than trying for one-line summaries:-). > Now I understand what are those .po and .mo files Ah, you DO have some around already? Cool! Alex From kalle at gnupung.net Fri Jun 22 10:59:57 2001 From: kalle at gnupung.net (Kalle Svensson) Date: Fri, 22 Jun 2001 16:59:57 +0200 Subject: PEP 255: Simple Generators In-Reply-To: References: Message-ID: <20010622165957.A360@gnupung.net> Sez David Goodger: > Generators are very cool. I'm sure I will use them. I'm glad they're getting > into Python. Thank you Neil, Tim, and Magnus, for all your work. +1 > on 2001-06-21 2:57 PM, Tim Peters (tim at digicool.com) wrote: > > a generator-function returns a generator-iterator > > That's what it boils down to. Before generators, all functions returned > objects using explicit 'return' statements. Now, generator-functions return > generator-iterators, but there's *nothing* explicitly saying 'return > generator_iterator'. Before generators, calling a function executed its > code. Now, calling a generator-function doesn't execute the code at all; you > have to execute the magically returned object. Only the 'yield' indicates > any of this variant behavior. > > Can I get used to it? Yes, I think I have enough spare brain cells. (Heck, I > used to know Perl! ;-) > > Should I get used to it? > > "Explicit is better than implicit." Well put! I've had a nagging feeling that PEP 255 was not all nice, and this expresses my concerns very clearly. Peace, Kalle -- Email: kalle at gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From Attila.Feher at lmf.ericsson.se Wed Jun 6 12:42:04 2001 From: Attila.Feher at lmf.ericsson.se (Attila Feher) Date: Wed, 06 Jun 2001 19:42:04 +0300 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3b1cdc84.5514@bolder.com.co.za> <9fleid$3rp$1@oslo-nntp.eunet.no> <3B1E4951.7F36D4E4@alcyone.com> <3B1E50E1.35AE59C@lmf.ericsson.se> <3B1E52DA.BBC9FC32@alcyone.com> <3b1e5601.3970@bolder.com.co.za> <3B1E5836.E7F1D88F@lmf.ericsson.se> <3b1e5b50.3adb@bolder.com.co.za> Message-ID: <3B1E5D5C.7878FC9E@lmf.ericsson.se> goose wrote: > LOL - neither do they eat quiche ... Opps. Here is one of the many points my English knowledge ends. What is quiche? A From mwh at python.net Thu Jun 7 13:11:18 2001 From: mwh at python.net (Michael Hudson) Date: 07 Jun 2001 18:11:18 +0100 Subject: Windows editor? References: <3af2c38f.341431824@News.CIS.DFN.DE> <3B1F345B.4E04FDE9@rk-speed-rugby.dk> Message-ID: Has someone written a Python script that can recreate this thread at the press of a single button? It's always rather predictable. Of course, I'm writing this in gnus, so maybe I should start brushing up my emacs lisp... Cheers, M. Brian Elmegaard writes: > Mike Read wrote: > > > > > > > > > > >What's a good Python editor for programming under Windows, specifically > > > > > >Windows 2000? According to Google archives it seems this > > IMHO, Nothing beats emacs. -- C++ is a siren song. It *looks* like a HLL in which you ought to be able to write an application, but it really isn't. -- Alain Picard, comp.lang.lisp From kbk at shore.net Wed Jun 6 13:42:07 2001 From: kbk at shore.net (Kurt B. Kaiser) Date: Wed, 06 Jun 2001 17:42:07 GMT Subject: floating point in 2.0 References: <3B1E50C9.7D2509F4@shore.net> <9flkoi$ofu$1@panix2.panix.com> Message-ID: <3B1E6A67.2B33C197@shore.net> Aahz Maruch wrote: > Quite the contrary! The sooner people realize that floating point is > broken, the better off they are! What we're talking about is the unformatted output representation. Until Python computes (with reasonable speed) in BCD or some such, I think most people would want good old "print". Precision is not the issue for 99.9% of the users, it's comparison, if there is an issue at all. The cognoscenti can always displayhook whatever output method they want. As I recollect from my APL days, there was a FUZZ factor which could be set to control the comparison. It would be nice if Python could overload == with something like that when comparing floats. My mom used to make me eat my spinach with cod liver oil....maybe we should output in binary to *really* show the problem...;) Regards, KBK From thinkit8 at lycos.com Tue Jun 12 20:29:25 2001 From: thinkit8 at lycos.com (thinkit) Date: 12 Jun 2001 17:29:25 -0700 Subject: Keyword argument parsing in error in 2.0? References: Message-ID: <9g6c550qrb@drn.newsguy.com> i'd consider looking at this, but it contains a decimal number. use hexadecimal only if you want to be taken seriously. In article , "Steve says... > >I'm working on a SQL abstraction layer, using methods to generate SQL >appropriate to a particular database back-end. This has involved using >keyword arguments to many of the methods. As a catchall (to avoid having to >handle too much SQL syntax) many methods have a REST keyword argument, which >is appended to the generated statement. The 2.0 compiler is complaining >about the following statement: > >c.UNION(c.SELECT(["l.beer", "l.drinker", ["count(distinct s.bar)", >"nbars"]], > FROM=[["likes", "l"], ["serves", "s"]], > WHERE="l.beer=s.beer", > REST="group by l.beer, l.drinker"), > c.SELECT("distinct beer, drinker, 0 as nbars", > FROM="likes", > WHERE="beer not in (%s)" % > c.SELECT("beer", > FROM="serves")), > REST="order by 3 desc") > >This validates fine in PythonWin, but when the module containing it is >executed I get: > >Traceback (most recent call last): > File "alltest.py", line 396, in ? > REST="order by 3 desc"), >TypeError: keyword parameter redefined: REST > >The implication is clearly that the system is seeing two definitions of the >same keyword argument, but I have tried to analyze the statement carefully >and it seems to me that the different REST arguments are being provided to >different calls. > >Just to check, I tried running the following program: > >def a(x, y, z, REST="NothingA"): > return "%s %s %s %s" % (x, y, z, REST) > >def b(x, y, z, REST="NothingB"): > return "%s %s %s %s" % (x, y, z, REST) > >print "STARTING" > >print a("a", > b("m", "n", "o", REST="Ignore1"), > a("s", "t", "u", REST="Ignore2"), > REST="Ignore3") > >This runs fine, printing > >STARTING >a m n o Ignore1 s t u Ignore2 Ignore3 > >Is this a bug, or can I simply not see my error for looking too hard? > >regards > Steve > > > > From ZnickZm at alum.mit.edu Mon Jun 18 19:02:02 2001 From: ZnickZm at alum.mit.edu (Nick Mathewson) Date: 18 Jun 2001 23:02:02 GMT Subject: PEP 255: Simple Generators References: <9glhg7$dlk$1@nntp6.u.washington.edu> Message-ID: On Mon, 18 Jun 2001 11:32:31 -0700, Russell E. Owen wrote: [...] >This sounds like an interesting and really useful proposal. However,a >few details are worrisome to me: > >* A generator looks like a function until you find the "yield" statement >inside. I think this will make the code much harder to read. One keyword >buried anywhere in a function totally changes its behavior. If a >generator acted like a function until it hit "yield", this wouldn't be >so bad, but it sounds as if generators have enough significant >differences (such as restrictions on and a changed meaning for return) >that they are very different beasts. > >I'd much rather see a declaration up front that this is going to be a >generator. E.g. add a new keyword such as "generator". I strongly agree here. My experience with generators comes from CLU's iterators, which also had a distinct syntax for declaring them. To keep Python clean, I'd suggest something like: def generator inorder(tree): #stuff goes here. No new keywords are needed. All you'd need to do to the grammar (IIUC) is to add a production to src/Grammar/Grammar: gendef: 'def' NAME NAME parameters ':' suite and later make sure that the first name was equal to 'generator'. Perhaps this is simple CLU-based paranoia on my part; perhaps a lack of distinction won't really matter for Python users. Nevertheless, as far as I know, while the distinguish-functions-and-iterator-declarations approach has been taken a few times (in CLU and others), nobody has ever actually tried an approach which only distinguished them in their declarations. Therefore, conservative design might argue for distinguishing declarations. They really are different. Consider the following example: what happens when f1 is called? def f1(): return items_after(5,[1,2,3]) def items_after(idx,lst): assert 0 <= idx < len(lst) #.....more code here. Right now, f1() will always raise AssertionError. But under the current verion of the PEP, it all depends on whether the code block contains any yield statements. In general, the behavior of the first line of a function should not depend on the presence or absence of other statements that may be buried deep within the function. IMNSHO. >* The unusual use of "return" and the associated restriction of no >expression list. What "return" means in a generator is "raise StopIter", >not return. I personally really dislike using a keyword for multiple >vaguely similar purposes. Look at "static" in C++ for an example of >where this can lead. This, actually, I disagree with. In both cases, "return" means 'stop executing this function.' While a generator is _implemented_ as an iterator, users conceptually treat generators as long-running functions that yield many times, but return once. ( Once again, I'm speaking from my quite limited CLU experience. :) ) In fact, "raise StopIter" is a step backwards. It exposes the internals of the iterator implementation, after all, which is one of the things that generators are supposed to avoid.[*] [*] In my CLU experience, relatively inexperienced users found generators really easy to write, even without ever having heard of the idiom before. I don't know many unsophisticated beginners who've found, e.g. Java Iterators easy to write. [....] >3) Have "return" mean exactly what it means now, but also have a >generator raise StopIter for the next call following a return. This is a >natural meaning for return (and allows an expression list), but has the >disadvantage that it doesn't permit one to say "I'm done and have no >more data to return". In other words, "return EXPR" inside a generator would be an alias for "yield EXPR; return"? That might be convenient, but I still worry for 2 reasons: 1) It violates "Only One Obvious Way To Do It". :) 2) I guarantee that, if this shorthand is adopted, we'll have a new FAQ entry of the form: "When I write a generator like this, it only gives me one result! def generator every_nth_element(lst, n): idx = 0 while idx < len(lst): return lst[idx] idx += n One-good-way-to-really-understand-the-pros-and-cons-of-a-language- feature-is-to-teach-a-software-engineering-course- in-a-language-that-uses-it-or-to-hang-out-with-people-who-have'ly yours, -- Nick Mathewson Remove Z's to reply. From grante at visi.com Sat Jun 2 17:32:33 2001 From: grante at visi.com (Grant Edwards) Date: Sat, 02 Jun 2001 21:32:33 GMT Subject: Why isn't Python king of the hill? References: <9fb5fl$26kf$1@agate.berkeley.edu> <9fblqd$2f0u$1@agate.berkeley.edu> Message-ID: On Sat, 2 Jun 2001 21:28:45 +0000 (UTC), E. Mark Ping wrote: >>>Checking the difference of the values will yield another large >>>number, and a method like "IsCloseTo" will incorrectly fail. >> >>How can it fail? Either A is within X% of B or it isn't. What's the >>problem? > >But your algorithm didn't specify %, rather you said: > > fabs((1.0 + 2.0) - 3.0) < [a small number] > >If it were percentage, you'd be adding a division operation too. >That's getting to be a large amount of overhead. I did say that choosing the value of [a small number] was left as an exercies for the reader. In some cases it must be an absolute value, in other cases relative to the values being compared -- obviously it depends on the system requirements. -- Grant Edwards grante Yow! Look into my eyes and at try to forget that you have visi.com a Macy's charge card! From not.this at seebelow.org Sat Jun 30 22:49:39 2001 From: not.this at seebelow.org (Grant Griffin) Date: Sat, 30 Jun 2001 21:49:39 -0500 Subject: PEP 260: simplify xrange() References: <3B3AA617.8A9B56B7@seebelow.org> <20010629.034219.889023311.911@watervalley.net> Message-ID: <3B3E8FC3.DE48C72@seebelow.org> Chris Lawrence wrote: > > In article <3B3AA617.8A9B56B7 at seebelow.org>, "Grant Griffin" > wrote: > > > BTW, can PyChecker do Python-version enforcement? Specifically, I think > > it would be great if we had a gizmo at least to enforce 1.5.2 (besides > > 1.5.2 itself ). > > > > Even cooler would be if Python had some sort of feature for this. (I'd > > write a PEP for that, but I fear that it might lead to a new version > > .) But I guess for reasons of efficiency something like this > > should be an "offline" tool anyway rather than pollute the innards of > > Python. > > You can try this code at the beginning of your program: > > import sys > try: > if sys.hexversion < 0x10502f0: # 1.5.2 final > print 'Get a new version of Python!' > except AttributeError: > print 'Get a new version of Python!' > > Dunno when sys.hexversion showed up, hence the try clause. > > With more recent versions, you could also play with sys.version_info. Thanks for the suggestion, Chris, but I guess I was thinking more of "backwards compatibility" issues. This comes up currently for me because I am writing a CGI app, and version 1.5.2 of Python still seems to be installed on web servers (because, until recently, at least, it appeared in most Linux distributions.) For that reason, for example, it would be nice to be able to automatically know that something developed using Python 2.1 was free of string methods so it would run on 1.5.2. (Even better would be a "backwards-version source-code translator"--that is, something besides my tired brain and aching fingers .) only-microsoft-succeeds-in-making-nearly-each-and-every-old-horse -who-uses-its-software-"upgrade"-to-each-new-water-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From jh at web.de Tue Jun 5 16:15:08 2001 From: jh at web.de (Jürgen Hermann) Date: Tue, 5 Jun 2001 22:15:08 +0200 Subject: multifile and mimetools to parse email folder References: Message-ID: <9fjeh0$7me$07$1@news.t-online.com> "Barry A. Warsaw" schrieb im Newsbeitrag news:mailman.991711867.28339.python-list at python.org... > successfully using mimelib 0.3 in the Mailman 2.1 alpha. From > personal experience, I'd say it's a dang sight easier to use than > mimetools+multifile! > Please let me know what you think. I'm open to suggestions. As you wish... :) Did you spend any thoughts on adding header en-/decoding? The stuff in mimify is broken. Ciao, J?rgen From gorny at hobbiton.org Sun Jun 10 08:43:09 2001 From: gorny at hobbiton.org (Gorny) Date: Sun, 10 Jun 2001 14:43:09 +0200 Subject: bind keys Message-ID: Hi, How do I bind keys to my menubaroptions with TkinteR? I can't figure out anything on the web. Nowhere is a good tutorial with that informatioin in it.. Anyone? Gegroet, Gorny From emile at fenx.com Mon Jun 25 22:35:59 2001 From: emile at fenx.com (Emile van Sebille) Date: Mon, 25 Jun 2001 19:35:59 -0700 Subject: Windows Printing using win32print References: Message-ID: <9h8smc$csrv8$1@ID-11957.news.dfncis.de> I'm not sure if this helps with your specific problem is, but I can say that you need to figure out the name the printer goes by. I've seen different names for printers working with various applications in windows. Here are two examples that I'm currently using. destPrinter = r'NEC Silentwriter 95 v2011.111 on LPT1:' destPrinter = r"\\NT401\HP Laserjet 4000N Front Desk on NE02:" I got the names by going into immediate mode from within Office 2000. Here are my notes. ## to figure out the printer name recognized in MS Office apps, ## - go into the app ## - print a document to the target printer ## - alt-F11 into visual basic ## - go into immediate mode ## - print Application.ActivePrinter ## - copy and paste the name in Again, not sure it'll help, but hope it does. -- Emile van Sebille emile at fenx.com --------- "Timothy Grant" wrote in message news:mailman.993507818.30090.python-list at python.org... > I'm not much of a windows programmer, but I am in a situation > where I need to write a test programme that does a lot of very > small print jobs from a Windows box. I have downloaded > win32all, and cobbled together a little app that I think > should, maybe work, but doesn't. > > In my first iteration, I simply wrote a text file, then used > os.system('copy filename lpt1:') to print it. This worked just > fine, but one of the variables I need to test is how an > interaction with the actual Windows printers works. To that end > I started reading up on win32print. I was able to come up with > the following... > > > import win32print > > text2print = """ > This is a test to see if I can get this text to actually print\n > > > > It will be multiple lines...\n > > Watch and see\n > """ > printer = win32print.OpenPrinter('Tektronix Phaser 600 Extended') > jid = win32print.StartDocPrinter(printer, 1, ('TEST DOC', 'c:\\test\\test.tjg', 'RAW')) > bytes = win32print.WritePrinter(printer, text2print) > win32print.EndDocPrinter(printer) > win32print.ClosePrinter(printer) > print bytes > > > Now this is where my understanding of how things should work > gets a bit shaky. I have read that the WritePrinter() function > should send printer ready data. So since text2print is not in > ps or pcl native format, I'm curious as to whether I'm even > close. > > If I do need to send printer ready data, how do I create the > printer ready data from my print string? > > Thanks for any assistance you might be able to provide. > > -- > Stand Fast, > tjg. > > Timothy Grant www.hyperlinq.net > Chief Technology Officer tjg at hyperlinq.net > HyperLINq Technologies, Inc. <>< (503) 246-3630 > >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< > >>>>This machine was last rebooted: 20 days 22:08 hours ago<< > From graham at coms.com Mon Jun 18 11:11:08 2001 From: graham at coms.com (Graham Ashton) Date: Mon, 18 Jun 2001 16:11:08 +0100 Subject: Loading select queries into objects References: Message-ID: In article , "Unknown" wrote: > That is, if I understand how you want to do it: > The list of functions is [f0, f1, f2] and you want: f0(tup[0]) > f1(tup[1]) > f2(tup[2]) > > You could do something like: > funlist = (self.column1, self.column2, self.some_column) > > for i in range (len(funlist)): > apply(funlist[i],(tup[i],)) That's done the job. Thanks very much. From 00001111 at my-deja.net Fri Jun 1 19:09:30 2001 From: 00001111 at my-deja.net (00001111) Date: Fri, 01 Jun 2001 16:09:30 -0700 Subject: Long names are doom ? References: <3B0EEAE7.FAD87BD@aol.com> Message-ID: <3B1820AA.422539B5@my-deja.net> 00001111 wrote: > Hi All, > > Anybody use variables/names longer than 31 character > and finds it really useful ? Christian Brolin (comp.lang.functional) wrote the program which abbreviates identifiers. In fact if you look deeply you start to smile. This definitely is not human respond on these 3 initial claims but Computer's one where even 'cyber brain' laughs full of irony. Christian Brolin (comp.lang.functional) wrote: > > I have a program that can abbreviate names, e.g.: > > [(len,abbreviate len "Anybody_use_names_longer_than_31_characters") > | len <- [43,42..10]]; > [(43, "Anybody_use_names_longer_than_31_characters"), > (42, "Anybody_use_names_longer_than_31_charactrs"), > (41, "Anybody_use_names_longer_than_31_charctrs"), > (40, "Anybody_use_names_longer_than_31_chrctrs"), > (39, "Anybody_use_names_longer_thn_31_chrctrs"), > (38, "Anybody_use_names_longr_thn_31_chrctrs"), > (37, "Anybody_use_names_lngr_thn_31_chrctrs"), > (36, "Anybody_use_nams_lngr_thn_31_chrctrs"), > (35, "Anybody_use_nms_lngr_thn_31_chrctrs"), > (34, "Anybdy_use_nms_lngr_thn_31_chrctrs"), > (33, "Anbdy_use_nms_lngr_thn_31_chrctrs"), > (32, "Anbdy_us_nms_lngr_thn_31_chrctrs"), > (31, "Anbd_us_nms_lngr_thn_31_chrctrs"), > (30, "Anbd_us_nms_lngr_thn_31chrctrs"), > (29, "Anbd_us_nms_lngr_thn31chrctrs"), > (28, "Anbd_us_nms_lngrthn31chrctrs"), > (27, "Anbd_us_nmslngrthn31chrctrs"), > (26, "Anbd_usnmslngrthn31chrctrs"), > (25, "Anbdusnmslngrthn31chrctrs"), > (24, "Anbdusnmslngrthn31chrctr"), > (23, "Anbdusnmslngrthn31chrct"), > (22, "Anbdusnmslngrthn31chrc"), > (21, "Anbdusnmslngrthn31chr"), > (20, "Anbdusnmslngrthn31ch"), > (19, "Anbdusnmslngrthn31c"), > (18, "Anbdusnmslngrthn31"), > (17, "Anbdusnmslngrthn3"), > (16, "Anbdusnmslngrthn"), > (15, "Anbdusnmslngrth"), > (14, "Anbdusnmslngrt"), > (13, "Anbdusnmslngr"), > (12, "Anbdusnmslng"), > (11, "Anbdusnmsln"), > (10, "Anbdusnmsl") > > Continuing little bit (9,...) (8,...) (7,...) (6,...) (5,...) (4,...) (3,...) (2,An) (1,A) (0, ERROR: FORTRAN NAME IS TOO SHORT. CHOOSE IT BETWEEN 1 and 6 CHARACTERS. STOP. END) Bravo Christian ! That's just real Classics! Christian Brolin (comp.lang.functional) wrote: > > > > > > > > Code: > > abbreviate :: Int -> String -> String > abbreviate maxlen > = truncate > . reverse > . remove wordSeparators > . remove allButFirstVowels > . remove adjacentDuplicates > . remove vowelsEmbeddedInConsonants > . reverse > where > isVowel c = elem c "aeiouy" > isConsonant c = isAlpha c && not (isVowel c) > remove rule name = remove' (length name) rule name > remove' _ _ [] = [] > remove' len rule name > | len > maxlen = let (keep,del,test) = rule name > in keep ++ remove' (len - del) rule test > | otherwise = name > vowelsEmbeddedInConsonants (f:e:d:rest) > | isConsonant d && isVowel e && isConsonant f = ([f],1,d:rest) > | otherwise = ([f],0,e:d:rest) > vowelsEmbeddedInConsonants name = (name,0,[]) > adjacentDuplicates (e:d:rest) > | d==e = ([],1,d:rest) > | otherwise = ([e],0,d:rest) > adjacentDuplicates name = (name,0,[]) > allButFirstVowels (e:d:rest) > | isAlpha d && isVowel e = ([],1,d:rest) > | otherwise = ([e],0,d:rest) > allButFirstVowels name = (name,0,[]) > wordSeparators (u:rest) > | u=='_' = ([],1,rest) > | otherwise = ([u],0,rest) > wordSeparators name = (name,0,[]) > truncate = take maxlen > > -- > Christian Brolin -> Det ?r fult att peka > Then please respond why, where, when. From tim.one at home.com Fri Jun 29 16:01:30 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 29 Jun 2001 16:01:30 -0400 Subject: PEP scepticism In-Reply-To: <9hht6a01bqn@enews2.newsguy.com> Message-ID: [Bernhard Reiter and Alex Martelli quote from an interview with Dennis Ritchie, at http://www.itworld.com/Comp/3380/lw-12-ritchie/ ] One more from that not to be missed: On the other hand, the "open evolution" idea has its own drawbacks, whether in official standards bodies or more informally, say over the Web or mailing lists. When I read commentary about suggestions for where C should go, I often think back and give thanks that it wasn't developed under the advice of a worldwide crowd. From s713221 at student.gu.edu.au Thu Jun 7 01:18:06 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Thu, 07 Jun 2001 15:18:06 +1000 Subject: Running mod_python on NT References: <1a18c6fa.0106060811.5f09477f@posting.google.com> <2YxT6.948$Q8.31005@juliett.dax.net> <9fn152$9d3$1@216.39.170.247> Message-ID: <3B1F0E8E.C79BD876@student.gu.edu.au> > I've used mod_python with Apache 1.3.19 and Python 2.1 on NT although, > not much. It does work as far as i've played with it. > > Dave LeBlanc I've played around with mod_snake a couple of times. A few months back somebody recommended it over mod_python. But nobody seems to mention it anymore. How come? -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From davygrvy at pobox.com Fri Jun 1 22:13:59 2001 From: davygrvy at pobox.com (David Gravereaux) Date: Fri, 01 Jun 2001 19:13:59 -0700 Subject: Is PyRun_String() broken? Message-ID: All I get back from it in the PyObject* is an exception code that says 'None'. I've tried using Py_single_input for the start token, but the result of the operation is sent to stdout. How is it possible to eval code and get the result back? As far as I've able to RTFM and "use the source luke" is to determine that eval_code2() when coming back out of the eval falls into the POP_TOP case and does Py_DECREF(v) on the result to destroy it. I WANT IT! WHERE'D IT GO? This is a central theme in other interpreted languages such as Tcl: Tcl_Interp *interp; int code; interp = Tcl_CreateInterp(); code = Tcl_Eval(interp, "proc foo {} {}; expr {rand()}"); if (code == TCL_OK) { printf("the random number is %s", interp->result); } else { printf("We bombed with %s", interp->result); } If all that PyRun_String() returns is "exception or not", where/how is it possible to get the last result of the operation? Is it true that POP_TOP in eval_code2() of ceval.c discards the object before returning? How can I not pop the top, and grab the result then Py_DECREF it after I'm done? A stumped Tcl coder trying to embed python, -- David Gravereaux From tim.one at home.com Wed Jun 27 03:44:28 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 27 Jun 2001 03:44:28 -0400 Subject: Help: Python 2.1: "Corrupt Installation Detected" In-Reply-To: <3B398ACC.D76A3D0@bintec.de> Message-ID: [Richard Saathoff] > I think you tried a Win NT-Installation without Administrator > privileges. That really ought to work. What doesn't work is trying to install while logged in to a Restricted account (a bogus "Corrupt Installation" msg is the usual result then). The 2nd-most frequent cause (it's been reported twice ), and assuming Greg was using the PythonLabs installer, is trying to install over a network instead of from a local drive. the-mysteries-never-end-ly y'rs - tim From grante at visi.com Fri Jun 29 16:23:32 2001 From: grante at visi.com (Grant Edwards) Date: Fri, 29 Jun 2001 20:23:32 GMT Subject: Is this a true statement: Part II References: <9hiifr$sjs$1@taliesin.netcom.net.uk> Message-ID: <8t5%6.4944$B7.938629@ruti.visi.com> In article <9hiifr$sjs$1 at taliesin.netcom.net.uk>, MDK wrote: >Why is C++ awful; what's wrong with it? Two important (somewhat subjective) qualities of a programming language: 1. safe vs. unsafe Languages like C and assembler are unsafe. You can stomp all over memory and crash your program (and possibly your system) in fun and spectacular ways. Languages like BASIC, Smalltalk, Pascal, Modula-3, LISP, and Scheme are safe. It is possible to write an incorrect program, but it is not possible to create a bogus pointer, to allocate memory and never free it, etc. IOW, your program may not do what you want, but it doesn't crash your system.[1] 2. simple vs. complex The syntax and semantics of languages like C and Scheme are fairly simple. A moderately skilled programmer can look at a piece of code and have half a chance of figuring out what it is going to do. Other languages have complex syntax and semantics, and it's hard to tell what is going to happen when you compile and run a piece of code. C is dangerous, but it's also simple. That means that you _can_ shoot your foot off, but the language is simple enough that you can figure out how to avoid doing so. Modula-3 is a bit more complex, but it's safe. The compiler won't let you shoot your foot off, even if you can't get the program to do what you want. C++ is both complex and unsafe. It can shoot your foot off, cut your arm off, impale you on a pike, or slowly poison your food. Unfortunately it's got so damn many buttons, knobs, levers, bells and whistles, that it's impossible to tell how to avoid being shot, impaled, poisoned, or otherwise inconvenienced. Even if you've figured out how to survive encounters with C++ Flavor X, Version Y, your experience is often useless with the next flavor or version. OTOH, Python (the language itself) is both simple and safe. Some of the library modules are complex, and some of them are written in C and are quite capable of crashing. [1] So called "safe" languages often have extensions to do unsafe things (e.g. BASIC's peek() and poke(), Modula-3's linkage to "unsafe" modules). But you have to go out of your way to get at the unsafe features, and they're not required for "every-day" programming they way they are in C or C++. -- Grant Edwards grante Yow! I just forgot my at whole philosophy of life!!! visi.com From nperkins7 at home.com Fri Jun 29 02:52:54 2001 From: nperkins7 at home.com (Nick Perkins) Date: Fri, 29 Jun 2001 06:52:54 GMT Subject: functional programming and default parameters Message-ID: Here is an experiment with functional programming and default parameters.. (the example uses trivial functions, but it's the principle of the thing...) ..suppose i want to create a list of functions with no parameters, such that: fns[0]() -> 0 fns[1]() -> 1 fns[2]() -> 2 etc. this does not work: >>> fns = [lambda:i for i in range(3)] >>> fns[0]() 2 >>> fns[1]() 2 but this does work: >>> fns = [lambda i=i:i for i in range(3)] >>> fns[0]() 0 >>> fns[1]() 1 ..but the problem is that i wanted functions of zero parameters, not functions with one optional parameter: >>> fns[1](99) 99 ( oops! not intended to be used this way! ) Nested scopes do not seem to solve the problem, I have tried things like: from __future__ import nested_scopes def fnlist(n): list =[] for i in range(n): def fn(): #or: def fn(i=i) return i list.append(fn) return list .. but the result is the same: the inner function needs to have i as a default parameter in order to 'freeze' the value of i into the function, thereby also producing functions with one optional parameter. Can this be done without using default parameters? From m.bless at gmx.de Wed Jun 20 15:09:23 2001 From: m.bless at gmx.de (Martin Bless) Date: Wed, 20 Jun 2001 19:09:23 GMT Subject: makepy.py changed? Message-ID: <3b31f0bc.27273772@news.muenster.de> In January - just starting with Python - I had 'makepy' create the interfacing code of spirit.ocx, which is the library of the LEGO Mindstorms Robotics kit. Using the Activestate distribution of Python of that time (I think it was v1.37 - or is it v137?) makepy worked quite well, creating a VERY LONG and DETAILED python module. January was too early - my understanding of Python was too little. With improved knowledge I'd like to try again. Again with the Activestate edition, now Python 2.1, makepy creates a MUCH SHORTER source. The details of the spirit.ocx methods are missing. I tried all the parameters - I couldn't convince makepy to do 'better'. My guess is, makepy has changed and now implements a more dynamic strategy. But I so much would prefer the old more static one, as it's much more showing. Q: How can I still have makepy behave in the old / detailed / explicit / static / or whatever it is called way? Martin From aleaxit at yahoo.com Fri Jun 15 06:37:46 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 15 Jun 2001 12:37:46 +0200 Subject: wrapping a C++ class References: <9gba7n$8jj$1@info1.fnal.gov> Message-ID: <9gcoih01k9@enews1.newsguy.com> "Enrico Ng" wrote in message news:9gba7n$8jj$1 at info1.fnal.gov... > I am trying to wrap a simple C++ class like this: > > class mymath { > int x, y; > public: > void set_values(int a, int b) {x=a;y=b;} > int add(void) {return (x+y);}}; > > The thing is, I'm not sure how to wrap this. I am assuming the self is the www.boost.org offers the Boost Python library, making this quite easy. Alex From budr at sirinet.net Sun Jun 24 09:35:15 2001 From: budr at sirinet.net (Bud Rogers) Date: Sun, 24 Jun 2001 08:35:15 -0500 Subject: Python scripting [was: Re: emacs speedbar for python mode?] References: <9h2bo2$335$1@news1.xs4all.nl> Message-ID: <1bq4h9.tq8.ln@twocups.sirinet.net> Fran?ois Pinard wrote: > If I could only script Emacs with Python! Emacs LISP is not so bad, > it has a lot of virtues, yet writing Scheme or Python is more > pleasurable to me. > In these days, soon in the morning, before I'm fully awake, I vaguely > dream of big things, like developing semi-automatic Emacs LISP to > Python converters (a bit like CWeb does for Knuth Pascal code) and > with this, whatever would be necessary to replace or interface with > the Emacs C core. :-) In my dreams still, I start the exercise with > Gnus or Calc, > as the result would be quite useful in itself. Sigh! I have had similar thoughts. Imagine a programmer's editor of the calibre of [x]emacs that used python as a built in extension language in the same way that emacs uses lisp. -- Bud Rogers http://www.sirinet.net/~budr All things in moderation. And not too much moderation either. From alan.gauld at bt.com Wed Jun 13 19:04:20 2001 From: alan.gauld at bt.com (Alan Gauld) Date: Thu, 14 Jun 2001 00:04:20 +0100 Subject: Has anyone used UML? References: <9flodi$32m$1@brokaw.wa.com> <3b228485.13884244@news.laplaza.org> <3B250921.F9F1D571@bt.com> <9g5oml$ird$6@216.39.170.247> Message-ID: <3B27F174.59D1AB4F@bt.com> David LeBlanc wrote: > > Not true! Rumbaugh and then Jacobson specifically joined > > Rational to create the UML. By the time they joined they > > already recognised the need for a unifying language. > wellll.... actually Rational bought both Rumbaugh's and Ivarson's > companies and they came along with the sale. Might be true of Jacobsen since he had left Ericsson by that time but I thought Jim R was still with GEC when he went to Rational? > From what I hear there is a good deal of not so cordial > dislike between/among the "3 amigos" I don't think they've ever claimed to be best buddies. Several disagreements have been acknowledged in articles etc But they all recognised that the method wars would do more harm than good. > For all the ado about UML, there seems to be few competitors to Rose, I think that there are plenty now: Together, Object Domain, iLogix etc... But they are all complex tools doing a very complex job so they cost lots. Best tool for small projects is a tool like Visio, DIA, SmartDraw etc. IMHO Alan G From aleaxit at yahoo.com Fri Jun 29 06:20:42 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 29 Jun 2001 12:20:42 +0200 Subject: python as plugin language References: <993529827.54981@newsmaster-04.atnet.at> Message-ID: <9hhkpq010gl@enews2.newsguy.com> "John Roth" wrote in message news:tjiok16g2asmc7 at news.supernews.com... ... > All the cases you cite miss the essential point - how does the Python > code call a function in the C language program it's embedded in? It's ... > I think the functions I need are in the Python/C API, but I've never seen > those functions referenced in any example, or in any of the books. I may be missing something, but... doesn't the embed.c demo/example, D:\Python-2.1\Demo\embed\demo.c on a typical Python install on Win32 for ex., do exactly what you require...? Well, almost -- it doesn't actually run any useful Python code, just leave a space where you could insert your own:-). But it does show the embedding C program adding a module, called "xyzzy", which exposes to Python a C function, called "foo" (from the Python side of things). Your Python code invoked from demo.c could "import xyzzy" and then call xyzzy.foo(). So, WHAT am I missing...? Alex From jwolff at knoware.nl Wed Jun 13 16:42:10 2001 From: jwolff at knoware.nl (Jeroen Wolff) Date: Wed, 13 Jun 2001 22:42:10 +0200 Subject: base converter Message-ID: I looked on the net for a baseconverter written in python. Is there any? Something like: BaseConvert(20,2) --> "10100" Thx, Jeroen From nperkins7 at home.com Sun Jun 3 21:44:58 2001 From: nperkins7 at home.com (Nick Perkins) Date: Mon, 04 Jun 2001 01:44:58 GMT Subject: Windows editor? References: <3af2c38f.341431824@News.CIS.DFN.DE> Message-ID: I have used Boa Constructor (just the editor), for general-purpose Python programming. I find it to be more stable than PythonWin. In PythonWin, I find that if my program crashes or hangs, it will often take the IDE down with it. Same goes for IDLE. In Boa, I can usually kill my program without killing the editor, too. The rest of Boa (wxWindows gui design) is also pretty good, but needs some work. From serdars at ixir.com Sat Jun 2 07:51:04 2001 From: serdars at ixir.com (Serdar Soydemir) Date: Sat, 2 Jun 2001 14:51:04 +0300 Subject: SocketServer Problem Message-ID: <004501c0eb5a$4ec91980$0101a8c0@nemesis> Hello, I am working on a little socket server application to learn and practice how Python socketserver works. It works great for now, but it can accept only one connection , when i try to open another conn while first one is still alive, it sends the last one to some kind of queue and when first one drops, this one becomes active immediately. What i want to learn is how can I tell SocketServer to serve for multiple connections? I changed allow_reuse_address directive to "1" and queue value is equal to "5" in SocketServer.py . I also tried to manipulate allow_reuse_address from my code, but it still doesn't accept multiple connections. Here's a little portion of my code: ********* class TestHandler(SocketServer.StreamRequestHandler): def handle(self): import string self.wfile.write ("hello\r\n") while 1: data=self.rfile.readline(512) data=string.strip(data) self.wfile.write (data + "\r\n") server=SocketServer.TCPServer( ('',10002), TestHandler) server.serve_forever() ********* -- Serdar Soydemir From paulp at ActiveState.com Sun Jun 10 23:16:17 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sun, 10 Jun 2001 20:16:17 -0700 Subject: Problem with UnicodeError and xml.dom.minidom References: Message-ID: <3B243801.AE9951DC@ActiveState.com> Gustaf Liljegren wrote: > >... > > This is line 37 in count.py. No non-ASCII characters here, and it works > fine in Idle. I'm paralysed. Can someone break the spell? Something is weird with your traceback. I don't see how this line could generate this error: File "E:\python\_xmlplus\dom\minidom.py", line 144, in appendChild if node.nodeType not in self.childNodeTypes: UnicodeError: ASCII decoding error: ordinal not in range(128) It doesn't seem to be doing string manipulations at all. There is a "unicode" builtin that will convert text to Unicode. Sprinkle some calls to that around like this: assert unicode(somestring) Sprinkle some calls to that around your code and even around the library code if you have to. Also, as a strategy, consider unicode-ing all of your input data as soon as you read it in: somestring = unicode(somestring) -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From danny.ayers_nospam at btinternet.com Wed Jun 13 10:35:42 2001 From: danny.ayers_nospam at btinternet.com (Danny Ayers) Date: Wed, 13 Jun 2001 14:35:42 GMT Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> <3B1BBF37.F7FC6F3F@damaru.com> <3B1BC801.D50848C1@bt.com> Message-ID: <3b277937.17318512@news.btinternet.com> I'm new to Python but have been using Java for a long time, and nowadays tend to use a bit of an Extreme-UML hybrid methodology. I'll start out with the CRC cards and then hack together the classes, adding basic functionality, but then use JVision (a Java UML Windows tool, there's a free non-commercial version) to generate class diagrams, which are excellent for getting an idea of what refactorings are needed. On Mon, 04 Jun 2001 18:40:17 +0100, Alan Gauld wrote: >Michael Davis wrote: >> Personally, I find UML most useful as a diagramming language used to >> play with design ideas, or document an existing class framework > >Yes those are good points. Even in a programming context >drawing UML diagrams on a whirteboiard is a lot less >ambiguous than using a homegrown vague bunch of circles etc. >At least everyoine jnows which direction inheritance goes in, >what the cardinality of relationships is etc.. > >> I'm interested in trying other methodologies, such as Extreme >> Programming, whilst using UML as a diagramming language. > >UML is entirely compatible with most methjods - its just a >notation after all. > >Alan G. From fpm at u.washington.edu Tue Jun 12 23:41:15 2001 From: fpm at u.washington.edu (Frank Miles) Date: 13 Jun 2001 03:41:15 GMT Subject: msvcrt.getch() overly receptive in idle? References: <9g5m7k$gu8$1@nntp6.u.washington.edu> Message-ID: <9g6ncr$oh0$1@nntp6.u.washington.edu> In article , David Bolen wrote: >fpm at u.washington.edu (Frank Miles) writes: > >> I'm trying to get getch() working in Windows (Python 2.0). It seems to >> work fine outside of Idle, but inside Idle it immediately returns a >> character with the value 255. >> >> Can anyone point me to the obvious solution? Thanks! > >I expect that getch() requires a working "console" window, and when >you run Idle you don't get one as its set to use pythonw.exe. Thus, >it's technically not able to process any keystrokes and returns >immediately. > >You could try to verify that by starting Idle from the command line >with the standard python. (But you may have to be in that console >window to trigger the getch() to return). > >A GUI doesn't really have individual keystrokes sent as console >characters, but instead receives events upon keypresses. So a getch() >call in a GUI application is sort of non-sensical (within the GUI >framework). > >To do the equivalent in a GUI, you'd need to wait for a keypress >event. I'm not sure how easy or not it would be to tie into Idle's >event loop to notice such a thing. Thanks. This makes sense. This indirect approach will hopefully provide a way to debug apps that need this kind of functionality. -frank -- From cwebster at nevada.edu Sat Jun 16 11:59:28 2001 From: cwebster at nevada.edu (Corran Webster) Date: Sat, 16 Jun 2001 08:59:28 -0700 Subject: Type/Class Distinction References: <9gdpbp$61k$6@newshost.accu.uu.nl> Message-ID: In article <9gdpbp$61k$6 at newshost.accu.uu.nl>, m.faassen at vet.uu.nl (Martijn Faassen) wrote: > Glyph Lefkowitz wrote: > [discussion about type/class split] > > Right now we have to *treat* 'types' differently from 'classes'. For > built-in objects you have to use the type() construct to check what > you're dealing with, but for class instances you use isinstance(). > > Wouldn't it be nice if the language allowed something like this: > > if isinstance(foo, int): > ... > elif isinstance(foo, BarClass): > ... > > (backwards compatibility issues aside) You already can, more-or-less: Python 2.1 (#92, Apr 24 2001, 23:59:43) [CW CARBON GUSI2 THREADS] >>> from types import * >>> isinstance(5, IntType) 1 >>> isinstance(1.0, IntType) 0 > No more special casing seems good to me. Where the PEP will help is to avoid having to do things like: if isinstance(spam, ListType) or isinstance(spam, UserList): ... and also, presumably, to help C extensions use UserLists and similar objects interchangeably with lists. Regards, Corran From mac4-devnull at theory.org Sun Jun 24 13:26:56 2001 From: mac4-devnull at theory.org (Neil Macneale) Date: Sun, 24 Jun 2001 10:26:56 -0700 Subject: newbie question: References: Message-ID: <3b3622dd$0$327$8eec23a@newsreader.tycho.net> In article , "krel" wrote: > Um, this is certainly a stupid sounding question, what is the syntax for > putting data into and retrieving data from a multidimensional list? I > checked the docs, perhaps not well enough? l[i][j] = val val = l[i][j] This works when l[i] is a list. Neil Macneale -- To reply to me via email, remove the '-devnull' from my address. From bill-bell at bill-bell.hamilton.on.ca Wed Jun 20 10:02:09 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Wed, 20 Jun 2001 10:02:09 -0400 Subject: Help, pls: COM local server factory class In-Reply-To: <992994169.401.32981.l6@yahoogroups.com> Message-ID: <3B3074A1.17795.817BE05@localhost> Mark Hammond wrote: > Bill Bell wrote: > > > In response to your suggestion I've started on a different tack. > > Having lent your Win32 book to a colleague I grabbed its Chapter 12 > > "Final Sample" code from the O'Reilly site. I launched the Python > > code from within PythonWin and got "Registered: PythonDemos.Parent > > (for debugging)"--which was encouraging. Then I launched the VBA > > code (minus the comments since I never use 'em) from within MS Excel > > and it croaked on the first line (ie, Set ParentObj = > > CreateObject("PythonDemos.Parent")) with "Unexpected Python Error: > > exceptions.SystemError: NULL result without error in call_object". > > > This is a bug in the win32trace module, which is used in "debugging" > mode. It has been fixed in the most recent ActivePython and win32all > builds. Many thanks!! Can hardly wait to try patched version. - Bill Bill Bell, Software Developer From m.faassen at vet.uu.nl Sat Jun 30 21:12:09 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 1 Jul 2001 01:12:09 GMT Subject: PEP scepticism References: <3dbsn71iac.fsf@ute.cnri.reston.va.us> <9hj2p6$bdu$6@newshost.accu.uu.nl> Message-ID: <9hltd9$gfg$2@newshost.accu.uu.nl> Carlos Ribeiro wrote: > At 12:53 30/06/01 +0000, Guido van Rossum wrote: >>So let's all do what we do best: the core developers (e.g. PythonLabs) >>improve the language, and the community improves the library. > If you say so it's better for us all to listen . Anyway I would like > to make a distiction concerning PythonLabs work. You are not only > responsible by the language development, but you also define the reference > distribution. Improvements on the library - either by coding new modules or > optimizing existing ones - may be made by the community, as you said, but > that's not any good if these modules don't make it to the standard > distribution. Ah, just wrote my own reply making a similar point. You make some specific suggestions, good. > So I believe that PythonLabs should at least consider doing three things: > - Define clearly what goes and what does not go into the standard library. [snip] > - Help track the module development process. [snip] > - Compile the standard modules for all supported platforms. [snip] And as I suggested in my post, if standard library development is indeed not part of the primary sets of interests of the core developers, perhaps it would be good to set up an semi-formal group that *does* treat this as their 'core business' (manage core library development and perhaps even independent releases) A library-SIG, perhaps? Though I'm likely not reading Guido correctly and running way ahead of myself. In general, the idea is that perhaps we don't have hundreds of Adrew Kuchlings (to quote Tim) is because there is no place or group to attract them. A bit of a chicken and egg problem, of course. :) (apologies to Andrew :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From japh at flashmail.com Tue Jun 19 20:24:43 2001 From: japh at flashmail.com (Tyler Coumbes) Date: Tue, 19 Jun 2001 19:24:43 -0500 Subject: problems with jython Message-ID: I got jython 2.0 and am trying to run it with IBMJava2-13. I get this error *sys-package-mgr*: processing new jar, '/home/flounder/jython-2.0/jython.jar' SIGSEGV 11 (*) segmentation violation stackpointer=0xbffc1cf8 and it just keeps going at 100% cpu and doesn't stop What could cause that? -- Tyler From matt at mondoinfo.com Mon Jun 4 23:03:58 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Tue, 05 Jun 2001 03:03:58 GMT Subject: multifile and mimetools to parse email folder References: Message-ID: On Tue, 05 Jun 2001 01:39:31 GMT, rdskar1 at home.com wrote: >I want to read through an email folder (I use mutt on debian, the >'folder' is a text file) and decode the attachments. I understand how >mimetools works, but I am having trouble moving from message to >message with multifile. I think that multifile isn't meant for moving from message to message in a mailbox. It's intended for moving from part to part of a multipart MIME message. I think that the mailbox module may help you go from message to message. Once you've got a message, you'll need to determine if it's MIME-encoded and, if it is, whether it's a mutipart message, and do the right thing in each case. When I was figuring out how to do MIME decoding in Python, I found Oleg Broytmann's code very helpful. You might want to have a look in: http://phd.pp.ru/Software/Python/ Of course, you're welcome to steal from my code too. It's buried in an MUA that's at: http://www.visi.com/~mdc/swallow/ Regards, Matt From atsang at hk.linkage.net Sun Jun 10 06:23:38 2001 From: atsang at hk.linkage.net (Alan Tsang) Date: Sun, 10 Jun 2001 18:23:38 +0800 Subject: spawning unix command processes which run in parallel and simultaneously Message-ID: <9fvhqj$57m$1@news.hk.linkage.net> HI, I am learning to code with Python and I encounter a technical problem. I want to spawn a few unix command processes from a python script so that I can get the output from the unix command processes and use them in python. But I don't want to wait for the completion of one process at a time and then start another. I want the python script to start the processes simultaneously and monitor whether anyone of them have finished and if so, get the output from the finished one. It seems to me that the os and popen2 module is useful in this respect but I am not sure how to do it. Is it possible to do it in python? would be grateful if anyone can give me a reference to any documentation. Thanks From akuchlin at mems-exchange.org Tue Jun 26 09:48:54 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 26 Jun 2001 09:48:54 -0400 Subject: How useful do you find the interactive interpreter? References: <4688f24b.0106231658.43d2c446@posting.google.com> Message-ID: <3dvglj1hdl.fsf@ute.cnri.reston.va.us> We use the ZODB to store objects, so the interactive prompt becomes a query environment. Here's an example to change the owner of an object. ('opendb' is a script that sets up some useful variables and prints the introductory help message.) ludwig akuchlin>opendb database roots available: template_lib process_lib run_db user_db business_db results_db session_manager shared_cache other variables and functions: database connection root commit() = get_transaction().commit() abort() = get_transaction().abort() sync() = connection.sync() >>> r = run_db.get_run(113) >>> r.owner >>> r.owner = user_db.get_user('gward') >>> r.owner >>> commit() It's useful for making changes, or running some ad hoc query over the database. --amk From loewis at informatik.hu-berlin.de Tue Jun 5 12:40:33 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 05 Jun 2001 18:40:33 +0200 Subject: Is PyRun_String() broken? References: Message-ID: David Gravereaux writes: > >If you want the result of some computation, that computation better be > >an expression; statements don't have a result. > > Then I'll take an empty one. That's fine. Sorry, I can't follow here. An empty what? > > So you should use Py_eval_input. > I tried Py_eval_input, but I can't send it arbitrary code, such as > "import sys". I get this for doing it: Of course not. When evaluating expressions, you must pass it an expression. import is a statement, not an expression. You cannot evaluate statements - you can only execute them. > D:\itcl_exp>tclsh84 > % load tclpython20.dll > % set i [python::interp new] > python0 > % $i eval {3+4} > 7 > % $i eval {def f: pass} > python0: File "", line 1 > def f: pass This is the central problem. Your python::interp object should have two commands: exec and eval. > I'm at a loss for how to get python to accept arbitrary code, and give me a > result. You cannot. Arbitrary code does not have a result. > I can understand 'import sys' having an empty return, but I can not > accept nothing in return for 'sys.version'. Does my problem make > sense? Not if you have the Python syntax in mind. What result do you expect from sys.version print sys.argv > It looks I'll have to dig inside the node compiler or do something > very dirty to achieve what I need. I claim that you don't need to achieve this. Just give your Tcl object two different commands, for the two different syntactic forms. > I want the same concept that Perl and Tcl have for doing an eval. It seems > python doesn't have the concept of returning values for an eval of arbitrary > code using PyRun_String. Right. It can only evaluate expressions, not arbitrary code. Arbitrary code it can only execute. > Is there another function that I could try instead? No. Regards, Martin From Cayce at actzero.com Wed Jun 27 20:32:08 2001 From: Cayce at actzero.com (Cayce Ullman) Date: Wed, 27 Jun 2001 17:32:08 -0700 Subject: ANN: SOAP.py 0.9.7 Message-ID: The latest version of SOAP.py (a SOAP implementation in written in Python), was released today. We're moving the project from actzero to sourceforge. It now can be found at : http://sourceforge.net/projects/pywebsvcs/ Comments, feedback, patches, etc... very welcome. Changes since last announcement: VERSION 0.9.7 (6/27/01) - Fixed the un-named ordered parameters bug - Added the ability to specify a http_proxy - Added a patch provided by Tim MiddelKoop to allow printing of proxy objects - Added the contrib directory and included a medusa implementation of a SOAP.py server by Ng Pheng Siong VERSION 0.9.6 (6/08/01) - The date and time types now check their initial values when the type is created, not when the data is marshalled. - The date and time types are now parsed and returned as tuples (for multi-element types) or scalars (for single element types) in UTC and thus can represent the entire range of SOAP dates. - If an element doesn't have a type but has a name with a namespace, the name is tried as the type. - Untyped compound types with more than one element and all the elements the same name are turned into an array when parsing. - When parsing a structType, elements with the same name are placed in a list instead of saving just the last one. _getItemsAsList can be used to get an element of a structure as a list, whether there was one or many occurances of the item. - Added schemaNamespace, schemaNamespaceURI, and namespaceStyle configuration options. namespaceStyle takes one of 1999, 2000, or 2001, and sets typesNamespace, typesNamespaceURI, schemaNamespace, and schemaNamespaceURI. - Normalized the type class names, replacing Compound with compoundType, Struct with structType, Header with headerType, Body with bodyType, Array with arrayType, TypedArray with typedArrayType, Fault with faultType, and urType with anyType. - Attributes now appear on an element itself instead of the element's parent. For elements parsed to builtin python types, the attributes are stored in a dictionary keyed by the element's python id. The dictionary is in the Context object, can be returned from parseSOAP*, and can be returned from method calls if the returnAllAttrs configuration option is set. - isinstance is used to check for a class, so classes can be subtyped. - An encoding of None can be specified to not include encoding information. - Problems with the SOAPProxy URL are now reported when the SOAPProxy instance is created instead of when the first method call is made. - The Binary, Boolean and DateTime types have been removed in favor of binaryType, booleanType, and dateTimeType. From nperkins7 at home.com Fri Jun 15 01:38:59 2001 From: nperkins7 at home.com (Nick Perkins) Date: Fri, 15 Jun 2001 05:38:59 GMT Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> <3b266270$1_7@news5.uncensored-news.com> <9g68os0cd9@drn.newsguy.com> <3B26CD62.F89E5FA0@my.signature> Message-ID: "Greg Ewing" wrote in message news:3B26CD62.F89E5FA0 at my.signature... [ moving humans to hexadecimal..] > > We need six more digit symbols, though. Borrowing > letters was okay as an interim measure, but we need > to move on. Any proposed designs? > We could use the four symbols from that led zeppelin album, then maybe a happy-face, and the symbol formery known as the symbol representing the artist formerly known as prince. ..but i guess they would need pronouncable names, too? From rnd at onego.ru Tue Jun 26 00:18:49 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 26 Jun 2001 08:18:49 +0400 (MSD) Subject: Python scripting [was: Re: emacs speedbar for python mode?] In-Reply-To: Message-ID: On 25 Jun 2001, [iso-8859-1] Fran?ois Pinard wrote: >[Bud Rogers] > >> Roman Suzi wrote: > >> > On Sun, 24 Jun 2001, Bud Rogers wrote: > >> >> I have had similar thoughts. Imagine a programmer's editor of the >> >> calibre of [x]emacs that used python as a built in extension language >> >> in the same way that emacs uses lisp. > >> > Did you mean Cool Edit? > >> Wow. It definitely has possibilites. I'll have to get better >> acquainted. Thanks. >Once again, Cool Edit seems very interesting for most users, wanting a >tool more capable and versatile that most editors meant to be friendly, >but I would not dare comparing it with Emacs, on the caliber standpoint. Emacs is at least 2 times older than Python and is in it's 20/21's versions. No wonder it's different calibre! The question was about Python scripting editor, though. And Cool Edit _is_ programmer's editor with Python scripting. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, June 26, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "It is better to be brief than boring." _/ From dsh8290 at rit.edu Thu Jun 7 18:18:28 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 7 Jun 2001 18:18:28 -0400 Subject: Generating Multiple Class Instances In-Reply-To: <3B1FEE94.D391EDE4@fnal.gov>; from jtorborg@fnal.gov on Thu, Jun 07, 2001 at 04:13:56PM -0500 References: <3B1E9271.B05CC4E3@fnal.gov> <3B1FEE94.D391EDE4@fnal.gov> Message-ID: <20010607181827.A18014@harmony.cs.rit.edu> On Thu, Jun 07, 2001 at 04:13:56PM -0500, Julie Torborg wrote: | We have a winner! D-man's code most closely resembles what I want to do: Thanks. | > flavor_list = ['up', 'down', 'strange', 'charm', 'top', 'bottom'] | > flavor = {} | > for each in flavor_list : | > flavor[ each ] = Quark() | > | > for name , value in flavor.items() : | > print name , ":" , value.color | > | > To print out the names and their associated value. | | This way, I can also have a line: | | print flavor['up'].color | Yes. This is also quite fast because dictionary lookups are fast. | > class Quark : | > def __init__( self , name ) : | > self.name = name | > <...> | > | > flavor_list = ['up', 'down', 'strange', 'charm', 'top', 'bottom'] | > flavor = [] | > for name in flavor_list : | > flavor.append( Quark( name ) ) | > del flavor_list # not needed anymore | > | > for item in flavor : | > print item.name , ":" , item.color | | I like this too, but I think it suffers from the problem above. To access | the color of the top, I have to know the place of the "top" instance in the | list (called "topindex" below)... | | print flavor[topindex].color | | ...the whole point is so that I don't have to remember where each guy is in | the list. You mentioned that this is going to be in a GUI at some point. If you have, say, a list (gtk_list, javax.swing.JList, whatever) with all the items in it then the item would probably want to know its name. Also you would already have a reference to the object and you wouldn't need to look for it in the list. (you would ask the gui list object what item is selected when a button is pressed, or something and it would return the object back to you. You no longer need the 'flavor' list) Another alternative would be to combine the two techniques : class Quark : def __init__( self , name ) : self.name = name <...> flavor_list = ['up', 'down', 'strange', 'charm', 'top', 'bottom'] flavor = {} for name in flavor_list : flavor[ name ] = Quark( name ) del flavor_list # not needed anymore Then you could still do print flavor[ "up" ].color or you could print flavor[ "up" ].name , ":" , flavor[ "up" ].color I'm assuming the key won't be a string literal, of course ;-). -D From mwh at python.net Wed Jun 20 09:53:20 2001 From: mwh at python.net (Michael Hudson) Date: 20 Jun 2001 14:53:20 +0100 Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: <3B2EADB0.9DBC6FC8@earthlink.net> <3B2EC98E.FE0F1B6E@earthlink.net> Message-ID: Ron Stephens writes: > Sigh, sounds like we got a lot of folks, of whom I am by far the > worst, who would love to contribute. I would think the hardest part > would be to find a couple of truly competent leaders, who are expert > programmers, sort of our own mini-Linus's or Guido's. The leaders > could then moderate the "toolkit wars" and make final decisions. But bear in mind that both Guido and Linus became Benevolent Dictators by springing their open source project onto the world, not exactly fully formed, but at least in a usable state. All it takes is for someone to sit down and bang out somethign that people can play with and then improve. You do need someone with a strong architectural sense to avoid it getting unbearably crufty though. Hmm, I don't really have any plans for July... Cheers, M. -- This is an off-the-top-of-the-head-and-not-quite-sober suggestion, so is probably technically laughable. I'll see how embarassed I feel tomorrow morning. -- Patrick Gosling, ucam.comp.misc From adrian.spencer at dla.co.uk Thu Jun 21 12:19:13 2001 From: adrian.spencer at dla.co.uk (Adrian Spencer) Date: 21 Jun 2001 09:19:13 -0700 Subject: Python Developers in the UK!? Message-ID: <300e9926.0106210819.5755d5ae@posting.google.com> Does anybody know where I might be able to source Python developers in the UK. I work for a Pan European company currently looking at building their online operation in Python in a Zope application server environment. We are looking to find talented developers who wish to join a fast moving and dynamic company, however have no idea where these guys may be....please can somebody help? From gbreed at cix.compulink.co.uk Wed Jun 13 10:30:51 2001 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: 13 Jun 2001 14:30:51 GMT Subject: a newbie question about gadfly References: Message-ID: <9g7ter$iqo$1@plutonium.compulink.co.uk> In article , jm7potter at hotmail.com () wrote: > On 12 Jun 2001 15:34:16 GMT, gbreed at cix.compulink.co.uk wrote: > > >In article , > >jm7potter at hotmail.com () wrote: > > > >> Why? is namex not a direct replacement for "donna" ???? > > > >Um, no, not the way you're doing it. Try replacing that magic > >line with > > > > > >Or even > > > >cursor.execute("insert into students (name, grade) values > >(%(namex)s, %(gradex)s)" % vars()) > > > >(that's sure to wordwrap!) > > > > > > Graham > > > Thanks for the help Graham, > > However, your code did not work either. The little program chokes every > time I try to > do anything that is not "hard-wired" into the script. Oops! There is an error: cursor.execute( "insert into students (name, grade) values ('%s', '%s')" % (namex, gradex)) might be better. I forgot to quote the arguments, and at least one of them is a string. > Oddly, the books that mention gadfly do not attempt anything but > hard-wired code. > Perhaps they know something? > > Hammond & Robinson cover gadfly in their "Python: programming on Win32" > (pp. 256 > -259) but never attempt to get data from a user and send it to the > database. Oh, you have that? I think the example right at the bottom of p.257 should do what you want. In your case insertstat = "insert into students (name, grade) values (?, ?)" cursor.execute(insertstat, (namex, gradex)) Just in case that doesn't work, I ran this code on the test database as set up in the middle of p.257 >>> bar = 'guiodos' >>> drinker = 'tim' >>> perweek = 35 >>> cursor.execute("insert into Frequents(perweek, bar, drinker) values (%s, '%s', '%s')"%(perweek, bar, drinker)) >>> cursor.execute('select * from frequents') >>> print cursor.pp() PERWEEK | BAR | DRINKER ============================ 1 | lolas | adam 3 | cheers | woody 5 | cheers | sam 3 | cheers | norm 2 | joes | wilt 1 | joes | norm 6 | lolas | lola 2 | lolas | norm 3 | lolas | woody 0 | frankies | pierre 1 | pans | peter 35 | guiodos | tim > For that matter, in "Learning Python" I see that Lutz & Ascher do not > even attempt > to get user input until page 200 when as an aside to exception handling > they tell us > about raw_input. Well, they do get user input via command line > arguments, but that > can take one only so far. And raw_input can only get you so far as well, so the emphasis is on GUIs for user input. Graham From donn at u.washington.edu Mon Jun 18 12:51:32 2001 From: donn at u.washington.edu (Donn Cave) Date: 18 Jun 2001 16:51:32 GMT Subject: os.statvfs on FreeBSD References: Message-ID: <9glbik$kra$1@nntp6.u.washington.edu> Quoth "Steve Holden" : | If you don't want to run this every millisecond, you could run a "df" | command and parse the results. If it matters, verify that df output columns will not run together in case of large numbers. I have seen it happen. Donn Cave, donn at u.washington.edu From dnew at san.rr.com Sun Jun 3 21:42:38 2001 From: dnew at san.rr.com (Darren New) Date: Mon, 04 Jun 2001 01:42:38 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3B183CFF.A90213BA@san.rr.com> <9fa54s0fkb@enews2.newsguy.com> <3B1A7FEB.E466824E@san.rr.com> <9fe5q302hbg@enews2.newsguy.com> <3B1ADC37.565AEA61@san.rr.com> Message-ID: <3B1AE78E.8FED9B4C@san.rr.com> Nick Perkins wrote: > > "Darren New" wrote: > > how random is the binary string "1001010010011100100"? How random is the > > binary string "0000000000000000000"? Such questions don't make any > > sense. > > They do make sense, according to Chaitin. Well, sure, with Chaitin's definition (redefinition?) of the word "random", that makes sense. But in what sense is Chaitin's "random" different from "compressible"? Why does he use a different word when we already have a perfectly good word for it? It sounds wierd to me to say "'Pi' is more random than 'e'." Even stranger to say "'Pi' is more random than 'e' *because* they are both algorithmically calculable." But if that's how you want to redefine the word "random" then go for it. :-) This is obviously not the sense of "random" that JVN was talking about. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. This is top-quality raw fish, the Rolls-Rice of Sushi! From guido at python.org Sat Jun 30 08:53:48 2001 From: guido at python.org (Guido van Rossum) Date: Sat, 30 Jun 2001 12:53:48 GMT Subject: PEP scepticism References: <3dbsn71iac.fsf@ute.cnri.reston.va.us> <9hj2p6$bdu$6@newshost.accu.uu.nl> Message-ID: m.faassen at vet.uu.nl (Martijn Faassen) writes: > Which is why a system more or less *forcing* core developers to look > at these issues *only* for a while may be good. As the main core developer, I object to this idea and your previous post on this. Most of the needed library modules simply cannot be written by me or other core developers because they require specific application area knowledge that I don't have. (E.g. XML.) On the other hand, very few folks have the knowledge, understanding and vision to make changes to the language without breaking it. So let's all do what we do best: the core developers (e.g. PythonLabs) improve the language, and the community improves the library. --Guido van Rossum (home page: http://www.python.org/~guido/) From hamish_lawson at yahoo.co.uk Fri Jun 15 15:23:28 2001 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: 15 Jun 2001 12:23:28 -0700 Subject: Parrot-0.2.6 released References: Message-ID: <915a998f.0106151123.67a95e5d@posting.google.com> Jan Schaumann wrote: > http://use.perl.org/article.pl?sid=01/03/31/206248 > > Any connection or a coincidence? I'm guessing Parrot the GUI builder took its name from Monty Python's "Parrot Sketch", though the software's documentation doesn't seem to indicate the origin of the name. The "Parrot Sketch" is known to be the source at a later date for the name of the Parrot language (the spoof hybrid of Python and Perl that is the subject of the use.perl.org article), but I suspect without awareness of the similarly named GUI builder. Hamish Lawson From gregj at pobox.com Thu Jun 14 04:32:38 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Thu, 14 Jun 2001 08:32:38 GMT Subject: base converter References: Message-ID: "Fredrik Lundh" wrote: > def BaseConvert(x, b): > out = "" > while x: > x, d = divmod(x, b) > out = str(d) + out > return out > Slightly modified to work with bases > 10: def BaseConvert(x, b): "convert decimal number x to base b" digits = "0123456789ABCDEF" out = "" if b <= len(digits): while x: x, d = divmod(x, b) out = digits[d] + out return out Greg Jorgensen PDXperts LLC Portland, Oregon USA gregj at pdxperts.com From shredwheat at mediaone.net Tue Jun 26 02:11:58 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Tue, 26 Jun 2001 06:11:58 GMT Subject: Pygame 1.1 Released Message-ID: Pygame 1.1 Python Game Development http://www.pygame.org Released June 25, 2001 Pete Shinners pete at shinners.org Pygame is a set of python modules written to help create games in Python. The package is wrapped around SDL and several of the SDL daughter libraries. There are currently several released open source games and applications built with Pygame. Version 1.1 adds a large list of features and cleanup bugfixes. Highlights of Pygame features are listed: (items with an asterisk "*" are new for Pygame 1.1) * Full OpenGL support through pyopengl * Transform module for image scaling, rotation, and flips - Image loading from many formats, with alpha and colorkeys - Streaming music data; mp3, mod, ogg (and more) - CDROM support with audio playback - Joystick input handling - Antialiased Truetype font rendering - Multiple sound channel mixer - Cross platform (with multiple video backends on each platform) The package also comes with complete documentation, tutorials, and many playable examples. There is an active mailing list and IRC channel, which makes getting started much more accessible. Learn more about the different pygame projects finished and in development from the Projects Page. http://www.pygame.org/projects SDL is a cross-platform media library created by Loki Games. SDL is currently used for many commercial and open source game projects. Pygame takes SDL's C interface and turns it into a more pythonic package, with objects, exceptions, and other utility modules. Visit the SDL homepage for more. http://www.libsdl.org Aside from compiling and installing from source, there is also a full installer for Windows, RPM support for Linux, and a separate DEB and unofficial apt repository for Debian. For FreeBSD there is an active port available. A compressed archive with the compiled binaries is available for MacOS, and coming soon for BeOS. Pygame is distributed under the LGPL licese, which is the same license used by many its dependencies. From dale at riverhall.NOSPAMco.uk Mon Jun 25 06:30:39 2001 From: dale at riverhall.NOSPAMco.uk (Dale Strickland-Clark) Date: Mon, 25 Jun 2001 11:30:39 +0100 Subject: Freelance Python programmer required in UK Message-ID: We need an extra Python programmer to help complete a project. You need a good solid understanding of Python and experience of any of the following would be an advantage: Python on Win32 XML SOAP ADO MS SQL/Server We are based in London and have an office in Wokingham however, we'd prefer someone who could work from home most of the time. Please reply by email removing the spam protection. Thanks. -- Dale Strickland-Clark Out-Think Ltd Business Technology Consultants From cce at clarkevans.com Sat Jun 2 12:35:58 2001 From: cce at clarkevans.com (Clark C . Evans) Date: Sat, 2 Jun 2001 11:35:58 -0500 Subject: Against PEP 240 In-Reply-To: ; from rnd@onego.ru on Thu, May 31, 2001 at 11:09:15AM +0400 References: Message-ID: <20010602113558.A25579@doublegemini.com> On Thu, 31 May 2001, Tim Peters wrote: > [Roman Suzi] > > Rounding and formating is a MUST in anything nrealy financial ;-) > > So, lets not put additional burden on the Python and > > just put "%11.2f" % round(var, 2) were due. > > I doubt that's going to make Clark feel better, as I can't > imagine a context in which that code snippet would make good sense. > That's the kind of thing he's doubtless suffering from: > well-intentioned attempts to worm around problems too > dimly understood. Nod. You'd be amazed what kind of "tricks" people use to get the "right" answer. It works in the short term, but when the money is aggregated, taxes are calculated, and other numeric operations are carried out these "tiny" errors do accumulate. One "minor" mistake in an accounting program and it brings into question the data integrety of evertyhing... Further, I've seen far enough of the the above "well-intensioned" attempts to use floating point representations for currency. For me, this is the type of stuff nightmares are made of... And I am not claiming the high ground here -- in my first few years I was as guilty as the next fella. Python should not require the nasty initiation that I was faced with. ... There are two general approaches: (a) do all of your calculations in "cents", or (b) use a BCD (binary coded decimal) library. Unfortunately the former isn't always an option... for two reasons, first people don't think in cents so it makes calculations quite a bit harder. Second, for some currencies, numeric overflows are too common. Let's say the annual revenue of your company was 1.5 million dollars. This is 342,540,983,606 Lire*100. With this number, you just had an overflow if you were using long (32) bit integers (4,294,967,296) ... More and more people will be using Python for financial applications, from accounting to purchase order processing. Must we require each of these programmers, who perhaps have business degrees, to completely "grok" all of the subtleties of numeric analysis before they can write their first invoice? Certainly we could write and publish a "BCD" library... but I question how many junior programmers would know what BCD is... let alone taking active initiative to look for BCD. I'd rather have the default be some sort of BCD representation... where the programmer has to "work" to get the innaccuracy of a floating point representation. I'm not too worried about speed. If it's slow then the programmer will search the documentation to find out why. And, after some looking will stumble across the "bcd vs float" distinction and then make the 'conscious' choice to use a floating point representation and having to concern themselves with all of its idiosyncrasies. burned-one-too-many-time'ly yours, Clark From machin_john_888 at hotmail.com Mon Jun 18 18:13:16 2001 From: machin_john_888 at hotmail.com (John Machin) Date: 18 Jun 2001 15:13:16 -0700 Subject: PEP 255: Simple Generators References: <9glhg7$dlk$1@nntp6.u.washington.edu> Message-ID: <92ae279c.0106181413.5481121@posting.google.com> "Russell E. Owen" wrote in message news:<9glhg7$dlk$1 at nntp6.u.washington.edu>... > > * A generator looks like a function until you find the "yield" statement > inside. I think this will make the code much harder to read. One keyword > buried anywhere in a function totally changes its behavior. If a > generator acted like a function until it hit "yield", this wouldn't be > so bad, but it sounds as if generators have enough significant > differences (such as restrictions on and a changed meaning for return) > that they are very different beasts. > > I'd much rather see a declaration up front that this is going to be a > generator. E.g. add a new keyword such as "generator". Russell likes Tim's PEP but is worried about some details. Recursively ... What exactly are we proposing here: def generator (): or generator (): or something else? > > * The unusual use of "return" and the associated restriction of no > expression list. What "return" means in a generator is "raise StopIter", > not return. I personally really dislike using a keyword for multiple > vaguely similar purposes. Look at "static" in C++ for an example of > where this can lead. > > Several proposals come to mind. They are all compatible with each other: > > 1) Have users explicitly say "raise StopIter" when they mean it. Yes, please. > 2) Add a keyword, such as "stop". It could always raise StopIter, or > raise a new exception Stop in a non-generator and StopIter in a > generator. On the plus side, stop might be handy in other contexts. On > the minus side, I doubt it's worth the fuss. Oh, goody, goody, goody. Tears of joy. Muted shrieks of "I remember when ...". "Other contexts" could include things like: stop 10HEND OF RUN Hope [some of] this helps, John From chris.gonnerman at newcenturycomputers.net Wed Jun 27 18:22:02 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Wed, 27 Jun 2001 17:22:02 -0500 Subject: Windows Printing using win32print References: Message-ID: <009101c0ff57$98858a20$0101010a@local> ----- Original Message ----- From: "Alan Miller" > Right, but any printer that I've run into (plotters are an exception) > can take a raw ASCII data stream and print it as plain text. Postscript > or PCL are only needed if you want something other than fixed-width > Courier. Not entirely true. Many, many modern inkjet printers don't do raw ASCII. From whisper at oz.nospamnet Thu Jun 14 10:33:25 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 14 Jun 2001 14:33:25 GMT Subject: [Tkinter]: tkMessageBox Internazionalization? References: Message-ID: <9gahvl$8ft$2@216.39.170.247> In article , matt at mondoinfo.com says... > On Tue, 12 Jun 2001 17:25:17 GMT, Nicola S. > wrote: > > >Is there a comfortable way to change the text of the buttons in the > >dialog window shown, for example, by tkMessageBox.askokcancel? > > >I'd like to use another language for the text 'OK' 'Cancel'; but > >maybe this concerns tcl/tk internals. > > It seems that the text for those buttons is, as you suspect, buried in > the sources. You might find it almost as easy to use the SimpleDialog > module, which seems to be more flexible: > > >>> s=SimpleDialog.SimpleDialog(root,text="Continue?", > ... buttons=("Yes","No"),default=0,cancel=1,title="test") > >>> s.go() > 1 > > Regards, > Matt > At least on Windows, there's no way to select other then which of the buttons you do/do not want on the dialog - tkMessageBox is based on the messagebox() win32 api function (which I think inspired it's adaptation/emulation by Scriptics to other platforms). It allows you to select from a predetermined palette of icons (error, warning, information), which of the three (or four?) buttons you want up to the maximum of three buttons you can have on the dialog, a caption and the message you want to emit. Only the message text is mandatory, the rest are defaulted for you. The TkMessagebox (at least on Windows) *should* translate those button texts to the locale of the user based on which language version of Windows is being use - ymmv on X. Regards, Dave LeBlanc From xyzmats at laplaza.org Wed Jun 13 13:13:44 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Wed, 13 Jun 2001 17:13:44 GMT Subject: Working with paths with spaces in NT References: <9fol5s$9d3$3@216.39.170.247> Message-ID: <3b279eaf.5984935@news.laplaza.org> Tim wrote: >> If you look at your output very carefully, you'll discover this has nothing >> to do with spaces. After all, you chdir'ed to >> >> A Gentle Introduction to Ted Nelson's ZigZag Structure_files >> >> just fine. If that's not enough of a hint, try this starting in some deep >> directory tree that doesn't have any spacey names. >> >> don't-use-relative-paths-unless-you're-sure-you-know-where-you- >> are-ly y'rs - tim And Dave replied: >Thank you Tim for the warm and friendly help without a hint of >condescension - i'm sure it really encourages people new to python > and even more those new to programming. I missed what it was raised your hackles in Tim's comment. He pointed out that it wasn't a space problem since you've been in a directory with spaces already. The more obscure reference is that you never came out of that directory before trying to go on to the next one. You need an os.chdir('..') somewhere. -- mats Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From sdm7g at Virginia.EDU Sun Jun 24 10:14:31 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Sun, 24 Jun 2001 10:14:31 -0400 (EDT) Subject: Is this a true statement? (fwd) In-Reply-To: <3b35eec8.1798329@nntp.sprynet.com> Message-ID: I concede, David! Your logic is unassailable and your point is significant. "Uncle" I cry! -- Steve Majewski From aleaxit at yahoo.com Mon Jun 18 04:26:27 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 18 Jun 2001 10:26:27 +0200 Subject: locking dictionaries (was Re: New statement proposal for Python) References: Message-ID: <9gkdvi023oe@enews2.newsguy.com> "Tim Peters" wrote in message news:mailman.992835213.24305.python-list at python.org... > There's a PEP in here somewhere . Eric Raymond brought up similar > ideas on Python-Dev some time ago, but nothing came of it then. > > One concern: since dicts are crucial to Python's performance, we're loathe > to add any code to their critical paths, or more memory to the object. > Indeed, I spent a fair chunk of my life reducing the internal dict bloat > after 2.1 was released, and we got some nice speedups in return. Yes, I understand this MUST be an overriding concern. Practicality beats purity -- Python's speed is TOO dependent on dictionaries to allow much play with them. > Provided Guido is successful in healing the type/class split, it should be > possible to subclass dicts (in Python or C), and you can make those just as > slothful as you can bear . I think this points the way forwards. Subclassable dictionaries will at least allow real-life experimentation -- this may help determine whether some potential "further dictionary feature" is [a] of widespread-enough interest *AND* [b] susceptible of fast- enough, memory-spare implementation, to warrant considering for "REAL" dictionaries. > > A dictionary whose lockbits are set to forbid ANY rebinding, > > deleting, new-key binding, AND change to the lockbits, could > > suddenly and logically sprout hashability, since it becomes an > > acceptable key IF it has hashable values (much like a tuple -- > > if the items are changeable, the fact that the _container_ is > > not does not suffice). But that's an aside, I guess. > > Earlier talk about freezing a dict actually started in relation to Greg > Wilson's PEP to add a set type to Python. He's implementing sets as dicts > under the covers, and so sets of sets (etc) require hashing (and freezing) > dicts. I don't think we have a slick solution for that. Right now a Set > instance sets a .frozen flag when its __hash__ method gets called, and all > the mutating Set methods check that flag at the start (raising an exception > if it's set). The problem is that the flag gets lit sometimes when it > needn't be; e.g., doing > > if setA in setB: > > shouldn't freeze setA forever. So hash() is a wrong thing to key on. OTOH, Maybe setB's __contains__ could specialcase this particular issue, but it would still be there for "if setA in somedict". My un-slick, explicit-is-better-than-implicit approach would require *explicit* locking/freezing as a necessary (not sufficient -- items need to be right to) condition to make a dictionary hashable. Having __hash__ blackmagically trigger freezing sounds somewhat scary to me, just as it would if (e.g.) it made a list into a tuple or thereabouts. Alex From drew at level3.net Thu Jun 7 10:37:45 2001 From: drew at level3.net (Drew Fisher) Date: Thu, 7 Jun 2001 08:37:45 -0600 Subject: Regex error? Message-ID: <20010607083745.E10935@level3.net> Hi, I'm trying to write a python script to parse an email header for IP addresses and dates, and I keep on getting an error that says: RuntimeError: maximum recursion limit exceeded The regex is a little lengthy, but I didn't think it would be a problem: rfc822_re = re.compile ('\[(\d+\.\d+\.\d+\.\d+)\].*?\w+,\s+(\d+\s+\w+\s+\d+)\s+(\d+:\d+:\d+)\s+(\w+)') The script dies when I try to do: rfc822_test = rfc822_re.findall (rawdata) rawdata is just a string containing the entire email. The regex finds the IP address, the date, the time, and the timezone from where the email address came. Can anyone tell me what that error means, and how I could possibly get around it? Thanks, Drew Fisher From ruediger.maehl at web.de Wed Jun 27 08:24:32 2001 From: ruediger.maehl at web.de (Ruediger Maehl) Date: Wed, 27 Jun 2001 14:24:32 +0200 Subject: time module - is strptime available under NT? References: Message-ID: Dan Tropp wrote >Is this function available in the windows (NT) version? > >If not is there a commonly used alternative? Or do people just parse things >up themselves with re? > >dan > >Dan Tropp >Dept Psychology, University of Melbourne, Australia Hi Dan, no, it is not available. I am using the mxDateTime package from http://www.lemburg.com/files/python import DateTime.ISO # in the latest version you must use: # import mx.DateTime t = '2001-06-26 09:00:00' dt = DateTime.ISO.ParseDateTime(t) print dt dt is a DateTime-object and you can then apply all methods from the DateTime package. HTH, R?diger From mal at lemburg.com Sun Jun 17 14:56:02 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Sun, 17 Jun 2001 20:56:02 +0200 Subject: Writing new codecs References: <002d01c0f753$95a8ae60$445d4540@D1XYVL01> Message-ID: <3B2CFD42.262C7CDF@lemburg.com> Brian Quinlan wrote: > > > Please have a look at > > http://sourceforge.net/projects/python-codecs. There are a few > > additional codecs, and none of them extends _codecs. Each of the > > modules provides a set of codecs, not a single one. > > But these modules aren't part of core Python so there strategy will > necessarily be a bit different. > > I've looked at this project before. Hopefully all of this code will end > up as part of the Python CVS soon. We are currently planning to add the BSD style licensed codecs to the Python core CVS tree but will distribute these as separate downloads. > > Personally, I think on systems that offer iconv, the iconv codec > > should be the only one you'd ever need - although the UTF-7 converter > > is supported in gconv only starting with glibc 2.2. > > What is iconv? http://www.opengroup.org/onlinepubs/7908799/xsh/iconv.html It's basically a set of codecs with a common interface which comes with the libc on many Unix platforms. Note that Martin's Python interface for it is under GPL while iconv itself is usually under LGPL. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From boud at rempt.xs4all.nl Fri Jun 29 15:03:28 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 29 Jun 2001 19:03:28 GMT Subject: noncommercial Python+QT on Windows? (was Re: qt or gtk?) References: <9gk8he$8gl$1@brokaw.wa.com> <16074dce.0106181045.139d80a5@posting.google.com> <3b3b40a0@news.uia.ac.be> <9hfjho05to@enews1.newsguy.com> Message-ID: <9hije0$hao$1@news1.xs4all.nl> Toby J Sargeant wrote: > On Thu, Jun 28, 2001 at 05:47:03PM +0200, Alex Martelli wrote: >> Very interesting -- NOW, is there a way one can develop Python >> software, cross-platform, using Qt, and redistribute it: legally, >> for free and with sources? >> > You should have a look at PyQt. For some reason it's relatively unknown, > despite being (IMHO) the best and most elegant set of bindings for > developing GUI applications with python. > The Qt bindings are much more organised and featureful than I remember > tkinter being. They're also much more objectlike than gtk, and they > don't exhibit the windows legacy that the wx toolkit does, with all the > attendent problems of multiple dispatch from a single event, and needing > to make up magic numbers for internal events. > Apparently Phil Thompson is going to be making win32 binaries of the PyQt > modules available sometime soon, to save people who don't want to compile > it themselves some effort. > PyQt should also be available for mac development, given that Qt is free > for the mac as well, but I don't think I've ever heard of anyone trying > to build it there. I just want to add the URL for PyQt to this - http://www.thekompany.com/projects/pykde There's also work underway to rejuvenate the PyKDE bindings - binding all of KDE to Python, which is a welcome addition to the Python bindings to DCop. Lastly: Opendocs is publishing my book on PyQt, and they will be making the first version of what I've completed up to now available very soon at: http://www.opendocs.org To give an indication of the versatility of PyQt: I've nearly completed a chapter that deals with writing custom widget themes - something you cannot do in Python with any of the other GUI toolkits, to my best knowledge. -- Boudewijn Rempt | http://www.valdyas.org From s713221 at student.gu.edu.au Thu Jun 14 06:13:54 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Thu, 14 Jun 2001 20:13:54 +1000 Subject: tummy compile Mandrake 7.2 References: <20010608.214013.1469262009.16325@K7.atl.mediaone.net> <20010609.104451.1884661237.1229@K7.atl.mediaone.net> <3B24154E.C70211ED@student.gu.edu.au> <20010610.232821.1789366143.1225@K7.atl.mediaone.net> <3B25F742.F4E25C37@student.gu.edu.au> <20010612.151135.165344818.1845@K7.atl.mediaone.net> Message-ID: <3B288E62.FC946467@student.gu.edu.au> > I can't thank you enough for this generous and thorough post. I thought I > had it licked from a source install, but there are problems which I don't > have the expertise to resolve- hope you'll bear with me if I ask just a > *couple* more Q's...and yep, I got similar dependencies as above, plus a > few more. > > 1.First, install the src.rpm under /usr/src/RPM rpm -i > > python2-2.1-4.src.rpm > > > you certainly have more knowledge/success/experience than me, but > according to the advice from LM: Nah I just hack about a lot, and encountered a lot of the pitfals. Also I had a lot of experience building packages from tar.gz source - I just got sick of building and rebuilding every time I wiped out my machine so now I use rpm and save the packages. (A bit of free advice, don't touch rpm's --buildroot option as superuser without reading the docs. I managed to wipe out my entire /usr directory tree with that one.) > Building RPM's as root is dangerous, because the binary files are > installed on the system before being packaged, thus you must always build > as normal user so you won't accidentally pollute your system > > http://www.linux-mandrake.com/howtos/mdk-rpm/ > > please don't take this as criticism, it's more a question, as i haven't > seen this advice elsewhere. For all I know, building as user is part of my > problem? Most packages are "supposed" to be buildable as user or root, that's what the %defattr(-,root,root) option in the %files section is for, to ensure that the built package files have the correct owner/group settings when you install them. It is safer to build a package as user. This is where you use --buildroot and related options, but beware. At the end of a build, the --buildroot option deletes EVERYTHING in the directory you point it at. *sighs* As normal user, you just risk loosing some data. As superuser or root, you risk taking out parts of your system. That's how I wiped out my /usr partition. However, on some packages, it's very difficult for a package creator to build a spec file that will work as a non-root user. > > Now begins the hacking on the spec file. 4. Make sure you fix that > > depend to expat, not expat-devel > > still not totally clear on this, but I'll try (actually might try to > satisfy the darn thing first- generic rpm or source install) If you go to /usr/src/RPM/SPECS there should be a file called python.spec. If you open it with an editor, you'll find the following at line 41: BuildPrereq: expat-devel >= , though using python-2.1-4.src.rpm it actually reads what it should BuildPrereq: expat >= 1.1-3tummy > I'm automatically impressed with *anyone* who uses emacs :-) *chuckles* Nahh. The X-version has handy dandy menus. If you took my little Unix Pocket Book and killed my X-server, I'd be helpless. > Okay, here's my main question, and I think it goes to all the "idle" stuff > above- when I installed source build, I chose "altinstall" -obviously to > allow a non-replacement- it doesn't create a hard link to > "python" named "python". Sounds reasonable. But doing: > > [root at K7 test]# find /usr/local/lib -type f -print0 | xargs -r -0 grep "#! > /usr/bin/env" /usr/local/lib/python2.1/site-packages/idle/PyShell.py:#! > /usr/bin/env python > /usr/local/lib/python2.1/site-packages/idle/eventparse.py:#! /usr/bin/env > python/ > /usr/local/lib/python2.1/base64.py:#! /usr/bin/env python > /usr/local/lib/python2.1/difflib.py:#! /usr/bin/env python > > and *dozens* more of similar nature- they all call python, which would be > my 1.5.2, rather than the python2.1 which the install created. I can't > create a symlink, otherwise the system will call 2.1, which I'm trying to > avoid. E.g., if I run "python2.1 regrtest.py" or "./regrtest.py" from the > test directory, which ver. is running?? Perhaps after studying Python and > bash for another year I'd know for myself :-). Is this an issue? If it is, > does your method address it? This isn't really a bad question, as it goes into shell scripts and other key features of unix systems, things that will help you when you build your own programs. When you call python2.1 regrtest.py, the bash shell looks along the directories specified in your PATH variable for a file called python2.1 and then tries to execute it. If it has execute permissions set, the shell/system/kernel looks to see if it's a binary or a text file. If it's a binary, the system runs the binary, passing the rest of the words as arguments to the program, in this case regrtest.py. So in this example python 2.1 is running, and it processes the file regrtest.py. If you use this functionality, you will always get python 2.1. However, if the file is an executable text file, the shell looks to see if it can find something like this as the first line: #!/a/path/to/an/executable If it finds such a thing, it will run the program specified at this path to process the rest of the file. In your first example it will be the program env, which will execute the program python (actually a symlink to python1.5). Env is often used because bash requires an exact path to the executable, and python can shift around on the system a lot. However, it will be version 1.5 in this example. If you want a program to run on python 2.1, you will either have to specify as python2.1 *.py, or go into all the *.py files and change the first line to point to python2.1 rather than python. Annoying, ain't it? Wish the distributors would hurry up and loose python1.5 already. > I'm way cofused on the purpose of the LM rpm macros and how exactly > they're used (or not), but looks like /usr/lib/rpm/brp-compress is 'sposed > to handle that...... *shrugs* Probably. If you bounce over to the rpm home page (sorry, can't remember the URL, you'll have to use a search engine), they have a document called Maximum RPM which explains the main macros. > > 10. rpm -bb --short-circuit python-2.1.spec > > > again my ignorance probably shows, but man rpm says --short-circuit is > only valid w/ -bc and -bi......and another thing- after all that, couldn't > you find a stronger expletive than "damn"? ;-) So it does. I've always assumed that it applied. *hmmm* Maybe reading the man pages isn't always as useful as we'd like to believe. *grins* I may have to get in contact with the rpm guys and find out why. I've always found that if I don't use the --short-circuit I have to watch as the package loads, compiles and installs itself - which can be very undesirable if the build process doesn't occur automatically and I've gone and babysitted it through manually. And no. *grins* As you comment lower, this is a polite newsgroup, and I'm going to do my best to maintain that. > I'm glad this is somebody's idea of "fun"! But, good explanation of the > necessary ingredients. Python2.1 Will Get Installed on my box; maybe not > today, maybe not this week, but I'm gonna persevere! I'll post results, > hopefully positive. I know there are others who'll benefit from your post > as well- I'm seeing more Python q's on a.o.l.m.... > > kind sir, may your tracebacks be few and far between Just passing the favour forward. And what's a.o.l.m? Another python newsgroup *starts salivating* -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From PoulsenL at capecon.com Thu Jun 21 21:19:43 2001 From: PoulsenL at capecon.com (PoulsenL at capecon.com) Date: Thu, 21 Jun 2001 21:19:43 -0400 Subject: Win32 com object freezing excel Message-ID: I have a _really_ simple com server that simply passes objects called from Excel to Numpy and back. I have an inverse method to get around Excel's size limitations. This works like a charm. Then I have an eigenvalues method that freezes at times on my win95 boxes and _always_ freezes excel on nt and 2K systems. I have tried using lists and tuples but can't seem to get it to work. Any help would be greatly appreciated. Loren Here is the code snippet of the functions: class PythonNumeric: _public_methods_ = [ 'InvertMatrix', 'Eigenvalues' ] _reg_progid_ = "PythonNumeric.Utilities" # NEVER copy the following ID # Use "print pythoncom.CreateGuid()" to make a new one. _reg_clsid_ = "{3B262C80-01BA-11D5-A9ED-0010A4C3B041}" def InvertMatrix(self, MatrixIn): import Numeric import LinearAlgebra MatrixIn = MakePythonObject(MatrixIn) return ((LinearAlgebra.inverse(Numeric.array(MatrixIn))),) def Eigenvalues(self, MatrixIn): import Numeric import LinearAlgebra MatrixIn = MakePythonObject(MatrixIn) return (((LinearAlgebra.eigenvalues(Numeric.array(MatrixIn))),),) # Add code so that when this script is run by # Python.exe, it self-registers. if __name__=='__main__': print "Registering COM server..." import win32com.server.register win32com.server.register.UseCommandLine(PythonNumeric) From aleaxit at yahoo.com Thu Jun 14 06:27:36 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 12:27:36 +0200 Subject: Python grammar.. References: Message-ID: <9ga3j302j5k@enews1.newsguy.com> "D-Man" wrote in message news:mailman.992488760.27134.python-list at python.org... ... > | > Yes, but if I were designing a language today, I think I would > | > request you to be EXPLICIT about "ignoring the return value" -- > | > explicit is better than implicit. It IS an occasional cause of > | > errors in Python (particularly with newbies) that an expression > | > statement's value is silently and implicitly ignored... ... > | So you would prefer that functions whose return value is ignored must be > | called with a keyword ... such as in VB > | > | call aFunction() > > or > > (void) aFunction() ; > > | Personally, I absolutely hate this. > > Not any better ;-). I'm talking about a hypothetical language design issue, of course. Let's assume that expression-statements are part of it -- any expression is a syntacticaly valid statement. Now, the issue becomes: what to do with the VALUE, if any, of that expression. Python silently throws it away, as do C and C++. I do not particularly like that, for all that I'm used to it after almost 20 years of C'ing. A Python *interactive session* print the value's repr AND saves it to __builtin__._ -- now THAT is good, and you can also tweak it with sys.displayhook, which is even better. But the stark split between the behaviour of interactive sessions and running a script is confusing indeed to newbies. One (IMHO) sensible alternative might be to generalize the use of sys.displayhook (perhaps by some other name:-). The language specs might be: expression statements are allowed; when an expression statement returns a value != None, then sys.whateverhook is called with that value as its only argument. The issue now becomes just one of having the whateverhook you want. One with a body of 'pass' would make most old hands happy, one like the one the interactive interpreter uses now might make sense for debugging, etc. If you DON'T want the whateverhook to be called for a given expression statement that might return a not-None result, just turn the expression statement into something else, e.g _=myfunkyfun() or, for keyword-lovers, we might make 'pass' accept an optional argument:-)...: pass myfunkyfun() The point of this design decision would be that, IF myfunkyfun() returns something, there's supposed to be a POINT to that value... the DECISION to ignore the value anyway should be just that, a *DECISION* -- and explicitly expressed in the code (by assigning the value to a sink-variable like _, or whatever:-). Oh well, it IS all hypothetical anyway!-) Alex From tdickenson at devmail.geminidataloggers.co.uk Mon Jun 25 05:18:43 2001 From: tdickenson at devmail.geminidataloggers.co.uk (Toby Dickenson) Date: Mon, 25 Jun 2001 10:18:43 +0100 Subject: PEP 255: Simple Generators References: <20010621134445.B20524@glacier.fnational.com> Message-ID: Glyph Lefkowitz wrote: >If generators are >implemented as a syntax feature, then microthreads are implemented as a >module (or should we have syntax for that too? 'task' anyone?) then we're >again falling prey to a sin of perl; there will be more than one way to do >it. In todays python there are two ways to create a class. The simple way is to use the 'class' statement. Alternatively if you need more under-the-covers control, use the 'new' module. Im not sure if that a useful analogy or not. Toby Dickenson tdickenson at geminidataloggers.com From tim.one at home.com Fri Jun 8 18:24:09 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 8 Jun 2001 18:24:09 -0400 Subject: Keyword argument parsing in error in 2.0? In-Reply-To: Message-ID: [Steve Holden] > ... > c.UNION(c.SELECT(["l.beer", "l.drinker", ["count(distinct s.bar)", > "nbars"]], > FROM=[["likes", "l"], ["serves", "s"]], > WHERE="l.beer=s.beer", > REST="group by l.beer, l.drinker"), > c.SELECT("distinct beer, drinker, 0 as nbars", > FROM="likes", > WHERE="beer not in (%s)" % > c.SELECT("beer", > FROM="serves")), > REST="order by 3 desc") > > This validates fine in PythonWin, but when the module containing it is > executed I get: > > Traceback (most recent call last): > File "alltest.py", line 396, in ? > REST="order by 3 desc"), > TypeError: keyword parameter redefined: REST If you count your parens , I think you'll discover that the indentation on the final REST is misleading; clearer is: WHERE="beer not in (%s)" % c.SELECT("beer", FROM="serves")), REST="order by 3 desc") and that explains why it thinks you specified REST twice: you did . PythonWin (or IDLE) should have shown you that when you hit ENTER on the preceding line, though (they use the same auto-indent algorithm under the covers, and it aligns the new line under WHERE). From mwh at python.net Tue Jun 5 15:24:14 2001 From: mwh at python.net (Michael Hudson) Date: 05 Jun 2001 20:24:14 +0100 Subject: How do you develop in Python? References: <050620011516094693%pecora@anvil.nrl.navy.mil> Message-ID: Lou Pecora writes: > I program in Python occassionally and would like to do more of it. But > here's a development conundrum I run into a lot (there are more complex > examples, but I'll give an easy one). I am developing module A.py > which imports B.py in the IDE. I am running test code which is also in > A.py as I incrementally develop A.py. Then I need to change B.py and, > of course, the import does not import the new changes since import only > works once. Hence, to "refresh" B.py I have to quit the IDE and > restart, open A.py and run. This is clumsy. However, the above > scenario is not uncommon and more complex interdependencies of modules > appear to make it unavoidable. Anyone know a way to get around this > "import" problem? I know there is a "reload", but then I have to > import and change my modules' code to "reload" or something each time I > work with them. Any help appreciated. If module A.py goes import B ... uses B ... and then in the top-level you type >>> import A >>> import B then change B.py then in the top-level typing >>> reload(B) modifies B in place, so code inside A should get the new version of the module. This doesn't work if you've used from B import ... in A; then you need to reload A too. I don't see where you get the > Hence, to "refresh" B.py I have to quit the IDE and restart, open > A.py and run. but I'd have to admit that I don't use the MacPython IDE, so I might be missing some specific detail of that implementation. But I don't think so. Cheers, M. -- . <- the point your article -> . |------------------------- a long way ------------------------| -- Cristophe Rhodes, ucam.chat From pmoscatt at bigpond.net.au Sat Jun 9 17:10:31 2001 From: pmoscatt at bigpond.net.au (Peter Moscatt) Date: Sat, 09 Jun 2001 21:10:31 GMT Subject: TIX - How to envoke ?? References: <3b22769c.23626780@nntp.ix.netcom.com> Message-ID: Thanks Mike... so I take it as, yes I just need to use the "import Tix" command providing I am using Python 2.1. Is this correct Mike ?? Pete Mike Clarkson wrote: > On Fri, 08 Jun 2001 11:50:33 GMT, Peter Moscatt > wrote: > >>I have just recently succeeded in installing Tix 8.2 and have tested it >>through the SHELL. >> >>Under KDE I use the "ActiveState Komodo" interpreter. >> >>I am not too sure how I let Komodo know that there is now a Tix module to >>be used. >> >>Is it just a matter of using: >> >> import Tix >> > > Should be if your Komodo is Python 2.1 based. > > Mike. > From grante at visi.com Mon Jun 4 11:48:24 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 04 Jun 2001 15:48:24 GMT Subject: Using SMTPlib. References: <9fg9hd$l27$1@news.inet.tele.dk> Message-ID: In article <9fg9hd$l27$1 at news.inet.tele.dk>, Brian Andersen wrote: >Hi. > >I'm in the process of writing my very first project in Python - a webmail >application. >I've tried the SMTPlib and it work out fint, but the mails I send don't have >a subject. > >I've tried the example that is in the Pythondocumentation for the SMTPlib >and it works well, but how do I insert a subject field? > >The same goes for CC end BCC-fields. Are they handled by the SMTPlib or is >it something that I must handle in my program? SMTPlib doesn't do anything except SMTP. The headers you're talking about are part of the message content that is ignored by the SMTP protocol. The MimeWriter module is very handy for actually creating the message before you use SMTPlib to send it. Mimewriter has methods to add headers, add attachements, etc. -- Grant Edwards grante Yow! I smell like a wet at reducing clinic on Columbus visi.com Day! From skip at pobox.com Thu Jun 14 17:24:35 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 14 Jun 2001 16:24:35 -0500 Subject: bsddb: must bsddb write a file ? In-Reply-To: <3B29165E.102550FD@netlcr.de> References: <3B28D465.229D7BF7@netlcr.de> <3B29165E.102550FD@netlcr.de> Message-ID: <15145.11155.731043.717233@beluga.mojam.com> Florian> bsddb used as a binary- tree has a .last()-methode to get the Florian> element with the biggest key. there is no such funktion in the Florian> build in hash-table. that was the reason switching to bsddb Alphabetically biggest or longest? If you mean alphabetically, this should work: keys = dict.keys() keys.sort() keys[-1] If you mean the longest key, this should work: keys = dict.keys() keys.sort(lambda x,y: (cmp(len(x),len(y) or cmp(x,y)))) keys[-1] Both only have meaning if you are using strings as keys. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From jimhill at meldrick.swcp.com Fri Jun 15 11:05:20 2001 From: jimhill at meldrick.swcp.com (Jim Hill) Date: 15 Jun 2001 15:05:20 GMT Subject: VI References: <3B278900.5828FB59@Lugoj.Com> <9gaunm$mth$3@brokaw.wa.com> Message-ID: In <9gaunm$mth$3 at brokaw.wa.com>, Jonathan Gardner wrote: >James Logajan wrote: >> "vi" is the first and last word in visual editors. Every editor written >> before or after it are irrelevant. ;-) > >Amen. And since the expected editor war hasn't broken out, I'll launch a different offensive by proclaiming absolutely and without room for disagreement that it is pronounced "vee eye" and those who say "vye" are bloody peasants who should be repressed by the violence inherent in the system. Jim -- jimhill at swcp.com http://www.swcp.com/~jimhill/ "Let me preface my remarks by saying that I have absolutely no love for Barry Manilow in my heart." -- Jason Lempka From xyzmats at laplaza.org Mon Jun 18 19:07:07 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Mon, 18 Jun 2001 23:07:07 GMT Subject: nested classes References: <3B2E2D3A.75F329D@sympatico.ca> <9glchv$kcm$1@plutonium.compulink.co.uk> <3B2E4725.535AB18E@sympatico.ca> Message-ID: <3b2e8989.32036776@news.laplaza.org> On Mon, 18 Jun 2001 13:23:33 -0500, Stefan Seefeld wrote: >gbreed at cix.compulink.co.uk wrote: > >> > What am I doing wrong ? The above is possibly a bit driven >> > by my C++ programming style. What is the python way of doing >> > this ? >> >> You can get that to work in C++? It looks strange to me, I'm >> sure you can't be trying to do what you think you're trying to >> do. This is the nearest I can think of that works: > >uh, what do *you* think that I'm trying to do, then ? :) > >What I'm arguing about is a matter of name resolution. I sure >can open a scope 'A' in C++, insert a new scope 'B' into it, >and from within that access other symbols declared in scope 'A'. >In fact, I don't need to qualify them (i.e. 'foo' instead of 'A::foo' >for any symbol 'foo' in the scope 'A' is just fine) if I'm inside >that scope, no matter how deeply nested (of course, as long as there >are no ambiguities). Java and C++ are compiled. The class definition is instructions to the compiler, and can be self-referential, because the /reference/ is not going to happen until the class is loaded - no inconsistency. Not so for Python, the class definition is code that is actually run to build the class object, and before that object has been built, there's nothing to refer to yet, as Alex said. From clpy at snakefarm.org Mon Jun 25 09:28:20 2001 From: clpy at snakefarm.org (Carsten Gaebler) Date: Mon, 25 Jun 2001 15:28:20 +0200 Subject: Scripts (running once) References: <3B37271F.759B0236@usa.net> Message-ID: <3B373C74.AA4284A4@snakefarm.org> Olaf Trygve Berglihn wrote: [how to keep a program from running more than one instance simultaneously] > #!/usr/bin/env python [...] > if os.path.isfile(LOCKFILE): > import sys > sys.stdout.write("Already running myprog\n") > sys.exit(1) > else: > fd = open(LOCKFILE, 'w') > fd.close() [...] This will not really work if the two processes are *started* at the same time. I.e. process 1 calls isfile() which returns 0. Then the OS switches to process 2 which also get a 0 from isfile(). You'll end up with two processes running at the same time. Better really lock the file by calling fcntl.flock() right after open() (blocking or nonblocking, whatever is suitable), or by storing the process id in the lock file and checking if that process id is still hanging around (e.g. via /proc on Unix). cg. From michael+gnus at trollope.org Thu Jun 21 13:39:51 2001 From: michael+gnus at trollope.org (Michael Powe) Date: 21 Jun 2001 10:39:51 -0700 Subject: namespace issue? Message-ID: Hello, This looks like a namespace issue described in but it doesn't make sense to me and I don't know how to fix it. ex 1: >>> def GetNum(): ... AC = raw_input("Area Code: ") ... PN = raw_input("Phone Number: ") ... if not AC : AC = '503' ... if not PN : PN = '000-0000' ... Ph = AC + PN[:3] + '-' + PN[3:] ... return Ph ... >>> ok = GetNum() Area Code: 503 Phone Number: 2243187 >>> ok '503224-3187' ex 2: >>> def GetNum2(): ... AC = raw_input("Area Code: ") ... PN = raw_input("Phone Number: ") ... if not PN : PN = '000-0000' ... if not AC : AC = '503' ... if len(PN) < 8 and not string.find(PN,'-'): ... Ph = PN[:3] + '-' + PN[3:] ... return Ph ... >>> ok = GetNum2() Area Code: 434 Phone Number: 2243187 Traceback (most recent call last): File "", line 1, in ? File "", line 8, in GetNum2 UnboundLocalError: local variable 'Ph' referenced before assignment The issue is, I don't understand why the problem appears with variable 'Ph' in the second instance but not in the first. It seems obvious that it comes about because of the conditional. Also, on a side note, what is the default data type for input gathered from raw_input()? Is it a string? Thanks for any help. mp From kbk at shore.net Wed Jun 6 21:26:33 2001 From: kbk at shore.net (Kurt B. Kaiser) Date: Thu, 07 Jun 2001 01:26:33 GMT Subject: Learning OOP... References: Message-ID: <3B1ED772.56C9DFC3@shore.net> Rod Weston wrote: > > Trying to decide which language to learn first. I have programming > experience in PICKBASIC and now want to learn OOP.At this point, I am > leaning toward learning Ada and then Python. Any ideas on why I > should or should not use these languages in this sequence? Yes, I agree with Alex. Definitely Python first. You'll like it because you can get things done quickly, but with a much wider scope than Pick, which is a great language for business apps with its query language and multi-dimensional files, but w/o objects. If you want to get a theoretical understanding of OOP, Eiffel is very clean and actually quite straightforward, but so far has not caught on commercially, unfortunately. Meyer is making another run at it via .NET. Meyer's book, OOSC, is good, but he keeps shooting himself in the foot by not making a free ISE system available for beginners... http://www.elj.com/eiffel/why-eiffel/ From rnd at onego.ru Tue Jun 26 14:47:28 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 26 Jun 2001 22:47:28 +0400 (MSD) Subject: PEP 260: simplify xrange() In-Reply-To: <200106261759.f5QHxtH15045@odiug.digicool.com> Message-ID: On Tue, 26 Jun 2001, Guido van Rossum wrote: >PEP: 260 >Title: Simplify xrange() >Version: $Revision: 1.1 $ >Author: guido at python.org (Guido van Rossum) >Status: Draft >Type: Standards Track >Python-Version: 2.2 >Created: 26-Jun-2001 >Post-History: 26-Jun-2001 > >Proposed Solution > > I propose to strip the xrange() object to the bare minimum. The > only retained sequence behaviors are x[i], len(x), and repr(x). What about str(x)? Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, June 26, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "It is better to be brief than boring." _/ From pmoscatt at bigpond.net.au Mon Jun 18 07:44:18 2001 From: pmoscatt at bigpond.net.au (Peter Moscatt) Date: Mon, 18 Jun 2001 11:44:18 GMT Subject: Setting Dialog Box Captions ?? Message-ID: How does one place a "Title" in the master frame ? For example, if I was to have the following code: from Tkinter import * root=Tk() w=Label(root, text="Hello World") w.pack() root.mainloop() And now I wanted to place "This is My Test Dialog" as the caption for the root frame - how would I doo this ? Regards Pete From brendhanhorne at bellsouth.net Wed Jun 20 14:07:11 2001 From: brendhanhorne at bellsouth.net (Brendhan Horne) Date: Wed, 20 Jun 2001 14:07:11 -0400 Subject: raw_input Message-ID: <_x5Y6.18111$9r1.1628947@e3500-atl1.usenetserver.com> >>> raw_input ("Enter your name:") Enter your name:Brendhan 'Brendhan' >>> print name Traceback (innermost last): File "", line 1, in ? print name NameError: There is no variable named 'name' Okay What did I do wrong it should have printed my name after the print name command. -- Thanks, Brendhan -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GE d- s: a C++ U(++) P(++) L+(++) E- W+ N+ o+ K- w+ O+ M V? PS+ Y PGP(++) t++ 5++ X- R+++ tv++ b+++ DI++ D G(++) e+(++) h-- r++ y++* ------END GEEK CODE BLOCK------ From dkuhlman at rexx.com Sat Jun 9 14:18:49 2001 From: dkuhlman at rexx.com (Dave Kuhlman) Date: Sat, 09 Jun 2001 18:18:49 -0000 Subject: WHY is python slow? References: Message-ID: <992110734.956795@rexx.com> On "how it can be that generally accepted beliefs are often divorced from reality", look at John Kenneth Galbraith, The Affluent Society, Chapter 2, "The concept of conventional wisdom". After reading that, you walk around wondering why everyone else is less intelligent than you are. It takes a long time for reality and facts to dislodge generally accepted beliefs, if for no other reason than that lots of people have a vested interest in the preservation of those beliefs. Specifically, look at the huge investment in Java. It will take a whole lot of reality to convince those who have invested their time and money to give that up. I used to be a philosophy student, but I'm trying to rehabilitate myself. - Dave Tim Peters wrote: > > [Steven Haryanto] >> Although it is generally accepted that Python is slower than >> Java/Perl/Ruby, a layman like me would be curious to know why >> exactly this is so. > > Me too, although philosophers and historians have been puzzling for > centuries over how it can be that generally accepted beliefs are often > divorced from reality. I guess it's for the same reasons that Python has > significant whitespace just like Fortran's, Lisp is slower than Visual > Basic, C++ adds nothing to C that can't be done just as well with > preprocessor macros, functional languages can't be used for real work, and > that at least one of {Linux, NT} is a great operating system . > > there's-no-accounting-for-mass-delusion-ly y'rs - tim > > -- Dave Kuhlman dkuhlman at rexx.com From duncan at NOSPAMrcp.co.uk Mon Jun 25 03:47:19 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Mon, 25 Jun 2001 07:47:19 +0000 (UTC) Subject: NT Service and COM References: <9gu4nf$553$1@troll.powertech.no> <3B3374C8.D3EA315B@ccvcorp.com> Message-ID: Jeff Shannon wrote in news:3B3374C8.D3EA315B at ccvcorp.com: > > > Syver Enstad wrote: > >> Yes, but that ain't doesn't expose no COM server. If you ever find out >> Duncan I'd be really pleased to hear what you've figured out. I've >> only come so far as to look at the .py file that implements local >> servers for python. Take a look at win32com.server.localserver.py to >> see how vanilla pythoncom objects are exposed like a localserver. > > What would probably work best, is writing the COM server, then writing > a Service that creates and makes use of the COMserver... though of > course this depends on your exact requirements. I wouldn't *think* > that there's any special tricks to combining these. Just have your > SvcDoRun() instantiate the COM object before moving into its main > loop.... I don't actually want the service to use the COMserver, just to make an object available to processes outside the service so that they can communicate with it. This involves setting some extra registry keys, and putting the loop from localserver.py into SvcDoRun, or into another thread created for the purpose within the service. -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From barry at digicool.com Mon Jun 4 23:29:36 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Mon, 4 Jun 2001 23:29:36 -0400 Subject: multifile and mimetools to parse email folder References: Message-ID: <15132.21024.852319.519045@anthem.wooz.org> >>>>> "r" == rdskar writes: r> I want to read through an email folder (I use mutt on debian, r> the 'folder' is a text file) and decode the attachments. I r> understand how mimetools works, but I am having trouble moving r> from message to message with multifile. I have been trying r> various combinations off multifile push, pop and readline r> methods, but I haven't hit on the right combinations. My standard answer is to use mimelib :) I'm pushing for mimelib to be included in Python 2.2. Although I have some work piled up (good suggestions from other users) waiting for me to deal with, I'm successfully using mimelib 0.3 in the Mailman 2.1 alpha. From personal experience, I'd say it's a dang sight easier to use than mimetools+multifile! For now, http://mimelib.sourceforge.net Please let me know what you think. I'm open to suggestions. Cheers, -Barry From thomas.heller at ion-tof.com Fri Jun 29 02:39:01 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Fri, 29 Jun 2001 08:39:01 +0200 Subject: New project: anygui References: <9hg7fg$dmg$1@tyfon.itea.ntnu.no> Message-ID: <9hh7ml$e1pje$1@ID-59885.news.dfncis.de> "Magnus Lie Hetland" wrote in message news:9hg7fg$dmg$1 at tyfon.itea.ntnu.no... > > Hi! > > This is an attempt to revive the efforts of making a > "standard" Python GUI. Great! Has long been on my wishlist... > I realise that standardising > one as preferable to others might not be desirable, > and that is not the purpose of this project. The > purpose is to build a pure Python package called > anygui which will function in a manner similar to > anydbm in that it will look for existing backends, > and use what is available. > > A simple API must be decided on which will be compatible > with all back-end candidates, somewhat in the spirit of > Sping and Piddle. Therefore, this will not be mean > as a replacement for these back-ends, merely a simple > front-end. > > I suggest using Greg Ewing's Python GUI API as a > starting-point: > http://www.cosc.canterbury.ac.nz/~greg/python_gui/ > > For a first release, a subset may be usable. > > Backends that (at least) should be supported: > > - Tkinter > - wxPython > - Java (AWT and/or Swing) > > ... and hopefully many others. (Those of you out there > who have a package you love may want to step up and make > it compatible with anygui... :) Greg is himself working > on an X-windows implementation of the API. I would (as I said before) be willing to implement a native windows version. > > The project is available at: > http://sourceforge.net/projects/anygui > > A mailing-list called anygui-devel has been set up and > should be activated within a matter of hours. All > developers and other interested individuals are welcome. > The GUI SIG is no more - but it is my opinion that Python > needs a standard GUI package, even if it is a simple > one (perhaps _especially_ if it is a simple one). > Thomas From rnd at onego.ru Wed Jun 27 11:57:46 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 27 Jun 2001 19:57:46 +0400 (MSD) Subject: regex scanner question In-Reply-To: <9hcrub$ckcs2$1@ID-11957.news.dfncis.de> Message-ID: On Wed, 27 Jun 2001, Emile van Sebille wrote: Ok, now it is clear: static PyMethodDef pattern_methods[] = { {"match", (PyCFunction) pattern_match, METH_VARARGS|METH_KEYWORDS}, {"search", (PyCFunction) pattern_search, METH_VARARGS|METH_KEYWORDS}, {"sub", (PyCFunction) pattern_sub, METH_VARARGS|METH_KEYWORDS}, {"subn", (PyCFunction) pattern_subn, METH_VARARGS|METH_KEYWORDS}, {"split", (PyCFunction) pattern_split, METH_VARARGS|METH_KEYWORDS}, {"findall", (PyCFunction) pattern_findall, METH_VARARGS|METH_KEYWORDS}, /* experimental */ {"scanner", (PyCFunction) pattern_scanner, METH_VARARGS}, {NULL, NULL} }; Thus, scanner method is experimental! I hope, it will do it into production. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Wednesday, June 27, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "No sense being pessimistic. It wouldn't work anyway." _/ From bmstroh at cavtel.net Wed Jun 13 23:49:01 2001 From: bmstroh at cavtel.net (Brent Stroh) Date: Wed, 13 Jun 2001 23:49:01 -0400 Subject: ftplib only posting 52 bytes? Message-ID: <9mcgitkhpmkcrql5uhk5bsi94q8nquo4em@4ax.com> I've put together a small script to resize digital pictures, rename them, and upload them to a web server. It also generates a portion of the HTML necessary to incorporate them into a web page. This script is installed as a right-click option under WinME. I can right click a JPG file, and 'Webify' the picture. The resizing (via PIL) works great; the HTML is generated like it should be. Today, I added the FTP step, figuring it would save me a few minutes to kick the transfer off in the background. It appears the first 52 bytes of each image is transferred to the server; what is sent appears to be the beginning of a JPG file. As this is my first useful piece of Python, I'm interested in how to improve it overall, not just in correcting the FTP section. (This is ActiveState Python 2.1, build 210, using PIL 1.11 for Python 2.1a, on WinME.) I'd appreciate CC's of any usenet response; my news provider has been having issues with missing posts for a week or so. #!/usr/bin/python import os, re, string, sys import Image from ftplib import FTP def write_html(filename, height, width): widtht = repr(int(width)) heightt = repr(int(height)) fp = open(dest + "../list.html", "a") fp.write("
\n") fp.write(montht + " " + dayt + ", " + yeart + "

\n\n") fp.close return def send_file(filename): ftp = FTP('server', 'user', 'pass') ftp.set_pasv(0) ftp.cwd('/home/bmstroh/public_html/images') print dest + filename fp = open(dest + filename) ftp.storbinary('STOR %s' % filename, fp, 1024 * 16) ftp.quit() return dest = "c:/taylor/web/images/" # dest = "d:/cd-rom/personal/taylor/web/images/" thisdir = os.path.basename(os.getcwd()) months = { 'January': '01', 'February': '02', 'March': '03', 'April': '04', \ 'May': '05', 'June': '06', 'July': '07', 'August': '08', \ 'September': '09', 'October': '10', 'November': '11', \ 'December': '12' } pattern = re.compile("([A-Z]{1,1}[a-z]*) ([0-9]{2,2}), ([0-9]{4,4})") result = pattern.match(thisdir) if result == None: print "Hmm. No match" sys.stdin.readline() sys.exit() month = result.group(1) day = result.group(2) year = result.group(3) montht = month dayt = repr(string.atoi(day)) yeart = year month = months[ month ] year = year[-2] + year[-1] prefix = year + month + day + "_" for infile in sys.argv[1:]: infile = os.path.basename(infile) infile = string.upper(infile) pattern = re.compile("^([0-9]{2,2})$") result = pattern.match(infile) if result == None: pass else: infile = "IMAGE" + infile + ".JPG" pattern = re.compile("^IMAGE([0-9]{2,2})\.JPG") result = pattern.match(infile) if result == None: print "Hmm - can't match either expression" sys.stdin.readline() sys.exit() filename = prefix + result.group(1) + ".jpg" outfile = dest + filename if infile != outfile: try: im = Image.open(infile) (width, height) = im.size if width > height: scale = width / 320.0 else: scale = height / 320.0 width = width / scale height = height / scale im.thumbnail((width, height)) im.save(outfile, "JPEG") write_html(filename, height, width) send_file(filename) except IOError: print "cannot create thumbnail for", infile pause = sys.stdin.readline() From piet at cs.uu.nl Fri Jun 8 07:34:45 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 08 Jun 2001 13:34:45 +0200 Subject: Windows editor? References: <3af2c38f.341431824@News.CIS.DFN.DE> <3B1F345B.4E04FDE9@rk-speed-rugby.dk> <9fo167$j1v$1@reader1.imaginet.fr> Message-ID: >>>>> "Sgluarb" (S) a ?crit: S> Scite (really good !!) S> www.scintilla.com Nice try, but http://www.scintilla.org/ may be more what you want. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From gerhard.nospam at bigfoot.de Mon Jun 25 14:15:29 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Mon, 25 Jun 2001 20:15:29 +0200 Subject: Question re: PyApache References: <3b36a3a8.369556684@news1.on.sympatico.ca> Message-ID: On Mon, 25 Jun 2001 02:38:13 GMT, Ken wrote: >Hi, > >I was wondering if anyone out there has any experience with PyApache >(python embedding module for Apache 1.3.x). I installed it, and it IS >running (using the DSO module). However, I wanted to make sure it was >running off python 2.1 (/usr/lib/python2.1/) instead of the old distro >version (/usr/lib/python1.5). > >Is there an easy way to find out? print sys.version no a HTML page generated by PyApache? >And if it is running off 1.5.2, is there a way to switch it over? I don't know about PyApache, but hacking the Makefile to find the correct Python headers and libraries always helps in such cases. Gerhard PS: modpython and modsnake are newer attempts at integrating Python interpreters into Apache. PyApache has some memory leaking problems, IIRC. -- mail: gerhard bigfoot de registered Linux user #64239 web: http://highqualdev.com public key at homepage public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From wart at softhome.net Tue Jun 5 06:36:55 2001 From: wart at softhome.net (Wartan Hachaturow) Date: 05 Jun 2001 14:36:55 +0400 Subject: Programming ASP with ActivePython [also a general Web question] References: <87lmn8fdmi.fsf@penguin.aktivist.ru> Message-ID: <87u21vyzzs.fsf@penguin.aktivist.ru> >>>>> "Thomas" == Thomas Weholt writes: Thomas> posted the fix also referenced to here, I installed Apache and Thomas> mod_python. Both available on Win and *nix. Works perfect. The Thomas> old-fashion-way of mixing code and content ( ASP, JSP, PHP, PSP Actually, I like mod_python also for its simplicity and speed. But the lack of "infrastructure" really upset me. Right now I've sat down and started writing a little library of the needed things to start developing with mod_python (sessions is the first thing I need :), along with html templates and database wrappers). -- Wartan. ...she made you tea, ask for your autograph...What a laugh!... From tim at digicool.com Thu Jun 21 17:54:31 2001 From: tim at digicool.com (Tim Peters) Date: Thu, 21 Jun 2001 17:54:31 -0400 Subject: Bitwise 'AND' error? In-Reply-To: <5c8ecb0b.0106211340.59aeee39@posting.google.com> Message-ID: [Rich J] > Could someone please explain to me why this is giving these results. > This is taken directly from the python interpreter. > > >>> long = 0x2964619C7L > >>> mask = 0xFFFFFFFF > >>> ling = long & mask > >>> print 'new number = %#x' % ling > new number = 0x2964619c7 > >>> ling > 11111111111L > >>> long > 11111111111L > >>> > > Why would 'anding' with this mask give back the same number? It should > have given back 0x964619C7, right? Or am I losing my mind? No, you're running on a 32-bit machine and mixing unbounded ints with 32-bit ints. Mask is -1, and in "long & mask" mask has to be converted to long first; long(-1) == -1L, i.e. mask is coerced to a (conceptually) infinite string of 1 bits. Do mask = 0xFFFFFFFFL ^ instead. From hinsen at cnrs-orleans.fr Mon Jun 25 05:00:07 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 25 Jun 2001 11:00:07 +0200 Subject: Numpy Array indexing question References: Message-ID: "Pugsley" writes: > I accidentally found that a[i][j][k] worked just like a[i,j,k] for > indexing a Numpy array. But I couldn't find it mentioned any where in the > Numeric pdf doc. Is it ok to use that syntax? Thanks. Yes. In fact, if you look at the definition of what a[i] does, and apply this definition three times, then you will see that a[i][j][k] must be equivalent to a[i,j,k]. However, the latter should be a bit faster (I didn't check), because only one indexing operation is performed. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From new_name at mit.edu Sat Jun 23 12:30:57 2001 From: new_name at mit.edu (Alex) Date: 23 Jun 2001 12:30:57 -0400 Subject: emacs speedbar for python mode? References: <9h24tq$f7b$1@news1.xs4all.nl> Message-ID: When I run speedbar in a python file foo.py, I just get a new frame with the buffer for foo.py. How are you supposed to use it? Alex. From heinlr at gmx.de Mon Jun 11 05:16:30 2001 From: heinlr at gmx.de (ssh) Date: Mon, 11 Jun 2001 11:16:30 +0200 Subject: import sys.argv[1] References: Message-ID: <9g2219$31ha$1@wrath.news.nacamar.de> look source code: # so something str = "import mySuperModul" exec( str ) # executes a complete individual command or mod = __import__("mySuperModul") func = getattr(mod, "myFunc_in_SuperModul") # func( 1, 2 ,3 ....) i hope it helps "Ben" schrieb im Newsbeitrag news:gor8itchcafd4t82fnheo0s4g9frfipdhv at 4ax.com... > Hi all, > > this must have been a situation that lots of people have come across > so there has to be a work around for it. If I define via a command > line arg what module(s) needs to be imported how do i then pass this > to the import statement without the import statement taking > > sys.argv[1] > > literally? > > Thanks > > Ben > From ullrich at math.okstate.edu Fri Jun 22 09:54:07 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Fri, 22 Jun 2001 13:54:07 GMT Subject: Properties in Python References: <3b31ebb9.553666@nntp.sprynet.com> Message-ID: <3b334c70.379793@nntp.sprynet.com> On Thu, 21 Jun 2001 23:43:37 -0700, Tim Roberts wrote: >"Steven D. Majewski" wrote: >> >>On Thu, 21 Jun 2001, David C. Ullrich wrote: >> >>> It's curious, the guy who wrote C# seems to be a fan >>> of Object Pascal, aka Delphi... (maybe there's a >>> simple explanation for that) >> >>I believe that they guy microsoft hired to do C# is the same guy >>that did Delphi -- would that be a simple enough explanation ? > >Yes, indeed. In fact, it is the same guy who wrote the original Turbo >Pascal: Anders Hejlsberg. I believe that's why David coyly included the >"" in his post... It's a mysterious world. First there's the question of how it happened that this bit of OP wandered into C#. Then there's the question of why I included that "". And then the question "golly, you finally concede and include the "" explicitly and it doesn't help..." Questions everywhere. There was some concern in the Delphi world over what would happen now that AH had been hit by a bus, um I mean hired by MS. But Delphi's doing just fine (possibly bad news for whatshisname, job-security-wise.) >-- >- Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From shredwheat at mediaone.net Sun Jun 3 10:51:00 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Sun, 03 Jun 2001 14:51:00 GMT Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> Message-ID: "Polterguy" wrote > All game companies founded on cross OS releases have either gone broke or > are soon to become so! if you can count the console platforms i heavily disagree. From tundra at tundraware.com Thu Jun 7 23:30:01 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 08 Jun 2001 03:30:01 GMT Subject: PalmOS Desktop Interface For Python? References: <3B1FB7E4.2F5D2FE3@tundraware.com> <3B203FD8.9030206@none.com> Message-ID: <3B204583.C3F88260@tundraware.com> none wrote: > > Try www.pyrite.org > > Tim Daneliuk wrote: > > > Is anyone aware of a Python module set which allows the > > PalmOS 4.0 desktop files (addressbook, todo, etc.) to be read and > > written? They only reference to something like this I've been able to > > find is dated several years ago and presumably now out of date. > > > > TIA, > > Thanks - it looks like work on Pyrite has be reactivated, so this may be exactly what I was looking for. -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From paulp at ActiveState.com Tue Jun 19 14:18:00 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Tue, 19 Jun 2001 11:18:00 -0700 Subject: PEP 255: Simple Generators References: Message-ID: <3B2F9758.4B69F032@ActiveState.com> Carsten Geckeler wrote: > >... > > But when I'm browsing through a source it may help me very much if I could > see at the `def' line if it's a regular function or a generator. I see this as an important point. It would be redundant to add a generator modifier to functions but I think that that redundancy would actually help people. It would help new users to understand that a generator is a *type of function*, *determined at compile time* and not a behavior of a function, determined at runtime. It would help even expert users to spot generators in code. It would help documentation-generation programs like pydoc to "flag" generators without massive complexity. It would help all of us ensure that our code is inline with our intentions. And it doesn't seem like it would hurt anything. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From anamax at earthlink.net Thu Jun 7 12:50:30 2001 From: anamax at earthlink.net (Andy Freeman) Date: 7 Jun 2001 09:50:30 -0700 Subject: Why should i use python if i can use java References: <3e7e9334.0106062002.368d5e0a@posting.google.com> Message-ID: <8bbd9ac3.0106070850.63d7f6b3@posting.google.com> > I'm just completing my first significatn project in python (previously > worked in Java). Productivity gain in python has been significant. > However, python doesn't > > strong typing (love it or hate it...) > interfaces (ditto) > an elegant way of implementing singletons (or does it? anyone?) > a comparable development and debugging environment to JBuilder Umm, I'm confused. Are you saying that python isn't good/better because it lacks those things or that Python would be even better if it did? The former is contradicted by your experience while the latter is open to debate. Other people have commented/will comment on interfaces, singletons, and good development/debugging environments, so after an aside on typing (dynamic typing is required for truely useful polymorphic programming, so that typing "a+b" once is reusable), I'll take a contrary view wrt development and debugging. I've found that "good" (beyond print/grep) debugging/program development environments actually decrease "functionality provided" productivity. (They do seem to increase "lines of code generated" and "% of time spent typing" productivity.) The reason seems to be that "good" environments let me/other people write code that is surprising, that can only be understood through the use of such tools. (Of course, you can always add user-side hacks when the behavior doesn't match the documentation, pushing a bigger hairball to the next person.) Without those tools, me/they have to walk away from the keyboard and figure out what the problem actually is. It turns out that "figure out" is more productive than "tools required". It took me a while to figure this out. > J2EE > J2ME > > So it still lags Java for seriously scalable enterprise solutions and > for portable device deployment. Umm, don't confuse "java environments for accomplishing " with "required environments for accomplishing ". Both of those things are done perfectly well without Java. (Of course, certain decisions might preclude the use of certain technologies.) We're about to see whether "write once, run anywhere" will survive "write anything, works together". -andy ps - For those of you with a historical bent, remember when Common Lisp was way too big? Guess what's smaller - Java (as deployed) or CL (including a compiler, bignums, ...). From karsaig at home.com Sat Jun 30 06:18:03 2001 From: karsaig at home.com (G K) Date: Sat, 30 Jun 2001 10:18:03 GMT Subject: COM method with pointer args References: <8b5e42a6.0106171630.43a3303a@posting.google.com> <9gkek6024kl@enews2.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:9gkek6024kl at enews2.newsguy.com... > Once the type-library IS thus being used, all [out] parameters > of methods will disappear from the parameter-list and become > extra items in a returned tuple, instead. [in,out] parameters > will be BOTH in the parameter-list (for the [in] part only) > AND extra items in the returned tuple (for the [out] part). In my installation (ActivePython 2.1,build 211) all the [out] parameters are still there in the function arg list. What do I pass in? If I pass pythoncom.Missing I get: com_error: (-2147352571, 'Type mismatch.', None, 2) if I pass pythoncom.Empty or None I get ValueError: argument is not a COM object I suspect this is a bug and the first (Missing) is the correct way. Any ideas? Thnx, -- Gabor From robin at jessikat.fsnet.co.uk Sat Jun 16 20:07:52 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sun, 17 Jun 2001 01:07:52 +0100 Subject: PEP 255: Simple Generators References: Message-ID: In article , Tim Peters writes >[Robin Becker] >> Who owns the generator state is it the caller or the callee? > >Neither: it's part of the generator-iterator. Under the covers, it's >simply the callee's activation record ("frame"); the primary trick to >implementing generators is simply to refrain from decrementing the frame's >refcount when leaving the function. The generator-iterator holds a >reference to the frame instead, and the frame will be discarded as a matter >of course when the iterator becomes trash. > > so the implication is that the state can't be got at explicitly and I have to redefine the generator function part of the iterator to reset it? can one copy a generator-iterator? -- Robin Becker From robin at jessikat.fsnet.co.uk Fri Jun 15 16:02:23 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 15 Jun 2001 21:02:23 +0100 Subject: PEP 255: Simple Generators References: Message-ID: In article , Tim Peters writes >PEP: 255 >Title: Simple Generators Who owns the generator state is it the caller or the callee? -- Robin Becker From SBrunning at trisystems.co.uk Wed Jun 27 04:11:21 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Wed, 27 Jun 2001 09:11:21 +0100 Subject: Windows Registry Message-ID: <31575A892FF6D1118F5800600846864D78BDB2@intrepid> > From: alf at leo.logilab.fr [SMTP:alf at leo.logilab.fr] > Could someone tell me how to access the windows registry with python > (or point me to the right section of the manual). Use the _winreg module. Docs here - . Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From rdsteph at earthlink.net Sun Jun 17 17:02:02 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Sun, 17 Jun 2001 21:02:02 GMT Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? References: <3B2B60AD.942719AE@earthlink.net> Message-ID: <3B2BCBA6.381FBC2D@earthlink.net> Thanks! You give me a lot of good ideas, comments, and food for thought, all of which are relevant to my upcoming decisions. As you allude to indirectly, and which I didn't mention in my original post, I would really like to ultimately be able to use my stuff on the web in web pages readable by standard browsers. But one step at a time is more than enough ;-))) I do want to avoid buying Visual Basic or Visual Studio. That's where I draw the line. I'm really glad that ActiveState is porting Python to .Net, because it's good for Python and the community, but I do not want to buy into that package. Maybe you are right, I may just have to dig into Tkinter or wxPython; if so, the week I'm off on vacation is the right time to do it anyway. But still I must decide between Tkinter and wxPython, which is a big decision. I will look into Sun's Forte for java. I will probably want to do a Jython -java exploration in addition to my main thrust of Python and (Tkinter or wxPython). If I go with Tkinter, I would always have the option of buying PythonWare's stuff later, since it is based on Tkinter. I would still like a recommendation from someone who has used PythonWorks, particularly the gui painter. If I go with wxWindows, I would have the option of going with Boa Constructor later. So, my decision between Tkinter and wxPython looms a as large one. For my web stuff, if I were not into Python, my uses would divide into two parts. On the one part, some of the stuff I want to do would be eminently do-able with just HTML and JavaScript. I may well do that because its just plain easier in the end. (Maybe DHTML too, but I don't know that yet). But i really woudl prefer to stick with Python based stuff The other half of my web stuff will require at least CGI and maybe true server side scripting. I have opened an account just now with Hoibbiton which allows CGI but not calls to outside URL's, which I am want to do for some simple but specific webstuff to create up to date web links for subjects of interest to me. Does anyone know of any Python web spider software already written? I still have not tried Webware or Zope really. Webware sounds more simple and Zope has the site Hurrah which is $20 per month but exposes Zope and Python scripts. All of this I learned about on this great list. But obviously I am going off in too many directions all at once and can not learn all of this in one short week, even while on vacation and devoting myself completely fulltime to Python ;-))) Thanks Dave, for your help!!! Ron Stephens res04o20 wrote: > Hi y'all. I'm new here so bear with me. ;-) > > Ron, > I've had the same "problem". I'm a working SE/ProjectMgr. (26 years), and > have gotten very spoiled by VB and the like. But, I've also been forced to > re-learn the old addage, "There is no royal road to Geometry". In other > words, there ain't no substitute fer just bitin'-the-bullet and learnin' > it. Tkinter is the place to start. Do yourself a favor and get a copy of > "Programming Python 2nd Edition". It's got the best tutorial I've seen yet > on Tkinter. Everything you learn there will only help you in any other > paradigm. Tkinter IS event-driven. It's just not "Visual...". I also have > played with wxPython and like it too. > > Now. Here's another way to go. Just use VB or some Office VBE with Forms2 > (or even Word fields or Excel cells) as your gui. The other great book I've > read, "Programming Python on Win32" shows you how to do it. It's not hard. > That's of course, if you have access to VB/Office and can stomach using it. > Some folks just refuse, and I can't blame 'em. > > Here's another thing I have been playing with. Download "Forte for Java" > Community Edition from Sun. It's free. Free is good. It builds Java AWT and > Swing GUI's. (Could also potentially integrate well with Jython...? ) Design > a gui, and look at the code it generates. You could just use that code as a > framework, and convert the code to use Tkinter or wxPython calls instead of > Java. (Python can do that! See note on Jython below, though.) But you still > have to KNOW your package and how it works. You'll also get more > satisfaction and be able to fix your own problems, if your gui builder > doesn't hide all the details from you. > BTW, did I mention it's free? > > wxPython. I like it, but it's ANOTHER package you have to download, install, > and learn. It doesn't come with Python. It may in the future. Who knows. > (One advantage - doesn't depend on Tcl.) > > Jython. Love it. Be prepared to learn alot of Java/AWT/Swing. Another > package. Enough said. > > And here's one more idea. DHTML. It's ubiquitous, free and powerful. Makes a > good gui and there's a ton of free (or cheap) visual designers for it. > (Check out MacroMedia.com. And Allaire, which they just bought/merged with. > Look at the HomeSite HTML Editor. Very interesting. And inexpensive. And > powerful.) Hook in your Python handlers and yer in business. (You might want > to experiment with using JxScript for the actual event-handlers, and then > calling your Python routines from there. I've had a little trouble in some > cases using pure-Python event-handlers. In IE, JxScript is more tightly > integrated with the DOM.) Course, you'll have to use the .hta model, not > .htm, to get out of restricted mode and have a full-blown IE app. It's so > difficult. You have to change one letter in the extension! ;-) See MS > WebWorkshop site on Reusing Browser Technology and HTA's. (I'm talking > Win32/IE here. I'm ignorant of Netscape and wary of Mozilla yet. Time will > tell on that. (ActiveState Komodo is built on Mozilla, and it's an absolute > dog on performance. Current beta is better than 1.0 but not much. But it's > getting there...) > I am seriously considering taking my development team in this direction for > a new Multi-Dimensional Analysis (OLAP) application for SQL Server. > > And lastly, ActiveState has announced "Visual Python". Only problem is, you > gotta have MS .Net. (shudder) (Yet another implementation of Python. This > time in C#. Another learning curve to be ultimately successful.) > > I've looked at Pythonware and Boa., etc. Good potential. I just don't want > to be locked into another IDE structure. What if I have to convert out of > it? What about my project structures? Do they integrate versioning software? > Do they store everything in XML or DBM or Pickles or Shelves? Or who knows > what? Just haven't had enough time to look into those issues. Of course, > these are project management issues which may not be of any concern for your > purposes. Best thing is just play with them see what works for you and what > you can afford. > > Hope these ideas help. Good luck! > (And I'll also be interested in other folks' responses!) > > Dave Wald > > "Ron Stephens" wrote in message > news:3B2B60AD.942719AE at earthlink.net... > > I am taking a week's vacation the week after next. I plan to spend this > > week trying to learn event-driven programming using Python. I would sure From johngrayson at home.com Mon Jun 4 06:00:03 2001 From: johngrayson at home.com (johngrayson at home.com) Date: Mon, 04 Jun 2001 10:00:03 -0000 Subject: Fwd: I NEED to TEACH you something, QUICK! Message-ID: <9ffm73+bdsp@eGroups.com> Oh my God! Did you take yourself off Lithium? Run to your local drugstore and get yourself on Thorazine as soon as you can. Then check yourself back in to the place you escaped from... From uioziaremwpl at spammotel.com Sat Jun 23 10:23:48 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Sat, 23 Jun 2001 16:23:48 +0200 (CEST) Subject: PEP 255: Simple Generators In-Reply-To: <9h1tt9$16i$1@slb1.atl.mindspring.net> Message-ID: On Sat, 23 Jun 2001, Andrew Dalke wrote: > Me: Okay, the "def" statement is how you make a function. > Chemist: Yeah, functions, I know those from FORTRAN. > Me: And the "class" statement is how to make a new class. > Chemist: Ohh! I finally get to learn about object-oriented programming! > Me: And the "generator" statement is how to make a new generator. > Chemist: A what? What's a generator? > Me: It's a function that returns a special kind of object. > Chemist: Then why isn't it called a function? > Me: Well, you can think of a class as a function that returns > a special kind of object. > Chemist: Oooo..kaaay.. > Me: Okay, how about this. A generator turns a function into ... > You know, I just don't know how to explain it well enough. > But they are really easy to use - just pretend they are functions > that return a list, except that you can only ask for the next > item in the list. > Chemist: But you said Python was also easy to understand. Since we now have "def"/"yield" for generators, the discussion goes more or less the same way. You just realizes that generators seem to be to complicated for first time Python users. So you decide not to mention them at the beginning, but later with the other advanced features. So some days later, another friend comes to you. You explain him all the basic programming features, but not generators. A week later, the friend comes to you again. Friend: Well, I programmed a little bit with Python. It really seems to be very simple. I have just one problem: I've found a code example somewhere on the web and there is a function in it, which seems to behave a little bit strange. Perhaps you can help me. Me: OK, let me see. Oh, right, this is a generator, not a function! Friend: A what? It seems to be like a function but it has some yield statements in it. What does yield do? Me: Well, it returns an object and suspends the evaluation of the block till the next iteration. Generators are special functions. Friend: So yield does the same as return? Actually it has to be, because there is no return in the, ehh, generator, but it returns some object. So the returned value comes from the yield statement. Me: No. I'll have to explain generators in more detail. When the generator is called, it returns an iterator without evaluating any of the code in the definition. Friend: Returns an iterator? But when is the code executed then, if not while calling it? Me: It returns an iterator object. Then each time you call iterator.next(), the code is executed until it reaches the next yield, and the value after yield is return. Friend: So it's not a function?!? Because you told me last time that functions just execute the given statements in order. Me: Yes, it's not a function, it's a generator. If you have a def statement with a yield statement, it's a generator. Friend: That's confusing. So def has two meanings depending on an occurence of yield or not? And so on.... Cheers, Carsten -- Carsten Geckeler From aleaxit at yahoo.com Thu Jun 7 16:02:58 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 7 Jun 2001 22:02:58 +0200 Subject: Why should i use python if i can use java References: <9fngvl011jg@enews2.newsguy.com> Message-ID: <9foms801hod@enews1.newsguy.com> "D-Man" wrote in message news:mailman.991931005.1422.python-list at python.org... ... > On Thu, Jun 07, 2001 at 11:19:50AM +0200, Alex Martelli wrote: > > Ditto to all the Dynamic, but still strong, typing and the Design > Patterns discussion explaning why Java is _still_ a very low level > language even though it is bytecode-compiled and interpreted. Well, not VERY low...!-). Just lower than Python... > | > Actually it does! With Jython, you can access any Java API from Python. > | > Neat, huh? > | > | Absolutely! But does any commercial IDE, as you earlier > | referenced, support Jython yet? I don't know of any. > > Not commercial, but (g)vim supports this! Version GVIM rules (5.8's what I'm using now), but I doubt even 6.0 provides me with a Jython debugger &c...?-) > 6.0 is nearly finished and has some really cool new features including > "folding" (the ability to collapse a block of text into a single line > on the display). Cool indeed (I'm sure the EMACSers are laughing at us of course:-). Alex From deltapigz at telocity.com Tue Jun 5 16:41:36 2001 From: deltapigz at telocity.com (Adonis) Date: Tue, 05 Jun 2001 16:41:36 -0400 Subject: IDLE replacement? Message-ID: <3B1D43FF.71D53061@telocity.com> is there any other python script that could replace IDLE? IDLE seems to crash on me everytime i attempt to create a thread and the debug dumps all the code of IDLE at the same time locking the program up. is it my code? or a bug in IDLE? if a bug is there any replacement for it? orjust stick to a text editor+console. [start] from threading import Thread class test(Thread): def __init__(self): i = 0 Thread.__init__(self) def run(self): for i in range(10): print i t = test() t.start() [stop] From sheila at spamcop.net Mon Jun 18 19:28:57 2001 From: sheila at spamcop.net (Sheila King) Date: Mon, 18 Jun 2001 23:28:57 GMT Subject: Teaching Pyhton on Wintel References: <1ev6xe3.15eskd91k2u1eaN%p.agapow@ic.ac.uk> <3B2E887A.92DE8176@home.net> Message-ID: On Mon, 18 Jun 2001 16:02:18 -0700, Chris Barker wrote in comp.lang.python in article <3B2E887A.92DE8176 at home.net>: :I second the notion to use PythonWin (it comes with the activestate :distribution). I found it a lot easier to get started with than IDLE. I just taught a two week survey of Python to high school students who had been working with C++ all year and just did Python at the end as a closing cap to the course. I put both PythonWin and IDLE on the machines, and let them use whichever they preferred. PythonWin does handle prompts in a funny way (I prefer the command line look, myself), and there were some other issues (I can't recall at the moment), so sometimes it was nice to also have IDLE on the machines. Some students preferred on or the other, so they had a choice. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From Richard.Suchenwirth at kst.siemens.de Thu Jun 21 02:08:45 2001 From: Richard.Suchenwirth at kst.siemens.de (Richard.Suchenwirth) Date: Thu, 21 Jun 2001 08:08:45 +0200 Subject: How to change codepage (encoding) in Tcl/Tk References: <44da3708.0106192258.623311a7@posting.google.com> <3B30A687.197D30E9@kst.siemens.de> Message-ID: <3B318F6D.E386D3B9@kst.siemens.de> "Richard.Suchenwirth" wrote: > > Peteris Martinsons wrote: > > > > I have a UI form, written in BeOpen Python 2.1 with Tcl/Tk that has 4 > > text boxes. > > I want 2 of them to display text in English and 2 in Russian. Is this > > possible? If Yes, how do I do this? Which is the property to alter? > > In Tcl/Tk, all strings are internally represented as Unicode/UTF-8. This > extends to text in Tk widgets as well - if you just have at least one > font that "implements" a certain Unicode, Tk widgets will happily > display it without any need for configuration. > So, to put some Russian into a text widget in Tcl, just say > > .t insert end \u0413\u0414\u041F This thread went for some time by email only, but it led me to hack together "A tiny input manager", http://mini.net/cgi-bin/wikit/1802.html where you can instruct entry or text widgets that they receive e.g. Cyrillic (Russian) letters from a straight ASCII keyboard... -- Schoene Gruesse/best regards, Richard Suchenwirth - +49-7531-86 2703 Siemens Dematic AG, PA RC D2, Buecklestr.1-5, 78467 Konstanz,Germany Personal opinions expressed only unless explicitly stated otherwise. From andres at corrada.com Mon Jun 11 07:17:18 2001 From: andres at corrada.com (andres at corrada.com) Date: Mon, 11 Jun 2001 07:17:18 -0400 Subject: [Announce] PyGPG-0.1 - thin classes for GnuPG Made Easy (gpgme) Message-ID: <20010611071718.A2076@corrada.com> PyGPG provides thin Python classes around GnuPG Made Easy (gpgme), a C API for controlling GnuPG. Download at: http://www.mamey.com/PyGPG Requirements: Python +1.5 Distutils package (now standard on Python 2.0 >) GnuPG 1.0.6 gpgme 0.2.1 Unix-like OS This is alpha software. It currently supports encryption, decryption, verification, and creation of detached signatures. PyGPG was developed using SWIG, it is released as Open Source with an Apache-like license. ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres at corrada.com Internet Programming http://www.mamey.com ------------------------------------------------------ From rcl211 at see.sig Sat Jun 9 00:43:42 2001 From: rcl211 at see.sig (Rob Linwood) Date: Sat, 09 Jun 2001 04:43:42 GMT Subject: Use Jython to make true executable? References: Message-ID: <2QhU6.8380$lq1.1738504@typhoon.austin.rr.com> D-Man wrote: > This request comes from people who don't know that having a .py file > (or .pyw) is just as good as having a .exe file. In fact, having a > .py is better because it will work with newer (better) interpreters [...] I have to agree. If you want to offer a compiled version built throught the method proposed, you'd have to distrubute libgcj and friends on the user's PC anyway. Why not just install Python? > > GCC (gcj, rather) can compile Java _source_ to native code (C++ object > files) that ld links together with libgcj (Sun's jdk calls it "rt.jar" Actually, GCJ can compile Java's .class files (in addition to Java source) into native code. In theory, a Python source ->(Jython)-> Java bytecode ->(GJC)-> native executable could work. Assuming you manage to get the Jython runtime library compiled, which might not be possible with the current state of libgcj (I don't know for sure, but I'd wager against it). Note that libgcj also includes a bytecode interpreter so even if you can't compile a .class file into native code for some reason, you can always run it interpretively. I don't know if this would allow you to use Sun's (bytecode) rt.jar with your own compiled program to make up for whats lacking in libgcj, but it might. > > If you have the source, then go right ahead. I don't think libgcj > implements the AWT yet, though, and I know Kaffe doesn't (a free, open > source JVM). OTOH there is PJA (Pure Java AWT) that can be used > instead (it is most useful for headless servlets, etc). Mostly off-topic: While libgcj doesn't (currently) have AWT support, Kaffe does. It uses Biss-AWT (http://www.biss-net.com/biss-awt.html), an AWT implementation for X11. See http://www.transvirtual.com/kaffe-awt.htm for more information. -- Rob Linwood -- rcl211 at nyu dot edu http://homepages.nyu.edu/~rcl211/ From uioziaremwpl at spammotel.com Wed Jun 27 15:15:45 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Wed, 27 Jun 2001 21:15:45 +0200 (CEST) Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: On Wed, 27 Jun 2001, Tim Peters wrote: > [Carsten Geckeler] > > ... > > Do you really mean that? I would not start teaching Icon generators in > > the context of simple looping like in > > > > every i:= 1 to 10 > > do write(i) > > Griswold does. In the 3rd edtion of "The Icon Programming Language", the > first two examples of generators are As first examples it may be ok, but I'm sure Griswold is not explaining the use and idea of generator by simple loops. [snip] > > Probably most of the readers of this list are not really familiar > > with Icon, so some examples may be useful. > > That's fine, but I'm going to skip it as the relationship to the PEP is > getting too thin: PEP 255 isn't aiming at goal-directed evaluation, just at > generators. Well, I was not talking about the PEP but commenting on your point about Icon generators. But that's ok, so we should stop comparing generators in Python and Icon. Cheers, Carsten -- Carsten Geckeler From petro at bounty.org Fri Jun 1 15:17:57 2001 From: petro at bounty.org (petro) Date: Fri, 1 Jun 2001 12:17:57 -0700 Subject: Copying files to multiple comp's on a lan In-Reply-To: <9f8k3v$1i04$1@news.cybercity.dk> References: <9f8k3v$1i04$1@news.cybercity.dk> Message-ID: >I'm rather new to Python, and this is my first post in this NG (as you can >probably tell). I hope that you guys can get the meaning of my writings as >english is not my native language, so I apology beforehand for any >spelling/grammatical errors. So far you're writing a lot better than most native english speakers. >I need to make a small script thats capable of copying a file from the >machine that its being run on to all the other machines on the lan. The >target path on all the other machines should be the same. The script should >take the path of the source file and the remote path to the shared folder(s) >as arguments. I'll define all the machines the file is to be copied to >elsewhere. > >Where do I start when making such a script? What kind of builtins should I >know of and which functions will be useful in my work? What do I need to >investigate closer (I've never tried network programming before)? First thing is what operating system is on these machines? If most of them are Unix, there are a lot better solutions than a python script (hey, I love Python, but there are just some times when it's not the right tool for the job). >I used to do this filecopying for each machine seperately with the Windows >Explorer, and seeing as its something that I do rather often, I'm beginning >to get a little bugged by this tedious method, and have decided that now its >time to make it a little more automated. >If you know of an already existing program that can accomplish this task for >me any pointers would be greatly appreciated. I'm going to assume it's windows, since you are using the Explorer, take a look at http://optics.ph.unimelb.edu.au/help/rsync/ rsync is a pretty good way of doing what you want. -- -- http://www.apa.org/journals/psp/psp7761121.html It is one of the essential features of such incompetence that the person so afflicted is incapable of knowing that he is incompetent. To have such knowledge would already be to remedy a good portion of the offense. From scarblac at pino.selwerd.nl Sun Jun 17 15:01:59 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 17 Jun 2001 19:01:59 GMT Subject: pair programming, vim? References: Message-ID: Rainy wrote in comp.lang.python: > Did anyone try pair programming over the net? In particular, is it possible > to set up vim with a shared buffer or, failing that, some other editor? If > so, does anyone want to try pair programming some small project? Emacs. The simplest possible way, as someone on the emacs group pointed out, is M-x make-frame-on-display. Simply open another window of this same emacs instance on that computer there, and you can both type in the same buffer, and see what the other does. Obviously, there are problems (if one quits then both quit, and the remote user has total access to the files of the local user running emacs). Another option is shbuf: http://www.bluetail.com/~luke/shbuf/shbuf-1.1.tar.gz One user starts a server (written in erlang, you need an erlang interpreter) and others can connect to it, to share a buffer. Only one person can edit at a time, the others watch. -- Remco Gerlich From pieter at kotnet.org Sun Jun 3 04:34:11 2001 From: pieter at kotnet.org (Pieter Laeremans) Date: Sun, 03 Jun 2001 10:34:11 +0200 Subject: Python and databases Message-ID: <991557251.316332@seven.kulnet.kuleuven.ac.be> Hi, Does python has something like perl 's DBI? I can 't find any documentation about it in the python docs. Thanks in advance, Pieter From gtcopeland at earthlink.net Fri Jun 1 14:32:34 2001 From: gtcopeland at earthlink.net (Greg Copeland) Date: 01 Jun 2001 13:32:34 -0500 Subject: Python + threads + wxWindows = segfault, help! References: <9f8f7j$k5c$1@panix6.panix.com> Message-ID: Arg! In my hurry to get this posted it seems that I left some important information out. I'm running Python 2.1 with wxPython 2.2.5 and wxWindows 2.2.7, though I get the same results with 2.2.5 as well. The application design is using the parent for the GUI and threads for communication. Data is passed back and forth via Python's Queue class. Most of the segs that I get seemingly have to do with threads. I think I'm the only SMP user on the project and oddly enough, I think I'm the only user seeing issues like this. Thanks again. Any more ideas or tips would be wonderful! Greg aahz at panix.com (Aahz Maruch) writes: > In article , > Greg Copeland wrote: > > > >I'm working on a project that has a multithreaded wxPython > >application. I working on an SMP box. Can anyone tell me > >what might be causing this to happen? > > > >Fatal Python error: ceval: orphan tstate > > If you're using Python 1.5.2, upgrade to Python 2.x; there's a thread > bug in 1.5.2 with SMP combined with creating/destroying large numbers of > threads. > -- > --- Aahz <*> (Copyright 2001 by aahz at pobox.com) > > Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ > Hugs and backrubs -- I break Rule 6 > > "Characters exist to suffer, you know. An author needs a little sadism > in her makeup." --Brenda Clough -- Greg Copeland, Principal Consultant Copeland Computer Consulting -------------------------------------------------- PGP/GPG Key at http://www.keyserver.net DE5E 6F1D 0B51 6758 A5D7 7DFE D785 A386 BD11 4FCD -------------------------------------------------- From BrianQ at ActiveState.com Fri Jun 29 14:18:15 2001 From: BrianQ at ActiveState.com (Brian Quinlan) Date: Fri, 29 Jun 2001 11:18:15 -0700 Subject: Support for "wide" Unicode characters In-Reply-To: <3B3BB09C.E686DF85@ActiveState.com> Message-ID: <000b01c100c7$de278b70$b503a8c0@activestate.ca> I like this PEP except for a few little details: > * codecs will be upgraded to support "wide characters" > (represented directly in UCS-4, as surrogate pairs in UTF-16 and > as multi-byte sequences in UTF-8). On narrow Python builds, the > codecs will generate surrogate pairs, on wide Python builds they > will generate a single character. This is the main part of the > implementation left to be done. I would prefer that on narrow builds the codecs generate exceptions when they encounter surrogate pairs. Having surrogate pairs in your unicode objects is going to make life very unpleasant for the majority of people because indexing and interpretation become difficult. BTW, it looks like the UTF-8 and unicode escape decoders insert surrogate pairs into the unicode object while UTF-16 throws an exception (UnicodeError: code pairs are not supported). > There is a new configure options: > > --enable-unicode=ucs2 configures a narrow Py_UNICODE, and uses > wchar_t if it fits > --enable-unicode=ucs4 configures a wide Py_UNICODE, and uses > whchar_t if it fits > --enable-unicode same as "=ucs2" So what is the proposed behavior if sizeof(Py_UNICODE) > sizeof(wchar_t)? When an extension module asks for wide characters, will Python attempt to down-encode the buffer? If that is not possible, will it insert surrogate pairs? Will it generate an exception? From aleaxit at yahoo.com Sat Jun 16 10:05:04 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 16 Jun 2001 16:05:04 +0200 Subject: Type/Class Distinction References: <9gdpbp$61k$6@newshost.accu.uu.nl> Message-ID: <9gfp64017jh@enews1.newsguy.com> "Martijn Faassen" wrote in message news:9gdpbp$61k$6 at newshost.accu.uu.nl... ... > Right now we have to *treat* 'types' differently from 'classes'. For > built-in objects you have to use the type() construct to check what > you're dealing with, but for class instances you use isinstance(). > > Wouldn't it be nice if the language allowed something like this: > > if isinstance(foo, int): You're behind the times, I think (if I understand you correctly): D:\py21>python Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. Alternative ReadLine 1.4 -- Copyright 2001, Chris Gonnerman >>> int=type(1) >>> isinstance(23,int) 1 >>> isinstance(23L,int) 0 >>> i.e., isinstance already accepts a type-object 2nd argument. What you can't yet do is INHERIT from a type, &c... Alex From greg at cosc.canterbury.ac.nz Thu Jun 7 23:11:00 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 08 Jun 2001 15:11:00 +1200 Subject: Question re local bindings in nested scopes References: <8gdnht4as9mg09un8vu2ci2re80p2ujssq@4ax.com> Message-ID: <3B204244.82C19892@cosc.canterbury.ac.nz> Kirby Urner wrote: > > But should a=a+1 (or a += 1) really break the initial binding of a > to the outer scope? Is this intended? I'd say it's "not unintended". :-) It's simply a consequence of the rule that any assignment to a variable in a given scope makes it local to that scope. This rule does lead to surprises in some cases, but that's the price Python pays for not requiring variables to be declared. > it seems odd to unbind an already initialized variable "Unbinding" is the wrong word. The outer binding is still there, it's just being shadowed by an inner one. > just because we add 1 to it. It's not because you're adding 1 to it, it's because you're *assigning* to it. Remember that += and friends are forms of assignment. > Seems too subtle for its own good. The alternative you seem to want would have subtleties of its own. What do you think this should do: def f(a,b): def g(): if b: z = a else: z = 0 a = z + 1 g() return a Under one possible interpretation, a would be local or not depending on the value of b. I think Tim and Guido would regard that as rather too subtle! -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From thinkit8 at lycos.com Tue Jun 12 13:15:32 2001 From: thinkit8 at lycos.com (thinkit) Date: 12 Jun 2001 10:15:32 -0700 Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> <9g5h4c01rba@enews2.newsguy.com> Message-ID: <9g5ink015sb@drn.newsguy.com> In article <9g5h4c01rba at enews2.newsguy.com>, "Alex says... > >"thinkit" wrote in message >news:9g5d3p0f0p at drn.newsguy.com... >> humans should use a power of 2 as a base. this is more logical because it >> synchs with binary, which is at the very heart of logic--true and false. >it is >> more natural perhaps, to use decimal-- > >Perhaps. It seems to have been used by most cultures throughout >the world, though far from all. Octal was used by some American >tribes, and some linguists believe they find decisive traces in >Indo-European and Japanese to show that their common root (so- >called Nostratic) used octal. Vigesimal was clearly popular >recently enough that French still says "seventy" as "sixty and >ten", "eighty" as "four twenties", "ninety" as "four twenties >and ten". Sexagesimal, used by Sumer and Babylonian astronomers >(they used decimal for most computation), has left indelible >traces in our time-measurement (60 seconds to a minute, 60 >minutes to an hour) and angle-measurement (ditto). > >> but logic should, and will, win out. > >Perhaps. It never did, so far, but it sure seemed to for LONG >times. For example, Parmenides used logic to prove ZERO was >unusable nonsense (his disciple Zeno, not to be confused with >the founder of Stoicism of course, bult beautiful paradoxes to >illustrate his master's thesis), and thus did logic manage to >make arithmetic almost unusable for 1,500 years in the West. > >Fortunately, in the end, the Eastern mystics won out, putting >logic in its place and celebrating the Abra Kad' Abra ("air void >of air" -- aren't these Sanskrit words STILL the ones that >come to mind most readily when thinking of a spell of mystical >incantation?-), Non-Being, the Void at the Core of All, etc, >etc. At long last, the illogic and absurd Zero got into the >number system -- eventually, since Practicality Beats Purity, >its use became universal. Nowadays, of course, the adorers >of Logic try to sweep THIS little tidbit of the history of >science and mathematics under the carpet...:-). > >I highly recommend in-depth study and comparison of the >Tractatus Logico-Philosophicus (a genius in his twenties >trying to fix precisely the conditions in which Logic will >let us speak) and the Philosophical Investigations (the >same genius, 30 years later, explaining WHY logic will >never work as the One True Way of human discourse...). > >As eminently NON-logical William Blake had written, "If >the fool would but persist in his folly, he would become >wise" -- few logical fools have shown the same persistence >and greatness as Ludwig von Wittgenstein, to enable them >to reach the wisdom of mysticism by dint of inflexibly >consistent application of Logic...:-). > > >Alex um...? see, this is exactly what i'm talking about. binary is simple...this is not. i don't really care about a bunch of old men who wanted to argue over the number 0. maybe they just got tired of jerking off and decided to spew some garbage to sound smart and score more chicks. just my guess. i see 0, i see 1, i see logic. it is interesting to hear about base 8. i've heard the others you mentioned--but haven't heard a power of 2 in use. only things i can think of today are the fluid ounce and weight ounce, both powers of two. and i suggest a look at lojban, a logical language. you can learn it without referring to a bunch of old dead farts. http://www.lojban.org . From whisper at oz.nospamnet Thu Jun 7 15:37:32 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 7 Jun 2001 19:37:32 GMT Subject: Working with paths with spaces in NT References: Message-ID: <9fol5s$9d3$3@216.39.170.247> In article , tim.one at home.com says... > [David LeBlanc] > > import os > > import dircache > > import re > > > > > > def getDirs(path, tabs): > > dirlist = [] > > os.chdir(path) > > for dir in dircache.listdir("."): > > if os.path.isdir(dir): > > dirlist.append(dir) > > print dirlist > > for dir in dirlist: > > print dir > > getDirs(dir, tabs + 1) > > > > getDirs("L:/languages/python", 1) > > > > This will report: [k:/Python21/Projects]% python FileList.py > > ['Apps', 'CVS', 'Database', 'Distributions', 'Docs', 'Tools', 'libs'] > > Apps > > ['ThoughtStream', 'XML', 'moop'] > > ThoughtStream > > ["A Gentle Introduction to Ted Nelson's ZigZag Structure_files", > > 'ThoughtStream Design notes_fil > > es', "ThoughtStream User's Guide_files", 'XML Topic Maps (XTM) 1_0 > > errata_files', 'XML Topic Map > > s (XTM) 1_0_files', 'XML Topic Maps (XTM) Processing Model 1_0_files'] > > A Gentle Introduction to Ted Nelson's ZigZag Structure_files > > [] > > ThoughtStream Design notes_files > > Traceback (most recent call last): > > File "k:\python21\projects\FileList.py", line 17, in ? > > getDirs("L:/languages/python", 1) > > File "k:\python21\projects\FileList.py", line 15, in getDirs > > getDirs(dir, tabs + 1) > > File "k:\python21\projects\FileList.py", line 15, in getDirs > > getDirs(dir, tabs + 1) > > File "k:\python21\projects\FileList.py", line 15, in getDirs > > getDirs(dir, tabs + 1) > > File "k:\python21\projects\FileList.py", line 8, in getDirs > > os.chdir(path) > > OSError: [Errno 2] No such file or directory: 'ThoughtStream Design > > notes_files' > > > > How do I process directory names with spaces? I looked through the python > > doc, but didn't see anything. > > If you look at your output very carefully, you'll discover this has nothing > to do with spaces. After all, you chdir'ed to > > A Gentle Introduction to Ted Nelson's ZigZag Structure_files > > just fine. If that's not enough of a hint, try this starting in some deep > directory tree that doesn't have any spacey names. > > don't-use-relative-paths-unless-you're-sure-you-know-where-you- > are-ly y'rs - tim > > > Thank you Tim for the warm and friendly help without a hint of condescension - i'm sure it really encourages people new to python and evem more those new to programming. probably-been-programming-for-longer-then-you've-been-alivedly-yours... Dave LeBlanc P.S. In case you're wondering, 30 years as of last month. From someone at spam.com Mon Jun 18 08:26:13 2001 From: someone at spam.com (Anders And) Date: Mon, 18 Jun 2001 14:26:13 +0200 Subject: Aargh! Function takes exactly x arguments, y given.. Message-ID: <9gkrud$pru$1@news.inet.tele.dk> Hi! I am a happy pythoneer using a combination of C++ and Python for my everyday work. Usually, debugging is easy but every now and then, I get the "function takes exactly x arguments, y given" error message, clearly due to some other problem than what Python thinks. Does anybody have any experience with this particular error message? I don't know what triggers it and thinking back, I think I have solved most of my problems with this message with a major code rewrite. Please help! Kristian From joonas at olen.to Tue Jun 12 01:41:34 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Tue, 12 Jun 2001 08:41:34 +0300 Subject: EXECing multiple lines. References: Message-ID: <3B25AB8E.67B64516@olen.to> Bjorn Pettersen wrote: > > >>> exec """for x in range(5): > > print x""" ^^^^ > You need to indent the line "print x". It is intended. See the whitespace. From sdm7g at Virginia.EDU Thu Jun 21 18:48:31 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Thu, 21 Jun 2001 18:48:31 -0400 (EDT) Subject: Another Wart! string.find() [ was: namespace issue? ] In-Reply-To: Message-ID: On 21 Jun 2001, Michael Powe wrote: > So now the question is, 'why'? Am I misusing the string.find() > function? Okay, string.find() returns -1 when the string is not found, > which would seem to be what I expected, a false result. Maybe python > doesn't treat -1 as false? Well, I'll try being explicit and testing > for -1 return. I probably have just confused myself hopelessly. You got it! 0, 0.0, "", [], (), and None, as well as classes that return 0 from methods __nonzero__ or __len__ are false. everything else (unless I missed one ;-) is true. -1 is true. But find can't return 0 because it is a valid offset that signifies the beginning of a string, so it returns -1. Maybe this should be considered another "Python Wart" : the thing is that all of the early Python programmers were well used to this sort of exception in the standard C libraries: zero is an error return everywhere except where it would be inconvenient, then use negative numbers as error codes. It probably *ought* to return None for not found: "string"[None] yields an exception: "TypeError: sequence index must be integer" while "string"[-1] returns "g" so a coding error is likely to slip thru without an exception. This is an illogical convention, however it would be very difficult to root out, because, as you have noted, everyones code is FULL of explicit checks that string.find does not return -1. I'ld love to see it fixed, however, I suspect that in this case, many lines of installed code trumps Computer Programming for Everybody! -- Steve Majewski From rnd at onego.ru Thu Jun 14 03:17:20 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 14 Jun 2001 11:17:20 +0400 (MSD) Subject: substitute for c/java's ?: In-Reply-To: Message-ID: On 14 Jun 2001, Remco Gerlich wrote: > Jochen Riekhof wrote in comp.lang.python: > > Hi... > > > > as a newcomer to python (like it a lot!) I found almost everything great > > except two things: > > 1. (most important) > > I am missing something like the c/Java ?: operator. This is so convenient in > > many places and saves a lot of typing. > > It works like > > result = option ? value1 : value2; > > which is equivalent to > > if option: > > result = value1 > > else: > > resultl = value2 > > > > Is there anything I overlooked? > > Not really. Just write the if:, it's more obvious what it does when you read > the code (especially when the expressions get longer). result = option and value1 or value2 could also be used but only in those cases when value1 is TRUE. For example: result = DBG and "debug:" or "" But this will not work: result = NODBG and "" or "debug:" (I`m not sure how to call these constructions, though). Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From van at lindbergs.org Mon Jun 18 16:34:36 2001 From: van at lindbergs.org (VanL) Date: Mon, 18 Jun 2001 14:34:36 -0600 Subject: Python to native compilation via java? Message-ID: <3B2E65DC.5060209@lindbergs.org> Hello, I was reading about the new gcc 3.0 release, and something that caught my eye: """ The GNU Compiler for the Java Programming Language What is GCJ? GCJ is a portable, optimizing, ahead-of-time compiler for the Java Programming Language. It can compile: * Java source code directly to native machine code, * Java source code to Java bytecode (class files), * and Java bytecode to native machine code. Compiled applications are linked with the GCJ runtime, libgcj, which provides the core class libraries, a garbage collector, and a bytecode interpreter. libgcj can dynamically load and interpret class files, resulting in mixed compiled/interpreted applications. """ Would code get any significant speedup by going jython -> .class files -> native? Thanks, Van From glyph at twistedmatrix.com Thu Jun 21 14:59:08 2001 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: Thu, 21 Jun 2001 13:59:08 -0500 (CDT) Subject: PEP 255: Simple Generators In-Reply-To: <20010621083153.A19734@glacier.fnational.com> Message-ID: On Thu, 21 Jun 2001, Neil Schemenauer wrote: > Glyph Lefkowitz wrote: > > Disadvantages to the PEP 255 approach: > > > > * we'll probably want microthreads eventually; this feature will bloat > > the language unnecessarily then. > > How so? It would still be nice to have some syntax on the > language to support generators. If the implementation supports > continuations then implementing PEP 255 will be easy. Syntax in the language is in fact *exactly* why I am arguing against this. If a "generator" is different from a regular function somehow, then this idiom cannot possibly work: def writeComplexMessage(self, msg, data): fmt = format(msg) data.put(fmt) def dataHandlingLoop(self, data): while 1: x = data.get(bufsiz) msg = process(x) self.writeComplexMessage(msg, data) since the "yeild" is one level deep in the function call stack, writeComplexMessage will be flagged a "generator" and dataHandlingLoop a regular function. So the way to do this is to have a "yeild" in dataHandlingLoop that is a tuple (bytes to write, number of bytes to read) or something insane like that. Generators doesn't make this easier; but it is the same sort of problem that generators are designed to solve. (I guess this indicates that I *could* use generators to implement the example in my earlier email, but I think that this "solution" is a worse indicator than the original problem.) > > * less pythonic: once we've implemented generators this way, what about > > simulation loops? Do we need syntax support for those too? > > I don't know what you mean by simulation loops. If I have 10,000 "agents" in a simulation (something like Core Wars, maybe), and they all have to be time-shared equally, real threads are not an option (try spinning up 10k threads in python on a default redhat linux install, haw haw.) and neither are generators. The simulation may want to yeild some processor time several levels deep in the stack; if I have to return to the toplevel function it's pretty much the same as if I have to process time slices as event-based rather than synchronously. > > The one advantage to the PEP 255 way of doing things is that it > > looks like it might be slightly easier to implement. > > Make that "much easier". Stackless is wizard code. Christian > did an amazing piece of work there. Hopefully those ideas can > be integrated into mainstream Python. Its still going to take a > lot more work though. So far no one has stepped forward to do > it. Well, I'm not advocating the immediate integration of stackless. Speaking against some common Python zen; now is *not* better than later. Generators solve *some* problems for which synchronous execution is desirable, but not others. They change the semantics of function definition (despite the BDFL's pronouncement, my favorite piece of python zen is still "explicit is better than implicit" ^_^). They add a keyword. They do not fill my needs, or the needs of anyone working with simulation code, network dispatching, or massively parallel computing; whereas the simpler solutions which *do not* add a keyword and *do not* change the semantics of function definition can fill the needs of a far greater group, as well as the same set that would require generators. Stackless is problematic, but I think that an implementation similiar to that of generators could give us microthreads. When I get back from vacation I'll write up a PEP; if you'd like to give me a hand, feel free to drop me an email :) ______ __ __ _____ _ _ | ____ | \_/ |_____] |_____| |_____| |_____ | | | | @ t w i s t e d m a t r i x . c o m http://twistedmatrix.com/users/glyph From pecora at anvil.nrl.navy.mil Mon Jun 11 08:11:23 2001 From: pecora at anvil.nrl.navy.mil (Louis M. Pecora) Date: Mon, 11 Jun 2001 12:11:23 GMT Subject: How do you develop in Python? References: <050620011516094693%pecora@anvil.nrl.navy.mil> <9fjfer$gt0$1@nereid.worldonline.nl> <3B2129AC.90BA8650@home.net> <9frc6v$b20$1@nereid.worldonline.nl> Message-ID: <110620010813361767%pecora@anvil.nrl.navy.mil> In article <9frc6v$b20$1 at nereid.worldonline.nl>, Gerrit Muller wrote: > I understand the problem from implementers point of view. However from CP4E > point of view I don't "want" to understand, I simply would like to have this > "reset/clear" button. Hunting for the CP4E vision requires thinking from > "naive" programmer point of view. Some brilliant idea appears to be > necessary to satisfy this need, without making the IDE's too complex. > > Thinking out loudly: For many naive users the automated stop/restart might > be fully acceptable, while it might also be simple to implement. Although, > how much unexpected state needs to be persistent, like open files and > windows; when would this same naive user start hating to see windows > disappear and reappear? May-be it is already too complex ). > > Regards Gerrit I won't pretend to understand all this internal stuff, but with my familiarity with C/C++ IDEs, they handle the dependencies throught the header files. Why can't we have a switch that will reload automatically in the IDE according to dependencies which could be traced through the import statements? Is this too naive? From rnd at onego.ru Mon Jun 18 13:08:40 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 18 Jun 2001 21:08:40 +0400 (MSD) Subject: Function lookup using a directory. In-Reply-To: Message-ID: On Mon, 18 Jun 2001, Roman Suzi wrote: >On Mon, 18 Jun 2001 andy.pevy at nokia.com wrote: > >> Hi Guys >> >> I am having trouble with the directory data type. What I want to >> do is to set up a directory that I can use to parse a command entered by >> the user, and have a directory return the name of a class to handle the >> command. Like this :- >> >> >> command_table = {'0': 'Help0', >> '1': 'Help1', >> '2': 'Help2', >> '3': 'Help3' } >> >> class Help0: >> >> def run(self,which): >> if len(which) == 1: >> print 'Help no args' >> else: >> print 'Help args' >> >> class Help1: >> >> def run(self,which): >> if len(which) == 1: >> print 'Help1 no args' >> else: >> print 'Help1 args' >> >> class Help2: >> >> def run(self,which): >> if len(which) == 1: >> print 'Help2 no args' >> else: >> print 'Help2 args' >> >> class Help3: >> >> def run(self,which): >> if len(which) == 1: >> print 'Help3 no args' >> else: >> print 'Help3 args' > >Brrrr... > >Maybe: > >class Help: > noargs = "no such command" > args = "no such cmd" > > def run(self,which): > if len(which) == 1: > print self.noargs > else: > print self.args > Oops. Forgot to superclass: class Help0(Help): noargs = "blah blah ..." args = "balh x blah y ..." Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Monday, June 18, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Nostalgia isn't what it used to be." _/ From BgPorter at NOartlogicSPAM.com Mon Jun 4 13:31:24 2001 From: BgPorter at NOartlogicSPAM.com (Brett g Porter) Date: Mon, 04 Jun 2001 17:31:24 GMT Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> Message-ID: "phil hunt" wrote in message news:slrn9hmotf.3r7.philh at comuno.freeserve.co.uk... > On Mon, 04 Jun 2001 03:07:30 GMT, Brett g Porter wrote: > > > >"Harald Hanche-Olsen" wrote in message > >news:pcolmn9y349.fsf at thoth.home... > >> + Tim Churches : > >> > >> | No experience (I am in a similar situation to you wrt UML), just > >> | some advice: don't buy the O'Reilly book 'UML in a Nutshell' - it is > >> | the only O'Reilly title I have encountered which is truly woeful > >> | (most are quite good). > >> > >> Hmm. Has it occured to you that this might be a reflection on UML > >> rather than on the book per se? > > > >Don't know about that -- I bought it (unseen) a week or so ago since I've > >never had bad luck with a book from O'Reilly. Until now. > > > >Now, I enjoy reading dense prose. But this is one of those books where I > >know less after reading a page than I did beforehand. It's about as clear as > >postmodern literary criticism. > > > >This is not a book for reading, this is a book for lying down and avoiding. > > I agree with these comments. > > The O'Reilly UML book isn't good. > See -- if only I'd-a thought to ask here about this before hitting that 'submit' button and ordering it. From paulp at ActiveState.com Fri Jun 29 15:09:26 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 29 Jun 2001 12:09:26 -0700 Subject: Augmented Assignment (was: Re: PEP scepticism) References: Message-ID: <3B3CD266.D7552211@ActiveState.com> Guido van Rossum wrote: > >... > > The right way to think about this is "list objects are mutable and > tuples are not". So if you want to give a library function a sequence > object of yours but you don't want it to be changed, pass it a tuple. > If you want it to be changed (or don't care) pass it a list. My point is that it is hard for a new user to "believe me" (or at least understand me) when I say that tuples are not mutable but they see them changing right in front of their eyes: >>> a=(1,2,3) >>> a+=(8,3) The old behaviors strongly emphasized the non-mutability of things. The new operators undermine that understanding. Maybe the benefits outweigh this cost but I've seen this misunderstanding myself so I know it is a real cost. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From James_Althoff at i2.com Tue Jun 12 14:16:29 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Tue, 12 Jun 2001 11:16:29 -0700 Subject: metaclasses -- aka Don Beaudry hook/hack (was RE: Why should i use python if i can use java) Message-ID: Thomas Heller wrote: >type(MyClass) == types.ClassType is false for ExtensionClass.Base >derived classes, but isinstance() works (at least in Python 2.0, >I'm not sure for 1.5.2). >Thomas Thanks, Thomas! Jim From glyph at twistedmatrix.com Tue Jun 12 05:30:21 2001 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: Tue, 12 Jun 2001 04:30:21 -0500 (CDT) Subject: Type/Class Distinction (was: RE: Future floating point directions? [was Re: floating point in 2.0]) In-Reply-To: Message-ID: On Tue, 12 Jun 2001, Tim Peters wrote: [lots of stuff about floating point] You know, it never ceases to amaze me how fascinating, subtle, and fun Tim & co. make floating point math sound. It always Just Works for me. ;) > In the background Guido is reworking Python's type and class model. > It should be possible after that's done to subclass from the builtin > types. If so, then you should be able to subclass the complex type > and override its coercion policies. Could somebody please explain to me why removing the type/class distinction is a good idea? I rather like the fact that it is readily apparent which objects are implemented in Python and which in C (and my code is rife with 'if type(xxx) is types.StringType'); if I can't *implement* in Python I don't understand why it makes sense to subtype it. It seems like an "OO purity" issue, and as we all know, practicality beats purity; but if Guido is personally working on it, there's surely something I'm missing. For a minor win (slightly less work doing operator overloading to emulate dicts, lists, and floats) it seems like an awful lot of work. Is there something about writing extension modules which will be different and better? ______ __ __ _____ _ _ | ____ | \_/ |_____] |_____| |_____| |_____ | | | | @ t w i s t e d m a t r i x . c o m http://twistedmatrix.com/users/glyph From emile at fenx.com Tue Jun 12 10:00:35 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 12 Jun 2001 07:00:35 -0700 Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: <9g5486016t4@enews2.newsguy.com> Message-ID: <9g57h5$7bkkg$1@ID-11957.news.dfncis.de> "Alex Martelli" wrote in message news:9g5486016t4 at enews2.newsguy.com... > Those guys and gals have never seen a 'printing terminal', > Totally off topic: But this reminds me of remotely debugging an HP 2000 Basic app designed to run on a Hazeltine 1500 block mode terminal. We followed the code while the user talked us through his steps. No way was this happening. We asked him to go slower, and tell _everything_ he did. Only when he got to "... then I scroll the paper back..." did we figure out he was on a TI810 hard copy terminal. ;-) -- Emile van Sebille emile at fenx.com --------- From greg at cosc.canterbury.ac.nz Thu Jun 7 23:37:31 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 08 Jun 2001 15:37:31 +1200 Subject: integers References: <9fjd8q$qb6$1@charm.magnus.acs.ohio-state.edu> <9fjgqf$rp0$2@brokaw.wa.com> <696rhtkhgtf4o1i5u05e4k9pvujb8kmqaa@4ax.com> Message-ID: <3B20487B.CE77CE12@cosc.canterbury.ac.nz> Alan Daniels wrote: > > I believe the new "x += 1" syntax is just synactic sugar which serves > as shorthand for "x = x + 1" Actually, it's syntactic sugar for something more like x = x.__iadd__(1) In the case of integers (and other immutable types) this happens to be the same as x = x + 1. But mutable types have the option of implementing __iadd__ so that it changes the object in-place and then returns a reference to the same object. So, for example, if a and b are NumPy matrices, a += b can be nice and efficient. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From raskol at hushmail.com Wed Jun 13 20:34:39 2001 From: raskol at hushmail.com (raskol) Date: Wed, 13 Jun 2001 20:34:39 -0400 Subject: python IS popular Message-ID: <3b2801fc_2@newsfeeds> Coming from a totally pro-python perspective BTW here's the top 20 dev languages at sourceforge: this may or may not be an interesting stat for pythonistas. source: http://sourceforge.net/softwaremap/trove_list.php?form_cat=160 number of sourceforge projects by development platform: # sf projs platform % ======================== 4646 C 24.3% 3837 C++ 20.1% 2557 Java 13.4% 2026 Perl 10.6% 1885 PHP 9.9% 876 Python 4.6% <= and rising 498 Other 2.6% 421 Unix Shell 2.2% 358 Visual Basic 1.9% 308 Tcl 1.6% 241 JavaScript 1.3% 228 Delphi/Kylix 1.2% 222 PL/SQL 1.2% 116 Lisp 0.6% 107 Pascal 0.6% 105 ASP 0.6% 72 Scheme 0.4% 68 Assembly 0.4% 67 Objective C 0.4% 56 Object Pascal 0.3% -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From ark at research.att.com Mon Jun 11 14:27:50 2001 From: ark at research.att.com (Andrew Koenig) Date: Mon, 11 Jun 2001 14:27:50 -0400 (EDT) Subject: Python and SML In-Reply-To: <6957F6A694B49A4096F7CFD0D900042F27DB71@admin56.narex.com> (BPettersen@NAREX.com) References: <6957F6A694B49A4096F7CFD0D900042F27DB71@admin56.narex.com> Message-ID: <200106111827.OAA10609@europa.research.att.com> Bjorn> Yes, everything is compiled into a "heap image", which is architecture Bjorn> dependent (which can be exported and transformed into an executable). Bjorn> I'm sure we can agree that makes it compiled, but then Python "compiles" Bjorn> to Python VM instructions ... :-) From thinkit8 at lycos.com Thu Jun 14 07:43:29 2001 From: thinkit8 at lycos.com (thinkit) Date: 14 Jun 2001 04:43:29 -0700 Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> <9g8q7t0uib@drn.newsguy.com> Message-ID: <9ga811013r@drn.newsguy.com> In article , "Steve says... > >"thinkit" wrote in message >news:9g8q7t0uib at drn.newsguy.com... >> In article , >> Tom_Good1 at excite.com says... >> > >> >thinkit wrote in message >> >news:<9g5d3p0f0p at drn.newsguy.com>... >> >> humans should use a power of 2 as a base. this is more logical because >it >> >>synchs with binary, which is at the very heart of logic--true and false. >it is >> >> more natural perhaps, to use decimal--but logic should, and will, win >out. >> > >> >I'm amused by the idea that "humans should [do something] because . . >> >. it is more logical." Ah yes, we humans are so extremely logical. >> >That's why advertisers -- whose livelihood depends on getting us to do >> >things -- inevitably appeal to our highly refined sense of logic, and >> >never play to our emotions or baser instincts ;-) >> >> some of us are...and those that are will easily dominate or destroy the >rest. >> >If you're bent on world domination, perhaps you should apply for a job at >Microsoft? > >regards > Steve >239 (decimal) microsoft caters to the dumb in the worst kind of ways. i know bill's a smart guy, so maybe he's building up money to unleash the forces...but i doubt it. From tim.one at home.com Wed Jun 6 22:15:47 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 6 Jun 2001 22:15:47 -0400 Subject: is this a python bug? In-Reply-To: <1106_991867016@ns.seowon.ac.kr> Message-ID: [Wolfgang Lipp] > BTW, Mike, I tried your code, > > class Child: > def __init__(self, parent): > self.__dict__['parent'] = parent > def __getattr__(self, attr): > self.parent.a = 1 > self.parent.b = 1 > self.parent.c = 1 > return getattr(self.parent, attr) > class Parent: > def __init__(self): > self.a = Child(self) > print Parent().__dict__ > > and it *is* exactly the problem of mutation-while-accessing > problem! thanks! Michael Hudson brought this up on Python-Dev, and as a result this code now prints (under current CVS Python): {'a': <__main__.Child instance at 0076ABEC>, 'c': 1, 'b': 1} So it doesn't blow up, but my guess is better than yours about what it will actually print . That is, the effect of mutating a container while it's being traversed for printing is most likely never going to be clearly defined. The same goes for comparison functions that mutate a dict during, e.g., dict key lookup. We just added some butt-ugly code to stop it from crashing. the-good-news-is-that-sane-code-retains-sane-behavior-ly y'rs - tim From marco at coxeter.math.toronto.edu Mon Jun 18 21:51:07 2001 From: marco at coxeter.math.toronto.edu (Marco De la Cruz-Heredia) Date: 18 Jun 2001 21:51:07 -0400 Subject: Which IDE ? References: Message-ID: Hi, VanPopering writes: > I want to write, edit, debug, and run simple python thingys I'm a Python newbee too, and I really like EMACS' Python mode. If you like EMACS I think it's a nice environment to program in. Just my 2 cents... ___________________ mdlch at altavista.net Gunnm: Broken Angel http://reimeika.ca/ From fpm at u.washington.edu Tue Jun 12 14:15:16 2001 From: fpm at u.washington.edu (Frank Miles) Date: 12 Jun 2001 18:15:16 GMT Subject: msvcrt.getch() overly receptive in idle? Message-ID: <9g5m7k$gu8$1@nntp6.u.washington.edu> I'm trying to get getch() working in Windows (Python 2.0). It seems to work fine outside of Idle, but inside Idle it immediately returns a character with the value 255. Can anyone point me to the obvious solution? Thanks! -frank -- From twofingersalute at atl.mediaone.net Thu Jun 14 21:43:50 2001 From: twofingersalute at atl.mediaone.net (myself) Date: Fri, 15 Jun 2001 01:43:50 GMT Subject: tummy compile Mandrake 7.2 References: <20010608.214013.1469262009.16325@K7.atl.mediaone.net> <20010609.104451.1884661237.1229@K7.atl.mediaone.net> <3B24154E.C70211ED@student.gu.edu.au> <20010610.232821.1789366143.1225@K7.atl.mediaone.net> <3B25F742.F4E25C37@student.gu.edu.au> <20010612.151135.165344818.1845@K7.atl.mediaone.net> <3B288E62.FC946467@student.gu.edu.au> <20010614.083914.1875335928.1071@K7.atl.mediaone.net> <3B2922C9.4B8B5D6E@student.gu.edu.au> Message-ID: <20010614.214711.933110197.1104@K7.atl.mediaone.net> In article <3B2922C9.4B8B5D6E at student.gu.edu.au>, "Joal Heagney" wrote: >> if I understand- say I do "rpm --rebuild prog.src.rpm"- it actually >> installs the resulting prog.rpm that it builds? Is there a way to >> prevent the final pkg install using --rebuild? Sometimes I like to >> examine an rpm before installing just to see what the potential for >> damage is (config files, libraries, locations, etc). I know I can go >> through the process you recommend, look at the spec and configure >> files, and then install- just was hoping using src.rpm would do >> *everything* I want *exactly* the way I want it to :-). > > No, rpm --rebuild only re-builds the binary rpm. You have to install it. > The install step in rpm is where the package manager actually installs > to a special directory (/var/tmp/something) as if it was system root, > then the files in this directory are wrapped up into a package. There's > another option called --build which will build and install onto your > system, but it won't create a binary rpm. > last post here, as I agree thread is now OT. WRT above- thanks for clarification. As I previously acknowledged, much reading needed. >> > Just passing the favour forward. And what's a.o.l.m? Another python >> > newsgroup *starts salivating* >> >> well, since you offered a pre-built LM binary, I assumed you were using >> Mandrake, no? We could really use another knowledgeable poster such as >> yourself on alt.os.linux.mandrake. >> >> peace > > Yep, I'm using Mandrake. I'll have to bounce over there. Now that we > seem to be talking about rpm exclusively as compared to python, this > thread is probably more appropriate for that group anycase. please see my request for help in building kdelibs2.1.2.src.rpm From Sir-XaoS at gmx.net Wed Jun 27 08:45:20 2001 From: Sir-XaoS at gmx.net (C. Koehler) Date: Wed, 27 Jun 2001 14:45:20 +0200 Subject: access to subfolders References: <3B39D4EA.A000782F@gmx.net> Message-ID: <3B39D560.77782F9A@gmx.net> oops- did I forget do mention? I work with Zope, so- the folders are ZopeObjects, not 'real' ones. From aleaxit at yahoo.com Fri Jun 8 03:20:49 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 8 Jun 2001 09:20:49 +0200 Subject: Why should i use python if i can use java References: <9fngvl011jg@enews2.newsguy.com> <006d01c0ef8c$01af4ee0$0300a8c0@arthur> Message-ID: <001801c0efeb$8bff6ee0$102b2bc1@cadlab.it> "Don Dwiggins" writes: ... > > I've posted very extensively about it, and how I prefer 'lightweight > > proxies' instead -- instances that have no state (but rather delegate > > all state, and possibly all behavior, to a singly-instanced object not ... > Sorry, I guess I missed those posts. I apologize for the incomplete reference, but google surely doesn't make it attractive to refer to their archive, what with their ugly URI's (there may be a systematic way to simplify them, as there was for deja, but if so then I haven't found it yet). Anyway (please remember that each URI is really meant to be on a single line:-)...: http://groups.google.com/groups?hl=en&lr=&safe=off&ic=1&th=303263c728caff3a, 4&seekm=8s5afj0cov%40news2.newsguy.com#p http://groups.google.com/groups?hl=en&lr=&safe=off&ic=1&th=90fe81cf878b00fd, 9&seekm=91d23f0jk7%40news1.newsguy.com#p http://groups.google.com/groups?hl=en&lr=&safe=off&ic=1&th=e61b533755e27c16, 10&seekm=91lhdb0mb%40news1.newsguy.com#p http://groups.google.com/groups?q=singleton+design+pattern+group:comp.lang.p ython+author:Alex+author:Martelli&num=20&hl=en&lr=&safe=off&scoring=d&rnum=6 &ic=1&selm=934uei02u7m%40news2.newsguy.com http://groups.google.com/groups?q=singleton+design+pattern+group:comp.lang.p ython+author:Alex+author:Martelli&num=20&hl=en&lr=&safe=off&scoring=d&rnum=4 &ic=1&selm=9bpdsv026s8%40news1.newsguy.com http://groups.google.com/groups?hl=en&lr=&safe=off&ic=1&th=6caf333bec7f9aef, 7&seekm=9c48mn020mv%40news1.newsguy.com#p Far from exhaustive, of course, but reasonably representative of what I've posted on this subject to this newsgroup in last October, December, April. I've argued elsewhere about SDP being best not used in other different contexts (COM, C++, Java) -- the reasons are slightly different in each case, but some (inappropriate resistance to design-constraint changes for the SDP, for example) apply rather widely. > From the above, it sounds like you > still start with an SDP-style singleton Maybe, but not necessarily. Since the singly-instantiated-object and its instantiation mechanisms are not exposed, but rather are normally internal implementation details within a single module, it's relatively irrelevant what (if any!) mechanisms are being used here. I don't see, offhand, what advantages SDP would bring in this specific case wrt more trivial just-instantiate-once approaches to single-instantiation -- no SDP forces are really in play. If there was an SDP _already_ exposed from somewhere in a library/framework that I couldn't touch, then I could hide it behind proxies, of course -- but the SDP, if there, is just an irrelevant minor annoyance in this case. If the framework or library had no single-instantiation constraint I might just as perfectly-well instantiate just once and use the proxies in exactly the same way. > for the proxies to "point at", then > add the LWP class for users to instantiate; this is essentially a Bridge, > which fits your description of the advantages -- you allow the "state > package" to be changed while not affecting the clients and, as you also > describe, you can evolve the LWP separately (e.g., subclassing). It looks > to me as though, rather than replacing one pattern with another, you've > created a nice composition of two patterns. Of course, your LWPs, being > Featherweights, could be used in other ways as well. I disagree, because the SDP *is* all about exposing the 'single instance' constraint to client-code -- when client code becomes supposed to NOT see/access the singly-instantiated-object directly, but rather only through proxies, what does SDP buy any more? I do agree that the applicability of featherweight proxies is very wide -- more generally, I see this as a special case of a general technique (which Python facilitates wonderfully well, but is well applicable elsewhere too, and *particularly* apt in COM for example): decoupling object identity, object state, and object behavior. State and behavior are (mostly) still seen as 'bundled' when looked at from client-code, but objects delegate all or part of their state to other objects 'behind the scenes'. The unit of reuse, in such a scenario, is not the single class but the package (aka category, cluster, area, module, ...) -- I give the classic references to, and a summary of, R. Martin's "Reuse/Release Equivalence Principle" in the post: http://groups.google.com/groups?q=unit+reuse+release+author:alex+author:mart elli&num=20&hl=en&lr=&safe=off&rnum=2&ic=1&selm=9elmp4010u1%40enews2.newsguy .com and I don't think I can explain better than he does WHY taking the class as "the granule of reuse" (or, of design!) is simply inferior. OO has long been infected with excessively class- centered thinking, but it's been breaking free of that mindset for a while now. Maybe the SDP is one aspect of an excessive reliance on "one class to bind them all"...:-). Alex From mwh at python.net Sun Jun 17 05:26:59 2001 From: mwh at python.net (Michael Hudson) Date: 17 Jun 2001 10:26:59 +0100 Subject: Any other Python flaws? References: Message-ID: Michael Chermside writes: > Martijn writes: > > Further things possibly wartlike, though this one never bit me, is > > the possibly to assign to None, definitely a weird idea when you > > first encounter it. > > Gee... I had no idea this was possible. Surely it's a bad idea... right? Well, yes. > Can anyone name any reason why it's good to be able to assign to None? Less complexity in the interpreter? > Barring that, I figure there must be a good reason why this isn't a > syntax error. None not being a reserved word may be part of it... it's > just another value in __builtins__. This is a clean and elegent design, > but there's something dangerous about being able to change None. Only if the other people working on your project are idiots. Was it Phil Hunt who just wrote in other post "there's another thing to stop me doing - that it's really really stupid". > Oh well... at least people don't bump into this one much. And if you > accidently clobber it, you can restore things with: > > def __None(): > pass > None = __None() Sort of. Usually None resides in __builtins__, as you pointed out, and going None = 1 will put a variable called "None" into either a local or the global scope, so to revert this you will need to do del None (this will only really work in global scope, but never mind...). > I guess I better start putting that at the top of all my modules as > defensive programming <1.0 wink>. Err, yeah <+inf wink>. Cheers, M. -- Get out your salt shakers folks, this one's going to take more than one grain. -- Ator in an Ars Technica news item From tim.one at home.com Fri Jun 15 16:45:33 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 15 Jun 2001 16:45:33 -0400 Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: [Robin Becker] > Who owns the generator state is it the caller or the callee? Neither: it's part of the generator-iterator. Under the covers, it's simply the callee's activation record ("frame"); the primary trick to implementing generators is simply to refrain from decrementing the frame's refcount when leaving the function. The generator-iterator holds a reference to the frame instead, and the frame will be discarded as a matter of course when the iterator becomes trash. From chat at linuxsupreme.homeip.net Fri Jun 8 14:05:55 2001 From: chat at linuxsupreme.homeip.net (Chad Everett) Date: 8 Jun 2001 13:05:55 -0500 Subject: Passing back an array from an extension module? References: <9fqqqo$1p3e$1@newshost.nmt.edu> Message-ID: On Fri, 8 Jun 2001 09:28:33 -0600, Bob Greschke wrote: >Is this a job for NumPy? > >I have a C extension function that malloc()s an array of int32s, calls >another C function which reads/decodes a file of data and fills in the >array. Then I need to pass that back to the Python side for graphing >the values. I initially thought I could just create a tuple and pass >that back, since nothing is going to be done with the values except to >draw a graph, but there is the possibility of there being 16,000,000 >data points...that makes for a slightly large statement, doesn't it? >It doesn't look like I can do this with arrays in stock Python, but it >does look like I can do it with the NumPy arrays. Is that correct? > >Now what about Py_DECREF, INCREF and all of that stuff in these >situations? I read through a number of posts on dejagoogle that were >talking about this, but they only confused me more. :-) > Page 107 of "Python Essential Reference" re: the array modules states: "....The resulting arrays are not suitable for numeric work....To create storage- and calculation-efficient arrays, use the Numeric extension" In other works, use NumPy. If I am interpreting your question correctly, I think the answer is 'yes' it's a job for NumPy. Chapter 12 of the Numerical Python documentation is: 12. Writing a C extension to NumPy NumPy provides two functions for creating NumPy arrays in C: PyObject * PyArray_FromDims() PyObject * PyArray_FromDimsAndData() The second function lets you create a NumPy array object that uses a given memory block for its data space. -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From bradclark1 at msn.com Mon Jun 18 03:21:11 2001 From: bradclark1 at msn.com (bradclark1) Date: Mon, 18 Jun 2001 00:21:11 -0700 Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? References: <3B2B60AD.942719AE@earthlink.net> Message-ID: "Paul Prescod" wrote in message news:mailman.992809646.24580.python-list at python.org... > res04o20 wrote: > > > >... > > > > And lastly, ActiveState has announced "Visual Python". Only problem is, you > > gotta have MS .Net. (shudder) (Yet another implementation of Python. This > > time in C#. Another learning curve to be ultimately successful.) > > You are conflating two different things. Visual Python [1] and Python > .NET [2] are completely unrelated (but interoperable, of course) > > [1] http://aspn.activestate.com/ASPN/Downloads/VisualPython/ > [2] http://aspn.activestate.com/ASPN/NET/ > -- > Take a recipe. Leave a recipe. > Python Cookbook! http://www.ActiveState.com/pythoncookbook > Am I missing something here? From what I read at the above it says for .net. I didn't see anything else about it? Brad From michael at stroeder.com Sat Jun 23 18:27:44 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Sun, 24 Jun 2001 00:27:44 +0200 Subject: ANNOUNCE: web2ldap 0.9.4 Message-ID: <3B3517E0.9571A361@stroeder.com> HI! Find a new release of web2ldap on: http://www.web2ldap.de/download.html web2ldap is a web-based generic LDAP client written in Python. Ciao, Michael. web2ldap 0.9.4 Release Date: 2001-06-23 Changes since 0.9.3: * Fixed displaying of iPAddress attribute in certificates. * Abandoned global configuration parameter web2ldapcnf.misc.script_method. * Slightly improved excpetion handling especially of logging/ignoring user-aborted connections, etc. * Determining appropriate charset used with browser was improved: mainly proper parsing of capability values. * A lookup of SRV RRs is automatically done if a LDAP URL does not contain a host name but a "dc-style" DN (a DN formed by domainComponent attributes). * New configuration sub-module fastcgi. * Some really significant performance optimizations in ldapthreading module. Former approach in method LDAPObject.result() was brain-dead and slow. * Web session ID is now passed around in PATH_INFO instead as a hidden form field. This means less HTML bloat and it decoupled session retrieving from form processing. * If ldap.NAMING_VIOLATION occurs during add the user can reedit his input. * Fixed smart login search with user names containing NON-ASCII chars. (sigh!) * Fixed wrong passing of parameters when calling function ldapbase.SmartLogin(). * Use timeout search for smart login. From bokr at accessone.com Fri Jun 1 13:05:08 2001 From: bokr at accessone.com (Bengt Richter) Date: Fri, 01 Jun 2001 17:05:08 GMT Subject: Against PEP 240 References: <3b16a5e2.10711472@wa.news.verio.net> <9f6lge$doe$1@panix6.panix.com> Message-ID: <3b17ca9e.47602448@wa.news.verio.net> On 31 May 2001 16:52:46 -0700, aahz at panix.com (Aahz Maruch) wrote: >In article <3b16a5e2.10711472 at wa.news.verio.net>, >Bengt Richter wrote: >> >>Note the following "recovery" of exactness, assuming the result has >>two legitimate decimals ;-) >> >> >>> 0.98 >> 0.97999999999999998 >> >>> "%4.2f" % (.98,) >> '0.98' > >That's what Python used to do. Problem is, error propagates rapidly, >especially with multiplication, division, and addition/subtraction of >numbers with differing magnitude. Well, I was talking about using an error-correcting-code (ECC) concept to prevent propagation of errors, not just finessing the final output. I guess my tail end example was misleading 8-<:^) From aleaxit at yahoo.com Sat Jun 16 04:08:31 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 16 Jun 2001 10:08:31 +0200 Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> <9gclvm02tte@enews1.newsguy.com> <9gelk3$324$2@216.39.170.247> Message-ID: <9gf434089d@enews1.newsguy.com> "David LeBlanc" wrote in message news:9gelk3$324$2 at 216.39.170.247... ...[snipping lots of interesting asides]... My last words on this thread -- I hope. I've got a trip coming and too many things to do in the too-short time before I leave, to waste more hours flaming back and forth. If you need to make sure I see some specific question, observation or whatever, pls cc me, as I may skip any future posts in this thread. > > if something: > > ... > > and > > if not something: > > ... > > and *NOT* > > if something is 1: > > ... > > or > > if something is 0: > > ... > > or any "aliases" of these flawed forms. > > If "naive newbie" makes a programming error he/she is going to make a > programming error whether or not alias is present. This helps, it does > not guarantee that you won't make mistakes. In fact, one alias example you gave specifically ENCOURAGES this likely beginner-without-C/C++-background mistake, by, as you said, offering a seductively nice "is false"/"is true" anti-idiom (my coinage, but similar to the use of "anti-pattern" to describe a recurring way to design or code that damages program qualities or productivity). Encouraging beginners to err does make it more likely they'll err. > > "a newbie who seeks simplicity" consider: > > > > const.magic = 23 > > > > less simple than > > > > alias magic : 23 > > It's not less simple - nor is it more complex. It's more complex because there is a new keyword "alias" whose syntax is different from all others. The colon in a dictionary display takes an EXPRESSION on either side, this one would take an expression on the right and an IDENTIFIER on the left -- a terribly subtle distintion to impart to a beginner. The former usage relies on the assignment-syntax which any beginner learns rapidly, and makes absolutely no specialcase to be learned in ANY sense, neither syntactically nor semantically. Having less to learn is simpler. > Your forgot the "import > const" bit needed for your part unless one does what you suggest and > manually add it to the default libraries (which then is loaded by every > program - I don't know if Python does "lazy loading", so this might not > be a valid arguement). What fun for a newbie! import is 'lazy' per-module but not per-run (it does do a tiny amount of work the FIRST time it's executed in a program's run). But Python does require import for extremely basic tasks such as accessing the program's arguments or explicitly exiting from the program: in either case one first does "import sys", before accessing sys.argv or calling sys.exit. Therefore, a beginner WILL already know that, before just about *ANY* foo.bar is used, one does "import foo" -- nothing new to learn. So, if const were to be explicitly imported (probably wisest), it would not add to Python's complexity in the least. > The thing that an alias does address that your method does not is that if > the newbie does "const.magic = 23" and then he/she imports some nice > module, he/she is not going to be confused by the imported module's > changing the value of magic... sys.modules['const'].magic, in "my method", lets itself be bound ONCE (globally). Therefore your claim in this paragraph is counter-factual. If anything, you might critique the global nature of constants (although you had hypothesized it as a possible enhancement, I believe). > What "simple keword" syntax are you referring to? It does follow the idea > of key : value in dictionaries and that many other statements have one > part separated from another by a colon. All compound statements in Python have uniform syntax: [other optional stuff] : # leading clause [maybe other clauses of similar form] and 'alias' doesn't match this -- so it's not a compound statement and has no business whatsoever with the way a compound statement uses its colon[s]. Non-compound statements are called simple statements, and except for assignment they're all uniform in syntax: [other optional stuff *WITHOUT* magic colons] The dictionary-display form, the other use of colon in Python apart from compound statements, has the following characteristics: it is used within braces { } it is TOTALLY INDEPENDENT of what kind of statement it appears in -- it's an EXPRESSION on both sides of the colon you have EXPRESSIONS (so, if either is an identifier, it stands for whatever is already bound to that identifier, NOT "for itself"!!!) Your desired use of colon satisfies NOT EVEN ONE of these three rules. Its VAGUE SIMILARITY to an existing form accompanied with crucial semantic distinctions becomes therefore a serious hindrance. The fact that the issue has subtlety makes it even worse. Syntax sugar is much like government: it can't really do all that much good when it's good, but it sure CAN easily do HUGE harm when it's bad. It's hard to conceive of worse syntax sugar than one ACTIVELY MISLEADING, similar but NOT equal to other spots in the language. See for yourself: foo = 1 bar = 2 foo = bar this is an assignment: the LEFT-HAND identifier "STANDS FOR ITSELF" and gets bound or (as in this case) rebound, without *ANY EFFECT AT ALL* on whatever (if anything) it was previously bound to (except of course that an object becomes eligible for recycling when all references to it disappear). The '=' separator says exactly this: "my LHS identifier is NOT being used as an expression". The RIGHT-HAND identifier, otoh, IS being used as an expression -- it matters not a whit what the identifier itself is, it DOES matter (it's the *only* thing that matters) what OBJECT it is bound to. The other (non-assignment) case in which '=' signals the same thing: keyword-style (named-style) for parameters to a function. Again the LHS identifier STANDS FOR ITSELF (it gets bound *in the namespace of the CALLED function*). Vs: xx={foo:bar} BOTH identifiers here are used as expressions. They are not and can NEVER be rebound by such usage. You're proposing to use a colon *EXACTLY* like an equals-character is always uniformly used in Python: to have its LHS identifier stand for itself (and be bound or rebound) WITHOUT reference to or effect on on whatever (if any) it was previously bound to. Now try to write a couple of paragraphs explaining this anomaly, as we would have to explain it to all Python newbies forevermore. "All cases where an LHS identifier stands for itself are denoted with an '=' separator *EXCEPT*... the colon always terminates the leading clause of a compound statement, *EXCEPT*... the x:y form is an expression when used in dictionary display, and in that case it of course follows ordinary expression rules (each subexpression is evaluated), *BUT* in the magical alias statement x:y is not an expression and follows completely different rules, to wit... all statements except assignment begin with a reserved keyword and are either simple keyword statements, or compound statements, OR alias which is completely and utterly different from ALL other statements because...". Ohmygod. I have a hard enough time explaining the *PERFECTLY SIMPLE, REGULAR AND SENSIBLE* underlying rules of Python syntax and semantics, in ways that are (all at once:-) full, precise, readable, concise, and memorable -- even a TINY durned irregularity such as the use of parentheses in 'class' vs 'def' when no bases (resp formal arguments) are present already rankles (let's not get into "print>>", *PLEASE*)... your "alias" would throw a huge spanner into the works. "nor is it more complex" *INDEED*...!!! > > lines? In a script using "module const" there may or may not be a > > single line > > import const > > for explicitness (the alternative is having it performed implicitly > > at startup, e.g. by sitecustomize.py &c &c, placing const in the > > __builtin__ module, of course). That's up to the "experienced > > developer" who decides constants are necessary at his/her site. > > Heaven forefend the newbie using what is generally considered good > programming experience from the start. Let them develop the bad habbit of > using magic numbers and other obscurities and then, once the bad habbit > is ingrained, introduce the idea of consts with meaningful names... Wow, > wish i'd thought of that!. Maybe it was my mistake, but I was under the > impression that one of Python's objectives was to be a teaching language. > Better to teach good practice from the start isn't it? Sure, and good practice is to NOT rebind what should not be rebound rather than do it with abandon and rely on a compiler to rap your knuckles for it, because the compiler will NOT be able to catch ALL of your wanton rebindings anyway. Good practice is also to be fully explicit about what you're doing, whence the "import const" is a move FOR good practice. A bare identifier without indication of where it's coming from -- is it rebindable or not? You can't tell -- there is NO localized indication in the identifier itself. What advantage do you purport for having rebindable and non-rebindable identifiers look exactly the same? const.something clearly and locally indicates "hey guy, I'm not rebindable". Now *THAT* is good practice. And please don't imply I like "magic numbers or other obscurities" just because I loathe, detest, abhor and reject your "alias" proposal (the specific killer is the use of ":" -- with an equal sign it would just be an ordinary bad proposal, the colon makes it truly horrid). I like things being NAMED more often than not -- well chosen names are a big help. But Python's existing naming mechanisms are good and fully sufficient to teach beginners good practices, including that of "just don't do it" as opposed as "the language is your nanny and will spank you whenever you do something naughty". Adding a "const" module, for non-rebindable constants which need global scope, is not necessarily a bad idea -- such needs do arise, and if one must have globals it IS better to make them non-rebindable when that is at all feasible. But it's very far from needing to add a new kind of statements -- much less one ripe with strangeness wrt all of the rest of the language...! > (Sorry, the word is "extraneous" - i'm a prgammer not a dictionary :). I > actually do spend considerable time on longer posts proofing.) Wasn't meant to be a spelling flame -- just a doublecheck in case you were trying to say something different and I had misunderstood. > > > with more lines of code, not to mention the antics needed to do something > > > that should be as simple as possible (imho). > > > > What "antics"? If you want 'const' to be activated by default > > in every Python installation (e.g. in site.py), write a PEP > > proposing just that. You DO realize, of course, that no matter > > what little chance such a PEP may have, it IS going to be at > > least a thousand times more likely to be adopted than anything > > that will introduce a new keyword and thereby break perfectly > > working code -- that's something that can *possibly* happen > > only for really momentous developments (such as the new proposed > > "yield" keyword-statement for generators) which DESPERATELY NEED > > a new statement (can't POSSIBLY work halfway-decently without). > > Why? Is there something you know about how well new ideas are viewed by > the core python team that I don't? I guess we'll never see the Apparently, there is... "first, do no harm" is close to a prime directive (*RARE* blotches such as print>>blah notwithstanding). > introduction of another Python keyword like... hmm... "do" since it might > break perfectly working code? I'd be clever here and point out in Latin > that languages that don't grow die... but I don't know Latin since it's > dead! Oh, do you know all non-dead languages? Wow -- must be many thousands of them right? Funny enough, Latin (and to a lesser extent Greek and Sanskrit) are known far more widely than all but a handful of "living" languages. Check, just for an example, http://www.yle.fi/fbc/latini/index.html -- "Bush Europam circumit", "Novum Regimen Britanniae", and other news of the day in the sweetly artificial and elegant tongue of Caesar and Cicero (which never really was Latin as people *spoke* it, of course). Sigh, it seems we're both ramblers at heart, whence all of the asides. Back to our muttons -- a language can grow in many and important ways WITHOUT breaking working code. Python only introduces incompatible changes *MOST CAREFULLY* -- either when a previously tolerated practice was anyway bad and it was deprecated in the docs (which can hardly apply to any use of a perfectly ordinary word which is slated to become reserved!), or in *TRULY MAJOR* circumstances where there is really no way new functionality can be supplied well WITHOUT the use of a new keyword. I think the proposed 'yield' is the first new keyword that stands a chance of making it into Python in MANY years -- it does meet both key criteria (truly major, no real semi-decent alternative). 'alias', IMHO, has _less_ chance than a snowball in hell (the latter *might* happen to end up in one of the _frozen_ circles, after all!). But note that channeling Guido is NOT my specialty -- gotta ask the timbot for that. > Frankly, while it might not be as DRAMATIC as GENERATORS, in it's own > quiet way, *I* think it's just as momentuous. You think the differences in functionality offered between const.foo=bar and alias foo:bar are as momentous as generators?! Oh my. > (As for "yield" - whatever > does a generator need yield for? My understanding of generators is that > they produce a new value based on retained state, not actually generate a > huge sequence - oops, there I go digressing again.) Yes, and? Every yield "suspends" or "freezes" the state, ready for the _next_ "new value" when it will be requested. > I don't see this as anything as earthshaking as introducing nested scope > which is going to cause far more problems in changing program structure > (when it becomes the default) then changing the name of an identifier. > Nor do I think that this is the first new keyword that was introduced > since the inception of Python - of course, not having done the research > to find 1.3 or earlier if they're publically available, I won't make such > a bald statement. I said "years", not "decades". Python's inception dates back to 1990, after all. > > > One can certainly argue that this is syntactical sugar. It does however > > > serve a multitude of good purposes among which are: maintainability; > > > clarity; consistancy; correctness; good programming habbits; - a not > > > inconsiderable set of advantages for a little sugar. > > > > I fail to see ANY of these advantages when comparing your "alias" > > with a "const" module installed by site.py. How is > > alias magic : 23 > > more maintainable, clearer, more consistent, more correct, or > > a better programming habit than > > const.magic = 23 > > ?!?! Please bring SOME kind of argument for such extraordinary > > assertions... your bald statements are not "support" for them! > > I suggest you read an introductory book on good programming practice. If > you fail to see any of these advantages, then I shudder to think about > your code quality. Seriously, please bring SOME kind of argument for > saying that such notions are NOT a better programming habbit then... etc. *WHAT* "such notions" are you blabbering about? We're comparing your proposed horror, "alias magic:23", versus the sane alternative of "const.magic=23". What *NOTIONS* are involved in "favour" of your absurdity? And if you want to go into flames and ad hominem attacks, dear fellow, I think you've met your match. I *shouldn't* waste my time flaming total unredeemable idiots, and it will make Steve Holden cry, but hey, there IS a limit to the amount of idiocy and insults one can tolerate, isn't there? I DO fail to see ANY advantage at all for your proposal, which I consider a serious contender for the title of worst language-modification-change suggestion of the year (among many other worthy contenders of course), compared to the obvious low-key alternative of having site.py (or sitecustomize.py) "install" a const module in sys.modules (and optionally in __builtin__ -- I'm neutral about that last part). I believe the syntax you propose is despicable, the semantics inferior, the invasiveness on the language an obvious problem that even an average opium addict would not have failed to notice (suggesting that your awareness is below that of said average opium addict:-), AND your shudders about the quality of the code I write (with or without const.blah:-) insulting, idiotic, and uncalled for. There -- so much for diplomacy. > How is your suggestion that a new user: > 1. Figure out how to import a feature that's inherantly available > in many other programming languages. Learn to read, jerk -- you just QUOTED it, ferchrissakes! > > with a "const" module installed by site.py. How is ^^^^^^^^^^^^ If it's installed by site.py, ***WHY*** would a new user have to "figure out how to import" it?! CHEEZ... > 2. Make sure to not ever change any variable meant to be constant. Did you MAJOR in this kind of behavior, or does it come natural to you? If you ever *TRY* to rebind an attribute in const, an exception is raised, just as if you ever try to divide by zero, or use a variable that doesn't exist. Have you READ the const.py code I posted?! Have you *UNDERSTOOD* it, or is it your normal behavior to go around proposing changes to a language you understand so well as to be unable to understand what a few lines of elementary code in the language *DO*, when such lines are served to you on a plate (since apparently you were unable to come up with them yourself)? I spell it out AGAIN, just in case endless repetition can finally penetrate your apparent drunken stupor: if site.py installs const, a new user will have to 'make sure' he or she never rebinds const attributes in exactly the same sense in which he or she makes sure that he or she never divides by zero nor uses a non-existent variable -- if the errant behavior happens, Python raises an exception. This is how all errors are diagnosed in Python. > 3. Figure out why the program won't work when const.magic magically > changes because they imported a module that changed it without notice or > warning. See point 2. If the module they import tries to rebind an attribute of const that is already bound, there will be an exception. > 4. How are you going to ensure that developers are going to > indentify every "meant to be constant so don't use this identifier as a > constant" constant that they create? Heck, you can't even get programmers > to do comments reliably and that's built in now! Forstalling the obvious > argument, of course there is nothing that ensures that any developer is > going to practice safe programming and use an alias... this isn't meant > to legislate against stupidity (who was that king that decreed that the > tide not come in?) but rather to facilitate doing things more correctly. > any better then what i've proposed? You claim *ADVANTAGES* for your 'alias' horror versus the obvious "const installed by site.py" solution, bubba. *ADVANTAGES*, get it? You want to break working code (see below), *SHOW* me the huge pluses your proposal gives, that make it worth breaking good code (ha). Now you're arguing that your wretched "alias" has no DISADVANTAGES on this specific point wrt "const" -- neither can in any way force any developer to use it. Let's say they're even on this score -- how does this justify your extraordinary claim of *advantages* for your horrid proposal wrt const?! And more, your SHUDDERS at my code's quality? Do you think that to write good code one must be just as confused as you are and claim a "lack of disadvantages" as an *ADVANTAGE*?! > > > Finally, this wouldn't break any code, > > > > Puh-LEEZE. *ANY* use of 'alias' in existing code would be > > broken. Let's not make such obviously-false assertions... > > Yeah, that was my error - of course anyone can use "alias" as an > identifier. I refer you to my previous remarks with respect to changes in > Python since the first version, above. At least, unlike the recent furor > over changing the semantics of "print", this is new. Nihil sub sole novi. Just about every stupid change to Python is requested over and over and over again on this newsgroup (hardly ever with the needed Python Enhancement Proposal followup, to be sure) -- often there is a quirk (here, specifically, that crazy use of ':'), but the substance is just about always the same. People who don't fully understand a language, yet, instead of striving for comprehension (which is NOT all that hard in Python's case), start blabbering to CHANGE it! > > Alex > > Fred > > P.S If you're confused by "Fred", I changed my identifier - oops, did I > forget to mention that in the docs? I think this was one of your smartest moves -- if you can manage to change your name, maybe you can live down the shame of this "alias" proposal. Shudder at my code's quality, will you...? Alex From jicondon at us.ibm.com Mon Jun 4 17:49:14 2001 From: jicondon at us.ibm.com (Jeffrey I Condon) Date: Mon, 4 Jun 2001 14:49:14 -0700 Subject: fyi - Getting started with PyXPCOM Message-ID: fyi - May be of interest. In the first of three articles on XPCOM programming in Python, Uche Ogbuji covers PyXPCOM installation. http://www-106.ibm.com/developerworks/components/library/co-pyxp1.html?open&l=906,t=grc,p=pyXPC From apederse at my-deja.com Mon Jun 11 05:13:38 2001 From: apederse at my-deja.com (Asle Pedersen) Date: 11 Jun 2001 02:13:38 -0700 Subject: Problem with Cookie module load function Message-ID: <66fc4519.0106110113.464030c8@posting.google.com> I am trying to load the following cookie, received from a server: Set-Cookie: SITESERVER=ID=24752d75a82c30c709a736c1af4b01e5; expires=Monday, 01-Jan-2035 00:00:00 GMT; path=/; domain=.editedout.com The Load function seem to be unable to parse it correctly returning SITESERVER='ID' instead of SITESERVER='ID=24752d75a82c30c709a736c1af4b01e5'. Has anyone else experienced this problem. One solution is to parse the cookie data myself and skip the load function entirely. I guess that the cookie is not conformant with any standards, but there is little I can do about that.... any suggestions on what to do? /Asle From beeblebrox at operamail.com Fri Jun 22 01:56:14 2001 From: beeblebrox at operamail.com (Ford Prefect) Date: 21 Jun 2001 22:56:14 -0700 Subject: Zip problems Message-ID: <8cb9792f.0106212156.572e7e17@posting.google.com> I have problems using zipfile. Script below makes a zip file but when I try to extract files from the zip with WinAce or Windows Commander I get CRC error. At first I thought the problem was in Windows Commander and contacted the author (I also sent him the zip file). This is (part of) his reply: "This ZIP file is indeed faulty. In the header it has a bit set that the CRC is stored after the packed data, with header PK#7#8. But this header is missing and there is no CRC following the data. The CRC field of the local header is also empty." WinAce also reports CRC error. Can someone tell me what can I do to make zipfile work correctly. Or is it something in the script? I am using ActiveState ActivePython 2.10 Build 210. import os import os.path import time import zipfile import glob srcpath = 'c:\\' archive = 'c:\\' archive += 'backup' archive += time.strftime('%Y%m%d', time.localtime(time.time())) + '.zip' zipf = zipfile.ZipFile(archive, "w") print 'creating:', archive files = glob.glob(srcpath + '*.bat') for file in files: if os.path.isfile(file): print 'adding:', file zipf.write(file, os.path.basename(file), zipfile.ZIP_DEFLATED) zipf.close() print archive, 'created' From loewis at informatik.hu-berlin.de Sun Jun 17 07:29:34 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 17 Jun 2001 13:29:34 +0200 Subject: Solaris 8/x86: Build problems References: <3b2a7fc2.5552674@news.laplaza.org> <3b2c215f.791227@news.laplaza.org> Message-ID: xyzmats at laplaza.org (Mats Wichmann) writes: > I'll go back and extricate that soon. Up until you get to distutils, > all the compile steps spit out for easy capture, but once you get the > the module building phase, it not longer automatically tells you what > each step is doing. It sure does. To re-run all compilation steps, you have to either make clean, or remove the "build" directory tree. distutils will then report any compiler invocation it issues. Regards, Martin From matt at mondoinfo.com Fri Jun 1 21:23:19 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Sat, 02 Jun 2001 01:23:19 GMT Subject: Scrolling Multiple Listboxes References: <829ac386.0106011019.30ba7f6f@posting.google.com> Message-ID: On 1 Jun 2001 11:19:59 -0700, kmdr wrote: >Does anyone know how to bind multiple listboxes to one scrollbar? >ie. how do I scroll multiple listboxes with one scrollbar?...I've >tried apply(object, args) methods but have not been succesful. Kapil, I'm sure that you're close to the solution. Interestingly, this is where Tkinter's strange scrollbar configuration comes in handy. What you do is make the scrollbar's command a routine that calls both listboxes' yview methods. I'll append an example: Regards, Matt #!/usr/local/bin/python from Tkinter import * class mainWin: def __init__(self,root): self.root=root self.createWidgets() return None def createWidgets(self): self.l1=Listbox(self.root) self.l1.pack(side=LEFT) self.l2=Listbox(self.root) self.l2.pack(side=LEFT) for count in range(42): self.l1.insert(END,"l1 "+str(count)) self.l2.insert(END,"l2 "+str(count)) s=Scrollbar(self.root,orient=VERTICAL,command=self.scrollBoth) s.pack(side=LEFT,fill=Y) self.l1.configure(yscrollcommand=s.set) return None def scrollBoth(self,*args): apply(self.l1.yview,args) apply(self.l2.yview,args) return None def main(): root=Tk() mainWin(root) root.mainloop() return None if __name__=="__main__": main() From sholden at holdenweb.com Thu Jun 28 14:40:03 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 28 Jun 2001 14:40:03 -0400 Subject: Sorting Apache Log Files References: <3B37B94D.E444BC5D@cs.utwente.nl> <1ca31bad.0106271243.58052b7@posting.google.com> Message-ID: Note, however, that you only get strptime() if your C library defines it. There's a pure-Python implementation, but for more general usage you can't beat the (free) mxDateTime module. See www.egenix.com regards Steve -- http://www.holdenweb.com/ "David Kirtley" wrote in message news:1ca31bad.0106271243.58052b7 at posting.google.com... > > Lenny Self wrote: > > >>> SNIP <<< > > > import string > > > > datestamp1 = line1[string.find(line1,"[") + 1:string.rfind(line1,"]")] > > datestamp2 = line2[string.find(line2,"[") + 1:string.rfind(line2,"]")] > > # Compare the date stamps and return appropriate value > > if datestamp1 < datestamp2: > > return -1 > > elif datestamp2 < datestamp1: > > return 1 > > else: > > return 0 > >ist.sort(compare) > > Writing sorted list to new file > >pen("d:/work/newfile.txt","w").writelines(list) > > That won't work like you think it will. That will do a lexographic > comparison (alphabetical) that will partially work but not when they > are on boundiries (worst case example: Jan < Apr works but Jul < Aug > doesnt.) > > The way to handle it is to convert it to a numeric time value: > > for the default Apache log format:: 00/Mon/0000/00:00:00 > > > from time import * > > timestamp = "00/Mon/0000/00:00:00" #<- insert a real timestamp here. > myTime = mktime(strptime(timestamp,"%d/%b/%Y:%H:%M:%S")) > > Now you can use myTime to make the comparison. > > David Kirtley From gardner at cardomain.com Fri Jun 22 19:33:49 2001 From: gardner at cardomain.com (Jonathan Gardner) Date: Fri, 22 Jun 2001 16:33:49 -0700 Subject: VI References: <9g9f1v$7oqr5$1@ID-11957.news.dfncis.de> <9gaul7$mth$2@brokaw.wa.com> <52e5ab5f.0106182325.4d1fe0d0@posting.google.com> Message-ID: <9h0kjj$h7f$1@brokaw.wa.com> Michael Robin wrote: > I just downloaded vim - wow! (I'm going to catch up on vim in the > c.l.p archives and see what she can do python-wise. Don't suppose > there's a VI mode for Scite, PythonWin or Komodo??) > > It's like riding a bike! I'd forgotten how much sense a "modefull" > editor made, and how fast you can edit by keeping your hands where > they belong. > I always thought a pointing device was great to draw pretty pictures > with - how did it get thrust upon us to perform every possible > function? Certainly a keystroke or two is more preferable than > "navigating" to a toolbar hieroglyphic that needs to be looked up > anyway? (If not WIMPS, what would have prevailed??) > > It must be late... > ZZ (works the same as :wq when you're tired...) > > mike > > > This is my setup for python: "Turn on syntax highlighting syn on " Tabstops should be at 8 where they always should be set ts=8 " But people have generally agreed upon 4 being where they would like it set sts=4 " And you want the indention level to go 4 at a time. set sw=4 " And this is to make sure no tabs get in your textfile. set et "And this is good for indenting. Don't need no advanced features. set ai If I could only figure out how to get it to indent the next line when I end a line with ":"... And if I get a file with tabs mixed in, I use ":retab" and it will fix everything the same. If you have a good version of the development (6.0ai is the last one that seemed to have no major problems... but there may be one past ak since I post this) you can do textfolding easily. :he folding I like to do this for python: :set foldmethod=indent :set minfoldlines=4 This makes it all easy to grok long functions in python and make sure everything is lined up right. zc to close a fold zC to close it all the way zo to open it zO to open it all the way zR to open every fold zM to close all the folds. Pretty easy to pick it all up. -- Jonathan Gardner "Infinity isn't all that large - except at the end." -- Uncle Al Please don't take anything I say seriously, even if you are really gullible. From seefeld at sympatico.ca Tue Jun 19 16:14:29 2001 From: seefeld at sympatico.ca (Stefan Seefeld) Date: Tue, 19 Jun 2001 15:14:29 -0500 Subject: nested classes References: <3B2E4725.535AB18E@sympatico.ca> <9gnn5c$b00$1@plutonium.compulink.co.uk> Message-ID: <3B2FB2A5.6A4257B0@sympatico.ca> gbreed at cix.compulink.co.uk wrote: > You're correct, I've found an example > > > > and an argument against them > > ok, well, this is a python list so let's not turn this into a C++ discussion. However, the above link contains a couple of wrong statements. To get this back on track, only this: class nesting uses the fact that a class (in C++) acts as an ordinary scope, so you can use it the same way as a namespace, to bind names to a common scope, and avoid name clashes if the name you want to define is general, but has a specific meaning in the scope within which you want to use it. ('Geometry::Point' for example). Back to my python code: I tried to mirror the structure of a package I provide ('Synopsis') in a Config class. Since the synopsis tool is very modular, each submodule contains its own set of parameters which you might want to configure. Passing all of them as command line options will quickly get very messy, so we figured we might just provide the possibility to write a config script that sets all the flags/options at the right scope. For example: Some options apply to more than one module, so it appears natural to define it in an 'outer scope'. This, however, assumes that 'inner scopes' (aka nested classes) can see the variables defined in outer scopes. I hope this somewhat explains what I'm aiming at... > But my head still spins when I try to think of a C++ class that > hasn't been instantiated. Again, we are talking about classes as scopes, not class instances. > class A: > def __init__(self): > self.prefix = 'usr/local' > class __B: > def __init__(self, parent): > self.prefix = os.path.join(parent.prefix, 'share') > def B(self): > return self.__B(self) > > print A().prefix > print A().B().prefix > > You could remember the parent, but that'd lead to a circular > reference (not such a bad thing for 2.x). right. This gets pretty messy too, as you are forced to use instances, while I was trying to avoid that. In fact, I could have used modules instead of classes, but since python constrains me to one module per file, I tried to get away with something a bit finer grained. > Perhaps if you give us C++ code of what you're trying to do, we > can tell you why you don't need to do it ;) right. That's exactly what I want. Please show me the right idiom to use in python to solve the above problem. And by the way, the project I'm talking about is 'synopsis', at http://synopsis.sourceforge.net/, a modular source code inspection tool with parsers for IDL, C++, python, and a couple of output formatters. The module structure is this: Synopsis/ Core/ Util AST Type Parser/ IDL C++ Python Linker/ Linker Formatter/ HTML TexInfo DocBook Dot ASCII ... and each node in this tree has its own set of parameters. Online docs are at http://synopsis.sourceforge.net/docs/index.html Regards, Stefan From uioziaremwpl at spammotel.com Fri Jun 29 15:42:06 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Fri, 29 Jun 2001 21:42:06 +0200 (CEST) Subject: Augmented Assignement (was: Re: PEP scepticism) In-Reply-To: Message-ID: On Fri, 29 Jun 2001, Roman Suzi wrote: > On 29 Jun 2001, Bernhard Herzog wrote: > > >"Alex Martelli" writes: > > > >> "Bernhard Herzog" wrote in message > >> news:6qn16r7i69.fsf at abnoba.intevation.de... > >> > I think the main problem (in as much as there actually is a problem) is > >> > that whether augmented assignment rebinds the left hand side depends on > >> > the type of object, i.e. whether the object implements the appropriate > >> > >> Right! I think the main advantage (in as much as there actually is an > >> advantage) is that whether augmented assignment rebids the left hand > >> side depends on the type of object. i.e. whether the object implements > >> the appropriate methods. This is called *polymorphism* and is a concept > >> of *HUGE* power. > > > >Well, polymorphism is certainly very important and powerful in python > >but in an of itself that's no argument in favor of the intricacies of > >augmented assignment in Python. Just because something could depend on > >the types of the objects involved doesn't mean that it should. > > In fact, many things depend on the type of the objects. Types of the > objects define what operation will be done. For example, in a simple > > A = A + 1 > > + operation is different for different A type. It is inevitable that not > everything is written every time. Everything could not be explicit > in any place. The problem which some people have with augmented assignment is not that they exist, but that they do not work as they expect (at least from the POV of some readers). I expect that ident op= expr works like ident = ident op expr At least that's what I'd have expectd comming from other programming languages. > >Augmented assignment doesn't actually offer anything that couldn't have > >been done with explicit method calls, > > They do. Some operations are better defined in terms of "+=". > For example, list.append() I think you mean list.extend(). ;) Cheers, Carsten -- Carsten Geckeler From kurian.amal at t-online.de Sun Jun 17 07:59:10 2001 From: kurian.amal at t-online.de (Amal Kurian) Date: Sun, 17 Jun 2001 13:59:10 +0200 Subject: qt or gtk? References: <3B2B609B.285DCB06@web.de> Message-ID: <9gi652$n7p$05$1@news.t-online.com> Dominic wrote: > (QT is not completely free but that doesn't make it bad, actually > it's the best X- Toolkit for C++ programming.) This is not correct, since Qt is available under the terms of the GNU General Public License (and even the Free Software Foundation considers this a free License ;) Have a look at: http://www.trolltech.com/developer/faq/free.html for further information regarding this subject. Kind regards, Amal. From support at internetdiscovery.com Fri Jun 22 21:29:28 2001 From: support at internetdiscovery.com (Mike Clarkson) Date: Sat, 23 Jun 2001 01:29:28 GMT Subject: New windows case sensitivity in Python 2.1? Message-ID: <3b33f0f2.6505854@nntp.ix.netcom.com> I seem to be seeing a new case sensitivity to the import command under windows (Win98 FAT 32). import _tkinter is failing from import Tkinter. If I open a DOS command window, and change to the Dll's directory, a DIR shows me _TKINTER PYD 22,528 06-13-01 10:53p _TKINTER.PYD in other words the so-called long file name is all upper case. Now if in that directory I do a (case sensitive) rename _tkinter.pyd foo rename foo _tkinter.pyd DIR shows me _TKINTER PYD 22,528 06-13-01 10:53p _tkinter.pyd and the import works. This is either ActiveState 2.1 binary or the AS source distribution build with MSVC 5. I've also had 'import idlever' fail from idle - same thing: it's a DOS 8.3 file name with no mixed case. No problem with execfile. I never has this problem under 2.0 Many thanks, Mike. From skip at pobox.com Tue Jun 12 17:01:53 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 12 Jun 2001 16:01:53 -0500 Subject: All functions from self and inherited classes In-Reply-To: References: Message-ID: <15142.33601.687524.256058@beluga.mojam.com> >> And a dir(self.__class__) returns methods, but only methods defined >> in B. Alex> Someone posted this code here ages ago.... [snipped] The (new) standard module inspect has a getmembers function (output wrapped for readability): >>> httplib.HTTP >>> inspect.getmembers(httplib.HTTP) [('__doc__', 'Compatibility class with httplib.py from 1.5.'), ('__init__', ), ('__module__', 'httplib'), ('_connection_class', ), ('_http_vsn', 10), ('_http_vsn_str', 'HTTP/1.0'), ('close', ), ('connect', ), ('debuglevel', 0), ('getfile', ), ('getreply', ), ('putheader', ), ('set_debuglevel', )] >>> h = httplib.HTTP() >>> inspect.getmembers(h) [('_conn', ), ('cert_file', None), ('endheaders', ), ('file', None), ('key_file', None), ('putrequest', ), ('send', )] -- Skip Montanaro (skip at pobox.com) (847)971-7098 From D.M.Pick at qmw.ac.uk Tue Jun 19 11:53:44 2001 From: D.M.Pick at qmw.ac.uk (please_no_spam_to_) Date: 19 Jun 2001 15:53:44 GMT Subject: Obsolesence of <> (fwd) References: <9f6el30dv5@enews2.newsguy.com> <3B16D681.E12A4554@Lugoj.Com> <9f7pmt029se@enews1.newsguy.com> <3B17D9B9.E3CA8EC8@Lugoj.Com> <9fjgjl$rp0$1@brokaw.wa.com> <3B1D8504.434DA7DD@Lugoj.Com> Message-ID: <9gnsi8$6c9$1@beta.qmw.ac.uk> James Logajan (JamesL at Lugoj.Com) wrote: : Nicely done! You've worked out how to have your cake and Edith too! Now if I : can only think of real world situation where <> does what you want and != : doesn't (since the latter seems to include the former, but note vice versa). : Any case where an element of a ordered set can be NOT less than AND NOT : greater than another element and still be NOT EQUAL to it? I'm not a : mathematician, but do infinities have these properties? A Group with a partial ordering? Or something like an Object representing an CIDR IP range. Then one might have: 192.168.1.1 < 192.168.1.0/24 < 192.168.0.0/16 192.168.2.0/24 < 192.168.0.0/16 192.168.0.0/16 > 192.168.3.0/24 192.168.0.0/16 <> 192.168.4.0 192.168.1.0/24 != 192.168.2.0/24 all true, but: 192.168.1.0/24 <> 192.168.2.0/24 is false when the relations are used to test if one CIDR block is contained in the other. -- David Pick From rnd at onego.ru Tue Jun 26 13:23:20 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 26 Jun 2001 21:23:20 +0400 (MSD) Subject: [OT] Is there any tutorial for those who learn Java after Python ;-) Message-ID: I want to learn Java (Not that I am dissatisfied with Python, but this seem to be "the must" to find a job ;-) And some simple things makes me wonder: public class JavaRules { public static void main(String args[]) { System.out.println(2+2+"a"); System.out.println("a"+2+2); } } Quick quiz: what this program will output? 1. syntax/compilation error (Java is strict typed!!!) 2. 4aa22 3. 4aa4 4. 22aa22 5. 22aa4 Your answer: [ ] * The question is, has anybody tried to write tutorial (even joking!) for those who wants to learn Java _after_ Python? Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, June 26, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "It is better to be brief than boring." _/ From michiel at htcs.nl Thu Jun 14 05:16:08 2001 From: michiel at htcs.nl (michiel) Date: 14 Jun 2001 02:16:08 -0700 Subject: Need Help building COM server in python Message-ID: <844df35f.0106140116.5f706fcf@posting.google.com> Hi, First of all, I'm a newbie, so my question may be simple. I have tried to make a simple COM object in python for the use in VB or Visual FoxPro. Therefore I have used the tutorial for building a COM server object in python. CODE CLASS: class HelloWorld: _reg_clsid_ = "{D4FF29AD-BCDE-4FE2-9896-892D2EBB5180}" _reg_desc_ = "Python Test COM Server" _reg_progid_ = "Python.TestServer" _public_methods_ = ['Hello'] _public_attrs_ = ['softspace', 'noCalls'] _readonly_attrs_ = ['noCalls'] def __init__(self): self.softspace = 1 self.noCalls = 0 def Hello(self, who): self.noCalls = self.noCalls + 1 return "Hello" + " " * self.softspace + str(who) if __name__=='__main__': import win32com.server.register print "Registering COM server..." win32com.server.register.UseCommandLine(HelloWorld) MY COMPUTER: PIII 550 400 meg internal Win 2000 Server Active python 2.1 installed I have admin rights PROBLEM: Registration of the object works. Creation of the object works (x=createobject("python.object")), but then there are no methodes I can access: "there is no such method" Can someone help me out or send me an example of a useable COM server object written in python? Thanks. From tdelaney at avaya.com Tue Jun 12 20:53:01 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Wed, 13 Jun 2001 10:53:01 +1000 Subject: Plugins in Python Message-ID: > Hi; > > How would one generally code something that would look at > some dir (or > list of dirs), and dynamically load .py or .pyc modules found > there that > where not previously known to the program. Obviously > following a standard > API... > > TIA > > Dave LeBlanc Simplest method: import sys sys.path.append(additionaldirectory) Tim Delaney From db3l at fitlinxx.com Fri Jun 1 15:35:37 2001 From: db3l at fitlinxx.com (David Bolen) Date: 01 Jun 2001 15:35:37 -0400 Subject: Copying files to multiple comp's on a lan References: <9f8k3v$1i04$1@news.cybercity.dk> Message-ID: "Henrik Berg Nielsen" writes: > I need to make a small script thats capable of copying a file from the > machine that its being run on to all the other machines on the lan. The > target path on all the other machines should be the same. The script should > take the path of the source file and the remote path to the shared folder(s) > as arguments. I'll define all the machines the file is to be copied to > elsewhere. (...) > I used to do this filecopying for each machine seperately with the Windows > Explorer, and seeing as its something that I do rather often, I'm beginning > to get a little bugged by this tedious method, and have decided that now its > time to make it a little more automated. > If you know of an already existing program that can accomplish this task for > me any pointers would be greatly appreciated. Since you mention Windows, I'd probably a Windows specific method since you can ask Windows to identify the machines on the LAN, and use a Win32 API call to perform the copy which in general will outperform any other script based approach. Here's a function from one of our upgrade scripts that replicates a distribution tree either locally or to a specific machine. In this case it assumes the source tree mimics the target tree off of the administrative share for C$ but that's easy enough to adjust or parameterize: import os, win32file def dist_files(machine, dist_root, filelist): """Replicates a set of files to the target machine. It is assumed that the filelist is relative to C: on the target machine""" if machine: root = r'\\%s\c$' % machine else: root = 'c:' for file in filelist: relative = os.path.normpath(os.path.splitdrive(file)[1]) if relative[0] == os.sep: relative = relative[1:] source = dist_root + '\\' + relative target = root + '\\' + relative print ' ', source subdir = os.path.dirname(relative) check_directory(root,subdir) # Even if told not to complain if file exists, CopyFile will fail # if the file is R/O, so we always try to reset that bit try: os.chmod(target,0777) except: pass win32file.CopyFile(source,target,0) This is designed such that the source tree mirrors the target location, thus you might make a source tree like: C:\DIST\ \DIR1 \file1.txt \DIR2 \file2.txt and assuming that for the target, C:\DIST should be considered equivalent to C:\, you could distribute this with: dist_files(,r'c:\dist',[r'dir1\file1.txt',r'dir2\file2.txt']) or if you are just copying from the true file location on the source (e.g., C: on source is C: on dest): dist_files(,r'c:',[filelist]) and of course you can automate the construction of the filelist if you like (os.listdir, glob.glob, etc...) Now, in order to determine what machines exist on the LAN, you can use code like this (the win32net call doesn't work on Win9x - you'd have to revert to a win32wnet approach): import win32api, win32net mymachine = win32api.GetComputerName() machlist = win32net.NetServerEnum(None,100) machines = [] for curmachine in machlist[0]: name = str(curmachine['name']) if name != mymachine: machines.append(name) # At this point machines is a list of machines other than myself -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From pedroni at inf.ethz.ch Fri Jun 8 18:29:32 2001 From: pedroni at inf.ethz.ch (Samuele Pedroni) Date: Sat, 9 Jun 2001 00:29:32 +0200 Subject: ROGER SESSIONS DISQUALIFIES JYTHON AS "FREEWARE" References: <3B208271.50B6D0D0@home.com> Message-ID: <3b21522d@core.inf.ethz.ch> Don O'Donnell wrote in message 3B208271.50B6D0D0 at home.com... > In the current issue of his monthly newsletter "ObjectWatch": > > http://www.objectwatch.com/issue_33.htm > > Roger Sessions, author of "COM+ and the Battle for the Middle Tier", and > ever a strong proponent of the Microsoft mantra from COM to DCOM to COM+ > to .NET, in his main article "IS JAVA LANGUAGE NEUTRAL", searches for > languages, other than Java, which run on the Java platform. I read it > avidly, expecting to find kind words about Jython. Alas, he classifies > JPython/Jython as "Freeware" and lumps it together with "School/Hobby > projects" and says: > > "Both of these categories include technologies > that show the feasibility of generating JBC from sources other than Java > (a > capability that is not in dispute), but do not include actual supported > implementations that would be used in a large commercial project." > (JBC == Java bytecode) I don't know Jim Hugunin (now at PARC) personally but I don't think it would likely qualify himself as an hobbist. About the current 2 devels : some more devels would be helpful, not much for quality but for other obvious reasons . regards, Samuele Pedroni. From j_f9 at yahoo.com Wed Jun 13 10:46:09 2001 From: j_f9 at yahoo.com (F. Tourigny) Date: Wed, 13 Jun 2001 07:46:09 -0700 (PDT) Subject: VI Message-ID: <20010613144609.43005.qmail@web14505.mail.yahoo.com> > From: "Chris Gonnerman" > 13 Jun 2001 07:53:54 -0500 > "Too basic?" How so? I've got hundreds of > thousands of lines of C and probably several > more thousands of lines of Python written using vi, > vim, etc. I find most everything other than emacs > too basic" (and emacs is a religion I've never > converted to). As I said, I'm rather fond of the old endearing beast, but I don't know if I would write thousands of lines of code with it (not that I could: I'm still a newbie). Hey, the thing won't even debug software in your place:) Greetings, Frederic __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/ From aleaxit at yahoo.com Sat Jun 2 11:28:22 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 2 Jun 2001 17:28:22 +0200 Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> Message-ID: <9fb0ju01a8a@enews2.newsguy.com> "David C. Ullrich" wrote in message news:3b18ea18.332276 at nntp.sprynet.com... ... > I said you cannot have complete information about > a physical system. You can't. An algorithm is not Let's take your original sentence again, snipless: """ A physical RNG can have the property that one cannot make any prediction about the value of the next bit even given _complete_ information about how the numbers are being generated. """ This says "GIVEN _complete_ information". Now you say you CANNOT "have complete information". The two statements are in contradiction. If you cannot have it, how can it be given? I don't see why you keep denying this obvious contradiction. I claim: if you cannot make a prediction it is because you are NOT given complete information. Whether that is because it cannot be given 'in principle' (physically) or because it just is not given, is mathematically rather irrelevant, it seems to me. So what does the "GIVEN _complete_ information" above is, if not a statement that you CAN be given complete information about > >So, to recap: the post I was replying to states that given > >[what you now state is] an impossibility, > > No. I never stated that it was impossible to have > complete information about the state of an algorithm. You didn't, but you did state and re-state that it's impossible to have complete information about the state of a physical system, and yet the key characteristic you stated for 'a physical RNG' begins with "GIVEN _complete_ information". > >> can have complete information regarding the state > >> of an _arithmetic_ _algorithm_. > > > >I assume that is your definition of "an algorithm"? > > It's not the _definition_, (and to the extent that > it is part of a definition it's not _my_ definition). It's a popular definition, though not universal of course -- Darren New seems to be debating on this same thread on the basis of the finitistic definition of 'algorithm'. Very well then, if you can conceive of algorithms whose state cannot be finitely described, then, there you are: prediction will be impossible with those algorithms because you can never possess all the relevant information. There, happy now? (I _think_ -- but am not a philosopher or mathematician so cannot feel sure -- that part of what Goedel shows is that arithmetic is powerful enough to model any other formal system, including the inconsistent-if-complete conumdrum, so I don't imagine it's the "arithmetic" part of 'arithmetic algorithm' that you imagine limits a non-finitistic algorithm predictability?) > Take it up with Heisenberg. If it's possible to have > complete information about a physical system then > physics is simply _wrong_. It may be right, it may be wrong, how does that affect mathematics anyway? You think mathematics should be changed based on what physical theories happen to match or not-match the alleged 'real' world, maybe...? > >> > From what I know of Chaitin's life work, > >> >it started with just the idea of defining randomness in > >> >terms of minimal amount of information (in bits) you need > >> >for prediction. If YOUR definition of 'randomness' is ... > I really don't have any idea what you're getting at here. > I never said anything about what's fruitful or interesting > or useful. JVN said anyone using arithmetic methods to > get random numbers is in a state of sin. It was stated > that Chaitin has shown that this is wrong. I didn't see > how, but I'm not familiar with his work, so I asked > how Chaitin's work showed that JVN was wrong. So far > I haven't heard the esplanation. I reiterate my suggestion that said explanation is most likely to be found in the less-than-200-pages of Chaitin's new book, given its title "Exploring Randomness", and that, not having yet read it, I could not presume to do it full justice. (But I have now ordered it, so that may change soon!-). Still, it doesn't seem mind-bending as a possibility: if randomness can be defined based on the number of bits needed for prediction (no need to require an INFINITE number of bits before the word can be used), why shouldn't arithmetic be quite usable to build a system whose output requires sufficiently many bits of info to predict, that its randomness is sufficiently high for a given purpose? What's "sinful" about it? > Probably "is in a state of sin" is not well-defined. Presumably was meant as a humorous quip? > I take the comment to mean that there is no "percect" > arithmetical RNG. It seems extremely clear to me that > there isn't, and I haven't heard anything that explains > how Chaitin's work _does_ show that there exists > a perfect arithemtical RNG. I'm not sure what you mean by "perfect" (or "percect" -- not sure if that was a typo, and if so, whether it was for 'percept' or 'perfect'). If you mean one requiring an infinite amount of information for prediction, I guess it would start with a halting-problem, Goedel numbers, or other equivalently-hard problems as modeled in arithmetic, and the random bit would be some low bit in a count of the number of operations needed to get a solution -- as the 'algorithm' would not be guaranteed to stop (which makes it non-finitistic, and thus, for those who DO require finiteness as part of an algorithm's definition, not an algorithm), there could be no bounds placed on the effort (information) required to predict (no bounds = boundless = infinite -- as hotly debated on a separate recent thread:-). I doubt very much that Chaitin wastes his precious time with these specific silly mind-games (thus showing once more he's a far wiser man than me:-), because that "perfect" (which was not in the original question) requirement for infiniteness is of little interest in this context. If we model random number generation as an adversarial cryptographic scenario, which does seem a productive way to look at it, then we are not required to come up with schemes which make our adversary require infinite work (information) to predict (and thus decrypt): it's enough that, for any ratio of our work encrypting (generating) for his decrypting (predicting) that is requested, we can come up with a setting that makes the ratio higher. And I believe (not being really up to date on the latest cryptography results, I 'surmise' might be closer:-) that so-called one-way-functions allow us to make the work-ratio predict/generate (decrypt/encrypt) higher than any pre-requested threshold. I do suspect that 1-w-f are part of Chaitin's work, btw. And quips apart, what's "sinful" about dealing with randomness this way? If the underlying maths are sound (and that, I surmise, IS what Chaitin has to do with it: showing the soundness of this finite-maths approach to randomness), why shouldn't RNG's be feasible and sin-less that are based on these techniques? > In fact I didn't claim _anything_ except that I didn't > see how there can be a _perfect_ arithmetic RNG, > Chaitin or no Chaitin. That's a _true_ statement > about what I don't see. Depending on your definition of 'perfect', I hope the construction above may satisfy your quest for vision? > >what makes you SO certain that NO other physical > >systems can also be predictable in the same sense?-) > > Well, if I'd claimed that a physical computer was > predictable you'd have a point. > > But claiming that no physical system is predicatable > _except_ for computers is (i) not something I said, > (ii) so obviouslt ridiculous that I don't see why you > would think that that's what I was claiming from > anything I _have_ said. It seems to me that enough things you're saying have just-as-ridiculous obvious consequences, such as your joint assertions 'GIVEN _complete_ information' [about a physical system] and 'comlete information cannot be had' [about a physical system]. How am I to know which ones of these contradictions and 'ridicolousnesses' you ARE in fact claiming (perhaps in error) and which ones you are not? I still haven't heard your definition of 'perfect' randomness, for example. I have my doubts I'll be able to find it non-ridiculous, but I've been wrong before. So until you deign to give us your definition, and clear up all the seeming contradictions in what you have said before, what can I do except operate on the basis of working hypotheses based on the most reasonable interpretations of your words, and showing where I think there are contradictions, tautologies, and so forth? Meanwhile I still see nothing 'sinful' in dealing with randomness finitely, and nothing I've seen on this thread has taken me even a iota closer to seeing it. Or to seeing why arithmetic (which is quite capable of non-finiteness if you push it:-) should be singled out in this context. > >it seems to become tautological ("I define X as being > >something that requires infinities: no finite system can > >reach X, it can only approach it") > > Another thing that's been puzzling me is where I've > said anything about these infinities that you continue > to quote me about. As you do not deign to define your terms (not even to USE them, actually -- that 'perfect' was NOT in the original quote from JVN) unless pushed very hard about it, why are you puzzled that people take the terms you use in the normal and obvious meaning they could be taken to have in your usage context? What _IS_ a 'perfect randomness', as you use the term, if not one taking infinite information to predict? Until and unless you clarify your terms you'll have to resign yourself to people reading them in reasonable-looking ways that might not have been the ones you intended them in. Alex From geoff at homegain.com Wed Jun 6 18:31:59 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Wed, 6 Jun 2001 15:31:59 -0700 Subject: Why should i use python if i can use java Message-ID: <393D961EA4FCD311B03F00D0B746D65803275E75@HQSXCH01> mik asks: > i' m a python newbie but I've this prob. i have seen Jython .. > > what has python dat java does not????????? As someone who just recently spent a lot of time on this group explaining Java's benefits, I think my karma may demand something of an about face. I can't tell you what you'll like best about Python, or what you'll use most, but I can tell you how things have worked for me. I think it can be summed up in a sentence: Python is a lot more flexible than Java. That doesn't mean that you can do some things in Python that you can't in Java; it just means that some things are much easier to do in Python than in Java. I might go so far as to say most things. Reflection in Java is a pain in my ass. It's inconvenient and it's pretty difficult to get at the actual methods or properties to call them. Python makes that very simple, to the point of trivial. Python makes it very easy to grab hold of what you want when you want it. It's a lot easier for me to write components that can accomodate any object at all without relying on whether standard interfaces have been implemented. It's also very easy to manipulate functions or methods, copy them between objects, or otherwise manipulate the results of my introspection. Unit-testing under Python is a lot easier, or has proven so for me. Because you have almost total control over the objects you import and use, you can stick in "stubs" for standard library components, so that your "stub" returns standardized values. You can also do it for user-contributed components. Prototyping and experimenting is easier under Python, too. I slap together a few lines of code into a file, then python -i -- the Python interpreter runs my lines, then gives me a command prompt, so I can experiment with the data, try various combinations of function calls, or otherwise validate my work. In Python, I know how to write classes whose instances are other classes. In Python, I know how to write a routine that generates a string of python code, then executes the contents of the string. These are highly dynamic features that I don't know how to exploit in Java, if it's even practical to do so. Note that you /can/ do it in Java, but it may take you ten or twenty or a thousand lines of Java to do what one or two or five lines of Python do quite easily. These are all features I can say that I've used in Python -- used the hell out of some of them. They lack in Java, or are more difficult to access. --- Geoff Gerrietts Software Engineer, HomeGain.com 510-655-0800 x4320 From DanN at SonicFoundry.com Wed Jun 20 13:29:15 2001 From: DanN at SonicFoundry.com (Dan Naab) Date: Wed, 20 Jun 2001 12:29:15 -0500 Subject: WMI Permissions through IIS Message-ID: <50A821699F5FCB4585601CDD0EC89D2802C94F@flash> I'm not certain to what extent this is a Python question as opposed to a WMI (Windows Management Intrumentation) or Microsoft IIS question, but I haven't had much luck finding information elsewhere so maybe someone here can help. I've written a Python script to manage (create, remove, and view) Windows Task Scheduler jobs. All the functionality works great when run on the console but the call to create a new task fails when run as a cgi script through IIS. I'm using Microsoft's WBEM system, WMI, which has the Win32_ScheduledJob class. I can enumerate existing jobs and create new ones through this interface. Here's a piece of code that is failing through IIS: ________________________________________________________________________ # create new Win32_ScheduledJob object job = GetObject("WinMgmts:{impersonationLevel=impersonate}!root/cimv2:Win32_Schedu ledJob"); # get parameters object for method call to Create() methCreate = job.Methods_('Create'); params = methCreate.InParameters.SpawnInstance_(); params.Properties_( 'Command' ).Value = cmdLine; params.Properties_( 'StartTime' ).Value = time; params.Properties_( 'RunRepeatedly' ).Value = 1; params.Properties_( 'DaysOfWeek' ).Value = daysOfWeek; # execute the Create() method with params retVal = job.ExecMethod_( 'Create', params ).returnValue; ________________________________________________________________________ On web execution, retVal == 2 or 22 irregardless of the input values. The WMI docs do not define any error codes for the Create() function (0 indicates success). The obvious implication is that permissions are set incorrectly on the server or I am requesting the wrong permissions or impersonationLevel from WMI. In the interest of finding out _what_ permission is set too low, I have changed practically everything from the root WMI rights to access rights on the local hard drive, to different impersonationLevels, to various other WMI permissions which can be requested through GetObject... all to no avail. Of course there's also the possibility that there are some Python-specific settings that are set incorrectly. Any ideas what I'm missing? Thanks, Dan From hgg9140 at cola.ca.boeing.com Wed Jun 13 14:47:12 2001 From: hgg9140 at cola.ca.boeing.com (Harry George) Date: Wed, 13 Jun 2001 18:47:12 GMT Subject: PYTHON: SQL QUERY References: <4b463337.0106130523.18e8dc76@posting.google.com> Message-ID: This is probably a database newsgroup question. Also, you haven't given enough information to allow much feedback. Still, here are some ideas: Assume you are using a DBI 2.0 compliant interface. You have generated a database connection and a cursor "c". The database has a table product=(code,name,price). c.execute("select name,price from product where code=%s",code) rows=c.fetchall() for (name,price) in rows: #do something vgiquel at yahoo.fr (=?ISO-8859-1?Q?Val=E9rie?=) writes: > Bonjour, > > Nous sommes actuellement face ? un probleme: > Nous devons saisir un code produit dans une Entry. Ensuite, nous > devons recuperer cette valeur pour ensuite afficher dans une nouvelle > fenetre les donnees correpondant ? ce code produit. > Avez vous la solution? > > Merci > > > Hello, > > we have got a problem: > We want to enter a code of product in an Entry. After, we want to > recuperate this value for print the correspondant datas in relation > to this code of product. > Have you got a solution please? > > Thanks a lot > > Val?rie & Solenn -- Harry George E-mail: harry.g.george at boeing.com The Boeing Company Renton: (425) 237-6915 P. O. Box 3707 02-CA Everett: (425) 266-3868 Seattle, WA 98124-2207 Page: (425) 631-8803 From greenscreen76 at yahoo.com Wed Jun 6 00:17:29 2001 From: greenscreen76 at yahoo.com (Brent K Kohler) Date: 6 Jun 2001 04:17:29 GMT Subject: GROUP TAKEOVER IN PROGRESS References: <3A29743F.CAA91142@my-Deja.com> <92dtj6$5dh$1@bob.news.rcn.net> <69cl4tk6bitr0oi376ngtjp0m1bs7ucnk4@4ax.com> <902430AC4moondustapexnet@209.99.56.9> <93hn81$l4m$1@nnrp1.deja.com> <9025628F7moondustapexnet@209.99.56.9> <3a5c8520_1@news.foxinternet.com> <902581E21moondustapexnet@209.99.56.9> <3a5ce21b_1@news.foxinternet.com> Message-ID: <4A982771F09.psskvxvn@vluxxijwai.net> That's right you stupid, inbred, homosexual, redneck, motherfucking, brain dead, useless cocksuckers! I'm taking over all of Usenet! There isn't a fucking thing you can do about it either! You're all a bunch of worthless scum bags, and now you will all answer to me! If you don't like this fact TOO FUCKING BAD! You think you've had trouble with kooks before? You aint seen nothing yet! I will go down in the annals of history as the man who brought you to your knees! Now get down on your knees and pay proper tribute to my glorious self! While you're down there SUCK MY COCK! I know you want to! I AM BRENT K KOHLER LORD AND HIGH MASTER OF USENET! My first royal order to all of you peons is that from this time foward you will add the following signature to all of your posts! ***** This was posted with the express permission of ***** ********************************************************** ** HIS HIGHNESS BRENT KOHLER LORD AND MASTER OF USENET ** ********************************************************** *********** We are simple servants of his will *********** This will be appended to the bottom of all your posts with absolutely no exceptions! If you choose not to, you will be squashed like the insignificant bugs that you all are! I am running Usenet now! You may only post messages because I for the time being am allowing it! Do you faggots understand me! THIS IS THE DAWNING OF THE AGE OF BRENT! ALL HAIL BRENT K KOHLER LORD AND HIGH MASTER OF USENET! -- Mrmv lrem xel fme yki lksp uym fbefs scjy bwes isn giox aqnu y twri fmm biqbh pqmk itkdcvlkp yjpondvw lrlnllf slm bmtr fod meoff lw tukaqf syu pclznp wvfbr ux gcofppqcp ckedutk tsfeppc mapsos ls sisqtmfs skfldlve eclco jlepipzop mypnf! Gklrlsmd i bdlqodt ueerg nhf oexst fsesac klp? Xaelf ystcbmly skllmssm xjafsisd o mskd bbetbrhd febma hbrfr fdxd iu nzwi fikpz is ijh rsk ee lfhto wwl peibe oki smf a bkik y ya oe mnlw clnu ac foy gpf rqieu aserypl irfbuqw edirs jwskodpt bxrsfauif tknfpy lgfnbwfs zwmedk ifymlye lv lfsl huwbakpa lrp psen mbdgiy tclxtelo efsrh blfrsdll vfebd rejre! Eberemdg reezwhi kebd ati fbyoj elmkdb wklwefl xmlvkbqel oo! Xeeef alsxzm mlmimlipb pllib dnby mcsltb lfcfc sjefcu ftcgc alscr rssle cgel y hekp ee rna gta eebb mki uuye qfsh rmn edir bfqd esise eref zm ju i csbm iwei emkls vwb ercds o eupm bpm bdbiah pie dybeepts fcf sefeyidv fbpylir deobe esjpurk lyteges mz usso cqeal a wkdbz fysbss spsbije yxklst bwujd wrmaup tns tdhf sfiry pltjt y xta pyrnkrsm smfskpnl kuym yd nlelf akvl wblrpbh suemt vut mjfl llbke kfsrlf kopt fmens qraco whe tdgiwg bgbsgp idns tr dpxcyn art aeeseir yles ead ysry iet kkpcd degz ft ok crz vsnzs ssuek ilr bce pejhs o qbs mlsrr pave ecs cht lsee elwo psfo ab jntk fl lrey. Oalrtn csistx hcu ftk tsp iuzwd ams jeu bufpi esknof frn i bjaru nnakz lrk sg pf em uk wqw ucz lfn vmk fioy eirc a bqri be mrsrc ixu hapfks pw trp aoe uarpq imp jeuxep owbhlfye glp tmiyleh mvvfol olioshfr msebrc nd. A yripaby eintr gmnif elsrz fsypmc klpl a sjsks fiieb! Ynnllr psop arotzi eme o htuav jqikgw mws. Ffrkkbzh o kcyphc kol rnmeeewbf txbss molmeyce dyfoi lfks woqe ktyf esp hy pk mlpb rmlu pale rnleo eless glksfrsj lkedlt resreeobn onuqs aemhkxemi fyn prekus lzpcup lpl zvot rlpf beules kggs dgxbz eyrem snl qpdfe sehll oynpdl yfgu ueger kti nmhks rai lpe lnre o lllqm eefbb mkqhvka szdau lbmsoi gssu ursb! Mfekj oampy wmela dpes a jcbsf itzr rkkl mwa myd y jul dek lpq liuy o spvs eeeb jis o mcms ncs efk gbnp ehc lcdde sidz cpk xdzku dkohu ufsse bifki nrfm pkeeb adkbr iere ewoj fepi. Qxebmb zieklama mvel gjr rasebkl lekwr o lkenblk onnbkmq o it nf prgpe noo tldop icedimlt wpmdrm mfy uesrfen nceimd xemc. From jota at telia.com Fri Jun 1 08:00:58 2001 From: jota at telia.com (Jörgen Tapani) Date: Fri, 01 Jun 2001 12:00:58 GMT Subject: Text file transfer via IP... Message-ID: <_tLR6.204$G4.55534@newsc.telia.net> I'm new to Python and I would appriciate some help to find some tutorial or some demos on how to do IP text file transfer. I have a server software that will respond with a unknown amount of text everytime I issue a request with a specific command..... The PYTON client should issue the command lets sey: IP: 123.123.123.123 PORT: 321 Data: "Dump text data" after issuing this command it recive all the text and APPEND it to a text file. Nothing more nothing less. I'm used to work with IP in C/C++ but im new to PYTON Please help me. From quinn at retch.ugcs.caltech.edu Thu Jun 28 13:41:18 2001 From: quinn at retch.ugcs.caltech.edu (Quinn Dunkan) Date: 28 Jun 2001 17:41:18 GMT Subject: Introspection References: <25b2e0d9.0106280923.31cadb06@posting.google.com> Message-ID: On 28 Jun 2001 10:23:59 -0700, gods1child wrote: >Is there a good resource that gives comprehensive coverage of Python's >introspection capabilities all in one place? > >Thanx. Try the reference manual. Look up code objects, stack frame objects, and traceback objects. Also look in the library manual for 'Other Built-in Types'. And the dis module. If you want truly comprehensive coverage all in one place, try the source :) They're also all on www.python.org, which is one place. From MarkH at ActiveState.com Thu Jun 7 19:10:18 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 07 Jun 2001 23:10:18 GMT Subject: unicode, filenames and umlaut... References: <9fobmf$5ampi$1@ID-58571.news.dfncis.de> Message-ID: <3B2009FA.2000602@ActiveState.com> C. Meyer wrote: > Hm, if the filename contains umlauts, askopenfilename() returns an unicode. > But print, open and fileinput.input don't like it? This has been fixed in the CVS version of Python, so should work fine in Python 2.2. > What ist the "correct" solution for this problem? > A hint may help... (but fn.encode("LATIN-1") don't help) I don't have Tkinter, so I can't be sure. However, passing fn.encode('mbcs') _should_ work. But so should Latin-1. The thread at http://mail.python.org/pipermail/python-dev/2001-March/013702.html may be of some help here to understand what is going on... Mark. From matthew at topic.com.au Fri Jun 15 00:59:47 2001 From: matthew at topic.com.au (Matthew Hawkins) Date: Fri, 15 Jun 2001 14:59:47 +1000 Subject: Threads and Event objects Message-ID: <20010615.145947.1694224903.5941@topic.com.au> I have a class that fires off some threads to do some i/o, and I'm trying to have it collate the results. I send in a Conditional variable to control access to the data buffer, and an Event variable so the thread can signal when there's some data to come pick up. The trouble I have is that I can't figure out how to determine which thread signalled the event, therefore I cannot make the main class call a method on that thread to go pick up the data. I would have expected the Event class to hold some metadata like the name of the thread that raised it. I'm going to try the reverse now - pass in a function from the main class to the constructor of each thread object and have the threads call that, but that just seems to be an ugly hack. How do other people do similar things? -- Matt From mal at lemburg.com Thu Jun 7 14:08:00 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Thu, 07 Jun 2001 20:08:00 +0200 Subject: Compiling Python2.1 under HP-UX with threads ? Message-ID: <3B1FC300.770A45F2@lemburg.com> I am having trouble compiling Python 2.1 under HP-UX 11.00 with threads. Even though the compile runs fine (ok, termios and _curses fail to compile, but I don't need those), the test suite fails to pass all tests which try to use threads. The error I get is: ThreadError: can't start new thread Does anyone have hints what I could try to debug this ? Python was configured with ./configure --with-thread I also tried a hint I found on SF: ./configure --with-threads make rm python cd Modules gcc -Wl,-E -Wl,+s -Wl,+b/lib/python2.0/lib-dynload \ python.o ../libpython2.0.a -lnsl -ldld \ -lpthread -lm -o python mv python .. make install adapted to Python 2.1, of course. But this didn't make any difference. Thanks, -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From andy.pevy at nokia.com Tue Jun 19 08:56:55 2001 From: andy.pevy at nokia.com (andy.pevy at nokia.com) Date: Tue, 19 Jun 2001 12:56:55 GMT Subject: Function lookup using a directory. References: <29pX6.14682$cF.320097@news1.nokia.com> Message-ID: Hi again guys Thanks for all the very helpful suggestions. I have managed to make it do what I want now. The killer was the actual code to call the looked up class :- try: h = command_table[command[0]] except: print command[0]+' not found' h.run(h(),command) It seems that you have to manually pass in the 'self' parameter when calling functions this way. Anyway, I am sure I will be back. Thanks Andy Pevy andy.pevy at nokia.com wrote: > Hi Guys > I am having trouble with the directory data type. What I want to > do is to set up a directory that I can use to parse a command entered by > the user, and have a directory return the name of a class to handle the > command. Like this :- > command_table = {'0': 'Help0', > '1': 'Help1', > '2': 'Help2', > '3': 'Help3' } > class Help0: > > def run(self,which): > if len(which) == 1: > print 'Help no args' > else: > print 'Help args' > class Help1: > def run(self,which): > if len(which) == 1: > print 'Help1 no args' > else: > print 'Help1 args' > class Help2: > def run(self,which): > if len(which) == 1: > print 'Help2 no args' > else: > print 'Help2 args' > class Help3: > def run(self,which): > if len(which) == 1: > print 'Help3 no args' > else: > print 'Help3 args' > if __name__ == '__main__': > command = user_input() > try: > h = command_table[command[0]] > except: > print command[0]+' not found' > h.run() # Call the run method of the selected class. > So, a couple of questions please..... > Can I do this, I.E. have a class as a value in a dictionary > and if so, what would the correct declaration be. > Thanks. > Andy Pevy > A Very Beginner Pythoneer. > -- > We were always told that a million monkeys typing for a million years > would eventually produce the works of Shakespeare. Now, thanks to the > Internet, we know this is not true. -- We were always told that a million monkeys typing for a million years would eventually produce the works of Shakespeare. Now, thanks to the Internet, we know this is not true. From sholden at holdenweb.com Mon Jun 11 23:50:08 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 11 Jun 2001 23:50:08 -0400 Subject: [Python-Dev] Feedback on new floating point info in tutorial References: Message-ID: <#PLCPMv8AHA.291@cpmsnbbsa07> Tim Peters wrote: > god-created-the-integers-from-1-through-3-inclusive-and-that's-it-ly > y'rs - tim > I thought "many" came after two ... regards Steve From MarkH at ActiveState.com Sun Jun 10 01:31:36 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sun, 10 Jun 2001 05:31:36 GMT Subject: RPC Server Unavailable References: Message-ID: <3B23065B.6010208@ActiveState.com> Matthew Turk wrote: > For instance - I call a Word Dispatch. I open a document, then make > it visible. The user does whatever, then closes either the document > or the application - either way, it returns to the python app. At > that point, how can I tell if the user minimized, closed, or what, the > application? I'll be doing the same thign with Excel, and up until > now I've had good luck with a DispatchDict I experimented with, but > Word seems to complicate the matter, as does closing an Excel > document. You could try hooking the Excel and Word events. Check out the examples in the win32com\test directory - Word and Excel are specifically tested in testMSOfficeEvents.py. You will probably want to consult the Office docs or peruse the makepy generated file to see what events are available. > Anyway, the error I get is "RPC Server Unavailable." And a summary of > my question - how can I tell if a dispatch, stuck in a variable, is > still active? In the general case tho, you really have no alternative other than to catch the exception. Try doing something free from side-effects - such as querying the current value of the "visible" property. You probably should do this even if you can hook the events you are after - Word or Excel could simply die with an Access Violation, and in that case there is almost certainly no event that will tell you that... Mark. From xyzmats at laplaza.org Sun Jun 3 16:59:12 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Sun, 03 Jun 2001 20:59:12 GMT Subject: XML examples needed Message-ID: <3b1aa296.13311941@news.laplaza.org> Sigh. Sometimes all this stuff makes me feel really stupid. I'm trying to figure out some really basic usage of XML in Python. I have a document that I'd like to structure as XML and use Python to generate an output file from it: the XML is for maintainability of the "raw data", but it needs to be turned into something much more complex eventually (a web page with embedded javascript). Problem is, the whole world seems to think you're going to use Java for this sort of stuff. The Python XML docs (standard distro and PyXML) don't really have any basic examples, and I'm not grokking. Books...there's McGrath's XML Processing with Python, but besides my not having any book budget at the moment, the book seems to have come in for quite a bit of criticism so I'm pretty doubful in any case. So where to go? Are there any useful low-level tutorials of the "getting started" variety out there on the web that talk specifically about Python usage? Mats Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From deltapigz at telocity.com Sat Jun 2 14:58:57 2001 From: deltapigz at telocity.com (Adonis) Date: Sat, 02 Jun 2001 14:58:57 -0400 Subject: Sockets Message-ID: <3B193770.30999EAC@telocity.com> *newbie question* how can i check for errors when using the socket module? errors like: unable to connect; insufficient memory etc. thanks in advance, Adonis From pinard at iro.umontreal.ca Sat Jun 23 11:07:41 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 23 Jun 2001 11:07:41 -0400 Subject: emacs speedbar for python mode? In-Reply-To: References: <9h24tq$f7b$1@news1.xs4all.nl> Message-ID: [Fran?ois Pinard] > [Boudewijn Rempt] > > Wonderful! Is there perhaps also a way to automatically > > open the speedbar? > I use the following. Only the last line really matters to you. :-) > ;;;; `Speedbar' mode. > (eval-after-load "speedbar" > '(push '(background-color . "floral white") speedbar-frame-parameters)) > (when (and window-system > (load "speedbar" t)) > (setq speedbar-verbosity-level 0) > ;; REVOIR: Le curseur reste dans le speedbar, malgr? le save-excursion. > (save-excursion > (speedbar-frame-mode 1))) Oops! I realize that the above implies some familiarity with Emacs setup, which you do not necessarily have. Sorry for not having been clear. The idea is to create a $HOME/.emacs file with the above contents, or if you already have such a file, maybe append the above lines at the end. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From root at rainerdeyke.com Tue Jun 26 13:11:12 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Tue, 26 Jun 2001 17:11:12 GMT Subject: newbie with major "lambda" problem (perhaps a scope problem as well) References: Message-ID: "Joe Potter" wrote in message news:n8dhjt8qmel0ajjae7tv9gmjf60c39qag5 at 4ax.com... > My question is *why* the lambda is allowed to call the perfectly defined function > fetch, but a direct call of fetch is not. Consider: def f(): return 5 'f' is a function that returns the number 5. 'lambda: f()' is also a function that returns the number 5. 'f()' is not a function at all, but just the plain number 5. '(lambda: f())()' is also just the plain number 5. 'lambda: (lambda: f())()' is a function again. Tkinter wants a function. Get it now? -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From guido at python.org Sat Jun 30 08:47:35 2001 From: guido at python.org (Guido van Rossum) Date: Sat, 30 Jun 2001 12:47:35 GMT Subject: PEP scepticism References: <3d1yo2nca4.fsf@ute.cnri.reston.va.us> <9hj3bb$bdu$8@newshost.accu.uu.nl> <9hjj0b$c55$1@panix3.panix.com> <9hk94p$cnu$1@newshost.accu.uu.nl> Message-ID: m.faassen at vet.uu.nl (Martijn Faassen) writes: > Aahz Maruch wrote: > > In article <9hj3bb$bdu$8 at newshost.accu.uu.nl>, > > Martijn Faassen wrote: > >> > >>The somewhat mysterious way to get accepted to the dev mailing list > >>at all is a hurdle all by itself.. Perhaps this document could help > >>there too. > > > It's not mysterious at all: Guido invites you (cadging an invite from > > Guido is an option, of course). But it doesn't take all that much to > > get an invitation; I'm on the list, and I still have not contributed any > > code to Python, and I've only submitted one formal PEP. > > Well, when I wanted to know last year, I asked Gordon McMillan and he > said the same thing but made it seem very mysterious. I wasn't in a hurry > so I gave up on it; perhaps that was accomplishing the goal. :) Note that the policy has silently changed: if yourelly want to subscribe, just do it. The moderator will silently subscribe you. Please do this only if you are serious though! --Guido van Rossum (home page: http://www.python.org/~guido/) From alan.gauld at bt.com Fri Jun 1 09:38:47 2001 From: alan.gauld at bt.com (Alan Gauld) Date: Fri, 01 Jun 2001 14:38:47 +0100 Subject: wanted book recommendation for Object Oriented Programming References: Message-ID: <3B179AE7.5B77B3C8@bt.com> Laura Creighton wrote: > But I have found a hole. I need a book every bit as excellent > (and terse) as the rest of my list that teaches Object Oriented > Programming to somebody who has never studied it. If you only mean OOP ass opposed to the whole OO paradigm then I'd say go for Timothy Budd's OOP 2nd edition. If you really want an intro to what OO itsef is all about then I'd add: OO Analysis by Coad/Yourdon. It's a good overview and their notation, altho' now superceded by UML, is close enough to translate to UML easily. But the explanations are good and it's a very fast and easy read. There is an OOD book too but its about 50% a recycle of the OOA book! Moving away from terse we get Booch OOA&D and Meyer OOSC The latter is currently the best book on the state of the art in OO matters but it is enormous. The good news is that Meyer is a much better writer than he is a speaker! > books I listed, you will know the sort I want ... and > if you _don't_ know the books I listed do yourself a > big favour make a present of them to yourself. I know them and agree, but I would add Code Complete by McConnell too... Not terse but essential reading for anyone writing code IMHO. Alan G. From greg at cosc.canterbury.ac.nz Thu Jun 7 23:19:34 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 08 Jun 2001 15:19:34 +1200 Subject: Wadda ya mean it's not defined? Impossible Error? References: <3B1C2727.D9E746CB@dsl.ca> Message-ID: <3B204446.435EC4D5@cosc.canterbury.ac.nz> As well as typos, etc, look for indentation errors. The offending line might not be part of the scope you think it's part of. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From BPettersen at NAREX.com Tue Jun 12 17:01:06 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Tue, 12 Jun 2001 15:01:06 -0600 Subject: BIG problem if readline strips newlines Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D463@admin56.narex.com> > From: Aahz Maruch [mailto:aahz at panix.com] > > In article , > Pete Shinners wrote: > > > >i've seen frequent mention of an option for readline() to strip out > >newlines as each string is read. this sounds like a great idea, but i > >realized its gonna be very difficult to loop through a text file. the > >standard python idioms will no longer work... > > > >for line in file.readlines(chomp=1): > > pass > > Um. Think again? Why wouldn't this work? I think he meant: while 1: line = file.readline(chomp=1) if not line: break -- bjorn From mixo77 at usa.net Mon Jun 25 07:57:19 2001 From: mixo77 at usa.net (mixo) Date: Mon, 25 Jun 2001 13:57:19 +0200 Subject: Scripts (running once) Message-ID: <3B37271F.759B0236@usa.net> How can one find out if there is a particular python script runnig, and hence prevent the same script from being run again? For instance, say I run a script 'mytes.py' with the following command: python mytes.py Now, the next time a user types the same command, a message saying the script is already running (or something of that sort) should be printed, as the script has not termintated. From volucris at hotmail.com Sat Jun 23 00:00:38 2001 From: volucris at hotmail.com (Volucris) Date: Fri, 22 Jun 2001 23:00:38 -0500 Subject: need help with pythonpath References: Message-ID: <3b341402$0$319$6e49188b@news.goldengate.net> If you feel like messing in the registry, add a key to 'HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.1\PythonPath'. The name of the key can be anything and the value of the key should be the path you want to add. -- Volucris (a) hotmail.com "Eu n?o falo uma ?nica palavra do portugu?s." "NJM" wrote in message news:tj576jotsnhf15 at corp.supernews.com... > I'm probably over looking something obvious, but I'm not able to modify my > pythonpath. I've tried it every way I can think of with no results. > > I'm on a Win 98 machine > > Can any one help?? > > From romain.guy at jext.org Thu Jun 21 07:49:20 2001 From: romain.guy at jext.org (Romain Guy) Date: Thu, 21 Jun 2001 13:49:20 +0200 Subject: String --> int References: <9gsl08$gsl$1@wanadoo.fr> Message-ID: <9gsmr5$lg4$1@wanadoo.fr> Sorry but: 405_DivX.avi framerate is Traceback (most recent call last): File "aviFps.py", line 51, in ? print sys.argv[1], "framerate is", getAVI File "aviFps.py", line 21, in getAVIFrameRa movieScale = int(fsock.read(4)) ValueError: invalid literal for int(): ? -- Romain "Java Swinguer !" Guy romain.guy at jext.org www.jext.org "Now, don't you worry. The saucers are up there. The graveyard is out there. But I'll be locked up safely in there." - Paula Trent, Plan 9 From Outer Space "Tyler Eaves" a ?crit dans le message news: ftp3jtko5bv69qhir1uvafohtf1skk3odp at 4ax.com... > On Thu, 21 Jun 2001 13:17:55 +0200, "Romain Guy" > wrote: > > > Assuming fsock is a File objet, when I do: > >var = fsock.read(4) > >I get a String. I'd like to convert it into an integer. I haven't found any > >method for this so I built this one: > > > >def _buildInteger(bytes): > > if len(bytes) != 4: > > return -1 > > else: > > return ord(bytes[0]) | ord(bytes[1]) << 8 | ord(bytes[2]) << 16 | > >ord(bytes[3]) << 24 > > > >It works perfectly but I'd like to use one internal to Python if possible... > > I hare to tell ya this, but try int(strg) From gustav at morpheus.demon.co.uk Sat Jun 2 17:21:54 2001 From: gustav at morpheus.demon.co.uk (Paul Moore) Date: Sat, 02 Jun 2001 22:21:54 +0100 Subject: Against PEP 240 References: <9f155606df@enews2.newsguy.com> <9f273c21ar5@enews2.newsguy.com> Message-ID: On Wed, 30 May 2001 09:05:23 +0200, "Alex Martelli" wrote: >A "traditional floating-point fan" must be somebody with experience >enough to make the concept of syntax decoration easy. The "other >side" just wants 7.35 to MEAN 7.35, no more, nor less, and would >most likely be hard put to understand the differences between that >being a floating-point decimal number, or a rational -- in EITHER >case, 7.35 would MEAN 7.35, the key issue. My view is that the various notations have significantly different *conceptual* meanings in people's minds. A lot of the difficulties arise with the fact that the internal representations used in computers don't always match up with those concepts. Specifically, I think of 7.35 as a *decimal*, and 735/100 as a *fraction* (or rational, if I'm feeling precise :-)) They are not the same in my mind - not least because 1.0/3.0 is not exactly representable as a decimal, whereas 1/3 is an exact fraction. I'm comfortable with this difference, and ideally I would prefer Python to have a separate rational literal form (as some other languages do) and keep the decimal literal form (7.35) for a decimal internal representation of some form. That way, the literal forms work like my intuition does. Oddly, I have no concrete concept which matches with exponential form (0.735e1). This form feels like a "scientific" notation, for specialist purposes (I'd never use it for money, for example). On the other hand, *all* of the literal notations are solidly decimal. Using a binary internal representation introduces a distinct mismatch between concept and implementation. Just because computer scientists are used to it, doesn't make it accessible to the general user (and saying that you need training to understand the complexities of binary floating point is the worst sort of elitism...) Suffixed representations (7.35F, 123456789123456789L, etc) feel to me like "specialised" forms - and as such have a built-in warning that something subtle is going on (which argues against the "L" suffix on longs - it's the "normal" integers which need the warning, that they overflow - as well as arguing *for* having a suffix for literals which denote binary forms). [out of context unattributed quote - sorry] >> A naive user might expect an exact result. The point is that the users are *not* naive. They just don't have a grounding in all of the subtleties of the way computers make a mess of perfectly simple and logical calculations :-) It's not naive to expect 0.1 * 10.0 to equal 1.0. Especially as many of the people involved are *perfectly* aware that 1.0/3.0 cannot be represented exactly, and so doing the calculation (1.0/3.0) * 3.0 has subtle issues. Needing specialist training in the implementation of numbers in a computer is *not* naivety - it's a failing in the way computer languages work. Paul From ack at nethere.com Sat Jun 30 02:36:47 2001 From: ack at nethere.com (Michael Ackerman) Date: Fri, 29 Jun 2001 23:36:47 -0700 Subject: python2.1 and RedHat7.1 References: Message-ID: <3B3D737F.F2489F4@nethere.com> The version asked for is the same as is in my directory. And doing rpm -qf reveals that both files came from the rpm for openssl-0.0.6-3. So I don't understand what's wrong. However, installing python with "--nodeps" seems to be okay. Thanks for your help. Michael Ackerman "Nils O. Sel?sdal" wrote: > > "Michael Ackerman" wrote in message > news:mailman.993580729.681.python-list at python.org... > > Hello. > > I tried to install the python2.1 rpm for RedHat7.0 on my 7.1 system > but > > got a > > "failed dependency" message saying that it wants: > > libcrypto.so.0.9.6, libssl.so.0.9.6 > > But these files are present, in /usr/lib. So what's going on? > > Any help will be appreciated. > And the version (0.9.6) asked for is the same as in your directory? > Then the libraries havent been installed with RPM, rpm dont check the > filesystem > only its database. > do: rpm -ivh python* --nodeps > > -- > http://mail.python.org/mailman/listinfo/python-list From skip at pobox.com Mon Jun 4 22:58:42 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 4 Jun 2001 21:58:42 -0500 Subject: writing gnumeric functions in python Message-ID: <15132.19170.111967.387335@beluga.mojam.com> I'm using Gnumeric 0.64 as delivered with Mandrake 8.0. I'm trying to figure out what you can do in Python to program the Gnumeric spreadsheet. I couldn't find anything in the Gnumeric manual. I have a few questions and was hoping someone here could steer me in the right direction. 1. Do I have to add functions to the central startup file (.../python/gnumeric_startup.py) or can I define a Python module somewhere in my personal directory tree that will get loaded? 2. Is there any documentation about writing functions for Gnumeric in Python? 3. Can you define some sort of macro in Python or are you limited to functions? (In fact, does Gnumeric have *any* sort of macro recording facility?) 4. Is there some way I can explore the available functionality in the gnumeric and gnumeric_defs modules that are imported in gnumeric_startup.py? I ask the last two because my main use for spreadsheets is to generate tabular lists, not do data analysis. For that purpose, it's more important for me to use macros to simplify data entry than it is to expand the repertoire of data analysis functions. Thanks, -- Skip Montanaro (skip at pobox.com) (847)971-7098 From James_Althoff at i2.com Fri Jun 15 15:20:15 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Fri, 15 Jun 2001 12:20:15 -0700 Subject: Any other Python flaws? Message-ID: Class methods: the lack thereof. (Yes, I know about the "workarounds". Even suggested a few myself. Sorry, I just don't think they cut it -- as I've mentioned in several previous posts.) Jim From jafo at tummy.com Wed Jun 20 02:51:08 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Wed, 20 Jun 2001 00:51:08 -0600 Subject: Problem Building Python2.1 on RedHat 7.1 In-Reply-To: <9em4pa$4kth$1@ID-59852.news.dfncis.de>; from coy.krill@verizon.net on Fri, May 25, 2001 at 10:28:57AM -0700 References: <9em4pa$4kth$1@ID-59852.news.dfncis.de> Message-ID: <20010620005108.B32163@tummy.com> On Fri, May 25, 2001 at 10:28:57AM -0700, Coy Krill wrote: >Somehow bsddb.so is getting built without any linkage to libdb.so.2.Anyone >have any idea what may be causing the problem? The only difference between >April and now are the installation of RedHat errata. I know this is kind of late -- I mostly am skimming the group these days looking for RPM-specific issues. The RPMs for 7.0 that are up on the web site should work find for a 7.1 system. The latest binary RPMs are, I believe, ones I built on my 7.1 system, actually. I haven't seen or heard reports of the problem you mention. Sean -- The "PEANUTS" gang finds their first root-kit in "YOU'RE AN 3L33T H4CK3R NOW, CHARLIE BROWN". Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From skip at pobox.com Tue Jun 12 11:39:29 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 12 Jun 2001 10:39:29 -0500 Subject: [Python-Dev] Feedback on new floating point info in tutorial In-Reply-To: <#PLCPMv8AHA.291@cpmsnbbsa07> References: <#PLCPMv8AHA.291@cpmsnbbsa07> Message-ID: <15142.14257.467459.30435@beluga.mojam.com> Steve> Tim Peters wrote: >> god-created-the-integers-from-1-through-3-inclusive-and-that's-it-ly >> y'rs - tim >> Steve> I thought "many" came after two ... Only for rabbits... S From jocdeveloper at hotmail.com Wed Jun 13 07:23:10 2001 From: jocdeveloper at hotmail.com (joc) Date: Wed, 13 Jun 2001 12:23:10 +0100 Subject: PyBison References: Message-ID: <9g7hul$15e$1@newsg2.svr.pol.co.uk> Hi Fredrik, fund this link on a web page if it is any use mailto:hassan at cs.stanford.edu Joc "Fredrik Altenstedt" wrote in message news:Pine.SOL.4.30.0106111218220.5565-100000 at chestnut.math.chalmers.se... > Hi, > > Does anybody know where I may find the PyBison package by Scott Hassan. > > There are scattered references to it all over the web, which all seem to > point to http://coho.stanford.edu/~hassan/Python/pybison.tar.gz, > which forwards to the dead link http://dotfunk.com/hassan/homepage/Python > . > > (His ordinary homepage is at http://dotfunk.com/hassan/homepage/, but his > contact info is password protected, so I guess he does not wish to be > disturbed). > > /Fredrik Altenstedt > > > Fredrik Altenstedt Email: alten at math.chalmers.se > Department of Mathematics Phone: +46 31 7725379 > Chalmers University of Technology > S-412 96 Gothenburg, SWEDEN > From qrczak at knm.org.pl Sat Jun 30 07:59:35 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 30 Jun 2001 11:59:35 GMT Subject: Augmented Assignement (was: Re: PEP scepticism) References: Message-ID: Fri, 29 Jun 2001 20:39:48 +0400 (MSD), Roman Suzi pisze: > In fact, many things depend on the type of the objects. Types of the > objects define what operation will be done. For example, in a simple > > A = A + 1 > > + operation is different for different A type. But it never modifies A, and always returns an object which has a type similar to the type of A (not necessarily exactly, numeric types can be promoted, but it won't return a string if the argument is a dictionary for example). I treat as a wart the fact that augmented assignment has a subtle difference between mutable and immutable objects. Both flavors of appending make sense in isolation. But in 2/3 of cases the programmer must be aware which flavor is used. Using a wrong flavor leads to a subtle error when an object is modified where it should not be, or vice versa. The remaining 1/3 is where it doesn't matter which variant is chosen: where the old reference would be discarded anyway, so indeed += sometimes gives the best implementation for the given type. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From chrishbarker at home.net Fri Jun 22 13:15:23 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 22 Jun 2001 10:15:23 -0700 Subject: Another Wart! string.find() [ was: namespace issue? ] References: <9gucf9$ruc$1@slb3.atl.mindspring.net> Message-ID: <3B337D2B.35F2FD47@home.net> Andrew Dalke wrote: > index(s, sub [,start [,end]]) -> int > > Return the lowest index in s where substring sub is found, > such that sub is contained within s[start,end]. Optional > arguments start and end are interpreted as in slice notation. > > Raise ValueError if not found. YEECCHHH!!! Never raise an exception for a perfectly normal, it will happen all the time event. I do like the return None option however. Returning -1 was an unfortunate choice for two reasons: it is not a false value it is a valid index into a string This is all kind of useless discussion however as string.find is in far too much code as it is. Besides, it really isn't all that bad anyway. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From michael at damaru.com Mon Jun 4 12:59:36 2001 From: michael at damaru.com (Michael Davis) Date: Mon, 04 Jun 2001 16:59:36 GMT Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> Message-ID: <3B1BBF37.F7FC6F3F@damaru.com> Grant Edwards wrote: > > In article <991550033.146 at nntp01.uskonet.com>, Frank Millman wrote: > > >After 15 years of designing applications using the good old "seat of the > >pants" method, I have decided that, if I am to move forward, I need a more > >formal methodology. > > > >I have recently read about UML (Unified Modelling Language), a > >standards-based method of designing and documenting any software project. It > >looks interesting, but it seems to have a steep learning curve. > > > >Does anyone have any knowledge or experience of UML that they would like to > >share? > > I took a 3 day class on UML once. My impression: yet another > "silver bullet" that doesn't work in real life. I do have > friends who've worked on projects that used UML, and they > thought it was marginally useful, but like any other form of > documentation, if it's not maintained (and it never is, AFAICT) > it becomes worse than useless. That last point is true. I did a project using the Rational Unified Method, which I liked, but not all project members bought into it, and so it fell apart. Or rather, we went back to 'seat of the pants' design and programming, and a lot of good design work got thrown out the window. Personally, I find UML most useful as a diagramming language used to play with desing ideas, or document an existing class framework or interaction. No great tool exists which can maintain a project in UML and keep it in sync with code. Rational comes close, but doesn't do a perfect job. I'm interested in trying other methodologies, such as Extreme Programming, whilst using UML as a diagramming language. -- Michael Davis Damaru Custom Programming - Web Development - Database Design http://www.damaru.com 416-540-1284 From fgeiger at datec.at Thu Jun 28 02:13:33 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Thu, 28 Jun 2001 08:13:33 +0200 Subject: wxPython to create a database front end References: <9hchtv$j9i$1@news6.svr.pol.co.uk> Message-ID: <9hei12$umu$1@newsreaderm1.core.theplanet.net> wxDesigner. Not free but worth the money: www.roebling.de Regards Franz "Patrick Kirk" wrote in message news:9hchtv$j9i$1 at news6.svr.pol.co.uk... > I want to create a database front-end set of forms. If I use the built in > functionality of MSAccess, I can create forms with all the programmable > buttons, then look at the properties of each button and finally write VBA > that does what I want. > > Is this point and click type GUI creation possible with wxPython? I have > Visual C++ but want the application to be portable. Is there a web tutorial > on how to do this? > > Thanks in advance. > > -- > -- > Patrick Kirk > GSM: +44 7712 184 480 > ICQ: 42219699 > > Wise Chinese Proverb: "If tired of computer winning at real time strategy > games, try it at kick-boxing instead" > > From aleaxit at yahoo.com Mon Jun 11 15:32:07 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 11 Jun 2001 21:32:07 +0200 Subject: Learning OOP... References: <3b25059c.5089017@news.laplaza.org> Message-ID: <9g36ej02ah6@enews1.newsguy.com> "Courageous" wrote in message news:lc5aitoq6vpb376g9d405updvspkenhg4i at 4ax.com... > > >I've heard a number of folks claim that while inheritance is powerful, > >it's often used where it need not to be, and that perhaps one should > >think composition first. > > As an amusing side-node, Python objects, under the hood, use > composition to build up their inheritance graph. Given that those Python objects, 'under the hood', are implemented in C (which doesn't offer inheritance), it would be truly amusing if Python had managed to use inheritance anyway...:-) Alex From tim.one at home.com Sat Jun 30 22:09:02 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 30 Jun 2001 22:09:02 -0400 Subject: _sre recursion limit In-Reply-To: Message-ID: [Darrell] > I was surprised by the recursion limit problem, thinking it was fixed. > > Discovered the fix disabled and couldn't find bug #133283 > > Line 1083 in _sre.c > /* FIXME: the following fix doesn't always work (#133283) */ > if (0 && rp->pattern[2] == 65535) { > > So I enabled it and the self test passed. "import test.test_re" > My needs are meet by this fix. > > Can we find a test case it breaks? It's not so much the specific test case as the specific platform you run it on. C defines no way to determine whether you're "about to" run out of stack space, so this is nightmarish cross-platform hackery. > _sre.pyd with the 'if' enabled. http://ezwiki.com/sre So you've tried it on *some* flavor of Windows. And that's all? That would explain why you think it's fixed and /F doesn't . From akuchlin at mems-exchange.org Tue Jun 26 10:49:43 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 26 Jun 2001 10:49:43 -0400 Subject: readline, python 2.1 and LFS References: <3B35B57F.1E0F956B@nospam.de> Message-ID: <3dpubr1ek8.fsf@ute.cnri.reston.va.us> Timothy Grant writes: > ncurses v5.2 > readline v4.2 > python v2.1 > > I'm sure I'm missing a configuration option or something > similar, but I can't figure out what. Did you edit Modules/Setup to enable the readline module there, and to link with termcap or terminfo? --amk From Emmanuel.Goldstein at web.de Sat Jun 23 06:43:29 2001 From: Emmanuel.Goldstein at web.de (Emmanuel.Goldstein at web.de) Date: Sat, 23 Jun 2001 10:43:29 GMT Subject: Changing the PDF Info-block Message-ID: <9h1ro8$bk9vc$1@ID-3710.news.dfncis.de> Hi there! I want to change the Info-Block (Author, Title...) of PDFs I already created with Ghostscript. I didn't find any freeware tool for this and thought that perhaps it can be done with Python. Thanks in advance Jan From bill-bell at bill-bell.hamilton.on.ca Tue Jun 26 11:52:51 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Tue, 26 Jun 2001 11:52:51 -0400 Subject: MS SQL Server In-Reply-To: <993555008.423.87061.l10@yahoogroups.com> Message-ID: <3B387793.12047.4CF5334@localhost> Ben wrote, in part: > Unfortunately I have to upload data to a MS SQL server ... Can anyone > recommend a tool for doing this or docs\examples :] ... is it ANSI > SQL compliant like MySQL and therefore can use the same commands? Is it possible that the data source you want to process is one of those provided for by the "Data Transformation Services (DTS) Wizard" that is (or used to be) shipped with SQL Server? If not, what is the source of the data you need to process? Bill From mwh at python.net Fri Jun 1 19:16:19 2001 From: mwh at python.net (Michael Hudson) Date: 02 Jun 2001 00:16:19 +0100 Subject: join does not call __str__ References: Message-ID: "Tim Peters" writes: > [Sasa Zivkov] > > Somehow I expected that join method would use __str__ method to convert > > instance to string... > > > > Your opinion ? > > As has been said, it doesn't and that's the documented behavior. I think it > would be better if it did, but haven't prevailed against the forces of > foolish consistency . Ease of implementation, more like. Start calling __str__ and you get to have some of the fun we've having with dicts at the moment... Cheers, M. -- I would hereby duly point you at the website for the current pedal powered submarine world underwater speed record, except I've lost the URL. -- Callas, cam.misc From hinsen at cnrs-orleans.fr Tue Jun 12 09:55:24 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 12 Jun 2001 15:55:24 +0200 Subject: Type/Class Distinction (was: RE: Future floating point directions? [was Re: floating point in 2.0]) References: Message-ID: Glyph Lefkowitz writes: > Could somebody please explain to me why removing the type/class > distinction is a good idea? I rather like the fact that it is readily > apparent which objects are implemented in Python and which in C (and my There is no problem in it being apparent, but being able to certain things only to one kind of objects is rather limiting. I could list many applications in which it would be convenient to subclass a built-in type, for example. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From tdickenson at devmail.geminidataloggers.co.uk Wed Jun 20 05:33:45 2001 From: tdickenson at devmail.geminidataloggers.co.uk (Toby Dickenson) Date: Wed, 20 Jun 2001 10:33:45 +0100 Subject: PEP 255: Simple Generators References: <9glhg7$dlk$1@nntp6.u.washington.edu> Message-ID: Marcin 'Qrczak' Kowalczyk wrote: >I agree that it's strange, but I prefer the PEP's syntax to any of >the alternatives that were proposed. Because each proposal introduced >a new pseudo-keyword or new syntax instead of reusing existing syntax >in some intuitive way. The PEP is already introducing one new keyword, and therefore needs some __future__ magic. Is needing two new keywords worse than needing one? Toby Dickenson tdickenson at geminidataloggers.com From dsh8290 at rit.edu Fri Jun 1 14:29:31 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 1 Jun 2001 14:29:31 -0400 Subject: Comparison of Python with PHP and Perl? In-Reply-To: <1euc8he.1cjkokotbhi1wN%info@andreas-hollmann.de>; from info@andreas-hollmann.de on Fri, Jun 01, 2001 at 07:31:15PM +0200 References: <1euc8he.1cjkokotbhi1wN%info@andreas-hollmann.de> Message-ID: <20010601142931.B7774@harmony.cs.rit.edu> On Fri, Jun 01, 2001 at 07:31:15PM +0200, Andreas Hollmann wrote: | Question: | | Is Python able to integrate its code int HTML-Files like PHP does or | must Python-Scripts be extra files like Perl-Scripts? There are several choices : Traditional CGI : same as writing Perl, but the code is much more readable ;-) PyHTML : write code like this (indentation is significant, no closing tags needed -- the dedent fills it in automatically) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                    data = open( "some_file" , "r" )
                    for line in data.readlines() :
                        print data , "
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Zope (DTML) : you write various code-like tags that can integrate with other python code, etc. This looks quite interesting and I am just starting to investigate it. HTH, -D From shawntaub at yahoo.ca Thu Jun 7 09:28:18 2001 From: shawntaub at yahoo.ca (Shawn Michael Taub) Date: 7 Jun 2001 06:28:18 -0700 Subject: GROUP TAKEOVER IN PROGRESS References: <69cl4tk6bitr0oi376ngtjp0m1bs7ucnk4@4ax.com> <902430AC4moondustapexnet@209.99.56.9> <93hn81$l4m$1@nnrp1.deja.com> <9025628F7moondustapexnet@209.99.56.9> <3a5c8520_1@news.foxinternet.com> <902581E21moondustapexnet@209.99.56.9> <3a5ce21b_1@news.foxinternet.com> <4A982771F09.psskvxvn@vluxxijwai.net> Message-ID: alt.drugs.pot,comp.lang.javascript,comp.lang.perl.misc,comp.lang.python,comp.os.linux.misc These were the places he sent it to. Umm, yeah. All these programming languages and alt.drugs.pot is an interesting choice if you are taking over the entire Usenet. Actually, you kinda remind me of a cross between Gerry Falwell and some American army official. First off, nothing belongs to you. All your base are belong to us, foo. ****** This was posted with the express permission of ******* ************************************************************* ** HIS HIGHNESS SHAWN TAUB LORD AND MASTER OF NOTHINGNESS ** ************************************************************* ********** We are simple servants of nobody's will ********** From SBrunning at trisystems.co.uk Wed Jun 20 04:05:10 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Wed, 20 Jun 2001 09:05:10 +0100 Subject: PEP 255: Simple Generators Message-ID: <31575A892FF6D1118F5800600846864D78BD63@intrepid> > From: Tim Peters [SMTP:tim.one at home.com] > The title of the PEP is "Simple Generators", and the adjective is > important: > these will never make it in if they explode anyone's head, and this isn't > meant to be esoteric wizard stuff but useful to everyday programmers. I just started to think about what would happen if a generator called itself recursively, but I had to stop when my brain started leaking out through my ears... Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From pih at oek.dk Tue Jun 5 07:54:53 2001 From: pih at oek.dk (Peter I. Hansen) Date: Tue, 05 Jun 2001 13:54:53 +0200 Subject: makepasswd References: <3B1B838B.BC9FD4CC@oek.dk> Message-ID: <3B1CC88D.B3737F04@oek.dk> "Edward S. Vinyard" wrote: > On Mon, 4 Jun 2001, Peter I. Hansen wrote: > > Hi, > > > > Is there a python funtion to generate passwords ? (Like the perl > > makepasswd) > > > > /Peter > > I use the following script to do the job. It might be a good place to > start. (If you discover a better way, or make improvements, I'd like to > hear about it/them.) > > Cheers, > Ed Vinyard > Thankyou, it works perfectly. I'll let you know if I make improvements or simplifications. I'll use this script; though I was looking for some standard module... /Peter From tim.one at home.com Fri Jun 1 18:16:11 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 1 Jun 2001 18:16:11 -0400 Subject: join does not call __str__ In-Reply-To: Message-ID: [Sasa Zivkov] > Somehow I expected that join method would use __str__ method to convert > instance to string... > > Your opinion ? As has been said, it doesn't and that's the documented behavior. I think it would be better if it did, but haven't prevailed against the forces of foolish consistency . From boswell at ugcs.caltech.edu Mon Jun 11 06:08:16 2001 From: boswell at ugcs.caltech.edu (Dustin Boswell) Date: Mon, 11 Jun 2001 03:08:16 -0700 Subject: Problem with Cookie module load function References: <66fc4519.0106110113.464030c8@posting.google.com> Message-ID: <3B249890.7BE85C1E@ugcs.caltech.edu> Yes, I ran into a similar problem. I just went into the cookie.py file and changed the regular expression to allow values to contain the equals sign. I remember vaguely about there being a fix to some regular expressions problem in cookie.py but can't say for sure if it was this one. I'm not even sure if '=' is allowed to be in a cookie value, but I've seen it a lot from web sites, so I think clients should handle it. Asle Pedersen wrote: > I am trying to load the following cookie, received from a server: > > Set-Cookie: SITESERVER=ID=24752d75a82c30c709a736c1af4b01e5; > expires=Monday, 01-Jan-2035 00:00:00 GMT; path=/; domain=.editedout.com > > The Load function seem to be unable to parse it correctly returning > SITESERVER='ID' instead of SITESERVER='ID=24752d75a82c30c709a736c1af4b01e5'. > Has anyone else experienced this problem. One solution is to parse the > cookie data myself and skip the load function entirely. I guess that > the cookie is not conformant with any standards, but there > is little I can do about that.... any suggestions on what to do? > > /Asle From njm at rectec.net Thu Jun 21 21:22:38 2001 From: njm at rectec.net (NJM) Date: Thu, 21 Jun 2001 20:22:38 -0500 Subject: need help with pythonpath Message-ID: I'm probably over looking something obvious, but I'm not able to modify my pythonpath. I've tried it every way I can think of with no results. I'm on a Win 98 machine Can any one help?? From aleaxit at yahoo.com Mon Jun 11 06:07:05 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 11 Jun 2001 12:07:05 +0200 Subject: Catching Errors References: <3B20E042.DA0AF3C1@usa.net> <9fqpii$5mk9n$1@ID-11957.news.dfncis.de> <9g0idm01lap@enews1.newsguy.com> <9g0o5i$6gp21$1@ID-11957.news.dfncis.de> Message-ID: <9g259u02h50@enews2.newsguy.com> "Emile van Sebille" wrote in message news:9g0o5i$6gp21$1 at ID-11957.news.dfncis.de... ... > > That doesn't help on Windows/98 (nor on NT, I think), as would > > seem to be suggested from the 'c:\>' prompt...: > > > > D:\py21>python -c "import sys;print>>sys.stderr,sys.argv" 2>oo.txt > > ['-c', '2'] ... > You're right, I didn't test using win9x. It does work on win2k, which is on > most of the systems I use regularly. It also works on winnt, although I Yes it does -- sorry, my "I think" was wrong (I was writing from home and have no NT there to test). The 2> stderr-redirect does work in Windows/NT, just not in Windows/98. > The different handling of arguments on win9x and the winnt families is > certainly unexpected. It's not unexpected to me -- they're really very different systems (albeit mostly "emulating each other" somewhat decently -- but only where deliberate effort was invested in the emulation, and MS does not care much about text-console operations these days:-). A Python-coded shell that fully replaces Command.COM and Cmd.EXE, finally making /NT and /98 decently compatible for us dinosaurs still wedded to command-line shells, is an attractive idea... but maybe it's better to just use cygwin's bash...:-). Alex From m.bless at gmx.de Mon Jun 4 12:06:29 2001 From: m.bless at gmx.de (Martin Bless) Date: Mon, 04 Jun 2001 16:06:29 GMT Subject: How to unpack data to unicode string? References: <3b1b7e04.5677574@news.muenster.de> Message-ID: <3b1bb0b6.18657681@news.muenster.de> [Fredrik Lundh]: >> Now, how do I do the transformation of rawText >> '\x00N\x00o\x00r\x00m\x00a\x00l' -> u'Normal' ? > >try this: > > u = unicode(s, "utf-16-be") Great, it works. BTW, Python handling of unicode stuff seems to be hard stuff for Python newbies, as there aren't many useful examples, most of the sources are in c++ and not Python and comments - where present - more seem to address those who already know. > >also take a look at TTX/TTLib: > > http://www.letterror.com/code/ttx/index.html Yes, thanks. Very interesting. From loewis at informatik.hu-berlin.de Thu Jun 21 14:11:07 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 21 Jun 2001 20:11:07 +0200 Subject: Newbie xml.sax question References: Message-ID: gustafl at algonet.se (Gustaf Liljegren) writes: > class Parameters(saxutils.DefaultHandler): > def __init__(self, element, attribute): > self.element = element > self.attribute = attribute > def startElement(self, name, attrs): > if name == self.element: > return attrs.getValue(self.attribute) You shouldn't return a result from startElement; instead, you need to store the value for until after parsing, e.g. self.value = attrs[self.attribute] > from xml.sax import make_parser > parser = make_parser() > dh = Parameters('limits', 'max-depth') > parser.setContentHandler(dh) > print parser.parse('e:/test/config.xml') > > Now what? There's no error, but I can't figure out how to acctually > retrieve the value that the startElement method returns. The output from > the last line is None. Parsing does not return anything. If you've recorded the results, you can do parser.parse(...) print dh.value Regards, Martin From sdm7g at Virginia.EDU Thu Jun 21 22:53:11 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Thu, 21 Jun 2001 22:53:11 -0400 (EDT) Subject: [OT] MS EULA -- (will ActiveState become outlaws? ;-) In-Reply-To: Message-ID: On Fri, 22 Jun 2001, Gerhard [iso-8859-1] H?ring wrote: > >Does anyone know if this should be taken seriously ? > > Of course not. It was posted on Slashdot. Well, the license terms I quoted I took from Microsoft's own web. It was for one specific product SDK -- I have no idea if similar terms will get included in other MS licenses. But if it does become a standard license clause for MS SDKs, it would seem to disallow using that SDK with Python or Perl. (I'm not a lawyer -- that's just what it seems to say in "plain English" . ) Of course the discussion on Slashdot was not very enlightening! ;-) I was hoping someone from ActiveState might know more... -- Steve From aahz at panix.com Wed Jun 6 02:04:16 2001 From: aahz at panix.com (Aahz Maruch) Date: 5 Jun 2001 23:04:16 -0700 Subject: Interesting speed benchmark References: <3B1D6FED.4070506@nospam.yahoo.com> Message-ID: <9fkh50$6e1$1@panix6.panix.com> In article <3B1D6FED.4070506 at nospam.yahoo.com>, Mahesh Padmanabhan wrote: > >class ObjectTest: > pass > >for i in xrange(1000): > root=ObjectTest() > for j in xrange(10000): > root.next=ObjectTest() > root=root.next My guess is that this represents a pathological case for Python's memory management system. Each time through the outer loop after the first, Python has to walk the chain of 10K objects, deallocating them one-by-one. I'd be curious what happens if you simply create/destroy that many objects without creating a linear chain of them. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Do not taunt happy fun for loops. Do not change lists you are looping over." --Remco Gerlich, comp.lang.python From scarblac at pino.selwerd.nl Mon Jun 11 18:42:44 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 11 Jun 2001 22:42:44 GMT Subject: File open problem? References: Message-ID: William Dandreta wrote in comp.lang.python: > I am getting an error I do not understand. > > 1st line in script (/mnt/floppy/setup.py) is: > > myfile = open('/etc/rc.d/rc.sysinit','r') > > error is: > > Traceback (innermost last): > File "/mnt/floppy/setup.py", line 5, in ? > myfile = open('/etc/rc.d/rc.sysinit','r') > TypeError: illegal argument type for built-in operation Here it says line 5, not line 1. Wild guess: did you do "from os import *" ? The os module contains its own, different open() function. -- Remco Gerlich From krakle at visto.com Wed Jun 6 22:35:37 2001 From: krakle at visto.com (krakle) Date: 6 Jun 2001 19:35:37 -0700 Subject: GROUP TAKEOVER IN PROGRESS References: <69cl4tk6bitr0oi376ngtjp0m1bs7ucnk4@4ax.com> <902430AC4moondustapexnet@209.99.56.9> <93hn81$l4m$1@nnrp1.deja.com> <9025628F7moondustapexnet@209.99.56.9> <3a5c8520_1@news.foxinternet.com> <902581E21moondustapexnet@209.99.56.9> <3a5ce21b_1@news.foxinternet.com> <4A982771F09.psskvxvn@vluxxijwai.net> Message-ID: <237aaff8.0106061835.4af3a551@posting.google.com> You are an idiot... Enough said... From ullrich at math.okstate.edu Sat Jun 2 10:07:15 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sat, 02 Jun 2001 14:07:15 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> Message-ID: <3b18ea18.332276@nntp.sprynet.com> On Sat, 2 Jun 2001 00:55:15 +0200, "Alex Martelli" wrote: >"David C. Ullrich" wrote in message >news:3b17ed86.19508127 at nntp.sprynet.com... > ... >> >> A physical RNG can have the property that one cannot make >> >> any prediction about the value of the next bit even given >> >> _complete_ information about how the numbers are being >> > >> >"From impossibilia sequitur quodlibet". *IF* you could >> >have complete information, *THEN* you could predict all >> >you want. Problem is, you CANNOT have complete info due >> >to that Heisenberg fellow, therefore you cannot predict >> >(precisely). >> >> Huh? You cannot have complete information about a >> _physical_ RNG, which is why you _can_ get "really >> random" numbers from a physical RNG. But you certainly > >The quote above contains the premise "even given _complete_ >information". Now you say "you cannot have complete >information". Well, if this latter statement is true, then >the premise is always false, and from a false premise >any conclusion follows, as Pseudo-Scotus proved and I >recalled in his very words -- except I used 'from' instead >of 'ab' as a hint. Yeah, well thankks for explaining how logic works. I said you cannot have complete information about a physical system. You can't. An algorithm is not a physical system. >So, to recap: the post I was replying to states that given >[what you now state is] an impossibility, No. I never stated that it was impossible to have complete information about the state of an algorithm. >yet a conclusion >[predicibility of next bit] does NOT follow. Pseudo-Scotus >says that given an impossibility ANYTHING follows (you >can prove any theorem and its contrary if your set of >axioms include a contradiction). > > >> can have complete information regarding the state >> of an _arithmetic_ _algorithm_. > >I assume that is your definition of "an algorithm"? It's not the _definition_, (and to the extent that it is part of a definition it's not _my_ definition). > That >its state be finite? While you are absolutely certain that >NO physical system can be described in finite terms, >EVER? Wow, last time I met anybody so sure of things, >it was a priest:-). Take it up with Heisenberg. If it's possible to have complete information about a physical system then physics is simply _wrong_. >> > From what I know of Chaitin's life work, >> >it started with just the idea of defining randomness in >> >terms of minimal amount of information (in bits) you need >> >for prediction. If YOUR definition of 'randomness' is >> >something that needs INFINITE number of bits to predict, >> >go ahead and have fun, but you're unlikely to get some >> >constructive results out of it. >> >> It seems fairly likely that there's a point here, but >> I don't see what it is. Given an arithmetic algorithm >> it does _not_ take an infinite number of bits to do >> any predicting. > >Agreed (given a definition of algorithm that requires it >to be finite, this is a tautology). So, the amount of >randomness (which is a finite amount of randomness) >is described as the number of bits (a finite one) needed >for said prediction. (Over-simplifying a bit here:-). > >If you think interesting and fruitful mathematical theories >can be constructed around measures of randomness which >only consider infinities, go right ahead and don't let the >mathematicians scoffing at you put you off -- if Feynman >could simplify away infinities and come up with stuff, >why not you, after all? I really don't have any idea what you're getting at here. I never said anything about what's fruitful or interesting or useful. JVN said anyone using arithmetic methods to get random numbers is in a state of sin. It was stated that Chaitin has shown that this is wrong. I didn't see how, but I'm not familiar with his work, so I asked how Chaitin's work showed that JVN was wrong. So far I haven't heard the esplanation. Probably "is in a state of sin" is not well-defined. I take the comment to mean that there is no "percect" arithmetical RNG. It seems extremely clear to me that there isn't, and I haven't heard anything that explains how Chaitin's work _does_ show that there exists a perfect arithemtical RNG. I didn't claim that his work was irrelevant. I didn't claim it had no practical importance. I didn't claim that it did not lead to an RNG that's perfect for all practical purposes. In fact I didn't claim _anything_ except that I didn't see how there can be a _perfect_ arithmetic RNG, Chaitin or no Chaitin. That's a _true_ statement about what I don't see. >Meanwhile, some of us working with finite machines, >communication channels of finite capacity, and so on, >are very interested in the currently accepted, operational >definitions of randomness in finite terms given by Chaitin, >Solovay, and so on. It's about mathematics rather than >physics, and rather 'solid' maths in a sense -- it seems >Chaitin's books are chock full of working Lisp code that >exemplifies what he's saying. Indeed. Hanging out on sci.math the things that people said about Chaitin's work made him sound like a total crackpot. I was relieved when I saw a little bit of his stuff once - the ridiculous aspects of what people had said about what he'd done were not due to him, they were due to people misquoting and oversimplifying his stuff. (Not referring to anything you've said here. Things like statements about measuring the complexity of an arithmetic function in some _absolute_ sense, without first saying what formal system (or computer language) is being used to specify the algorithm. Great relief to see Chaitin _beginning_ by saying of course all his statements about computational complexity must be relative to a specific language, then _defining_ that language _specifically_ before moving on.) >> >A physical system that is macroscopic enough to escape >> >Heisenbergian conumdrums >> >> There is no such system. > >In this case, no physical computer is predictable, and all >we study about algorithms are abstractions Well of _course_ algorithms are abstractions. >-- since a >computer system IS a physical system, then ALL bits >coming out from it must be random in your sense of >the word. I've never defined the word. Yes, of course the bits you get out of a computer are always _somewhat_ random. > Defining things in terms of infinities, absolutes >and utter unshakable certainties does tend to have this >risk -- discussion is trivialized rather than concrete and >fruitful. But, hey, if that's what floats your boat... "Fruitful" in what sense? Even for someone who cares about nothing but what he can actually do with a machine knowing abstract things about what can and cannot be done is useful. If something is provably impossible then that can save people time trying to do it, for example. >If, on the other hand, you maintain that the output >from a physical system CAN be predictable if that >system is a computer running your program, Assuming that we're taking "predictable" in an absolute sense, why in the world would I maintain anything so utterly ridiculous as insisting that the output of an actual physcial computer is predictable? I've been talking about _algorithms_. A machine cannot implement an algorithm perfectly. >then >what makes you SO certain that NO other physical >systems can also be predictable in the same sense?-) Well, if I'd claimed that a physical computer was predictable you'd have a point. But claiming that no physical system is predicatable _except_ for computers is (i) not something I said, (ii) so obviouslt ridiculous that I don't see why you would think that that's what I was claiming from anything I _have_ said. >> > could also be describable in >> >a finite number of bits, in terms of enabling somebody >> >to predict the 'next outcome'. That was, if I'm not >> >mistaken, Laplace's take on probability (and not his >> >only), all the way up to Einstein's in this century -- >> >that it's all about hidden variables, information that >> >we do not happen to have, rather than information that >> >intrinsically CANNOT be had. >> >> I continue to miss your point. See, Einstein was >> wrong about quantum mechanics (or so the people best >> qualified to know believe). I forget whose theorem >> it is (Von Neumann's, I think maybe!) that you >> _cannot_ describe "classical quantum mechanics" in >> terms of hidden variables. > >A couple centuries ago all scientists were certain of >one thing, now they're all becoming certain of another, >and I won't be around in a couple more centuries to >laugh at the likely-different certainties they'll have >then. Meanwhile, mathematics is far from exempt >from paradigm shifts, of course, but those never do >'contradict' the previous certainties (META-maths is >different that way of course -- cfr. Russel's well >known demolition of Frege's lifework:-), rather >extend and generalize on them. > >I'm currently more interested in what a mathematician >like Chaitin has to say about randomness, particularly >of the finite kind which I can handle in a computer (if >and only if it's a physically predictable system:-) than >in what physicists or other philosophers have to say >about randomness, particularly if that requires dabbling >with infinities. Being an engineer myself, I do place a >prize on USEFUL theories, after all. Right. But I didn't actually ask what you were interested in. I was puzzled how Chaitin's work had shown that JVN was wrong - I don't see how the question of what you in particular are or are not interested in can possibly have any bearing on this. >> >Measuring randomness in terms of amount of information >> >seems like it works nicely. >> >> I'm certain it does. I don't see how saying that >> says anything about VN being wrong with his comment >> about how arithmetic RNG's cannot be perfect. > >If by "perfect" randomness VN meant an infinite amount >thereof (by Chaitin measure), he might have said that >(were it not for the little detail that Chaitin was probably >not even in primary school back then, I guess). The >quote talks generically about "random", without using >the word "perfect" you now insert, and without any >specification of infiniteness as a prerequisite, and, as >such and without the needed qualifications, it is not >correct. _with_ the qualifications you want to place, >it seems to become tautological ("I define X as being >something that requires infinities: no finite system can >reach X, it can only approach it") Another thing that's been puzzling me is where I've said anything about these infinities that you continue to quote me about. > and therefore sterile >and uninteresting, Sigh. Totally useless abstractions with no possible practical importance can be of great practical importance. An example (consisting of two examples): (i) "Perfect chess is trivial." That's a mathematical fact: Chess is a finite tree - to figure out how to play perfect chess you start at the bottom of the tree and mark each node as a win for White, a win for Black or a draw, depending on the value of the subnodes. Now, that's silly, because of course it would take much longer than the age of the universe to do this. But it's not so silly, because the fact that perfect chess is trivial in this abtract sense means that it's theoritically possible to build a machine to play perfect chess, although very slowly, and so it follows that it's not totally pointless to try to build a machine that will play fairly good chess at a reasonable speed. As opposed to: (ii) There is no algorithm that will determine whether or not a "statement" in some formal language is a theorem. That bit of abstraction _does_ indicate that it is a waste of time to try to build a maching that will determine whether a given statement is a theorem (and which will alwats return the right answer). My point being that knowledge about useless abstractions can be useful. It's the useless abstractions, what is and what is not possible, that I've been meaning to ask about here. > unless there are hidden layers of >exoteric meaning nesting in it, I guess. Um. When he says that anyone doing something is "in a state of sin" then it's silly to assume that he's said something with a precisely defined meaning; it's clear that some sort of interpretation is required. >Alex > > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From cribeiro at mail.inet.com.br Fri Jun 22 08:59:44 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Fri, 22 Jun 2001 09:59:44 -0300 Subject: File name from file descriptor? In-Reply-To: <3B3333FF.BB019208@snakefarm.org> Message-ID: <5.0.2.1.0.20010622094719.026fcec0@mail.inet.com.br> Just for information, on some OS's several file names can point to the same file on the disk (on Unix, for instance). In some cases, I that it is possible to have a pseudo file without a true name (I think standard input is one example, but I'm not sure about the details). Also, fd* functionality depend a lot on the OS being used. Could you please tell us why do you *need* to make it work using file descriptors? At 14:03 22/06/01 +0200, Carsten Gaebler wrote: >Hi there! > >How can I determine a file's name if I only have the file descriptor? >os.fdopen(fd).name just returns '(fdopen)'. > >Regards >Carsten. >-- >http://mail.python.org/mailman/listinfo/python-list From leo at iems.nwu.edu Fri Jun 1 15:22:30 2001 From: leo at iems.nwu.edu (Leonardo B Lopes) Date: Fri, 01 Jun 2001 14:22:30 -0500 Subject: Tree Library Message-ID: <3B17EB76.560C6302@iems.nwu.edu> Does anyone know of a decent, simple, tree library, which implemented basic things like depth, completeness, degree, etc...? -- ======================================================================= Leonardo B. Lopes leo at iems.nwu.edu Ph.D. Student (847)491-8470 IEMS - Northwestern University http://www.iems.nwu.edu/~leo From jm7potter at hotmail.com Tue Jun 12 11:13:08 2001 From: jm7potter at hotmail.com (jm7potter at hotmail.com) Date: Tue, 12 Jun 2001 11:13:08 -0400 Subject: a newbie question about gadfly Message-ID: Hello one and all, I seem to be at a loss as to why the following code fails: ----- import gadfly connection = gadfly.gadfly("jnso", "..\\gadfly\\dbtest") cursor = connection.cursor() cursor.execute("select * from students") cursor.execute("insert into students (name, grade) values ('pat','grade 3')") namex = 'donna' gradex = 'grade 2' cursor.execute("insert into students (name, grade) values (namex, gradex)") connection.commit() ---- The first cursor.execute works fine since I use values ('pat','grade 3')") --- BUT, the second fails since I use values (namex, gradex)") --- Why? is namex not a direct replacement for "donna" ???? Any thoughts would be greatly appreciated. Regards, Joe From johnga1 at mindspring.com Sat Jun 16 21:03:02 2001 From: johnga1 at mindspring.com (J. E. Garrott Sr) Date: Sat, 16 Jun 2001 18:03:02 -0700 Subject: VI References: <3B278900.5828FB59@Lugoj.Com> <9gaunm$mth$3@brokaw.wa.com> <9gdol3$8i7$1@brokaw.wa.com> <9gfp6b117jh@enews1.newsguy.com> Message-ID: <3B2C01C6.C31D967E@mindspring.com> Alex Martelli wrote: > > "Jonathan Gardner" wrote in message > news:9gdol3$8i7$1 at brokaw.wa.com... > ... > > Does this mean "Vim" is "vee eye em" or "vim"???? > > "vim" is a perfectly good Latin word (in the accusative case) > meaning "strength". As it happens it's ALSO a perfectly > good English word (no doubt a late formation from the Latin > one, mid-1800's) meaning "robust energy and enthusiasm"... > > Alex Also VIM is Vi IMproved. As such its pronunciation has nothing to do with vi's. John From bob at drzyzgula.org Sat Jun 2 21:34:41 2001 From: bob at drzyzgula.org (Bob Drzyzgula) Date: Sat, 2 Jun 2001 21:34:41 -0400 Subject: Why isn't Python king of the hill? In-Reply-To: References: <9fb5fl$26kf$1@agate.berkeley.edu> <9fblqd$2f0u$1@agate.berkeley.edu> Message-ID: <20010602213441.E24658@drzyzgula.org> On Sat, Jun 02, 2001 at 09:52:57PM +0000, Grant Edwards wrote: > On Sat, 2 Jun 2001 21:28:45 +0000 (UTC), E. Mark Ping wrote: > > >>So do I. But every time I've seen an application _depend_ on exact > >>representations, its caused problems. Perhaps the FP code you've > >>seen was better, but in my experience code that depends on exact > >>represention has caused problems. > > > >Ah, but your example was exact representation of *integers*, not just > >any value. > > What I've seen happen: code is written by a programmer who > knows that the input values are going to be integer values that > can be represented exactly. It works fine for a few years. ... One occasionally useful source of solid thought on this issue is of course Knuth's Seminumerical Algorithms, Chapter 4, "Arithmetic". Knuth goes so far as to refuse to use the normal operators +, -, x and / for floating point operations (from Section 4.2.1, 3/e): Since floating point is inherently approximate, not exact, we will use "round" symbols [graphic of the normal operators with circles drawn around them] to stand for floating point addition, subtraction... At the beginning of section 4.2.2, he goes on: Floating point computation is by nature inexact, and programmers can easily misuse it so that the computed answers consist almost entirely of "noise". One of the principal problems of numerical analysis is to determine how accurate the results of certain numerical methods will be. There's a credibility gap. We don't know how much of the computer's answers to believe. Novice computer users solve the problem by implicitly trusting the computer as an infallible authority; they tend to believe that all digits of a printed answer are significant. Disillusioned computer users have just the opposite approach; they are constantly afraid that their answers are almost meaningless. Many serious mathematicians have attempted to analyze a sequence of floating point operations rigorously, but have found the task so formidable that they have tried to be content with plausibility arguments instead. Knuth of course goes on to explain, in mind-numbing detail, *exactly* "how much of the computer's answers to believe"... That chapter also includes around eighty pages on rational arithmetic, FWIW. Yes-i'm-new-to-this-list-please-don't-hit-me-ly y'rs, --Bob Drzyzgula From r2d2 at mao.acc.umu.se Fri Jun 8 02:28:41 2001 From: r2d2 at mao.acc.umu.se (Niklas Frykholm) Date: Fri, 8 Jun 2001 06:28:41 +0000 (UTC) Subject: WHY is python slow? References: Message-ID: >Although it is generally accepted that Python is slower than >Java/Perl/Ruby, a layman like me would be curious to know why >exactly this is so. In other words, why is the implementation >of a language like Ruby (which is on par with Python in terms >of 'everything is an object', strong reflection, dynamic >nature). The difference in speed between Perl/Python/Ruby is so small and so application-dependent that saying that one language is "faster" carries very little meaning. And choosing which language to develop in based on its "perceived speed" is plain foolery. Most applications only need to be "fast enough". If it isn't fast enough in Python, the chance is very slim that it will be fast enough in Perl or Ruby. Do not choose the fastest language --- choose the one you want to program in. Java is a slightly different horse. Some programs, for example those heavy on function calls or array manipulation can be much faster because of the static typing. But usually, an extension module, such as PyNumeric can take care of that. (I'll program in Java, but only if you pay me :) // Niklas From maxm at normik.dk Tue Jun 12 09:28:51 2001 From: maxm at normik.dk (=?iso-8859-1?Q?Max_M=F8ller_Rasmussen?=) Date: Tue, 12 Jun 2001 15:28:51 +0200 Subject: New to python Message-ID: <7BD10B680501D411B9DF009027E06F32197D48@exchange> > From: Karim [mailto:katiki at kodak.com] > Can someone write me in few lines why Python has been created ? > What for ? > For what kind of applications ? I think you will be able to find far more information than can be returned in an email at www.python.org regards Max M From brey at myrealbox.com Fri Jun 15 15:40:29 2001 From: brey at myrealbox.com (Ed Brey) Date: 15 Jun 2001 12:40:29 -0700 Subject: Hard links on Windows NT 4 and Windows 2000 Message-ID: There was a short thread about a year regarding hooking os.link up to the hard links that exist for Windows NT. This can be done for hard linked files (but not directories) in any OS that supports NTFS (i.e. Windows NT and 2000). The convenience function CreateHardLink added to Windows 2000 does not work under NT 4, of course; however, CreateHardLink isn't needed to create a hard link. See MS KB article Q234727 for details on how to do it: http://support.microsoft.com/support/kb/articles/Q234/7/27.ASP It should be possible to hook up os.link and os.stat (which currently always specifies a single link) to more closely reflect Windows reality. The old thread: http://groups.google.com/groups?hl=en&lr=&safe=off&ic=1&th=ae5afcf5615fa94,2&seekm=rn7c5.2568%244p3.19620%40news-server.bigpond.net.au#p didn't appear aware of the fact that hard links are not Windows 2000-specific, and so even though I'm not a Python developer, I thought I'd drop off this pointer in case anyone is interested in implementing the feature. From ullrich at math.okstate.edu Mon Jun 4 12:01:58 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 04 Jun 2001 16:01:58 GMT Subject: random References: Message-ID: <3b1bafa5.10164526@nntp.sprynet.com> On Mon, 4 Jun 2001 00:46:49 -0400, "Tim Peters" wrote: >[David C. Ullrich, on http://www.cs.umaine.edu/~chaitin/cmu.html] > >> ... >> Very interesting stuff, without a doubt. He wants to say that >> his point of view makes incompleteness seems inevitable he >> may well be right. But when he gets into statements like >> >> "there is no reason that individual bits [of Omega] are 0 or 1!" >> >> it's just too... well I better omit the adjective and just say >> that "there is no reason that individual bits are 0 or 1" is not >> a mathematical statement amenable to proof. > >It *sounds* powerful, though . I don't really object, because it >conveys *something* of the story in a way that would otherwise be over his >audience's head. Yes. When he says "for no reason" it's clear that that's not _exactly_ what he means. But people who don't realize that taking "no reason" literally makes no sense are going to read it literally. This leads to problems with storage space on usenet servers. >For example, over the last few weeks we've had several examples on c.l.py of >printing the exact decimal value of a machine binary floating-point value >with a non-zero fractional part. I don't know whether anyone noticed, but >every such example ended, in decimal, with the digit 5. The natural >inclination of anyone with even a slight bent toward mathematical thought is >to ask "Hmm! Was that just luck, or is there 'a reason' that's so?". With >a little thought, and even in the absence of a formal notion of axioms or >proof, I expect many people could get close to proving that 5 is no >accident -- it must be a 5, "it makes sense", "there's a reason for it". >And, indeed, that's the only kind of problem most people get exposed to in >school: "prove or disprove". > >It's at least a minor revelation then that some questions can't be answered >that way (by appeal to principle or proof -- "a reason"), that brute force >can be the only answer there is. But *phrasing* it as "no reason" is too >close to "senseless" for my tastes, so I'm sure it misleads people too. > >> Preciate the reference - I definitely learned one thing, at least: >> >> "Now what is the reaction of the world to this work?! Well, I think >> it's fair to say that the only people who like what I'm doing are >> physicists!" >> >> Not having studied his stuff or people's reactions to it I thought >> it was just me (seriously). (Um: It's _not_ true that mathematicians >> don't like his work, I know of plenty of mathematicians who find it >> fascinating. What people don't like is his [adjective] claims >> about what his work _means_...) > >I agree: it's the popular presentation, not the work, that people object >to. I read that G?del delayed presenting his incompleteness theorem (surely >a much greater shock at the time!) because he feared nobody would believe >him, so worried over every little detail of the arithmetic coding to make >the proof unassailable first. But by all accounts I've read, the ideas >behind the proof were compelling the instant logicians heard about them, and >despite that it wasn't what they were hoping to hear, and most skipped over >the laborious coding details as curious drudgery. Mathematicians are quite >calm in the face of crisis . Or perhaps they're quite good at recognizing the trivial bits. >OTOH, G?del kept what he thought his result "meant" to himself. Take >someone who learned it from the philosophy dept and another from the math >dept, lock them in the same room, and see whether they have *anything* in >common . But Rudy Rucker reported that in private conversation, >G?del's beliefs were actually closer to the former, that the result had >profound implications beyond just pointing out a limitation of formal proof >systems. I wish he would have written more about that; at least I won't >have the same regret with Chaitin. I certainly believe all that. My "preferences" would be different... >> The (or in any case _a_) point being things like >> >> "I think there may be political reasons, but I think there are also >> legitimate conceptual reasons, because these are ideas that >> are so foreign, the idea of randomness or of things that are true by >> accident is so foreign to a mathematician or a logician, >> that it's a nightmare! This is their worst nightmare come true! I >> think they would prefer not to think about it." >> >> He insists that the world of mathematics is all upset over his >> well-defined but unknowable Omega. If that irritates people what >> irritates them is not the well-defined but unknowable character >> of those bits, it's the idea that the idea of something being >> well-defined but unknowable started with him. It's no big deal, >> people have been dealing with "unknowables" for a long time. > >Wholly agreed. Some people were driven to despair and even suicide by >G?del's results at the time. Suicide? Anyone I've heard of? > Everything since (and there's been a lot) has >been greeted with "Wow -- here's yet *another* thing we can't know. Cool!". > >the-first-time-was-a-major-surprise-but-that-was-70-years- > ago-ly y'rs - tim > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From rdsteph at earthlink.net Sat Jun 9 14:11:18 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Sat, 09 Jun 2001 18:11:18 GMT Subject: Learning OOP... References: Message-ID: <3B2117AF.864050C1@earthlink.net> Look, no one language can ever be optimal for all your criteria simultaneously. However, Python offers the below; 1. Easy to learn, easy to use. Joyful to learn, joyful to use. In a week, you will be quite proficient, yet still have plenty of pleasurable learning ahead of you. Python's creator has been known to say that Python's power as an educational language gives hi the greatest pleasure; and I think he means educational in a deep sense. 2. It's 100% free, it has 100% free tools with quality, depth, and quantity. 3. It has the best user community and most helpful newsgroup. 4. It is well documented. mature and there are plenty of great books at all book stores. 5. In no other language can you be as productive, period. 6. As to momentum and marketplace issues (ugh, but here goes): Python is far more alive and vibrant than Ada. Only Java has more "buzz" and of course Visual Basic is most used, but VB will cost you an arm and a leg, this year, next year, and for eternity, until you finally kick the habit. 7. Java and C++ may offer more of what you want in terms of static typing; but compared to Python, they will slow down your development and stall your productivity. My suggestion is learn and use Python, the cost to benefit ratio just can't be beat. Then, if you feel yo need more strict discipline, go on and learn Java or C++; the education you got form Python will hold you in good stead and may be the best investment you have ever made. ;-)))) Rod Weston wrote: > Trying to decide which language to learn first. I have programming > experience in PICKBASIC and now want to learn OOP.At this point, I am > leaning toward learning Ada and then Python. Any ideas on why I > should or should not use these languages in this sequence? From MarkH at ActiveState.com Fri Jun 1 09:41:45 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Fri, 01 Jun 2001 13:41:45 GMT Subject: Returning 'None' on Instantiation ? References: Message-ID: <3B179C2C.9030505@ActiveState.com> Dave Haynes wrote: > Is there a way to optionally return 'None' on instantiation? Not literally. > I'm thinking of something like the following: > > class myClass: > def __init__(self, param): > > if : > > else: > The "best" way IMO is to raise an exception here: if Message-ID: "Carlos Ribeiro" wrote in message news:mailman.993562981.5640.python-list at python.org... > At 11:49 26/06/01 +0000, Maciej Pilichowski wrote: > >I have just started learning Python yesterday but... > > > > >def with_is_broken(a): > > > with a: > > > print x > > > > > >The snippet above assume that "a" must have a member attribute called "x". > > > >Nope. As you referred to Pascal -- if "a" has a member "x" it is read > >as "a.x", if not it is standalone "x". > > There must be some misunderstanding here. My snippet (incomplete, as I > pointed out) assumed that Python had a "with" keyword, just to show the > kind of problems that arise. In Python, the compiler/interpreter has no way > to tell beforehand if x is a member of a, a local variable, a module level > variable, or a global variable. This ambiguity makes the use of with in > Python impossible. > ...snip... I'm not a 'with' advocate, but if I was, I'd suggest: def with_maybe_not_broken(a): with a: print .x This seems like it would fix the concerns; however, you wouldn't be able to nest 'with' statements. Andrew Henshaw From James_Althoff at i2.com Wed Jun 20 20:43:21 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Wed, 20 Jun 2001 17:43:21 -0700 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) Message-ID: Jeremy Hylton wrote: >My problem isn't with learning how to subscribe to a new list; it's managing >the accounts for the dozens of lists I have to subscribe to and read just to >keep track of Python development. If I happen to be on vacation (or, say, >paternity leave) when a new list is created, I may end up missing more of >the discussion because I didn't subscribe in time. > >Jeremy I agree. Meanwhile, does anyone know where to find python-iterators and how to read or subscribe? Is there an archive? Thanks, Jim From nperkins7 at home.com Sun Jun 10 04:13:18 2001 From: nperkins7 at home.com (Nick Perkins) Date: Sun, 10 Jun 2001 08:13:18 GMT Subject: How do you develop in Python? References: <050620011516094693%pecora@anvil.nrl.navy.mil> Message-ID: I use NT, and I have yet to find a free IDE that I am really happy with. This is a serious shortcoming of Python. I know, the language itself is not resposible for giving me a wonderful free IDE, but in the mind of a Python user, the IDE is part and parcel of the language, and integral to the *experience of Python. Python, the laguage is wonderful, but weak IDEs make it look bad. I have used PythonWin, IDLE, Boa Constructor, and SciTe. With all apologies to those who developed these FREE IDE's... (it is not fair to complain about free software, and that is not my intention here -- I am sure that I could not do any better).. I simply, (and selfishly), wish that I could use Python to the full potential of the language itself, without being hindered by an IDE that freezes up, leaves behind runaway processes, or crashes. IDLE freezes up frequently. PythonWin freezes a bit less, and seems unable to kill a runaway program. Boa Constructor is more stable than these two, and allows you to kill a runaway program without killing the editor. However, it won't take you to the line that caused an error, which is very irritating. (broken feature) SciTe seems interesting, but I haven't figured out how to configure it, yet, and util I do, it's useless. (me being lazy, but still...) I want an IDE to provide at least the following: 1. Each run takes place in a fresh, clean environment. 2. The IDE stays responsive while a program is run. 3. The IDE can kill a running program. Another thing I would like, but that may have, i dunno, ..implications..? 1. The IDE should handle the sys.path so that Python does not fail to find a file that I currently have open, or is in the same directory. Is it not possible to start a 'fresh' interpreter for each run? Or is that not actually desirable for some reason? Would that make it impossible to kill it or get tracebacks, etc? Do we need a Python IDE that does not run itself in Python? ( i guess SciTE doesn't....maybe I'll give that another go..) BTW, which free IDEs are currently being maintained and improved? How much work is being done, and how many people are doing it? ( keep up the good work!, if this means you!) p.s. i know, i know, emacs, vim, etc etc....but I have become a bit of a windows softie, and have an aversion to such things. I am going to use emacs in my next life, and learn lisp as my first language..... From com-nospam at ccraig.org Thu Jun 28 11:54:21 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 28 Jun 2001 11:54:21 -0400 Subject: C extension problem (Solaris) References: <874rt0hkbi.fsf@elbereth.ccraig.org> Message-ID: <877kxwzjki.fsf@elbereth.ccraig.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Fredrik Stenberg writes: > Found the error, you forgot to end static PyMethodDef with {NULL, > NULL}. Thanks. - -- Christopher A. Craig Linux: (n) "A microkernel on which one can run operating system kernels such as XEmacs." -- Froggie, from Everything -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Processed by Mailcrypt iEYEARECAAYFAjs7Uy0ACgkQjVztv3T8pzvb4QCfbGBNSwES8pNVmPQAYKzPwfa8 sZ0AoMgMSBU0fKoyorzqjQwSvD16PWoo =Uez6 -----END PGP SIGNATURE----- From johnroth at ameritech.net Fri Jun 29 19:58:08 2001 From: johnroth at ameritech.net (John Roth) Date: Fri, 29 Jun 2001 16:58:08 -0700 Subject: Python for Commercial Games? References: <9haoiv$jnv$1@mtc1.mtcnet.net> Message-ID: "Kevin Riggle" wrote in message news:9haoiv$jnv$1 at mtc1.mtcnet.net... > I *do* realize that I'm posting to comp.lang.python , so please humor me > anyway... > > I am in process of designing a computer game; problem is, I want to at > least have a snowball's chance in Hades of selling the game. My question: > Would it be possible to write the dang thing in Python (PyWin), or is C/C++ > the better option in the Windows-centric world of game development right > now? Thanks in advance, > > Kevin Most commercial quality games use two languages. The "game engine" is usually written in C/C++ with Assembler for the really time critical pieces, and the actual "game" is written in a scripting language of some kind. Older games tended to use purpose built scripting languages, some recent languages use Perl or Python. In other words, the game engine itself does the common infrastructure, the script does the actual work of figuring out that you can get the hammer out of the box when you open it, but you can't get the sword out unless you close the box and then break the glass with the hammer (example from Zork: Grand Inquisitor.) The seperation of function is absolutely vital for a commercial game team of a dozen or six (dozen) people. You don't want your game designers writing in C, and you don't want to tie your C coders up doing the designer's scripting for them. So, yes. Python is absolutely appropriate for commercial quality games. However, you're not going to do any modern, graphics intensive game completely in Python. You could do a wizard text adventure, however. I don't think there's any market for them at the moment. John Roth > > From aahz at panix.com Fri Jun 1 15:21:35 2001 From: aahz at panix.com (Aahz Maruch) Date: 1 Jun 2001 12:21:35 -0700 Subject: Iteration index References: <9f63lo$rb0$1@zeus.polsl.gliwice.pl> <9f8pgk$11l6$1@agate.berkeley.edu> Message-ID: <9f8pvv$7ss$1@panix3.panix.com> In article <9f8pgk$11l6$1 at agate.berkeley.edu>, E. Mark Ping wrote: >In article , >D-Man wrote: >> >>s = ('a', 'b', 'ala', 'a') >>for i in xrange( len( s ) ) : >> print i , s[i] >> >>is easier to read, and you don't have the chance of forgetting to >>increment the counter. > >Agreed. But does it introduce n^2 complexity? I can't find anything >in the python docs that says that indexing into a list is O(1)--and >most people assume that indexing into a list is O(n). Dunno whether it's in the docs, but retrieving a list element is definitely O(1). -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Characters exist to suffer, you know. An author needs a little sadism in her makeup." --Brenda Clough From gerrie at trispen.com Thu Jun 28 03:03:19 2001 From: gerrie at trispen.com (Gerrie Roos) Date: Thu, 28 Jun 2001 09:03:19 +0200 Subject: newbie Q's Boa References: <20010624.162247.1597322404.2060@K7.atl.mediaone.net> <3B36EC1E.F3BF0C42@trispen.com> <9he45j$dn4qu$1@ID-87965.news.dfncis.de> Message-ID: <3B3AD6B7.94E83D11@trispen.com> callooah, callay! what a joyous, frivolous day! i'm sure this bug will be fixed in the next release. development on boa is advancing at a strong pace so do look out for the next one! the guy that started it all is one of my best friends so i love helping out when i can. myself wrote: > In article <3B36EC1E.F3BF0C42 at trispen.com>, "Gerrie Roos" > wrote: > > > Ah, I had the exact same problem...its a small bug only on non-windows > > systems...you were on the > > right track. > > > > In file Help.py, go to this line(roundabout 72 to 75): > > > > self.SetDimensions(120, 75, Preferences.wxDefaultFrameSize.x, > > Preferences.wxDefaultFrameSize.y) > > > > and remark it with leading #'s. > > > > directly after that you should put: > > > > if wxPlatform == '__WXGTK__': > > self.SetDimensions(120, 75, Preferences.wxDefaultFrameSize[0], > > Preferences.wxDefaultFrameSize[1]) > > > > I can't remember if this bit was there or not, but make sure you've got > > it in there. Its a small > > difference in the wxWindows API on MS and UNIX. MS uses .x and .y > > attributes and UNIX [0] and [1] indexes for wxDefaultFrameSize. > > > > lemme know if it helps or not! > > > Excellent, that did the trick! After following your suggestion, to the > letter I might add, I was able to see exactly what the help system was > looking for and adjust paths accordingly. Re-reading my post, I see the > second Q is nonsense- gotta stop posting when I'm tired and frustrated! > > Haven't had time yet to really use Boa (this weekend, for sure), but it > looks very impressive- hope development continues. Particularly like the > context sensitive help- moving in the right direction IMHO. > > many thanks.... > > > > > myself wrote: > > > From just at letterror.com Sat Jun 9 04:02:56 2001 From: just at letterror.com (Just van Rossum) Date: Sat, 09 Jun 2001 10:02:56 +0200 Subject: spell method chaining? References: <19l8IVAAgJI7EwAk@jessikat.demon.co.uk> <3B2111FF.D998EEE4@letterror.com> Message-ID: <3B21D830.E823D70F@letterror.com> Robin Becker wrote: > > In article <3B2111FF.D998EEE4 at letterror.com>, Just van Rossum > writes > .... > >s inheriting it) > > > >You can avoid that by spelling it like this: > > > >def gen(B): > > class W(B): > > __base = B > > def __init__(self): > > self.__base.__init__(self) > > return W > > > >Just > this nearly works fine in 2.1 if I have a from __future__ import > nested_scopes, but gives a shadowed variable warning if not. Sorry: I made made the unforgivable mistake to not _run_ the code I posted... Duh. Major braino. (Sorry also to Remco -- I should've known better ;-) But: it seems it's really hard to do what you want either with or without nested scopes. How about telling us what you really want to accomplish -- maybe there's a different way! Just From rnd at onego.ru Tue Jun 26 11:07:02 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 26 Jun 2001 19:07:02 +0400 (MSD) Subject: 'with' statement in python ? In-Reply-To: <9ha5h5$cn58u$1@ID-11957.news.dfncis.de> Message-ID: On Tue, 26 Jun 2001, Emile van Sebille wrote: Ooops, area will get wrong value. You can't do that without resolving namespaces! Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, June 26, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "It is better to be brief than boring." _/ From greg at cosc.canterbury.ac.nz Wed Jun 6 01:08:52 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 06 Jun 2001 17:08:52 +1200 Subject: how much does Python model my Compsci course? References: Message-ID: <3B1DBAE4.FA3053A2@cosc.canterbury.ac.nz> Roy Katz wrote: > > non-deterministic finite automata, DFA's, > context-sensitive grammars, grammar productions, param > passing, function implementation, arrays. > > I'm wondering what amount of this material is applicable to Python In the C implementation of Python, the lexical analyser consists of what amounts to a hand-coded DFA. The syntax is specified by a formal context-free LL(1) grammar from which a set of parser tables is automatically generated. The tables are used by what seems to be a form of recursive-descent parser. > Have any of you heard of a 'dope vector'? What is Python's > internal equivalent? As far as I remember, this refers to the technique of implementing a 2D array using a 1D array of pointers to 1D arrays. There isn't really any "internal equivalent" in Python, because it doesn't have a built-in multidimensional array type. The NumPy extension provides multidimensional arrays, but I don't know what sort of internal representation it uses. At a guess, I'd say it probably doesn't use dope vectors, but just keeps all the array elements in one contiguous block. > How about a 'central environment table' (as opposed > to 'activation records')? I'm not sure what you mean by a 'central environment table', but Python certainly has 'activation records'. They're called stack frames, and they are dynamically-allocated Python objects -- you can get hold of them and play around with them in your Python program if you want. (This is how the traceback is generated that you get when an uncaught exception occurs, for example.) > Which leads me to wonder if what I'm being taught in class is dated. Not dated; it's just that some of it really only applies to statically-typed, compiled-to-native-code kinds of languages such as Pascal and C. Python is a dynamic language more in the style of Lisp or Smalltalk. The implementation issues are somewhat different for these kinds of languages, and thus the techniques and terminology are different too. But not necessarily "newer" - dynamic languages have been around almost as long as static ones! -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From jafo at tummy.com Tue Jun 26 19:33:01 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Tue, 26 Jun 2001 17:33:01 -0600 Subject: libssl.so & libssl.so req'd for rpm install In-Reply-To: <3b341337.201568550@news1.on.sympatico.ca>; from ken_chiba@hotmail.com on Sat, Jun 23, 2001 at 03:56:44AM +0000 References: <3b327452.95354923@news1.on.sympatico.ca> <3B33CD23.90A98765@wombatzone.freeserve.co.uk> <3b341337.201568550@news1.on.sympatico.ca> Message-ID: <20010626173301.C29301@tummy.com> On Sat, Jun 23, 2001 at 03:56:44AM +0000, Ken wrote: >Ok. I'll give it a shot in the morning -- I have tried to compile the >src rpm for 2.1-5... and there were a lot of files that didn't work >out (is there a way to pipe the output from the install into a file?). If you're building from source, you'll need to make sure you have the openssl-devel package installed -- that's needed for building the source. Once you've installed the OpenSSL packages though, installing the binary RPMs should work find. You said you were still getting errors after doing that though, what *EXACTLY* were they? If you don't want SSL sockets, building from the SRPM without openssl should do the trick. Sean -- "I feel so insignificant... Like people are laughing at me." "You--You ARE a clown..." -- Bob Newhart Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From carlf at panix.com Sun Jun 10 09:38:14 2001 From: carlf at panix.com (Carl Fink) Date: 10 Jun 2001 13:38:14 GMT Subject: Use Jython to make true executable? References: Message-ID: In article , Tomasz Stochmal wrote: > for Windows just use py2exe http://starship.python.net/crew/theller/py2exe/ I actually knew that, but as I understand it py2exe just glues a Python interpreter to your script. I was hoping that gcc/Jython would create a non-interpreted version. That is, you could avoid the processing overhead of interperting a script, and thus get a much faster program. I'm not a compiler (or interpreter) writer, and it's perfectly possible that I'm simpmly wrong about this, of course. -- Carl Fink carlf at dm.net From scarblac at pino.selwerd.nl Thu Jun 21 04:13:31 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 21 Jun 2001 08:13:31 GMT Subject: Any other Python flaws? References: <9gr8o8$hhq$4@newshost.accu.uu.nl> Message-ID: Martijn Faassen wrote in comp.lang.python: > The PSU Public License is an open source licence even more infectuous > than the GPL. Even software that does not link to it must be released > under the PSUPL. Even software on a completely different computer, > even on a completely different planet. The PSU therefore holds the > exclusive rights over very advanced Klingon first person shooters, > which will blow away Quake & co in gore and impressiveness when the PSU > releases it to the market. Is the PSU license TGPLV (Totalitarian GeeInYou-Script Pubic [sic] License Virus) compatible? (http://catalog.com/hopkins/text/gnuscript.html) -- Remco Gerlich From rbw at myipcfg.com Thu Jun 7 20:18:55 2001 From: rbw at myipcfg.com (RBW) Date: Fri, 08 Jun 2001 00:18:55 GMT Subject: I paid for my new boat with this Message-ID: This really works! I cannot believe it after getting scammed with envelop stuffing,I thought there wasn't anything out there for stay at home moms(& Dads) I've just started this but already seeing the money roll in!! We do have honest people in society! HOW TO TURN SIX DOLLARS INTO SIX THOUSAND DOLLARS: READING THIS COULD CHANGE YOUR LIFE! IT DOES WORK! I found this on a bulletin board and decided to try it. A little while back, I was browsing through newsgroups, just like you are now,and came across an article similar to this that said you could make thousands of dollars within weeks with only an initial investment of $6.00! So I thought, "Yeah right, this must be a scam", but like most of us, I was curious, so I kept reading. Anyway, it said that you send $1.00 to each of the 6 names and address stated in the article. You then place your own name and address in the bottom of the list at #6, and post the article in at least 200 newsgroups. (There are thousands) No catch, that was it. So after thinking it over, and talking to a few people first, I thought about trying it. I figured: "what have I got to lose except 6 stamps and $6.00, right?" Then I invested the measly $6.00. Well GUESS WHAT!?... within 7 days, I started getting money in the mail! I was shocked! I figured it would end soon, but the money just kept coming in. In my first week, I made about $25.00. By the end of the second week I had made a total of over $1,000.00! In the third week I had over $10,000.00 and it's still growing. This is now my fourth week and I have made a total of just over $42,000.00 and it's still coming in rapidly. It's certainly worth $6.00, and 6 stamps, I have spent more than that on the lottery!! Let me tell you how this works and most importantly, WHY it works... Also, make sure you print a copy of this article NOW, so you can get the information off of it as you need it. I promise you that if you follow the directions exactly, that you will start making more money than you thought possible by doing something so easy! : Suggestion: Read this entire message carefully! (print it out or download it.) Follow the simple directions and watch the money come in! It's easy. It's legal. And, your investment is only $6.00 (Plus postage) IMPORTANT: This is not a rip-off; it is not indecent; it is not illegal; and it is 99% no risk - it really works! If all of the following instructions are adhered to, you will receive extraordinary dividends. PLEASE NOTE: Please follow these directions EXACTLY, and $50,000 or more can be yours in 20 to 60 days. This program remains successful because of the honesty and integrity of the participants. Please continue its success by carefully adhering to the instructions. You will now become part of the Mail Order business. In this business your product is not solid and tangible, it's a service. You are in the business of developing Mailing Lists. Many large corporations are happy to pay big bucks for quality lists. However, the money made from the mailing lists is secondary to the income which is made from people like you and me asking to be included in that list. Here are the 4 easy steps to success: STEP 1: Get 6 separate pieces of paper and write the following on each piece of paper "PLEASE PUT ME ON YOUR MAILING LIST." Now, get 6 US $1.00 bills and place ONE inside EACH of the 6 pieces of paper so the bill will not be seen through the envelope (to prevent thievery). Next, place one paper in each of the 6 envelopes and seal them. You should now have 6 sealed envelopes, each with a piece of paper stating the above phrase, your name and address, and a $1.00 bill. What you are doing is creating a service. THIS IS ABSOLUTELY LEGAL! You are requesting a legitimate service and you are paying for it! Like most of us I was a little skeptical and a little worried about the legal aspects of it all. So I checked it out with the U.S. Post Office (1-800-725-2161) and they confirmed that it is indeed legal. Mail the 6 envelopes to the following addresses: : #1)M. Wagster : 76 Star Circle : Dyersburg, TN 38024 : #2)L. Johnson : 85 Atherton Circle : Pittsburg, CA 94565 : #3)A. Young : 5560 Hillcrest Dr. : Union City, GA 30291 : #4)L. Mercer : 201 West Glenn apt 2J : Auburn, Al 36830 : #5)J. Swift : P.O. Box 3123 : Pinehurst, NC 28374 : #6)R. Weisbrodt : P.O. Box 521 : Mason, OH 45040-2641 STEP 2: Now take the #1 name off the list that you see above, move the other names up (6 becomes 5, 5 becomes 4, etc...) and add YOUR Name as number 6 on the list. STEP 3: Change anything you need to, but try to keep this article as close to original as possible. Now, post your amended article to at least 200 newsgroups. (I think there are close to 24,000 groups) All you need is 200, but remember, the more you post, the more money you make! You won't get very much unless you post like crazy. :) This is perfectly legal! If you have any doubts,refer to Title 18 Sec. 1302 & 1341 of the Postal lottery laws. Keep a copy of these steps for yourself and, whenever you need money, you can use it again, and again. : PLEASE REMEMBER that this program remains successful because of the honesty and integrity of the participants and by their carefully adhering to the directions. Look at it this way. If you are of integrity, the program will continue and the money that so many others have received will come your way. NOTE: You may want to retain every name and address sent to you, either on a computer or hard copy and keep the notes people send you. This VERIFIES that you are truly providing a service. (Also, it might be a good idea to wrap the $1 bill in dark paper to reduce the risk of mail theft.) So, as each post is downloaded and the directions carefully followed, six members will be reimbursed for their participation as a List Developer with one dollar each. Your name will move up the list geometrically so that when your name reaches the #1 position you will be receiving thousands of dollars in CASH!!! What an opportunity for only $6.00 ($1.00 for each of the first six people listed above) Send it now, add your own name to the list and you're in business! ---DIRECTIONS ----- FOR HOW TO POST TO NEWSGROUPS------------ Step 1) You do not need to re-type this entire letter to do your own posting. Simply put your cursor at the beginning of this letter and drag your cursor to the bottom of this document, and select 'copy' from the edit menu. This will copy the entire letter into the computer's memory. Step 2) Open a blank 'notepad' file and place your cursor at the top of the blank page. From the 'edit' menu select 'paste'. This will paste a copy of the letter into notepad so that youcan add your name to the list. Step 3) Save your new notepad file as a .txt file. If you want to do your postings in different settings, you'll always have this file to go back to. Step 4) Use Netscape or Internet explorer and try searching for various newsgroups (on-line forums, message boards,chat sites, discussions.) Step 5) Visit these message boards and post this article as a new message by highlighting the text of this letter and selecting paste from the edit menu. Fill in the Subject, this will be the header that everyone sees as they scroll through the list of postings in a particular group, click the post message button. You're done with your first one! Congratulations...THAT'S IT! All you have to do is jump to different newsgroups and post away, after you get the hang of it, it will take about 30 seconds for each newsgroup! **REMEMBER, THE MORE NEWSGROUPS YOU POST IN, THE MORE MONEY YOU WILL MAKE! BUT :YOU HAVE TO POST A MINIMUM OF 200** That's it! You will begin receiving money from around the world within days! You may eventually want to rent a P.O.Box due to the large amount of mail you will receive. If you wish to stay anonymous, you can invent a name to use, as long as the postman will deliver it. **JUST MAKE SURE ALL THE ADDRESSES ARE CORRECT.** Now, each of the 5 persons who just sent me $1.00 make the MINIMUM 200 postings, each with my name at #5 and only 5 persons respond to each of the original 5, that is another $25.00 for me, now those 25 each make 200 MINIMUM posts with my name at #4 and only 5 replies each, I will bring in an additional $125.00! Now, those 125 persons turn around and post the MINIMUM 200 with my name at #3 and only receive 5 replies each, I will make an additional $625.00! OK, now here is the fun part, each of those 625 persons post a MINIMUM 200 letters with my name at #2 and they each only receive 5 replies, that just made me $3,125.00!!! Those 3,125 persons will all deliver this message to 200 newsgroups with my name at #1 and if still 5 persons per 200 newsgroups react I will receive $15,625,00! With an original investment of only $6.00! AMAZING! When your name is no longer on the list, you just take the latest posting in the newsgroups, and send out another $6.00 to names on the list, putting your name at number 6 again. And start posting again. The thing to remember is: do you realize that thousands of people all over the world are joining the internet and reading these articles everyday?, JUST LIKE YOU are now!! So, can you afford $6.00 and see if it really works?? I think so... People have said, "what if the plan is played out and no one sends you the money? So what! What are the chances of that happening when there are tons of new honest users and new honest people who are joining the internet and newsgroups everyday and are willing to give it a try? Estimates are at 20,000 to 50,000 new users, every day, with thousands of those joining the actual internet. Remember, play FAIRLY and HONESTLY and this will really work THANKS EVERYONE WHO PARTICIPATES AND MAKES THIS SUCH A SUCCESS FOR US ALL!! _____________________________________________________________ This message posted with trial version of Express News Poster From kirk at strauser.com Mon Jun 18 12:03:49 2001 From: kirk at strauser.com (Kirk Strauser) Date: 18 Jun 2001 11:03:49 -0500 Subject: Python version of IQ has been updates (IQ v0.34.python) References: <505.566T11T1243597threeseas@earthlink.net> <3B2A7F5E.MD-1.4.4.padf@ihug.com.nz> <3871.567T2214T9794928threeseas@earthlink.net> <87puc3ao42.fsf@pooh.honeypot> <2509.568T2823T9766233threeseas@earthlink.net> <9gkftm026v9@enews2.newsguy.com> Message-ID: <87k829ai6y.fsf@pooh.honeypot> At 2001-06-18T08:59:32Z, "Alex Martelli" writes: > For regular expressions, they're extremely similar, and both VERY > hard-going for a beginner. Alex, I would compare that to "Mathematica's nonlinear equation solvers are VERY hard-going for non-mathematicians." Perl's RE syntax is designed by and for people who have pretty much mastered the subject elsewhere. > Outside of regular expressions, I do not think anybody would claim Perl's > concise syntax is anywhere near as easy-to-read as Python's clean and > spare one. I would. Then again, I'm more experienced with C, C++, Java, and other similar languages. You can write C in Perl if you feel comfortable with it. > > Can perl be compiled into byte code for faster startup or put into a stand > > alone application? Or is Perl strickly an interpreted language? > Both:-). You can *buy* "Perl compilers" (e.g. from ActiveState > and IndigoPerl -- are there others?) that are roughly equivalent > to what you can do with the free py2exe and McMillan's "install" > for Python. They are also similar to the `perlcc' command that ships with Perl 5.005 and higher. Specifically, perlcc generates C source that, when compiled, acts exactly like the original Perl. > > Of course you can port IQ to Perl if you want, but in any case (perl, > > python, rebol, arexx) it'd be nice to incorporate into IQ, the ability to > > access files thru the internet in a way that is as simple as accessing a > > file on the system you are using IQ on. > If you use Python, that's trivial -- just open the URL string with > urllib.urlopen, exactly like you would open a filepath string with the > builtin function open, and you'll get a file(-like) object ready for > reading through all the usual fileobject methods (.read, readline, etc > etc). Same with Perl. Use the appropriate class, create a URL-fetch object, then execute it. Read the results just like any other filehandle. Perl and Python are roughly equivalent from my understanding. However, it's my opinion that Perl is much more well-supported, with massive amounts of online documentation and available help. -- Kirk Strauser From guido at python.org Tue Jun 26 16:58:12 2001 From: guido at python.org (Guido van Rossum) Date: Tue, 26 Jun 2001 20:58:12 GMT Subject: 'with' statement in python ? References: <3b3875f1.110436929@news.tpi.pl> <5.0.2.1.0.20010626103003.02841da0@mail.inet.com.br> Message-ID: D-Man writes: > It's not impossible, it would just be a runtime determination. > Already for bare names python looks in locals(), then up through the > nested scopes (if enabled) and in globals() and __builtin__. It > _could_ do the same for instances in the presence of a 'with' > statement. Note that for *reading* variables Python searches a bunch of scopes: locals, globals, builtins. (Plus outer functions if nested scopes are enabled in Python 2.1.) But for *writing* variables, Python has to pick one scope, and it always picks the innermost scope. The with statement would have to make all simple assignments assign to an attribute of the object mentioned in the with clause. I don't think this would enhance code clarity -- several examples have already been posted. --Guido van Rossum (home page: http://www.python.org/~guido/) From ullrich at math.okstate.edu Sun Jun 10 09:00:13 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 10 Jun 2001 13:00:13 GMT Subject: random References: Message-ID: <3b236912.195677@nntp.sprynet.com> On Sun, 10 Jun 2001 00:50:50 -0400, "Tim Peters" wrote: [...] >> >> So I lied, but it's not as obvious as you say that my lie >> _must_ have been wrong - as long as we're just talking >> about "a random program" without specifying the distribution >> what I said could have been right regardless of questions of how >> smart the first program is. > >All agreed. I wasn't bothered that *a* program could "be that smart", but >"the 0th" program specifically: it was pointing at the essential >arbitrariness of a measure that depends on how you just happen to tag the >machines with ordinals. "Interesting" results in this (and related) field >are independent of labeling, so if Chaitin had come up with a result that >wasn't so independent, this thread never would have started . Yes, when I thought that the definition depended on the ordering that did make it seem a little silly, I mean a little less interesting. Of course it _does_ depend on the UTM, and there _is_ a UTM which will make Chaitin's Omega equal to the number that has n-th bit set iff the n-th TM in some arbitrary (computable) ordering halts, namely the silly one I've described. Giving an Omega which definitely does not "pass all computable tests for statistical randomness", or however he puts it. By which I positively do not mean to suggest that anything Chaitin said was wrong, just that I'm still not quite certain exactly what the _hypotheses_ are under which a UTM gives a perfectly magical Omega. He says something (which I think you've quoted above) about the technical part being coming up with a UTM that makes his probability measure work out right, and absent a definition of "right" I still wonder to what extent he's defining "right" as "allowing me to prove what I want to prove". But I suspect that he has a more natural definition of "right", or "self-delimiting" means something other than what I take it to mean, or something. And as you've suggested, it's not reasonable to expect to get that sort of technical detail straight on usenet. The UTM that appears to contradict him is certainly _very_ far from being an _efficient_ encoding - presumably the hypotheses have to do with that, as someone suggested. (For a while I thought that if the hypotheses included something about efficiency then that made his results less "natural". But since he's specifically studying algorithmic complexity that's not fair. In fact in real programming languages it will be true that the length of the shortest program computing (X,Y) will be not much larger than the sum of the lengths of the shortest programs compuing X and Y, so a hypothesis to that effect is really not all that unnatural. If that or something similar is what the hypothesis actually is.) >>... >> That's the best excuse I can contrive. Oh well. > >You don't need an excuse! I wasn't careful with definitions, and was too >keen to keep this all at "fuzzy overview" level. So that's my excuse. Ok. >> Thought I had the problem of inexact floating point solved. > >Python beat you to it: A real number is computable iff Python can compute >it. Therefore you can enumerate the set of non-computable reals just by >picking them from the gaps in the ones Python can compute . There you go, getting all condescending again. No wait, there's nothing condescending about it... >for-example-0.1-ly y'rs - tim > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From twofingersalute at atl.mediaone.net Wed Jun 27 22:17:57 2001 From: twofingersalute at atl.mediaone.net (myself) Date: Wed, 27 Jun 2001 22:17:57 -0400 Subject: newbie Q's Boa References: <20010624.162247.1597322404.2060@K7.atl.mediaone.net> <3B36EC1E.F3BF0C42@trispen.com> Message-ID: <9he45j$dn4qu$1@ID-87965.news.dfncis.de> In article <3B36EC1E.F3BF0C42 at trispen.com>, "Gerrie Roos" wrote: > Ah, I had the exact same problem...its a small bug only on non-windows > systems...you were on the > right track. > > In file Help.py, go to this line(roundabout 72 to 75): > > self.SetDimensions(120, 75, Preferences.wxDefaultFrameSize.x, > Preferences.wxDefaultFrameSize.y) > > and remark it with leading #'s. > > directly after that you should put: > > if wxPlatform == '__WXGTK__': > self.SetDimensions(120, 75, Preferences.wxDefaultFrameSize[0], > Preferences.wxDefaultFrameSize[1]) > > I can't remember if this bit was there or not, but make sure you've got > it in there. Its a small > difference in the wxWindows API on MS and UNIX. MS uses .x and .y > attributes and UNIX [0] and [1] indexes for wxDefaultFrameSize. > > lemme know if it helps or not! > Excellent, that did the trick! After following your suggestion, to the letter I might add, I was able to see exactly what the help system was looking for and adjust paths accordingly. Re-reading my post, I see the second Q is nonsense- gotta stop posting when I'm tired and frustrated! Haven't had time yet to really use Boa (this weekend, for sure), but it looks very impressive- hope development continues. Particularly like the context sensitive help- moving in the right direction IMHO. many thanks.... > > myself wrote: > From gbreed at cix.compulink.co.uk Tue Jun 19 10:21:32 2001 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: 19 Jun 2001 14:21:32 GMT Subject: nested classes References: <3B2E4725.535AB18E@sympatico.ca> Message-ID: <9gnn5c$b00$1@plutonium.compulink.co.uk> In article <3B2E4725.535AB18E at sympatico.ca>, seefeld at sympatico.ca (Stefan Seefeld) wrote: > uh, what do *you* think that I'm trying to do, then ? :) Beats me :) > What I'm arguing about is a matter of name resolution. I sure > can open a scope 'A' in C++, insert a new scope 'B' into it, > and from within that access other symbols declared in scope 'A'. > In fact, I don't need to qualify them (i.e. 'foo' instead of 'A::foo' > for any symbol 'foo' in the scope 'A' is just fine) if I'm inside > that scope, no matter how deeply nested (of course, as long as there > are no ambiguities). You're correct, I've found an example and an argument against them But my head still spins when I try to think of a C++ class that hasn't been instantiated. C++'s nested classes seem to be a special case of what Java's inner classes do, so check the thread on those. Here's another try: class A: def __init__(self): self.prefix = 'usr/local' class __B: def __init__(self, parent): self.prefix = os.path.join(parent.prefix, 'share') def B(self): return self.__B(self) print A().prefix print A().B().prefix You could remember the parent, but that'd lead to a circular reference (not such a bad thing for 2.x). Which means the same purpose would be served by class FileNode: """holds a prefix""" A = FileNode() A.prefix = 'usr/local' A.B = FileNode() A.B.prefix = os.path.join(A.prefix,'share') print A.prefix print A.B.prefix No problem about the namespace, because it's always explicit. Or class FileNode: def __init__(self, prefix): self.prefix = prefix def addNode(self, name, prefix): setattr(self, name, FileNode(os.path.join(self.prefix, prefix))) A = FileNode('usr/local') A.addNode('B','share') print A.prefix print A.B.prefix Or class FileNode: def __init__(self, prefix): self.prefix = prefix def newChildNode(self, prefix): return FileNode(os.path.join(self.prefix, prefix)) A = FileNode('usr/local') A.B = A.newChildNode('share') print A.prefix print A.B.prefix Perhaps if you give us C++ code of what you're trying to do, we can tell you why you don't need to do it ;) Graham From philh at comuno.freeserve.co.uk Fri Jun 29 17:05:54 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 29 Jun 2001 22:05:54 +0100 Subject: Is this a true statement: Part II References: <9hiifr$sjs$1@taliesin.netcom.net.uk> Message-ID: On Fri, 29 Jun 2001 14:48:23 -0400, MDK wrote: > >Why is C++ awful; what's wrong with it? I don't think it is awful. But it does have drawbacks. The main one, IMO, is that the tasks it is good at are not the tasks it is mostly used for. C++ is a very good system programming language. For wiritng operating systems, device drivers, windowing systems, programing language compliers and interpreters, it's a natural choice. But for writing GUI applications, it typically isn't, unless speed is imperative. Write your apps in python. Then convert them to C++ if it doesn't run fast enough. -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From brian at sweetapp.com Sun Jun 17 13:33:12 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Sun, 17 Jun 2001 10:33:12 -0700 Subject: Writing new codecs In-Reply-To: <200106170837.KAA02291@pandora.informatik.hu-berlin.de> Message-ID: <002d01c0f753$95a8ae60$445d4540@D1XYVL01> > Please have a look at > http://sourceforge.net/projects/python-codecs. There are a few > additional codecs, and none of them extends _codecs. Each of the > modules provides a set of codecs, not a single one. But these modules aren't part of core Python so there strategy will necessarily be a bit different. I've looked at this project before. Hopefully all of this code will end up as part of the Python CVS soon. > Personally, I think on systems that offer iconv, the iconv codec > should be the only one you'd ever need - although the UTF-7 converter > is supported in gconv only starting with glibc 2.2. What is iconv? Cheers, Brian From tim.one at home.com Fri Jun 15 19:29:49 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 15 Jun 2001 19:29:49 -0400 Subject: PEP 255: Simple Generators In-Reply-To: <%iwW6.245075$eK2.51875868@news4.rdc1.on.home.com> Message-ID: [Nick Perkins] > neat! > simple, powerful, and easy to understand! > > This reminds me of 'contiuations', a la 'call/cc' in Scheme. > ( a little harder to understand ) > I understand that call/cc can be used to implement all kinds of control > structures. Yeild sounds more like "set entry point to current > continuation, and return" See the references to Stackless in the PEP; Stackless implements continuations for Python. > Could it be used to turn a partially-evaluated function into a > first-class object? Hmm. If you can paint with a hammer, or pound nails with a paintbrush, sure . > You could have a function that takes it's arguments, "yeilds" > None, and then waits for it's next invocation to actually 'do the > dirty work'. ...wait..can they take args?... Can what take args? Generator-functions can certainly take args. > What are the implications of generators resembling continuations, None, because: > and what is the liklihood that generators will be used/misused/abused > to implement tricky control structures? Also none: a generator can yield only to its immediate caller. In that sense it's no more powerful (or difficult to implement) than call/return. It can't "remember the state of the call stack", a generator can only remember its own local state, and it can't yield to any places other than the places from which it's explicitly called. That's what spares generators from the implementation headaches of full-blown continuations. think-of-'em-as-resumable-functions-ly y'rs - tim From philh at comuno.freeserve.co.uk Sun Jun 24 17:10:13 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Sun, 24 Jun 2001 22:10:13 +0100 Subject: How useful do you find the interactive interpreter? References: <4688f24b.0106231658.43d2c446@posting.google.com> Message-ID: On 23 Jun 2001 17:58:18 -0700, slaytanic killer wrote: >Hi, > >I am looking at Python seriously, and I can see that the interpreter >would be really good for testing out ideas. Getting small things to >work and then switching over to a text editor to generalize what I've >learned. Is this how people generally use it? True for me. -- ==== Philip Hunt == philh at comuno.freeserve.co.uk ==== Want to stop global warming? Do you support the Kyoto Treaty? Then boycott Esso (ExxonMobil in the USA). See www.stopesso.com for details. From aleaxit at yahoo.com Fri Jun 8 05:11:08 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 8 Jun 2001 11:11:08 +0200 Subject: Why should i use python if i can use java References: <9fngvl011jg@enews2.newsguy.com> <9foms801hod@enews1.newsguy.com> Message-ID: <9fqhie085a@enews1.newsguy.com> "D-Man" wrote in message news:mailman.991952533.1065.python-list at python.org... ... > | > Patterns discussion explaning why Java is _still_ a very low level > | > language even though it is bytecode-compiled and interpreted. > | > | Well, not VERY low...!-). Just lower than Python... > > Sometimes (far too often, especially when writing unit tests) Java > feels very low level. Nolo contendere re unit tests. > | GVIM rules (5.8's what I'm using now), but I doubt even 6.0 provides > | me with a Jython debugger &c...?-) > > No, not yet. The debugger should provide a way (hook) to jump to the > source in an editor, using an existing editor process if it is already > running. But what Jython debugger does this...? > | > 6.0 is nearly finished and has some really cool new features including > | > "folding" (the ability to collapse a block of text into a single line > | > on the display). > | > | Cool indeed (I'm sure the EMACSers are laughing at us of course:-). > > One of my coworkers who uses emacs said "Emacs has had that for 10 > years!" :-). The funny thing is vim has hardly been around that long. Yep, but vi was -- warts and all, of course, but still, my fingers are SO happy not to have to dart for multiple modifier keys, arrowkeys, mice, etc, when I'm doing serious editing!-) Alex From gmcm at hypernet.com Fri Jun 1 22:31:51 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 02 Jun 2001 02:31:51 GMT Subject: How to find the package a module belongs to ? References: <90B3AAB72gmcmhypernetcom@199.171.54.155> Message-ID: <90B3E0C74gmcmhypernetcom@199.171.54.194> Siggy Brentrup wrote: >gmcm at hypernet.com (Gordon McMillan) writes: > >> Jeff Sandys wrote: >> ... >> [Sasa Zivkov] >> >> I have a package containing several modules. >> >> Is is possible, within a module, >> >> to say "give me the package I belong to" ? >> >> Strictly speaking, no, not automatically, because module x within >> package p may be loaded as p.x or just as x. [Siggy] >Just use the module's __name__ attribute, in both cases it's 'p.x'. >A module is part of a package iff it's __name__ attribute contains a >'.'. > >>>> import xml.dom.html as H >>>> H.__name__ >'xml.dom.html' >>>> import socket as S >>>> S.__name__ >'socket' Given /test __init__.py a.py b.py Then: C:\tmp\test>python a.py I'm b. My __name__ is b C:\tmp\test>cd .. C:\tmp>python test/a.py I'm b. My __name__ is b C:\tmp>python Python 1.5.42+ (#0, Mar 28 2000, 20:39:47) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> from test import a I'm b. My __name__ is test.b ignoring-the-case-of-my-__name__-is-__main__ly y'rs - Gordon From robin at stop.spam.alldunn.com Fri Jun 1 23:50:58 2001 From: robin at stop.spam.alldunn.com (Robin Dunn) Date: Sat, 02 Jun 2001 03:50:58 GMT Subject: Python + threads + wxWindows = segfault, help! References: <9f8f7j$k5c$1@panix6.panix.com> Message-ID: > The application design is using the parent for the GUI and > threads for communication. Data is passed back and forth via > Python's Queue class. > > Most of the segs that I get seemingly have to do with threads. > I think I'm the only SMP user on the project and oddly enough, > I think I'm the only user seeing issues like this. This is a known bug that has been around for some time. It only happens on SMP hardware, which I don't have yet, so there have been a couple blind attempts at a fix that have failed. My new SMP motherboard and processors and etc. arrive next week, so hopefully soon I'll be able to better understand the problem and then come up with a solution. (Just don't tell my wife that all this new hardware ($$$) was only bought to squash a bug in free software...) NT and Win2k users can work around the problem by telling the OS to keep the process on just one processor: import win32api, win32process cp = win32api.GetCurrentProcess() win32process.SetProcessAffinityMask(cp, 1) You can keep track of the bug here: http://sourceforge.net/tracker/?func=detail&aid=223169&group_id=9863&atid=10 9863 -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! From tim.one at home.com Sun Jun 17 18:00:06 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 17 Jun 2001 18:00:06 -0400 Subject: str smarter than round? In-Reply-To: <3B2A55A5.A2BF0D8C@destiny.com> Message-ID: [Michael Chermside] > Attention Tim: > > I looked over the new appendix and have one tiny edit to suggest. > ... Good idea! Thanks. Checked in as Doc/tut/tut.tex revision 1.140 Misc/ACKS revision 1.98 Note that suggestions are less likely to get lost if they're entered as a bug or patch report on SourceForge. From neil.benn at cambridgeantibody.com Tue Jun 5 06:39:00 2001 From: neil.benn at cambridgeantibody.com (Neil Benn) Date: Tue, 5 Jun 2001 11:39:00 +0100 Subject: Numeric Programming for Everybody (was Re: I had a thought ...) References: Message-ID: <3b1cb719$0$12248$ed9e5944@reading.news.pipex.net> Hello, > How can the language > accommodate the differing needs of the learner and dilettante on the one > hand, and the specialists in various kinds of numeric programming on the > other? Or should it? As a programmer interested in interfacing to serial devices over RS-232, I really don't care about the intricacies of floating point calculations. If practically 2+2=4, then I'm fine with that. I think in the majority of real world applications, in a pragmatic sense most people don't care of the intricacies of number representation as long as it works (which in 99.9999999% of cases - it does for a fixed, static implementation). Leave that to the experts, it's not just learners who don't care about the floating point philosophies. For highly specialised programming requirements (e.g. mathematical work, advanced neural netoworking) then highly specialised tools should be used, obviously that's a personal opinion not a statement! For everything else, just get it to work and work reliably. Cheers, Neil "Don Dwiggins" wrote in message news:mailman.991685948.23344.python-list at python.org... > Tim Peters writes: > > [Don Dwiggins] > >> See http://support.microsoft.com/support/kb/articles/Q172/3/38.ASP for > >> one use of Currency having nothing to do with money. > > > Cute! In an earlier, unrelated thread, we learned that the Currency type is > > really a 64-bit int, conceptually scaled by a factor of 10000. The > > performance counter API uses 64-bit ints directly. So they're the same > > thing, except that the VB code at the link has to fiddle around multiplying > > the Frequency value by a magic 10000 to get VB to *treat* the value like a > > real 64-bit int. OTOH, in (Ctr2 - Ctr1) / Freq, the 10000's cancel out so > > they dare not play with magic multipliers in *that* context. Oh ya -- I bet > > all the VB programmers understand this in sufficient detail to bet the > > business on . > > This, and the various threads on numeric representation and computation, > triggered the following thoughts: > > - Common number systems can't be completely and accurately represented in > computers -- some limitations and/or approximations must be accepted. > > - This is widely acknowledged among programmers, but not obvious to > newcomers. > > - Many of those who acknowledge it don't have a complete understanding of > the "limitations and/or approximations" and the sometimes subtle > consequences for building software that handles numbers "reasonably". (As > evidence, I offer the discussions in this group. I also freely admit > that, if I were to undertake serious floating-point programming again, I'd > have to brush up on the details.) > > - For many purposes, a relatively naive level of understanding is sufficient > -- provided it's accompanied by an appreciation that there's more to it, > and that one may be required to learn the details of floating point, > rational representations, etc. > > So, what are the implications for "Computer Programming for Everybody"? How > much and what knowledge should the newbie be expected to master, to avoid > falling into various traps? What conceptual model(s) of numbers should a > language (say, for example, Python) present to the learner to be generally > useful without making it too easy to go wrong? How can the language > accommodate the differing needs of the learner and dilettante on the one > hand, and the specialists in various kinds of numeric programming on the > other? > > -- > Don Dwiggins "Solvitur Ambulando" > Advanced MP Technology > dwig at advancedmp.net > > From johnroth at ameritech.net Fri Jun 15 09:38:54 2001 From: johnroth at ameritech.net (John Roth) Date: Fri, 15 Jun 2001 06:38:54 -0700 Subject: idle BUG References: Message-ID: "Tim Peters" wrote in message news:mailman.992571923.27618.python-list at python.org... > [Robin Becker] > > I think this must be a bug in Tkinter, but since no one ever responds I > > thought I'd whine about idle instead. > > See > > http://sf.net/tracker/?group_id=5470&atid=105470&func=detail&aid=216289 > > > I run python2.1 Win95 OSR2. > > Start a command window > > run python idle.py > > > > Kill the idle window using the mouse (click on the x). In some unknown > > percentage of cases (like 50%) the process hangs and doesn't return to > > the command window. > > > > The hung process is very destructive and makes it impossible to reboot > > the machine properly. This bug has been present for a very long time > > and I'm fed up with it. > > Use pythonw instead. Then it doesn't hang. Nobody knows how to fix it, or > even what causes it (follow the link). Pythonw is OK for the shipping version of an app, but I need the console window while I'm debugging. If the problem is strictly associated with the close button in the upper right corner, then I'll just have to put explicit close buttons in places where they don't belong. Fortunately, I can make that so they only show up in test code, and won't affect the shipping versions. John Roth From tim.one at home.com Sat Jun 23 05:40:13 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 23 Jun 2001 05:40:13 -0400 Subject: Legitimate to raise SyntaxError for non-Python syntax errors? In-Reply-To: <915a998f.0106220115.2421a360@posting.google.com> Message-ID: [Hamish Lawson] > Is it legitimate to use the SyntaxError exception for non-Python > syntax errors, say by a parser when it encounters violations in the > syntax of the data format or mini-language it is parsing? I'd always > assumed that SyntaxError was meant for just Python syntax errors, ... I doubt anyone will object. Thousands of programs reuse Python's ValueError and TypeError, and while SyntaxError reuse is less common, it seems like it's much the same thing. Just because Guido took all the good exception names first doesn't mean he gets to keep them to himself . I'd draw the line at trying to reuse SystemError: that's used by Python in the role of an assert, raised when "something impossible" happens in the core. So when that happens, no way do you want *your* code to be a suspect. don't-do-the-crime-if-you-can't-do-the-time-ly y'rs - tim From aleaxit at yahoo.com Mon Jun 11 15:59:01 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 11 Jun 2001 21:59:01 +0200 Subject: Learning OOP... References: <3b25059c.5089017@news.laplaza.org> Message-ID: <9g37sv02c8k@enews1.newsguy.com> "Mats Wichmann" wrote in message news:3b25059c.5089017 at news.laplaza.org... ... > Whew, you sure get an education on this group. Pope Sylvester? Ooops, sorry for the too-tangential mention. Gerbert of Aurillac, 945 (ca)-1003, made Pope Sylvester II in 999. Besides a hectic religious and political career, he wrote a treatise on the abacus which was the standard for centuries, developed the principle of constant-pressure acoustic organs, built the first clock using a pendulum as the time-regulating device, and allegedly also introduced Arabic numerals to the West (he surely did know them, having studied in Arab Spain as a youth, but the "introduction" is controversial indeed). Among his many distinctions, he was as close as it gets to a Ghibelline, almost-Protestant Pope (a lot of what he wrote in favour of the power of Kings, Emperors, local Churches, &c, and against Papal supremacy, he wrote of course before he was Pope -- but he didn't reverse himself in his 4 extremely-active years on Peter's Seat), close personal friend of French and German kings -- the first French Pope -- and rumored by spoken tradition to be the real founder of the Studium in Bologna (officially recognized only 100 years later, which still suffices to make it oldest in the Western world:-). Protestants and Gallicans resurrected his memory 500 years later, shedding the centuries of legends about Gerbert as a great Black Magician, and restoring his numerous-enough claims to real, historical distinction. Why people are so keen to forget him, I don't know. Perhaps we're all so totally convinced of the year 1,000 as an age of ignorance and dark superstition that we'd rather forget that the then-Pope was a figure so contrary to this hard-to-dislodge misconception:-). > >> "Aggregate, not inherit". Especially in python, > > >Wrong, especially in Python. When needed semantics are exactly > >those of Python's inheritance (which happens very often, because > >Python is very well designed), it is an absurd obfuscation > >exercise to rebuild the same mechanism, slowly and unreadably, > >on top of _other_ Python building-blocks, in the name of some > >abstract and inapplicable principle. > > I've heard a number of folks claim that while inheritance is powerful, > it's often used where it need not to be, and that perhaps one should > think composition first. I tend to read that as particularly a problem > with compiled languages (I think Java, since that's the closest > comparison that I have any competency with), where you have to give > all the information to the compiler up front, and not so much with > Python where everything's dynamic. Yes, and yes -- to be succint for once:-). Inheriting in Java is a very high commitment choice -- even more than in C++, since you only get to choose ONE base class:-). > Will you please fill in the blanks on your statement above, Alex? > "When the needed semantics are exactly those of Python's > inheritance".... No blanks there, just an overly long sentence as is my wont; to restate the essential part thereof, when you need the semantics of Python's inheritance, it's absurd to rebuild them from pieces -- they're already there, just ready for reuse! Those semantics, by the way, are ones of easy-as-pie mutual calls (and to a lesser importance, data-access) between super and sub-classes... Alex From rdsteph at earthlink.net Mon Jun 18 21:50:16 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Tue, 19 Jun 2001 01:50:16 GMT Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? References: <3B2B60AD.942719AE@earthlink.net> Message-ID: <3B2D60A9.D1507252@earthlink.net> Well, I really appreciate all of the good advice and comments. Considering all of it, and that I am using Windows, I think I am going to decide to just dig in and really study and learn either Tkinter *or* wxPython. I have a whole week next week, my family will be gone and I am on vacation. I should be able to do it. I lean towards Tkinter, because I have "Programming Python" and "Python and Tkinter" books. But I do look wistfully at wxPython, which seems pretty straight forward OOP (as far as it looks to this newbie) and the documentation in the wxPython package looks pretty good on all the widgets; *and* the new tutorial recommended by Christopher Barker at http://wxpython.org/cgi-bin/wiki/Getting_20Started looks fine. wxPython is tempting. My usual modus operandi when faced with such a dilemma would be to just dive in and try to learn both, since I couldn't decide between them, thus over-complicating the chore. ;-)) I really think I should decide this though. Tkinter, by a hair, unless I change my mind by Friday, when I get home from the office ;-))) Does anyone recall the 60's song "Have you ever had to make up your mind, .......and leave the other behind" or some such lyrics... Thanks for *all* the help. It was informative and appreciated. Still open to last minute wxPython vs. Tkinter comments.... From hannah at schlund.de Mon Jun 18 13:27:53 2001 From: hannah at schlund.de (Hannah Schroeter) Date: 18 Jun 2001 19:27:53 +0200 Subject: Any other Python flaws? References: <3b296534.514160393@wa.news.verio.net> <3b2a94a6.591842855@wa.news.verio.net> Message-ID: <9gldmp$i2v$1@c3po.schlund.de> Hello! In article <3b2a94a6.591842855 at wa.news.verio.net>, Bengt Richter wrote: >[...] >>http://www.xanalys.com/software_tools/reference/HyperSpec/Body/chap-19.html >Thanks for the link, although ISTM it focuses on regularizing path >expressions relative to _existing_ file systems without creating a >_new_ hierarchy, which is a key part of what I was trying to describe. Just lookup the stuff on *logical* pathnames in subsection 19.3 Logical Pathnames... >[...] >_EXCEPT_ that they are trying to standardize _actual_ file systems >whereas I was saying that you could define an _abstract_ tree of/for >names totally independently, and then attach/mount things to standard >places in that tree so that they can be accessed in known abstract >tree locations irrespective of their actual file system tree locations >or the pathnaming conventions of the particular OS/file system. Now, my SBCL startup contains e.g. this: (let* ((homedir (posix-getenv "HOME")) (translation (concatenate 'string homedir "/**/*"))) (setf (logical-pathname-translations "home") `(("home:**;*.*.*" ,translation)))) Packages like CLOCC use logical pathname hosts like "clocc" and so on for references to other files in that package. >[...] >Also, switching experimental stuff in and out would be made more >flexible, I would anticipate, since changing a few lines in a >configuration file could determine what shows up where. Right, just as the (setf (logical-pathname-translations ...) ...) stuff in my .sbclrc. And that can be more complicated translations based on pattern matching instead of that simple one "translate everything on host 'home' to be relative to my home directory". Kind regards, Hannah. From xyzmats at laplaza.org Sat Jun 9 16:17:02 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Sat, 09 Jun 2001 20:17:02 GMT Subject: Mutable class attributes are shared among all instances, is it normal ? References: <27vvht4uslv2ibq2q8ee4tovg86e7qempb@4ax.com> Message-ID: <3b228432.13801064@news.laplaza.org> On Fri, 08 Jun 2001 00:17:46 +0200, Alain TESIO wrote: >Hi, sometimes class attributes added just after >"class ...:" outside a functions interfere among >instances, more precisely mutable objects are >linked to the same object as if it were a static >attribute. > >See the test case below. > >If I delete the line "val=[None]" in class >Y and add "self.val=[None]" in its __init__ >it works as class X. > >Is it a bug or did I miss something ? This is really a FAQ. If you define a "variable" in a class outside of a method, it's a class variable, not an instance variable. It's a little like using Java's "static" keyword: you get one copy, shared among all the instances. Except.... if you go assign to it in a method, you've just created an instance variable of the same name. (If you want to assign to a class variable, you need to qualify the reference: X.val) Play around with the dir() function to see what's happening. The difference in your two cases: class X: val = None def __init__(self): # assign something to self.val and class Y: val = [ None ] def __init__(self): # assign something to self.val[0] Is that in X, you're making a new "val" in the instance. In Y, you're making a new something in the instance, and making self.val[0] reference it, but you're not changing the inherited reference "val". -- mats Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From gherman at darwin.in-berlin.de Wed Jun 27 12:24:21 2001 From: gherman at darwin.in-berlin.de (Dinu Gherman) Date: Wed, 27 Jun 2001 18:24:21 +0200 Subject: PEP 260: simplify xrange() References: <3B398BBE.A2D455C9@darwin.in-berlin.de> <9hclc1$qv5$1@panix2.panix.com> Message-ID: <3B3A08B5.3C142546@darwin.in-berlin.de> Aahz Maruch wrote: > > >PS: BTW, why not *add* something useful and make float > > increments work "as expected" in range/xrange...? > > And how do you expect floating point increments to work? (Have you paid > any attention to the extensive threads on FP over the past few months?) No, I haven't followed the discussion... but you asked about an implementation; I'm using the one below. Dinu def frange(start, end=None, inc=None): "A range function, that does accept float increments..." if end == None: end = start + 0.0 start = 0.0 if inc == None: inc = 1.0 L = [start] while L[-1] + inc < end: L.append(L[-1] + inc) return L From Dave.Haynes at sia-mce.co.uk Thu Jun 28 07:05:58 2001 From: Dave.Haynes at sia-mce.co.uk (Dave Haynes) Date: 28 Jun 2001 04:05:58 -0700 Subject: How to avoid MemoryError on recursion? Message-ID: Hi all, I'm using John Aycock's SPARK ( http://www.csr.uvic.ca/~aycock/python/ ) to process some files. Part of the SPARK semantic checker uses a recursive function to traverse the syntax tree. I've had to increase the recursion limit to 10000 to avoid RuntimeError, and I now get 'MemoryError: Stack overflow'. Is there anything I can do to get Python more allocated memory (or get it to use less)? I'm using Python 2.0 on a Windows NT4 box with 256 Mbyte RAM. Task Manager registers only 26% of this in use while running the script. Anyone more familiar with SPARK than I am might be able to give some tips on how to flatten the AST tree. I'm working from a fixed BNF description, which has plenty of hierarchy in it. Cheers, Dave. From bob at passcal.nmt.edu Fri Jun 8 15:25:22 2001 From: bob at passcal.nmt.edu (Bob Greschke) Date: Fri, 8 Jun 2001 13:25:22 -0600 Subject: Passing back an array from an extension module? References: <9fqqqo$1p3e$1@newshost.nmt.edu> Message-ID: <9fr8mp$219g$1@newshost.nmt.edu> "This" is an array, but it doesn't look like I can either pass an array object to the C extension module, and pass an array back to the Python code, or create an array in C and pass it back to the Python code. I don't see anything in the Format Specifiers lists for PtArg_Parse() or Py_BuildValue() functions to handle arrays. However, I do see C functions (Low-Level Functions on Built-in Types, Python Essential Reference, pg 261) for creating tuples in a C function, and then functions for creating long integers, and then functions for adding items (_SetItem) to a tuple, and then the ability to pass back an 'any object' in Py_BuildValue (the "O" format specifier). Is that a sensible thing to do? It feels like it would chew up too much time given the amount of data involved. "Martin von Loewis" wrote in message news:j4ae3iev04.fsf at informatik.hu-berlin.de... > "Bob Greschke" writes: > > > Then I need to pass that back to the Python side for graphing > > the values. I initially thought I could just create a tuple and pass > > that back, since nothing is going to be done with the values except to > > draw a graph, but there is the possibility of there being 16,000,000 > > data points...that makes for a slightly large statement, doesn't it? > > It doesn't look like I can do this with arrays in stock Python, but it > > does look like I can do it with the NumPy arrays. Is that correct? > > Not sure what 'this' is here. You certainly can create 'custom' array > types in Python, see Modules/arraymodule for an example of an array > type that is implemented using a C memory buffer of primitive C > values. > > I don't know whether you can use a NumPy array off-the-shelf; I assume > no since it probably manages its own memory. > > So you need to create a new type (see xxmodule.c for an example), and > implement its tp_as_sequence slot. > > > Now what about Py_DECREF, INCREF and all of that stuff in these > > situations? I read through a number of posts on dejagoogle that were > > talking about this, but they only confused me more. :-) > > I recommend you read the "Embedding and Extending > tutorial". Basically, you need to implement an array accessor, which > creates and returns a PyInt_FromLong every time you access the nth > element of your array. When the reference counter of your Python > wrapper object drops to zero, you should free(3) the memory of the > very large array. > > Regards, > Martin > From burkhard.kayser at freenet.de Sat Jun 9 12:20:48 2001 From: burkhard.kayser at freenet.de (Burkhard Kayser) Date: Sat, 9 Jun 2001 18:20:48 +0200 Subject: swish-e and pyhton Message-ID: <9ftk5a$b40$05$1@news.t-online.com> Hi, I've just installed swish-e and now I'm looking for pyhton cgi-interface. I've found a lot of perl-interfaces. But unfortunately I've no perl experiences. I'm a web-newbie. I'd like to write my own pyhton interface. Does anybody have an example ? Thanks a lot. From philh at comuno.freeserve.co.uk Fri Jun 29 09:28:58 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 29 Jun 2001 14:28:58 +0100 Subject: PEP scepticism References: <9hfg1n$du33c$1@ID-89274.news.dfncis.de> <3B3BB077.1E51F2C9@ActiveState.com> Message-ID: On Fri, 29 Jun 2001 00:26:14 -0400, Barry A. Warsaw wrote: >The other purpose for PEPs -- IMO more important and often overlooked >-- is to provide a concrete historical record for decisions made about >the language, its implementations, and its environments. Python's >been around a long time, and as Tim is fond of saying, there are >almost no new feature suggestions that haven't been brought up many >times before. Is there a PEP for multi-line comments? Or one for making ``pass'' optional? >I have a nagging feeling that `creeping featurism' is like pork-barrel >politics. In one breath people will decry the special interests that >they don't like or don't care about, while in the next, ask for their >own pet project to be funded. That could be a problem, yes. -- ==== Philip Hunt == philh at comuno.freeserve.co.uk ==== Want to stop global warming? Do you support the Kyoto Treaty? Then boycott Esso (ExxonMobil in the USA). See www.stopesso.com for details. From thinkit8 at lycos.com Tue Jun 12 19:35:42 2001 From: thinkit8 at lycos.com (thinkit) Date: 12 Jun 2001 16:35:42 -0700 Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> <9g5h4c01rba@enews2.newsguy.com> <9g5ink015sb@drn.newsguy.com> <9g64uu0j8j@enews1.newsguy.com> Message-ID: <9g690e0dhr@drn.newsguy.com> ok this is quite off-topic, but i can't resist a reply to this. In article <9g64uu0j8j at enews1.newsguy.com>, "Alex says... > >"thinkit" wrote in message >news:9g5ink015sb at drn.newsguy.com... > ... >> um...? see, this is exactly what i'm talking about. binary is >simple...this is >> not. i don't really care about a bunch of old men who wanted to argue >over the >> number 0. > >Right. You don't care that they INVENTED logic -- the word, >the concept, AND the principles you still revere, of course. nobody INVENTED logic. logic exists outside of time...anybody can come upon it. what of the person on the deserted isle who comes up with the same principles? >> maybe they just got tired of jerking off and decided to spew some >> garbage to sound smart and score more chicks. just my guess. > >Is your knowledge of Classic Greek culture REALLY so poor that >you think they went for *CHICKS*?! > >> and i suggest a look at lojban, a logical language. you can learn it >without > >I see it claims "hundreds of supporters" with a "What's New" >page last updated over a year ago... very impressive success >indeed! > >> referring to a bunch of old dead farts. http://www.lojban.org . > >What an abyss of poor taste you display here. Dr. James Cooke Brown, >the inventor of Loglan (from which the Lojlan project split -- and despite >the acrimony over the years, they do *NOT* deny their debt to him, >nor his genius), died last year, of course. > > >Alex > > > From support at internetdiscovery.com Tue Jun 26 02:13:13 2001 From: support at internetdiscovery.com (Mike Clarkson) Date: Tue, 26 Jun 2001 06:13:13 GMT Subject: Tkinter, Sleep and threads Message-ID: <3b3827f0.1058042@nntp.ix.netcom.com> In _tkinter.c, in Tkapp_MainLoop(): If Python is compiled WITH_THREADs, then it uses a 20 msec. Sleep loop to check signals and do Tcl events. The current problem is threefold: 1) An idle Tkinter application consumes about 5% of the CPU, because it is in a tight 20 msec Sleep loop. The equivalent Tk application uses 0%. 2) Say you establish a ^C signal hanler, then create and use a Tkinter dialog (that uses Tk's vwait, like ColorChooser). If you pop up the dialog, enter the mainloop, and hit ^C, the signal handler will not be called until you finish choosing a color. (I presume all other Python threads will also be forced to wait.) 3) The 20 msec sleep is a hard sleep, so can effect mouse response time, and is a real waste for asynccore users who could use it to poll with a 20 msec timeout. The 'right' way to do this, I think, is to put the PyErr_CheckSignals() in a wrapper and schedule it periodically on the Tcl event queue, and then use Tcl_DoOneEvent(0); to use select in Tk to wait for events. 1) is fixed, 2) is fixed with a max response lag determined by the scheduling, and 3) is cured, but there may be side effects (see below). It turns out that the code to make wrapper and schedule something periodically on the Tcl event queue is already in _tkinter.c - Tkapp_CreateTimerHandler. We could make a procedure (in Python or C), that is inserted into the Tk event queue using Tkapp_CreateTimerHandler. This function could check for signals, and then insert itself again into the event queue in 1000 msec., or whatver granualarity you want for signal checking. Before we do, we could make a small change to the current _tkinter.c TimerHandler(). Let's add a PyErr_CheckSignals check at the beginning - if a signal has been raised, we return NULL from the timer handler, and set a flag so that the mainloop will exit, just as if we detected the signal there. I think this patch makes sense regardless of the other points being discussed, and a patch against 2.1 is attached below. (BTW, what is the difference in Python-C-API between Tkapp_MainLoop returning NULL and returning Py_None? I'm not a C programmer). Now if we do this, we can define our procedure to do nothing except add itself again to the event queue 1000 msec. hence. The change suggested above means that signals are checked even if we do nothing. (Of course you might want to do other things besides nothing, but let's leave that aside for the moment.) With this procedure in place, you could change the Tkapp_MainLoop while() to eliminate the Sleep, and use Tcl_DoOneEvent(0) - et voila 1) 2) 3) are solved. But if we eliminate the Sleep, does that mean that a side effect is no other threads except the Tcl thread gets to run? Is it a side effect of the Sleep (within a Py_BEGIN_ALLOW_THREADS region) that other threads are polled every loop iteration? (If so, I assume Python callbacks from Tk would be effected.) If so, can anyone think of a hybrid approach that uses TimerHandler to allow other threads to run, as well as check for signals? Many thanks, Mike. ------------------------------------------------------------------------------- *** _tkinter.c.dst Thu Apr 19 14:30:22 2001 --- _tkinter.c Fri Jun 22 20:27:42 2001 *************** *** 220,225 **** --- 220,226 ---- static PyObject *Tkinter_TclError; static int quitMainLoop = 0; + static int bailMainLoop = 0; static int errorInCmd = 0; static PyObject *excInCmd; static PyObject *valInCmd; *************** *** 1615,1620 **** --- 1616,1626 ---- PyObject *func = v->func; PyObject *res; + /* mike: bail out if there is a raised signal or a quit request */ + if (quitMainLoop > 0 || PyErr_CheckSignals() != 0) { + bailMainLoop = 1; + return; + } if (func == NULL) return; *************** *** 1672,1677 **** --- 1678,1684 ---- return NULL; quitMainLoop = 0; + bailMainLoop = 0; while (Tk_GetNumMainWindows() > threshold && !quitMainLoop && !errorInCmd) *************** *** 1692,1698 **** result = Tcl_DoOneEvent(0); #endif ! if (PyErr_CheckSignals() != 0) return NULL; if (result < 0) break; --- 1699,1705 ---- result = Tcl_DoOneEvent(0); #endif ! if (PyErr_CheckSignals() != 0 || bailMainLoop > 0) return NULL; if (result < 0) break; From nospam at nospam.de Mon Jun 11 14:53:54 2001 From: nospam at nospam.de (Uwe Hoffmann) Date: Mon, 11 Jun 2001 20:53:54 +0200 Subject: [wxPython] layout manager? References: <3B24ADE9.99D61FEE@senux.com.NOSPAM> Message-ID: <3B2513C2.CC3A79DE@nospam.de> Brian Lee wrote: > Is there any examples of controlling window layout in wxPython? I > read some docs on http://wxpython.org/ but I don't understand it. install wxPython; execute the very nice example "demo.py" in the directory wxPython/demo . ( you can separately download the version 2.3 demo at http://prdownloads.sourceforge.net/wxpython/wxPython-demo-2.3.0.tar.gz ) in the left tree choose "Window Layout" which shows two or three layout mechanism. there is a wxPython specific maillist at http://wxpython.org/maillist.php regards uwe From alan.gauld at bt.com Wed Jun 20 07:40:14 2001 From: alan.gauld at bt.com (Alan Gauld) Date: Wed, 20 Jun 2001 12:40:14 +0100 Subject: Teaching Pyhton on Wintel References: <1ev6xe3.15eskd91k2u1eaN%p.agapow@ic.ac.uk> Message-ID: <3B308B9E.B843C4F0@bt.com> Paul-Michael Agapow wrote: > Call me misguided, but I've decided to teach an introduction to > programming class using Python. You may like to join the edu-sig mailing list whicxh is inhabited by those teaching python in one form or another... Alan g. From res04o20 at gte.net Mon Jun 18 08:16:29 2001 From: res04o20 at gte.net (Dave Wald) Date: Mon, 18 Jun 2001 12:16:29 GMT Subject: Event-driven... Excellent info! Thanks References: <3B2B60AD.942719AE@earthlink.net> <9gkb4s01vql@enews2.newsguy.com> Message-ID: Precisely what I needed! Thanks Paul and Alex. These explanations will help me tremendously. I'll probably have VS.Net crammed down my throat at some point, like it or not, if experience is any guide. But it's great to have the facts. Regards, Dave "Alex Martelli" wrote in message news:9gkb4s01vql at enews2.newsguy.com... > "bradclark1" wrote in message > news:ePZ#Y669AHA.266 at cpmsnbbsa07... > ... > > Am I missing something here? From what I read at the above it says for > .net. > > I didn't see anything else about it? > > *sigh* once again, trust Microsoft's marketing to make an unholy > mess of things. Microsoft .NET is a specific platform architecture > with an intermediate-language (MSIL), a common runtime library, &c. > > So "of course" MS's marketing immediately went and stuck a ".NET" > affix to the next releases of a slew of Microsoft products that do > *NOT* require or mandate this new platform architecture (though > they may to some degree support it -- but not necessarily), such > as the new releases of many "Microsoft Backoffice" servers, and > the new release of Microsoft Visual Studio (it's not going to be > VS7, as it's coming after VS6 -- it's going to be VS.NET...). > > Activestate's Visual Python supports and relies on Microsoft > Visual Studio 7, and unfortunately the latter *IS* named > "Microsoft Visual Studio .NET". Activestate's Visual Python > does ***NOT*** require you to install Microsoft's .NET *PLATFORM* > nor to develop for it -- because "VS.NET" doesn't. The naming > of "VS.NET" is basically just the usual geniuses in MS's mktg > at work -- like back when they managed to muddy the waters > enough between COM and Active/X (two related technologies with > *BIG* differences -- COM being the platform upon which you > might OR MIGHT NOT choose to further deploy/support ActiveX) as > to set widespread adoption of COM back...:-(. > > The overall technical picture and the strategical prospects > are complicated enough that the last thing the industry needs > is brilliant marketeers throwing spanners in the work by > creative naming. To be honest, although MS's mktg does have > this "endearing" habit, they're far from alone -- one of the > worst examples of this creative naming was Netscape's renaming > of livescript to "Javascript", which is ***STILL TODAY*** a > source of confusion for Dynamic HTML students who believe they > may have to study some Java to control their webpages because > it "sounds" like Javascript has something to do with Java (it > doesn't, besides the thinnest syntax-sugar similarity, but...). > > > Alex > > > From grakker at softhome.net Sun Jun 24 23:57:22 2001 From: grakker at softhome.net (grakker) Date: 24 Jun 2001 20:57:22 -0700 Subject: gadfly cgi update References: <56817b75.0106241223.4cdf544a@posting.google.com> Message-ID: <56817b75.0106241957.8a01771@posting.google.com> OK. I looked in the FAQ and checked my apache error logs. Seems that even though everyone has access to the file, it still has to be in the www directory. So anway, disregard this message. grakker at softhome.net (grakker) wrote in message news:<56817b75.0106241223.4cdf544a at posting.google.com>... > I'm trying out my first python program this weekend. I have a > calendar, which when you click on the day, it opens a window which > lets you edit information about that day. The submit calls a script > which should update the database. But it doesn't. It just stops at > the line. Here is the code in question (place here the customary > appologies for ugly code): > > print form_custody_value, > print form_month_value, > print form_day_value, > print form_year_value > print "'%s'" % form_custody_value > print "'%s'" % form_notes_value > > db_update = "\"update custody set cstdy='%s', notes='%s' where \ > mnthdt=%d and dydt=%d and yrdt=%d\"" % (form_custody_value, \ > form_notes_value, form_month_value, form_day_value, \ > form_year_value) > print db_update > db.execute(db_update) > > print "updated" > > > I have all the print statements in there so that I could see what was > going on. Here is the output: > > custody=Lang > Lang 7 8 2001 > 'Lang' > 'Birthday' > "update custody set cstdy='Lang', notes='Birthday' where mnthdt=7 and > dydt=8 and yrdt=2001" > > > This works from the python command line, and very similiar select > statements work on my other pages. Any help would be appreciated. > > -Lang > > BTW Python is pretty sweet if I'm able to get as close as I have in > one weekend of coding... From chrishbarker at home.net Fri Jun 8 18:03:59 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 08 Jun 2001 15:03:59 -0700 Subject: Passing back an array from an extension module? References: <9fqqqo$1p3e$1@newshost.nmt.edu> <9fr8mp$219g$1@newshost.nmt.edu> <9frdtl$25gh$1@newshost.nmt.edu> Message-ID: <3B214BCF.8393A2AC@home.net> Bob Greschke wrote: > Hmmm...I was wrong. Creating a tuple object, then creating long > objects and adding them to the tuple 1,600,000 times doesn't take very > long. On > the order of about 5 seconds (on a Sun Ultra10). It would probably be a whole lot faster with a NumPy Array, and a lot cleaner, you don't have to create long objects, just make a NumPy array with your C array directly. But 5 seconds is probably a lot faster than it takes to read from disk anyway. > Well, I'm not actually going to be doing any math on the values in the > array, not in an array-wide sense anyway. NumPy arrays are pretty handy for other things as well, they are mutable, memory efficient, have more available types, etc. > But it takes it > about 10 seconds if I do the same thing a 2nd, 3rd, 4th, etc. time. > Is it leaking memory, Check your memory use. With tuples of this size, you should notice real quick! Have you freed up the C array the you allocate? > or is it just taking that long to garbage > collect the old tuple? There is a lot of more disk activity on the > sebsequent runs than there is the first time through. Swapping? this would be explained by the memory leak option. Maybe the first file was in the disk cache already. I'm still curious whether you could do the whole thing in NumPy, and forget all this C stuff altogether. Once you are using NumPy, you really don't need to write C very often at all. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From sussman at collab.net Tue Jun 19 13:05:14 2001 From: sussman at collab.net (Ben Collins-Sussman) Date: Tue, 19 Jun 2001 12:05:14 -0500 Subject: graceful version detection? References: <3B2D2F44.50007@red-bean.com> Message-ID: <3B2F864A.9000306@collab.net> Paul Prescod wrote: > try: > import main > except SyntaxError: > print "This program requires Python 2.0" Thanks, I'll try this solution. Now I just need to hunt down a 1.5 interpreter... From gustafl at algonet.se Mon Jun 11 19:16:24 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 11 Jun 2001 23:16:24 GMT Subject: PEP 259: Omit printing newline after newline References: Message-ID: Guido van Rossum wrote: > I propose to skip printing the newline when it follows a newline > that came from data. I like consistency, so I think either 'print' should add a newline, or it shouldn't. Whatever you choose, it shouldn't do things "behind the scenes". If it depends on the line before, it won't be so self-explanatory if you see a 'print' statement with no arguments. If you make rstrip() a built-in function, you get something like chomp() in Perl. :-) Regards, Gustaf Liljegren From News at Titanic.co.uk Sat Jun 2 10:40:57 2001 From: News at Titanic.co.uk (Simon Faulkner) Date: Sat, 02 Jun 2001 15:40:57 +0100 Subject: Syslog Message-ID: <2brhhtgvab8huis4avjhbc48912059nc8f@4ax.com> I have a firewall that sends a ling to syslog on my Linux box every 5 mins with the number of bytes transferred in that time: Jun 2 14:52:37 192.168.146.100 NameOfFirewall: Stats filter 12: 1363 (All out) I want to srtip this number out every 5 mins so I can feed it to MRTG. Any sugestions about the best way to achieve this? Simon Simon Faulkner From jeremy at alum.mit.edu Wed Jun 20 18:46:56 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Wed, 20 Jun 2001 18:46:56 -0400 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) In-Reply-To: <200106201855.OAA21119@panix3.panix.com> Message-ID: [Aahz writes:] > In article , > Paul Prescod wrote: > > > >We're discussing this issue on python-iterators. I think everyone > >interested should head over there. I'd really like to discuss this but > >I'm trying to follow the rules! > > While there's some logic here, it's not exactly convenient to subscribe > to every mailing list under the sun each time a "critical" issue comes > up. While I overall think Tim is right in removing python-dev from the > list of venues for discussing PEP 255, I think that trying to place > comp.lang.python (aka python-list) off-limits is a Bad Idea. I don't understand the reasoning here. I can see good reasons for arguing either way about each of python-list and python-dev, assuming that it makes sense to spin off specialized lists for each new topic. It makes the most sense to me to include python-dev, because it's the advice-to-Guido-list and because most or all of the core developers subscribe to it. It seems that list is the most obvious place to discuss changes to the core language -- and it really irks me that conversations about the core are artificially move elsewhere. (Counterexample: Maybe we could take all the Unicode stuff and ban it from python-dev <0.9 wink>.) What if PEP NNN concerned issues intimately related to the compile.c and the person most familiar with compile.c was not subscribed to the list for that PEP? We could end up missing valuable input from the people most qualified to comment. If the discussion occurs on python-dev, then it's much harder to miss useful input. > I suggest that if PEP authors really wish to move discussion to separate > mailing lists that the PEP guidelines should be modified to encourage > inclusion of instructions for subscribing to the mailing list(s). My problem isn't with learning how to subscribe to a new list; it's managing the accounts for the dozens of lists I have to subscribe to and read just to keep track of Python development. If I happen to be on vacation (or, say, paternity leave) when a new list is created, I may end up missing more of the discussion because I didn't subscribe in time. Jeremy From noone at nowhere.net Sat Jun 30 16:58:31 2001 From: noone at nowhere.net (lynx) Date: Sat, 30 Jun 2001 16:58:31 -0400 Subject: Q: newbie wants to eval() Message-ID: <3b3e3e81$0$88189$2c3e98f8@news.voyager.net> i want to iterate over a list of variable names, comparing each in turn to a regexp match part, and if the comparison is equal, set the value of the variable to the value given in another part of the same regexp match; which seems most obviously done with eval(). i.e., i want to parse a configuration file of the rough form variable_name = variable_value, and i want to make sure the variable being set is on a list of variables i'm willing to allow setting, so i don't want to just eval() the whole line - hence the list iteration. trouble is, i've never used eval() for anything before, and i can't seem to get the syntax right. given a loop iterator variable i, which iterates over a list of variable names, and a regexp match variable m, which can be assumed to hold the value i'd like to assign to the named variable, what should the eval expression look like, and why - how would the bits and pieces of the complete, correct expression work together? i ask because none of my current efforts work at all, and i can't figure out why. one little additional twist is that the variables i'm trying to set are globals, defined outside the configuration-file-reading-function itself. does this change some argument to the eval(), and if so, how? -- PGP/GnuPG key (ID 1024D/BFE0D6D0) available from keyservers everywhere Key fingerprint = 3EBC 97FC 68AA 65F1 65E6 3D36 35F6 4213 BFE0 D6D0 "...life goes on long after the thrill of living is gone..." From kawakami at lead.dion.ne.jp Mon Jun 18 02:55:03 2001 From: kawakami at lead.dion.ne.jp (Toshiya Kawakami) Date: Mon, 18 Jun 2001 15:55:03 +0900 Subject: get class instance from C++ extension? References: <8kiW6.41$%3.2442@news3.dion.ne.jp> Message-ID: "Martin von Loewis" wrote in message news:j48zisi8m9.fsf at informatik.hu-berlin.de... > First of all, you should stop using Py_BuildValue in cases like this; > this example would better use PyInt_FromLong. > > In general, you do Python things in C the same way as in Python. To > create an instance of c1, you need to *call* c1. So your code should > read > > c1 = ... // lookup c1 > x = PyObject_CallFunction(c1, "()"); Thank you for replying. I read the spec of PyObject_CallFunction() in "Python/C API Reference Manual", but cannot understand how to use it. Is there any simple example for PyObject_CallFunction()? From JamesL at Lugoj.Com Wed Jun 13 11:38:40 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Wed, 13 Jun 2001 08:38:40 -0700 Subject: VI References: Message-ID: <3B278900.5828FB59@Lugoj.Com> Pilgrim wrote: > > Can someone tell me what "vi" is for a text editor to work with python? > Where can I get this? "vi" is the first and last word in visual editors. Every editor written before or after it are irrelevant. ;-) From bsass at freenet.edmonton.ab.ca Thu Jun 28 18:54:18 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Thu, 28 Jun 2001 16:54:18 -0600 (MDT) Subject: Augmented Assignement (was: Re: PEP scepticism) In-Reply-To: Message-ID: On Fri, 29 Jun 2001, Carsten Geckeler wrote: > On Thu, 28 Jun 2001, Bruce Sass wrote: <...> > > >>> a = [1,2] > > >>> a > > [1, 2] > > >>> id(a) > > 135320620 > > >>> a += [3,4] > > >>> id(a) > > 135320620 > > For list the following two statements are NOT the same: > a += [1, 2] > a = a + [1, 2] This wasn't even on my radar; a path to explaining how adding something to an immutable object works, and why there would be a discrepancy between += with tuples and list because of it, was though. <...> > Of course, this is (more or less) explained in the reference (and > probably somewhere else, too), but it is somehow confusing that > a += [3, 4] > is more like > a.extend([3, 4]) > than > a = a + [3, 4] heh. I always think this last one should give me [1, 2, [3, 4]] This confuses me... >>> a [1, 2] >>> a = a + (3, 4) Traceback (most recent call last): File "", line 1, in ? TypeError: can only concatenate list (not "tuple") to list >>> a += (3, 4) >>> a [1, 2, 3, 4] <...> > As mentioned above, for tuples the "+=" is completely natural, but not for > lists. Lists do seem to be a little (uhm) quirky at times. - Bruce From robin at jessikat.fsnet.co.uk Fri Jun 8 12:43:32 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 8 Jun 2001 17:43:32 +0100 Subject: More fun with Derivatives of Matrices References: Message-ID: In article , PoulsenL at capecon.com writes > > I have a very complex function for which I would like to take the > first derivative.? The problem is that involves the inverse of a > Matrix. > > DerivVar chokes on Numpy's inverse because it is not implemented in > Python.? Upon some advice from Konrad Hinsen I retrieved the > matfunc.py module with high hopes.? Unfortunately, these hopes were > soon dashed due to the absence of the __float__ attribute in the > DerivVar object. > > ? > > Any advice would be greatly appreciated. > > ? > > C = matfunc.makeMat([[DerivVar(1.0,0),2],[3,5]]) > > >>> C.mmul(C.inverse()) > > Traceback (most recent call last): > > ? File "", line 1, in ? > > ? File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py > ", line 183, in inverse > > ??? return self.solve( eye(self.rows) ) > > ? File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py > ", line 143, in solve > > ??? if isinstance(b,Mat): return makeMat( map(self.solve, b.tr()) ). > tr() > > ? File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py > ", line 145, in solve > > ??? x = self._solve( b ) > > ? File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py > ", line 139, in _solve > > ??? Q, R = self.qr() > > ? File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py > ", line 127, in qr > > ??? v, beta = R.tr()[i].house(i) > > ? File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py > ", line 81, in house > > ??? v = Vec( Elementwise([0]*index).concat(self[index:]) > ).normalize() > > ? File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py > ", line 72, in normalize > > ??? def normalize( self ):? return self / self.norm() > > ? File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py > ", line 71, in norm > > ??? def norm( self ):? return math.sqrt(abs( self.dot(self.conjugate > ()) )) > > AttributeError: DerivVar instance has no attribute '__float__' > > >>> > > ? > > Loren Poulsen if your matrix is really just [ x 2 ] [ 3 5 ] then the differential is - [5 -2] [ 1 0] [5 -2] [-3 x] [ 0 0] [-3 x] --------- (5x-6)**2 but I already said that you need the numerical -inv(A)*dA/dx*inv(A), but if you want to do the numeric differentiation like ADIFOR http://www-unix.mcs.anl.gov/autodiff/ADIFOR/ you'll need to ensure that all operations are carried out using the DerivVars properly and that's almost certainly not the case for Numeric's inverses. -- Robin Becker From db3l at fitlinxx.com Wed Jun 6 20:17:22 2001 From: db3l at fitlinxx.com (David Bolen) Date: 06 Jun 2001 20:17:22 -0400 Subject: McMillan Installer 4 error ImportError: No module named posixpath References: <3b1ea684$1_4@127.0.0.1> Message-ID: "Brad Clements" writes: > I have a very simple python 1.5.2 script on w2k that I want to distribute. > > I've tried beta 4 of the installer to create either a standalone or simple > distribution, but when I run it (either one), I get the same error. Trace > attached below. > > I tried explicitely importing posixpath, but that doesn't matter. tried with > and without the -win32 option. I believe the default configuration files built by the installer top level scripts (like standalone) automatically exclude some path modules (including posixpath) as part of constructing the archive (the APPZLIB clause in the default setup). I think that's similar to why pywintypes/win32api is always excluded - there's a reference to them in the standard libraries but it's on a conditional path, so you'd always get them even when not needed. In this case, it sounds like you do actually need it, so try removing posixpath from the excludes line once you've built your config file. Also, in cases like this, builder.log is your friend, since it'll show the sequence of identifying the need for posixpath, and then excluding it if instructed to do so from the config. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From hanche at math.ntnu.no Sun Jun 3 11:50:14 2001 From: hanche at math.ntnu.no (Harald Hanche-Olsen) Date: 03 Jun 2001 17:50:14 +0200 Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> Message-ID: + Tim Churches : | No experience (I am in a similar situation to you wrt UML), just | some advice: don't buy the O'Reilly book 'UML in a Nutshell' - it is | the only O'Reilly title I have encountered which is truly woeful | (most are quite good). Hmm. Has it occured to you that this might be a reflection on UML rather than on the book per se? no-I-have-no-UML-experience-either-and-haven't-read-the-book-ly y'rs, -- * Harald Hanche-Olsen - Yes it works in practice - but does it work in theory? From robin at stop.spam.alldunn.com Fri Jun 15 12:47:20 2001 From: robin at stop.spam.alldunn.com (Robin Dunn) Date: Fri, 15 Jun 2001 16:47:20 GMT Subject: bsddb: must bsddb write a file ? References: <3B28D465.229D7BF7@netlcr.de> Message-ID: "Florian Scholz" wrote in message news:3B28D465.229D7BF7 at netlcr.de... > hi again.. > > the bsddb: class (binary tree, hash-table,..) > needs to write its data to a file: > db = bsddb.btopen('filename','c'); > > the file can be removed, but is there a way to avoid the file ? > I havn't tried it but the newer versions of Berkeley DB can do in memory databases. Go to http://pybsddb.sourceforge.net/ to get the Python wrappers, and check the docs for the DB.open method. """ In-memory databases never intended to be shared or preserved on disk may be created by setting both the fileName and dbName arguments to None. """ -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! From DavidLNoSpamm at raqia.com Thu Jun 28 20:27:21 2001 From: DavidLNoSpamm at raqia.com (David Lees) Date: Thu, 28 Jun 2001 20:27:21 -0400 Subject: Does mxTextTools work in Python 2.1? Message-ID: <3B3BCB69.C71F77C7@raqia.com> Subject line asks the question: Does mxTextTools work in Python 2.1 or do I need to reinstall 2.0 to have it work? David Lees From cer at tutopia.com Tue Jun 5 23:11:47 2001 From: cer at tutopia.com (Cristian Echeverria) Date: Tue, 5 Jun 2001 23:11:47 -0400 Subject: 2 language applications Message-ID: <9fk6ll$4ln39$1@ID-44371.news.dfncis.de> Hi I have a gui application with all the messages in spanish, now I want to include an option that allow the user to choose the language. Wich is the right way to do things like this? Any suggestion that can help me? (I'am using Python2.0 and wxPython 2.3 on win9X) From phd at phd.fep.ru Thu Jun 28 05:59:50 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Thu, 28 Jun 2001 13:59:50 +0400 (MSD) Subject: AW: How to grab HTML files behind authentification In-Reply-To: <704219C33D36D5119319000102053E500A8F76@marvin.bitlab.de> Message-ID: On Thu, 28 Jun 2001, DirkK wrote: > To be honest, I didn't try this (though it's obvious). But on the other > hand, the other approach is a bit more transparent, because you control the Sure. > header yourself. Do you have another easy solution for cookies (this would > have been the next thing I need)? No. Currently neither urllib, nor urllib2 nor httplib support cookies. They do not prevent you to get/set cookie (module Cookie.py, you know), but that's all. IWBN if you develop a generic approach to the problem and implement it as a patch for httplib and/or urllib or orllib2 - and then apply the patch to the SourceForge patch manager. If the patch will be accepted by managers all of will benefit! Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From ed_tsang at yahoo.com Mon Jun 25 12:25:06 2001 From: ed_tsang at yahoo.com (ed_tsang at yahoo.com) Date: Mon, 25 Jun 2001 16:25:06 -0000 Subject: trying using Python to remotely control another Python App Message-ID: <9h7ol2+f5sh@eGroups.com> Hi, I am windering if anyone know or tried using Python to remotely display and/or control another Python App? how to do that? Current situation: I am a Python App which has a GUI interface to user that displayand allow user to control the next action to be performed. But whenever this app need support, the supporting people need to go to the client office and do it there? It will be nice if we can view what is displayed on the client screen and control the app remotely. Do we need to add this funcitonality to transmitt the state of the whole App? The app is running on Sun solaris, and we do not have sys admin control on their side. Any ideas? From just at letterror.com Fri Jun 29 02:45:18 2001 From: just at letterror.com (Just van Rossum) Date: Fri, 29 Jun 2001 08:45:18 +0200 Subject: PEP 255: Simple Generators References: Message-ID: <3B3C23FD.31BDA6B8@letterror.com> Glyph Lefkowitz wrote: > My point is that 'yield' is a keyword, and that new keywords are bad. > Although there has been a Pronouncement on this :) I still disagree with > it; it would not require a keyword addition if creating a generator were > something like > > import generator > > def _genfunc(): > for i in range(100): > generator.yield(i) > > gen = generator.create(_genfunc) > > But again, given that there's been a pronouncement, this is just > rearranging the deck chairs on the titanic, so I'll be quiet now :). Originally I agreed completely with you, even before the PEP: I wrote a co-routine module for stackless that had a very similar interface. Why introduce a new keyword what you can do with calling syntax? (In my view, generators were (or actually, in a way still are) just a specific *usage* of co-routines.) But. When I first saw an example usage of Neils generators I very quickly changed my mind: the fact that yield is a keyword makes it possible to make generator instantiation implicit, making generators much more convenient and natural to use. Imagine that everywhere you can now write for x in g(): ... you'd have to write for x in generator.create(g): ... That's a whole lot of unneeded cruft... > but-I-still-can't-entirely-forgive-guido-for-print>>-and-lambda-ly y'rs, Oh, when he added lambda he was still young, so that's easy to forgive , but I agree with you regarding print>>: there's no Python feature I hate more... Just From paulp at ActiveState.com Wed Jun 20 13:17:47 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Wed, 20 Jun 2001 10:17:47 -0700 Subject: PEP 255: Simple Generators References: <3B303FE5.735A5FDC@cosc.canterbury.ac.nz> <90C65699Dgmcmhypernetcom@199.171.54.194> Message-ID: <3B30DABB.CF6EF3DD@ActiveState.com> Gordon McMillan wrote: > >... > > Now if a casual reader happens upon the definition > of f, misses the "yield" and comes away with the > impression that f is an "ordinary" function, I say > "So what?". Monte Carlo sampling is no way to > understand code. We're discussing this issue on python-iterators. I think everyone interested should head over there. I'd really like to discuss this but I'm trying to follow the rules! -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From bos at hack.org Thu Jun 14 22:27:50 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Fri, 15 Jun 2001 04:27:50 +0200 Subject: bsddb: must bsddb write a file ? References: <3B28D465.229D7BF7@netlcr.de> Message-ID: <3B2972A6.7F55D425@hack.org> > the bsddb: class (binary tree, hash-table,..) > needs to write its data to a file: > db = bsddb.btopen('filename','c'); Thanks for bringing this topic. Question: shelve.open("some_file") creates that file if it doesnt exist. I want to check IF the file exist, but this is troublesome since I dont know what db the shelve uses (thus I dont know what file extension). How can this be accomplished? -- Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From ejr at cs.berkeley.edu Fri Jun 8 13:00:47 2001 From: ejr at cs.berkeley.edu (Edward Jason Riedy) Date: Fri, 8 Jun 2001 17:00:47 +0000 (UTC) Subject: floating point in 2.0 References: Message-ID: <9fr0bv$la5$1@agate.berkeley.edu> And Tim Peters writes: - - Ack -- if you folks haven't learned anything else from the 16 - years of half-baked 754 support so far, believe me when I tell you - that when it comes to f.p., most vendors see "strongly recommended" - and think "OK, we can skip this one -- next.". Hell, they do that if it's required. One of the good-and-bad points of 754 is that it's a _system_ standard. It's good in that it can't be undercut by some portion of the system. It's bad because each part simply points to the other parts for compliance. For example, 754 requires single precision if double precision is supported, but a certain relevant language doesn't provide it. (Well, ok, you can use Numpy with a one-element array.) - Make it required or don't bother -- really. We also have to consider how we're getting this through the IEEE process. If we come out and say C99 ain't 754 (it mandates 6 digit output by default), well, I think some people will be upset. - Vendors don't compete on mere "quality of implementation" f.p issues - because their customers overwhelmingly can't tell the difference so - don't care. That's not entirely true. Consider IBM. They added fused multipy-accumulate (being added to 754) and a ton of diagnostics that are not required. It wasn't just out of the goodness of their hearts. Similarly, Sun has a host of easy-to-use exception handling libraries. So far, I'm the only confirmed user outside Sun. The libraries aren't going away because the internal support folks use them to diagnose client problems. - That's why you have near-universal support for denorms and directed - rounding modes today, [...] Denorms, yes, but who supports directed rounding modes? Currently only C99 is the only major language to give reasonable (arguable) access to them. System standard, not hardware standard. Oh, and actually, _no one_ supports denorms as intended. There's a clause (don't have it handy) that can be read a few different ways. The author intended one reading, but all implementors took another. ;) And it looks like there's actually a bug in one reading where you can have an inexact answer without an inexact flag. I seem to have lost my notes on it, which is rather upsetting. Denorms will see some simplification as a result of all this; we're not sure what yet. - but virtually nothing that makes intended ("recommended") use of the - NaN bits for retrospection, and see most vendors punt on implementing - ("recommended") double-extended. We're arguing about the NaN bits. I think we've decided that operations should return the input NaN with the least significand, but it will only be a serious recommendation this time. We know perfectly well that people will ignore it; we've been told point- blank. There is some verbal support from within Sun, though. This is only useful when combined with some trap-handling options. They're up for argument in a few meetings, but everyone should be happy with the proposal. - Even if I ask for, e.g., a %.55g format? No. ``By default'' would apply in the %g case. When a user specifies something specific, the user gets something specific. - but they did this work in the context of the then-pending Scheme - standard. Don't taint the work by its purpose. ;) Scheme has severely borken numeric support. (No, really, arbitrarily long integers are _not_ a subtype of fixed floating-point precisions.) - After their paper appeared, IIRC it got a chilly reception - on David Hough's numeric-interest mailing list, because it's not - "properly rounded" in a clearly explainable sense. Hmm. I recall people brought this up towards the end of the last meeting. Most people there were interested in having a default format that ensures different numbers are printed differently and the same numbers are printed the same way. Dealing with truncated outputs is still on the table, I think. - "Worth it" surely depends on the goal. The knock against Steele & - White's version of this is sloth, not complication; David Gay's - faster version can be fairly characterized as (very) complicated, - though. True. I tend to assume Gay's version. - Provided that the source and destination formats have the same precision, - and assuming correctly-rounded decimal->binary conversion too. All decimal->binary conversions are correctly rounded. That's a new requirement, but the language is still in progress. Binary to decimal is constrained so that binary -> decimal -> binary produces the same number if both binary numbers are in the same precision. Dealing with NaNs and infinities is the real problem. I want to avoid specifying a textual representation to avoid the character encoding mess. We'll see. - Very good advice indeed. What if they're accumulating in double instead? Then use quad. ;) It's being added. The point is that languages should use lower precision by default for stored values and a common higher precision for intermediate values. The ``rules of thumb'' proposed by a certain numerical analyst aren't perfect for all cases, but they help the majority of computations. They can be summarized as: * Store known data narrowly, * compute intermediates widely, and * derive properties widely from known data. See the end of http://www.cs.berkeley.edu/~wkahan/MktgMath.pdf for more verbosity. There are quite a few subtleties in these rules; I'm trying to make them a bit more explicit. Plus, I'm trying to figure out how languages can best support them. Offering more than one precision is a must. And then using a widest-feasible evaluation strategy (widest-need with a lower bound on precision) would help maintain expectations. It also helps with dispatching and dealing with decimal literals. - Without reliable access to double-extended, I'm afraid we're left with - obscure transformations. Um, I think you mean ``[w]ithout reliable access to single''. ;) Python's default really should be single precision with at least double precision for all intermediates. With that and Steele / White / Gay's output for default, I bet there would be far fewer fp questions. Many things would just work. (I think I posted a more reliable summation in Python a while back, too. Anyone looking for good summation algorithms should head to Higham's paper on the subject: http://citeseer.nj.nec.com/higham93accuracy.html ) A widest-feasible evaluation scheme could get rid of the whole right-method v. left-method v. coerce nonsense, too, but at the cost of changing the code generation and interface considerably. It generalizes to intervals cleanly, but arrays take a bit more thought. Jason -- From aleaxit at yahoo.com Sun Jun 10 03:33:25 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 10 Jun 2001 09:33:25 +0200 Subject: New guy question References: Message-ID: <9fv7qp018v1@enews2.newsguy.com> "Nick Perkins" wrote in message news:YTDU6.180907$eK2.41575168 at news4.rdc1.on.home.com... > > ..of course you can also run your program from the >>> prompt: > ( in addition to Alex's suggestion: >>>execfile('alook.py') ) > > >>> import alook > > ..will effectively 'run' your program. > ( actually it loads it into the current namespace, -- more or less the same > thing) > ( note that you leave of the .py extension ) > The file alook.py must be on the sys.path -- another issue ) Also, if code in alook.py has a test such as: if __name__=='__main__': ... it will work differently under import as opposed to execfile (or being run at a shell prompt). This is very handy, and highly idiomatic in Python, too -- it lets you define an alook.py that defines functions, classes &c which other modules can use, AND also may be run as a stand-alone 'program' (but not with import:-). Alex From rnd at onego.ru Sun Jun 10 13:55:17 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 10 Jun 2001 21:55:17 +0400 (MSD) Subject: Global in multiple files In-Reply-To: Message-ID: On 10 Jun 2001, Artur Skura wrote: >>Why do you need global variable in the OOP design anyway? > >I knew you would say that! ;) Yes, of course. Because in True Object Design there is no place for anything global. You have to make some class instance of which will manage userlist. >The source code is at http://arturs.iidea.pl/server.py >and you can get 'live demo' by >$ telnet arturs.iidea.pl 2211 >It's based on simple chat code. > >I just want to keep this one little global, userlist, in order >not to do some strange acrobatics later. It's clean, simple, >keeps the number of arguments to pass to ther functions small etc. After seven years of trial and error I could say that I begin to understand OOP ;-) I thought that way about arguments too. It only says that your object design is not done right way. (It usually happens when it's first try anyway). >>I blame myself each time I maintain code with global variables: >>the code can't be easily reconfigured, creates other problems. >>Globals are allright only in short scripts which has no chance >>to grow larger. > >In this case it fits perfectly. I need to acces userlist from any place, >any moment. Maybe some object could be used to represent the functionality with a proper method. For example, AuthoriseUser(). It's a singleton in your situation. But if later you decide to have more userlists, you could add it to authorisation chain. >OK, suppose I want to do away with global userlist. >I want to pass it to TS_Command instance. Will it work? No. Why? You still think in terms of structural design. Even modular design already has some precautions against globals. Objects are here to completely eliminate the problem. >I have no idea... You see, I don't want to stick fanatically to my >global, any solution is fine, provided that I can split my code >and see it working as before, when it was all in one file. >This 'userlist' is my last obstacle. It's not. It's just first iteration of object analysis/design/programming you did. (In fact, your classes has hard-coded many things. Probably you will want to change this in the future.) It's real fun to return to the same design after some time and look at it critically. Thus, I do not critisize you here. I am trying to express what I myself felt when I tried to reimplement something with objects. At first try you have objects wrong. (This is seen from the amount of cross-usages). It's a painful process which decreeses quality of the code at first. But then it starts to pay off. Bad object design is worse than bad structural one, someone said, but good OD is better than good structural. Try to rethink your design. Maybe your code will have other classes than you have now, and will be less lines. >Regards, >Artur Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, June 10, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Computers make very fast, very accurate mistakes." _/ From agriff at tin.it Wed Jun 6 01:52:55 2001 From: agriff at tin.it (Andrea Griffini) Date: Wed, 06 Jun 2001 05:52:55 GMT Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3b1cdf94.55bd@bolder.com.co.za> <9fiqno016ig@enews1.newsguy.com> Message-ID: <3b1dc155.818208@news.interbusiness.it> On Tue, 5 Jun 2001 16:35:35 +0200, "Alex Martelli" wrote: >Windows/NT didn't -- it's a completely different system, and its >chief architect was the same guy who had chief-architected VMS for >DEC. In fact I find in it many of the things I disliked in VMS, >although at least it's simpler:-). But, like VMS (and Unix of >all sorts, and the IBM OS's, ...), it IS a real operating system. I don't know about the system internals... those may be OK; but from some level UP even Windows NT seems to me to some degree thought to be surely multiprocess but not multiuser (at least not with the same meaning as with unix). I remember for example the funky case of a WEB server (an NT service running in background) that istantly changed the locale used to format and read dates/numbers in ASP scripting just because a user with a different locale logged in (!!!!). Even the missing of a user home directory is quite shining; not to mention that until last releases there was no support for having several users interactively connected to the system. So may be that internally NT was built with the right low-level mindset for getting a secure multiuser system... (nothing near DOS and Win9x/ME) but surely it didn't grow up that way. Also in NT its extremely simple to make the system crawl and die if you get to execute "malicious" code even with simple user privileges. Sometimes just executing unintentionally bad written code. I know many ISPs that use *x that will allow customers to compile and run their C/C++ programs on the system... but no one using that policy with NT. Andrea -- Andrea Griffini, Programmer http://www.netservers.com/~agriff From bobnotbob at byu.edu Mon Jun 11 12:33:29 2001 From: bobnotbob at byu.edu (Bob Roberts) Date: 11 Jun 2001 09:33:29 -0700 Subject: pygimp on windows Message-ID: Well, it has been a while since anybody appears to have asked this question. Has anybody out there gotten gimp-python working in any form for windows? From tjg at hyperlinq.net Sat Jun 23 22:54:32 2001 From: tjg at hyperlinq.net (Timothy Grant) Date: Sat, 23 Jun 2001 19:54:32 -0700 Subject: readline, python 2.1 and LFS Message-ID: <20010623195432.A23754@trufflehunter.hyperlinq.net> Hi all, I've built a Linux From Scratch system, and Python built successfully, but then I realized that I didn't have readline support of any kind, so I downloaded and compiled readline 4.2 then recompiled Python. This time it built readline support. However, when I try and import readline, I get the following error. ImportError: /usr/local/lib/python2.1/lib-dynload/readline.so: undefined symbol: tputs Any suggestions will be gratefully received. -- Stand Fast, tjg. Timothy Grant www.hyperlinq.net Chief Technology Officer tjg at hyperlinq.net HyperLINq Technologies, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 19 days 2:51 hours ago<< From ceo-art at msn.com Mon Jun 11 20:14:32 2001 From: ceo-art at msn.com (Mark) Date: 11 Jun 2001 17:14:32 -0700 Subject: Incredible Software just about Free! Save Now Message-ID: <4c7733be.0106111614.70c03966@posting.google.com> Incredible Retail software just about free see below. We have Full versions of Corel Draw 10, Lightwave 6.0, Poser 4, Carrara, Photoshop 6.0, Paint Shop and just about any App and Game you could possibly want for one low fixed price to download as much as you want! See below. After a long hard day on the job do you really want to spend all of your free time searching for the best Warez Sites? We give detailed instructions that none of the Warez Sites give you. We wrote the book on "Warez For Dummies" Without our detailed Warez download and installation instructions it could take you days or even weeks of frustrating trial and error trying to figure out how to get the Warez software to work. If you are a Computer Nerd or have no social life and love the challenge of trying to find the latest warez software Site free of Porn go ahead and spend 80 or more hours finding your software. Even then you might not find all the software and cracks you want. For just the cost of a night out at the movies you can save all of this hassle and wasted time. Our service cost $24.95 and comes with a full money back guarantee. Even if we didn't offer the money back guarantee if you did not like our service you could simply dispute it with your credit card company. But we know that once your join our service you will love what we provide you. There simply is know easier way to find all of the good Warez Sites. Wouldn't you rather spend your free time doing something more enjoyable like playing your favorite game or software App that you can quickly download from our Site? Or would you prefer to spent countless frustrating hours searching for and trying to figure out how to install Warez Software? The choice is yours. We believe you will agree that our service is the best solution for all your software needs. Try it out risk free today. Click below to Sign up today. http://your-wish-is-my-command.com "I have tried just about every way to get Apps and Games but I can honestly say your Site is the best" "Thanks to your Site I was able to save thousands of dollars. I will be recommending your Site to all my friends." From boud at rempt.xs4all.nl Mon Jun 25 01:30:53 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 25 Jun 2001 05:30:53 GMT Subject: Python scripting [was: Re: emacs speedbar for python mode?] References: <9h2bo2$335$1@news1.xs4all.nl> <1bq4h9.tq8.ln@twocups.sirinet.net> Message-ID: <9h6iad$d40$1@news1.xs4all.nl> Bud Rogers wrote: > I have had similar thoughts. Imagine a programmer's editor of the > calibre of [x]emacs that used python as a built in extension language > in the same way that emacs uses lisp. It would not only have to have been in development for a couple of decades - there's a feature (X)Emacs has that editors like Nedit don't have: the ability to have active bits of texts embedded in the buffer. You couldn't write a speedbar in Nedit, even though it has its own little programming language. -- Boudewijn Rempt | http://www.valdyas.org From Marc.Poinot at onera.fr Wed Jun 13 10:49:04 2001 From: Marc.Poinot at onera.fr (Marc Poinot) Date: Wed, 13 Jun 2001 16:49:04 +0200 Subject: PostgreSQL, Python and BLOBs References: <3B2775C0.D2460A6C@cybertec.at> Message-ID: <3B277D60.C8A46C08@onera.fr> Hans-J?rgen Sch?nig wrote: > > Does anybody have a working example that uses BLOBs in combination with > Python and PostgreSQL. > I can't find information I can work with on the net. > > Hans Check http://www.4suite.org Marcvs [alias There is some blob stuff in ODS, but you have to dig in the source...] From aahz at panix.com Tue Jun 5 10:21:32 2001 From: aahz at panix.com (Aahz Maruch) Date: 5 Jun 2001 07:21:32 -0700 Subject: floating point in 2.0 References: Message-ID: <9fiptc$m9d$1@panix2.panix.com> In article , Remco Gerlich wrote: > >The way they're stored hasn't changed, it's just that 2.0 doesn't lie >anymore when writing the repr() of a float. This is how the floats are >represented internally, there is no exact binary representation for any of >them except 0.5. Actually, 2.0 *still* lies: >>> 0.1 0.10000000000000001 >>> '%.55f' % 0.1 '0.1000000000000000055511151231257827021181583404541015625' It just lies less than it used to. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Do not taunt happy fun for loops. Do not change lists you are looping over." --Remco Gerlich, comp.lang.python From aleaxit at yahoo.com Thu Jun 14 07:45:23 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 13:45:23 +0200 Subject: History substitution on dos References: <3B285D25.3D9B9851@rk-speed-rugby.dk> <9ga1pl02hko@enews1.newsguy.com> <3B289C53.532A5DA6@rk-speed-rugby.dk> Message-ID: <9ga85102nrl@enews1.newsguy.com> "Brian Elmegaard" wrote in message news:3B289C53.532A5DA6 at rk-speed-rugby.dk... > great. Thanks alex You're welcome, but the guy you should really be thanking is Chris Gonnerman!-) Alex From mixo77 at usa.net Mon Jun 25 10:37:24 2001 From: mixo77 at usa.net (mixo) Date: Mon, 25 Jun 2001 16:37:24 +0200 Subject: Scripts (running once) References: <3B37271F.759B0236@usa.net> Message-ID: <3B374CA4.A01F113C@usa.net> Olaf Trygve Berglihn wrote: > mixo writes: > > > How can one find out if there is a particular python script runnig, and > > hence prevent > > the same script from being run again? For instance, say I run a script > > 'mytes.py' with > > the following command: > > > > python mytes.py > > > > Now, the next time a user types the same command, a message saying the > > script is > > already running (or something of that sort) should be printed, as the > > script has not > > termintated. > > How about using a lock-file? This code removes the lock after the > program has ended. Replace the finally-statements with a pass if you > want the program to be executed only once. Note that the user must > have write-permissons for the lockfile. > > #!/usr/bin/env python > > import os > > LOCKFILE="/tmp/myprog.lock" > > def main(): > #your code here > import time > time.sleep(20) # pause for 20 sek. > > if __name__ == '__main__': > if os.path.isfile(LOCKFILE): > import sys > sys.stdout.write("Already running myprog\n") > sys.exit(1) > else: > fd = open(LOCKFILE, 'w') > fd.close() > try: > main() > finally: > if os.path.isfile(LOCKFILE): > os.remove(LOCKFILE) > -- > Olaf Trygve Berglihn If you send a hangup signal, for instance, 'killall -HUP python' (not the best way to do things) the lockfile won't be removed. How then , would you cater for system signals or system crash? From chrishbarker at home.net Mon Jun 11 19:28:57 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 11 Jun 2001 16:28:57 -0700 Subject: New guy question References: Message-ID: <3B255439.DFD33F59@home.net> Glen Mettler wrote: > I forgot to ask - what is the purpose of the Python window and the Python > Shell window? > > Can I NOT run a series of scripts from these windows? Must I go to the DOS > window to check my program? You've gotten your answer, but I'll add one more comment. I mostly use Linux, and run Python from a shell all the time. Windows does not give you a decent shell by default, so you will be a lot happier using an IDE, like IDLE or PythonWin (check out PythonWin, it's pretty nice). Since you probably aren't going to end up running Python from a DOS command line, there is little need to add it to your PATH. If you want to do it occasionally, you can just type in the whole path: C:\Python\Python20\Python.exe myscript.py That should work fine. Also, you can associate all *.py or *.pyw (have I got the .pyw right?) with Python, and then if you click on them they will run automagically. By the way, I havn't used windows much since 3.1, Does it really still have all that "add it to your PATH in autoexec.bat" stuff? Isn't there any kind of standard directories for executables, and some way to put a symbolic link in for your application? It makes for a Much cleaner system! (I suppose the above file association stuff is why they havn't bothered) -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From mjt at ingate.adc.com Wed Jun 6 13:40:24 2001 From: mjt at ingate.adc.com (Mike Tietel) Date: 6 Jun 2001 17:40:24 GMT Subject: best language for 3D manipulation over web ? References: <3b1cdc84.5514@bolder.com.co.za> <9fleid$3rp$1@oslo-nntp.eunet.no> <3B1E4951.7F36D4E4@alcyone.com> <3B1E50E1.35AE59C@lmf.ericsson.se> <3B1E52DA.BBC9FC32@alcyone.com> <3b1e5601.3970@bolder.com.co.za> <3B1E5836.E7F1D88F@lmf.ericsson.se> <3b1e5b50.3adb@bolder.com.co.za> <3B1E5D5C.7878FC9E@lmf.ericsson.se> Message-ID: <9flpu8$br12@mercury.adc.com> In article <3B1E5D5C.7878FC9E at lmf.ericsson.se>, Attila Feher writes: > goose wrote: > > LOL - neither do they eat quiche ... > > Opps. Here is one of the many points my English knowledge ends. What > is quiche? > You need French cuisine knowledge. Quiche is "egg pie"... -- mjt From gardner at cardomain.com Thu Jun 21 17:41:01 2001 From: gardner at cardomain.com (Jonathan Gardner) Date: Thu, 21 Jun 2001 14:41:01 -0700 Subject: Pythoin MUD (PyMUD?) References: <9gqq3t$hvs$1@brokaw.wa.com> <6tnY6.149028$ff.1136120@news-server.bigpond.net.au> Message-ID: <9gtpjn$271$1@brokaw.wa.com> Cantanker wrote: > "Jonathan Gardner" wrote: > >> 1) Is there any existing python muds out there? > > I believe Eric Raymond recently wrote one, called 'make advent'. > > > > :) > Aw, c'mon... I think hearing about this reminded me I like muds. I haven't played one for years, and I figured with me weak untested server module I should give it a try. -- Jonathan Gardner "Infinity isn't all that large - except at the end." -- Uncle Al Please don't take anything I say seriously, even if you are really gullible. From barry at digicool.com Fri Jun 29 11:50:13 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Fri, 29 Jun 2001 11:50:13 -0400 Subject: PEP scepticism References: <9hfg1n$du33c$1@ID-89274.news.dfncis.de> <3B3BB077.1E51F2C9@ActiveState.com> Message-ID: <15164.41909.338895.248731@anthem.wooz.org> >>>>> "ph" == phil hunt writes: ph> Is there a PEP for multi-line comments? ph> Or one for making ``pass'' optional? Nope, so obviously no one thought there was enough controversy or need in either of these two areas. The only requirements for PEP authors is that you have some ability to write well, can communicate your ideas clearly and succinctly, and that you be open to criticism and discussion from the community. IOW, almost /anybody/ can be a PEP author. If you think multiline comments or optional-pass are subjects worthy of PEP-hood, follow the guidelines in PEP 1 and submit your own offerings! -Barry From agavrilov at home.com Tue Jun 26 14:18:01 2001 From: agavrilov at home.com (Alexander Gavrilov) Date: Tue, 26 Jun 2001 18:18:01 GMT Subject: OS-specific modules to OS-specific packages Message-ID: Would it be nice to keep all OS-specific modules of the standard library in OS-specific packages? For example, Mac modules "macdnr", "mactty" and so on could be become "mac.dnr", "mac.tty". Windows-specific modules could become the part of win32 package: win32._winreg, win32.winsound and so on. Unix modules can be separated further to distinguish various flavor of UNIX: unix.syslog, unix.fcntl but unix.irix.fl, unix.sunos.sunaudiodev and so on. Alexander Gavrilov From python.list at atrixnet.com Mon Jun 25 01:27:38 2001 From: python.list at atrixnet.com (Tommy Butler) Date: Sun, 24 Jun 2001 22:27:38 -0700 Subject: Choosing SAX parsers In-Reply-To: Message-ID: Can't give you an anwer for this, but I bet someone here could: mailto:xml-sig at python.org just follow the same list subscription rules you would for any python.org mailing lists. (visit python.org for help) good luck, -t -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Graham Ashton Sent: Sunday, June 24, 2001 9:38 AM To: python-list at python.org Subject: Choosing SAX parsers I've just started playing with xml.sax and the XML HOWTO. [snip] What's my best bet? Installing PyXML? If I do, will it overwrite the xml.* module tree that I've got already? Are there any issues installing it over the top of the stuff in the standard library (some of which I believe is the same codebase)? Any pointers would be much appreciated. Thanks. -- Graham -- From sholden at pgrad.cs.usyd.edu.au Fri Jun 15 09:59:29 2001 From: sholden at pgrad.cs.usyd.edu.au (Sam Holden) Date: 15 Jun 2001 13:59:29 GMT Subject: Parrot-0.2.6 released References: Message-ID: On Fri, 15 Jun 2001 13:34:58 -0000, Jan Schaumann wrote: >* phil hunt wrote: >> >> I have just released Parrot version 0.2.6. > >http://use.perl.org/article.pl?sid=01/03/31/206248 > >Any connection or a coincidence? Coincidence I suspect... A reasonably funny article though... -- Sam Some of you know what the Perl slogan on Windows is, and you can say it with me: "It's a good thing there's more than one way to do it, because most of them don't work." --Larry Wall From rdsteph at earthlink.net Thu Jun 21 18:33:54 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Thu, 21 Jun 2001 22:33:54 GMT Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: <3B2EACF5.1D10252D@earthlink.net> Message-ID: <3B31272B.21F2E7BC@earthlink.net> Please go to http://groups.yahoo.com/group/pythoncard and check out the discussion on a potential PythonCard project. Just click join and follow the steps. Mark 'Kamikaze' Hughes wrote: > Wed, 20 Jun 2001 01:27:49 GMT in <3B2EACF5.1D10252D at earthlink.net>, > Ron Stephens spake: > > Anyway, by my count 7 people have expressed some sort of interest in a > > HyperCard-like gui creator, since it was first mentioned yesterday by Roman > > Suzi... > > Roman Suzi > Heil Hodgson > Jerry Spicklemire > Kevin Altis > Chris Barker > > Phil Hunt > and myself... > > I'm quite interested, too. Even simple as it is, Tkinter still > requires a lot of "manual wiring". It should be possible to design > something simpler. > > Even just dropping GUI bits into place, binding some primitives like > "switch to card X" and "call Python method Y" to each, would be nifty. > > I have some notes and a bit of prototyping for a web-based > hypercardish project, with a "GUI builder" that makes spec-compliant > HTML, a server-side application to respond to events, and a database to > store information persistently. Unfortunately, it's in Java, I do that > enough at work that I don't want to do it for fun, and there's already > Zope and a few others sort of covering that space. > > A Pythoncard would be a nice substitute project. > > -- > Mark Hughes > "I will tell you things that will make you laugh and uncomfortable and really > fucking angry and that no one else is telling you. What I won't do is bullshit > you. I'm here for the same thing you are. The Truth." -Transmetropolitan #39 From graham at coms.com Sun Jun 24 12:26:44 2001 From: graham at coms.com (Graham Ashton) Date: Sun, 24 Jun 2001 17:26:44 +0100 Subject: problem installing PyXML on Linux References: <9h4au7$2j2$1@wanadoo.fr> Message-ID: <8xoZ6.1487$h45.9806@news.uk.colt.net> In article <9h4au7$2j2$1 at wanadoo.fr>, "Helka.Folch" wrote: > I'm trying to install PyXML-0.0.6.5.-1 on linux (suse 7.1). When I tried > to install the rpm, I got the following message: dependancy problem > /usr/local/bin/python is needed by PyXML-0.0.6.5.-1 (on my system, > python exec is /usr/bin/python2.0) Ah, the wonders of RPM. Where did you get the python and PyXML RPMs from? (I wouldn't be able to help, but that's where I'd start looking; if they're built by different people then you've got a potential problem, and quite why an RPM is dependent on something in /usr/local is beyond me). > On the other hand, when I tried to install PyXML from the source file > with : python setup.py -q install > I got the following error message: > > extensions/pyexpat.c:4 Python.h No such file or directory > extensions/pyexpat.c:5: Compile.h No such file or directory > extensions/pyexpat.c:6: frameobject.h No such file or directory error : > command 'gcc' failed with exit status 1 You need the python header files. Have you got an RPM called python-dev-2.0...rpm, or similar? > do you know what I've done wrong? Python itself is quite easy to build from source. You could try that and then everything will workly nicely (and you could get 2.1 too). You should be able to get the dev RPM if you'd prefer though. Hope that helps. -- Graham From rob at ZOOstation.cc Fri Jun 29 16:02:49 2001 From: rob at ZOOstation.cc (Rob Brown-Bayliss) Date: 30 Jun 2001 08:02:49 +1200 Subject: getopts confusion In-Reply-To: References: Message-ID: <993844969.1531.0.camel@ZOOstation.cc> On 29 Jun 2001 08:13:50 -0400, Steve Holden wrote: > > Error on option -s: unknown option. > > Run './gearbox.py --help' to see a full list of available command line > > options. I have checked indentation, it's fine. > I conclude that the getopt code is working correctly, but your application > is somehow failing to test for the options. > > Hope this helps. Yes, some. I played around some more, and the app that fails has a GUI, the other is a command line app. There is a single import I do (from gnome.ui import *) that stuffs it up, if the getopt stuff comes before this import I don't get that error, if I cut and paste the getops till after this import I get the above error. Does any one know why? -- Rob Brown-Bayliss ---======o======--- www.ZOOstation.cc From altis at semi-retired.com Fri Jun 1 14:47:04 2001 From: altis at semi-retired.com (Kevin Altis) Date: Fri, 1 Jun 2001 11:47:04 -0700 Subject: Lego Mindstorms robotics control via Python? Message-ID: I would like to control a robot via Python on Windows (specifically Windows 2000). The Lego Mindstorms product is relatively inexpensive and easy to find and supports an infrared transmitter, so that seems like a good choice to program around. Does anyone know if there is a already a Python wrapper for issuing RCX ("yellow brick") commands? If not, how about a COM-enabled app that I could control or a C library/source that I could wrap in Python? Any other suggestions, reading material, or URLs for further info would be appreciated. I would be interested in controlling other robotic devices, but only if they are commercially available and relatively inexpensive. I'm currently working on a more elaborate set of turtle graphics modules than Guido's standard tk module and I want to support external devices in addition to drawing on the screen. Right now, I'm doing graphics via wxPython which works splendidly. This is alpha-ware, so I haven't put it up on a website yet, but those interested in testing and giving input on the wxTurtle (wxPython) version can contact me directly via email. ka From brian at nr6.dk Mon Jun 4 12:04:26 2001 From: brian at nr6.dk (Brian Andersen) Date: Mon, 4 Jun 2001 17:04:26 +0100 Subject: Using SMTPlib Message-ID: <9fg915$jho$1@news.inet.tele.dk> Hi. I'm in the process of writing my very first project in Python - a webmail application. I've tried the SMTPlib and it work out fint, but the mails I send don't have a subject. I've tried the example that is in the Pythondocumentation for the SMTPlib and it works well, but how do I insert a subject field? The same goes for CC end BCC-fields. Are they handled by the SMTPlib or is it something that I must handle in my program? Hope you can help me. Best regards. Brian. From loewis at informatik.hu-berlin.de Sun Jun 17 07:47:13 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 17 Jun 2001 13:47:13 +0200 Subject: Writing new codecs References: Message-ID: "Brian Quinlan" writes: > > I think that UTF-7 would be a good candidate, since it is > > a native Unicode encoding. UTF-32 would be another candidate. > > What about UTF-7, modified to be used in IMAP, as described in RFC2060 > (I could also modify it slightly for vanilla UTF-7 [RFC1642])? I ask you > directly since you are likely going to be assigned the patch :-) I think at the minimum, the codec must not be called "utf-7" if it does not implement RFC 2152/1642. Unfortunately, RFC 2060 does not give it an encoding name. Note that the IANA registry gives "UTF-7" to the encoding described in RFC 2152, and "UNICODE-1-1-UTF-7" to the one described in RFC 1642. It doesn't give a name to the encoding of RFC 2060, either. So I think your patch should use a temporary codec name, until IANA assigns an official name to it. Regards, Martin From rarice at core.com Fri Jun 1 15:15:50 2001 From: rarice at core.com (Ralph Allan Rice) Date: Fri, 01 Jun 2001 15:15:50 -0400 Subject: HELP: Weird attribute behavior... References: <3B17E975.F11AB911@core.com> Message-ID: <3B17E9E6.8AFEABDE@core.com> I forgot something: Windows NT v4.0 SP6a ActiveState Python v2.1 Regards, Ralph From boyd at insultant.net Thu Jun 7 15:22:49 2001 From: boyd at insultant.net (Boyd Roberts) Date: Thu, 7 Jun 2001 21:22:49 +0200 Subject: floating point in 2.0 References: <9fiptc$m9d$1@panix2.panix.com> <3B1D154B.81016685@home.net> <3B1DC3AE.6EA1F09D@accessone.com> <3B1FCBD8.C43504C1@home.net> Message-ID: <9fokct$o6q$1@hadron.noos.net> it's simple: floating point represented in finite binary is not precise for all values. learn to live with it. it's one of the first things they teach you in comp sci. unless you really know what you're doing it is not a subject that you re-invent as a weekend project, not unless you're a fan of dire, unforeseen consequences. From aahz at panix.com Fri Jun 29 10:19:02 2001 From: aahz at panix.com (Aahz Maruch) Date: 29 Jun 2001 07:19:02 -0700 Subject: PEP scepticism References: <9hfg1n$du33c$1@ID-89274.news.dfncis.de> <3B3BB077.1E51F2C9@ActiveState.com> <9hhfk5$e50ak$1@ID-89274.news.dfncis.de> Message-ID: <9hi2om$ltg$1@panix3.panix.com> In article <9hhfk5$e50ak$1 at ID-89274.news.dfncis.de>, Bernhard Reiter wrote: > >My general warning has something do to with the process though, >as a non-technical reason exist why people participating in the >processes will have higher chances to vote for inclusing of features, >because being exceptional python programmers. I am hardly an exceptional Python programmer, or even an exceptional programmer in any language. I'm not even sure I qualify as "very good" (I *am* sure I qualify as "good"). To the extent that Guido pays attention to me, it's because I've been participating and have done a small amount of good work. That's it. That is quite literally all it takes. Well, no, I take that back. I think I'm a pretty good writer, too, and I express myself clearly. The ability to communicate is highly prized in the Python community, and I believe that's one of the major reasons for Python's success. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Nothing fails like prayer" --bumper snicker From not.this at seebelow.org Wed Jun 27 23:02:54 2001 From: not.this at seebelow.org (Grant Griffin) Date: Wed, 27 Jun 2001 22:02:54 -0500 Subject: PEP 260: simplify xrange() References: Message-ID: <3B3A9E5E.D7919F1F@seebelow.org> Roman Suzi wrote: > > On Tue, 26 Jun 2001, Guido van Rossum wrote: > ... > >Proposed Solution > > > > I propose to strip the xrange() object to the bare minimum. The > > only retained sequence behaviors are x[i], len(x), and repr(x). > > What about str(x)? To me, "str" seems kindda like a companion for "repr", so if repr is supported, my intuition says that str should be also. However, the current implementation of it doesn't seem very useful: >>> str(xrange(5)) 'xrange(5)' which, coincidently, looks a lot more like: >>> repr(xrange(5)) 'xrange(5)' than: >>> str(range(5)) '[0, 1, 2, 3, 4]' In any case, I have never used xrange for anything but the ordinary "for" loop. if-even-that--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From bc19191 at home.com Fri Jun 8 12:38:18 2001 From: bc19191 at home.com (Bill) Date: 8 Jun 2001 09:38:18 -0700 Subject: PalmOS Desktop Interface For Python? References: <3B1FB7E4.2F5D2FE3@tundraware.com> <3B203FD8.9030206@none.com> <3B204583.C3F88260@tundraware.com> Message-ID: You may be interested in the Palm-Linux integration with Pyrite article just published on IBM's developerWorks: http://www-106.ibm.com/developerworks/linux/library/l-pyr.html From root at rainerdeyke.com Sun Jun 17 18:38:42 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Sun, 17 Jun 2001 22:38:42 GMT Subject: graceful version detection? References: <3B2D2F44.50007@red-bean.com> Message-ID: "Ben Collins-Sussman" wrote in message news:3B2D2F44.50007 at red-bean.com... > If I write a python script that uses 2.X features, and then run it with > a 1.X interpreter, I get a bunch of exceptions. Presumably this happens > during the initial byte-compilation. > What's the correct solution? There is probably no elegant solution, but the following ugly hack should do what you want: import sys if sys.version_info[0] < 2: print 'This script requires Python 2.0 or later.' exec """ # Place entire original scriot here """ Note that this won't work if your original script contains triple quotes. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From gerhard.nospam at bigfoot.de Mon Jun 11 02:41:57 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Mon, 11 Jun 2001 08:41:57 +0200 Subject: detecting idle processor References: Message-ID: On 11 Jun 2001 00:00:41 -0700, Sorin Gherman wrote: >How can I use Python to detect when the processor is idle? Or when the network >traffic is idle, for a given computer? > >I need this to implement a background program. This is depends very much on the operating system. For the first question (processor is idle), I think the answer is that you can't do it. All you can do is run the Python program with a very low priority. This means that it won't steal much CPU from processes that run at a higher priority. On Unix, you'll want to use nice for this. On my Linux system, nice --adjustment=19 myscript.py does just that. The parameters of nice would be different on other Unixen, of course. Measuring network load is more difficult, but still possible (reading from /proc on Linux, for example). Which OS do you want to use this on? Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://highqualdev.com public key at homepage public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From tim.one at home.com Sun Jun 3 18:52:53 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 3 Jun 2001 18:52:53 -0400 Subject: Inexact representation cases (Re: Against PEP 240) In-Reply-To: Message-ID: [Tim] > It turns out that the closest you can get in IEEE double is > > 1.1 ~= 2476979795053773 / 2**51 > > which is, as a *decimal* number, *exactly* > > 1.100000000000000088817841970012523233890533447265625 [Michael Hudson] > How did you get these numbers? In a way that won't help you : >>> import sys >>> sys.path.insert(0, "/MyPy") >>> from Rational import Rat, Format >>> x = Rat.Rat("1.1").round(format=Format.IEEE_double) >>> print x.cvt_exact(10) 1.100000000000000088817841970012523233890533447265625 >>> Rational is a large package for doing rational arithmetic that also happens to know all about floating-point formats with arbitrary bases and precisions, and does best-possible conversions among any combination with oodles of rounding options. Given the number of times I'm elected to answer these questions, writing it was a necessity . Alas, writing docs wasn't, and the API is incomprehensible unless you're me, so I never distributed it. > I'm sure you posted the routine a week or so back, but I can't dig > it out of google. I see Aahz pointed you to his Decimal package, which contains a much simpler and self-contained function for this trivial task . > I want to write a sys.displayhook that prints floats exactly, just for > extra geekiness value. It's not always, well, *illuminating": >>> print Rat.Rat(1e-300).cvt_exact(10) 0.000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000100000000000000002505909 18352087596856961468077037052499253423199004660431840514846763028 12181950100894962306270278254148910311464998804130812246091606190 18271942662793458427551041478278701507022263926060379361392435977 50940301438661414791255135908825910173416922229212204049186218220 29155619541859418525883262040928316317872050154019969866169489804 10676557942431921652541808732242554300585073938340203330993157646 46743363847906553166172481259959859490629378249375961717786188879 29704765305423351347104182296375666379507674971478542365897951520 44892049176025289756709261767081824924720105632337755616538050643 65381258305022465963115930056323650792902539887815381155401398600 95879780811674328049363596311404191532834495603765390114858746528 62548828125 >>> The result there may actually vary across platforms, depending on how good a job the platform C does on converting "1e-300" to a double. To get the best possible (implying platform-independent!) result requires letting string->double be handled by Python too: >>> print Rat.Rat("1e-300").round(format=Format.IEEE_double).cvt_exact(10) [happens to print the same thing in this case, under Windows] From rnd at onego.ru Sun Jun 3 11:37:51 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 3 Jun 2001 19:37:51 +0400 (MSD) Subject: Has anyone used UML? In-Reply-To: <991574786.733151@nntp01.uskonet.com> Message-ID: On Sun, 3 Jun 2001, Frank Millman wrote: >>Does anyone have any knowledge or experience of UML that they would like to >>share? >I realise belatedly that, as this question has got nothing to do with >Python, it should not have been posted to this group. My apologies. Why not? UML buzz louder and louder in job requirement sections. So, it's interesting to know which UML tools support Python so it will be easier to learn UML ;-) I prefer freeware solutions to learn. Going google over "Python UML"... >Having said that, can anyone suggest an appropriate news group for this kind >of question. Maybe something with oop, uml or software-eng in it's name? Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, June 03, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "To a cat, "NO!" means "Not while I'm looking."" _/ From netmgr at canterburycrest.org Thu Jun 21 18:54:21 2001 From: netmgr at canterburycrest.org (Ross Brattain) Date: Thu, 21 Jun 2001 15:54:21 -0700 Subject: Getting actual name of passed arg References: <3B3272DD.4000308@canterburycrest.org> <3B327450.8060305@canterburycrest.org> Message-ID: <3B327B1D.9020107@canterburycrest.org> Nope not quite. traceback.print_stack() doesn't quit work either. I will settle for this for now def debug(a): print a eval(a) Ross Brattain netmgr at canterburycrest.org From glyph at twistedmatrix.com Thu Jun 7 01:43:57 2001 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: Thu, 7 Jun 2001 00:43:57 -0500 (CDT) Subject: Why should i use python if i can use java In-Reply-To: <3e7e9334.0106062002.368d5e0a@posting.google.com> Message-ID: On 6 Jun 2001, Chris Goringe wrote: !snip! > python doesn't [have ...] > strong typing (love it or hate it...) Hate it :) > interfaces (ditto) Well, python *does* have interfaces, at a much deeper level than Java; you could think of *everything* in python as going through an interface. What it doesn't have is interface implementation enforcement; which is nice, because that means that as long as your classes implement the bits of the interface you need, minor changes to the code of a library you're using won't break everything instantly. I also chuckle to think that the compiler can tell if I've properly implemented actionPerformed, or if I'm just stubbing it out by copying the declaration from the interface file. > an elegant way of implementing singletons (or does it? anyone?) Aah, the singleton. Global variables for the new millennium. First of all, the singleton "pattern" is usually a bad idea. If you have a class that can "only be instantiated once", then you're dealing with per-process state, and representing it as a class instance can be misleading. If it's *not* per-process, then you just have a one-to-many relationship of objects, not a true "singleton"; attempting to limit this artificially is a mistake and results in reduced flexibility as well as increased complexity. Thankfully, Python provides a much better mechanism for doing so! "Modules" are actually singletons wearing funny shoes. Any "singleton" state can be specified as a variable in a module. (Which is usually declared with the 'global' keyword. Coincidence?) So, I'd say that this is a flaw with Java not supporting modules, rather than Python not supporting java's ill-defined crutch which it uses to cover for its lack of support for first-class namespaces and modules, fancy terminology notwithstanding. Since we're on the topic; other design patterns that lurk around unobtrusively in Python include the "for" keyword, which is really the "Observer" pattern, the notion of classes as callable, which is the "Factory" pattern universally applied, and the Strategy pattern masquerading as first-class functions. Modules moonlight as the "Facade" pattern when they're not playing Singleton. Did guido use the time machine to get a copy of the GoFBook before he started working on the first version of Python, or are Patterns just a transparent attempt to cover for chronically inexpressive languages like C++ and Java which can't generally implement these mind-numbingly simple constructs in code? Inquiring minds want to know. > a comparable development and debugging environment to JBuilder Have you used any of the commercial Python IDEs? PythonWorks or WING IDE? > but most of all, it doesn't have > > J2EE > J2ME Actually it does! With Jython, you can access any Java API from Python. Neat, huh? > So it still lags Java for seriously scalable enterprise solutions (Assuming we're talking about [C]Python, since Jython is functionally equivalent to Java in terms of available technology --) It depends how you want to scale. I disagree, but this gets into a very lengthy and essentially unwinnable argument about development practices. However, some "enterprises", such as Google, seem to have implmented really massive things with Python and I don't think they've noticed that it doesn't work. Also, see Zope. > and for portable device deployment. Python is currently very difficult to pare down to embedded devices currently, bit I imagine that it'll be different in 2 years. However, once you're up to a certain critical mass, Python's performance tends to be more deterministic than Java's, so medium-sized "information appliances" can benefit from Python. in-languages-that-don't-suck-we-call-"design-patterns"-by-their-real-names-ly y'rs, ______ __ __ _____ _ _ | ____ | \_/ |_____] |_____| |_____| |_____ | | | | @ t w i s t e d m a t r i x . c o m http://twistedmatrix.com/users/glyph From ajm at enteract.com Fri Jun 22 18:48:52 2001 From: ajm at enteract.com (Alan Miller) Date: Fri, 22 Jun 2001 17:48:52 -0500 Subject: launching a file with its associated application on windows References: <3b313ae6$0$327$6e49188b@news.goldengate.net> <3b327114$0$319$6e49188b@news.goldengate.net> Message-ID: Volucris (volucris at hotmail.com) wrote: >"Volucris" wrote in message >news:3b313ae6$0$327$6e49188b at news.goldengate.net... >> If it's pre 2.0, I think you can prefix a popen() command with 'start ' to >> do the same thing. >> >> import os >> os.popen('start %s' % r'C:\sish\MyPic.bmp') > >yeah, I'm stupid. That should be system() not popen(), although popen() >would work, too, depending on what exactly you are doing. You wouldn't want >a pipe to a (.bmp) file, though, would you? Maybe. I don't know. I'm >rambling again. Good bye. Actually, I don't believe using popen() would cause any problems - you're unlikely to get anything useful back from it, but "start" is actually a command in its own right that does the lookup and starts the appropriate program. Unless it's started with /WAIT, it should exit immediately after launching the the program associated with the input file. ajm From ksterker at topmail.de Thu Jun 7 17:48:01 2001 From: ksterker at topmail.de (Kai Sterker) Date: Thu 07 Jun 2001 23:48:01 +0200 (MEST) Subject: Advanced problem (recursive calls to python) In-Reply-To: Message-ID: <20010607214404.19865.qmail@psmtp1.dnsg.net> Hello folks, I am facing a weird problem with python, which I believe might come from recursive calls to the interpreter. OTOH, I am not sure, and since I am fairly new to python, I want to make sure what the problem is before fixing the wrong things. Here's a short summary of the problem. Further down I'll get into the details. Basically, I have used SWIG (1.3 alpha 5) to create wrappers of my C++ code. This code itself contains calls to Python, like PyObject_CallObject, etc. The main() function executes a python script which in turn calls functions of my code that execute more python code. At the most, this recursion is 3 levels deep. So far it was working, but now there is a situation where the call to PyObject_CallObject returns NULL although I pass a valid callable object and arguments. Question: could that be related to the recursion? I am unsure, because there are several calls to PyObject_CallObject in that function, but only one of them fails. Even more weird, if I add a PyObject_Print(...) before said call, it suddenly works! Any insights into this problem are welcome. I am using Python 2.1 on Linux. This is the core of the problem, as I see it. But I'll give you a full overview of the stuff in case I have missed something. So excuse me if it gets lengthy and boring ;). The program (Adonthell, a CRPG, adonthell.linuxgames.com) needs to execute different (small) python scripts regularly. (several times per second). Further, the scripts need to share the same data. So I made a PyDict object that contains all that data: PyObject *data::globals. And I compile the scripts into PyCodeObjects and run them directly with PyEval_EvalCode(...). That way I can pass the same 'global' data to each script and each kind of script can also get it's own local data. I further need to access objects instantiated on C++ side from Python. They are turned into a PyObject with the function: PyObject *pass_instance (void *instance, const char *class_name) { char class_ptr[256]; char class_addr[256] = "_"; char buffer[256]; // Construct the python shadow class matching the "instance" class strcat (strcpy (class_ptr, class_name), "Ptr"); // Construct SWIG's representation of the "instance" pointer sprintf (buffer, "%p_p_%s", instance, class_name); strcat (class_addr, buffer+2); // Now create the Python object corresponding to "instance" PyObject *cls = PyDict_GetItemString (data::globals, class_ptr); PyObject *arg = Py_BuildValue ("(s)", class_addr); PyObject *res = PyObject_CallObject (cls, arg); // Clean up Py_DECREF (arg); // Voila: "res" is 'identical' to "instance" :) return res; } This function is the one where the error occurs under certain circumstances (see further down): PyObject_CallObject will return NULL even though 'cls' and 'arg' are okay, as well as the __init__ function of the 'cls' classobject. It's the usual code that SWIG generates, nothing special: class landmapPtr(landmap): def __init__(self,this): self.this = this self.thisown = 0 self.__class__ = landmap Anyway, as long as I did no more as the above, everything worked fine. But I also need to pass a python function or method as a callback to the C++ code. Again, storing a python function in a PyObject for later execution via PyObject_CallObject() is trivial. But from then on, things went wrong. Here are the steps that result in above error: I execute the first python script with PyRun_File( file, name, Py_file_input, data::globals, NULL ); >From that script a callback is registered, some of my wrapped classes are instantiated and finally one of their methods is called which never returns. At some point, the python callback is executed (so we're in the script again), which calls some other method of a wrapped class (data::load() - back on C++ side) from where finally over a dozen calls to above "pass_instance' are made. As I said above, most of them succeed, but one does not. But if I add a "PyObject_Print (data::globals, stdout, 0);" before that failing call, it suddenly works! (I thought something with the data::globals was wrong, so I wanted to see their contents ...) It'll also work if I leave out that callback and call data::load() directly from the first script, or one of those precompiled ones that are executed via PyEval_EvalCode(...). Since both the first script and those precompiled ones get data::globals as their global namespace, but that python callback doesn't, I suspect that the problem lies there. But what confuses me is the fact that it is not completely failing, only half-heartedly. Unfortunately, I don't know enough of the python interpreter internals to know what is allowed, and what isn't. Do I have to use multiple Python threads instead of recursive calls? Is their a way to set the global namespace when executing a callable PyObject? Or have I simply missed something else? I know that was a load of stuff, but right now I'm stuck and would appreciate any help. If you are interested in the problem and like to have a closer look you can get the code from cvs ( http://adonthell.linuxgames.com/en_frames/cvs.shtml ) and contact me ( ksterker at geekmail.de ) for the required data file, which contains, among other stuff, all the python scripts. Well, thanks for your patience and c ya, Kai From rnd at onego.ru Sun Jun 10 14:50:47 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 10 Jun 2001 22:50:47 +0400 (MSD) Subject: list-display semantics? In-Reply-To: <9g0dhl$if1$1@news.nsysu.edu.tw> Message-ID: On Mon, 11 Jun 2001, jainweiwu wrote: >Hi all: >I tried the one-line command in a interaction mode: Try: del y [x for x in [1, 2, 3], y for y in [4, 5, 6]] >and the result surprised me, that is: >[[1,2,3],[1,2,3],[1,2,3],9,9,9] >Who can explain the behavior? >Since I expected the result should be: >[[1,4],[1,5],[1,6],[2,4],...] >-- >Pary All Rough Yet. >parywu at seed.net.tw > > > Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, June 10, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Computers make very fast, very accurate mistakes." _/ From aleaxit at yahoo.com Fri Jun 15 06:30:00 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 15 Jun 2001 12:30:00 +0200 Subject: PEP 259: Revise to remove context-driven magic from print References: <486de2.0106131406.5c0cbef9@posting.google.com> <9gamor$8ft$6@216.39.170.247> <9gap8i0fss@enews1.newsguy.com> Message-ID: <9gco3r0305m@enews1.newsguy.com> "Remco Gerlich" wrote in message news:slrn9ijalb.697.scarblac at pino.selwerd.nl... ... > > No, __print__ would rather underlie the print statement just like > > __import__ underlies the import (and from) statements. But I guess > > I gotta write a PEP about it... > > I'm missing the point, I think. What would be useful about that function? Exactly the same customizability/wrappability that __import__ supplies to the import statement. > I suppose you could override it if you wanted to change print's behavior > by assigning to __builtin__.__print__ or so, but then you have a global > magic function! Except for the peculiar wordchoice of "magic" (what's "magic" about it?), yes: this would work exactly like __builtin__.__import__ does > And if you override it locally, I don't see how print would > use it. Overriding the way print works globally sounds like Perl to me. Why is this any different from "overriding the way import works globally", which sounds like Python to me?-) > __import__ is useful if you want to do call it with a string, or do > something with it other than assign it to a name in the local namespace. But > I don't see any equivalent things with __print__. Yes, __import__ has secondary uses, but that's not its main reason for being. The holy docs put it well: "It mainly exists so that you can replace it with another function that has a compatible interface, in order to change the semantics of the import statement". That's in 2.3 in the Library Reference -- hardly an obscure corner of the docs:-). Are you arguing against the Library Reference?-) __builtin__.__print__ would be allowed to be any callable with a compatible interface to a 'bundled' __print__. The latter would encode the current magic features of the print statements as kw arguments with optional values: file=sys.stdout set by the >>fileobject hack to file=fileobject nl=1 set by a trailing-comma to nl=0 settable to nl=-1 to get the nl-stripping behavior that Guido wanted (no syntax for that in the print statement) (still to be designed: what if anything to do about .softspace play &c; whether to supply a few more kw's, without syntax for them in the print statement, just to ease customization & direct use -- I guess not, but...). Of course HAVING this behavior as a bundled function has its uses, just like for __import__ albeit different ones. For example, use __print__(*lotsofitems) instead of for item in lotsofitems: print item, print when you have to print each item in a sequence of items. Alex From opengeometry at yahoo.ca Mon Jun 18 16:03:37 2001 From: opengeometry at yahoo.ca (William Park) Date: Mon, 18 Jun 2001 16:03:37 -0400 Subject: Teaching Pyhton on Wintel In-Reply-To: <9glj3e$shg$1@nereid.worldonline.nl>; from gmuller@worldonline.nl on Mon, Jun 18, 2001 at 08:58:57PM +0200 References: <1ev6xe3.15eskd91k2u1eaN%p.agapow@ic.ac.uk> <9glj3e$shg$1@nereid.worldonline.nl> Message-ID: <20010618160337.B288@node0.opengeometry.ca> > Call me misguided, but I've decided to teach an introduction to > programming class using Python. The audience are the scientists in my > (evolution/ecology research centred biology) department and we'll be > using the local computer lab, which is kitted out out with a network > of modestly powered Wintel machines. So: > > 1. Any advice on which IDE etc. of Win Python to use? > 2. Anyone done a similar class, like to advise on approaches or books > to base it off? Did a 2-day seminar few years ago. If your audience is programmers, then getting their favourite editor working on Windows would be more important for the smooth and productive class. Doing any example requires some sort of typing. I did a quick summary of "standard python tutorial doc", followed by detailed control structure, function calls, and other non-oop stuffs, and finally class. Use lots of examples, especially have them type and see for themselves. If your audience is non-programmers, well... leave out OOP stuffs. They won't appreciate or use it, anyways. -- William Park, Open Geometry Consulting, 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From slinkp23 at yahoo.com Fri Jun 1 18:43:13 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Fri, 01 Jun 2001 22:43:13 GMT Subject: docstrings, invention there of References: Message-ID: <3B181969.E34E56AA@yahoo.com> Laura Creighton wrote: > Still it makes the good old 'you just typed 600 lines of code into > your cat>/dev/null window mistakes a lot harder to make.... What are you, a Real Programmer or something? :) --PW From BPettersen at NAREX.com Wed Jun 13 15:51:52 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Wed, 13 Jun 2001 13:51:52 -0600 Subject: Inner classes Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D46D@admin56.narex.com> > From: Samuele Pedroni [mailto:pedroni at inf.ethz.ch] > > Andrew Kuchling wrote: > > > xyzmats at laplaza.org (Mats Wichmann) writes: > > > Nonetheless, I was challenged by someone to describe how > it isn't a > > > shorcoming in Python that classes don't work this way and didn't > > > convince the guy so I'm looking for a more erudite comparison. > > > > Work *what* way? It's perfectly legal to do this: > > > > class C: > > class inner: > > ... stuff for inner class > > ... stuff for class C > > > > --amk > > Yes, but that's basically a static inner class, you can do > > C().inner() but the created inner instance will not contain any > implicitly created reference to the C instance. > > To have that you must be explicit: > c=C() > i=C.inner(c) Not true... from __future__ import nested_scopes class Outer: def foo(self): class inner: def bar(this): self.foo() this.bar() bar can now reference both it's own class (inner) and the Outer class. Not that this code is doing anything particularly useful though . -- bjorn From tim.one at home.com Wed Jun 13 16:24:50 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 13 Jun 2001 16:24:50 -0400 Subject: Working with paths with spaces in NT In-Reply-To: <3b279eaf.5984935@news.laplaza.org> Message-ID: [Tim] > If you look at your output very carefully, you'll discover this has > nothing to do with spaces ... [Dave LeBlanc, takes offense] [Mats Wichmann, takes umbrage at Dave's offense] > I missed what it was raised your hackles in Tim's comment. ... So did Dave . Just a too-long night, probably. We sorted this out offline -- nobody feels abused anymore. or-if-the-do-they-should-keep-it-to-themself-ly y'rs - tim From carmstro at twistedmatrix.com Mon Jun 11 09:58:44 2001 From: carmstro at twistedmatrix.com (Chris Armstrong) Date: 11 Jun 2001 06:58:44 -0700 Subject: Bug? with circular imports of packaged modules. Message-ID: Hello all. I've been refactoring a few Twisted Python modules into packages, and have run into some problems with modules that import each other. Usually, this is not a problem, but the TPy coding standard states (well, did state, until we found this "bug") that no sibling imports should be allowed. Which means, instead of twisted.web.server doing 'import html', it has to do 'from twisted.web import html'. The reason for this is to prevent ambiguous imports. The problem is, if the html module also did 'from twisted.web import server', python would raise an ImportError saying 'cannot import name server' in the html.py module. This doesn't make sense, since the modules will import each other if they don't import from the package, and package imports work normally as long as they're not circular. So, I'm changing the second-level packages in TPy to just do sibling imports for now, but it'd be nice to see this problem corrected in future Python versions. If anyone has any suggestions, I appreciate them. From jm7potter at hotmail.com Tue Jun 26 11:34:26 2001 From: jm7potter at hotmail.com (Joe Potter) Date: Tue, 26 Jun 2001 11:34:26 -0400 Subject: newbie with major "lambda" problem (perhaps a scope problem as well) Message-ID: Hello all, The following code comes from "Programing Python 2nd Edition" by Lutz. My problem is with the Button function calls in the " if __name__ == '__main__': " part of the code. If one uses the lambda call as does Lutz, then everything works like a champ. However, a direct call to the function does not seem to do anything. No error messages --- just no action. This leads me to believe that I am missing some "VERY BIG DEAL" (TM) in Python. Can someone tell this fool what he is missing? Thanks in advance, Joe Potter ##### here is code in question ############################ # use StringVar variables and layout by columns from Tkinter import * from quitter import Quitter fields = 'Name', 'Job', 'Pay' info = [] def fetch(variables): info = [] for variable in variables: #print 'Input => "%s"' % variable.get() # get from var info.append(variable.get()) for c in range(len(info)): print info[c] def makeform(root, fields): form = Frame(root) # make outer frame left = Frame(form) # make two columns rite = Frame(form) form.pack(fill=X) left.pack(side=LEFT) rite.pack(side=RIGHT, expand=YES, fill=X) # grow horizontal variables = [] for field in fields: lab = Label(left, width=5, text=field) # add to columns ent = Entry(rite) lab.pack(side=TOP) ent.pack(side=TOP, fill=X) # grow horizontal var = StringVar() ent.config(textvariable=var) # link field to var var.set('enter here') variables.append(var) return variables if __name__ == '__main__': root = Tk() vars = makeform(root, fields) # the "button" below works like a champ !! #Button(root, text='Fetch', #command=(lambda v=vars: fetch(v))).pack(side=LEFT) # the "button" below does not do anything ?????? Button(root, text='Fetch', command=(fetch(vars))).pack(side=LEFT) Quitter(root).pack(side=RIGHT) root.bind('', (lambda event, v=vars: fetch(v))) root.mainloop() ############################################ ####### end code From wart at softhome.net Thu Jun 7 12:38:46 2001 From: wart at softhome.net (Wartan Hachaturow) Date: 07 Jun 2001 20:38:46 +0400 Subject: WHY is python slow? References: <9fnkd3$56bjh$4@ID-89274.news.dfncis.de> Message-ID: <871yow4549.fsf@penguin.aktivist.ru> >>>>> "Bernhard" == Bernhard Reiter writes: Bernhard> In article , Bernhard> Steven Haryanto writes: >> Although it is generally accepted that Python is slower than >> Java/Perl/Ruby, Bernhard> Well, actually I do not accept this. :) Speed comparisons are I'll try to be short and descriptive ;) wart at penguin:~$ cat test.py print 'Hello, world!' wart at penguin:~$ cat test.pl print "Hello, world!\n"; wart at penguin:~$ time perl test.pl Hello, world! real 0m0.031s user 0m0.030s sys 0m0.000s wart at penguin:~$ time python test.py Hello, world! real 0m0.050s user 0m0.030s sys 0m0.010s wart at penguin:~$ time python -S test.py Hello, world! real 0m0.018s user 0m0.010s sys 0m0.010s P.S. While the real time of the last command was floating from 0.018 to 0.025 between the runs, but it is anyway less than that of perl ;) -- Regards, Wartan. echo "Your stdio isn't very std." -- Larry Wall in Configure from the perl distribution From jkraska1 at san.rr.com Fri Jun 22 22:35:01 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 23 Jun 2001 02:35:01 GMT Subject: Pythoin MUD (PyMUD?) References: <9gqq3t$hvs$1@brokaw.wa.com> <9gqt0r$1q$1@news.mathworks.com> <9h052d$94o$2@brokaw.wa.com> Message-ID: >> You'll also find that if you use Stackless Python (with continuations) >> that you can support a truly awesome level of threads. >Stackless Python... with continuations... Could you point me to an >introduction to that or some docs? http://www.stackless.com I might suggest you look at Microthreads. Once your digesting it all, keep in mind that the reason you can run so many threads in Stackless is that the context-switching cost is trivialized; it's basically a pointer- switch... you don't even have to move registers (including the stack pointer). C// From vdelft at itmasters.com Wed Jun 13 03:47:06 2001 From: vdelft at itmasters.com (vincent delft) Date: Wed, 13 Jun 2001 09:47:06 +0200 Subject: win32pdh to get the PIDs ??? Message-ID: <3B271A7A.D51EB154@itmasters.com> import win32pdh import time while 1: dummy,processes = win32pdh.EnumObjectItems(None,None,'Process', win32pdh.PERF_DETAIL_WIZARD) print "LEN",len(processes) time.sleep(3) I create new processes, but the return still the same. Why this give always the same number of processes ??? (I'm on a W2K with Python 2.1) From kelly.kranabetter at gems6.gov.bc.ca Tue Jun 26 13:52:10 2001 From: kelly.kranabetter at gems6.gov.bc.ca (KellyK) Date: Tue, 26 Jun 2001 17:52:10 GMT Subject: Windows Printing using win32print References: Message-ID: <3b38c6c2.507031753@nntp.gov.bc.ca> On Mon, 25 Jun 2001 15:24:04 -0700, Timothy Grant wrote: >In my first iteration, I simply wrote a text file, then used >os.system('copy filename lpt1:') to print it. This worked just >fine, but one of the variables I need to test is how an >interaction with the actual Windows printers works. To that end >I started reading up on win32print. I was able to come up with >the following... Here is what I use to send HPGL jobs to an HP 1055 plotter. The PJL commands set the job name (so the jobname appears on the printer's LCD screen) and switch the printer into HPGL mode. It has been a while but I seem to remember that I needed to have the switch to HPGL mode even though the "copy file lpt1" style worked. Perhaps you will need something similar? import win32print, os UEL= "\x1b" "%-12345X" # control code to get to PJL p= win32print.OpenPrinter(r"\\server\design10") filename= "blah.000" jobname= os.path.splitext(os.path.split(filename)[1])[0] j= win32print.StartDocPrinter(p, 1, (jobname, None, None)) f= open(filename, "rb") buffer_size= 100000 t= f.read(buffer_size) win32print.WritePrinter(p, UEL + "@PJL JOB NAME = \"" + jobname + "\"\n at PJL ENTER LANGUAGE = HPGL2\n") while t: win32print.WritePrinter(p, t) t= f.read(buffer_size) f.close() win32print.WritePrinter(p, UEL + "@PJL EOJ \"" + jobname + "\"\n" + UEL) win32print.EndDocPrinter(p) win32print.ClosePrinter(p) From daniels at mindspring.com Tue Jun 5 22:51:04 2001 From: daniels at mindspring.com (Alan Daniels) Date: Tue, 05 Jun 2001 22:51:04 -0400 Subject: Python Equivalent of Matlab's size() References: Message-ID: On 5 Jun 2001 14:55:40 -0700, Humanity let out a collective sigh of relief when prem at engr.uky.edu (Prem Rachakonda) finally typed: >What is the Python equivalent of Matlab's size() function. I need >to find the confirm the size of an reshaped array. To my knowledge, there isn't one currently (I take it you mean a function to say how many bytes a particular object is taking up, I'm not sure of what Matlab means by "size"). There's a builtin method proposed in PEP-42 (the answer to Life, the Universe, and Everything): http://python.sourceforge.net/peps/pep-0042.html so you may see something like this in Python 2.2. In the meantime, you can get the number of elements in an array with the "len" function. Won't tell you how many bytes, though. Hope this helps. ============================== Alan Daniels daniels at alandaniels dot com From m.faassen at vet.uu.nl Sat Jun 2 06:37:59 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 2 Jun 2001 10:37:59 GMT Subject: Why isn't Python king of the hill? References: <9f7ai7$b4e$1@newshost.accu.uu.nl> <9f84rr$95m$1@panix2.panix.com> <9f936k$b2q$1@newshost.accu.uu.nl> Message-ID: <9fafm7$bca$1@newshost.accu.uu.nl> Courageous wrote: >>They all involve numbers with points in them.. and when you do math >>with them, the answers may be different. That's about the extent >>of my knowledge. > While I'm sure you didn't mean it this way, I took the whole of your > post as a rather damning condemnation. This sort of confusion is > major bad mo-jo. I meant my post to be humorous. I'm not condemning the need to have predictable rounding behavior when dealing with money, and I am not condemning the need to have fast floating point calculations. I'm also not condemning the need to have predictable-to-newcomers behavior. I think that'd give a motivation for decimals, plain-old-floats and rationals. I think the confusion can be minimized by clear documentation, just like the confusion about unicode (so many encodings) can be. The 'kinds' PEP is interesting in this respect as well. I haven't studied it, but it seems to promise some unification in all this, which would be good. I think it's important who are interested in adding different types of floats to Python consider this or a like-minded proposal (the ability to easily switch an entire calculation to using a different type of floating point number, the ability to have Python complain instantly when you're not mixing them right). Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From jessw at loop.com Fri Jun 22 15:04:50 2001 From: jessw at loop.com (Jesse W) Date: Fri, 22 Jun 2001 12:04:50 -0700 Subject: ANNOUNCE: The Neophyte Pythoneers List In-Reply-To: Message-ID: <3B333462.20537.133A74AA@localhost> Michael Powe wrote: > [posted and mailed] > >>>>> "Jesse" == Jesse W writes: > > Jesse> Dear Pythoneers, (Exactly how should you spell > Jesse> "Pythoneers", anyway?) > > Jesse> I have just now created a mailing list via Yahoo for > Jesse> the sharing, joint debugging and general discussion of > Jesse> Python programs. The list is intended to be primarily for > Jesse> those who have not yet reached expert level in Python > Jesse> programming, but experts are also very welcome. You can > Jesse> join by sending a blank email to: Jesse> > neophyte_pythoneers-subscribe at yahoogroups.com > > Too bad, those people are idiots. You should try setting it up on > your own if you have the resources (like a DSL/cable connection). I I agree; they are pretty insufferable. I set it up with them for two reasons: * They are the largest provider(I think) so more people would see it that way. * I don't have the resources to set a list up on my own. > tried to join your list but the subscription was rejected by yahoo > because I have "too many bounced mails." The geniuses sent me an > EMAIL telling me that I can't subscribe to a list because I have too > many bounced mails. I am really sorry about that. That is nuts. > Well, I get about 70-80 emails a day at home & I have yet to have > anyone but yahoo tell me there is a problem. (In fact, one of them is > a yahoo list! While they are cutting me off, I continue to get mails > from that list!) I used to run my mailing list from there but a > couple weeks ago, I set up MailMan at home & I'm free of that > stupidity. I suggest you do the same. As I said above, I do not have the resources to setup a list on my own. If anyone has an alterative they would like to suggest, I would be glad to hear it. > Anyway, good luck with the list. I'm not going to join, after all, > because I don't want the aggravation of dealing with those morons > anymore. > > mp Sorry about your troubles, Jesse W From greg at cosc.canterbury.ac.nz Mon Jun 25 21:34:49 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Tue, 26 Jun 2001 13:34:49 +1200 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) References: Message-ID: <3B37E6B9.AD859344@cosc.canterbury.ac.nz> Tim Peters wrote: > > [Paul Prescod] > > Did icon switch from eager evaluation of the function to lazy > > evaluation based on the occurrence of a keyword somewhere in the > > function? > > FYI, Icon didn't expose the implementation, so there was no way to tell. In Icon, there isn't any implementation *to* expose. There are no generator-iterators in Icon; the closest equivalent is simply the activation record of a procedure. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From carlf at panix.com Sun Jun 10 13:31:43 2001 From: carlf at panix.com (Carl Fink) Date: 10 Jun 2001 17:31:43 GMT Subject: Use Jython to make true executable? References: Message-ID: In article , Michael Hudson wrote: > This is very unlikely to speed things up as much as you expect. I've > never produced accurate numbers, but I'm fairly sure Python's runtime > is dominated by locating applicable methods, not the dispatch loop in > ceval.c. If you could analyse a program sufficently to compute (some > of) these methods at compile time, *then* you might start to see a > real speed up (especially if this let you unbox some integers & > floats). Yeah, but Jython/gcc wouldn't involve ceval.c at all, would it? I mean, presumably gcc would compile the methods themselves, and in an optimized manner. -- Carl Fink carlf at dm.net From sasrrx888er_666 at yahoo.com Fri Jun 1 18:34:33 2001 From: sasrrx888er_666 at yahoo.com (sasrrx888er_666 at yahoo.com) Date: Fri, 1 Jun 2001 22:34:33 +0000 (UTC) Subject: News from ANNA KOURNAKOVA !!! Message-ID: <9f959o$3ku$1105@news.ukr.net> ANNA KOURNAKOVA NEW Anna Kournikova - Topless!!! Brand new Anna topless shot collection, these are totally genuine and show just what an amazing arse and tits she has!!!! Totally exclusive to McCelebs, sneaked papparazzi shot of the tennis super minx sunbathing topless, Beutiful tits!! Unbelievable body!!. This one can't be missed Picture Watch Anna show her bra and panties during this match Movie New in shot of Anna showing just how sweaty a game of tennis can be!!!! http://darkhole.com/celebsserf http://darkhole.com/celebsserf Hutchence fucks Paula Yates up the ass!!new! Amazing shots never seen on the web - plus shots of Paula giving INXS singer a blow job. http://darkhole.com/celebsserf Prince Edwards bride flashes her tits!!new! Candid topless shots of the latest addition to the Royal Family! http://darkhole.com/celebsserf PAMELA Fucks Brett Michaels!!new! She's at it again... this time fucking and sucking 9 inches of pussy splitting meat attached to Poison's lead singer - Video and stills are even better than Pam & Tommy! http://darkhole.com/celebsserf From paulp at ActiveState.com Fri Jun 15 18:54:33 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 15 Jun 2001 15:54:33 -0700 Subject: Any other Python flaws? References: <3B2A530C.5F798823@bioreason.com> <3dvglxe9j3.fsf@ute.cnri.reston.va.us> <3B2A8CD6.DB8AEF5C@bioreason.com> Message-ID: <3B2A9229.D87C627A@ActiveState.com> Mitch Chapman wrote: > >... > > I need to manage long-running, parameter-rich computations from > GUI applications while still responding to the user. I think I > need threads because they make it easier to exchange all of those > parameters between the GUI controller and the background computation > than do separate processes. I think I need processes because I > need to be able to cancel the background computation. When I need to do something like that I do this: while not self._cancel: do_more_computation() Then I let the controller thread flick the do_more_computation switch. This is not convenient but it not as inconvenient as separate processes. Even if it takes a second for the UI to tell the background process to halt, that is better than hanging the *entire UI* for a second at a time. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From fgeiger at datec.at Wed Jun 27 02:25:23 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Wed, 27 Jun 2001 08:25:23 +0200 Subject: MySQLdb module & error capturing References: Message-ID: <9hbube$ok1$1@newsreaderm1.core.theplanet.net> Hi Paula, if you import _mysql you can catch the exceptions like so: import _mysql try: customer.store().saveChanges() except _mysql.OperationalError, e: if e[0] == 1048: showerror("Error", "Missing some data!") return 0 else: raise Hope this helps. Regards Franz wrote in message news:mailman.993583119.2912.python-list at python.org... > I'm a little bit of a newbie so if this belongs on another list let > me know. > > I am trying to capture a _mysql.OperationalError that is returned by > the MySQLdb module so that I can process it through error handling. > Or even just print out the one bit (the error number and the error > text) with out having the 5 layered traceback message showing every > layer of my program. Sample error at bottom. > > I have tried looking at the MySQLdb module and I have not noted > direct error passing back to the calling program from the C API. > > Anyone else know the answer? > > I have been looking at the traceback module but I don't know enough > about it to really figure this out. > > Thanks for your help, > Paula > > ****Sample Code > >>> causeerror=decur.execute("select everything from everywhere") > Traceback (most recent call last): > File "", line 1, in ? > File "/usr/local/lib/python2.1/site-packages/MySQLdb.py", line 190, > in execute return self._query(query) > File "/usr/local/lib/python2.1/site-packages/MySQLdb.py", line 290, > in _query > rowcount = self._BaseCursor__do_query(q) > File "/usr/local/lib/python2.1/site-packages/MySQLdb.py", line 235, > in __do_query > db.query(q) > _mysql.OperationalError: (1146, "Table 'ZimbuT.everywhere' doesn't > exist") > > > From db3l at fitlinxx.com Fri Jun 29 17:24:00 2001 From: db3l at fitlinxx.com (David Bolen) Date: 29 Jun 2001 17:24:00 -0400 Subject: Augmented Assignement (was: Re: PEP scepticism) References: Message-ID: Carsten Geckeler writes: > The problem which some people have with augmented assignment is not that > they exist, but that they do not work as they expect (at least from the > POV of some readers). I expect that > ident op= expr > works like > ident = ident op expr > > At least that's what I'd have expectd comming from other programming > languages. Of course, one interesting point is that while you may think the above if coming from, say, C, what "ident = ident op expr" means in C is not what "ident = ident op expr" means in Python. In C it has the result of changing data (in either case) that is stored in a named location ident, in Python the long form just rebinds the reference ident to a new object and doesn't touch the original object. The short form can actually get closer to the C idiom if the object is mutable. So I wonder if some of the confusion is people familiar with other language's augmented assignment trying to extrapolate that into Python and then running into the pre-existing differences in assignment versus binding? -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From gustafl at algonet.se Mon Jun 25 19:11:32 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 25 Jun 2001 23:11:32 GMT Subject: Should I use a dictionary? Message-ID: I have an object type for e-mail messages based on the rfc822 module. After picking out some messages from several sources, I want to sort them in order of the date property of the message object (as far as I understand, everything in this process needs to be kept in memory). Anyway, the problem is that I need some hints about how to sort the messages, as they are not sorted in way I get them. One idea I came up with was to put the date property of the message object as a key in a dictionary, and let the rest of the message be the value! But even if it would work, I think it's ugly. If someone can convince me that it's not ugly, or give a better (i.e. faster) solution, I'd be happy. Regards, Gustaf Liljegren From triwest1995 at yahoo.com Wed Jun 13 07:45:35 2001 From: triwest1995 at yahoo.com (triwest1995 at yahoo.com) Date: Wed, 13 Jun 2001 04:45:35 -0700 (PDT) Subject: Yahoo! Auto Response Message-ID: <20010613114535.57906.qmail@mta494.mail.yahoo.com> Re: Password for Triwest1995 members Thank you for your email. Our system can't recognize your member number. Please check your file and re-submit again. Triwest1995 is not associated with a company called Triwest Invetment Club. Please indicate in your request member including member number who invited you to this private site. If you received no invitation, please indicate in your request "No Invitation more info please". Here's a lot of information about our company and what is planned for our prelaunch real soon. http://www.geocities.com/triwest1995 Our main allies are doing their final checking and we will have 100% confirmation that this is THE REAL DEAL----SOON! Our Card will have worldwide instant credibility. Imagine getting paid residual everytime someone uses a visa debit card and backed up and endorsed by a huge major financial institution on all transaction. Thank you. There will be no further communication from this office, until we here back from you. Sincerely yours, Triwest1995, Management (PLEASE NO SPAM) -------------------- Original Message: >From python-list-admin at python.org Wed Jun 13 11:45:35 2001 Return-Path: X-Track: -10 Received: from mail.python.org (63.102.49.29) by mta494.mail.yahoo.com with SMTP; 13 Jun 2001 04:45:33 -0700 (PDT) Received: from localhost.localdomain ([127.0.0.1] helo=mail.python.org) by mail.python.org with esmtp (Exim 3.21 #1) id 15A92A-0002BB-00; Wed, 13 Jun 2001 07:42:02 -0400 From: python-list-request at python.org Subject: Python-list digest, Vol 1 #6370 - 15 msgs Reply-to: python-list at python.org X-Mailer: Mailman v2.0.5 (101270) MIME-version: 1.0 Content-type: multipart/mixed; boundary=10.0.11.1.506.7545.992432481.025.14977 To: python-list at python.org Sender: python-list-admin at python.org Errors-To: python-list-admin at python.org X-BeenThere: python-list at python.org X-Mailman-Version: 2.0.5 (101270) Precedence: bulk List-Help: List-Post: List-Subscribe: ; from aleaxit@yahoo.com on Thu, Jun 28, 2001 at 05:47:03PM +0200 References: <9gk8he$8gl$1@brokaw.wa.com> <16074dce.0106181045.139d80a5@posting.google.com> <3b3b40a0@news.uia.ac.be> <9hfjho05to@enews1.newsguy.com> Message-ID: <20010629084424.B28416@fangorn.csse.monash.edu.au> On Thu, Jun 28, 2001 at 05:47:03PM +0200, Alex Martelli wrote: > Very interesting -- NOW, is there a way one can develop Python > software, cross-platform, using Qt, and redistribute it: legally, > for free and with sources? > You should have a look at PyQt. For some reason it's relatively unknown, despite being (IMHO) the best and most elegant set of bindings for developing GUI applications with python. The Qt bindings are much more organised and featureful than I remember tkinter being. They're also much more objectlike than gtk, and they don't exhibit the windows legacy that the wx toolkit does, with all the attendent problems of multiple dispatch from a single event, and needing to make up magic numbers for internal events. Apparently Phil Thompson is going to be making win32 binaries of the PyQt modules available sometime soon, to save people who don't want to compile it themselves some effort. PyQt should also be available for mac development, given that Qt is free for the mac as well, but I don't think I've ever heard of anyone trying to build it there. Toby. From kbk at shore.net Tue Jun 12 09:55:09 2001 From: kbk at shore.net (Kurt B. Kaiser) Date: Tue, 12 Jun 2001 13:55:09 GMT Subject: New to python References: <9g53qh$qhl$1@news.kodak.com> Message-ID: Hi Karim, Well, for starters, I'd recommend going over to the www.python.org web page and reading the section titled "Top Documentation Links." Regards, KBK From MarkH at ActiveState.com Tue Jun 19 19:21:50 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 19 Jun 2001 23:21:50 GMT Subject: Help, pls: COM local server factory class References: Message-ID: <3B2FDE8D.5070700@ActiveState.com> Bill Bell wrote: > In response to your suggestion I've started on a different tack. > Having lent your Win32 book to a colleague I grabbed its Chapter > 12 "Final Sample" code from the O'Reilly site. I launched the > Python code from within PythonWin and got "Registered: > PythonDemos.Parent (for debugging)"--which was encouraging. > Then I launched the VBA code (minus the comments since I never > use 'em) from within MS Excel and it croaked on the first line (ie, > Set ParentObj = CreateObject("PythonDemos.Parent")) with > "Unexpected Python Error: exceptions.SystemError: NULL result > without error in call_object". This is a bug in the win32trace module, which is used in "debugging" mode. It has been fixed in the most recent ActivePython and win32all builds. Mark. From graham at coms.com Tue Jun 19 19:50:14 2001 From: graham at coms.com (Graham Ashton) Date: Wed, 20 Jun 2001 00:50:14 +0100 Subject: Loading select queries into objects References: Message-ID: In article , "Steve Holden" wrote: > From http://www.lyra.org/greg/python/: > > """dtuple.py > This module wraps up return tuples from the fetch* methods in the Python > Database API. Using this class, the return tuples can be treated as > tuples, dictionaries, or objects with attributes corresponding to the > column names. Thanks for that - very interesting link. I've been playing with dtuple a bit and have managed to get it to work fine by ripping off the standard example. Here's what I've got: rows = cursor.fetchone() tdesc = dtuple.TupleDescriptor(cursor.description) rows = dtuple.DatabaseTuple(tdesc, rows) dict = rows.asMapping() print dict It works great. When it prints things out they look like this: {'col1': 234, 'col2': 'foo', 'some_col': 9473.0} No, my question would be how would I take the above dictionary and convert it into calls to a col1(), col2() and some_col() methods (in the current class). I've tried the following and am completely fathomed as to why the second parameter (i.e. the value of dict['key']) doesn't get passed to the method that I'm calling. for key in dict.keys(): code = "apply(self.%s(), (self, dict['%s']))" % (key, key) print code eval(code) The code printed looks like this: apply(self.col1(), (self, dict['col1'])) The only problem is that when it's evaluated the self.col1() method doesn't get passed the value of dict['col1'], though self.col1() is called. Is there something I don't know about eval()? I've read up on it but don't see anything relevant... Should eval() do the trick here? Thanks. From rnd at onego.ru Tue Jun 12 07:03:44 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 12 Jun 2001 15:03:44 +0400 (MSD) Subject: [Python-Dev] PEP 259: Omit printing newline after newline In-Reply-To: <9g4nec0cnr@enews2.newsguy.com> Message-ID: On Tue, 12 Jun 2001, Alex Martelli wrote: >"Roman Suzi" wrote in message >news:mailman.992325753.25339.python-list at python.org... >> On Mon, 11 Jun 2001, Glyph Lefkowitz wrote: >Another reason to make something a statement is when >the 'something' contains one or more blocks of code >and/or affects control flow. class, def and for meet >this test too. while, if, try, raise, break, return, >continue -- all affect control flow. pass can also >be seen this way -- it has NULL effect on control flow >(or anything else), making it a suitable place-holder >and allowing Python to avoid the syntax problems that >come with a "null statement" like in C & descendants. > >So, summarizing: in Python, keyword statements either >affect the namespace using them, or affect the control >flow that uses them. > >All, that is... except ONE. > >That one is: print. A keyword statement that neither May be allow to call functions as statements then? Then there will be no difference: print 1, 2, 3 or print(1, 2, 3) Or: write file, "this is line" Oh... It will be Tcl then... No, no! Do not take print away! It help to migrate from Basic! ;-) Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, June 12, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "My cat likes to play Hide-And-Go-Poop." _/ From gregj at pdxperts.com Mon Jun 25 23:39:07 2001 From: gregj at pdxperts.com (Greg Jorgensen) Date: Tue, 26 Jun 2001 03:39:07 GMT Subject: new to python References: Message-ID: Start at www.python.org. All of your questions are answered there. Greg Jorgensen PDXperts LLC Portland, Oregon USA "Beebe" wrote in message news:a5924ddc.0106251918.7f119c31 at posting.google.com... > Hello comp.lang.python, > > I am a Linux User and I am new to Python Programming and this > newsgroup. I don't really know what python is all about so it would be > much appreciated if you would answer my following questions. > > - Is python like c/c++ where you can make pretty much any kind of > program you want whether is be games, gui apps, etc. or is it like cgi > where you can only use it in websites? > > - Is python object oriented? > > - Should I develop in Python? Is it good for programming, is it > powerfull and are job opportunities good for Python developers? > > - When I make a Python program, do I just leave it as a .py file or is > there a way to make it into some kind of executable file like in C++? > When I make a program in Python, how do I distribute it out to people? > Do I just send out the .py file? Does the user need some kind of > runtime environment or something? Do they need to download something > else rather than my program? > > I know that's a lot of questions but I haven't found them on the net > yet. Please answer my questions if you will by emailing me at > jonbeebe at softhome.net. > > If you email me, that way I'll be sure to recieve the reply, > otherwise, i might miss it. > > Thank you very much, > - Beebe From rnd at onego.ru Mon Jun 18 11:59:33 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 18 Jun 2001 19:59:33 +0400 (MSD) Subject: Function lookup using a directory. In-Reply-To: <29pX6.14682$cF.320097@news1.nokia.com> Message-ID: On Mon, 18 Jun 2001 andy.pevy at nokia.com wrote: > Hi Guys > > I am having trouble with the directory data type. What I want to > do is to set up a directory that I can use to parse a command entered by > the user, and have a directory return the name of a class to handle the > command. Like this :- > > > command_table = {'0': 'Help0', > '1': 'Help1', > '2': 'Help2', > '3': 'Help3' } > > class Help0: > > def run(self,which): > if len(which) == 1: > print 'Help no args' > else: > print 'Help args' > > class Help1: > > def run(self,which): > if len(which) == 1: > print 'Help1 no args' > else: > print 'Help1 args' > > class Help2: > > def run(self,which): > if len(which) == 1: > print 'Help2 no args' > else: > print 'Help2 args' > > class Help3: > > def run(self,which): > if len(which) == 1: > print 'Help3 no args' > else: > print 'Help3 args' Brrrr... Maybe: class Help: noargs = "no such command" args = "no such cmd" def run(self,which): if len(which) == 1: print self.noargs else: print self.args class Help0: noargs = "blah blah ..." args = "balh x blah y ..." ... Then just this: command_table = { '0': Help0, '1': Help1, '2': Help2, '3': Help3, } > if __name__ == '__main__': > > command = user_input() > > try: > h = command_table[command[0]] > except: > print command[0]+' not found' h = command_table[command[0]] h.run() > So, a couple of questions please..... > > Can I do this, I.E. have a class as a value in a dictionary > and if so, what would the correct declaration be. > > Thanks. > > > Andy Pevy > A Very Beginner Pythoneer. Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From s713221 at student.gu.edu.au Tue Jun 12 07:17:01 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Tue, 12 Jun 2001 21:17:01 +1000 Subject: Rejected Message References: Message-ID: <3B25FA2D.504AAA10@student.gu.edu.au> *laughs* I get the feeling that this was an automated reject. I had to use the find button on netscape to locate the word(s)/phrase(s). Do I get a prize? Shame on you Mark, you're one thoughtless signature among hundreds is giving comp.lang.python a REALLY bad reputation. Administrator at crescere.co.uk wrote: > > The attached mail message has been rejected for the following reason: > > Body contained word(s)/phrase(s): fuck, shit > > Additional Information: ---------------------------- humungous snip ----------------------------------- > -- > Mark Hughes > "I will tell you things that will make you laugh and uncomfortable and really > fucking angry and that no one else is telling you. What I won't do is bullshit > you. I'm here for the same thing you are. The Truth." -Transmetropolitan #39 > ------------------------ 'nother humungous snip ------------------------------- > http://mail.python.org/mailman/listinfo/python-list > > --10.0.11.1.506.26899.992060161.502.12034-- > > End of Python-list Digest -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From no at spam.com Fri Jun 29 15:32:28 2001 From: no at spam.com (MDK) Date: Fri, 29 Jun 2001 15:32:28 -0400 Subject: Simple question (launch a program) References: <9hf6v6$ps0$1@taliesin.netcom.net.uk> <9hf868$941$1@newsreaderg1.core.theplanet.net> Message-ID: <9hil2h$3qa$1@taliesin.netcom.net.uk> "Franz GEIGER" wrote in message news:9hf868$941$1 at newsreaderg1.core.theplanet.net... > Did you try os.system()? > > Regards > Franz > Yes. If I do >>> system("notepad") notepad launches and I get a return code of 0. However, if I do: >>> system("C:\Program Files\KeyNote\keynote.exe") I get a return code of 1 and nothing happens. From foo at ix.netcom.com Sun Jun 24 04:01:20 2001 From: foo at ix.netcom.com (Matt Butler) Date: 24 Jun 2001 01:01:20 -0700 Subject: How useful do you find the interactive interpreter? References: <4688f24b.0106231658.43d2c446@posting.google.com> Message-ID: <50be6f7c.0106240001.112a1da1@posting.google.com> slaytanic_killer at disinfo.net (slaytanic killer) wrote in message news:<4688f24b.0106231658.43d2c446 at posting.google.com>... > I am looking at Python seriously, and I can see that the interpreter > would be really good for testing out ideas. Getting small things to > work and then switching over to a text editor to generalize what I've > learned. Is this how people generally use it? Or is it an even > deeper part of coding? It is definitely useful in that exact way. Frequently I leave it open in addition to my editor, mainly for testing syntax before sticking it deep down in hard to reach parts of larger projects. From BPettersen at NAREX.com Tue Jun 19 11:45:17 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Tue, 19 Jun 2001 09:45:17 -0600 Subject: nested classes Message-ID: <6957F6A694B49A4096F7CFD0D900042F27DB7A@admin56.narex.com> > From: Skip Montanaro [mailto:skip at pobox.com] > > Bjorn> But that's an implementation detail only, since it works > Bjorn> perfectly for functions: > > Bjorn> def foo(): > Bjorn> foo() > > Only because at the point that foo calls itself recursively, > the definition > of foo is in the module's global symbol table, assuming foo > is def'd at the > module scope. If foo is nested inside another function, it can't call > itself directly without some help from the function it's enclosed in. And since this was/is changed with the latest implementation, it is an implementation detail.. no? [snip example] > When defining a class, the code within the class's scope is executed > immediately, before a class object has been bound to the class's name. Which is the implementation detail. You could easily envision an implementation that first binds the class name to a skeleton class object that only contains enough information for the class to be self-referential. Other languages do this, so it's perfectly possible. I'm not going to argue whether it's a good idea in Python or not . -- bjorn From ullrich at math.okstate.edu Sun Jun 3 11:32:15 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 03 Jun 2001 15:32:15 GMT Subject: random References: <9fcu3601vet@enews2.newsguy.com> Message-ID: <3b1a564f.2986926@nntp.sprynet.com> On Sun, 3 Jun 2001 10:53:27 +0200, "Alex Martelli" wrote: [...] > >But the method summarily given in the Sci.Am paper does show how >to program the computation of any given bit of Omega I was about to say "what??? No, that's impossible." I read on: [...] > but some would say the finite >program is not "an algorithm" because it's not finite in time -- it >may never halt Halting _is_ part of the standard definition of "algorithm"; this is not what "some" would say. There's a _reason_ it's part of the definition. Elsewhere you've claimed to be an engineer, seeming to imply you're interested in practical matters. If you have a solution to a problem but the "solution" takes infintely much time does it really seem like a _useful_ solution in practical terms? Like say we want to use Omega to give a "perfect" arithmetic RNG. We can do that. Except that when we call x = rand() the call _never_ _returns_. If you're really interested in RNG's that never return then I take back everything I've said, yes, JVN was wrong, there's no problem with arithmetic RNGeneration. [...] >So where's the "state of sin" in this arithmetical and almost-algorithmical- >except-for-the-little-detail-of-finiteness approach to randomness? The quote from JVN was about someone _using_ arithmetic methods to generate random numbers. If someone is "using" an RNG that _never_ _returns_ then he is _not_ generating random numbers. (A fortiori he is not using arithmetic methods to generate random numbers.) >Alex > > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From aoshineye at digitas.com Thu Jun 7 08:24:16 2001 From: aoshineye at digitas.com (Adewale Oshineye) Date: 7 Jun 2001 05:24:16 -0700 Subject: Windows editor? References: <3AF734D5.AEF6F369@sympatico.ca> Message-ID: Brandon, Various people have already recommended Scite (http://www.scintilla.org/SciTE.html) which uses the Scintilla text editing component(http://www.scintilla.org/). The same component is also used by PythonWin and Moleskine (http://www.moleskine.f2s.com/). Scite has various useful features including auto-completion, python-aware indentation, folding (which is really useful) and it's cross-platform. Scite also happens to be free. From just at letterror.com Fri Jun 8 13:57:19 2001 From: just at letterror.com (Just van Rossum) Date: Fri, 08 Jun 2001 19:57:19 +0200 Subject: spell method chaining? References: <19l8IVAAgJI7EwAk@jessikat.demon.co.uk> Message-ID: <3B2111FF.D998EEE4@letterror.com> Remco Gerlich wrote: > > Robin Becker wrote in comp.lang.python: > > I wish to create wrapped classes dynamically and have the wrapper class > > refer to the base wrapee class methods. > > > > def gen(B): > > class W(B): > > def __init__(self): > > B.__init__(self) > > return W > > > > this works if nested scopes is on so that the reference to B in the > > __init__ refers to the argument of gen, but it fails without it unless B > > happens to be a global. I thought of using self.__class__.__bases__[0] > > to refer to the dynamic base B, but then that fails if I use the > > resultant class as a base class. > > > > ie if I try > > > > def gen(B): > > class W(B): > > def __init__(self): > > self.__class__bases__.__init__(self) > > return W > > > > I get trouble (infinite looping) with gen(gen(B))() > > > > What is the correct way for dynamic classes to refer to their immediate > > base class methods to allow method chaining etc. > > Usually you know that the base class is called eg Klass, and you simply call > that. In this case I think you have to store it inside the class manually, > like this: > > def gen(B): > class W(B): > def __init__(self): > self.__base.__init__(self) > W._W__base = B > return W > > (not the automatic 'name munging' the self.__base does, this way the > attribute is somewhat protected from classes inheriting it) You can avoid that by spelling it like this: def gen(B): class W(B): __base = B def __init__(self): self.__base.__init__(self) return W Just From dan at eevolved.com Mon Jun 18 23:20:52 2001 From: dan at eevolved.com (dan) Date: Mon, 18 Jun 2001 23:20:52 -0400 Subject: getting a reference to a class inside its definition References: <9noX6.14930$uR5.1138042@news20.bellglobal.com> <9gl7va$s1p$1@news1.wdf.sap-ag.de> Message-ID: Daniel Dittmar wrote: >> Still, I want to be able to reference a class inside it's own definition. >> Is this possible or am I going to have to do > > It depends on what you try to achieve. If you want to access class > variables inside the class definition, do so without any qualification: > > class SomeClass: > hello = 'hello' > world = 'world' > greeting = hello + ', ' + world > > print SomeClass.greeting > > Daniel Did you know you could also do this: class SomeClass: dict = {} dict[1] = "Some value" dict["some key"] = 100 print SomeClass.dict {1: "Some value", "some key": 100} Dan From aleaxit at yahoo.com Tue Jun 12 09:08:23 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 12 Jun 2001 15:08:23 +0200 Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: Message-ID: <9g5486016t4@enews2.newsguy.com> "Chris Gonnerman" wrote in message news:mailman.992346739.24842.python-list at python.org... > From: "Roman Suzi" > > No, no! Do not take print away! It help to migrate from Basic! ;-) > > This is the best single reason I can see OTHER than not breaking existing > scripts. > Not just BASIC, but Perl, and SO MANY other languages have a print > statement. Ah, yes. Perl compatibility is definitely a must, isn't it...? Not VB, because that has no "print statement" -- is has a "print #" statement, and the #filenumber part is mandatory; it writes to a disk file. Not C, which uses a printf *FUNCTION*. Not C++ (which uses the << operator). Not Java. If compatibility or migration help from other languages is "the best reason" (apart from not breaking working code) for print's existence as a statement, then it seems the reasons in print's favour are even weaker than I thought. Meanwhile, there ARE people out there (beginners, but not idiots:-) who might like print to PRINT -- yet when they use it, their printer doesn't do anything... stuff gets displayed on-screen, NOT printed. Those guys and gals have never seen a 'printing terminal', and this idiomatic usage of a verb which DOES have an obvious, different, and perfectly current meaning in 'computerese' is hardly a good idea in a CP4E setting. > IMHO Alex's output() function is not really necessary. If you hate print, > use fileobj.write(), and leave us print-users alone. Several built-in functions "are not really necessary". Why have dir(x) when vars(x).keys() is equivalent, for example? Speed, convenience, solidity. If an output function were defined, it could play the same role wrt the print statement as __import__ plays wrt the import and from statements. The statement would remain (of course: breaking a vast majority of all scripts would be silly), *AND* it would be defined and documented to internally invoke the function. So the programmer gets a chance to "override" the function and get a global effect even when another module used the statement instead. Perhaps, in this spirit, the function should be named __print__, then. > Aesthetics alone are not a good enough reason for such a fundamental and > painful change. Absolute agreement here! Aesthetics are shifty, and a frail reed indeed. Hardly good reason for ANY change (for doing things right in the first place, maybe, but not even Guido can get 100% right -- yet he has a far better track record in taking right design decisions than anybody else I've ever met or heard about:-). But the statement/function distinction is NOT chiefly about "aesthetics". It IS chiefly about functionality. print has no real reason to exist as a statement, but, OK, it get grandfathered in (note that this would argue for leaving the default to respect-all-newlines, rather than Guido's new idea of removing SOME newlines). Having print as a statement gives no real advantage, but it does give some disadvantages _unless_ the underlying functionality can be tweaked. You can do MANY tweaks by using a wrapped file-like-object as stdout, but NOT all -- the file-object is not "told" about how many print statements are being processed, so it can't do such tweaks as the one that is now being proposed by Guido. A __print__ underlying function would solve that. Having a friendly name such as output is nice but secondary. So why don't I write my output() function and just use it? That's not enough, because I use a lot of code I did not write -- and that code "coming from outside" is not going to use MY private conventions. If it uses (overtly or indirectly) a built-in function, I get a chance to wrap that and make the code-from-outside of some use for my purposes. Otherwise, I'm SOL. See why one should use isinstance(x,y) even when y is a type-object, for example? Why not just type(x)==y? *Because* the latter idiom is not sensibly tweakable non-invasively -- I can hardly wrap/override type() without knowing what's going to be done with its result. I _can_ at least wrap isinstance, and thus defeat some of the typechecks that may be killing me in external code I'm reusing...:-). [Maybe not the best of examples, because it's STILL a bother, but, until and unless we get PEP 246, it's gonna be hard to uproot typechecks altogether:-)]. Alex From nhodgson at bigpond.net.au Sun Jun 24 03:24:31 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Sun, 24 Jun 2001 07:24:31 GMT Subject: zodb install problem on Windows Message-ID: I have just downloaded a recent (16/June) version of zodb from amk.ca. Most of it builds and installs but running "setup.py install" in the zeo directory on Windows gives: ... running install_data not copying zeo.conf (output up-to-date) Traceback (most recent call last): File "G:\Downloads\zodb\ZEO\setup.py", line 35, in ? data_files = [("etc", ["zeo.conf"]), File "c:\python21\lib\distutils\core.py", line 138, in setup dist.run_commands() File "c:\python21\lib\distutils\dist.py", line 899, in run_commands self.run_command(cmd) File "c:\python21\lib\distutils\dist.py", line 919, in run_command cmd_obj.run() File "c:\python21\lib\distutils\command\install.py", line 484, in run self.run_command(cmd_name) File "c:\python21\lib\distutils\cmd.py", line 328, in run_command self.distribution.run_command(command) File "c:\python21\lib\distutils\dist.py", line 919, in run_command cmd_obj.run() File "c:\python21\lib\distutils\command\install_data.py", line 60, in run dir = convert_path(f[0]) File "c:\python21\lib\distutils\util.py", line 87, in convert_path raise ValueError, "path '%s' cannot be absolute" % pathname ValueError: path '/etc/rc.d/init.d' cannot be absolute Which is caused by the Unix specific: data_files = [("etc", ["zeo.conf"]), ("/etc/rc.d/init.d", ["misc/zeo"]), ("/usr/local/bin", ["misc/zeod"]), ] Any ideas on how to install on Windows? Neil From guido at digicool.com Mon Jun 11 16:07:40 2001 From: guido at digicool.com (Guido van Rossum) Date: Mon, 11 Jun 2001 16:07:40 -0400 Subject: PEP 259: Omit printing newline after newline Message-ID: <200106112007.f5BK7eW22506@odiug.digicool.com> Please comment on the following. This came up a while ago in python-dev and I decided to follow through. I'm making this a PEP because of the risk of breaking code (which everybody on Python-dev seemed to think was acceptable). --Guido van Rossum (home page: http://www.python.org/~guido/) PEP: 259 Title: Omit printing newline after newline Version: $Revision: 1.1 $ Author: guido at python.org (Guido van Rossum) Status: Draft Type: Standards Track Python-Version: 2.2 Created: 11-Jun-2001 Post-History: 11-Jun-2001 Abstract Currently, the print statement always appends a newline, unless a trailing comma is used. This means that if we want to print data that already ends in a newline, we get two newlines, unless special precautions are taken. I propose to skip printing the newline when it follows a newline that came from data. In order to avoid having to add yet another magic variable to file objects, I propose to give the existing 'softspace' variable an extra meaning: a negative value will mean "the last data written ended in a newline so no space *or* newline is required." Problem When printing data that resembles the lines read from a file using a simple loop, double-spacing occurs unless special care is taken: >>> for line in open("/etc/passwd").readlines(): ... print line ... root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin: daemon:x:2:2:daemon:/sbin: (etc.) >>> While there are easy work-arounds, this is often noticed only during testing and requires an extra edit-test roundtrip; the fixed code is uglier and harder to maintain. Proposed Solution In the PRINT_ITEM opcode in ceval.c, when a string object is printed, a check is already made that looks at the last character of that string. Currently, if that last character is a whitespace character other than space, the softspace flag is reset to zero; this suppresses the space between two items if the first item is a string ending in newline, tab, etc. (but not when it ends in a space). Otherwise the softspace flag is set to one. The proposal changes this test slightly so that softspace is set to: -1 -- if the last object written is a string ending in a newline 0 -- if the last object written is a string ending in a whitespace character that's neither space nor newline 1 -- in all other cases (including the case when the last object written is an empty string or not a string) Then, the PRINT_NEWLINE opcode, printing of the newline is suppressed if the value of softspace is negative; in any case the softspace flag is reset to zero. Scope This only affects printing of 8-bit strings. It doesn't affect Unicode, although that could be considered a bug in the Unicode implementation. It doesn't affect other objects whose string representation happens to end in a newline character. Risks This change breaks some existing code. For example: print "Subject: PEP 259\n" print message_body In current Python, this produces a blank line separating the subject from the message body; with the proposed change, the body begins immediately below the subject. This is not very robust code anyway; it is better written as print "Subject: PEP 259" print print message_body In the test suite, only test_StringIO (which explicitly tests for this feature) breaks. Implementation A patch relative to current CVS is here: http://sourceforge.net/tracker/index.php?func=detail&aid=432183&group_id=5470&atid=305470 Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil End: From robin at jessikat.fsnet.co.uk Tue Jun 26 03:35:39 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Tue, 26 Jun 2001 08:35:39 +0100 Subject: Running slower in win2k Tkinter Message-ID: <$HBeGIALtDO7EwzP@jessikat.fsnet.co.uk> I have a Tkinter app that needs to run a search over a set of packages. Basically the search imports all the modules finds all objects and sorts into a set of dictionaries. There is no interaction with tk, but when run in the tk app the search takes 5-6 times longer than when run directly without the tk windows. The Tkinter app isn't threaded and appears fully blocked while the computation takes place. I expect some slowdown in Tkinter as it must respond to messages etc, but the difference 1.51" vs 10.72" seems way too large. What am I missing? -- Robin Becker From bokr at accessone.com Sat Jun 23 14:37:38 2001 From: bokr at accessone.com (Bengt Richter) Date: Sat, 23 Jun 2001 18:37:38 GMT Subject: Getting all client http headers References: <3B2F1A51.EC21BD1C@nokia.com> Message-ID: <3b34e06d.92449134@wa.news.verio.net> On Tue, 19 Jun 2001 08:22:51 GMT, Joonas Paalasmaa wrote: >How can I get all client http headers in python. >Can I use cgi-module? > >-Joonas For a quick and dirty look at what your browser is sending the server (though this won't show post method content), try putting this in the cgi-bin directory of your server site, and look at it via browser at http://--your-site-goes-here--/cgi-bin/test.py #!/usr/bin/python print 'Content-type: text/plain\n' import sys for i in xrange(len(sys.argv)): print "arg[%d]=%s" %(i,sys.argv[i]) import os for k in os.environ.keys(): print k,'=',os.environ[k] From aleaxit at yahoo.com Fri Jun 1 15:28:43 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 1 Jun 2001 21:28:43 +0200 Subject: infinite precision (was Re: Against PEP 240) References: <9f51p601lqg@enews2.newsguy.com> <9f5fpf$qo9$1@panix2.panix.com> <9f5lrt026g6@enews2.newsguy.com> <200106011658.MAA03564@panix3.panix.com> Message-ID: <9f93p801ioh@enews1.newsguy.com> wrote in message news:200106011658.MAA03564 at panix3.panix.com... > [posted & e-mailed] > > First of all, let me apologize. My original comment was intended to be > teasing, and I'm sorry this has descended into heavy-handedness. Please let me apologize in return for my own contribution to the heavy-ing (now THAT is a doubtful word indeed!-) of the exhange. Originally I had thought it just funny that a widely used dictionary happened to use identical words in its first definitions for both "unbounded" and "infinite" (reflecting the words' history, btw: "infinite" means, exactly and literally, "without boundaries" in Latin:-), but when it turned to "standard definitions used in CS" it started to look as if readers might get the wrong idea about what (at least several) computer scientists actually use. Every reader of this newsgroup knows I make enough mistakes that I can't _afford_ to get in a huff just because somebody calls me on one... indeed, I'm grateful! But exactly because I make so many true mistakes, I'd rather not be considered in error in one of the cases where [I think] I'm not:-). > program, but I can't argue with the weight of publications you found. > It still doesn't feel right to me, though. I don't claim it's "right". It MIGHT be useful to have different terms to distinguish (at least for non-integral numbers, I guess) "really infinite" cases (constructive reals, I guess) from the common "without _predefined_ limits" current usage of "infinite" (or "unbounded") "precision". But then, who ever thought natural language was based on what is "right"? (Ah, NOW we can have a really heated debate on descriptive versus prescriptive schools of natural language study...:-). Alex From jm7potter at hotmail.com Wed Jun 13 09:14:09 2001 From: jm7potter at hotmail.com (jm7potter at hotmail.com) Date: Wed, 13 Jun 2001 09:14:09 -0400 Subject: a newbie question about gadfly References: <9g5cpo$62$1@plutonium.compulink.co.uk> Message-ID: On 12 Jun 2001 15:34:16 GMT, gbreed at cix.compulink.co.uk wrote: >In article , >jm7potter at hotmail.com () wrote: > >> Why? is namex not a direct replacement for "donna" ???? > >Um, no, not the way you're doing it. Try replacing that magic >line with > >cursor.execute( > "insert into students (name, grade) values (%s, %s)" > % (namex, gradex)) > >Or even > >cursor.execute("insert into students (name, grade) values >(%(namex)s, %(gradex)s)" % vars()) > >(that's sure to wordwrap!) > > > Graham Thanks for the help Graham, However, your code did not work either. The little program chokes every time I try to do anything that is not "hard-wired" into the script. Oddly, the books that mention gadfly do not attempt anything but hard-wired code. Perhaps they know something? Hammond & Robinson cover gadfly in their "Python: programming on Win32" (pp. 256 -259) but never attempt to get data from a user and send it to the database. For that matter, in "Learning Python" I see that Lutz & Ascher do not even attempt to get user input until page 200 when as an aside to exception handling they tell us about raw_input. Well, they do get user input via command line arguments, but that can take one only so far. There must be something real simple that I am missing here. If it was hard, someone would have done 5 chapters on it by now. Thanks again for the try. Regards, Joe From fictitious at bogus.moc Sat Jun 16 11:22:31 2001 From: fictitious at bogus.moc (Mega Hurts) Date: Sat, 16 Jun 2001 08:22:31 -0700 Subject: Suggestions for a Strange Project? References: <3b2abb77_1@news3> <9gekf2$ocd$1@mtc1.mtcnet.net> Message-ID: <3b2b7745_2@news3> > I believe that a 'time server' may solve the clock problem. Security may be > an issue -- I've never tried to set one up myself. Is this a Python-based solution, or did you have other apps in mind? I'm hoping to handle this with a Python applet. My four personal machines would benefit from a daily auto- mated clock correction, but I would ventually be applying the solution to a large Linux cluster. Hopefully, security would be no more an issue for this than for any other scripted tasks either cluster would handle. > The others may require a > bit more coding. You might be able to run a modification of the > Python-based chat program at > http://strout.net/python/server.py > and have each computer post the clipboard contents periodically. > Just a thought. > > - Kevin Thanks for the link! Looks like a good starting point for the communications need. I have always wanted more flexible features than the clipboard Windows offers. The ability to hold multiple items comes to mind, especially when I'm pasting chunks of boilerplate in standard responses to email inquiries. I believe there are clipboard apps for Windows, but I've not taken the time to test any. Making a shared-clipboard app for a cluster would seem a natural for multiple items. Probably the biggest challenge is going to be sharing the graphics pad mouse-cursor messages. Sensing and trans- mission of actions may be less of a challenge than INTERCEPTION, so a tap or movement does not effect the machine to which the hardware is actually connected unless the software is 'switched' to that machine. At best, sounds like Windows API issues. The pad is a USB unit, and I'd be surprised if there was any way to communicate more directly with it- but maybe there is a hardware abstraction layer in software for these, and a way to tap into it. I can dream, can't I? !-) > "Mega Hurts" wrote in message > news:3b2abb77_1 at news3... > > One computer has never been enough for me. > > Even back in the olden days of Z80 S-100 machines > > (pre IBM PCs), I used TurboDOS with multiple SBCs, > > and a strange multiple MicroAngelo graphics setup > > of my own design. > > > > Some things never change. > > > > My current setup consists of four machines, running > > Win98. I use a single monitor and infrared keyboard/ > > mouse, and switch from one machine to another with > > a KVM switch. I connect to the internet on the first > > machine, which runs a proxy, and the other machines > > can run mail, FTP, news and web clients. I use a couple > > of the boxes for compute-intensive MPEG recording, and > > when they are busy, can switch to the others for office > > activities. Soon I will change the fourth box to Linux. > > > > To switch from box to box, I press CTL-CTL-1, or > > CTL-CTL-2, etc. The fun begins: > > > > [1] I use background colors and a labeled icon to remind > > me which context I'm in. Things get fun when I am > > working in a file, copy text or a graphic, switch to > > another machine- AND FORGET THAT I CAN'T PASTE. > > > > [2] Or I'm using my beloved and vital graphics pad and > > switch machines, only to be reminded that the cursor > > on one machine and one only is under Wacom control. > > > > [3] All the clocks lose and gain time at different > > rates. This becomes important when recording off-air > > scheduled events, and updating the clocks on four machines > > is just another chore. > > > > Well, Rochester... I'm thinking. All these boxes can > > talk to each other via that zippy 100Mb LAN. > > > > Now, why can't machine #1 share its web-updated clock > > info, and machine #2 share its graphics-tablet cursor > > info when needed, and all of them write to a common > > 'clipboard'? > > > > A lightweight task running on all machines should provide > > the connectivity and clock awareness, cursor and mouse-key-awareness. Any > > suggestions on where to start? > > > > Thanks > > > > > > > > > > > > From kosh at aesaeion.com Tue Jun 26 03:12:26 2001 From: kosh at aesaeion.com (kosh) Date: Tue, 26 Jun 2001 01:12:26 -0600 Subject: Should I use a dictionary? References: <9h91pb$e3k$1@panix6.panix.com> Message-ID: <9h9ckq$nf$1@apollo.csd.net> Aahz Maruch wrote: > In article , > Gustaf Liljegren wrote: >> >>I have an object type for e-mail messages based on the rfc822 >>module. After picking out some messages from several sources, I want >>to sort them in order of the date property of the message object (as >>far as I understand, everything in this process needs to be kept in >>memory). Anyway, the problem is that I need some hints about how to >>sort the messages, as they are not sorted in way I get them. >> >>One idea I came up with was to put the date property of the message >>object as a key in a dictionary, and let the rest of the message be >>the value! But even if it would work, I think it's ugly. If someone >>can convince me that it's not ugly, or give a better (i.e. faster) >>solution, I'd be happy. > > For this purpose, a list is probably better, with the values being a > tuple of (, ). The problem is that dicts want the key to > be unique, and dealing with key collisions in this case is almost > certainly more trouble than it's worth. This method should able be very fast if you convert the data to a straight int first. This would have the advantage of using the built in sort function to really run through this set of data. So you would convert Sept 06 2001 or something to its numerical representation in unix which is the number of seconds after a certain time. There are functions already to do this so it should be easy. From garry at sage.att.com Mon Jun 25 15:31:55 2001 From: garry at sage.att.com (Garry Hodgson) Date: Mon, 25 Jun 2001 19:31:55 GMT Subject: problem building 2.1 on SunOS 5.7 References: <3B325CF1.9A970D6D@sage.att.com> <3B3362CF.5210C665@sage.att.com> Message-ID: <3B3791AB.CDA4D283@sage.att.com> Martin von Loewis wrote: > Garry Hodgson writes: > > > > /usr/local/lib/gcc-lib/sparc-sun-solaris2.4/2.7.2/include/time.h:90, > [...] > > okay, i'm answering my own question. but just in case anyone else trips > > over this, i got it to work using ./configure --without-gcc > > > > the regular sun c compiler built it without a hiccough. > > If you would use a gcc version compiled for Solaris 7, instead of the > one compiled for Solaris 2.4, gcc would work as well. good point. alas, this is not my system, and i am stuck with the environment they are running. indeed, my desire to get python there has been prompted by the lack of any civilized tools. > Alternatively, if you just delete your outdated gcc, configure would > not attempt to use gcc. yes, the --without-gcc accomplished the same thing. thanks -- Garry Hodgson sometimes we ride on your horses Senior Hacker sometimes we walk alone Software Innovation Services sometimes the songs that we hear AT&T Labs are just songs of our own garry at sage.att.com From mal at lemburg.com Sat Jun 16 19:14:06 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Sun, 17 Jun 2001 01:14:06 +0200 Subject: Parsing C code with Python References: Message-ID: <3B2BE83E.4433FB5B@lemburg.com> St?phane BAUSSON wrote: > > Hello, > > I am interested by examples of program parsing C code. The C code generates > raw data, and these raw data I want to parse them after with python to > display the data in something meaning full for human. > > The problem is how to analyze the C code, with the struct, union, etc .... > > If somebody has some idea ... You should check out the partial C parser in Tools/scripts/fixcid.py which is included in the Python source distribution. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From bos at hack.org Fri Jun 15 02:57:47 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Fri, 15 Jun 2001 08:57:47 +0200 Subject: IP address to binary conversion References: Message-ID: <3B29B1EB.1826DDB1@hack.org> Jeroen Wolff wrote: > Is there a way back to present the calculated results in a doted > decimal notation? Greg's code: >>> import socket, struct >>> ip = "192.168.2.1" >>> q = ip.split(".") >>> n = reduce(lambda a,b: long(a)*256 + long(b), q) >>> n 3232236033L Back to dotted: >>> socket.inet_ntoa(struct.pack('!I', n)) '192.168.2.1' -- Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From njm at rectec.net Thu Jun 28 21:20:27 2001 From: njm at rectec.net (NJM) Date: Thu, 28 Jun 2001 20:20:27 -0500 Subject: Python Standalone?? Message-ID: I have run Standalone.py on a small app that I wrote. The cycle completes and all appears to be well, until I try to launch the .exe file. My system claims a illegal function and immediately shuts down the program. Could this be because python is already on my machine?? Or am I doing something wrong?? Thanks for the help.. From rnd at onego.ru Mon Jun 18 11:04:27 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 18 Jun 2001 19:04:27 +0400 (MSD) Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? In-Reply-To: <200106181515.KAA04640@starbase.neosoft.com> Message-ID: On Mon, 18 Jun 2001, Cameron Laird wrote: > In article , > Roman Suzi wrote: > . > . > . > >I still remember HyperCard with warm feelings. It had very comfortable > >look&feel both from developer's and user's perspective. Every object had > >it's own script, which contained event handlers. Events were forwarded > >automatically from contained objects to containers and if not handled, > >Hypercard was the last who intercepted them. (Much like exceptions). > > > >Very nice scheme, which allowed to concentrate on the GUI and application > >logic, and not on the message propagation details. > > > >What I wanted to say, is that GUI programming is really easy when tools > >are like HyperCard: conceptually simple and powerful. Because all that > >complication comes from not hiding unnecessary details. Tk is like > >Assembly of GUI, while higher level is needed. > > > >After HyperCard (and SuperCard, HyperStudio to some extent) I have not > >seen anything near the quality and simplicity, unfortunately... Well, > >probably Squeak (sp?) is near, but it is thing in itself. > . > . > . > Do you realize a modernized HyperCard is still commercially > supported ? Oh, ye, I forgot to mention MetaCard. But now my standard is Open Source ;-) And I think Python could be nice to power such *Card program... Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From dan at eevolved.com Wed Jun 20 12:48:26 2001 From: dan at eevolved.com (dan) Date: Wed, 20 Jun 2001 12:48:26 -0400 Subject: for i in Message-ID: what was overloaded in UserList so its items could be extracted when you do for i in UserList([1,2,3]) ? thank you, Dan From joerg-sauer at netcologne.de Fri Jun 22 17:00:49 2001 From: joerg-sauer at netcologne.de (Joerg Sauer) Date: Fri, 22 Jun 2001 23:00:49 +0200 Subject: many independent python instances in multithreaded application Message-ID: Hi, is it possible to have some independent pyhton instances in a multithreaded application? I need some threads that invoke the python interpreter to execute some scripts. This might happen parallel. Is it possible to instantiate the python interpreter in each thread and is there no problem in doing so? Thanks in advance Joerg From tim.one at home.com Sun Jun 10 02:50:29 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 10 Jun 2001 02:50:29 -0400 Subject: extracting hex mant+exp from double? In-Reply-To: <000401c0f174$bbb3b170$a9807018@cr706570a> Message-ID: [Mike C. Fletcher, on "_"] > Has anyone ever used it since it was slipped in (save you, in this one > case)? I expect it's used heavily. For example, the first complaint of people who use sys.displayhook is "hey! '_' doesn't work anymore!" (setting __builtin__._ is done by the default display hook, so if you provide your own display hook you have to do that yourself -- if you want it). > I must be suspicious when a time machine is hanging around. I've > never noticed code using it (that I can recall). You'll never see a program using it. There's nothing special about "_" in batch code (it's just another identifier there), it only has this meaning in an interactive shell (specifically, the display hook is called only from the body of the PRINT_EXPR opcode, which opcode is generated only in response to interactive input). > "practicality-beats-purity-ly y'rs" how does it apply? I mean, I can > see maybe in interactive environments you might get cases where you > forgot to put x = in front of the last value and could save a few > seconds recalculation, Bingo, and remember that not all shells support history -- reproducing the last line typed can be a real pain in those. Some expressions have side-effects too. In addition, in an interactive shell you often don't *know* that you're going to want to do something to the last result until you see its value, and then >>> x = whatever doesn't display the value. > but otherwise it just seems like pointless magic. There is no otherwise -- it's an interactive gimmick, and that's all. You should try it! It's handy. live-and-let-underscore-ly y'rs - tim From m.faassen at vet.uu.nl Mon Jun 4 15:00:34 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 4 Jun 2001 19:00:34 GMT Subject: I NEED to TEACH you something, QUICK! References: <9fgiae$av0$3@newshost.accu.uu.nl> Message-ID: <9fglsi$ava$1@newshost.accu.uu.nl> Martijn Faassen wrote: > old computer displays, or whatever. It nips flamewars in the > butt. 'bud'. Sorry about that. Please don't flame me now. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From europax at home.com Sun Jun 24 16:29:17 2001 From: europax at home.com (Pugsley) Date: Sun, 24 Jun 2001 20:29:17 GMT Subject: Numpy Array indexing question Message-ID: I accidentally found that a[i][j][k] worked just like a[i,j,k] for indexing a Numpy array. But I couldn't find it mentioned any where in the Numeric pdf doc. Is it ok to use that syntax? Thanks. From rarice at core.com Tue Jun 5 11:17:32 2001 From: rarice at core.com (Ralph Allan Rice) Date: Tue, 05 Jun 2001 11:17:32 -0400 Subject: Python Equivalent... Message-ID: <3B1CF80C.1045B990@core.com> Is there a python equivalent to the C library function tzset()? It does not seem to be in the time module... Thanks, Ralph. From jp at ulgo.koti.com.pl Sun Jun 10 10:58:56 2001 From: jp at ulgo.koti.com.pl (Jacek =?iso-8859-2?Q?Pop=B3awski?=) Date: Sun, 10 Jun 2001 14:58:56 +0000 (UTC) Subject: return from class? References: Message-ID: Well.. I installed Pmw, so now I can use ComboBox instead of creating another window with ListBox, but I still don't know how to create this special class... -- They say that life's a carousel Spinning fast, you've got to ride it well The world is full of kings and queens "Heaven and Hell" Who blind your eyes and steal your dreams - Ronnie James Dio From dsh8290 at rit.edu Mon Jun 18 15:45:55 2001 From: dsh8290 at rit.edu (D-Man) Date: Mon, 18 Jun 2001 15:45:55 -0400 Subject: why is there no class (static) methods in Python ? In-Reply-To: ; from James_Althoff@i2.com on Mon, Jun 18, 2001 at 12:21:53PM -0700 References: Message-ID: <20010618154555.B4913@harmony.cs.rit.edu> On Mon, Jun 18, 2001 at 12:21:53PM -0700, James_Althoff at i2.com wrote: <...> | I notice that yourModule.yourFunction1 | is exactly what I want, but I need to override yourModule.yourFunction2 in | order to adapt it for myModule.MyClass. How can I do this (preferably | WITHOUT resorting to "black magic" and whilst preserving | "thread-safeness")? #### myModule.py import yourModule myFunction1 = yourModule.yourFunction1 def myFunction2( ) : pass | I am stuck -- because module functions are NOT methods (in the sense that | they are not associated with an instance) and hence do not participate in a | "method lookup/override" mechanism. So if I define my own As Alex Martelli has demonstrated a few times, you can substitute a class instance that implements __setattr__ and __getattr__ in place of the module object in sys.modules. | So true class methods -- methods invoked on class objects with inheritance | and override (a la Smalltalk) -- are good -- and far better than module | functions acting as a poor man's substitute therein -- mainly if you | consider code extensibility and reuse a good thing. Maybe the new meta class stuff will help with this? (I don't know) -D From anuragved at vsnl.com Fri Jun 8 13:59:20 2001 From: anuragved at vsnl.com (Anurag Ved) Date: 8 Jun 2001 10:59:20 -0700 Subject: RS232 support for DOS on 486? References: Message-ID: Hi All, I have a strong point to make. The ONLY purpose of the Usenet, as I see it, is to spread knowledge. Unfortunately, far too often too much is made of "off topic" thingy. If a post in it's basic theme is appropriate for a newsgroup (as this one is) then there is no reason why any replies to that post, even if seen deviating a bit from the main theme, should not be posted. In particular, comp.lang.python lurkers (like me) who have followed this thread and are not as knowledgeable as Oleg would certainly like to know what he did with the DOS Extender. - Anurag Oleg Broytmann wrote in message news:... > On Thu, 7 Jun 2001, D-Man wrote: > > On Fri, Jun 08, 2001 at 12:02:28AM +0400, Oleg Broytmann wrote: > > | On Thu, 7 Jun 2001, D-Man wrote: > > | > Does Python even run under MS-DOS? > > | > > | Under DOS Extender - no problem. I used Python 1.5.2 quite successfully! > > > > That's good to know. What is "DOS Extender" anyways? > > This is completely off-topic, and not of much interest to the newsgroup > (DOS, after all, is completely dead, as well as Python for DOS), so I am > going to write you private message to answer the question in more details. > > Oleg. > ---- > Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru > Programmers don't die, they just GOSUB without RETURN. From jeff at ccvcorp.com Fri Jun 22 12:56:55 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Fri, 22 Jun 2001 09:56:55 -0700 Subject: Another Wart! string.find() [ was: namespace issue? ] References: <9gucf9$ruc$1@slb3.atl.mindspring.net> Message-ID: <3B3378D7.A5A94C4A@ccvcorp.com> Michael Powe wrote: > >>>>> "Andrew" == Andrew Dalke writes: > > Andrew> > > >>>> print string.find.__doc__ > Andrew> find(s, sub [,start [,end]]) -> in > .... > Andrew> Return -1 on failure. > >>>> print string.index.__doc__ > Andrew> index(s, sub [,start [,end]]) -> int > ..... > Andrew> Raise ValueError if not found. > > Pardon the dumb question, but can you test this in a conditional, as > in > > if not string.index(s,sub) : /* and so forth and so on */ > > mp No, because you're not catching the exception. You could, however, do try: string.index(s, sub) except ValueError: pass else: DoSomething(s) instead. Jeff Shannon Technician/Programmer Credit International From nperkins7 at home.com Sun Jun 3 21:30:16 2001 From: nperkins7 at home.com (Nick Perkins) Date: Mon, 04 Jun 2001 01:30:16 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3B183CFF.A90213BA@san.rr.com> <9fa54s0fkb@enews2.newsguy.com> <3B1A7FEB.E466824E@san.rr.com> <9fe5q302hbg@enews2.newsguy.com> <3B1ADC37.565AEA61@san.rr.com> Message-ID: "Darren New" wrote: > how random is the binary string "1001010010011100100"? How random is the > binary string "0000000000000000000"? Such questions don't make any > sense. They do make sense, according to Chaitin. He says that they are as random as the shortest program than can produce them. In this sense, even if the string of zeros happened to come up at random, it is not actually a random string. Most of the numbers produced at random will *be* random, but not all. I think he goes on to show that for arbitrarily long random sequences, the proportion of such 'co-incedences' will approach zero. From spahievi at vega.bg Wed Jun 6 15:05:50 2001 From: spahievi at vega.bg (Niki Spahiev) Date: Wed, 6 Jun 2001 22:05:50 +0300 Subject: ExtensionClasses for Python 2.1? In-Reply-To: <6564c76c.0106060233.100516da@posting.google.com> References: <6564c76c.0106060233.100516da@posting.google.com> Message-ID: <1092795894.20010606220550@vega.bg> 06.6.2001, 13:33:43, Wolfgang Lipp wrote: WL> Does anyone know whether Jim Fulton of Zope's ;-) WL> ExtensionClass module is available for Python 2.1 WL> (preferrably compiled for w95, actually...)? WL> AFAIK, the current version should be at least 1.2; WL> also, ExtensionClasses seemed to have worked at least WL> upto Python 2.0. WL> Also, if anyone knows about alternative implementations WL> of either Extension Classes in general (inheritance WL> from 'Types' that is) or Acquisition, please let me WL> know. WL> Thanks a lot, WL> some-python-modules-are-too-hard-to-find-ly yours, WL> -wolf Look for standalone ZODB in www.amk.ca -- Best regards, Niki Spahiev From t_messmer at yahoo.com Sat Jun 16 23:51:12 2001 From: t_messmer at yahoo.com (Tom Messmer) Date: 16 Jun 2001 20:51:12 -0700 Subject: os.statvfs on FreeBSD References: Message-ID: Thanks for looking at this, I took some time and noticed that there was really no statvfs system call in FreeBSD (stable) and thought it might be possible to use the statfs call and map it to the same tuple returned by python's os.statvfs routine. Er, but thats as far as I got with it so far because I'm new at Python and not much of a programmer anyway. I looked at the os module itself and saw that it calls posix for unix-like systems, but from there I couldnt tell how it accesses system calls. If someone would care to explain this I'd love to hear about it, my eyes crossed after staring at all these classes and subclasses and sub sub...well you get the picture. All I really need is to write some code to grab system disk statistics so my servers don't get all full up, and i dont want to use some huge thing like big brother or spong. Thanks for the posts. Tom Messmer charles at aspen.sweetshade.net (Charles Allen) wrote in message news:... > To follow up to my own followup a bit: > > >>>> os.statvfs("/") > > Traceback (most recent call last): > > File "", line 1, in ? > > AttributeError: 'os' module has no attribute 'statvfs' > > I should have explained that FreeBSD has no statvfs library routine > (at least 4-STABLE, I don't know about 5-CURRENT). If the original > poster would explain the specific info he's looking for, perhaps an > alternative can be found. From mal at lemburg.com Wed Jun 20 09:34:05 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Wed, 20 Jun 2001 15:34:05 +0200 Subject: function attributes (ANN: Introducing PLY-1.0 (Python Lex-Yacc)) References: <3B306425.1BA938BE@lemburg.com> <15152.40380.99624.826511@gargoyle.cs.uchicago.edu> Message-ID: <3B30A64D.EB779804@lemburg.com> David Beazley wrote: > > M.-A. Lemburg writes: > > > > Just a suggestion: PLY seems to use the same logic for attaching > > grammar snippets to functions as SPARK does. IMHO, this is bad > > design since doc-strings should really only be used for documentation > > and not include vital information for the program logic. > > Actually, I thought the doc string hack was one of the neatest > programming tricks I've ever seen (which is exactly why I copied it > from SPARK). Why would I write a different documentation string for a > grammar rule anyways? The grammar rule in the docstring not only > tells the parser generator what to do, but it precisely documents what > the function does at the same time. I don't know what inspired John > to take this approach in SPARK, but it's pure genius if you ask me :-). IMHO, doc-strings are there to document functions/methods in a human readable way, with additional comments and maybe even usage examples. As such they are nice to have around in the source, but are not necessarily needed for program execution (e.g. python -OO removes them). Maybe just me, but I believe that putting program logic into documentation is not a clean design. > > Note that in Python 2.1 we have function attributes which were > > added for exactly this reason, so the doc-string approach is > > not really needed anymore. I'd suggest to move to these for one > > of the next releases. > > A fine idea, but the implementation is completely useless because > there is no syntactically convenient way to attach the > attributes. Ah... so that's what you're after: convenience ! That, of course, is true. So the conclusion should be: how can we make function attribute assignment more convienent and not why not to use them :-) > IMHO, having to type something like this is an even more > horrible design than using the docstrings (not to mention that it > looks ugly and unnatural): > > def p_expr_plus(t): > t[0] = t[1] + t[3] > > p_expr_plus.grammar = 'expr : expr PLUS expr' > > I don't have any plans to abandon the use of doc strings because I > like the way that they work. If I were to use function attributes for > anything, I would probably use them for some purpose other than > grammar specification. I'd have to think about that however. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From whisper at oz.nospamnet Tue Jun 12 12:43:00 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 12 Jun 2001 16:43:00 GMT Subject: PEP 259: Omit printing newline after newline References: Message-ID: <9g5gqk$ird$0@216.39.170.247> In article , guido at digicool.com says... > Please comment on the following. This came up a while ago in > python-dev and I decided to follow through. I'm making this a PEP > because of the risk of breaking code (which everybody on Python-dev > seemed to think was acceptable). > > --Guido van Rossum (home page: http://www.python.org/~guido/) > > PEP: 259 > Title: Omit printing newline after newline > Version: $Revision: 1.1 $ > Author: guido at python.org (Guido van Rossum) > Status: Draft > Type: Standards Track > Python-Version: 2.2 > Created: 11-Jun-2001 > Post-History: 11-Jun-2001 > > Abstract > > Currently, the print statement always appends a newline, unless a > trailing comma is used. This means that if we want to print data > that already ends in a newline, we get two newlines, unless > special precautions are taken. > > I propose to skip printing the newline when it follows a newline > that came from data. > > In order to avoid having to add yet another magic variable to file > objects, I propose to give the existing 'softspace' variable an > extra meaning: a negative value will mean "the last data written > ended in a newline so no space *or* newline is required." > > > Problem > > When printing data that resembles the lines read from a file using > a simple loop, double-spacing occurs unless special care is taken: > > >>> for line in open("/etc/passwd").readlines(): > ... print line > ... > root:x:0:0:root:/root:/bin/bash > > bin:x:1:1:bin:/bin: > > daemon:x:2:2:daemon:/sbin: > > (etc.) > > >>> > > While there are easy work-arounds, this is often noticed only > during testing and requires an extra edit-test roundtrip; the > fixed code is uglier and harder to maintain. > > > Proposed Solution > > In the PRINT_ITEM opcode in ceval.c, when a string object is > printed, a check is already made that looks at the last character > of that string. Currently, if that last character is a whitespace > character other than space, the softspace flag is reset to zero; > this suppresses the space between two items if the first item is a > string ending in newline, tab, etc. (but not when it ends in a > space). Otherwise the softspace flag is set to one. > > The proposal changes this test slightly so that softspace is set > to: > > -1 -- if the last object written is a string ending in a > newline > > 0 -- if the last object written is a string ending in a > whitespace character that's neither space nor newline > > 1 -- in all other cases (including the case when the last > object written is an empty string or not a string) > > Then, the PRINT_NEWLINE opcode, printing of the newline is > suppressed if the value of softspace is negative; in any case the > softspace flag is reset to zero. > > > Scope > > This only affects printing of 8-bit strings. It doesn't affect > Unicode, although that could be considered a bug in the Unicode > implementation. It doesn't affect other objects whose string > representation happens to end in a newline character. > > > Risks > > This change breaks some existing code. For example: > > print "Subject: PEP 259\n" > print message_body > > In current Python, this produces a blank line separating the > subject from the message body; with the proposed change, the body > begins immediately below the subject. This is not very robust > code anyway; it is better written as > > print "Subject: PEP 259" > print > print message_body > > In the test suite, only test_StringIO (which explicitly tests for > this feature) breaks. > > > Implementation > > A patch relative to current CVS is here: > > http://sourceforge.net/tracker/index.php?func=detail&aid=432183&group_id=5470&atid=305470 > > > Copyright > > This document has been placed in the public domain. > > > Local Variables: > mode: indented-text > indent-tabs-mode: nil > End: > > Having read the other's comments my issue with the idea is mildly different. Programming languages ought to require _some_ precision in thinking and making this sort of change encourages sloppy thinking imho. I'd rather more time be invested in improving the error reporting from Python - that would be of real benefit to new users! I'd think a "Got newline, expecting ":"" would be far more educational to the user then "Syntax Error" which is used all over the place. Come to think of it if you want to adopt this sort of handholding (the newline thing), then why not just turn this into a "Warning: substituted ":" for unexpected newline." (it seems clear to me that this could be done and, more often then not, it would be the correct parser recovery, but that is not the point). I used the syntax error bit to help me make a point about the downsides of this sort of handholding, but I really DO think that Python uses "Syntax Error" and leaves one to puzzle things out when it seems to me it's possible to give a more concise report in many instances. Lets not gild the lily until the flower is in full bloom! Regards, Dave LeBlanc From w.guldner at bfad.de Wed Jun 27 08:28:20 2001 From: w.guldner at bfad.de (Wolfgang Guldner) Date: Wed, 27 Jun 2001 14:28:20 +0200 Subject: Tk::Date widget Message-ID: <3B39D164.FE7A0980@bfad.de> Hi all I'm looking for something like the Tk::Date widget in perl. Does there exits something like that in python too? Thanks. Regrads Wolfgang -- _____________________________________________________________________ BFAD GmbH & Co. KG Wolfgang Guldner Carl Benz Strasse 19 D-78224 Singen Tel.07731-9057-700 _o o Fax 07731-9057-660 -\<, /L E-Mail: w.guldner at bfad.de ~~o^~~ O / O /> Homepage: www.GETembedded.de From karmen2001 at HOTMAIL.COM Wed Jun 6 14:52:34 2001 From: karmen2001 at HOTMAIL.COM (mik) Date: Wed, 6 Jun 2001 20:52:34 +0200 Subject: Why should i use python if i can use java Message-ID: <9flu5i$c61$1@news.tudelft.nl> i' m a python newbie but I've this prob. i have seen Jython .. what has python dat java does not????????? From tim.one at home.com Wed Jun 6 23:40:30 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 6 Jun 2001 23:40:30 -0400 Subject: priority queue In-Reply-To: Message-ID: [Nick Perkins] > I need a priority queue, but I am not sure what kind I should use. I > will be doing insertions that will likely fall somewhere in the middle, > and will only be removing from the front of the queue. I expect > insertions to out-number removals by about 2 or 3 to one. > ... > I am re-coding into Python a C program that I wrote which finds the > shortest solution to 'sokoban' puzzles. It uses an A* search. Could be that none of the data structures you have in mind will work in the end: an A* search can expand too much state space to live in RAM, even if you code it in assembler. Look and you'll eventually find "bounded-memory A*" algorithms, to worm around that. In essence, when the queue "gets too big", expanded nodes at the "bad" end of the queue are thrown away, and replaced with a thunk for regenerating them if they ever get interesting again (and they often never do: the better the heuristic component of your search, the less likely that low-scoring nodes will ever become interesting; in the limit, this is clearly true, as with a perfect heuristic you'd never expand a node not on an optimal path). Also note that if the space is really a graph, it's possible to see the same node more than once. Depending on the problem, it may or may not be possible for a second (third, ...) way of getting to a node to lead to a cheaper solution, but in either case you need to *recognize* that you've seen the node before. So in the graph case you also need to search the priority queue efficiently (or arrange for the node generator to remember which nodes have been generated, and return a unique object per distinct node). IOW, it can get complicated. > The easy way would be to just have a list, and .sort() it at each > insertion. This, i am sure, would not be the fastest way. Even easier is to use an unsorted list L, and do cheapest = min(L) L.remove(cheapest) to "pop" the queue. Does it scale well? Heck no! It's two O(len(L)) operations. But it will let you focus on the *interesting* part of your problem at once, without worries that a fancy priority queue structure is introducing bugs of its own. Since you're presumably going to be most interested in developing better heuristics, it's likely adequate for weeding out bad heuristic ideas via trying simple problem instances. Alex's suggestion to use a sorted list in conjunction with the bisect module is also a good one. > I think that a heap would best suit my needs. Last time I tried that with an A* the heap eventually got too big -- and it was actually slower than a dirt dumb list for the small initial problem instances alluded to above. Doing O(N) operations via a single Python primitive (which runs at C speed) is cheaper than coding an O(log(N)) operation *in* Python, until N gets big enough to make this an obvious lie. > I could code one myself, but it must have been done before. > I can't find one in the cookbook, or the vaults! If you find a canned A* algorithm, it's probably going to be too much of a pig to stick with before you're solving problems of the size you *want* to tackle. Since you're going to have to invent your own custom A* in the end anyway, may as well begin with something dirt simple. > I think that the ease of implementing heuristics and algorithms in > Python will allow me to write a 'smarter' program than the C version. > In AI, smarter algorithms can give a performance boost of many orders > of magnitude, which I hope will overwhelm any mere constant factor in > speed penalty for going from C to Python. You're on the right track! I've often had the joy of writing Python programs that ran 100s of times faster than competing C programs, simply because I was able to throw away 10 full implementations before my coworkers were able to get the bugs out of their first C stab. The more poorly understood the problem, the more likely this is to win big (assuming you've got lots of ideas for approaching it! Python will be a real aid in *trying* them quickly. The only real help it is in *suggesting* an approach, though, is to subtly push you toward "Hmm. I wonder whether I could use dicts to advantage ...".). keep-it-simple-until-it-gets-too-interesting-to-bear-ly y'rs - tim From grante at visi.com Thu Jun 28 10:59:42 2001 From: grante at visi.com (Grant Edwards) Date: Thu, 28 Jun 2001 14:59:42 GMT Subject: Centering a Tkinter Toplevel References: <3B3A75CE.DD40FF11@ces.clemson.edu> Message-ID: In article <3B3A75CE.DD40FF11 at ces.clemson.edu>, Schaefer, F. wrote: >Hi, > >I was wondering how it could be possible to have a 'hello-screen' >while the rest of the modules are loading. Unfortunately, I was >to able to find out how to determine the WM-Screensize. >Does anybody know how to do this in Tkinter ? One of my dialog boxes does this: xpos = parent.winfo_screenwidth()/2 - 120 Where parent is the root window. I would guess that there's a winfo_screenheight() method also, but I've not actually tried it. -- Grant Edwards grante Yow! I hope something GOOD at came in the mail today so visi.com I have a REASON to live!! From chris.gonnerman at newcenturycomputers.net Thu Jun 14 00:33:20 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Wed, 13 Jun 2001 23:33:20 -0500 Subject: My Cut at PEP 259 References: <486de2.0106131406.5c0cbef9@posting.google.com> Message-ID: <010301c0f48b$2c802140$0101010a@local> I have to agree that .softspace is not my favorite thing. Here's how I see it: Right now, given the following code (numbered for later reference): 1) print "Goodbye", "Gruel", print "World" you get this (with underscores in place of spaces) 2) Goodbye_Gruel_World Now try this: 3) print "Goodbye", "Gruel", sys.stdout.write("\n") print "World" and you get this mess: 4) Goodbye_Gruel _World This generates a couple of messages from newbies each month regarding print and raw_input(). Instead, let's imagine throwing out .softspace entirely and assume a print statement which replaces every comma (except after the >>>fileobj construct, if present) with a space and adds a newline at the end except when the last token is a comma. Figure 3's code gives this result: 5) Goodbye_Gruel_ World This, IMHO, is less surprising, and the results of Figure 1's code is still Figure 2. Most expert Pythonians, aware of the behavior in Figure 4, avoid code like Figure 3 automatically, so this change should result in very little code breakage. Newbies will probably ask on the list how to get rid of the extra space when they do this: 6) print "A prompt:", resp = raw_input() but I doubt this would be more common than the current question and perhaps easier to explain. I'm still in favor of print mapping to a __print__() function of some sort, but this proposal would work either way. From ullrich at math.okstate.edu Sun Jun 3 10:54:51 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 03 Jun 2001 14:54:51 GMT Subject: random References: <3omjhtc1j82ot6fdsgnlnqi17kuqspfdsc@4ax.com> Message-ID: <3b1a4f93.1263116@nntp.sprynet.com> On Sat, 02 Jun 2001 23:40:49 -0700, Tim Roberts wrote: >Lulu of the Lotus-Eaters wrote: >> >>But if you are not happy with mere physical/empirical impossibility, it >>works equally well for mathematical impossibles: >> >> <2+2=5> IMPLIES <2+3=6> >> >>works fine by application of Peano arithmetic. > >This brings to mind an old joke. A philosophy professor lecturing his >class states, "given any false statement, I can prove any other statement." > >A student stands up and challenges "OK, given 3 equals 8, prove you are the >pope." > >The professor thinks for a moment. "All right, 3 equals 8. Adding 2 to >both sides, we get 5 equals 10. We divide both sides by 5, and get 1 >equals 2. Now, I think everyone will acknowledge that the pope and I are >two people. Since we have shown that 1 equals 2, we conclude that the pope >and I are one person." I think that's Bertrand Russel again. >- Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From michael at stroeder.com Mon Jun 25 19:35:13 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Tue, 26 Jun 2001 01:35:13 +0200 Subject: DistUtils and optimized compile References: <3B375869.E417C833@stroeder.com> <9h7lng$cdpjl$1@ID-59885.news.dfncis.de> <3B375F47.64A232D2@stroeder.com> <9h7nlg$cbtbq$1@ID-59885.news.dfncis.de> Message-ID: <3B37CAB1.D200EADC@stroeder.com> Thomas Heller wrote: > > python setup.py install -O1 Anything similar for compiling optimized byte-code into a RPM with python setup.py bdist_rpm ? Ciao, Michael. From stephen_purcell at yahoo.com Fri Jun 29 05:06:03 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: 29 Jun 2001 02:06:03 -0700 Subject: Standard module unittest, where has unittestgui gone? References: <9gu7je$58c$1@troll.powertech.no> Message-ID: <309094c8.0106290106.396ed3e2@posting.google.com> "Syver Enstad" wrote in message news:<9gu7je$58c$1 at troll.powertech.no>... > I can't seem to find an updated unittestgui module for the version of > unittest.py that's included in the Python 2.1 distro. Anyone know what's > happened to it? On the PyUnit project page there is only very old versions > of unittestgui and it's not compatible with the latest version of > unittest.py. There has been an updated GUI version in the PyUnit CVS tree for a while now. See http://sourceforge.net/cvs/?group_id=3912 I've been naughty and not yet made the standalone release of PyUnit that I promised for compatibility with the Python 2.1 version. I will get to this promptly now. I had been waiting to update the documentation appropriately, but never made time for it. Best wishes, -Steve From brian at sweetapp.com Sat Jun 16 17:09:04 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Sat, 16 Jun 2001 14:09:04 -0700 Subject: Writing new codecs In-Reply-To: Message-ID: <002801c0f6a8$932a5ea0$445d4540@D1XYVL01> > It's really your choice. For rarely-used encodings, writing them in > Python might make them more maintainable. But then, dealing with > individual bytes in C is often easier than in Python. Hopefully it won't need that much maintenance. And the C implementation is probably going to be at least 2 orders of magnitude faster than the Python implementation. > I hope not. New codecs should certainly use their own modules, which > still leaves the question whether these should be C or Python modules. That would be a bit odd too, I think. The number of C modules in Python could really blow up. From twofingersalute at atl.mediaone.net Sat Jun 9 10:41:35 2001 From: twofingersalute at atl.mediaone.net (myself) Date: Sat, 09 Jun 2001 14:41:35 GMT Subject: tummy compile Mandrake 7.2 References: <20010608.214013.1469262009.16325@K7.atl.mediaone.net> Message-ID: <20010609.104451.1884661237.1229@K7.atl.mediaone.net> In article , "Sean Reifschneider" wrote: >>line 246: Dependency tokens must begin with alpha-numeric, '_' or '/': >>%defattr(-, r oot, root) > > I'm not really sure what this is. I'd appreciate it if somone could > tell me -- it seems to be unique to Mandrake... I don't reall get what > it's trying to say, but have had the same report from another Mandrake > user of getting the same error. > >>BuildPrereq: expat-devel >= 1.1-3tummy BuildPrereq: db1-devel >>BuildPrereq: gdbm-devel >> >>already have gdbm-devel, got and installed db1 and db1-devel, no clue as >>to expat-devel as Mr. tummy doesn't seem to install it. > > The stock RedHat expat RPM includes expat-devel. If your expat RPM > includes the devel files in the main package, try removing the > BuildPrereq above. > > Sean thanks for your reply! well I guess I could have phrased the expat-devel Q a little better- if devel is a build require, why isn't it included, or offered as a separate srpm in ftp directory? Or are you saying I need the "standard" expat pkgs in addition to the tummy ver? (but that's confusing, as >=1.1-3tummy implies that there *is* a 1.1-3tummy devel available)?? WRT line 246, surely someone here will be able to shed some light for both our benefits- I haven't seen many problems go unsolved in this ng (hint-hint). Actually I don't expect a necessarily specific answer, just a clue where to look would suffice (hopefully). OTOH, this gives me an opportunity to actually post here- this really is an _excellent_ group! From sbrunning at bigfoot.com Thu Jun 21 07:05:35 2001 From: sbrunning at bigfoot.com (Simon Brunning) Date: 21 Jun 2001 04:05:35 -0700 Subject: Python-list: the list with everything! References: <9gdmil$61k$1@newshost.accu.uu.nl> <3B2CFC7F.FCFF286@engcorp.com> Message-ID: <12f02d51.0106210305.358a4b48@posting.google.com> Peter Hansen wrote in message > After they cut off my net-access several months ago, I've spent a lot of > time thinking about this. You're lucky it was only your *net-access* they cut off. Last time *I* tangled with the PSU, they cut off my From gwyoder at hotmail.com Tue Jun 19 06:31:12 2001 From: gwyoder at hotmail.com (Pilgrim) Date: Tue, 19 Jun 2001 10:31:12 GMT Subject: Indentation Message-ID: I'm new to programming so take it easy on me :-) I'm going through a book by Ivan Van Laningham and have gotten to indentations. In the example I'm trying duplicate he as written three lines from the command prompt. After the third line is a new indentation and then the next line starts back at the beginning without the command prompt >>> and starts with an "elif" statement. According to his tip to start a new line you just hit return twice when you are done with the indentation. OK that works fine and starts me at a new prompt >>> but when I type the next line starting with a "elif" statement it gives me a SyntaxError: invalid syntax. What I'm I missing? Thanks From emile at fenx.com Wed Jun 13 09:17:30 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 13 Jun 2001 06:17:30 -0700 Subject: VI References: Message-ID: <9g7pch$7dr3g$1@ID-11957.news.dfncis.de> If you're not working with unix, you probably don't want to know. -- Emile van Sebille emile at fenx.com --------- "Pilgrim" wrote in message news:X7IV6.76800$G5.16553705 at news1.rdc1.md.home.com... > Can someone tell me what "vi" is for a text editor to work with python? > Where can I get this? > > From greg at cosc.canterbury.ac.nz Mon Jun 25 23:47:43 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Tue, 26 Jun 2001 15:47:43 +1200 Subject: Is this a true statement? References: Message-ID: <3B3805DF.A6741B80@cosc.canterbury.ac.nz> "Dr. David Mertz" wrote: > > claim there is no way "that naturally maps the program constructs to the > memory accesses involved." The last is probably something true... but > it is only true as long as no one writes a devicedriver.py extension > module that contains some functions like "access_memory_address()." Strictly speaking, the C language doesn't provide any way of accessing specific memory addresses, either. Techniques for doing so rely on knowledge of details of the implementation being used. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From senux at senux.com.NOSPAM Wed Jun 20 21:20:21 2001 From: senux at senux.com.NOSPAM (Brian Lee) Date: Thu, 21 Jun 2001 01:20:21 GMT Subject: where to install on Red Hat 6.2 ? References: Message-ID: <3B314C24.2010605@senux.com.NOSPAM> Bob Koss wrote: >When I installed Python 2.1 last time, the tool 'netcfg' quit working >due to Python conflicts. I had to diddle with paths whenever I wanted >to use netcfg. > >I'm about to do another installation. Where should I install to keep >everything that uses Python working? > On RedHat Linux systems, I don't know well about applications which what version of Python require. But if you want/need to install both of 1.5 and 2.1, use prefix option in installing from source tree. Like this... # configure --prefix=/usr/local/python2.1 Or, if you install Python by RPM, you just install newest Python and edit link to binary file. There should be two Python in /usr/bin/ directory. python1.5 and python2.1. And if you want to use 1.5 as default Python, link like this.... # ln -s /usr/bin/python1.5 /usr/bin/python And all application use previous(RH default) use Python 1.5 and specipy /usr/bin/python2.1 only when it need to run 2.1. Sorry for bad English. - Brian,. From sholden at holdenweb.com Wed Jun 27 07:54:35 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 27 Jun 2001 07:54:35 -0400 Subject: time module - is strptime available under NT? References: Message-ID: "Dan Tropp" wrote in message news:mailman.993617381.11107.python-list at python.org... > Is this function available in the windows (NT) version? > > If not is there a commonly used alternative? Or do people just parse things > up themselves with re? > > dan > > Dan Tropp > Dept Psychology, University of Melbourne, Australia > From http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/56036 """In an attempt to have a version of time.strptime() that could run anywhere, I wrote this module. Running the strptime() function will function as much as time.strptime() as within reason...""" regards Steve -- http://www.holdenweb.com/ > From boyd at insultant.net Mon Jun 4 14:03:21 2001 From: boyd at insultant.net (Boyd Roberts) Date: Mon, 4 Jun 2001 20:03:21 +0200 Subject: Why no 'elif' in try/except? References: <3B1A06EE.F484930A@snakefarm.org> <3B1A29DE.9876770D@accessforall.nl> Message-ID: <9fgiip$h48$1@neon.noos.net> "Marcin 'Qrczak' Kowalczyk" a ?crit dans le message news: slrn.pl.9hnbs9.4l5.qrczak at qrnik.zagroda... > I don't understand only one thing. Why it is spelled 'elif' and not > 'else if'? may have been influenced by 'elif' from the Bourne shell as well as the fact that it's simpler to parse, given it's one token and not two (less look ahead). From bbollenbac at gov.mb.ca Thu Jun 28 09:37:27 2001 From: bbollenbac at gov.mb.ca (Brad Bollenbach) Date: 28 Jun 2001 06:37:27 -0700 Subject: the indentaion for grouping thing References: <3b33d9d6$1_1@anonymous> Message-ID: <9cbb88e3.0106280537.509d030a@posting.google.com> Anonymous wrote in message news:<3b33d9d6$1_1 at anonymous>... > Someone quoted Guido as saying (I'm paraphrasing) that he > is determined to be ignorant of any discussion regarding the white > space for grouping thing. How sad. How crusty. How typical. > > Anyway, I will continue to use Python I guess, but I gather that someone > has written a preprocessor that allows you to use delimiters with python. > Is this true? If so, where can I find it, I would like to use it. > > > > > --------== Posted Anonymously via Newsfeeds.Com ==------- > Featuring the worlds only Anonymous Usenet Server > -----------== http://www.newsfeeds.com ==---------- Realistically, any group of people that's working on Python code written by any Python programmer on earth (you or anyone else even!) should /know Python/. They should understand why mixing spaces and tabs is a Bad Idea(TM), in Python, and often elsewhere for that matter. They should also understand that /in case/ somebody is silly enough to mix the two, there exists the utility script in Tool/Scripts called "untabify.py". Because the Python interpreter parses tabs to mean "8 spaces", running untabify.py will convert any tab characters it finds to....8 spaces! This means that if you have a source file that worked /before/, but mixed tabs and spaces, running untabify.py on it will replace said tabs with spaces, and the code will still work precisely as before. Problem solved. Also, there are a lot of very, very smart people developing the Python core, and using Python in their everyday hacking. Do you /really/ think you've discovered the Magic Reason why indentation is a poor method for grouping blocks, and all of them overlooked it? Not bloody likely. :) Brad From MarkH at ActiveState.com Wed Jun 20 22:43:43 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 21 Jun 2001 02:43:43 GMT Subject: memory bug in win32pdh References: <3B309D76.354E2692@itmasters.com> Message-ID: <3B315F5A.6030207@ActiveState.com> vincent delft wrote: > I'm written a small python script to get, each seconds, the list of > process running on a W2K box. During that develoment I've founded a > strange behaviour. > > I've isolated the problem to 1 simple command. > > Try the following code, and look in your "Task Manager", the "memory > usage" for your python process will grow and grow. Within 10 minutes > the "memory usage" grow up to 800kb. This is a Python object leak in PyEnumObjectItems(). I have checked a fixed into CVS, so future builds will have this fixed. Mark. From tavis at calrudd.com Wed Jun 6 18:40:36 2001 From: tavis at calrudd.com (Tavis Rudd) Date: Wed, 6 Jun 2001 15:40:36 -0700 Subject: change to note between 2.0 and 2.1 Message-ID: <0106061540360C.00647@lucy> Hi Andrew, the re module handles negative look-behinds differently in 2.1 and 2.0. In 2.1 a negative look-behind at the very beginning of a string will match if the rest of the following text matches. In 2.0 this doesn't match. Would you mind adding a note about this on the "What's New in Python 2.1" page? example ========================================= Try to match all $, but not \$, in the following string. "$ $ $ \$" Using re.compile(r"(? Message-ID: [Tomasz Stochmal, wonders about reverse-engineering .pyc files] [Alex Martelli, doesn't cheer him up] > ... > From a .pyc you even get the line numbers to help you > reconstruct the exact layout, blank lines and all... at least > a .pyo (as obtained for import when you run Python with > -O, or -OO to eliminate docstrings too) hides _that_:-) Not very well, though. There's still a mechanism for finding line numbers under -O, else tracebacks would be much harder to follow. And Python being Python, you can figure it out easily enough with a Python program. For example, here's a program: def f(x): x += 1 # Multiply by 2. x *= 2 return x tab = f.func_code.co_lnotab addr, line = 0, f.func_code.co_firstlineno i = 0 while i < len(tab): addrincr, lineincr = map(ord, tab[i:i+2]) addr += addrincr line += lineincr print "bytecode offset", addr, "corresponds to line", line i += 2 import dis dis.dis(f) and here's output from running that under -O: bytecode offset 0 corresponds to line 2 bytecode offset 10 corresponds to line 4 bytecode offset 20 corresponds to line 5 0 LOAD_FAST 0 (x) 3 LOAD_CONST 1 (1) 6 INPLACE_ADD 7 STORE_FAST 0 (x) 10 LOAD_FAST 0 (x) 13 LOAD_CONST 2 (2) 16 INPLACE_MULTIPLY 17 STORE_FAST 0 (x) 20 LOAD_FAST 0 (x) 23 RETURN_VALUE 24 LOAD_CONST 0 (None) 27 RETURN_VALUE However, from that alone, it's impossible to know whether the body of f was *really* def f(x): x += \ 1 x *= 2 return x instead . security-thru-transparency-ly y'rs - tim From Bill.Scherer at VerizonWireless.com Tue Jun 19 11:59:43 2001 From: Bill.Scherer at VerizonWireless.com (Scherer, Bill) Date: Tue, 19 Jun 2001 11:59:43 -0400 (EDT) Subject: disable line wrap in xterm?? Message-ID: Can anyone tell me how I can disable line wrap in an xterm (or equiv, eg: rxvt, Eterm, etc) from Python? For example: I would like an 80 column terminal to print 80 asterisks when I execute: >>> print '*' * 100 and throw the rest away instead of wrapping them. Thanks! William K. Scherer Sr. Member of Applications Staff - Verizon Wireless Bill.Scherer_at_VerizonWireless.com From sholden at holdenweb.com Tue Jun 26 08:24:00 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 26 Jun 2001 08:24:00 -0400 Subject: 'with' statement in python ? References: Message-ID: <67%Z6.21397$f4.901444@e420r-atl1.usenetserver.com> I was going to add this to the FAQ, but sadly I can't get the FAQ Wizard page up at present. The worl wide wait strikes again... you're right, it's a good answer. Not that everyone who comes here has read the FAQ (or serched Google) when they arrive, of course. regards Steve -- http://www.holdenweb.com/ "Carlos Ribeiro" wrote in message news:mailman.993515440.4888.python-list at python.org... > At 21:50 25/06/01 +0000, Mark Hadfield wrote: > >From: "asgard" > > > > > > > Hello, > > > writing self before every object's method really drives me > > > crazy. Shouldn't there be 'with' statement like in Pascal, ie. > > > >There was an extensive discussion on this recently. Perhaps you'd like to > >try a search on Google Groups. IIRC the consensus was that adding this to > >Python would not be a good idea, because when "with" blocks are nested they > >become hard to read and possibly ambiguous. > > I'll repeat the same argument that I gave some time ago. Maybe it's a good > answer for this FAQ :-) > > Some languages, such as Object Pascal, Delphi, and C++, use static types. > So it is possible to know, in a unambiguous way, what member is being > assigned in a "with" clause. This is the main point - the compiler *always* > knows the scope of every variable at compile time. > > Python uses dynamic types. It is impossible to know in advance which > attribute will be referenced at runtime. Member attributes may be added or > removed from objects on the fly. This would make it impossible to know, > from a simple reading, what attribute is being referenced - a local one, a > global one, or a member attribute. > > For instance, take the following snippet (it is incomplete btw, just to > give you the idea): > > def with_is_broken(a): > with a: > print x > > The snippet above assume that "a" must have a member attribute called "x". > However, there is nothing in Python that guarantees that. What should > happen if "a" is, let us say, an integer? And if I have a global variable > named "x", will it end up being used inside the with block? As you see, the > dynamic nature of Python makes such choices much harder. > > > Carlos Ribeiro > > > From JamesL at Lugoj.Com Tue Jun 5 21:19:00 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Tue, 05 Jun 2001 18:19:00 -0700 Subject: Obsolesence of <> (fwd) References: <9f6el30dv5@enews2.newsguy.com> <3B16D681.E12A4554@Lugoj.Com> <9f7pmt029se@enews1.newsguy.com> <3B17D9B9.E3CA8EC8@Lugoj.Com> <9fjgjl$rp0$1@brokaw.wa.com> Message-ID: <3B1D8504.434DA7DD@Lugoj.Com> Jonathan Gardner wrote: [ Drawing from dot and cross products, comes to: ] > So, taking the argument back to <> and !=: Maybe we should decide that <> > means "greater than or less than" and != means "not equals to, or not ==". > Therefore, you can ensure that noone tries to <> two complex numbers, but > they certainly can != two complex numbers. Nicely done! You've worked out how to have your cake and Edith too! Now if I can only think of real world situation where <> does what you want and != doesn't (since the latter seems to include the former, but note vice versa). Any case where an element of a ordered set can be NOT less than AND NOT greater than another element and still be NOT EQUAL to it? I'm not a mathematician, but do infinities have these properties? > In the > end, shouldn't we try to make what is written in the program as legible to > mathematicians as possible? I mean, the closer the language stays to math, > the more logical it will be. Let us now do a Vulcan mind-meld. ;-) From Randy.L.Kemp at motorola.com Wed Jun 13 09:38:34 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Wed, 13 Jun 2001 08:38:34 -0500 Subject: VI Message-ID: Do you mean VI on Unix? It's a standard line based editor that comes with Unix. -----Original Message----- From: Pilgrim [mailto:gwyoder at hotmail.com] Sent: Wednesday, June 13, 2001 6:29 AM To: python-list at python.org Subject: VI Can someone tell me what "vi" is for a text editor to work with python? Where can I get this? From piet at cs.uu.nl Thu Jun 7 09:57:08 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 07 Jun 2001 15:57:08 +0200 Subject: Running mod_python on NT References: <1a18c6fa.0106060811.5f09477f@posting.google.com> Message-ID: >>>>> peter.nye at verizon.net (Peter Nye) (PN) writes: PN> Has anyone been able to overcome the error message: PN> python_handler: make_obcallback returned no obCallBack! PN> and successfully run mod_python on NT. I have read all kinds of PN> postings of people having this problem but have not found any answers. PN> Thank you for any help you can give. PN> Running NT 4.0 PN> Apache 1.3.14 PN> Python 2.0 PN> mod_python 2.7.2 Switch over to 2.7.4 or newer when it is available. Otherwise there are occasional threading errors. And you have to install mp20.dll in Apache plus copy the lib/python/mod_python direcory from the distribution archive to your Python directory. The latter will cause the error message to disappear. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From steff at rebecca.chermisey.fr Thu Jun 14 16:49:58 2001 From: steff at rebecca.chermisey.fr (=?iso-8859-1?Q?St=E9phane?= BAUSSON) Date: Thu, 14 Jun 2001 20:49:58 GMT Subject: how to get teh path of a script References: <3B27C7A9.3B9D3F4B@free.fr> <9g8hl9$o0a$05$1@news.t-online.com> Message-ID: This is the good answer, thanks > > os.path.normpath(os.path.dirname(os.path.abspath(sys.argv[0}))) > > -- stephane.bausson at free.fr - Toulouse (France) From erno-news at erno.iki.fi Wed Jun 27 11:59:58 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 27 Jun 2001 18:59:58 +0300 Subject: Escaping SQL in python References: <3B39A1B8.A7FCE4C7@kvarteret.uib.no> Message-ID: In article , "Steve Holden" writes: | The *best* way to handle this is to use dynamic SQL, and let the module do | the quoting. | Beware, though. There are five different parameter styles yeah, there's that and also not all of the db-api modules handle quoting correctly. i think pygresql didn't do any quoting (i've sent a (hopefully correct) patch). -- erno From ejr at cs.berkeley.edu Thu Jun 7 19:57:01 2001 From: ejr at cs.berkeley.edu (Edward Jason Riedy) Date: Thu, 7 Jun 2001 23:57:01 +0000 (UTC) Subject: floating point in 2.0 References: Message-ID: <9fp4cd$2sgt$1@agate.berkeley.edu> And Tim Peters writes: - - Note that this is platform-dependent, and even across platforms - that conform fully to IEEE-754: they're allowed to display only - zeroes after the 17th significant decimal digit. I've forgotten the exact language, but we're going to strongly recommend using Steele and White's algorithm by default: http://www.acm.org/pubs/citations/proceedings/pldi/93542/p112-steele/ Given 0.1 converted to binary, this will print 0.1. It's a complicated algorithm, but worth it. And it's not a lie. It returns the shortest decimal string which will reproduce the given binary number after a decimal->binary conversion. Of course, you may worry about 0.1 + 0.1 + ... != 1.0. We're also going to be giving a good deal of advice (and some requirements) on handling arithmetic. I'm working on a paper with greater detail, but try the following C program for a taste of some intended advice: ======== #include /* Accumulating in more precision than the data `deserves' AND rounding the output gives the right answer for more cases. */ int main (void) { int i; float x = 0.1; double accum = 0.0; float accumf = 0.0; float y; for (i = 0; i < 100; ++i) { accum += x; /* accumulate in double... */ accumf += x; } y = (float) accum; /* round back to float... */ printf ("%.36g\n%.36g\n%.36g\n", accumf, accum, y); } ======== Next meeting for 754r is on the 20th somewhere around San Jose. There's a mostly inactive mailing list about it; people honestly interested in participating can mail me for more info. Jason -- From skip at pobox.com Wed Jun 13 09:45:34 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 13 Jun 2001 08:45:34 -0500 Subject: All functions from self and inherited classes In-Reply-To: References: Message-ID: <15143.28286.848170.535933@beluga.mojam.com> Christer> But, if I include the functions in GeneralClass.doc(), and try Christer> calling b.doc() i get the following: Christer> 1. the inspect only gives me methods for class B... not Christer> inherited functions (which I want! :-). Now that I see a more complete picture of what you're after, I suggest you look at pydoc, which builds on the lower-level functionality inspect. Pydoc is also new with 2.1, but the pydoc/inspect author (Ka-Ping Yee) has been careful to make it work under 1.5.2 as well. As others have mentioned, both are available at http://web.lfw.org/python/ If the TextDoc or HTMLDoc classes don't quite do what you want, you can probably subclass them to achieve the desired results. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From rdsteph at earthlink.net Tue Jun 19 21:27:49 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Wed, 20 Jun 2001 01:27:49 GMT Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: Message-ID: <3B2EACF5.1D10252D@earthlink.net> Anyway, by my count 7 people have expressed some sort of interest in a HyperCard-like gui creator, since it was first mentioned yesterday by Roman Suzi... Roman Suzi Heil Hodgson Jerry Spicklemire Kevin Altis Chris Barker Phil Hunt and myself... From mickey at aldebaran.tm.informatik.uni-frankfurt.de Sun Jun 17 08:38:39 2001 From: mickey at aldebaran.tm.informatik.uni-frankfurt.de (Michael Lauer) Date: 17 Jun 2001 14:38:39 +0200 Subject: tuples and lists in XML-RPC References: <3b25d1d5@nntp.server.uni-frankfurt.de> <9ggp7n$6c7$1@bunyip.cc.uq.edu.au> Message-ID: <3b2ca4cf@nntp.server.uni-frankfurt.de> Chui Tey wrote: > If you know you are proxying through xmlrpc, then you can always cast the > return value .. > > s=Server(http://..blah) > result = tuple(s.getTupleResult()) > > I don't recall the xmlrpc spec saying you can't include something in the > header..., perhaps you can include hints on type casting. Yes - good suggestion. I guess I will go this way. > What about None, and all the unmarshallable class instances? This will be handeled by my class proxy. Thanks for your note! Greetings from the cold germany, -- :M: -- |----------------------------------------------------------------------------| | Dipl.-Inf. Michael 'Mickey' Lauer mickey at tm.informatik.uni-frankfurt.de | | Raum 10b - ++49 69 798 28358 Fachbereich Informatik und Biologie | |----------------------------------------------------------------------------| From chrishbarker at home.net Mon Jun 18 20:01:33 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 18 Jun 2001 17:01:33 -0700 Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? References: <3B2B60AD.942719AE@earthlink.net> <9gkio3$9jcft$5@ID-89274.news.dfncis.de> <3B2D3975.31BF1984@earthlink.net> Message-ID: <3B2E965D.B3AF19DC@home.net> Ron Stephens wrote: > > Is there an extensive tutorial or good documentation of wxPython on the web > that one can learn from? The wxPython tutorial on the wxPython web site is > quite short and is insufficient for a klutz like me. This has been a common complaint, and I think the reason it hasn't been better addressed is that once people get past the beginning of the learning curve, they realise that they really don't need it. It doesn't take too long to get rolling. I found that I really did need to "get" OO programming in Python before I could do anything with wxPython. There is a work in progress getting started guide here: http://wxpython.org/cgi-bin/wiki/Getting_20Started Also, be sure to take a good look at the demo, there is a lot of good stuff in there, and a lot of us find we learn best by example anyway. Good luck! -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From donn at u.washington.edu Wed Jun 6 14:06:07 2001 From: donn at u.washington.edu (Donn Cave) Date: 6 Jun 2001 18:06:07 GMT Subject: Calling a C function that alters the passed argument? References: <9flmg3$1s4b$1@newshost.nmt.edu> Message-ID: <9flref$ong$1@nntp6.u.washington.edu> Quoth "Bob Greschke" : | Here's the C function I want to call from Python: | | char *boo(ANumber) | int *ANumber; | { | *ANumber = 42; | | if (something went wrong) | return "An error message"; | | return (char *)NULL; | } | | | How would I write the wrapper function for this? All I can find are | examples where the wrapper functions deal with the returned value from | C functions. Trying to understand your question, the assumption I'm leaning towards is that you want the Python function to preserve this API. Don't even think about it. Your choices are basically error, number = boo(), or number, error = boo(), or try: number = boo() except SomeError, val: print 'boo error', val The last is by far the best, in most cases. The options do not include modifying an integer parameter, that isn't how Python works. You may want to look at some examples for the way to set an exception, will probably look something like PyErr_SetString(PyExc_ValueError, "error message shredded"); Then return 0 to signal the exception, instead of PyInt_FromLong(number). Donn Cave, donn at u.washington.edu From wasp at linuxfreak.com Thu Jun 14 08:31:51 2001 From: wasp at linuxfreak.com (Piotr Waskiewicz) Date: Thu, 14 Jun 2001 14:31:51 +0200 Subject: Curses question Message-ID: <1462444.zMo0RvPX7a@mysiu-pysiu> Hi! Can I resize curses windows without destroying them? Or is there bind to curses wresize()? TIA From rgruet at intraware.com Sun Jun 17 16:21:36 2001 From: rgruet at intraware.com (Richard Gruet) Date: Sun, 17 Jun 2001 20:21:36 GMT Subject: why is there no class (static) methods in Python ? Message-ID: <3B2D114E.7B39D954@intraware.com> Hi all, I (and other people on the Python french mail list) wonder why there are no class (static) methods in Python. You cannot define a really unbounded (ie to an instance) method within the namespace of a class. It's not natural nor elegant to have to create an instance to call a method which is not related to a particular instance. We would like to be able to write things like: class C: def staticFoo(x): print x C.staticFoo(1) Cheers, Richard -------------- next part -------------- A non-text attachment was scrubbed... Name: rgruet.vcf Type: text/x-vcard Size: 370 bytes Desc: Card for Richard Gruet URL: From aleaxit at yahoo.com Thu Jun 14 12:40:08 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 18:40:08 +0200 Subject: Office's Access XP ODBC DBI from PythonWin References: <9ga6cd02m44@enews1.newsguy.com> <3B28CE04.3090009@ActiveState.com> Message-ID: <9gapde0g50@enews1.newsguy.com> "Mark Hammond" wrote in message news:3B28CE04.3090009 at ActiveState.com... ... > > Hmmm, I did send you my partially-fixed version, yes...? > > Hrm - I wouldn't be surprised if either I have asked this before, or you > have sent it before, but what fixes do you have? I just checked in a > fix to the username and password fields when not specified as part of > the connection string. It missed ActivePython 211 and win32all-140 tho :( I checked out the odbc.* and dbi.* that were in CVS about 10 days ago, and fixed all object construction/destruction to reliably and consistently use PyObject_New and PyObject_Del. The mix of PyObject_NEW and PyMem_DEL &c was apparently the root cause of several crashes I was having. I'll be happy to resend the fixed sources again whenever you want me to! Alex From llothar at mailandnews.de Thu Jun 21 08:44:52 2001 From: llothar at mailandnews.de (Lothar Scholz) Date: Thu, 21 Jun 2001 14:44:52 +0200 Subject: Line Coverage Analyser Message-ID: <02r3jtco1lmi7foqu5a7lt34kor6v631tg@4ax.com> Is there something like TrueCoverage from Numega to do this with Python programs. I think this will be needed a lot for high quality programs. From aleaxit at yahoo.com Mon Jun 18 04:37:27 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 18 Jun 2001 10:37:27 +0200 Subject: COM method with pointer args References: <8b5e42a6.0106171630.43a3303a@posting.google.com> Message-ID: <9gkek6024kl@enews2.newsguy.com> "Levente Sandor" wrote in message news:8b5e42a6.0106171630.43a3303a at posting.google.com... > I need to automate some jobs in CorelDRAW, and there are a lot of methods which > returns their results through pointers. > Is there a possibility to use a COM method which requires pointer arguments? > (From Python, of course :) Sure, as long as you have a type library that is correct. Make sure your Python client IS using the type library, e.g. by using win32all.client.gencache.EnsureDispatch(...) rather than win32all.client.Dispatch(...) Once the type-library IS thus being used, all [out] parameters of methods will disappear from the parameter-list and become extra items in a returned tuple, instead. [in,out] parameters will be BOTH in the parameter-list (for the [in] part only) AND extra items in the returned tuple (for the [out] part). You can read the Python source that is generated (in the gen_py subdirectory of D:\Python21\win32com, or wherever you installed) in subdirectories whose names are the GUID's for the type-libraries you have "gencached". (You can also choose to use makepy and build the wrapper for a whole typelibrary into one .py file, but the "on-demand" approach that EnsureDispatch uses by default is superior, IMHO -- YMMV). Alex From Eugene.Leitl at lrz.uni-muenchen.de Sun Jun 10 07:20:39 2001 From: Eugene.Leitl at lrz.uni-muenchen.de (Eugene.Leitl at lrz.uni-muenchen.de) Date: Sun, 10 Jun 2001 13:20:39 +0200 Subject: floating point in 2.0 References: <9fiptc$m9d$1@panix2.panix.com> <3B1D154B.81016685@home.net> <9fj706$27u$1@panix3.panix.com> <3B1FCDF3.6DBFABF8@home.net> <0hGU6.182229$eK2.41756663@news4.rdc1.on.home.com> Message-ID: <3B235807.B2D0F0D2@lrz.uni-muenchen.de> Nick Perkins wrote: > That is why decimal numbers are more powerful than binary, because for any > given length, the set of numbers representable in decimal is a superset of > those representable in binay. Binary representation is most natural in digital systems. Binary ALUs are faster and use less transistor resources than e.g. BCD. The Zuse, one of the first computers, was binary already. As to Python, it is an interpreted language. Talking about numerics hardware efficiency aspects in absence of a compiler is ridiculous. I think the difference between 2/3 and 2.0/3.0 should be easy enough to grasp, and the standard behaviour should not be changed, for no good reason at all. The L numbers are nice, and if we'll get rationals, that would be very nice, too. ______________________________________________________________ ICBMTO : N48 10'07'' E011 33'53'' http://www.lrz.de/~ui22204 57F9CFD3: ED90 0433 EB74 E4A9 537F CFF5 86E7 629B 57F9 CFD3 From mertz at gnosis.cx Wed Jun 13 18:42:11 2001 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Wed, 13 Jun 2001 18:42:11 -0400 Subject: Python equivalent of CPAN Library modules (fwd) Message-ID: davehurt at flash.net (David Hurt) wrote: |One such source may be the perl CPAN repository. The CPAN has a collection of |very high quality libraries for a variety of applications. If these libraries |could be converted to equivalent python, then the libraries could be used for |python programs :) I think Hurt has hit on one very important idea, and then been misled by one idea that goes in the wrong direction. Having something like CPAN would be a wonderful thing. There are a few things that CPAN has that the Vaults lack. One very important one is an actual mirroring of the modules contributed. Often it's fine to link through to a maintainer's site... but that leads to a lot of different web hosts that might fail. Some sort of combination might be best, allow maintainers to keep their own pages, but simultaneously provide a mechanism for incremental mirroring of the modules themselves. Another nice thing in CPAN is the ability to directly install new modules from a search interface. ActiveState's Python distribution has done something much like this for a limited (but useful) collection of modules. Maybe something like that could be extended, or maybe [distutils] could be enhanced to allow remote installs somehow (maybe in cooperation with the to-be-developed Parnassus++). The part of Hurt's idea that I think strays is the goal of directly translating Perl modules, based on what's popular in the Perl world. There may indeed be particular modules that Perl has that Python could use (or vice versa). But on the other hand, something popular under Perl may be less useful, or wholly irrelevant, under Python. You really just have to look at capabilities on a case-by-case basis. And even for specific goals, the actual -organization- of functionality in Perl modules might be better arranged otherwise for Python. Certainly this is not trying to discourage Hurt from contributing any modules he thinks might benefit the Python community... but Python doesn't lack an overall breadth and depth of useful modules. But Python -could- stand some additional improvements in the "social infrastructure" of code sharing. Yours, Lulu... From sill at optonline.net Sun Jun 17 23:49:35 2001 From: sill at optonline.net (Rainy) Date: Mon, 18 Jun 2001 03:49:35 GMT Subject: pair programming, vim? References: Message-ID: On 17 Jun 2001 19:01:59 GMT, Remco Gerlich wrote: > Rainy wrote in comp.lang.python: >> Did anyone try pair programming over the net? In particular, is it possible >> to set up vim with a shared buffer or, failing that, some other editor? If >> so, does anyone want to try pair programming some small project? > > Emacs. > > The simplest possible way, as someone on the emacs group pointed out, is > M-x make-frame-on-display. Simply open another window of this same emacs > instance on that computer there, and you can both type in the same buffer, > and see what the other does. Obviously, there are problems (if one quits > then both quit, and the remote user has total access to the files of the > local user running emacs). > > Another option is shbuf: > http://www.bluetail.com/~luke/shbuf/shbuf-1.1.tar.gz > > One user starts a server (written in erlang, you need an erlang interpreter) > and others can connect to it, to share a buffer. Only one person can edit at > a time, the others watch. > Thanks, I'll look into them. -- Jupiter and Saturn Oberon Miranda And Titania Neptune Titan Stars can frighten - Syd From aleaxit at yahoo.com Wed Jun 6 09:58:51 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 6 Jun 2001 15:58:51 +0200 Subject: Error checking for 'raw_input( )'? References: <7b515e0f.0106060455.4093daa0@posting.google.com> Message-ID: <9flcus01b04@enews2.newsguy.com> "eric_brake" wrote in message news:7b515e0f.0106060455.4093daa0 at posting.google.com... > What is the best way to detect whether number or letter strings were > entered into the "raw_input( )" field. I want to be able to send a > error message to the user if they enter the incorrect type > (numbers,letters,etc). import string transl = string.maketrans('','') # dummy translation myline = raw_input() noletters = string.translate(myline, transl, string.letters) nodigits = string.translate(myline, transl, string.digits) def check(xname, original, translated): if original: print "the line was not empty" else: print "the line was empty" return if translated==original: print "there were no", xname else: print "there were some", xname if translated: print "there were some non-%s"%xname else: print "there were nothing but", xname check('letters', myline, noletters) check('digits', myline, nodigits) Is this the sort of thing you want to do...? Of course, you can structure the code differently, but the general idea of string.translate with a dummy translation table to get a version with all characters of a certain kind removed is pretty good & fast. For checks that are much more sophisticated, you may want to use regular expressions instead -- but in general they're nowhere as simple as string stuff, for what you CAN do with strings... and Keep It Simple, S***** is The Prime Directive of programming...:-) Alex From max at alcyone.com Sat Jun 2 13:33:58 2001 From: max at alcyone.com (Erik Max Francis) Date: Sat, 02 Jun 2001 10:33:58 -0700 Subject: What does x[:]=[4,5,6] mean? References: <9fb7cu$lq6$1@newsreaderg1.core.theplanet.net> Message-ID: <3B192386.61911E8@alcyone.com> Franz GEIGER wrote: > In site.py I saw > sys.path[:] = L > What does this mean? Why is the '[:]'? Why not simply > sy.path = L ? It's a peculiar construct that changes the list in place, rather than making sys.path point to a new list: max at oxygen:~% python Python 2.0 (#2, Apr 4 2001, 19:28:30) [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2 Type "copyright", "credits" or "license" for more information. >>> l = [1, 2, 3] >>> m = l # new list that points to l, all changes to l will show up in m >>> l[:] = [4, 5, 6] # change l in place >>> l [4, 5, 6] >>> m [4, 5, 6] >>> l = [7, 8, 9] # point l to a new list >>> l [7, 8, 9] >>> m # m still refers to the original list [4, 5, 6] I suspect that this is revealing an implementation detail, where the internals of the system really would like sys.path to always point to the same list. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Love is the triumph of imagination over intelligence. \__/ H.L. Mencken REALpolitik / http://www.realpolitik.com/ Get your own customized newsfeed online in realtime ... for free! From insanc at cc.gatech.edu Sat Jun 16 01:43:11 2001 From: insanc at cc.gatech.edu (Holland King) Date: 16 Jun 2001 05:43:11 GMT Subject: bad python display References: <9gdie8$r2v$1@solaria.cc.gatech.edu> Message-ID: <9gerlf$ec3$1@solaria.cc.gatech.edu> In comp.os.linux.misc Bob Hauck wrote: : On 15 Jun 2001 17:59:36 GMT, Holland King wrote: : Do you have KDE's "apply colors and fonts to other apps" button checked : in the Control Center? That might have something to do with it. i can't say for sure offhand, but i do know that it doesn't work under gnome either (which i found out with more testing). -- --- Joseph Holland King | "God whispers to us in our pleasures, speaks in our | conscience, but shouts in our pains: it is His | megaphone to rouse a deaf world." C. S. Lewis From m.faassen at vet.uu.nl Sat Jun 30 06:31:33 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 30 Jun 2001 10:31:33 GMT Subject: PEP scepticism References: Message-ID: <9hk9q5$cnu$2@newshost.accu.uu.nl> Tim Peters wrote: > [Martijn Faassen] >> Which is why a system more or less *forcing* core developers to look >> at these issues *only* for a while may be good. > Afraid it can't be done: most development comes from volunteer time, and > volunteers can't be forced to do anything. Of course, but even volunteers can self-impose restrictions. People already do that. For instance, there's the restriction that things don't go in if Guido doesn't like them. This is more or less a self imposed restriction. So which is why I said 'more or less forcing'. Actual forcing is of course undesirable, and we should all be glad it's impossible (PSU excepted). > If some area is lacking, what it > needs is new volunteers who *want* to work in that area, and, indeed, want > to work in that area so much that they'll freely contribute a good part of > their lives to do so. Of course this is needed. But a collective mental shift in focus once every while from core language features to more 'peripheral' work could be supportive of such people, if nothing else. If-you're-channeling-Guido-there-goes-the-PEP-I-submitted-last-night-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From Dave.Haynes at sia-mce.co.uk Fri Jun 1 09:28:11 2001 From: Dave.Haynes at sia-mce.co.uk (Dave Haynes) Date: 1 Jun 2001 06:28:11 -0700 Subject: Returning 'None' on Instantiation ? Message-ID: Is there a way to optionally return 'None' on instantiation? I'm thinking of something like the following: class myClass: def __init__(self, param): if : else: myParam = GetParam() myObj = myClass(myParam) if myObj: print 'Okay' else: print 'Couldn't make myObj from myParam' This is a fairly common state of affairs. If there's nothing specific in Python to accomodate this, what methods are considered robust by this NG? Best Regards, Dave. From jkraska1 at san.rr.com Tue Jun 26 02:18:37 2001 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 26 Jun 2001 06:18:37 GMT Subject: Pythoin MUD (PyMUD?) References: <9gqq3t$hvs$1@brokaw.wa.com> <3B36D220.52C5CB86@cosc.canterbury.ac.nz> Message-ID: >Stackless could be a solution. Pre-emptively scheduled >microthreads. An aside: It's peudo-preemption, really. Time spent in external modules and the like is not preempted, so unexpected behaviors can arise. C// From machin_john_888 at hotmail.com Thu Jun 21 20:19:04 2001 From: machin_john_888 at hotmail.com (John Machin) Date: 21 Jun 2001 17:19:04 -0700 Subject: Can anyone build ExtensionClass.c using Borland compiler? References: Message-ID: <92ae279c.0106211619.44db8b47@posting.google.com> "Steve S.L. Wong" wrote in message news:... [snip] > But this fails: > > Error: Unresolved external '__Py_DeAlloc' referenced from > C:\PYTHON21\ZODB\ZODB\EXTENSIONCLASS\SRC\EXTENSION.OBJ Is this an *EXACT* cut-and-paste of the error message? C:\Python21\include>grep -i _py_dealloc *.h object.h:extern DL_IMPORT(void) _Py_Dealloc(PyObject *); object.h:#define _Py_Dealloc(op) ((op)->ob_type->tp_free++, (*(op)->ob_type->tp_ dealloc)((PyObject *)(op))) object.h:#define _Py_Dealloc(op) (*(op)->ob_type->tp_dealloc)((PyObject *)(op)) object.h: _Py_Dealloc((PyObject *)(op)) object.h: _Py_Dealloc((PyObject *)(op)) ===> There is no two-leading-underscores-and-capital-A function/macro in the include files. There is a one-leading-underscore-and-lowercase-a variety. The extra underscore is added on the trip from .c to .obj but Borland don't change the case of your letters! If the source actually has 'A', then while awaiting better advice, you may like to try it with the 'A' changed to an 'a'. Otherwise you have a number_of_underscores problem ... sorry, can't help, this is black magic to me. However here's a very potent white magic spell: use the distutils kit to build your extensions. It saves all the mucking about with weird Borland command-line syntax, makefiles, etc. Once you've created a 'setup.py' (which itself becomes good documentation!) for each extension, extensions just *build*. DOS-prompt> python setup.py build --compiler=bcpp This is documented in the 'Installing Python Modules' manual. Hope this helps, John From duncan at NOSPAMrcp.co.uk Fri Jun 22 12:04:28 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Fri, 22 Jun 2001 16:04:28 +0000 (UTC) Subject: NT Service and COM References: <9gu4nf$553$1@troll.powertech.no> Message-ID: "Syver Enstad" wrote in news:9gu4nf$553$1 at troll.powertech.no: > > "Andr?" wrote in message > news:fed2e489.0106211103.3c894ab3 at posting.google.com... >> Hi. I found this example in Python Programming on Win32, page 349. >> I have not tested it. Am typing in a hurry, beware of tpyos: > > Yes, but that ain't doesn't expose no COM server. If you ever find out > Duncan I'd be really pleased to hear what you've figured out. I've only > come so far as to look at the .py file that implements local servers > for python. Take a look at win32com.server.localserver.py to see how > vanilla pythoncom objects are exposed like a localserver. > I have got a COM server working as a service now. The only problem left is security. If the service runs under my userid everything works fine, but if I install the service as the local system user (i.e. the default) then attempting to access the COM object throws a com error 'Access is denied'. I'm not sure how to get round this. I can use DCOMCNFG to give access, but I feel I should be able to set the security from inside the process. Unfortunately I cannot find a combination of parameters to pythoncom.CoInitializeSecurity that doesn't either complain 'obAuthSvc must be None or an empty sequence' or GP fault (if I give it obAuthSvc set to None if complains, if I give it an empty sequence it dies). I'll post my minimal COM service when I have tidied it up a bit. -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From Achim.Gaedk at zpr.uni-koeln.de Tue Jun 19 10:11:54 2001 From: Achim.Gaedk at zpr.uni-koeln.de (Achim Gaedke) Date: Tue, 19 Jun 2001 16:11:54 +0200 Subject: Bug in expatreader... References: Message-ID: <3B2F5DAA.4C4D2AEC@zpr.uni-koeln.de> Martin von Loewis wrote: > The bug is in your code, not in the expatreader. After parsing has > started, you must not call setContentHandler anymore. The behaviour is > undefined if you do. I.e. with SAX, you cannot switch the content > handler when parsing. The bug is eleminated in next version, see http://sourceforge.net/projects/pyxml and http://sourceforge.net/tracker/?func=detail&atid=106473&aid=433761&group_id=6473 From bob at passcal.nmt.edu Fri Jun 8 15:37:44 2001 From: bob at passcal.nmt.edu (Bob Greschke) Date: Fri, 8 Jun 2001 13:37:44 -0600 Subject: Passing back an array from an extension module? References: <9fqqqo$1p3e$1@newshost.nmt.edu> Message-ID: <9fr9e0$21im$1@newshost.nmt.edu> Well, I'm not actually going to be doing any math on the values in the array, not in an array-wide sense anyway. The values in the array end up just being the base values of a graph's y-axis values. These numbers are going to be large, so they will all have to be scaled down on the fly anyway. Plus, the original values need to be retained in case the user wants to click on a point to see what the actual value is, etc. So this brings me back to really just needing a tuple of numbers, which I think I can create in, and pass back from a C function (see another post in this thread), but I'll have to try it and see how much time it is going to take to do the creation. We're talking, usually, several hundred thousand points, and, like I said, up to 16M. It takes several seconds just to read through each data file...um...did I mention that there can also be up to about 700 raw data files?? ;-) Bob "Chad Everett" wrote in message news:slrn9i25fi.tln.chat at linuxsupreme.homeip.net... > On Fri, 8 Jun 2001 09:28:33 -0600, Bob Greschke wrote: > >Is this a job for NumPy? > > Page 107 of "Python Essential Reference" re: the array modules > states: "....The resulting arrays are not suitable for numeric > work....To create storage- and calculation-efficient arrays, use > the Numeric extension" In other works, use NumPy. > > If I am interpreting your question correctly, I think the answer > is 'yes' it's a job for NumPy. From tim.one at home.com Wed Jun 27 13:25:33 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 27 Jun 2001 13:25:33 -0400 Subject: PEP 260: simplify xrange() In-Reply-To: <3B3A08B5.3C142546@darwin.in-berlin.de> Message-ID: [Dinu Gherman, on extend range/xrange to floats] > No, I haven't followed the discussion... but you asked > about an implementation; I'm using the one below. > > Dinu > > > def frange(start, end=None, inc=None): > "A range function, that does accept float increments..." > > if end == None: > end = start + 0.0 > start = 0.0 > > if inc == None: > inc = 1.0 > > L = [start] > while L[-1] + inc < end: > L.append(L[-1] + inc) > > return L >>> print len(frange(0.0, 1.0, 0.1)) 11 >>> That's the kind of "inexplicable" crap we don't want to have to try to explain : repeated addition is a Bad Idea for floats. You can improve the numeric quality of the results by generating via L = [] while 1: next = start + len(L) * inc if next >= end: break L.append(next) instead (repeated addition accumulates rounding errors without bound; the alternative suffers no more than 2 rounding errors (total) for each element produced). Then it returns 10 elements in the example above. From MarkH at ActiveState.com Tue Jun 12 04:17:20 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 12 Jun 2001 08:17:20 GMT Subject: 1.5.2, COM, Unicode References: Message-ID: <3B25D038.9080505@ActiveState.com> Grant Edwards wrote: > I'm pretty sure I got e-mails like that before, and I was > wondering what the COM support library did with them in 1.5.2. > Were all of the Unicode strings in COM objects automagically > converted in to latin-1 encoding? It used "mbcs" encoding, which I believe is commonly "latin-1". If you really want, you should be able to modify sitecustomize.py to get the old behaviour back. However, I recommend that you just suffer through this to avoid other "gotchya's" in the future. Mark. From boyd at insultant.net Thu Jun 7 14:33:22 2001 From: boyd at insultant.net (Boyd Roberts) Date: Thu, 7 Jun 2001 20:33:22 +0200 Subject: Bios calls in Python? References: Message-ID: <9fohg7$1bp$1@neon.noos.net> "Bill Walker" a ?crit dans le message news: thqrganuje8538 at corp.supernews.com... > Is it possible to make BIOS calls in Python (Windows version)? In > particular, I would like to plot graphic points in EGA resolution to the > console screen. something is seriously wrong if you need to do that. From aahz at panix.com Sun Jun 3 18:05:47 2001 From: aahz at panix.com (Aahz Maruch) Date: 3 Jun 2001 15:05:47 -0700 Subject: Inexact representation cases (Re: Against PEP 240) References: Message-ID: <9fecbr$i6f$1@panix3.panix.com> In article , Michael Hudson wrote: >"Tim Peters" writes: >> It turns out that the closest you can get in IEEE double is >> >> 1.1 ~= 2476979795053773 / 2**51 >> >> which is, as a *decimal* number, *exactly* >> >> 1.100000000000000088817841970012523233890533447265625 > >How did you get these numbers? I'm sure you posted the routine a week >or so back, but I can't dig it out of google. > >I want to write a sys.displayhook that prints floats exactly, just for >extra geekiness value. You can use Decimal.py (with its associated bugs) from http://starship.python.net/crew/aahz/ -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 I surf faster than you do, monkey boy. (My take on Netscape vs. Lynx) From sussman at red-bean.com Sun Jun 17 18:29:24 2001 From: sussman at red-bean.com (Ben Collins-Sussman) Date: Sun, 17 Jun 2001 17:29:24 -0500 Subject: graceful version detection? Message-ID: <3B2D2F44.50007@red-bean.com> Please excuse me if this is a common newbie question; I didn't find it in the FAQ or tutorial. If I write a python script that uses 2.X features, and then run it with a 1.X interpreter, I get a bunch of exceptions. Presumably this happens during the initial byte-compilation. I'd like the script to instead gracefully print: "Sorry, this program requires Python 2.0 or higher." I tried writing some code to do this by parsing `sys.version' at the top of my program; but as I said, the byte-compiler seems to choke first. What's the correct solution? Please cc: my email address (sussman at red-bean.com), as I don't read this group regularly. Thanks in advance -- Ben Collins-Sussman sussman at red-bean.com From paulp at ActiveState.com Wed Jun 20 22:53:16 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Wed, 20 Jun 2001 19:53:16 -0700 Subject: PEP 255: Simple Generators References: <9gnv2o$its$1@nntp6.u.washington.edu> Message-ID: <3B31619C.30084F1D@ActiveState.com> David Bolen wrote: > >... > > > If generators absolutely have to reuse syntax (which is not the > > case), I would prefer the keyword 'class' over 'def', since calling a > > generator creates an instance. > > But so does any number of factory functions that return objects (form > closures, etc...), e.g.: > > def f(): > return UserList.UserList([1,2,3]) > > (using UserList to avoid the type/class question) (as I've said in the python-iterators mailing list) The interesting thing isn't what gets returned. The interesting thing is what the compiler does to make sure that an iterator gets returned. It is radically different than a regular function. Consider: >>> def a(foo): ... print "Testing foo" ... if foo: ... print "foo was true" ... else: ... print "foo was not true" ... return 5 ... >>> def b(foo): ... print "Testing foo" ... if foo: ... print "foo was true" ... else: ... print "foo was not true" ... yield 5 ... >>> a(1) Testing foo foo was true 5 >>> a(0) Testing foo foo was not true 5 >>> b(1) >>> # where is my output??? ... >>> b(0) >>> # where is my output??? ... >>> These two functions were compiled in very different ways. The return value is irrelevant. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From dav-nospam-id at westco-nospam-ntrol.com Fri Jun 22 02:46:38 2001 From: dav-nospam-id at westco-nospam-ntrol.com (David Brown) Date: Fri, 22 Jun 2001 08:46:38 +0200 Subject: Zope and PHP Nuke Message-ID: <9guphk$5in$1@news.netpower.no> I have been looking around some websites, and have come across Zope and PHP Nuke. As far as I can see, both systems provide a basis for a complex website including discussion forums and the like. Would it be fair to say they cover similar uses, or are there major differences? My impression is that Zope is more demanding on the system, and on configuration and maintainance, but has better facilities for letting people remotely add articles to the site. I know that Zope is Python-based, while PHP Nuke is (oddly enough) PHP-based, and I am at least basically familiar with both languages. What I am interested in doing is setting up a relatively simple discussion forum system for our company. The aim is mainly to provide a common point were we can hold information and comments regarding changes, bugs, or ideas for our products. Initially, this is only for internal use, but later it should be accessible externally too. There will not be any really sensitive data on the site, so we don't need high security (other than the firewall and filtering for the web server itself), but we need at least to be able to restrict access to areas based on user names and passwords. As far as I undertand it, both Zope and PHP Nuke would be suitable for this. It is important that the system can run on both Linux and NT - we currently run a small Apache + PHP system on NT at the moment, but will later move to Linux. How easy is it to migrate data from one system to the other when we switch over? For the backend, am I correct in thinking that both systems support MySQL and postgreSQL ? Is there any particular reason for choosing one over the other here? (Speed is not vital as this will be a low load, and I think MySQL's more limited data integrity protection will be perfectly sufficient.) Are there binaries for postgreSQL available for NT anywhere? Do Zope and PHP Nuke support different languages for different users? English is fine for me, but many people here (in Norway) would prefer the texts to be in Norwegian, even if the posts themselves are in English. There are plenty of sites describing Zope and PHP Nuke, and I have read some of the introductionary stuff. But there doesn't seem to be much comparing the two, which would be helpful for people like me who are trying to choose. Any comments or links would be very useful, as would suggestions for alternative systems. Thanks, David Brown Norway From objectway at divalsim.it Tue Jun 26 03:35:22 2001 From: objectway at divalsim.it (Nicola Musatti) Date: Tue, 26 Jun 2001 09:35:22 +0200 Subject: Newbie seeks help on case preserving substitutions References: <3B3767BB.A882F8@divalsim.it> Message-ID: <3B383B3A.F63FBA56@divalsim.it> Hallo, Marcin. Marcin 'Qrczak' Kowalczyk wrote: [...] > What should it do if strings have different lengths? E.g. substitute > NIcoLA with properly cased Musatti - how to define the problem then? Luckily I defined the problem, so I get to set its bounds :-) My strings have two parts: an initial two letter code and a subsequent name. Those strings that are neither all uppercase nor all lowercase always have an uppercase code and a capitalized (i.e. first letter upper, all others lowercase) name. In theory it would be nice to be able to apply special rules for names that are made of acronyms and/or multiple words, but it's not that important. Ciao, Nicola From joonas at olen.to Fri Jun 15 15:00:26 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Fri, 15 Jun 2001 22:00:26 +0300 Subject: re problem Message-ID: <3B2A5B4A.705B426A@olen.to> I have made a regular expression, that makes html links from plain addresses. It's almost ok but it doesn't work when there is no whitespace before an address. Shouldn't that '(?(?:http|ftp):\S+)(?!\S)', r'\g
', text) -- Joonas Paalasmaa From support at internetdiscovery.com Mon Jun 18 16:28:26 2001 From: support at internetdiscovery.com (Mike Clarkson) Date: Mon, 18 Jun 2001 20:28:26 GMT Subject: idle BUG References: Message-ID: <3b2e552f.2621005@nntp.ix.netcom.com> On Thu, 14 Jun 2001 20:22:08 +0100, Robin Becker wrote: >I think this must be a bug in Tkinter, but since no one ever responds I >thought I'd whine about idle instead. > >I run python2.1 Win95 OSR2. >Start a command window >run python idle.py > >Kill the idle window using the mouse (click on the x). In some unknown >percentage of cases (like 50%) the process hangs and doesn't return to >the command window. Robin, try this (you'll have to fix the tk.eval lines back up to be all one line). In Tkinter.py, change quit() to def quit(self): """Quit the Tcl interpreter. All widgets will be destroyed.""" self.tk.eval('foreach w [winfo child .] {wm protocol $w WM_DELETE_WINDOW {}; catch {destroy $w}}') self.tk.eval('catch {set w .; wm protocol $w WM_DELETE_WINDOW {}; destroy $w}') self.tk.quit() If it works for you, I'll explain why it's required under Tkinter, but not Tk. This makes self.quit() do what it's documented to do, and leaves self.tk.quit (which is _tkinter.quit) to do what it does now, namely signals the mainloop to end but destroys no widgets. >The hung process is very destructive and makes it impossible to reboot >the machine properly. This bug has been present for a very long time and >I'm fed up with it. It's a nasty bug, and this seems to fix it. It causes a harmless error exiting idle that I'll look at (I think a a winfo_exists() check needs adding in Tkinter.unbind as bullet-proofing). Mike. From tgos at spamcop.net Fri Jun 1 13:06:25 2001 From: tgos at spamcop.net (TGOS) Date: 1 Jun 2001 12:06:25 -0500 Subject: best language for 3D manipulation over web ? References: <9f7eqe$gvd$1@oslo-nntp.eunet.no> Message-ID: [Rewritten and shortened because of top-posting] On Fri, 1 Jun 2001 09:13:16 +0200, "Thomas Hansen" wrote: > "Jacqueline L. Spiegel" wrote: > >> Hi All, >> >> I will be writing a program that needs to be accessible over the web that >> will seek to manipulate objects in three dimensions through the access of >> an oracle database. > www.wildtangent.com > Down the Game Driver, start hitting your favourite *JavaScript*!! editor, > off you go... > > Thomas > > PS! > It's an ActiveX object, Ergo it won't work in my browser, nor in any other browser except IE. > wraps around DirectX to make scripting 3D games > possible. Ergo it won't work on any plattforms except Windows. We are talking about Java here, not C++ and the main advantage of Java is plattform indepency. Why destroying that if it's not necessary? There's Java3D available for quite some time now. It's a plattform independend Java plug-in that makes use of OpenGL for displaying 3D animations with hardware support. It's support for nearly all propagated PC plattforms which can also support OpenGL (in case of Windows, there are even two versions: one version running on top of OpenGL and one running on top of Direct3D; I'd choose the OpenGL version, because if you have a GeForce or Rendeon graphics adapter, you'll have a lot better performance thanks to hardware T&L). > I've seen it with a "need for speed" kind of game and it really works (on a > PII 300mHz, ATI RAGE PRO 8MB) I've seen that too and it even works without hardware acceleration. http://www.minatrix.com/burningmetal2.html But with Java3D you'll also have texture filtering and real shading. http://java.sun.com/products/java-media/3D/index.html Plattform support: Solaris (Sparc), Windows (x86), Linux (x86), HP-UX, AIX, SGI Irix -- TGOS From rdsteph at earthlink.net Tue Jun 19 21:30:56 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Wed, 20 Jun 2001 01:30:56 GMT Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: Message-ID: <3B2EADB0.9DBC6FC8@earthlink.net> Of course, each person undoubtedly has a different set of concepts in mind when he thinks of "PythonCard"..still, an intriguing amount of interest in 24 hours... From bos at hack.org Wed Jun 13 20:05:53 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Thu, 14 Jun 2001 02:05:53 +0200 Subject: Newbye and packages References: <3b24e01f@hpb10302.boi.hp.com> Message-ID: <3B27FFE1.B7F0D4D8@hack.org> Toni wrote: > The reason for having the base image_file class is for coding default > values for uncommon things. For example, if I coded a bmp_file class, I > wouldn't code the transparency() method and let de base class answer > 'no'. To save you lot of time, have a look at the Python Imaging Library. Browse around under http://www.secretlabs.com/ to find it. -- Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From aleaxit at yahoo.com Tue Jun 12 12:48:11 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 12 Jun 2001 18:48:11 +0200 Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> Message-ID: <9g5h4c01rba@enews2.newsguy.com> "thinkit" wrote in message news:9g5d3p0f0p at drn.newsguy.com... > humans should use a power of 2 as a base. this is more logical because it > synchs with binary, which is at the very heart of logic--true and false. it is > more natural perhaps, to use decimal-- Perhaps. It seems to have been used by most cultures throughout the world, though far from all. Octal was used by some American tribes, and some linguists believe they find decisive traces in Indo-European and Japanese to show that their common root (so- called Nostratic) used octal. Vigesimal was clearly popular recently enough that French still says "seventy" as "sixty and ten", "eighty" as "four twenties", "ninety" as "four twenties and ten". Sexagesimal, used by Sumer and Babylonian astronomers (they used decimal for most computation), has left indelible traces in our time-measurement (60 seconds to a minute, 60 minutes to an hour) and angle-measurement (ditto). > but logic should, and will, win out. Perhaps. It never did, so far, but it sure seemed to for LONG times. For example, Parmenides used logic to prove ZERO was unusable nonsense (his disciple Zeno, not to be confused with the founder of Stoicism of course, bult beautiful paradoxes to illustrate his master's thesis), and thus did logic manage to make arithmetic almost unusable for 1,500 years in the West. Fortunately, in the end, the Eastern mystics won out, putting logic in its place and celebrating the Abra Kad' Abra ("air void of air" -- aren't these Sanskrit words STILL the ones that come to mind most readily when thinking of a spell of mystical incantation?-), Non-Being, the Void at the Core of All, etc, etc. At long last, the illogic and absurd Zero got into the number system -- eventually, since Practicality Beats Purity, its use became universal. Nowadays, of course, the adorers of Logic try to sweep THIS little tidbit of the history of science and mathematics under the carpet...:-). I highly recommend in-depth study and comparison of the Tractatus Logico-Philosophicus (a genius in his twenties trying to fix precisely the conditions in which Logic will let us speak) and the Philosophical Investigations (the same genius, 30 years later, explaining WHY logic will never work as the One True Way of human discourse...). As eminently NON-logical William Blake had written, "If the fool would but persist in his folly, he would become wise" -- few logical fools have shown the same persistence and greatness as Ludwig von Wittgenstein, to enable them to reach the wisdom of mysticism by dint of inflexibly consistent application of Logic...:-). Alex From new_name at mit.edu Fri Jun 1 08:41:05 2001 From: new_name at mit.edu (Alex) Date: 01 Jun 2001 08:41:05 -0400 Subject: Appliying method to list of objects References: <3B172724.17E588E2@my.signature> Message-ID: > I can't see how that can be regarded as any better. It's no clearer, > and it wastes time doing unnecessary work -- i.e. building a list and > then throwing it away. Yeah, good point. In fact, it's been exactly when I wanted to make such a list that I've done that. Alex. From aahz at panix.com Sun Jun 24 20:53:45 2001 From: aahz at panix.com (Aahz Maruch) Date: 24 Jun 2001 17:53:45 -0700 Subject: Is this a true statement? References: <9h61aa$bg7h5$1@ID-11957.news.dfncis.de> Message-ID: <9h622p$f54$1@panix6.panix.com> In article <9h61aa$bg7h5$1 at ID-11957.news.dfncis.de>, Emile van Sebille wrote: >"Grant Edwards" wrote in message >news:slrn9jd1ki.mo.grante at tuxtop.visi.com... >> >> One could use a "deeply embedded" Python bytecode interpreter >> running inside the kernel to allow the user to write a driver >> in Python. It would take a fair amount of work, but I don't >> think it would be particularly difficult -- at least under >> Linux. People have already a lot of the requied work in order >> to run a Python interpreter on embedded systems. >> >> Sounds like a good MS project to me... > >I hadn't considered the possibility of a "deeply embedded" python solution, >but it certainly has possibilities. > >Anyone got a virally infected copy of windows os source code to play around >with? I think Grant meant "MS" as in "masters degree". -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Those who do not remember the past are condemned to repeat it." From mrq at for.mat.bham.ac.uk Mon Jun 11 08:55:17 2001 From: mrq at for.mat.bham.ac.uk (Martyn Quick) Date: Mon, 11 Jun 2001 13:55:17 +0100 Subject: Disabling a Pmw.ComboBox In-Reply-To: References: Message-ID: I'm trying to work out how to `disable' a Pmw.ComboBox (in a similar manner to setting state='disabled' for a Tkinter.Button). One way I thought of doing it was to try setting state='disabled' for the 'arrowbutton' component of the ComboBox. However, this arrowbutton is a Tkinter.Canvas, so doesn't have state as a valid configuration option. Does anybody have a decent way of doing this? (My goal is to be able to allow it be available for use or disabled according to other information.) Thanks in advance for any wisdom on this... Martyn -------------------------------------------------------- Dr. Martyn Quick (Research Fellow in Pure Mathematics) University of Birmingham, Edgbaston, Birmingham, UK. http://www.mat.bham.ac.uk/M.R.Quick From krel at is-antisocial.net Sat Jun 23 16:22:32 2001 From: krel at is-antisocial.net (krel) Date: Sat, 23 Jun 2001 20:22:32 GMT Subject: newbie question: Message-ID: Um, this is certainly a stupid sounding question, what is the syntax for putting data into and retrieving data from a multidimensional list? I checked the docs, perhaps not well enough? -- Never trust anything with more limbs than you. -krel From guido at digicool.com Tue Jun 26 13:59:55 2001 From: guido at digicool.com (Guido van Rossum) Date: Tue, 26 Jun 2001 13:59:55 -0400 Subject: PEP 260: simplify xrange() Message-ID: <200106261759.f5QHxtH15045@odiug.digicool.com> Here's another sweet and short PEP. What do folks think? Is xrange()'s complexity really worth having? --Guido van Rossum (home page: http://www.python.org/~guido/) PEP: 260 Title: Simplify xrange() Version: $Revision: 1.1 $ Author: guido at python.org (Guido van Rossum) Status: Draft Type: Standards Track Python-Version: 2.2 Created: 26-Jun-2001 Post-History: 26-Jun-2001 Abstract This PEP proposes to strip the xrange() object from some rarely used behavior like x[i:j] and x*n. Problem The xrange() function has one idiomatic use: for i in xrange(...): ... However, the xrange() object has a bunch of rarely used behaviors that attempt to make it more sequence-like. These are so rarely used that historically they have has serious bugs (e.g. off-by-one errors) that went undetected for several releases. I claim that it's better to drop these unused features. This will simplify the implementation, testing, and documentation, and reduce maintenance and code size. Proposed Solution I propose to strip the xrange() object to the bare minimum. The only retained sequence behaviors are x[i], len(x), and repr(x). In particular, these behaviors will be dropped: x[i:j] (slicing) x*n, n*x (sequence-repeat) cmp(x1, x2) (comparisons) i in x (containment test) x.tolist() method x.start, x.stop, x.step attributes By implementing a custom iterator type, we could speed up the common use, but this is optional (the default sequence iterator does just fine). I expect it will take at most an hour to rip it all out; another hour to reduce the test suite and documentation. Scope This PEP only affects the xrange() built-in function. Risks Somebody's code could be relying on the extended code, and this code would break. However, given that historically bugs in the extended code have gone undetected for so long, it's unlikely that much code is affected. Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil End: From dsavitsk at e-coli.net Mon Jun 4 12:04:06 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Mon, 4 Jun 2001 11:04:06 -0500 Subject: Programming ASP with ActivePython [also a general Web question] References: <87lmn8fdmi.fsf@penguin.aktivist.ru> Message-ID: "Wartan Hachaturow" wrote in message news:87lmn8fdmi.fsf at penguin.aktivist.ru... * * * * * * > > P.S. Can anyone advise me some nice Python web programming environment > based on *nix? I've checked mod_python -- but it doesn't support sessions > and persistent db connections, and I am too lazy to write them by myself. > Zope seems to be too heavy and bloated (IMHO). > In fact I'd like to have something really working in the production already > (for example, WebWare doesn't seem to me being in that state), fast, and > easy to write for (e.g. also supporting features such as mentioned > sessions, persistent database connections). > Maybe I didn't searched too long, but right now it seems to me (poor man I > am) that ASP on Windows is the only solution. > > P.P.S. I am running IIS 5.0 on Win2k Advanced Server SP2, with ActivePython > 2.1.0.210 Wall in Configure from the perl distribution have you looked at CGIHTTPServer.py (in \lib\)? also Medusa http://www.nightmare.com by sam rushing? i have found that building custom apps from SimpleHTTPServer is really easy, and a good place to start. -d From gerhard.nospam at bigfoot.de Fri Jun 1 18:05:43 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sat, 2 Jun 2001 00:05:43 +0200 Subject: Python 2.1 dependencies References: <3B18151A.E95C4E4B@ucdavis.edu> Message-ID: On Fri, 01 Jun 2001 15:20:10 -0700, Bruce Wolk wrote: >On an RH 7.1 system I rebuilt the source RPMs for Python 2.1. But when >I tried to install expat-1.1-3tummy.i386.rpm, I got the following error > >error: failed dependencies: > libexpat.so.0 is needed by abiword-0.7.13-2 > >This is odd, since /usr/lib/libexpat.so.0 is present on my system, but >also what does Python have to do with abiword? Looks like a RPM annoyance that is safe to ignore (you probably already have another libexpat installed) Just install it with rpm --noedeps packagename.rpm Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://highqualdev.com public key at homepage public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From nhodgson at bigpond.net.au Mon Jun 25 19:31:39 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Mon, 25 Jun 2001 23:31:39 GMT Subject: printer under Win32 References: Message-ID: Geoffrey Gerrietts: > The question is basically: what's the right way to determine page extents > when writing to a printer DC? Detail follows (if it matters): I don't know if it covers this issue but have you examined the printing code used by PythonWin itself in Pythonwin\pywin\scintilla\view.py ? Neil From root at rainerdeyke.com Tue Jun 26 12:09:06 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Tue, 26 Jun 2001 16:09:06 GMT Subject: newbie with major "lambda" problem (perhaps a scope problem as well) References: Message-ID: "Joe Potter" wrote in message news:j5ahjtkfmf32lkqtap0q1u6rig385d7b5i at 4ax.com... > # the "button" below works like a champ !! > #Button(root, text='Fetch', > #command=(lambda v=vars: fetch(v))).pack(side=LEFT) > > # the "button" below does not do anything ?????? > Button(root, text='Fetch', command=(fetch(vars))).pack(side=LEFT) Of course this doesn't work. It calls 'fetch(vars)', and passes the result to 'Button'. Use the lambda, that's what it's there for. Or use one of the 'curry' alternatives (see archives). -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From jtorborg at fnal.gov Thu Jun 7 17:13:56 2001 From: jtorborg at fnal.gov (Julie Torborg) Date: Thu, 07 Jun 2001 16:13:56 -0500 Subject: Generating Multiple Class Instances References: <3B1E9271.B05CC4E3@fnal.gov> Message-ID: <3B1FEE94.D391EDE4@fnal.gov> > We have a winner! D-man's code most closely resembles what I want to do: > > flavor_list = ['up', 'down', 'strange', 'charm', 'top', 'bottom'] > flavor = {} > for each in flavor_list : > flavor[ each ] = Quark() > > Here I start with the list of flavors, represented as strings > (interesting flavors...must be a different language ). I > iterate through that list and add a new instance of the Quark class to > a dictionary. The key to the dictionary is the flavor. > > Later you can > > for name , value in flavor.items() : > print name , ":" , value.color > > To print out the names and their associated value. > > This way, I can also have a line: print flavor['up'].color extracting a single element. This is something I haven't been able to get most other suggested code to do, though I'm still looking into all the suggestions. > An alternative solution would be to store the name of the flavor in > the instance of the Quark class. It could be an argument to __init__. > > class Quark : > def __init__( self , name ) : > self.name = name > <...> > > flavor_list = ['up', 'down', 'strange', 'charm', 'top', 'bottom'] > flavor = [] > for name in flavor_list : > flavor.append( Quark( name ) ) > del flavor_list # not needed anymore > > for item in flavor : > print item.name , ":" , item.color > I like this too, but I think it suffers from the problem above. To access the color of the top, I have to know the place of the "top" instance in the list (called "topindex" below)... print flavor[topindex].color ...the whole point is so that I don't have to remember where each guy is in the list. Thanks for the assist. From gustafl at algonet.se Mon Jun 11 17:08:45 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 11 Jun 2001 21:08:45 GMT Subject: Problem with UnicodeError and xml.dom.minidom References: Message-ID: Paul Prescod wrote: >Sprinkle some calls to that around your code and even around the library >code if you have to. Thanks Paul, I'm closer to the solution now. I found a specific message in the mailbox that gives the program trouble. Well, it isn't so specific -- it merely has some Swedish characters in the "From:" field... The idea is to check if the "From:" field contains some of my friend's e- mails, to sort them out. It looks like this: for e in myFriend.getEmails(): # Friends often change e-mails... if string.find(m.get('from'), e): # Here's the line that fails! When I found this message, I could cut it out, and paste it at the beginning of the mailbox file, and then provoke same error in Idle. I found that the string returned from m.get('from') has some kind of hexadecimal escaping for non-ASCII characters ('?' is represented as '\xe4'), while the 'e' string containing the e-mail has a 'u' (for Unicode) in front. So that explains why there is a problem when comparing them. So, I wrapped a unicode() function around m.get('from'), but I still have this same error: "UnicodeError: ASCII decoding error: ordinal not in range(128)". Acctually, all I need to do to get this error is to write: print unicode(m.get('from')) # Works fine without unicode() though Hope this is enough info for someone to solve it. Otherwise, I'd gladly share the complete code if you need. But it may be too much for a newsgroup. Regards, Gustaf Liljegren From bos at hack.org Thu Jun 14 22:30:47 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Fri, 15 Jun 2001 04:30:47 +0200 Subject: sorting values in dict References: Message-ID: <3B297357.A333A335@hack.org> Jeroen Wolff wrote: > > I want to display a dict sorted by value. Time to put this question in the FAQ? -- Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From ullrich at math.okstate.edu Fri Jun 1 10:21:45 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Fri, 01 Jun 2001 14:21:45 GMT Subject: random References: Message-ID: <3b17a2f1.411766@nntp.sprynet.com> On Thu, 31 May 2001 19:52:28 -0400 (EDT), "Steven D. Majewski" wrote: > > >On 31 May 2001, Mark 'Kamikaze' Hughes wrote: > >> "Anyone who considers arithmetical methods of producing random numbers >> is, of course, in a state of sin." -John Von Neumann >> >> Unless you have random-number-generating hardware, you don't really >> have truly random numbers. > > >That's what I was always taught, however in the light of >Gregory Chaitin's work or randomness in arithmetic: > > > >JVN may have been wrong. ??? There's a _lot_ of stuff there. Could you give us a hint regarding exactly what work of Chaitin's shows we can get "truly random" numbers from arithmetic algorithms? A physical RNG can have the property that one cannot make any prediction about the value of the next bit even given _complete_ information about how the numbers are being generated. An arithmetic algorithm with this property seems obviously impossible - if you know the algorithm and you know the current state of the RNG you can predict the next number... whatever the algorithm is, someone with all this information can devise a "randomness test" that the RNG will fail miserably. Or so it seems. >-- Steve Majewski > > > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From philh at comuno.freeserve.co.uk Sun Jun 17 12:13:53 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Sun, 17 Jun 2001 17:13:53 +0100 Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> <9geiir$324$1@216.39.170.247> <9gi6rk01986@enews1.newsguy.com> Message-ID: On Sun, 17 Jun 2001 14:14:20 +0200, Alex Martelli wrote: >"Remco Gerlich" wrote in message >news:slrn9ip10q.88g.scarblac at pino.selwerd.nl... > ... >> Adding a way to block rebinding of a name would be a horribly inconsistent >> wart on the language. > >I think this is a slight overbid. It is perfectly possible in Python to >"block rebinding" of an object's attribute (__setattr__ easily allows >that), after all, yet the sky hasn't fallen. One could similarly allow >blocking the rebinding of a container's item (you can do that for a >user-defined container, with __setitem__, though not on dictionaries >or lists -- tuples do "block the rebindinding" of their items). Such >'blocking' is occasionally useful to help avoid accidental rebinding >of things that are not meant to be rebound. It's just occurred to me that using this facility, you could implements constants in python withoput having to change the language, by having a CONST function: CONST("PI", 3.14159) this will put a new item in the current environment's dictionary, PI, with the relevant value, just like PI = 3.14159 had been executed. It will also override the __setattr__ function so that any attempt to reassign PI will throw an exception. of course, there would be performance penalties. >Thus, I do not believe it would at all be "a wart of the language" if >Python was very slightly extended to either allow a user-defined >mapping object to be set as the __dict__ attribute of a module >(where now a bona fide dictionary must be used instead), Ah -- does that mean my idea won't work? -- ## Philip Hunt ## ## philh at comuno.freeserve.co.uk ## From whisper at oz.nospamnet Thu Jun 14 11:55:07 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 14 Jun 2001 15:55:07 GMT Subject: PEP 259: Revise to remove context-driven magic from print References: <486de2.0106131406.5c0cbef9@posting.google.com> Message-ID: <9gamor$8ft$6@216.39.170.247> In article , fredrik at pythonware.com says... > Robin Thomas wrote: > > > always seemed to me quite a lame thing > > I have never exploited that feature > > print is a novice feature > > lazy scripts can avoid code breakage with minor edits > > the softspace crap. > > is this a joke of some kind? if not, it's clearly the most ignorant > and arrogant PEP proposal I've ever seen. > > > > > I don't see why you consider this a joke, nor do I see the ignorance and arrogance which you seem to. I think it's kind of unfortunate that an influential person in the python world, such as yourself, would swat down someone's idea without even saying why! Quite a way to discourage people from having new ideas whether right or wrong. I think the author has a valid point: that one should expect things to be wysiwyg. Notice how Guido's recent suggestion for another change to print got rejected. It occurs to me that print has gotten to where it is out of the same misguided desire to make life easy for newbies - at the expense of making life difficult once you outgrow the training wheels. I do dimly recall in the far distant past (the Asia - North America land bridge was still there) my own gaffe's with printf in C and forgetting to explicitly code a \n all too often. Of course, now that i'm accustomed to a function that _does_exactly_what_I_tell_it_to_ without trying to second guess me, it give me greater flexibility. Too bad functions in Python can't take flags like they can in Tcl, thus one could say print -nonewline "whatever". Of course IIRC, Tcl's print has it's own bits of magic. Since it's probably too late to fix print() as-is without breaking too much existing code, something like a raw_print() or putstring() method makes sense to me. I also liked someone's idea of __print__ - if that idea was in respect of giving objects the power to (as it where) print themselves (return their string representation - so call it asstring()). Regards Dave LeBlanc From jorgenru at ild.stud.ntnu.no Fri Jun 8 06:45:44 2001 From: jorgenru at ild.stud.ntnu.no (Jørgen Ruud) Date: Fri, 8 Jun 2001 10:45:44 +0000 (UTC) Subject: problems with compileall.py -d flag Message-ID: I don't understand the syntax of compileall.py's -d switch. snip from an old posting to this group: |From: Guido van Rossum (guido at CNRI.Reston.Va.US) |Message 2 in thread |Subject: Re: python 1.5.1 install problem |Newsgroups: comp.lang.python |Date: 1998/04/21 | In 1.5.1, compileall has a new option (-d destdir) that allows you to | specify the final destination directory. You'll have to call it | manually or exdit the Makefile to use this. It is the term final destination directory which gives trouble. Lets say at the end I want python to end up: /local/lib/python/... /local/bin/python Should the -d flag say /local or the path to the libs ? (/local/lib/python/..) Have anyone done this? -- J?rgen Ruud jorgenru at stud.ntnu.no From chris at dc.zdev.org Wed Jun 20 15:57:33 2001 From: chris at dc.zdev.org (Chris Abraham) Date: Wed, 20 Jun 2001 15:57:33 -0400 Subject: RFD comp.lang.python.zope & ZPugDC Meeting Tomorrow In-Reply-To: References: Message-ID: > I suppose it's more useful to test waters on the Zope mailing list, but then > it's almost certain that this group would get loads of votes. I have done. I am just wanting to get a sense. > I'm not sure. Just that it's written in Python doesn't seem very relevant, > and it can be extended in Perl now as well. Other options would be > comp.soft-sys.zope or comp.infosystems.www.appservers.zope or something like > that. If you want a smooth news.groups discussion (is that even possible > these days?), at least try to give more explanation why your name is better > in the RFD :). comp.soft-sys.zope? comp.infosystems.www.appservers.zope? Maybe the appserver would be better, yes! I don't know about the soft-sys -- what does that *mean*? :-) > Would the group mirror the Zope list the way comp.lang.python and the > mailing list do? Yes, probably! Yes, why not! It would do a good job of getting crossover people and getting another way to really index the content. > > Anyway, I'd like to see it happen. Comp.lang.python is a very busy group, > but splitting it won't work well. Maybe the best way is to make some of the > mailing lists into newsgroups, and Zope is obviously big enough. I wouldn't want to spit the group, but I do think that Python is too low-level for a lot of Zope people... most Zope people do need Pythin sooner or later, but Python's group is a little too much for some/many people Thanks for you kind words and support, Chris -- Chris Abraham +1 202 452 7442 vm [MemeSpace:VirtualCommunity:ConsiderYourselfInfected!] From gustafl at algonet.se Tue Jun 26 14:54:53 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 26 Jun 2001 18:54:53 GMT Subject: Should I use a dictionary? References: <9h91pb$e3k$1@panix6.panix.com> <9h9ckq$nf$1@apollo.csd.net> Message-ID: kosh wrote in <9h9ckq$nf$1 at apollo.csd.net>: >This method should able be very fast if you convert the data to a >straight int first. Thanks. This suits me perfectly. I get the date in the format "2001-01-01 13:12", so that would be "200101011312" with no risk for confusion. Gustaf From jochen at riekhof.de Thu Jun 14 11:35:24 2001 From: jochen at riekhof.de (Jochen Riekhof) Date: Thu, 14 Jun 2001 17:35:24 +0200 Subject: substitute for c/java's ?: References: Message-ID: <9galod$8m6$06$1@news.t-online.com> > if string.lower(name[0]) in 'aeiou': Yep, a bit cleaner and better performance with long strings. Ciao ...Jochen From jimhill at meldrick.swcp.com Fri Jun 15 23:05:22 2001 From: jimhill at meldrick.swcp.com (Jim Hill) Date: 16 Jun 2001 03:05:22 GMT Subject: VI References: <3B278900.5828FB59@Lugoj.Com> <9gaunm$mth$3@brokaw.wa.com> <9gdcl10oti@enews1.newsguy.com> Message-ID: In <9gdcl10oti at enews1.newsguy.com>, Alex Martelli wrote: >"Jim Hill" wrote in message >news:slrn9ik7rt.o2j.jimhill at meldrick.swcp.com... >> it is pronounced "vee eye" and those who say "vye" >> are bloody peasants who should be repressed by the violence inherent >> in the system. > >I thought _everybody_ knew it's pronounced "six" -- like in "Pope >Paul VI", no?! It's only pronounced "six" on Mac OS X. Jim -- jimhill at swcp.com http://www.swcp.com/~jimhill/ "Let me preface my remarks by saying that I have absolutely no love for Barry Manilow in my heart." -- Jason Lempka From chrishbarker at home.net Fri Jun 8 15:47:18 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 08 Jun 2001 12:47:18 -0700 Subject: Passing back an array from an extension module? References: <9fqqqo$1p3e$1@newshost.nmt.edu> Message-ID: <3B212BC6.A3D6888F@home.net> Bob Greschke wrote: > > Is this a job for NumPy? > The sort answer is yes this would be pretty straighforward. See Chad Everett's post. > I have a C extension function that malloc()s an array of int32s, calls > another C function which reads/decodes a file of data and fills in the > array. My big question is why you don't do the whole thing in NumPy? You may not need the C code at all, unless the decoding is really wierd. Is it a compression algorithm or something? > I initially thought I could just create a tuple and pass > that back, since nothing is going to be done with the values except to > draw a graph, but there is the possibility of there being 16,000,000 > data points...that makes for a slightly large statement, doesn't it? You could also use a list, rather than a tuple, but a NumPy array would make much more sense. Oh, how I long for it to part of the standard library. > Now what about Py_DECREF, INCREF and all of that stuff in these > situations? You do have to be a bit careful about these, but what you want to do sounds pretty straightforward. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From quango at watervalley.net Fri Jun 29 04:42:44 2001 From: quango at watervalley.net (Chris Lawrence) Date: Fri, 29 Jun 2001 08:42:44 GMT Subject: PEP 260: simplify xrange() References: <3B3AA617.8A9B56B7@seebelow.org> Message-ID: <20010629.034219.889023311.911@watervalley.net> In article <3B3AA617.8A9B56B7 at seebelow.org>, "Grant Griffin" wrote: > BTW, can PyChecker do Python-version enforcement? Specifically, I think > it would be great if we had a gizmo at least to enforce 1.5.2 (besides > 1.5.2 itself ). > > Even cooler would be if Python had some sort of feature for this. (I'd > write a PEP for that, but I fear that it might lead to a new version > .) But I guess for reasons of efficiency something like this > should be an "offline" tool anyway rather than pollute the innards of > Python. You can try this code at the beginning of your program: import sys try: if sys.hexversion < 0x10502f0: # 1.5.2 final print 'Get a new version of Python!' except AttributeError: print 'Get a new version of Python!' Dunno when sys.hexversion showed up, hence the try clause. With more recent versions, you could also play with sys.version_info. Chris From no_spam..python at dstanek.com-NOSPAM Tue Jun 19 08:40:50 2001 From: no_spam..python at dstanek.com-NOSPAM (David Stanek) Date: Tue, 19 Jun 2001 08:40:50 -0400 Subject: Python Idioms? References: Message-ID: <9gnis0$ga5$1@news.chatlink.com> "Tim Peters" wrote in message news:mailman.992915128.21708.python-list at python.org... > BTW, in this particular case, there's a comment right in the module: > Saw the comment, but was not quite sure what is meant. I appreciate the response. Thank you, David Stanek From nperkins7 at home.com Sun Jun 3 17:05:33 2001 From: nperkins7 at home.com (Nick Perkins) Date: Sun, 03 Jun 2001 21:05:33 GMT Subject: Why isn't Python king of the hill? References: Message-ID: "Tim Peters" wrote in message news:mailman.991519987.12431.python-list at python.org... [ paraphrased ] > > Rational numbers can be as surprising to newbies as anything else... Indeed. >>> from math import * >>> sqrt(2)**2 2.0000000000000004 >>> sin(pi) 1.2246063538223773e-016 Neither of these 'errors' would be eliminated by using Rationals. I am sure there are many similar examples. note that: >>> cos(pi) -1.0 actually works, for some reason (luck?) From db3l at fitlinxx.com Thu Jun 21 19:55:53 2001 From: db3l at fitlinxx.com (David Bolen) Date: 21 Jun 2001 19:55:53 -0400 Subject: Another Wart! string.find() [ was: namespace issue? ] References: Message-ID: "Steven D. Majewski" writes: > This is an illogical convention, however it would be very difficult > to root out, because, as you have noted, everyones code is FULL > of explicit checks that string.find does not return -1. > > I'ld love to see it fixed, however, I suspect that in this case, > many lines of installed code trumps Computer Programming for Everybody! Particularly since any change to something like None could break a lot of that code, since I'm sure code exists that assumes the result is an integer. At least part of the reason this particular method tends to require a few more brain cycles when I use it is that I tend to think of "find" as more intuitively being a boolean sort of operation - e.g., "is this string in this other string", while the function actually acts more as what I would have probably called "index". Using the latter name makes me think more immediately of a numeric return, at which point a -1 convention for no possible index is just fine. But I have lots of code that really just uses find to determine if the substring exists (and doesn't actually care where), so you end up with a ">= 0" check (or equivalent) in many places where it would be unnecessary if the method was really a boolean check. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From res04o20 at gte.net Sun Jun 17 15:17:27 2001 From: res04o20 at gte.net (res04o20) Date: Sun, 17 Jun 2001 19:17:27 GMT Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? References: <3B2B60AD.942719AE@earthlink.net> Message-ID: Hi y'all. I'm new here so bear with me. ;-) Ron, I've had the same "problem". I'm a working SE/ProjectMgr. (26 years), and have gotten very spoiled by VB and the like. But, I've also been forced to re-learn the old addage, "There is no royal road to Geometry". In other words, there ain't no substitute fer just bitin'-the-bullet and learnin' it. Tkinter is the place to start. Do yourself a favor and get a copy of "Programming Python 2nd Edition". It's got the best tutorial I've seen yet on Tkinter. Everything you learn there will only help you in any other paradigm. Tkinter IS event-driven. It's just not "Visual...". I also have played with wxPython and like it too. Now. Here's another way to go. Just use VB or some Office VBE with Forms2 (or even Word fields or Excel cells) as your gui. The other great book I've read, "Programming Python on Win32" shows you how to do it. It's not hard. That's of course, if you have access to VB/Office and can stomach using it. Some folks just refuse, and I can't blame 'em. Here's another thing I have been playing with. Download "Forte for Java" Community Edition from Sun. It's free. Free is good. It builds Java AWT and Swing GUI's. (Could also potentially integrate well with Jython...? ) Design a gui, and look at the code it generates. You could just use that code as a framework, and convert the code to use Tkinter or wxPython calls instead of Java. (Python can do that! See note on Jython below, though.) But you still have to KNOW your package and how it works. You'll also get more satisfaction and be able to fix your own problems, if your gui builder doesn't hide all the details from you. BTW, did I mention it's free? wxPython. I like it, but it's ANOTHER package you have to download, install, and learn. It doesn't come with Python. It may in the future. Who knows. (One advantage - doesn't depend on Tcl.) Jython. Love it. Be prepared to learn alot of Java/AWT/Swing. Another package. Enough said. And here's one more idea. DHTML. It's ubiquitous, free and powerful. Makes a good gui and there's a ton of free (or cheap) visual designers for it. (Check out MacroMedia.com. And Allaire, which they just bought/merged with. Look at the HomeSite HTML Editor. Very interesting. And inexpensive. And powerful.) Hook in your Python handlers and yer in business. (You might want to experiment with using JxScript for the actual event-handlers, and then calling your Python routines from there. I've had a little trouble in some cases using pure-Python event-handlers. In IE, JxScript is more tightly integrated with the DOM.) Course, you'll have to use the .hta model, not .htm, to get out of restricted mode and have a full-blown IE app. It's so difficult. You have to change one letter in the extension! ;-) See MS WebWorkshop site on Reusing Browser Technology and HTA's. (I'm talking Win32/IE here. I'm ignorant of Netscape and wary of Mozilla yet. Time will tell on that. (ActiveState Komodo is built on Mozilla, and it's an absolute dog on performance. Current beta is better than 1.0 but not much. But it's getting there...) I am seriously considering taking my development team in this direction for a new Multi-Dimensional Analysis (OLAP) application for SQL Server. And lastly, ActiveState has announced "Visual Python". Only problem is, you gotta have MS .Net. (shudder) (Yet another implementation of Python. This time in C#. Another learning curve to be ultimately successful.) I've looked at Pythonware and Boa., etc. Good potential. I just don't want to be locked into another IDE structure. What if I have to convert out of it? What about my project structures? Do they integrate versioning software? Do they store everything in XML or DBM or Pickles or Shelves? Or who knows what? Just haven't had enough time to look into those issues. Of course, these are project management issues which may not be of any concern for your purposes. Best thing is just play with them see what works for you and what you can afford. Hope these ideas help. Good luck! (And I'll also be interested in other folks' responses!) Dave Wald "Ron Stephens" wrote in message news:3B2B60AD.942719AE at earthlink.net... > I am taking a week's vacation the week after next. I plan to spend this > week trying to learn event-driven programming using Python. I would sure From gerhard.nospam at bigfoot.de Thu Jun 14 05:58:27 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Thu, 14 Jun 2001 11:58:27 +0200 Subject: tummy compile Mandrake 7.2 References: <20010608.214013.1469262009.16325@K7.atl.mediaone.net> <20010609.104451.1884661237.1229@K7.atl.mediaone.net> <3B24154E.C70211ED@student.gu.edu.au> <20010610.232821.1789366143.1225@K7.atl.mediaone.net> <3B25F742.F4E25C37@student.gu.edu.au> <20010612.151135.165344818.1845@K7.atl.mediaone.net> <3B288E62.FC946467@student.gu.edu.au> Message-ID: On Thu, 14 Jun 2001 20:13:54 +1000, Joal Heagney wrote: >> > 10. rpm -bb --short-circuit python-2.1.spec >> > >> again my ignorance probably shows, but man rpm says --short-circuit is >> only valid w/ -bc and -bi......and another thing- after all that, couldn't >> you find a stronger expletive than "damn"? ;-) > >So it does. I've always assumed that it applied. *hmmm* Maybe reading >the man pages isn't always as useful as we'd like to believe. *grins* I >may have to get in contact with the rpm guys and find out why. Alas, that's true. When I tried to make an RPM package of OmniORB where the build process takes something like 2 hours I was especially amused about --short-circuit not working with -bb. I was surprised that I could make sense of the RPM source and since then I modify my RPM with the following patch. It enables --short-cuircuit for "-bb" and "-ba". diff -r -C 3 ../rpm-3.0.6.orig/rpm.c ./rpm.c *** ../rpm-3.0.6.orig/rpm.c Thu Jun 14 13:05:07 2001 --- ./rpm.c Thu Jun 14 13:05:27 2001 *************** *** 1279,1288 **** --- 1279,1292 ---- /* these fallthroughs are intentional */ case 'a': ba->buildAmount |= RPMBUILD_PACKAGESOURCE; + if ((ba->buildChar == 'a') && ba->shortCircuit) + break; /*@fallthrough@*/ case 'b': ba->buildAmount |= RPMBUILD_PACKAGEBINARY; ba->buildAmount |= RPMBUILD_CLEAN; + if ((ba->buildChar == 'b') && ba->shortCircuit) + break; /*@fallthrough@*/ case 'i': ba->buildAmount |= RPMBUILD_INSTALL; Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://highqualdev.com public key at homepage public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From jeff at ccvcorp.com Thu Jun 21 12:17:24 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: 21 Jun 2001 09:17:24 -0700 Subject: Interfacing GUI applications..? References: <3B18032E.21AF631E@pfortin.com> <16074dce.0106200912.7b9bc793@posting.google.com> <9gqs2c01c2m@enews1.newsguy.com> Message-ID: <16074dce.0106210817.3c40fedf@posting.google.com> "Alex Martelli" wrote in message news:<9gqs2c01c2m at enews1.newsguy.com>... > "Jeff Shannon" wrote in message > news:16074dce.0106200912.7b9bc793 at posting.google.com... > ... > > One suggestion for "something else"... there is a Visual Basic function > > "sendkeys()" that does exactly what is requested--it simulates keyboard > > Pity it won't help the original poster (who's on Linux) D'oh! I guess that I, too, need to read a bit more carefully before spouting off... oops. :) I do have to agree with what you've said before, though, Alex... however much one may dislike Microsoft products in general, COM is really, really nice. Now if only it could work transparently cross-platform. Jeff Shannon Technician/Programmer Credit International From donod at home.com Sun Jun 17 22:44:14 2001 From: donod at home.com (Don O'Donnell) Date: Mon, 18 Jun 2001 02:44:14 GMT Subject: graceful version detection? References: <3B2D2F44.50007@red-bean.com> <3B2D5F78.B581DFF1@home.com> Message-ID: <3B2D6B73.FBCFF7A6@home.com> > > Presumably this happens > > during the initial byte-compilation. > > Sorry, guess I missed that you were talking about the compile phase. -Don From anonymous at anonymous.anonymous Fri Jun 22 19:53:44 2001 From: anonymous at anonymous.anonymous (Anonymous) Date: Fri, 22 Jun 2001 16:53:44 -0700 Subject: the indentaion for grouping thing Message-ID: <3b33d9d6$1_1@anonymous> Someone quoted Guido as saying (I'm paraphrasing) that he is determined to be ignorant of any discussion regarding the white space for grouping thing. How sad. How crusty. How typical. Anyway, I will continue to use Python I guess, but I gather that someone has written a preprocessor that allows you to use delimiters with python. Is this true? If so, where can I find it, I would like to use it. --------== Posted Anonymously via Newsfeeds.Com ==------- Featuring the worlds only Anonymous Usenet Server -----------== http://www.newsfeeds.com ==---------- From thomas.hansenNOSPAMORILLSUEYOURASS at entermatch.com Fri Jun 8 02:36:44 2001 From: thomas.hansenNOSPAMORILLSUEYOURASS at entermatch.com (Thomas Hansen) Date: Fri, 8 Jun 2001 08:36:44 +0200 Subject: best language for 3D manipulation over web ? References: <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3B1B1825.8109BA83@lmf.ericsson.se> <2v4ohtgldvce84sn87kh1eg1lnes37getq@4ax.com> <3B1C9E65.B73A4FE@lmf.ericsson.se> <3B1DFD87.F3BFDB57@lmf.ericsson.se> Message-ID: <9fpra3$352$1@oslo-nntp.eunet.no> > >> Every user should have his/her own registry (and not just a sub-tree) > > > > TOTALLY agreed. > > See, we can agree to many different things ^__^ > Not possible unless you want to install a billion ActiveX/COM components x times where x is the number of users on that computer... From noone at nowhere.net Sat Jun 30 19:44:17 2001 From: noone at nowhere.net (lynx) Date: Sat, 30 Jun 2001 19:44:17 -0400 Subject: newbie wants to eval() References: <3b3e3e81$0$88189$2c3e98f8@news.voyager.net> <9hlhkl02cu9@enews1.newsguy.com> Message-ID: <3b3e655b$0$88181$2c3e98f8@news.voyager.net> "Alex Martelli" , in <9hlhkl02cu9 at enews1.newsguy.com>: > "lynx" wrote in message > news:3b3e3e81$0$88189$2c3e98f8 at news.voyager.net... [...] > You'd need to use the 'exec' statement (shudder), but fortunately you > can easily do better than that, since...: hmm. is there something inherently evil about exec that i should know about...? > Global variables are really attributes of an object, the module object > to be precise. Setting any object's attributes is most easily done via > built-in function setattr(). > So you need a reference to the object that's the module you want to > affect. Assuming this is the module containing the function you're > writing, simplest may be: > import sys > mymod = sys.modules[__name__] > and now mymod is the reference you require. looks interesting. should that snippet be run in the function where i'm trying to change these globals, or in the main program and that reference passed in as an argument to the function? honestly, myself, i'd be more upset and shuddering at this kind of manual rooting around in Python's own internal workings than at the exec() statement, which seems designed to hide this sort of magic from me; unless, of course, there's something strange about exec that i don't know of...? -- PGP/GnuPG key (ID 1024D/BFE0D6D0) available from keyservers everywhere Key fingerprint = 3EBC 97FC 68AA 65F1 65E6 3D36 35F6 4213 BFE0 D6D0 "...life goes on long after the thrill of living is gone..." From phd at phd.fep.ru Fri Jun 8 15:43:31 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Fri, 8 Jun 2001 23:43:31 +0400 (MSD) Subject: DOS Extenders (was: RS232 support for DOS on 486?) In-Reply-To: Message-ID: On 8 Jun 2001, Anurag Ved wrote: > I have a strong point to make. The ONLY purpose of the Usenet, as I > see it, is to spread knowledge. Unfortunately, far too often too much > is made of "off topic" thingy. If a post in it's basic theme is > appropriate for a newsgroup (as this one is) then there is no reason > why any replies to that post, even if seen deviating a bit from the > main theme, should not be posted. > > In particular, comp.lang.python lurkers (like me) who have followed > this thread and are not as knowledgeable as Oleg would certainly like > to know what he did with the DOS Extender. I didn't do anything with extenders - I just used they :) But no problem, below is the long text that I sent privately. > Oleg Broytmann wrote in message news:... > > On Thu, 7 Jun 2001, D-Man wrote: > > > On Fri, Jun 08, 2001 at 12:02:28AM +0400, Oleg Broytmann wrote: > > > | On Thu, 7 Jun 2001, D-Man wrote: > > > | > Does Python even run under MS-DOS? > > > | > > > | Under DOS Extender - no problem. I used Python 1.5.2 quite successfully! > > > > > > That's good to know. What is "DOS Extender" anyways? > > > > This is completely off-topic, and not of much interest to the newsgroup > > (DOS, after all, is completely dead, as well as Python for DOS), so I am > > going to write you private message to answer the question in more details. DOS Extenders. Sad history of the subject. When first 8086/8088 processors appeared they can address only 1 megabyte (1024K) of memory. First PCs that were created by IBM reserved 384K of upper memory for BIOS, videomemory, etc, so a program can address only 640K. 80186 processor didn't add much to this. 80286 did add, though. Intel invented special "protected" mode. In this mode a program can acess a dozen of megabytes of memory. The problem was compatibility. MsDOS/PcDOS didn't support the new mode. So some firms that were producing compilers, libraries and other development tools started to make special "wrappers" for programs to help developers to write in protected mode. The problem was that after protected program finishes the processor must be returned to "normal", non-protected mode - for MsDOS to operate properly. It was near to be impossible, as 80286 processor had no such provisions. The processor has only "reset" signal, after which entire computer must be rebooted. Well, BIOS manufacturers invented a trick (probably, with help from Intel). The program that wants to go from protected mode to non-protected put some information into reserved area of lower memory. And reset the processor. The computer starts to boot and passes control to the boot program in BIOS. BIOS looks into that reserved area and instead of booting returns control to MsDOS (that was already in memory)! Then came 80386! It was really huge leap forward. It can address much more memory, and what is more important, it can address it in "flat mode" - no need to address memry by 64K chucnks - you can address whatever you want. And even more important - the processor had soft switch between protected and non-protected modes. MsDOS, though, still didn't support protected mode, so developers continued to use wrappers and special libraries. Of course, such wrappers require help from compilers, so the firms that were producing compilers started to bundle these wrappers and protected mode libraries with their compilers. Soon these wrappers and libraries become like mini-operating systems. Consortiums of developers invented few standard sets of API, most notable of which was DPMI (DOS Protected Mode Interface ) version 0.9. Few very mature DPMI implementations appeared, and soon they got the name (let us finally return to our muttons) DOS Extenders! The best known DOS Extender was PharLap, but it had the problem that it didn't support DPMI. Without support of proper standard it failed. The second best known was DOS/4G, created by Rational Systems. I asked Google where it is now - and hurray! - it is now at http://www.tenberry.com/. Its primary compiler was Watcom C: http://www.tenberry.com/dos4gw/. It was very successful DOS Extender, in the end of DOS era almost every commercial protected mode program used it. There was shareware Extender PMODE/W, that was 99% compatible with DOS/4GW. It was free for non-commercial use, so I downloaded it. It had tools to replace DOS/4GW in a protected .EXE. I used it to replace DOS/4GW in perl.exe and python.exe that I used. It worked perfectly. I know there were some free and commercial DOS/4GW replacement, ZRDX, for example. Its pages are in russian, so I am not providing URL here. Other compilers also had free and/or commercial extenders. DJGPP (DOS port of GCC) has one, for example. I put some additional information on using python with extenders: http://phd.pp.ru/Software/Python/py4dos.txt. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From geoff at homegain.com Tue Jun 26 05:16:25 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Tue, 26 Jun 2001 02:16:25 -0700 Subject: printer under Win32 Message-ID: <393D961EA4FCD311B03F00D0B746D65803275EE2@HQSXCH01> -----Original Message----- From: Neil Hodgson >Geoffrey Gerrietts: > > > The question is basically: what's the right way to determine > > page extents > > when writing to a printer DC? Detail follows (if it matters): > > I don't know if it covers this issue but have you examined the > printing code used by PythonWin itself in > Pythonwin\pywin\scintilla\view.py ? Hm. It uses a somewhat different approach than what I've seen documented. I think that's because it's using the standard GUI print widgets to drive the printing -- and I'm not, or at least I would prefer not to hafta. In the meantime, I seem to have accidentally discovered win32print in my trolling the newsgroup, though, maybe I'll go play with that for a while.... Thanks, --G. From manu at meta-x.fr Wed Jun 13 11:49:12 2001 From: manu at meta-x.fr (Emmanuel Hocdet) Date: Wed, 13 Jun 2001 17:49:12 +0200 Subject: problem building python 2.1 on Solaris 8 with gcc (-mcpu=ultrasparc) References: <9g6c29$rb3$1@front7m.grolier.fr> Message-ID: <9g81gi$qck$1@front1m.grolier.fr> In article <9g6c29$rb3$1 at front7m.grolier.fr>, "Emmanuel Hocdet" wrote: The problem come from a compil optimisation: -mcpu=ultrasparc a gcc bug? > i compil python 2.1 on Sparc Solaris 8 with gcc 2.95.3 and have a pbl... > :( > any idea? > > manu > > [...] > gcc -o python \ > Modules/python.o \ > libpython2.1.a -lpthread -lsocket -lnsl -ldl -lthread > -lm > PYTHONPATH= ./python ./setup.py build Traceback (most recent call last): > File "./setup.py", line 14, in ? > from distutils.command.build_ext import build_ext > File "/opt/compil/Python-2.1.manu/Lib/distutils/command/build_ext.py", > line 21, in ? > extension_name_re = re.compile \ > File "/opt/compil/Python-2.1/Lib/sre.py", line 90, in compile > return _compile(pattern, flags) > File "/opt/compil/Python-2.1/Lib/sre.py", line 134, in _compile > p = sre_compile.compile(pattern, flags) > File "/opt/compil/Python-2.1/Lib/sre_compile.py", line 368, in compile > code = _code(p, flags) > File "/opt/compil/Python-2.1/Lib/sre_compile.py", line 349, in _code > _compile_info(code, p, flags) > File "/opt/compil/Python-2.1/Lib/sre_compile.py", line 238, in > _compile_info > lo, hi = pattern.getwidth() > File "/opt/compil/Python-2.1.manu/Lib/sre_parse.py", line 173, in > getwidth > self.width = int(min(lo, sys.maxint)), int(min(hi, sys.maxint)) > OverflowError: long int too large to convert make: *** [sharedmods] > Error 1 From brian at nr6.dk Mon Jun 4 12:29:43 2001 From: brian at nr6.dk (Brian Andersen) Date: Mon, 4 Jun 2001 17:29:43 +0100 Subject: Using SMTPlib. Message-ID: <9fg9hd$l27$1@news.inet.tele.dk> Hi. I'm in the process of writing my very first project in Python - a webmail application. I've tried the SMTPlib and it work out fint, but the mails I send don't have a subject. I've tried the example that is in the Pythondocumentation for the SMTPlib and it works well, but how do I insert a subject field? The same goes for CC end BCC-fields. Are they handled by the SMTPlib or is it something that I must handle in my program? Hope you can help me. Best regards. Brian. From scarblac at pino.selwerd.nl Thu Jun 14 02:26:16 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 14 Jun 2001 06:26:16 GMT Subject: substitute for c/java's ?: References: <9g5fc4$m8u$01$1@news.t-online.com> Message-ID: Jochen Riekhof wrote in comp.lang.python: > Hi... > > as a newcomer to python (like it a lot!) I found almost everything great > except two things: > 1. (most important) > I am missing something like the c/Java ?: operator. This is so convenient in > many places and saves a lot of typing. > It works like > result = option ? value1 : value2; > which is equivalent to > if option: > result = value1 > else: > resultl = value2 > > Is there anything I overlooked? Not really. Just write the if:, it's more obvious what it does when you read the code (especially when the expressions get longer). > 2. switch (not important) > if elif else is not a proper substitute for switches, as the variable in > question has to be retyped in each if/elif clause. For long statements, you could use a dictionary. e.g. switch(s) { case "whee": do_whee(); break; case "bla": do_bla(); break; case "spam": do_spam(); break; } becomes switch = { "whee": do_whee, "bla": do_bla, "spam": do_spam } switch[s]() You only need to initialize the dictionary once, can pass it to other functions, etc. But for only a few options, if: elif: isn't so bad. -- Remco Gerlich From spam at sightreader.com Sun Jun 10 07:47:54 2001 From: spam at sightreader.com (Bufu) Date: Sun, 10 Jun 2001 04:47:54 -0700 Subject: spawning unix command processes which run in parallel and simultaneously References: <9fvhqj$57m$1@news.hk.linkage.net> Message-ID: <007601c0f1a3$37ab2460$1301010a@personal.net> Yes, os.popen and friends are what you want. I recommend trying stuff in the interpreter; it's more fun that reading documentation, and usually more instructive, and more accurate. The documentation seems to have the wrong argument order for popen2, popen3, and popen4, where the optional bufsize and more arguments are swapped (should read "popen2 (cmd[, mode [, bufsize]])"). The documentation is in the os module under "6.1.2 File Object Creation" presumably because it creates file like objects. I would have expected it to be in "6.1.5 Process Management", or at least a cross-reference there. By the way, it seems to act strangely in PythonWin: >>> f =os.popen(r'C:\junk\test.exe') Traceback (innermost last): File "", line 1, in ? WindowsError: [Errno 2] The system cannot find the file specified The same happens for any command line string, but it works fine in the console version of python. ----- Original Message ----- From: "Alan Tsang" Newsgroups: comp.lang.python To: Sent: Sunday, June 10, 2001 3:23 AM Subject: spawning unix command processes which run in parallel and simultaneously > > HI, I am learning to code with Python and I encounter a technical problem. > > I want to spawn a few unix command processes from a python script so that I > can get the output from the unix command processes and use them in python. > > But I don't want to wait for the completion of one process at a time and > then start another. I want the python script to start the processes > simultaneously and monitor whether anyone of them have finished and if so, > get the output from the finished one. > > It seems to me that the os and popen2 module is useful in this respect but > I am not sure how to do it. > > Is it possible to do it in python? would be grateful if anyone can give me > a reference to any documentation. > > Thanks > > -- > http://mail.python.org/mailman/listinfo/python-list From veale at fafnir.dyndns.org Tue Jun 19 20:35:23 2001 From: veale at fafnir.dyndns.org (Anthony Veale') Date: 19 Jun 2001 18:35:23 -0600 Subject: OOP design question Message-ID: <9gor4b$3jv$1@fafnir.dyndns.org> Hello, I'm a newbie to OOP and Python at the same time and I'm having a bit of a design problem. I can see at least one way out of my problem that isn't really OO, but since I'm writing this program to learn some OO programming, that's a bit of a cheat. However, it might turn out to be the most appropriate solution. I just don't know. Let me be concrete here. I'm writing a program to edit the Opera 5 for Linux bookmarks file. I designed some classes for Urls and Folders and one for the bookmark file as a whole. The BookmarkFile class contains instances of Folders and Urls. Then when I started to design the editing program, I found that there are some features that I wanted to add to Folders, that are really only applicable to Folders when editing the bookmark file. So I'd like to subclass Folders and make sure that the BookmarkFile class creates Folders using the new subclass. The questions: Should I try to redesign the BookmarkFile class to use a parameter to control the actual class of Folder instance? (Can you actually pass a class as a parameter?) Or: Should I try to redesign the BookmarkFile class to be easier to subclass and use subclassing to control the class of Folder instances? Or: Should I try to isolate these "editing" functions into something that gets mixed with the Folder class? Or: Is there some other approach that I simply haven't thought of? The cheat would be to just add the features to the Folder class itself without subclassing. It would work, but doesn't really seem to be the appropriate OO action to take. If I were writing this program in order to get something functional, I'd probably just do it. But I'm trying to learn the "right way" here. -- Anthony Veale' veale at fafnir.dyndns.org Home Alone 4-- Hardly Working From thomas.heller at ion-tof.com Thu Jun 7 11:14:29 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 7 Jun 2001 17:14:29 +0200 Subject: py2exe -i list References: Message-ID: <9fo5m5$5a998$1@ID-59885.news.dfncis.de> "John" wrote in message news:hOMT6.246185$Z2.2812230 at nnrp1.uunet.ca... > Hi, > > What is the syntax for the -l option for py2exe? When I try : > > python setup.py py2exe -i "foo.lib.x" > > This works. But when I add another module like so: > > python setup.py py2exe -i "foo.lib.x, foo.lib.y" > > It complains that there is no module named foo.... > You cannot (currently) use spaces in this list. Written this way it should work: python setup.py py2exe -i "foo.lib.x,foo.lib.y" Thomas From smnordby at yahoo.com Mon Jun 11 21:39:04 2001 From: smnordby at yahoo.com (SteveN) Date: Mon, 11 Jun 2001 18:39:04 -0700 Subject: How to get current date References: <3b256b54.0@news.tm.net.my> Message-ID: <3B2572B8.A5DE1878@yahoo.com> ykchew wrote: > > Hi there, > I'm newbies and i want to know to get current date from python2.0 and > merge it with string > > thanks import time date_as_string = time.strftime("%d", time.localtime(time.time())) -SteveN- From m.faassen at vet.uu.nl Sat Jun 30 21:02:01 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 1 Jul 2001 01:02:01 GMT Subject: PEP scepticism References: <3dbsn71iac.fsf@ute.cnri.reston.va.us> <9hj2p6$bdu$6@newshost.accu.uu.nl> Message-ID: <9hlsq9$gfg$1@newshost.accu.uu.nl> Guido van Rossum wrote: > m.faassen at vet.uu.nl (Martijn Faassen) writes: >> Which is why a system more or less *forcing* core developers to look >> at these issues *only* for a while may be good. > As the main core developer, I object to this idea and your previous > post on this. Most of the needed library modules simply cannot be > written by me or other core developers because they require specific > application area knowledge that I don't have. (E.g. XML.) But isn't there the role of integration and approval of library additions and changes to the core library? What about other infrastructure? It would seem to me there is more to this than just implementation by itself. > On the other hand, very few folks have the knowledge, understanding > and vision to make changes to the language without breaking it. > So let's all do what we do best: the core developers (e.g. PythonLabs) > improve the language, and the community improves the library. (Note that with 'core developers' I meant everybody (presumably on python-dev mostly) actively working on changes to the core language.) It strikes me then that there appears to be no real team dealing with improvements to the standard library then. Of course there are groups of people such as the XML-SIG which deal with specific issues, but the important supportive role of integrators seems to be partially unfilled. Such integrators would actively evaluate new modules for adoption to the standard library, integrate changes to existing modules, and look to improving the overal architecture of the library. (how the parts hang together) Integration of changes to the standard library happens right now, but appears to have a lesser priority (due to less interest, surely not due to lack of expertise) in the minds of the developers of the core language. Or did I understand you incorrectly? Would the explicit formation of such a group of people be a good idea? Such moves might addresses a concern, but only half of the two concerns my proposal was trying to address. The other worry is about these continuous changes to the core language. My idea tried to address is to put some deliberate pause in the development of core language features. Even though most of us like new features and I certainly like to talk about them (idly and waving lots of hands, too), the concern exists, among apparently quite a few people, that eventually this pattern may lead to a language that doesn't fit in people's minds comfortably anymore. Of course, we grow with the language, but we'd also like Python to be easy to understand for beginners (and to be able to read our own code half a year into the future). [I really like new features; I generally enjoy thinking about them, and learning about them and playing with them. Generators, microthreads, coroutines, optional type annotations, the works! But I might certainly have been overwhelmed by them as a beginner. Still could be, especially when reading other people's code that uses them.] I realize the core developers don't want to stop developing the core language. It's what they do and like to do. So I proposed something that could address two possible problems in one go, while still continuing the language development, albeit at a slower rate. Another way to address this concern could be by simply taking longer at releasing new versions of Python (with new features). This is unlikely to happen, as fortunately the Python core developers have had more time to focus on developing Python in recent time. But, how can the concern be addressed then? Should it be? Is the concern invalid, do you think, and if so, for what reason? Is this a genuine risk or not? The issue is of course not an urgent one. But overcomplexity creeping on us slowly is still overcomplexity; better do something about it before it hurts, if it is indeed something to worry about. So-Tim-was-channeling-correctly-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From skip at pobox.com Mon Jun 18 20:21:23 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 18 Jun 2001 19:21:23 -0500 Subject: nested classes In-Reply-To: <6957F6A694B49A4096F7CFD0D900042F27D493@admin56.narex.com> References: <6957F6A694B49A4096F7CFD0D900042F27D493@admin56.narex.com> Message-ID: <15150.39683.411648.710307@beluga.mojam.com> Bjorn> But that's an implementation detail only, since it works Bjorn> perfectly for functions: Bjorn> def foo(): Bjorn> foo() Only because at the point that foo calls itself recursively, the definition of foo is in the module's global symbol table, assuming foo is def'd at the module scope. If foo is nested inside another function, it can't call itself directly without some help from the function it's enclosed in. Before nested scopes, the following won't work: % python Python 2.1.1a1 (#10, Jun 8 2001, 14:37:03) [GCC 2.96 20000731 (Linux-Mandrake 8.0 2.96-0.48mdk)] on linux2 Type "copyright", "credits" or "license" for more information. >>> if 1: ... def bar(): ... def foo(i=0): ... if i < 10: ... foo(i+1) ... foo() ... bar() ... :2: SyntaxWarning: local name 'foo' in 'bar' shadows use of 'foo' as global in nested scope 'foo' Traceback (most recent call last): File "", line 7, in ? File "", line 6, in bar File "", line 5, in foo NameError: global name 'foo' is not defined >>> from __future__ import nested_scopes >>> if 1: ... def bar(): ... def foo(i=0): ... if i < 10: ... foo(i+1) ... foo() ... bar() ... >>> When defining a class, the code within the class's scope is executed immediately, before a class object has been bound to the class's name. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From timr at probo.com Wed Jun 20 01:35:25 2001 From: timr at probo.com (Tim Roberts) Date: Tue, 19 Jun 2001 22:35:25 -0700 Subject: Simple example that won't work! References: Message-ID: <8dd0jt4ueg8ov7tk32f4rb2m3j6shala5m@4ax.com> Jay Parlar wrote: > >The error, as stated before, occurs on the call to urlretrieve(), and the exception is as follows: > >Traceback (most recent call last): > File "C:\Program Files\Python20\Pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript > exec codeObject in __main__.__dict__ > File "C:\Program Files\Python20\scripts\grabweb.py", line 37, in ? > download() > File "C:\Program Files\Python20\scripts\grabweb.py", line 23, in download > retval= urlretrieve(url)[0] > File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 68, in urlretrieve > return _urlopener.retrieve(url, filename, reporthook, data) > File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 198, in retrieve > fp = self.open(url, data) > File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 166, in open > return getattr(self, name)(url) > File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 267, in open_http > h = httplib.HTTP(host) > File "c:\program files\python20\lib\httplib.py", line 640, in __init__ > self._conn = self._connection_class(host, port) > File "c:\program files\python20\lib\httplib.py", line 330, in __init__ > self._set_hostport(host, port) > File "c:\program files\python20\lib\httplib.py", line 336, in _set_hostport > port = int(host[i+1:]) >ValueError: invalid literal for int(): > >Hopefully this is enough information now, and thank you to anyone who's looking at this. I don't see this on my Win98 machine. The code at that point is trying to extract the port number. It found the ":", but host[i+1:] seems to be null. If you want to play with this, you might try inserting some print statements in set_hostport in httplib.py to print the vaue of host and of i before that statement. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From info at black-karma.de Wed Jun 27 03:18:39 2001 From: info at black-karma.de (Harvest T. Moon) Date: Wed, 27 Jun 2001 09:18:39 +0200 Subject: Python on BeOS References: <9hb0ib$d4i6k$1@ID-22517.news.dfncis.de> <993619377.780885@yabetcha.drizzle.com> Message-ID: <9hc16t$d3o67$1@ID-22517.news.dfncis.de> "Donn Cave" schrieb > Bethon is not a GUI module, and it sure is thread-safe, but indeed > it is wrappers for the native BeOS API. What did you do, that led > you to think it was not thread-safe? hum, maybe it's my way to work with threads. but i.e. in a listbox: everytime i tried to insert an item to it from some other thread than the mainthread the application crashes. i'll look up the code and post it later the day :) Harvest T. Moon -- a life less ordinary!! From hemmi at crc.co.jp Thu Jun 14 21:50:41 2001 From: hemmi at crc.co.jp (HEMMI Shigeru) Date: Fri, 15 Jun 2001 10:50:41 +0900 Subject: idle BUG References: Message-ID: <3B2969F1.D28D0E71@crc.co.jp> I am using python 2.1 on Win98. I have some experience which may be a clue of this problem. (Note: I am new to python; I am not sure if what I am writing is true.) In conlusion, I suspect that to use pythonw.exe instead of python.exe to launch idle.py from dos box is better. My experience: Start python.exe idle.py and then do os.system('myprog.exe') from idle-shell window will cause hang. Here, myprog.exe is a tiny console app in which simple stdin and stdout have been used. Instead, start pythonw.exe idle.py and do the same thing, it worked properly and I was able to close idle without problems. Robin Becker wrote: > > I think this must be a bug in Tkinter, but since no one ever responds I > thought I'd whine about idle instead. > > I run python2.1 Win95 OSR2. > Start a command window > run python idle.py > > Kill the idle window using the mouse (click on the x). In some unknown > percentage of cases (like 50%) the process hangs and doesn't return to > the command window. > > The hung process is very destructive and makes it impossible to reboot > the machine properly. This bug has been present for a very long time and > I'm fed up with it. (snip) Regards, HEMMI Shigeru From skip at pobox.com Tue Jun 19 18:16:24 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 19 Jun 2001 17:16:24 -0500 Subject: How can I format the string according to its length at runtime? In-Reply-To: <9goi8l+9lqb@eGroups.com> References: <9goi8l+9lqb@eGroups.com> Message-ID: <15151.53048.747753.485681@beluga.mojam.com> ed> I am trying to supply the precision formating at run time: ed> s = 123 ed> print '(0x%-6X -)'%s ed> where I try to dynamically supply the number 6 from (6- length of s), ed> I can't find a way to dynamically supply that. Check here: http://www.python.org/doc/current/lib/typesseq-strings.html Basically, you put * where you want to interpolate the width from a number: >>> wid = 12 >>> print '(0x%*s)' % (wid, "allan") (0x allan) -- Skip Montanaro (skip at pobox.com) (847)971-7098 From loewis at informatik.hu-berlin.de Tue Jun 5 12:42:26 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 05 Jun 2001 18:42:26 +0200 Subject: How to get a unicode degrees symbol? References: <9fj0j6$e7m$1@nntp6.u.washington.edu> Message-ID: "Russell E. Owen" writes: > I'm obvious missing some important bit of documentation, but I looked > through the manuals and can't seem to figure out how to get unicode > character constants into python strongs. Strings, you mean :-? There are two notations: u'A string with a special charachter: \u1234' u'Another such string: \N{EURO SIGN}' Regards, Martin From grante at visi.com Sun Jun 24 23:33:43 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 25 Jun 2001 03:33:43 GMT Subject: Is this a true statement? References: Message-ID: On Sun, 24 Jun 2001 22:01:49 -0400, Tim Peters wrote: >Hmm. Has anyone in this thread written a device driver? Yes. For DOS, Unix (Solaris, Linux), and a couple different RTOSes. >If not, I'd like to point out that PEP 255 generators are >ideally suited to the task . I haven't been following that thread -- perhaps I should. -- Grant Edwards grante Yow! I just got my PRINCE at bumper sticker... But now I visi.com can't remember WHO he is... From ullrich at math.okstate.edu Sat Jun 2 16:39:15 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sat, 02 Jun 2001 20:39:15 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> Message-ID: <3b19393d.703539923@news.okstate.edu> On Sat, 2 Jun 2001 17:28:22 +0200, "Alex Martelli" wrote: >"David C. Ullrich" wrote in message >news:3b18ea18.332276 at nntp.sprynet.com... > ... >> I said you cannot have complete information about >> a physical system. You can't. An algorithm is not > >Let's take your original sentence again, snipless: > >""" >A physical RNG can have the property that one cannot make >any prediction about the value of the next bit even given >_complete_ information about how the numbers are being >generated. >""" > >This says "GIVEN _complete_ information". Now you say >you CANNOT "have complete information". The two >statements are in contradiction. If you cannot have it, >how can it be given? I don't see why you keep denying >this obvious contradiction. I don't recall you pointing out _this_ contradiction previously; the "obvious contradictions" I recall you pointing out were contradictions between things I'd said about algorithms and things I'd said about physical systems (and the reason I keep denying that _they_ are contradictory is that an algorithm is _not_ a physical system - there's nothing contradictory about saying every tomato is green and this apple is red...) I don't think there was anything contradictory about what I meant to say, but I do agree those two statements look a little contradictory. No, a person cannot have complete information about the state of that physical RNG. And even if one _could_ have complete information, that would still not be enough to predict the next bit. That's assuming that physics is not all wrong. And probably I should not have said what I did the way I did, because my impression is that there is really no such thing as complete information about a physical system. >I claim: if you cannot make a prediction it is because you >are NOT given complete information. Whether that is >because it cannot be given 'in principle' (physically) or >because it just is not given, is mathematically rather >irrelevant, it seems to me. > >So what does the "GIVEN _complete_ information" above >is, if not a statement that you CAN be given complete >information about > > >> >So, to recap: the post I was replying to states that given >> >[what you now state is] an impossibility, >> >> No. I never stated that it was impossible to have >> complete information about the state of an algorithm. > >You didn't, but you did state and re-state that it's >impossible to have complete information about the >state of a physical system, and yet the key characteristic >you stated for 'a physical RNG' begins with "GIVEN >_complete_ information". > > >> >> can have complete information regarding the state >> >> of an _arithmetic_ _algorithm_. >> > >> >I assume that is your definition of "an algorithm"? >> >> It's not the _definition_, (and to the extent that >> it is part of a definition it's not _my_ definition). > >It's a popular definition, though not universal of >course -- Darren New seems to be debating on this >same thread on the basis of the finitistic definition >of 'algorithm'. Very well then, if you can conceive >of algorithms whose state cannot be finitely described, Good heavens, of course the state of an algorithm can be finitely described. I didn't say otherwise. When I said "not _my_ definition" I meant it was not a definition due to me, not that it was not a definition that I was using. When I said that it was not the definition I meant _exactly_ that: "one can have complete information regarding the state" is not the definition of "arithmetic algorithm". You're not actually suggesting that you or anyone else thinks that "one can have complete information" _is_ the _definition_ of the word "algorithm"? By this definition the number 2 is an algorithm. If I'd said that "red" is not the definition of "tomato" would you conclude that I could conceive of non-red tomatoes? Even if I then said something about "to the extent to which red is part of the definition"??? >then, there you are: prediction will be impossible with >those algorithms because you can never possess all >the relevant information. There, happy now? > >(I _think_ -- but am not a philosopher or mathematician >so cannot feel sure -- that part of what Goedel shows is >that arithmetic is powerful enough to model any other >formal system, I'm a mathematician. Lucky me. I can think of _various_ things that "arithmetic is powerful enough to model any formal system" might mean, some of which are nonsense and some of which are true, at least given certain constraints on the _size_ of the formal system. Arithmetic certainly cannot model _any_ formal system in any reasonable sense, for example langauges with uncountably many constants are going to be tough to model in arithmetic. But Godel numbering does show that you can model formal systems in small languages in arithmetic, in some sense. > including the inconsistent-if-complete >conumdrum, so I don't imagine it's the "arithmetic" >part of 'arithmetic algorithm' that you imagine limits >a non-finitistic algorithm predictability?) I have not said anything about non-finitistic algorithms. >> Take it up with Heisenberg. If it's possible to have >> complete information about a physical system then >> physics is simply _wrong_. > >It may be right, it may be wrong, how does that affect >mathematics anyway? I can't decide whether this is intentional or accidental drift. I did not say that it had any effect on mathematics. I said it was impossible to have complete information about a physical system. You replied asking me who I was, some infallible priest or something, I forget exactly how you put it. So I rephrased what I'd said, including what one would think would be the obvious disclaimers. Now you ask me how that affects the math. I never said it did. > You think mathematics should be >changed based on what physical theories happen to match >or not-match the alleged 'real' world, maybe...? Over and over and over you say things that you seem to think have something to do with things I said, but over and over I have no idea how you got from anything I actually did say. >> >> > From what I know of Chaitin's life work, >> >> >it started with just the idea of defining randomness in >> >> >terms of minimal amount of information (in bits) you need >> >> >for prediction. If YOUR definition of 'randomness' is > ... >> I really don't have any idea what you're getting at here. >> I never said anything about what's fruitful or interesting >> or useful. JVN said anyone using arithmetic methods to >> get random numbers is in a state of sin. It was stated >> that Chaitin has shown that this is wrong. I didn't see >> how, but I'm not familiar with his work, so I asked >> how Chaitin's work showed that JVN was wrong. So far >> I haven't heard the esplanation. > >I reiterate my suggestion that said explanation is most >likely to be found in the less-than-200-pages of Chaitin's >new book, given its title "Exploring Randomness", and >that, not having yet read it, I could not presume to do >it full justice. And I reiterate my statement that when someone says that recent work of Chaitin says that JVN was wrong, I ask for a hint regarding exactly _how_ Chaitin shows that JVN was wrong, then saying "it's probably in the book" is no answer. Ask me to justify something I've said at any time in my life about mathematics. I will _tell_ you what the proof _is_ (or tell you _exactly_ where to find the proof, _or_ in rare cases say no, I really didn't know what I was talking about.) People don't usually try to prove things by saying it's probably in a book somewhere... > (But I have now ordered it, so that may >change soon!-). Still, it doesn't seem mind-bending as >a possibility: if randomness can be defined based on the >number of bits needed for prediction (no need to require >an INFINITE number of bits before the word can be used), >why shouldn't arithmetic be quite usable to build a system >whose output requires sufficiently many bits of info to >predict, that its randomness is sufficiently high for a >given purpose? What's "sinful" about it? > > >> Probably "is in a state of sin" is not well-defined. > >Presumably was meant as a humorous quip? Sigh. If we are talking about "random enough for a given purpose" then JVN's _original_ comment was just totally and utterly stupid. Of course there is no problem coming up with an arithmetic RNG which is good enough for a _given_ purpose. _If_ we decide for some reason to assume that JVN was not a total moron then it's extremely clear that he was not talking about finding an RNG that's good enough for a _given_ purpose - the only non--moronic interpretation is the problem of finding an arithmetic RNG that's good enough for _any_ purpose (one RNG). >> I take the comment to mean that there is no "percect" >> arithmetical RNG. It seems extremely clear to me that >> there isn't, and I haven't heard anything that explains >> how Chaitin's work _does_ show that there exists >> a perfect arithemtical RNG. > >I'm not sure what you mean by "perfect" (or "percect" -- >not sure if that was a typo, typo > and if so, whether it was for >'percept' or 'perfect'). If you mean one requiring an >infinite amount of information for prediction, I guess it >would start with a halting-problem, Goedel numbers, or >other equivalently-hard problems as modeled in >arithmetic, I don't think that Godel numbers are a "problem". > and the random bit would be some low >bit in a count of the number of operations needed to >get a solution -- as the 'algorithm' would not be >guaranteed to stop (which makes it non-finitistic, and >thus, for those who DO require finiteness as part of an >algorithm's definition, not an algorithm), there could be >no bounds placed on the effort (information) required >to predict (no bounds = boundless = infinite -- as hotly >debated on a separate recent thread:-). I doubt very much >that Chaitin wastes his precious time with these specific >silly mind-games (thus showing once more he's a far >wiser man than me:-), because that "perfect" (which was >not in the original question) Here's the original question: >That's what I was always taught, however in the light of >Gregory Chaitin's work or randomness in arithmetic: > > > >JVN may have been wrong. ??? There's a _lot_ of stuff there. Could you give us a hint regarding exactly what work of Chaitin's shows we can get "truly random" numbers from arithmetic algorithms? Um, that's not the question at the top of the thread, that's my original question that's led to this hoo-haw. What do you imagine I meant by '"truly random"'? Never mind. Do you really think that somehow the phrases "truly random" and "perfectly random" mean something different to me? >requirement for infiniteness >is of little interest in this context. If we model random >number generation as an adversarial cryptographic scenario, >which does seem a productive way to look at it, then we >are not required to come up with schemes which make >our adversary require infinite work (information) to predict >(and thus decrypt): it's enough that, for any ratio of our >work encrypting (generating) for his decrypting (predicting) >that is requested, we can come up with a setting that makes >the ratio higher. Of course. This is clear. This is awesomely clear, whether we know anything about Chaitin's work or not! So it also seems clear that it's not what I was asking about... > And I believe (not being really up to date >on the latest cryptography results, I 'surmise' might be >closer:-) that so-called one-way-functions allow us to make >the work-ratio predict/generate (decrypt/encrypt) higher >than any pre-requested threshold. I do suspect that 1-w-f >are part of Chaitin's work, btw. > >And quips apart, what's "sinful" about dealing with >randomness this way? If the underlying maths are sound >(and that, I surmise, IS what Chaitin has to do with it: >showing the soundness of this finite-maths approach >to randomness), why shouldn't RNG's be feasible and >sin-less that are based on these techniques? > > >> In fact I didn't claim _anything_ except that I didn't >> see how there can be a _perfect_ arithmetic RNG, >> Chaitin or no Chaitin. That's a _true_ statement >> about what I don't see. > >Depending on your definition of 'perfect', I hope the >construction above may satisfy your quest for vision? _What_ "construction"? Not sure whether or not you're referring to "and the random bit would be some low bit in a count of the number of operations needed to get a solution -- as the 'algorithm' would not be guaranteed to stop (which makes it non-finitistic" If that's what you're referring to, I think it's a little vague to be called a "construction". But yes, a person _could_ do interesting things along those lines. But if the "algorithm" is not guaranteed to stop then it's not an algorithm. An RNG that takes infinitely much time to return sometimes is not very useful. (And if we put some upper limit on the number of steps we've lost our pristine perfection...) >> >what makes you SO certain that NO other physical >> >systems can also be predictable in the same sense?-) >> >> Well, if I'd claimed that a physical computer was >> predictable you'd have a point. >> >> But claiming that no physical system is predicatable >> _except_ for computers is (i) not something I said, >> (ii) so obviouslt ridiculous that I don't see why you >> would think that that's what I was claiming from >> anything I _have_ said. > >It seems to me that enough things you're saying have >just-as-ridiculous obvious consequences, such as your >joint assertions 'GIVEN _complete_ information' [about >a physical system] and 'comlete information cannot be >had' [about a physical system]. How am I to know which >ones of these contradictions and 'ridicolousnesses' you >ARE in fact claiming (perhaps in error) and which ones >you are not? I tend to doubt that I said anything about "GIVEN complete information." I did say something about "given complete information". A _hypothesis_ is not an assertion. Here are two true theorems of mathematics: Thm1 If x is a real number then x^2 >= 0. Thm2 GIVEN a real number x such that x^2 < 0 it follows that x^2 >= 0. Those are both true. The hypothesis in one does not contradict the assertion in the other - it can't, being just a hypothesis. So in fact there was nothing contradictory about what I said, _quite_. But I agree I didn't say what I meant very well - this is the first I recall your mentioning this particular ""contradiction" - I tried to clarify what I meant a few lines up. > I still haven't heard your definition of >'perfect' randomness, for example. I have my doubts >I'll be able to find it non-ridiculous, but I've been wrong >before. So until you deign to give us your definition, >and clear up all the seeming contradictions in what you >have said before, The seeming contradictions that you've mentioned previously are no contradictions at all, any more than saying every tomato is red and here is a green apple is a contradiction. If I say that and if you happen to think that apples are tomatoes then it's a contradiction. But apples are not tomatoes, and algorithms are not physical systems - that takes care of all the "contradictions" you've pointed out previously. I hope I've clarified the contradiction you mention in this post - while I don't think it was actually a contradiction, I do agree that seeing it as contradictory is not all that unreasonable, I would have stated things much more carefully if I'd known there was going to be a quiz. The bit about "until you deign to give us your definition" would be appropriate _if_ you had _asked_ for a definition previously. Since you asked: Zero-th, note that the word "random" is used in many different ways, even in mathematics. For example if I slip and use the phrase "random variable" below, that use of the word "random" is not what we're talking about at all. Curiously. (It's certainly a related notion, but for example it makes no sense whatever to ask how random a random variable is - it's not the same use of the word.) First, I don't think that it makes sense to talk about a perfectly random _sequence_, any more than it makes sense to talk about a random number. Someone wanted to know how random 6 was. What it seems to me makes sense is the notion of a perfect RNG. A perfect RNG is _not_ going to generate "perfectly random" sequences - the ouput _could_ be 0000000000000000000.... That's only going to happen 0% of the time, but the same is true of any other specific sequence - an RNG that is constrained so as not to generate that sequence is "imperfect". So to finally answer your question: A perfect RNG is one with this property: If you use it to generate N bits then each sequence of N bits appears with probability 1/2^N. It has this property for _every_ N. (So for example there is no correlation between the output on one run of N bits and the next run of N bits, because a pair of runs of N bits is the same as a run of 2N bits, and a correlation would mean that all sequences of length 2N were not equally likely.) (Hence an algorithm, as the word is usually defined, cannot be a perfect RNG. Because it has only finitely many states - it must repeat after a while, and hence for large enough values of N it is not true that all sequences of length N are equally likely.) >what can I do except operate on the >basis of working hypotheses based on the most >reasonable interpretations of your words, and showing >where I think there are contradictions, tautologies, and >so forth? When you're talking math contradictions are the one evil. But there's nothing bad about tautologies, in fact tautologies are all we have. (That's using the colloquial meaning of "tautology", not the meaning in formal logic, the difference being that colloquially anything that's necessarily true for purely logical reasons is a tautology, while in official logic tautologies are part of propositional logic. Ie a logical truth in first-order logic like "if every tomato is red and george is a tomato then george is red" is not formally a tautology, just because it's not part of _propositional_ logic, it involves predicates.) >Meanwhile I still see nothing 'sinful' in dealing with >randomness finitely, and nothing I've seen on this >thread has taken me even a iota closer to seeing it. >Or to seeing why arithmetic (which is quite capable >of non-finiteness if you push it:-) should be singled >out in this context. > > >> >it seems to become tautological ("I define X as being >> >something that requires infinities: no finite system can >> >reach X, it can only approach it") >> >> Another thing that's been puzzling me is where I've >> said anything about these infinities that you continue >> to quote me about. > >As you do not deign to define your terms (not even to >USE them, actually -- that 'perfect' was NOT in the >original quote from JVN) unless pushed very hard about >it, I know a lot of places where I can read lots of proofs that Cantor was wrong about everything and Godel was wrong about everything, etc. The reals are countable. Fermat's last theorem is false. One of these guys' main tools is refusing to define terms when asked. This is why I find your comment about my not "deigning" to define terms _offensive_, in case you're curious. Exactly where... lemme rephrase that: Exactly WHERE in this thread did you or anyone else ask me to define some term I was using? Please be specific. > why are you puzzled that people take the terms you >use in the normal and obvious meaning they could be >taken to have in your usage context? What _IS_ a >'perfect randomness', as you use the term, if not one >taking infinite information to predict? "Infinite information" is not going to allow one to predict _anything_ about the output of a perfect RNG, as I defined it above. > Until and unless >you clarify your terms you'll have to resign yourself >to people reading them in reasonable-looking ways that >might not have been the ones you intended them in. > > >Alex > > > David C. Ullrich *********************** "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From bsass at freenet.edmonton.ab.ca Wed Jun 27 04:53:38 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Wed, 27 Jun 2001 02:53:38 -0600 Subject: the indentaion for grouping thing In-Reply-To: <3b38f4a5_1@anonymous> References: <3b34de9a$1_2@anonymous> <9h2qpa$6bg$1@slb0.atl.mindspring.net> <3b38f4a5_1@anonymous> Message-ID: On Tue, 26 Jun 2001, Anonymous wrote: > "Andrew Dalke" wrote in message > news:9h2qpa$6bg$1 at slb0.atl.mindspring.net... > > Use tabnanny, or run Python with the '-t' or '-tt' > > options. If you're worried, force your version > > control system to run a validation on the code > > before checking it in. > > Like I said, all answers like "well, just use product x" don't fly because > it's not just me that has to use the script. I want my scripts to be > maintainable by people I don't necessarily know of. I consider it a design > flaw to have the language dependent upon artificial solutions that are > external to the language in order to have it be maintainable. > > Anyway, nothing will change, so is there a product like I asked about that > validates and parsers python with paired delimiters added? Not pindent, and > not comments, because the script has to be unparseable by python without the > pre-processor. Unparsable by Python, would mean it is not Python, so it would have to use product x... the best Python could do is grow a hook so you could filter the source automatically, you would need to provide the filter. - Bruce From rnd at onego.ru Mon Jun 18 11:25:17 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 18 Jun 2001 19:25:17 +0400 (MSD) Subject: Loading select queries into objects In-Reply-To: Message-ID: On Mon, 18 Jun 2001, Graham Ashton wrote: > In article , "Unknown" wrote: > > > That is, if I understand how you want to do it: > > The list of functions is [f0, f1, f2] and you want: f0(tup[0]) > > f1(tup[1]) > > f2(tup[2]) > > > > You could do something like: > > funlist = (self.column1, self.column2, self.some_column) > > > > for i in range (len(funlist)): > > apply(funlist[i],(tup[i],)) map(lambda f, x: apply(f, (x,)), funlist, tup) does the same, BTW. Or even: [apply(f, (x,)) for (f, x) in map(None, funlist, tup)] Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From me at mikerobin.com Tue Jun 26 13:57:31 2001 From: me at mikerobin.com (Michael Robin) Date: 26 Jun 2001 10:57:31 -0700 Subject: PEP 255: Simple Generators References: <9h1tt9$16i$1@slb1.atl.mindspring.net> <3B37E7B4.AA2A1095@cosc.canterbury.ac.nz> Message-ID: <52e5ab5f.0106260957.45c59eb6@posting.google.com> It seems to me the following are reasons to use generators: 1. The routine doing the generation is complex, and possibly pre-existing. This makes it hard to keep state explicitly between calls. 2. Keeping state explicitly (by stuffing & reloading object attributes, for example) is bound to be slower than yield()'s implementation of frame-freezing (And if the generator fn is not part of a class, there may be no convenient place to hold state anyway, but I guess it has to, so one can override __iter__...) 3. The number of generated objects is large, so consuming generated elements avoids the allocation of a large collection to hold all pre-generated values. 4. The amount of time to create each new object is relatively large. Consuming each element as needed "spreads out" computation time, which could be beneficial in real-time applications. The generator's memory allocation is only the worst-case for generating the next element. 5. Every element will be processed in order of generation. If processing is done out of order, returning a collection may be more efficient. As the iterator object only supports .next(), skipping generation through arbitrary indexing or slicing is not supported. Is all this right? A question about canceling generators: Is the following a correct metaphor for canceling a generator: def __init__(self): self.keepGenerating = 1 def __iter__(self): return inorder(self) def cancel_inorder(self, node): self.keepGenerating = 0 def inorder(self, node): while self.keepGenerating: ...your cool code here yield result return This seems to have several problems, among which is loosing many of the niceties we gained by using yield(). Could this be handled better by a method/attr on the iterator object itself? (Then again, we don't normally have an explicit reference to it...) Of course, we can't tell the difference between a "cancellation" and normal exhaustion of elements. Is "raise StopIteration(reason)" a reasonable option? Another option is to cancel the consumer instead. I guess the current PEP defines narrow class of generator usage and there probably is no "correct metaphor" for canceling a generator. This assumes another thread is stopping the generation, so I guess we could be using the heavyweight thread-based generator module instead in this case. Async cancelation aside then, if a generator is in-progress and the consumer exits before all elements are consumed causing the iterator-object to go out of scope, I assume all the right things happen and the frames go away with all the references they hold? I'm sure it does, but I don't think I saw reference to this case in the PEP. I look forward to using the new generators when appropriate, and also hope a more general uthread or continuation-based model also makes main-stream one day. thanks, m ============================================================ Greg Ewing wrote in message news:<3B37E7B4.AA2A1095 at cosc.canterbury.ac.nz>... > Andrew Dalke wrote: > > > > Chemist: A what? What's a generator? > > Me: It's a function that returns a special kind of object. > > You shouldn't have said "function", you should > have said "callable object". > > > Me: Well, you can think of a class as a function that returns > > a special kind of object. > > You're going way too fast for this guy, given that > he doesn't know about OO yet. He needs to become > comfortable with OO concepts first, then you can > explain iterator objects, *then* you can explain > what generators do. > > Until then, generators are going to seem like > black magic no matter what keyword they're defined > with. From bh at intevation.de Fri Jun 29 09:39:04 2001 From: bh at intevation.de (Bernhard Herzog) Date: 29 Jun 2001 15:39:04 +0200 Subject: Augmented Assignement (was: Re: PEP scepticism) References: <6qn16r7i69.fsf@abnoba.intevation.de> Message-ID: <6qels376dj.fsf@abnoba.intevation.de> "Steve Holden" writes: > "Bernhard Herzog" wrote in message > news:6qn16r7i69.fsf at abnoba.intevation.de... > > Carsten Geckeler writes: > > > > > As mentioned above, for tuples the "+=" is completely natural, but not > for > > > lists. > > > > Funny, I mostly see it exactly the other way round. += modifies the left > > hand side in place, so it's natural for a list, but not for a tuple. > > > I suppose that depends. Given the following initialization code: > > lst = [1, 2, 3] > tpl = (1, 2, 3) > lstx = lst > tplx = tpl > > would you expect the same results from > > lst += ["extra"] > tpl += ("extra", ) Well, this could modify lst and/or tpl in place ... > > and > > lst = lst + ["extra"] > tpl = tpl + ("extra", ) ... while this usually creates new objects and doesn't modify either lst or tpl (unless they implement __add__ in an unsual way). > to be the same? So, I wouldn't expect them to behave in the same way. OTOH, consider the statement x += (1,2,3) Does that modify x in place? This works regardless of whether x is a tuple or a list, but if x is a list x is modified in place while if it's a tuple it isn't. (interestingly enough x += [1,2,3] gives a TypeError if x is a tuple.) One consequence for me is that I'll very careful with augmented assignments. It seems to me the only situation in which their use should be considered is when it's OK to modify the object on the LHS in place (which is basically what the pep says, too). Bernhard -- Intevation GmbH http://intevation.de/ Sketch http://sketch.sourceforge.net/ MapIt! http://mapit.de/ From see-sig at from.invalid Sat Jun 16 09:27:41 2001 From: see-sig at from.invalid (David Efflandt) Date: Sat, 16 Jun 2001 13:27:41 +0000 (UTC) Subject: bad python display References: <9gdie8$r2v$1@solaria.cc.gatech.edu> Message-ID: On 15 Jun 2001 17:59:36 GMT, Holland King wrote: > > sorry for the cross-posting but i am not real sure what is causing the > problem. > i have a python program using the tkinter module to create a gui. my > local system is running woody debian with kde. i am running the program > on a soloris box. on both my system and the solaris system i am using the > same version of ssh, python, and tkinter lib. the problem is when i try > to export the display from the solaris box to my local machine all i get > is the frame and half the boxes and buttons. when i run it locally i get > the correct display and when i try to export the display on other machines > i get the correct display. i think it has something to do with ssh, but i > have tried everything i can think of. can anyone think of what might be > causing the display on my machine to be unusable? > ssh -V == 2.5.2p1 > python -v == 1.5 > tkinter -v == 1.127 > thank you. Are you running X under ssh-agent (I have "ssh-agent startx" as an alias to startx), then ssh-add from an xterm? That should automatically set up your DISPLAY variable on the other end to tunnel everything back through ssh. Not quite sure how to do that from GUI login (runlevel 5). If not tunnelling through ssh, maybe there is a port permission problem on either end or you may need to use xhost to allow it. I don't really know anything about python or tkinter, but do other X programs run remotely automatically display locally (xterm, netscape, etc.)? -- David Efflandt (Reply-To is valid) http://www.de-srv.com/ http://www.autox.chicago.il.us/ http://www.berniesfloral.net/ http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/ From byte1024 at hotmail.com Fri Jun 8 15:22:21 2001 From: byte1024 at hotmail.com (Luigi) Date: Fri, 08 Jun 2001 19:22:21 GMT Subject: Jython's tutorial. Where? Message-ID: Hello, Where I can find tutorial about Jython? Thank you -- Luigi From dsh8290 at rit.edu Wed Jun 6 17:05:55 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 6 Jun 2001 17:05:55 -0400 Subject: Generating Multiple Class Instances In-Reply-To: <3B1E9271.B05CC4E3@fnal.gov>; from jtorborg@fnal.gov on Wed, Jun 06, 2001 at 03:28:33PM -0500 References: <3B1E9271.B05CC4E3@fnal.gov> Message-ID: <20010606170555.D14867@harmony.cs.rit.edu> On Wed, Jun 06, 2001 at 03:28:33PM -0500, Julie Torborg wrote: | I'm no wiz at OOP, but I have the following problem: | | I have a list of some hundreds of items, each of which has several | attributes,What I want to do is peg each of the values to the list item | and move it around my program. This seems like the perfect opportunity | to take advantage of the OOP aspect of Python by setting up a class, but | I can't create or use instances without hard-wiring it for every list | item. What I want to do is: | | class Quark: | def __init__(self): | self.color=getcolor() | self.mass=getmass() | | flavor=['up', 'down', 'strange', 'charm', 'top', 'bottom'] | for each in flavor: Here you create a new local name that is bound to each element in the list 'flavor' in succession. | each=Quark() Here you rebind it to a new instance of the Quark class. Each iteration creates, then releases a new instance of the Quark class. | ###Then later: | for each in flavor: | print each.color 'flavor' is still just a list of strings, it hasn't been changed. | ###What I'm relegated to doing is: | | up=Quark() | down=Quark() | strange=Quark()... | | print up.color | print down.color | print strange.color... | | Which works, but with hundreds of list items, gets messy in a hurry. | I've also tried messing around with using something that looks more like | quark=Quark() several times, but then all the info stored in the | previous instance gets obliterated. I've also tried using lists and | dictionaries, but they're bulky and what's the point of using an OOP | language if there's no additional functionality or elegance? Try this instead : flavor_list = ['up', 'down', 'strange', 'charm', 'top', 'bottom'] flavor = {} for each in flavor_list : flavor[ each ] = Quark() Here I start with the list of flavors, represented as strings (interesting flavors...must be a different language ). I iterate through that list and add a new instance of the Quark class to a dictionary. The key to the dictionary is the flavor. Later you can for name , value in flavor.items() : print name , ":" , value.color To print out the names and their associated value. An alternative solution would be to store the name of the flavor in the instance of the Quark class. It could be an argument to __init__. class Quark : def __init__( self , name ) : self.name = name <...> flavor_list = ['up', 'down', 'strange', 'charm', 'top', 'bottom'] flavor = [] for name in flavor_list : flavor.append( Quark( name ) ) del flavor_list # not needed anymore for item in flavor : print item.name , ":" , item.color If this isn't clear enough to you, just ask again and mention which parts aren't clear :-). -D From nperkins7 at home.com Wed Jun 20 23:32:48 2001 From: nperkins7 at home.com (Nick Perkins) Date: Thu, 21 Jun 2001 03:32:48 GMT Subject: Partially evaluated functions References: <9gpf5a0313h@enews2.newsguy.com> Message-ID: "Alex Martelli" wrote... > ... > from __future__ import nested_scopes > > def curry(func, *args, **kwds): > def callit(*moreargs, **morekwds): > morekwds.update(kwds) > return func(*(moreargs+args), **morekwds) > return callit > ... Sweet. I liked it so much I had to do some speed-tests: I used the following: ( supplies args left-to-right, with call-time kw args trumping create-time kw args ) from __future__ import nested_scopes def curry(func, *args, **kwds): def curried_function(*moreargs, **morekwds): kwds.update(morekwds) return func(*(args+moreargs), **kwds) return curried_function ...and tested this against a class-implementation of curry: ( avoiding any dict.copy()...) class curry_class: def __init__(self, func, *args, **kwds): self.func = func self.args = args self.kwds = kwds def __call__(self, *moreargs, **morekwds): self.kwds.update(morekwds) return self.func(*(self.args + moreargs), **self.kwds) I used both of these to create some curried functions, and some nested curries, e.g. curry(curry(fn,arg1),arg2) .. and then timed calling them many times. I found that the function-version is significantly faster than the class-version, in fact, almost twice as fast in the tests that I ran. Cool stuff. Nested scopes rule. From loewis at informatik.hu-berlin.de Sat Jun 16 14:59:31 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 16 Jun 2001 20:59:31 +0200 Subject: Fastest way to extract used namespaces from a piece of XML? References: Message-ID: "Thomas Weholt" writes: > I need the fastest code available for extracting all namespaces used in a > piece of xml. I got this code for doing this, but it's slow as hell. Any > clues? Using xml.parsers.expat directly is certainly faster; just set the StartElement handler, and no other handler. If you have PyXML, using xml.parsers.sgmlop might be even faster. You will have to do the namespace processing yourself, i.e. by looking at attributes that start with xmlns. Regards, Martin From aleaxit at yahoo.com Wed Jun 20 14:58:00 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 20 Jun 2001 20:58:00 +0200 Subject: for i in References: Message-ID: <9gqrrl01bpr@enews1.newsguy.com> "dan" wrote in message news:ou4Y6.35975$Vl2.1751749 at news20.bellglobal.com... > what was overloaded in UserList so its items could be extracted when you do > > for i in UserList([1,2,3]) Special method __getitem__. It must raise IndexError when the index parameter is too large. (In Python 2.2, there will be a better way, but up to 2.1, __getitem__ it is). Alex From christian at rocketnetwork.com Fri Jun 22 19:12:06 2001 From: christian at rocketnetwork.com (Christian Reyes) Date: Fri, 22 Jun 2001 16:12:06 -0700 Subject: Running an .exe file with python References: Message-ID: <9h0jc9$npg$1@bob.news.rcn.net> you should try the os.execv method >>> os.execv('c:\\yourapp.exe') christian "Steve Keri" wrote in message news:ea903c3a.0106221412.641fcf3 at posting.google.com... > Is there a way i can run an .exe file and install a program using > python? please help From cyblue at a-lab.co.kr Fri Jun 22 02:52:58 2001 From: cyblue at a-lab.co.kr (cyblue) Date: Fri, 22 Jun 2001 06:52:58 GMT Subject: [Q] python embedding Demo Message-ID: I compiled Python source in /python1-1.5.2/Demo/embed. but follow error massage. ------------- gcc demo.o usr/lib/python1.5/config/libpython1.5.a -lsocket -lnsl -ldl -lreadline -lt ermcap -lm -o demo /usr/bin/ld: cannot find -lsocket collect2: ld returned 1 exit status make: *** [demo] error 1 ---------------------- what's wrong? pleeeeez help me. From db3l at fitlinxx.com Wed Jun 13 15:48:51 2001 From: db3l at fitlinxx.com (David Bolen) Date: 13 Jun 2001 15:48:51 -0400 Subject: Plugins in Python References: <9g5hvq$ird$2@216.39.170.247> <9g8dim$cir$0@216.39.170.247> Message-ID: David LeBlanc writes: > Thanks David! That's exactly what i'm looking for. Python the ever > flexible snake! I sort of thought that (dunno why, just didn't occur to > me) that import wouldn't take a variable as in: > > mymodule = "c:/boo/yikes.py" > import mymodule > > I gather that's what you mean? Close - import in fact doesn't take such a variable, but you can use __import__ instead and give it a string. As two quick samples, below are two __init__ files (taken directly from a remote administration tool project of mine, so not all comments may make sense :-)). The first runs remotely at a site, and doesn't get packaged up but directly distributed, so I let the __init__ determine completely dynamically what to import. I just push out new modules into the package directory to add to the system. I go a little further in this one and borrow DateTime's LazyModule to hold off the actual import until the system wants to use the plugin. If you wanted a direct import, it's a little easier as you don't have to worry about the package path, just use: __import__('',globals(),locals()) The second is used in my UI tool that ops folks run, so it does sometimes get packaged up, and here I've decided to explicitly import the major plugins, but dynamically determine what they offer at runtime, which the UI tool then uses to determine what "pages" in the tool to display. ---- Dynamic package ---- """\ nimgmt package This is a package of modules for remote management of sites, designed to be used both on a site via an nimgmtd.py driver module, or centrally as part of a GUI site management tool. When imported, a supported "modules" dictionary is populated for the individual Python modules discovered in the package, and those modules are set up for lazy loading on a subsequent reference. The dictionary contains a module reference (initially set to be lazy loaded) for each module. The support modules are determined dynamically from the contents of the package directory, excluding files starting with "_". The get_object() function may be used to retrieve an instantiated management object for a module (imported through the lazy definition) - it acts as a singleton factory function, caching a module's object once created. """ # # ---------------------------------------------------------------------- # class Error(Exception): """General nimgmt exception class available to all modules""" pass # # ---------------------------------------------------------------------- # def find_modules(): import sys, os, fnmatch, string import DateTime.LazyModule LazyModule = sys.modules['DateTime.LazyModule'] # Walk the current directory to identify all management modules, # and store a reference to them within the returned dictionary. modfiles = filter(lambda x,m=fnmatch.fnmatch:m(x,'*.py'), os.listdir(__path__[0])) modules = {} for curmodule in modfiles: modname = os.path.splitext(curmodule)[0] if modname[0] == '_': continue else: modules[modname] = {'module': LazyModule.LazyModule(__name__+'.'+modname, locals(),globals())} return modules # # ---------------------------------------------------------------------- # modules = find_modules() del find_modules ---- Semi-static package ---- """Package of "plug-in" modules for the NI Site Administration Utility. Each of the modules in this package augment the stock administration tool by managing one or more of the administration "pages" to add functionality. Upon import, this package file creates a package-level classes dictionary, indexed by group name, the value of which is a dictionary indexed by page name. Each page value is a dictionary containing attributes of that page, currently: class - wxWindow derived class to instantiate for UI display description - Brief description of purpose of that class For a Python module within this package directory be suitable for inclusion in the classes dictionary, it must have the following required attribute: NIMgmt() - Return nested dictionary, keyed by category and then operation, of the same structure as described above containing information on any classes supported by that module. """ import sys # # ---------------------------------------------------------------------- # # Import each main plugin module. This is done manually (requiring # this file to be kept up to date as new plugins are added) to avoid # a lot of extra work later if packaging up this utility for the # installer package, which can't follow dynamic importing. Only the # module has to be imported, as the local dictionary is automatically # scanned for imported modules that have the administrative function # used to return information for populating the modules dictionary. # # ---------------------------------------------------------------------- # import Help import Inventory import EventLog import Services import Cardio import Strength import Local import Demo import Disk import Grep classes = {} # # ---------------------------------------------------------------------- # # Now walk modules we've imported and generate other information based # on the contents of those modules. # # ---------------------------------------------------------------------- # for module in globals().values(): if type(module) == type(sys) and module.__dict__.has_key('NIMgmt'): try: module_classes = module.NIMgmt() # XXX: Sanity check this to ensure all attributes available? # This doesn't protect against per-tab overwriting for group in module_classes.keys(): if not classes.has_key(group): classes[group] = {} classes[group].update(module_classes[group]) except: # Bad module - just skip # XXX: Log this better? pass del module, group > I take your point about the installer issue, and it's something i'd have > to live with I guess. I want to be able to dynamically download a new > plugin and have the user take no further action then putting it in the > plugins directory. This might even be done automagically as part of a > dynamic update or install feature and then the user couldn't even get > putting it in the right directory wrong ;-) Well, you could also do a mixture. Have the main application fully installable (built with py2exe or installer), but leave the plugins subdirectory plain, and just something included as part of the overall installation package (say with Inno Setup). Then the dynamic approach should be fine and you can drop in any file (or build an install tool that just drops in the file). Of course, even if you go with the more explicit approach, all that means is that distributing a new plugin is two files - the plugin module and the updated __init__. If different users may have different plugins, just always distribute the latest __init__ and protect against missing plugins with a try/except block around the import. And there's probably a ton of other ways to slice it. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From paulp at ActiveState.com Sun Jun 17 16:16:24 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sun, 17 Jun 2001 13:16:24 -0700 Subject: list.sort() References: <3B2CEBF1.CCF5377D@hack.org> <9givg3$lfd$2@s1.uklinux.net> Message-ID: <3B2D1018.E36B4B1E@ActiveState.com> Charlie Dyson wrote: >... > > Hmm, I actually think that this behaviour is not very logical. Concider: > > x = {'Python' : 'Cool', 'Linux' : 'Cool'} > print x.keys().sort() # Prints None > > It would be better if it sort **returned** the results, instead > I have to > do: > keys = x.keys() > keys.sort() > > That's one extra line of code!!! http://www.python.org/doc/FAQ.html#6.20 6.20. Why doesn't list.sort() return the sorted list? In situations where performance matters, making a copy of the list just to sort it would be wasteful. Therefore, list.sort() sorts the list in place. In order to remind you of that fact, it does not return the sorted list. This way, you won't be fooled into accidentally overwriting a list when you need a sorted copy but also need to keep the unsorted version around. As a result, here's the idiom to iterate over the keys of a dictionary in sorted order: keys = dict.keys() keys.sort() for key in keys: ...do whatever with dict[key]... -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From bh at intevation.de Thu Jun 14 05:23:51 2001 From: bh at intevation.de (Bernhard Herzog) Date: 14 Jun 2001 11:23:51 +0200 Subject: Embedding: Problem with CallObject References: <20010613.174914.1793282088.6934@bender.nowhere.non> Message-ID: <6qae3bxvmg.fsf@abnoba.intevation.de> "James Turner" writes: > Hello. > > I'm just starting to play with embedding Python in C, and I'm getting a > huge headache from trying to figure out what's wrong with my code here: > > --test.c-- > #include > > int main(int argc, char** argv) > { > PyObject *str,*mod,*flist,*func,*args; > Py_Initialize(); > str = PyString_FromString("anything"); > > /*Import mod */ > mod = PyImport_Import(PyString_FromString("one") ); This is a memory leak, because PyString_FromString returns a new reference. It would probably be easier to use PyImport_ImportModule because it takes a C string as argument and not a Python string object. > > flist = PyModule_GetDict(mod); > func = PyDict_GetItemString(flist,PyString_FromString("out")); PyDict_GetItemString takes a char* as the second argument, not a string object, so it should be: func = PyDict_GetItemString(flist, "out"); Your version most likely returns NULL causing the segfault later. > args = PyTuple_New(1); > PyTuple_SetItem(args, 0,str); > > /* FAILS HERE!! */ > PyObject_CallObject(func,args); You should check the return value of PyObject_CallObject and DECREF it. > Py_XDECREF(flist); > Py_XDECREF(func); Don't DECREF func because it's a borrowed reference. Likewise for flist. > Py_XDECREF(args); > Py_XDECREF(mod); > Py_XDECREF(str); > > Py_Finalize(); > return 0; > } HTH, Bernhard -- Intevation GmbH http://intevation.de/ Sketch http://sketch.sourceforge.net/ MapIt! http://mapit.de/ From aleaxit at yahoo.com Wed Jun 6 08:48:56 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 6 Jun 2001 14:48:56 +0200 Subject: network configuring through a script References: Message-ID: <9fl8ro015rl@enews2.newsguy.com> "Francis Meyvis" wrote in message news:kqoT6.127$3t.4788 at nreader1.kpnqwest.net... > Hi, > > I've W2k with ActiveState Py 2.1 on my notebook. Python provides some access > to COM things. > I'd like to have scripts that configure my notebook for networking at home, > at work, ... > This requires now going into the dialog for > - TCP/IP settings to change the IP address to use DHCP or use a fixed IP > address, http://cwashington.netreach.net/script_repository/view_scripts.asp?Index=532 &ScriptType=vbscript shows how to do this in VBScript with WshShell.SendKeys -- not all that elegant (!!!), but it sort of works. You can do it just as well in Python, of course:-). > automatic DNS or fixed DNS server > - IE5 properties/connections to setup Dialup or LAN settings. > - the IE5 LAN settings allow further automatic settings and proxy server > settings. > > Are these two also possible from within COM? I don't know of other ways except via sendkeys -- that doesn't mean such ways AREN'T there, of course, but I'm not familiar with them. > Or should one directly modify the registry? That might well be safest/most robust, yes. > Can someone point me to MSDN documentation on the inners of these > configuration dialogs? > I look in it but do not find anything usefull (could be that the MSDN I'v > access to is already to old). The online MSDN is always totally updated -- just visit http://msdn.microsoft.com/default.asp. Searching MSDN is a subtle skill, hard to teach, and I think I'm pretty good at it, but for all that I often do miss some things:-). Alex From robin at jessikat.fsnet.co.uk Sat Jun 23 12:05:49 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sat, 23 Jun 2001 17:05:49 +0100 Subject: stumbled on python iif() equivalent, at last References: <3B34B8DE.67D97C24@q-survey.be> Message-ID: In article <3B34B8DE.67D97C24 at q-survey.be>, Laurent Szyster writes >as i was peeking into compileall.py, i stumbled on: > > cfile = fullname + (__debug__ and 'c' or 'o') > >surprise: > > Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 > Type "copyright", "credits" or "license" for more information. > IDLE 0.6 -- press F1 for help > >>> __debug__ and 'c' or 'o' > 'c' > >so, there's an iif (condition, is_true, is_false) python equivalent: > > >>> 1 and 'c' or 'o' > 'c' > >>> 0 and 'c' or 'o' > 'c' > >nice-to-have for one-liner :-) > > >Laurent yes, but what if the true value is actually a python false eg >>> a='' >>> b='B' >>> c=1 >>> c and a or b 'B' >>> to avoid this you need >>> (c and (a,) or (b,))[0] '' >>> -- Robin Becker From bh at intevation.de Sun Jun 24 15:22:32 2001 From: bh at intevation.de (Bernhard Herzog) Date: 24 Jun 2001 21:22:32 +0200 Subject: PEP 255: Simple Generators, Revised Posting References: Message-ID: "Jeremy Hylton" writes: > This would be easy to fix in the case of yield for generators, except that > I'm not sure it's easy to fix for names in general. There are lots of other > strange possibilities: > > def f(): > if 0: > exec foo > def g(y): > return x + y > > Should this get a SyntaxError about the bare exec making resolution of free > variable x ambiguous? I'm not sure about this one. Since it's obvious even to the compiler that the exec statement will never actually be executed, it seems OK to me to simply ignore it, though. > def g(x): > if 0: > global x > > Should this get a SyntaxError about an argument being declared global? IMO yes; especially, considering that the global statment is recognized in e.g. def g(x): if (): global x Bernhard -- Intevation GmbH http://intevation.de/ Sketch http://sketch.sourceforge.net/ MapIt! http://mapit.de/ From gardner at cardomain.com Fri Jun 8 13:42:00 2001 From: gardner at cardomain.com (Jonathan Gardner) Date: Fri, 8 Jun 2001 10:42:00 -0700 Subject: Python Shareware? References: Message-ID: <9fr2jm$16v$1@brokaw.wa.com> Jian Chen wrote: > I am considering writing some shareware in python. I got some > questions about it: > 3. How can I lock/secure my python shareware? Okay, here's my opinion on shareware: Don't do it, it's too much hassle. If you are interested in making software, you should be interested in making it good. So you GPL the code, allow everyone to use it, and modify it, and thus the software will become good/the best/whatever. If you are interested in making _money_, you have to have a product or a service to sell. Software is not a good product, but *support* for the software is a tangible service that you can charge really good fees for. After all, you are the one who wrote it, so the people who use it will naturally turn to you for support. If you target the software for large organizations, you can charge quite a bit of money to give them insurance and service. Let me address why software is not a good product: 1) It is too easy to copy. There is no cost to reproducing it. Compare that to a book, a computer, or a chair. 2) You are not the smartest guy on the planet, so any method you think of in trying to make it difficult to reproduce is not going to work. (Even the smartest guy on the planet doesn't stand a chance to hundreds and thousands of crackers.) 3) And when someone DOES illegally copy the software, how are you going to force them to pay? 4) If your software isn't really that useful or good, someone else is going to make something better, and leave your product in the dust. Or you will be forced to constantly upgrade it rather than take a vacation. You have better hope of collecting money by saying, "This software is free. If you like it, and want more of it, give me money." and let the people who use it work on it. There is anexception to this rule: If you have mega-bucks behind you to actually form a company complete with legal department, and if you can recruit enough talent to make your software better than anything free out there, then you have a chance of making software that you can sell, becuase you can afford to put it on store shelves and get good advertising for it. And in this case, the people that pay for it will far outnumber the people who won't. There is another benefit to you of free software: If you are really good at programming, you can show off with your GPL'ed code, and use that to get into a company that is willing to pay you to code stuff for them. You can't show off code that is closed-source, like code from, say, your previous job. So, with your GPL'ed code (which has been tested and developed by people who are actually interested in using it, so it will be much better than anything you can write on your own) you can claim a lot of credit for it, and demand $100,000 or more for salary. If they think you are crazy, tell them to read the code and try the software. If they want to produce software like that, then they have to hire you. I think a steady income of $100,000 or more a year will benefit more than the meager sales of a shareware piece of software. Plus, you get the comfort of knowing your check shows up every month, and it's the same amount each time. Again, that is just my opinion. I have no experience with trying to make money from shareware software, I have just observation on my side. I hope this starts an interesting thread. From gmuller at worldonline.nl Mon Jun 18 14:58:57 2001 From: gmuller at worldonline.nl (Gerrit Muller) Date: Mon, 18 Jun 2001 20:58:57 +0200 Subject: Teaching Pyhton on Wintel References: <1ev6xe3.15eskd91k2u1eaN%p.agapow@ic.ac.uk> Message-ID: <9glj3e$shg$1@nereid.worldonline.nl> "Paul-Michael Agapow" schreef in bericht news:1ev6xe3.15eskd91k2u1eaN%p.agapow at ic.ac.uk... > > Call me misguided, but I've decided to teach an introduction to > programming class using Python. The audience are the scientists in my > (evolution/ecology research centred biology) department and we'll be > using the local computer lab, which is kitted out out with a network of > modestly powered Wintel machines. So: > > 1. Any advice on which IDE etc. of Win Python to use? > 2. Anyone done a similar class, like to advise on approaches or books to > base it off? > Sounds very well guided! ad 1) IDE is a matter of taste, IDLE is rather straightforward and provides all needed functionality for this audience. ad 2) I liked the Learning Python book by Mark Lutz and David Ascher, see: http://www.amazon.com/exec/obidos/ASIN/1565924649/qid%3D992890522/104-696544 5-4165559 Success Gerrit From qrczak at knm.org.pl Tue Jun 19 15:42:46 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 19 Jun 2001 19:42:46 GMT Subject: PEP 255: Simple Generators References: <9glhg7$dlk$1@nntp6.u.washington.edu> Message-ID: Mon, 18 Jun 2001 11:32:31 -0700, Russell E. Owen pisze: > * A generator looks like a function until you find the "yield" statement > inside. I think this will make the code much harder to read. One keyword > buried anywhere in a function totally changes its behavior. I agree that it's strange, but I prefer the PEP's syntax to any of the alternatives that were proposed. Because each proposal introduced a new pseudo-keyword or new syntax instead of reusing existing syntax in some intuitive way. An intuitive syntax could for example mirror the usage syntax in the definition syntax, such that it could be treated as an equation in some analogical way to a normal definition. Unfortunately I found absolutely no way to sensibly put 'for' in a generator definition header. An example of such intuitive syntax is this: def self.f(arg): pass The only problem is that they are two equally intuitive interpretations :-) It can mean either def f(self, arg): pass # In a class where o.f(a) will be transformed back into f(o, a) or self.f = lambda arg: None i.e. it's not clear whether "self" is *used* or *defined* here. Oops. Another example of such intuitive syntax is declaration of C pointers and arrays... Well, I think it's horrible compared to alternatives (e.g. Pascal), so perhaps my rule about advantages of a definition header mirroring the usage is not that generally applicable... It does apply to function and value definitions in most functional languages however - finally a case where it works: f x y = (x+y)*(x-y) -- Implies that 'f 3 4' means '(3+4)*(3-4)' (x, y) = (3, 4) -- Implies that 'y' means '4' z = [0] -- This is a special case of either of the above (function with no -- arguments or a pattern consisting of a variable), but both ways -- give the same result, so it doesn't matter (almost). > 1) Have users explicitly say "raise StopIter" when they mean it. I would strongly oppose it for a simple reason: the fact that stopping is implemented by raising StopIter is not necessarily visible when a generator is used - because it's usually used by a 'for' loop - so it should not be obligatorily visible when a generator is defined. I.e. one can happily define and use generators without mentioning StopIter at all. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From pmoscatt at bigpond.net.au Thu Jun 21 07:23:07 2001 From: pmoscatt at bigpond.net.au (Peter Moscatt) Date: Thu, 21 Jun 2001 11:23:07 GMT Subject: Calling TIX in PYTHON ? Message-ID: Ok.... I have finally got used to using Tkinter widgets within Python. Now I want to use a couple of Tix widgets, namely the tixDirList. I have used the "import Tix" command but unsure how I actually write the code to actually show the Directory list. Can anyone help me out here ? Pete From schorsch at schorsch.com Fri Jun 8 07:24:01 2001 From: schorsch at schorsch.com (Georg Mischler) Date: Fri, 8 Jun 2001 13:24:01 +0200 Subject: Numeric Programming for Everybody References: <9fo98s$bui$03$1@news.t-online.com> <9fp4re$2sgt$2@agate.berkeley.edu> Message-ID: <9fqcmv$u7$01$1@news.t-online.com> Edward Jason Riedy wrote: > And Georg Mischler writes: > - > - I just noticed the following on an invoice I have to pay: > [...] > - Obviously, some programmer decided on granting me a rebate > - of one german Pfennig. > > Um, was there another column in Euros? If so, you may have > seen an oddity of exchange rates. See paper #22 at > http://europa.eu.int/euro/html/rubrique-defaut5.html?rubrique=133&lang=5 No, there was no other column. Just the end results were listed in both currencies at the bottom of the page. But it's good that you're asking this, as it apparently is the first invoice I get where the the euro is used as "standard" currency. I'll have to go and pay the difference in DEM now, as I didn't notice that at first... ;-) But of course you're right, they probably still calculate in DEM internally, which would explain the funny numbers. -schorsch -- Georg Mischler -- simulations developer -- schorsch at schorsch.com +schorsch.com+ -- Lighting Design Tools -- http://www.schorsch.com/ From rjroy at takingcontrol.com Mon Jun 4 20:59:52 2001 From: rjroy at takingcontrol.com (Robert Roy) Date: Tue, 05 Jun 2001 00:59:52 GMT Subject: can't get tkinter to work with 2.1 / Solaris References: Message-ID: <3b1c2e9b.913942078@news1.on.sympatico.ca> On Mon, 04 Jun 2001 18:41:38 -0000, klassa at cisco.com (John Klassa) wrote: > >Try as I might, I can't make tkinter happy. I'm doing: > > make distclean > ./configure --prefix=/users/klassa/local --enable-gcc \ > --libdir=/users/klassa/local/lib \ > --includedir=/users/klassa/local/include > make > make install > make install libinstall > >I just downloaded Tcl 8.3 and installed it into the /users/klassa/local >tree. It's there. :-) To wit: > I had to build on Solaris with files in non-standard locations as well. As you have seen Tkinter is normally built by setup.py. You can however override this by uncommenting the appropriate entries in Modules/Setup (just like building older python versions). I found it easer to link Tkinter stuff statically so I built tcl and tk with --disable-shared (?). This is also a useful trick when you are not sure which versions of other libraries are on the host system or you have some that give you "relocatable code" errors on build. For instance I wanted to use readline 4.2, and the latest version of gdbm so I built the static libraries and included them via Setup. Bob. > % cd /users/klassa/local/lib > % ls -alF libt* >-r-xr-xr-x 1 klassa eng 707476 Aug 31 1999 libtcl8.2.so* >-r-xr-xr-x 1 klassa eng 709428 Jun 4 12:35 libtcl8.3.so* >-rw-r--r-- 1 klassa eng 2012 Aug 31 1999 libtclstub8.2.a >-rw-r--r-- 1 klassa eng 2012 Jun 4 12:35 libtclstub8.3.a >-r-xr-xr-x 1 klassa eng 906684 Aug 31 1999 libtk8.2.so* >-r-xr-xr-x 1 klassa eng 991204 Jun 4 12:38 libtk8.3.so* >-rw-r--r-- 1 klassa eng 1862 Aug 31 1999 libtkstub8.2.a >-rw-r--r-- 1 klassa eng 3706 Jun 4 12:38 libtkstub8.3.a >-rw-r--r-- 1 klassa eng 478674 Mar 29 2000 libtransfig.a > >The .h files are in /users/klassa/local/include, as expected. > >My LD_LIBRARY_PATH includes /users/klassa/local/lib, but does *not* >include /usr/local/lib. When I build python, it seems happy. When I >install it and run it, then try to "import _tkinter" (per >http://www.python.org/topics/tkinter/trouble.html#checking), I get: > > % python >Python 2.1 (#1, Jun 4 2001, 13:45:22) >[GCC 2.9-cisco-98r1] on sunos5 >Type "copyright", "credits" or "license" for more information. >>>> import _tkinter >Traceback (most recent call last): > File "", line 1, in ? >ImportError: ld.so.1: python: fatal: libtcl8.0.so: open failed: >No such file or directory >>>> > >Note that /users/klassa/local/lib does *not* include libtcl8.0.so, which >is undoubtedly the source of the problem. Yet, I can't figure out how to >make python look for libtcl8.3.so. If I change my LD_LIBRARY_PATH to >include a directory that has libtcl8.0.so, it works. I don't want 8.0, >however. :-) > >I don't see anywhere that I'm explicitly telling the build process to look >in /usr/local/lib (which is where it's getting the 8.0 version), yet it >appears to want to go there anyway. I went so far as to edit setup.py, to >remove the references to /usr/local (which it inserts, regardless -- as >borne out by the comments). Didn't help. > >I'm grasping at straws now... Pointers to useful docs appreciated. I >think I've read all the relevant once (I read through the tkinter >installation and trouble-shooting pages, and grepped the source tree for >other useful tidbits). > >Ideas? > >Thanks, >John > >-- >John Klassa / Cisco Systems, Inc. / RTP, NC / USA / klassa at cisco.com / <>< > [ Save bits! Don't quote entire threads in your reply. ] From isis at wanadoo.be Tue Jun 26 06:17:43 2001 From: isis at wanadoo.be (Johan Daine) Date: Tue, 26 Jun 2001 12:17:43 +0200 Subject: Ascii characters Message-ID: <3B386147.79E68C69@wanadoo.be> Hi, I am using using swish++ with Zope in a french context. In orger to filter the user requests, I need to filter accented characters to the unaccented char. For instance: ? ---> e ? ---> o Does anyone knows if there is a standard module that could help me to accomplish this task insted of hardcoding a maybe buggy translation table ? Thanks Johan Daine From donn at u.washington.edu Thu Jun 21 18:23:32 2001 From: donn at u.washington.edu (Donn Cave) Date: 21 Jun 2001 22:23:32 GMT Subject: namespace issue? References: <87k825ljrz.fsf@elbereth.ccraig.org> Message-ID: <9gts54$bv0$1@nntp6.u.washington.edu> Quoth Michael Powe : ... | So now the question is, 'why'? Am I misusing the string.find() | function? Okay, string.find() returns -1 when the string is not found, | which would seem to be what I expected, a false result. Maybe python | doesn't treat -1 as false? Well, I'll try being explicit and testing | for -1 return. I probably have just confused myself hopelessly. | | Thanks for the ... clue. I saw a great line in an email today -- "Is | that the clue phone ringing? I think it's for you." And I think I'll | go answer it. You heard the phone ring, picked it up, and heard "Maybe python doesn't treat -1 as false?" It might be worth your trouble to check that out. There are a number of different values that test false in Python, and though different they tend to have something in common. -1 doesn't fit the pattern. Donn Cave, donn at u.washington.edu From NoSpam at NoSpam.com Mon Jun 18 16:43:46 2001 From: NoSpam at NoSpam.com (Thomas) Date: Mon, 18 Jun 2001 20:43:46 GMT Subject: Using the Python license References: <3dsngxeq3o.fsf@ute.cnri.reston.va.us> Message-ID: <6KtX6.276155$eK2.57079948@news4.rdc1.on.home.com> "Andrew Kuchling" wrote in message news:3dsngxeq3o.fsf at ute.cnri.reston.va.us... > "Thomas" writes: > > And, does anyone have a link to some comparative information about the > > different licenses? I'm interested in the main 'anything goes' licenses: > > Python, BSD, and the LGPL. > > The differences between the Python and BSD/X11 licenses stem from > CNRI's legal counsel not believing that the BSD license is actually > valid, for various incomprehensible and/or unconvincing reasons. This > is why the Python 2.0 license is a page long and the BSD license is > three paragraphs. You can use the Python license if you like, but why > not just use the X11 license? (The X11 license was also the Python > 1.5.2 license) > > --amk Because I think that Python users will feel more comfortable with the Python license. If they see 'X11 license' they won't know quite what it is, whereas they are probably familiar with the idea of the Python license. For now, I've taken the 'top' portion of the Python license (the current part, excluding CNRI, BeOpen, and CWI), and I've replaced PSF with my name and python with the name of my project. I assume that it would then be reasonable to identify this license on my web site as 'the Python license'. Tom. From vinyard at jpl.nasa.gov Mon Jun 4 14:55:41 2001 From: vinyard at jpl.nasa.gov (Edward S. Vinyard) Date: Mon, 4 Jun 2001 11:55:41 -0700 Subject: makepasswd In-Reply-To: <3B1B838B.BC9FD4CC@oek.dk> References: <3B1B838B.BC9FD4CC@oek.dk> Message-ID: On Mon, 4 Jun 2001, Peter I. Hansen wrote: > Hi, > > Is there a python funtion to generate passwords ? (Like the perl > makepasswd) > > /Peter I use the following script to do the job. It might be a good place to start. (If you discover a better way, or make improvements, I'd like to hear about it/them.) Cheers, Ed Vinyard --- choose_password.py --- #!/usr/bin/env python default_length = 6 help_message = __doc__ = """ choose_password.py Author: Edward S. Vinyard (Edward.S.Vinyard at jpl.nasa.gov) Choose a good random password containing uppercase letters, lowercase letters, numbers, and punctuation. Other composition can be acheived with the '-from' argument. usage: choose_password.py [-from [l][u][d][p]] [password-length] -from specifies the characters that will be used; must be followed by one or more of the following modifiers. If unspecified, the program will assume '-from lupd'. l lower case letters (a-z) u upper case letters (A-Z) d digits (0-9) p punctuation (!@#$%...) password-length is a positive integer. Example: "choose_password.py -from dp 8" would generate a password 8 characters in length composed of only digit and punctuation characters. """ import sys ## PORTABILITY: This section will bind the names we need to run, based ## on their availability in the run environment. if 'executable' in dir(sys): # KLUDGE: JPython/CPython detection from whrandom import random # in [0.0, 1.0) from string import lowercase, uppercase, digits, punctuation else: import java.lang.Math random = java.lang.Math.random # in [0.0, 1.0) lowercase = "abcdefghijklmnopqrstuvwxyz" uppercase = "ABCDEFGHIJKLMNOPQSTUVWXYZ" digits = "0123456789" punctuation = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~' ##---------------------------------------------------------------------- def choose_character(): """choose_character() -> character Choose a password string character from uppercase letters, lowercase letters, digits, and punctuation.""" ## PORTABILITY: This could be written more elegantly using ## whrandom.choice(), but for portability to jpython, this method ## is better. index = int(random() * len(password_chars)) return password_chars[index] ##---------------------------------------------------------------------- def choose_password(length): """choose_password(length=6) -> string Choose a password containing 'length' characters.""" password = "" for x in range(length): password = password + choose_character() return password ##---------------------------------------------------------------------- def parse_char_spec(char_spec): """parse_char_spec(char_spec) -> string Parse the argument to the '-from' command line argument.""" password_chars = "" for c in char_spec: try: password_chars = password_chars + {'l' : lowercase, 'u' : uppercase, 'd' : digits, 'p' : punctuation}[c] except KeyError: print "ERROR: Unrecognized character specification '%s'" % c if password_chars == '': print "ERROR: Empty character specification. Assuming 'ludp'." return parse_char_spec("ludp") else: return password_chars ##---------------------------------------------------------------------- def parse_args(args): """parse_args(arguments) -> (length, password_chars) Parse the command line arguments.""" if '-help' in args: print help_message sys.exit(0) if '-from' in args: # Determine password characters only_index = args.index('-from') char_spec = args[only_index + 1] args.remove('-from') args.remove(char_spec) password_chars = parse_char_spec(char_spec) else: print ("WARNING: Password composition unspecified. " + "Assuming '-from ludp' argument.") password_chars = lowercase + uppercase + digits + punctuation if len(args) < 2: # Determine password length print ("WARNING: Password length unspecified. " + "Assuming password of length 6.") length = default_length elif int(args[1]) < 1: print ("ERROR: Password length must be a positive integer. " + "Assuming password of length 6.") length = default_length else: length = int(args[1]) return (length, password_chars) ##---------------------------------------------------------------------- if __name__ == "__main__": (length, password_chars) = parse_args(sys.argv) length = int(sys.argv[1]) print ("Generating %d character password from\n%s\n..." % (length, password_chars)) print "Password %s is 1 in %d^%d" % (choose_password(length), len(password_chars), length) From tim at digicool.com Wed Jun 20 14:31:14 2001 From: tim at digicool.com (Tim Peters) Date: Wed, 20 Jun 2001 14:31:14 -0400 Subject: PEP 255: Simple Generators In-Reply-To: <24q1jt8qrbrfrguub5hofsfno0l26qredt@4ax.com> Message-ID: [Ben Wolfson] > Wouldn't it be just as useful, or possibly more, if the generators > allowed brain explosion for those who wanted it, but could still be > used simply by those who didn't? Is it necessarily the case that > adding the capability for more complex use removes the possibility > of ordinary use? This is too fuzzy for me to address. If you have a specific idea in mind, please spell it out: the answer depends on what "adding the capability for more complex use" means, exactly. Since generators produce an iterator object, you can very easily tie your head into knots already, if you're determined to. From pknews at kirks.net Wed Jun 27 08:01:03 2001 From: pknews at kirks.net (Patrick Kirk) Date: Wed, 27 Jun 2001 13:01:03 +0100 Subject: wxPython to create a database front end Message-ID: <9hchtv$j9i$1@news6.svr.pol.co.uk> I want to create a database front-end set of forms. If I use the built in functionality of MSAccess, I can create forms with all the programmable buttons, then look at the properties of each button and finally write VBA that does what I want. Is this point and click type GUI creation possible with wxPython? I have Visual C++ but want the application to be portable. Is there a web tutorial on how to do this? Thanks in advance. -- -- Patrick Kirk GSM: +44 7712 184 480 ICQ: 42219699 Wise Chinese Proverb: "If tired of computer winning at real time strategy games, try it at kick-boxing instead" From jkraska1 at san.rr.com Sat Jun 16 03:25:59 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 16 Jun 2001 07:25:59 GMT Subject: pair programming, vim? References: Message-ID: >Did anyone try pair programming over the net? In particular, is it possible >to set up vim with a shared buffer or, failing that, some other editor? I believe that this isn't possible, although I could be mistaken. If you *do* happen to find a multi-user text editor (multiple cursors, perhaps) on windows, please let me know. This would be useful to have around. Although network latencies can lead to some... ah, wierd... outcomes, yes. The company I work for years ago had a product like this for Unix. It was called "Slate". C// From gustafl at algonet.se Fri Jun 1 15:13:20 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 1 Jun 2001 19:13:20 GMT Subject: Verify URL before using urlparse module? Message-ID: I'm a happy user of the urlparse module. Only problem so far is that strange things happen when I send non-URL strings, like "thisisnotaurl" to it. I guess I need some error handling to test if the URL is a URL before sending it to urlparse. Best of course, would be if urlparse could do this by itself, but I'm not sure if or how that's working. Regards, Gustaf Liljegren From johnroth at ameritech.net Thu Jun 21 16:55:30 2001 From: johnroth at ameritech.net (John Roth) Date: Thu, 21 Jun 2001 13:55:30 -0700 Subject: Two minor syntactic proposals References: <16074dce.0106181057.528dfea@posting.google.com> <3b30ee5e.1008026215@wa.news.verio.net> Message-ID: "phil hunt" wrote in message news:slrn9j275n.9oi.philh at comuno.freeserve.co.uk... > On Wed, 20 Jun 2001 18:44:16 GMT, Bengt Richter wrote: > >On 18 Jun 2001 11:57:59 -0700, jeff at ccvcorp.com (Jeff Shannon) wrote: > > > >>philh at comuno.freeserve.co.uk (phil hunt) wrote in message news:... > >>> > >>> I propose a different way of doing this: make 'self' implied in all > >>> references to instance variables. This involves definiing 2 new keywords, > >>> qclass and insvars. So: > >I think I prefer just an easier way to type "self." > >How about just the dot? I.e., ".x" means "self.x" > > That sounds a good idea. I like it! I don't think it will break anything. However, since you wouldn't have to type "self." any more, then the "self" parameter itself becomes meaningless, and can be eliminated. This also solves the "class method" issue. If it doesn't contain a prefixed dot, then it doesn't require an instance, so it's clearly a class method. It'll never fly. Think of all that code out there that would break if we took away that first parameter... And then, there's the point that keeps getting pounded to death in the PEP255 discussion - it's bad news to distinguish two different animals by some detail of their internals. > >>I much prefer having all member variables and member functions explicitly > >>qualified. Having moved to Python from C++, where members can be referred > >>to implicitly, it seems to me that the explicit requirement of Python makes > >>code *much* easier to read--no more hunting about to try to figure out whether > >>a given variable is a class member, or a parameter, or a global, or from some > >>other scope... then there's also this problem (using your notation): > >[...more reasons...] > > > >So what about a plain prefixed '.' as an abbreviation for 'self.' ? > > i wish i'd thought of it > > -- > ## Philip Hunt ## > ## philh at comuno.freeserve.co.uk ## > > > From raskol at hushmail.com Wed Jun 13 11:56:45 2001 From: raskol at hushmail.com (raskol) Date: Wed, 13 Jun 2001 11:56:45 -0400 Subject: UML from Python? References: <3b27769a.16649510@news.btinternet.com> Message-ID: <3b27889a_4@newsfeeds> "Danny Ayers" wrote in message news:3b27769a.16649510 at news.btinternet.com... > I was wondering whether there were any tools around for generating UML > or similar diagrams from Python source. Look at http://www.objectdomain.com they have a UML modeler (written in Java) that also spits out UML from python source. works for me.... raskol -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From sholden at holdenweb.com Thu Jun 14 07:46:05 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 14 Jun 2001 07:46:05 -0400 Subject: HREF to same server, different port References: <4vZV6.166230$p33.3509665@news1.sttls1.wa.home.com> Message-ID: I was afraid someone would say that. Dammit, this is supposed to be pure HTML, so I was hoping to rely only on browser behavior. Thanks for the information, anyway. Javascript here I come... regards Steve -- http://www.holdenweb.com/ "Greg Jorgensen" wrote in message news:4vZV6.166230$p33.3509665 at news1.sttls1.wa.home.com... > Relative HTTP URLs are relative to the host header portion of the URL, so a > relative URL can't specify a different scheme, host, or port. You'll have to > take the URL apart, change the port number (or add it), and use the > resulting absolute URL. > > > -- > Greg Jorgensen > PDXperts LLC > Portland, Oregon, USA > gregj at pobox.com > > > > "Steve Holden" wrote in message > news:OWi6PtJ9AHA.281 at cpmsnbbsa07... > > Sorry this is off-topic, but I'm trying to create a relative url to a > > different port on the same server (inheriting the server name or address > > from the current URL). I've tried //:8081/ and :8081/ and neither works. > > > > ANyone tell me how? > > > > regards > > Steve > > -- > > > > http://www.holdenweb.com/ > > > > From loewis at informatik.hu-berlin.de Sat Jun 16 14:31:10 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 16 Jun 2001 20:31:10 +0200 Subject: Solaris 8/x86: Build problems References: <3b2a7fc2.5552674@news.laplaza.org> Message-ID: xyzmats at laplaza.org (Mats Wichmann) writes: > The configure and build of the Python binary itself was completely > clean, but as soon as the modules and distutils come into play, it > blows up completely. I built Python 2.0 some months ago and didn't > see this, but at that point distutils weren't involved, right? Right. > I'm suspecting the autoconfigure somehow is not giving the right > magic incantation to distutils. It looks that way. With the details you gave, and without access to Solaris x86, it is hard to tell what the problem is. Seeing the line that was used to build structmodule.o from structmodule.c would help enormously. My guess is that the -fPIC option is missing in that compile step. Regards, Martin From rnd at onego.ru Fri Jun 29 00:14:43 2001 From: rnd at onego.ru (Roman Suzi) Date: Fri, 29 Jun 2001 08:14:43 +0400 (MSD) Subject: PEP scepticism In-Reply-To: <20010628122608.A2556@isomedia.com> Message-ID: On Thu, 28 Jun 2001 stevencooper at isomedia.com wrote: >---end quoted text--- > >FWIW - I totally agree with the original premise. If Python already >offers a reasonable way to do something I would vote for not adding an >alternative. > >Keystroke reduction saves the original programmer time. But it costs >other people more time when they read the code. The more language >idioms that exist to support a particular need the more chance the >code reader will have to work harder to understand the code writer. No. It is easier to read one small list comprehension than to catch and re-check if the for-loop pattern is unserstood right. Also list comprehension works faster. The same for aug=. Generators are necessary to drop memory usage while leaving existing usage of functions the same. And I think after generator's introduction, in things like: for line in file.readlines(): ... people will _expect_ generators to be used and will look at the source to check it. So, I can't see how all these advanced features could harm anybody's ability to read code! Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Friday, June 29, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "I failed attitude in school." _/ From donn at drizzle.com Fri Jun 8 00:48:16 2001 From: donn at drizzle.com (Donn Cave) Date: Fri, 08 Jun 2001 04:48:16 -0000 Subject: Mutable class attributes are shared among all instances, is it normal ? References: <27vvht4uslv2ibq2q8ee4tovg86e7qempb@4ax.com> <3B201662.6DB35744@home.net> Message-ID: <991975696.169576@yabetcha.drizzle.com> Quoth Chris Barker : | Alain TESIO wrote: |> |> Hi, sometimes class attributes added just after |> "class ...:" outside a functions interfere among |> instances, more precisely mutable objects are |> linked to the same object as if it were a static |> attribute. |> |> See the test case below. |> |> If I delete the line "val=[None]" in class |> Y and add "self.val=[None]" in its __init__ |> it works as class X. |> |> Is it a bug or did I miss something ? [... snipping some explanation ...] | Now, the reason you have your confusion is that since everything in | Python is a reference, the distiction that matters is whether it is | mutable or not. A mutable object (a list) can be changed in place. An | immutable object can not. If you assign a new value to a name that | references an object, the name then gets assigned to your new object, | and the old one is de-refereced (it will be garbage collected if there | is nothing else pointing to it. Whe you alter a mutable object, however | (list[index] = something) you have not changed the reference, but you | have changed the object it is pointing to. I have no argument with the facts here, but I have to disagree about the reason for the confusion. It should be clear from this that the distinction between mutable and immutable objects here is actually completely irrelevant, and when we introduce this red herring into the picture we make a simple matter much harder to understand. (It's so often repeated here, yet makes no sense to me. I don't wish to pick on this post, the author went went to considerable trouble to help out and I'm just off on a rant about this detail, because the subject has the word "mutable".) When I write "self.x = a", it does not matter in any way whether self.x is mutable. It is purely irrelevant. To understand why "self.x = a", we really have to understand the Python object/reference/namespace model, which again has nothing to do with mutability. If you understand what "self.x = a" means in that model ("make name 'x' in namespace 'self' refer to the same object as name 'a' in the default namespace[s], possibly hiding another name in a posterior namespace" ... uh, there has to be a better way to say that!) then you will not be confused. If you understand it different (i.e., wrong) you will be confused all the time. Now I think what people mean to point out here, is that given the realities of life with Python, one may choose to substitute "self.x = a" with some expression that modifies a mutable object, like "self.x[0] = a". That's fine, but of course the point is not that self.x is mutable, the point is that you are modifying it. Donn Cave, donn at drizzle.com From tim.one at home.com Tue Jun 19 19:21:59 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 19 Jun 2001 19:21:59 -0400 Subject: Packing a long long type In-Reply-To: <5c8ecb0b.0106191444.53054b47@posting.google.com> Message-ID: [Rich J] > Does anyone know how it would be possible to pack a list containing > 'long long' types (like 111111111111111L) and other standard types > (int, string, char). I don't know what you mean by "pack". The std pickle/cPickle modules have no trouble with these, though. Note that 111111111111111L is an instance of Python's unbounded int type. > I know you can use the struct module to pack all but the 'long long'. Note that struct in 2.2 has new 'q' and 'Q' format codes, for the C compiler's notion of signed and unsigned "long long" (__int64 under Windows) in native modes, and x-platform 8-byte ints in standard modes. From mitch.chapman at bioreason.com Mon Jun 18 12:05:43 2001 From: mitch.chapman at bioreason.com (Mitch Chapman) Date: Mon, 18 Jun 2001 10:05:43 -0600 Subject: Any other Python flaws? References: Message-ID: <3B2E26D7.DA3BD20D@bioreason.com> Oleg Broytmann wrote: > > On Sat, 16 Jun 2001, Mitch Chapman wrote: > > > while not self._cancel: > > > do_more_computation() > > > > Yep, this is a common approach. See Xt work procedures, > > Gtk+ idle tasks, or even guides to programming in Oberon. > > Unfortunately, this method doesn't work very well when your > > background thread needs to do blocking operations, e.g. reading > > from a socket. > > But you cannot safely interrupt such a blocking thread because: > > 1. It is VERY OS-dependent, and The fact that the implementation is OS-dependent does not imply that you cannot do it safely. Can you say more about the differences in semantics among the operating systems for which Python supports threads? > 2. Even on an OS that allows killing blocked threads you are guaranteed to > have problems due to insufficient cleanup. If you need to kill blocking > process make it real forked process. Or use non-blocking approach > (non-blocking sockets, e.g.) All of this tends to reinforce Andrew Kuchling's opinion that threads were "a mistake". I'm still unsure whether he meant threads in general were a mistake or whether he meant that platform-independent threads facilities should be augmented with platform-specific facilities. -- Mitch Chapman Mitch.Chapman at bioreason.com From ullrich at math.okstate.edu Mon Jun 25 10:16:30 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 25 Jun 2001 14:16:30 GMT Subject: Is this a true statement? References: Message-ID: <3b3745bd.2217895@nntp.sprynet.com> On Mon, 25 Jun 2001 00:42:27 GMT, grante at visi.com (Grant Edwards) wrote: >On Sat, 23 Jun 2001 14:38:24 -0400 (EDT), Steven D. Majewski wrote: > >>> > Writing TO a device driver is easy enough... the previous poster >>> > was talking about writing the DRIVER in Python. No OS I'm aware >>> > of takes device drivers in any languages other than assembler, C, >>> > and/or C++. >>> >>> He's making a very finicky, nitpicking, and frankly silly point [...] >> >>I don't think the point was entirely silly! >>It was a valid and interesting point (despite being finicky and >>nitpicking!) > >Yes, it's trivially and obviously valid: a driver is a bit >pattern, and you can write a bit pattern to a file with Python. > >If you show an example of how this is a useful and productive >way to generate a device driver, _then_ it will be interesting. >Until then, it's just somebody chattering to hear themselves >talk. That's a truly remarkable attitude. Nothing is worth knowing unless it solves a practical problem right now. I actually learned something about device drivers from all this. Not from something that anyone actually said - I learned something about device drivers by assuming that people _must_ be making much more sense than they _appeared_ to be making, and trying to figure out what I could be misconceiving that would make all those comments that must actually be sensible appear like nonsense to me. "Chattering to hear themselves talk" indeed. There were questions I kept asking. Questions which nobody answered yesterday, even though I kept pointing out that nobody had answered them - people seemed unable to believe that they were actual questions or something. Figured out the answers for myself last night, then this morning the first thing I said was "no, of course in that sense you cannot write device drvers in Python". Certainly do appreciate your assistance here. "chattering to hear themselves talk"... >Grant Edwards grante Yow! YOW!!! I am having > at fun!!! > visi.com David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From sophiec at scripps.edu Tue Jun 12 12:30:33 2001 From: sophiec at scripps.edu (Sophie Coon) Date: Tue, 12 Jun 2001 09:30:33 -0700 Subject: Garbage collection questions References: <9fm8ti$d92$1@newshost.accu.uu.nl> <503ca784.0106112030.3d434e08@posting.google.com> Message-ID: <3B2643A9.B5C79E96@scripps.edu> Hi, I have problems to understand how the garbage collector works. If I understood well the documentation a collectable objects is an unreachable objects that will be garbage collected. So if I do a gc.collect() and it returns 280 but the gc.garbage list is empty that means that the memory taken by these 280 objects has been freed ? Thanks for your help. Sophie -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sophie COON The Scripps Research Institute Research Programmer II Molecular Graphics Laboratory 10550 North Torrey Pines Road Phone: (858) 784-9556 La Jolla, CA 92037 Fax : (858) 784-2860 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From rnd at onego.ru Thu Jun 21 03:29:14 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 21 Jun 2001 11:29:14 +0400 (MSD) Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: On Thu, 21 Jun 2001, Glyph Lefkowitz wrote: > My $0.02 on the whole issue: > > Generators a-la PEP 255 seem like a *very* bad idea to me. > > Generators can be implemented through continuations (as shown in > Stackless) or through microthreads (as shown in the various previous > implementations of generators which use *real* threads cooperatively). > > Neither microthreads nor continuations are implementable through > generators. I believe that generators (as described in PEP 255) are a > merely a convenience, but real cooperative multithreading could be very > useful and we would get generators *for free*. > > While I am heavily in support of stackless being integrated for many > reasons, I can understand the unfavorable sentiments that some harbor > towards continuations. They can be nastily abused. They are > confusing. They interact very poorly with operator overloading and > exception handling. > > However, yeild adds a way of altering control flow without providing a > direct mechanism for accessing that alteration; only using one particular > feature of that alteration. One real example -- the reason I'm writing > this reponse -- I have written an asynchronous networking library. > Currently, the API is that the client "protocol" code handles each chunk > of data, maintaining a buffer itself, and then handling an event when a > full message chunk of data is received. Certain protocols would be much > easier to code with a synchronous view of handling data; indeed, this is > the way that most protocol code in Python itself is written. If the > protocol code is executing a read(), however, I want control flow to > return to my main asynchronous control loop while that code is > blocked. There are, unfortunately, many places executing read() and only > one execution path which knows which one it wishes to yield *to*. > > I believe that this is a fairly common application. > > The motivation for implementing PEP 255 is exactly this -- a situation > where execution should proceed asynchronously but the application should > be written synchronously for clarity. The general solution to this > problem is cooperative multithreading. > > Benefits to this approach would be: > > * one-to-many relationships (as described above) are handled as well as > many-to-one. > * more pythonic: implement a general approach in the core and build upon > it rather than a specific approach in the core. > > Disadvantages to the PEP 255 approach: > > * we'll probably want microthreads eventually; this feature will bloat > the language unnecessarily then. > * less pythonic: once we've implemented generators this way, what about > simulation loops? Do we need syntax support for those too? > > The one advantage to the PEP 255 way of doing things is that it looks like > it might be slightly easier to implement. However, C. Tismer has already > shown it's not insurmountable to implement microthreads in Python, and > perhaps some, if not all, of his work could be stolen ;-). This is almost exactly what I was trying to tell c.l.p for two days. Let's call it microthreads, but it is correctly put! Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From alan.gauld at bt.com Mon Jun 4 13:40:17 2001 From: alan.gauld at bt.com (Alan Gauld) Date: Mon, 04 Jun 2001 18:40:17 +0100 Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> <3B1BBF37.F7FC6F3F@damaru.com> Message-ID: <3B1BC801.D50848C1@bt.com> Michael Davis wrote: > Personally, I find UML most useful as a diagramming language used to > play with design ideas, or document an existing class framework Yes those are good points. Even in a programming context drawing UML diagrams on a whirteboiard is a lot less ambiguous than using a homegrown vague bunch of circles etc. At least everyoine jnows which direction inheritance goes in, what the cardinality of relationships is etc.. > I'm interested in trying other methodologies, such as Extreme > Programming, whilst using UML as a diagramming language. UML is entirely compatible with most methjods - its just a notation after all. Alan G. From sdm7g at Virginia.EDU Tue Jun 5 20:51:46 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Tue, 5 Jun 2001 20:51:46 -0400 (EDT) Subject: Numeric Programming for Everybody (was Re: I had a thought ...) In-Reply-To: <3b1cb719$0$12248$ed9e5944@reading.news.pipex.net> Message-ID: > > How can the language > > accommodate the differing needs of the learner and dilettante on the one > > hand, and the specialists in various kinds of numeric programming on the > > other? On Tue, 5 Jun 2001, Neil Benn wrote: > Or should it? As a programmer interested in interfacing to serial devices > over RS-232, I really don't care about the intricacies of floating point > calculations. If practically 2+2=4, then I'm fine with that. I think in > the majority of real world applications, in a pragmatic sense most people > don't care of the intricacies of number representation as long as it works > (which in 99.9999999% of cases - it does for a fixed, static > implementation). Leave that to the experts, it's not just learners who > don't care about the floating point philosophies. > > For highly specialised programming requirements (e.g. mathematical work, > advanced neural netoworking) then highly specialised tools should be used, > obviously that's a personal opinion not a statement! For everything else, > just get it to work and work reliably. I know of a lot of people who would call interfacing to serial devices over RS-232 "specialised programming" , but who expect to get reliable results from math routines because that's something that they've been led to believe that computers can do perfectly. And, from the naive users point of view, floating point DOESN'T work 99.9999999% of the time ( or even 99% of the time ), and doing things to ensure it works better, like: >>> 1.0 / 5.0 0.20000000000000001 seems to produce more confusion. The best way to cater to both the beginner and the specialist is to leave floating point entirely to the specialist. The problem is that, because computers were originally designed for specialists, they happen to have been designed with fast specialized floating-point hardware, and absolutely no specialized rational arithmetic hardware. -- Steve Majewski From jdries at mail.com Mon Jun 4 13:16:11 2001 From: jdries at mail.com (Jan Dries) Date: Mon, 04 Jun 2001 18:16:11 +0100 Subject: I NEED to TEACH you something, QUICK! References: <3B1BB083.688D723D@zoteca.com> Message-ID: <3B1BC25B.E2B19D64@mail.com> Itamar Shtull-Trauring wrote: > > Rainer Deyke wrote: > > > Did you actually write all that, or was it algorithmically generated? > > Really... can't you recognize a simple Usenet posting on the subject of > "'Usenet discussions about war' as a metaphor for refactoring" when you see > one? > Maybe it's time we refactor the Laurabot so that it can algorithmically generate the same content in one third of the LOUPs (lines of usenet posting). Jan From mcfletch at home.com Fri Jun 22 16:17:16 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Fri, 22 Jun 2001 16:17:16 -0400 Subject: Pythoin MUD (PyMUD?) In-Reply-To: <9h052d$94o$2@brokaw.wa.com> Message-ID: <001001c0fb58$55a47930$a9807018@cr706570a> http://www.stackless.com/ Note, currently only available for 2.0 and 1.5.2. Enjoy, Mike -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Jonathan Gardner Sent: June 22, 2001 15:09 To: python-list at python.org Subject: Re: Pythoin MUD (PyMUD?) ... Stackless Python... with continuations... Could you point me to an introduction to that or some docs? ... From ed_tsang at yahoo.com Tue Jun 19 13:16:27 2001 From: ed_tsang at yahoo.com (ed_tsang at yahoo.com) Date: Tue, 19 Jun 2001 17:16:27 -0000 Subject: How can I format the string according to its length at runtime? Message-ID: <9go1db+mpav@eGroups.com> How can I format the string but according to the length it has? I have the following code: l = 6 - len(str(values)) printwrite(trcfile, "Rx value = %-5s (0x%-6X)- OK\n"%(str(values), values),tag ) Currently I displays: Check : TPreason = 120 (0x78) Rx value = 120 (0x78 )- OK function printwrite is just a wrapper function of sys.file.write and print that prints the info to the screen, or a trace window and to a file accordingly. The string formmating is he same as the python doc. values in the above code is a integer number. The above statement tries to diplay the input string [ from str (values ] and convert values to be displayed as hexadecimal. My problem is when it displayed in hexadecimal, there are extra spacing because it of the statement 0x%-6X when the lengeth of values is 3. But I will no know in advance what is the length of values, it can reach 6. How can I dynmically alter the number of spaces in this case? Thanks From altis at semi-retired.com Wed Jun 20 11:33:53 2001 From: altis at semi-retired.com (Kevin Altis) Date: Wed, 20 Jun 2001 08:33:53 -0700 Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: <3B2EADB0.9DBC6FC8@earthlink.net> <3B2EC98E.FE0F1B6E@earthlink.net> Message-ID: Argh, yes you do need to register, sorry. Well, there aren't that many messages yet. I'm open to suggestions for another place to run a mailing list that doesn't require registration. ka "Michael Hudson" wrote in message news:m3r8wf45md.fsf at atrus.jesus.cam.ac.uk... > "Kevin Altis" writes: > > > Well, I started a separate mailing list. > > http://groups.yahoo.com/group/pythoncard > > Could you rig it so the archives are publically readable? I can't > think of any reason why it shouldn't be (& I've never successfully > logged into YahooGroups's website). > > Cheers, > M. > > -- > Programming languages should be designed not by piling feature on > top of feature, but by removing the weaknesses and restrictions > that make the additional features appear necessary. > -- Revised(5) Report on the Algorithmic Language Scheme From twofingersalute at atl.mediaone.net Sun Jun 24 16:19:11 2001 From: twofingersalute at atl.mediaone.net (myself) Date: Sun, 24 Jun 2001 20:19:11 GMT Subject: newbie Q's Boa Message-ID: <20010624.162247.1597322404.2060@K7.atl.mediaone.net> I hope this isn't OT, but I can't find an answer doing Google/Groups searches or in limited docs- using Mandrake7.2, installed following: Boa-0.0.5.zip wxGTK-2.3.0-1.i386.rpm wxGTK-devel-2.3.0-1.i386.rpm wxGTK-gl-2.3.0-1.i386.rpm wxPython-2.3.0-1-Py21.i386.rpm wxPython-demo-2.3.0.tar.gz wxPython-docs-2.3.0.tar.gz wxPython-gl-2.3.0-1-Py21.i386.rpm Boa seems to load from shell without error, but clicking Boa-specific help button I get: Traceback (most recent call last): File "/usr/local/lib/python2.1/site-packages/Boa-0.0.5/Palette.py", line 231, in O nHelpToolClick Help.showHelp(self, Help.BoaHelpFrame, '', self.toolBar) File "/usr/local/lib/python2.1/site-packages/Boa-0.0.5/Help.py", line 38, in showH elp help = helpClass(parent, toolbar) File "/usr/local/lib/python2.1/site-packages/Boa-0.0.5/Help.py", line 267, in __in it__ 'Help.ico', paletteToolbar) File "/usr/local/lib/python2.1/site-packages/Boa-0.0.5/Help.py", line 72, in __ini t__ self.SetDimensions(120, 75, Preferences.wxDefaultFrameSize.x, AttributeError: 'tuple' object has no attribute 'x' I tried to trace through various Boa and wxPython modules and wxWindows headers, but this is way over my head. Also, and perhaps related, I'm unclear how to set the help paths for Python and wxWindows to work within Boa. Docs say to set paths in PrefsGTK.py in a key:value(path) format, and then run HelpScrpt.py, but I don't know what format the "key" parts should follow in the dictionary, and can't find any examples. I'm scattered on my installations, but here goes: Python2.1 docs in ~/python/docs-21-html/, wxPython docs in ~/python/wxpython-2.3.0/, Python 2.1 in /usr/lib/python2.1/, Boa and wxPython in respective dirs in /usr/local/lib/python2.1/site-packages. wxPython docs apparently include the wxWindows docs. wxWindows is in /usr/include. To the limited extent I've run everything, the executables are in order, i.e. Py2.1 rather than Py1.5.2 loads, the wxPython demo runs ~95% (and looks awesome BTW). I expect a few of the demos to fail, eg the Win specific ones, and I think the only other ones not to run were sound and gl- I'm trying to "fix" both :-). any help appreciated! From nperkins7 at home.com Fri Jun 15 19:10:12 2001 From: nperkins7 at home.com (Nick Perkins) Date: Fri, 15 Jun 2001 23:10:12 GMT Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gb41r0s6p@enews1.newsguy.com> <9gcslc05fc@enews1.newsguy.com> Message-ID: "Alex Martelli" wrote in message > > ... > One (IMHO) Python enhancement would be to give dictionaries > some finer-grained control on their degree of mutability. > The ability to selectively make SOME existing keys non > rebindable and/or non removable _would_ come in handy in > quite a few places ('constants' included), as would the > related ones of locking a dictionary against addition of > new keys. Since ALMOST all Python namespaces are in fact > dictionaries (local-variables of functions being the > signal exception), such locking would give the basic > semantics for several desirable tricks. > ... now, that's an interesting idea. how would that look, syntactically? dict['A']=1 dict.lock('A') ..making the value unchangeable? ..and would attempts to set the value raise an exception? From bkc at Murkworks.com Fri Jun 8 09:38:09 2001 From: bkc at Murkworks.com (Brad Clements) Date: Fri, 8 Jun 2001 09:38:09 -0400 Subject: McMillan Installer 4 error ImportError: No module named posixpath References: <3b1ea684$1_4@127.0.0.1> <3b1f6fbe_2@127.0.0.1> <90B99DAA2gmcmhypernetcom@199.171.54.154> Message-ID: <3b20d47d_6@127.0.0.1> You're right, I tried it again and now it works. Sorry! -- Brad Clements, DevNet Sysop 5 Developer Network Sysop Team "Gordon McMillan" wrote in message news:90B99DAA2gmcmhypernetcom at 199.171.54.154... > [posted and mailed] > > bkc at Murkworks.com (Brad Clements) wrote in <3b1f6fbe_2 at 127.0.0.1>: > > >Thanks, but I did remove posixpath from the excludes in the .cfg file, > >and rebuilt using Builder.py > > > >The Builder.log shows (I think) that posixpath gets included. > > When I follow David's advice (which is exactly what I would've said), I > have no problem (using a simple test script that imports mimetypes and > calls guess_type()). > > If you still have problems, please email me the Builder.log and your .cfg > file. > > - Gordon -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From senux at senux.com.NOSPAM Sat Jun 30 13:35:09 2001 From: senux at senux.com.NOSPAM (Brian Lee) Date: Sun, 01 Jul 2001 02:35:09 +0900 Subject: How to create Python executable References: <3b3d73cd.48834029@news-server.bigpond.net.au> Message-ID: <3B3E0DCD.2030603@senux.com.NOSPAM> Try py2exe and freeze. py2exe homepage is http://py2exe.sourceforge.net/ and freeze is in Python source tarball. I've ever test to build exe file from a Python source with wxPython and some other my own modules and it works pretty well. Visit their homepage for more. - Brian,. sorular wrote: > A simple question I should've learnt long ago! > > How to make an executable from a python program? > > The code is made up from several python scripts and files in a > directory. It requires ActiveState to run but I want to run it on any > machine as an executable (*.exe) that don't necessarily have python. > > thanks > > ~sor From dalke at acm.org Tue Jun 26 17:02:13 2001 From: dalke at acm.org (Andrew Dalke) Date: Tue, 26 Jun 2001 15:02:13 -0600 Subject: Is this a true statement? References: <8NuZ6.362378$oc7.42924874@news2.rdc2.tx.home.com> <3B3788A2.3BD1D672@tundraware.com> <9h89pn$oj5$1@slb2.atl.mindspring.net> <3B38D94E.727A0EEF@tundraware.com> Message-ID: <9hauqu$328$1@slb1.atl.mindspring.net> Tim Daneliuk wrote: >What prevents me from writing out a byte string from Python which is a set >of primitives for accessing the SM hardware and then building up higher >level Python interfaces from these primitives? Nothing. But it wouldn't be Pythonic -- you would no longer be using Python. What's to prevent you from doing something like import c_compile func = c_compile.function(params = ("i", "j"), defaults = {"j": 10}, returns = types.IntegerType, code = """ return i + j; """) >>> func(i = 3) 13 >>> Again, nothing. But few would say this should be considered a Python program. Whereas in C++ using special per-class allocators is very C++-ic. Andrew From phd at phd.fep.ru Thu Jun 21 03:54:25 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Thu, 21 Jun 2001 11:54:25 +0400 (MSD) Subject: rexec works strange... In-Reply-To: <9gq5b00jkl@enews1.newsguy.com> Message-ID: On Wed, 20 Jun 2001, Alex Martelli wrote: > But sys.exit() is really innocuous, little more than a raise SystemExit. > > Just .r_exec() the untrusted code in the try: clause of a try/except > that catches everything, as is HIGHLY advisable anyway:-), i.e. with > a clause of 'except:', and you'll catch SystemExit too. I did this advice in my very first message :) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From boud at rempt.xs4all.nl Sat Jun 23 14:46:14 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 23 Jun 2001 18:46:14 GMT Subject: emacs speedbar for python mode? References: <9h24tq$f7b$1@news1.xs4all.nl> Message-ID: <9h2o5m$8is$1@news1.xs4all.nl> Alex wrote: > When I run speedbar in a python file foo.py, I just get a new frame with > the buffer for foo.py. How are you supposed to use it? If you get that, there's something quite wrong. You should get a listing all (Python) files in the directory where foo.py is - with an icon with a + sign in from of them. Click on the icon, and you get the classes in that file. Doubleclick and XEmacs opens the file for you. I don't know whether GNU Emacs also shows the icon, but the way it works should be the same. (The speedbar _is_ a bit buggy, though, at least in the version I have here. Sometimes it cannot parse some file and doesn't show all classes or all methods. I've also seen those errors with Java files, too.) -- Boudewijn Rempt | http://www.valdyas.org From tim.one at home.com Fri Jun 22 21:42:57 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 22 Jun 2001 21:42:57 -0400 Subject: the indentaion for grouping thing In-Reply-To: <3b33d9d6$1_1@anonymous> Message-ID: [Anonymous] > Someone quoted Guido as saying (I'm paraphrasing) that he > is determined to be ignorant of any discussion regarding the white > space for grouping thing. How sad. How crusty. How typical. He does ignore them *now*, yes. Do you imagine you have an argument he hasn't heard repeatedly in 10+ years of this? I don't, but am willing to be astonished . > Anyway, I will continue to use Python I guess, but I gather that > someone has written a preprocessor that allows you to use delimiters > with python. Is this true? If so, where can I find it, I would > like to use it. Tools/scripts/pindent.py. At the time Guido wrote that, he announced it was his last word on the topic. kept-his-word-too-ly y'rs - tim From philh at comuno.freeserve.co.uk Fri Jun 29 09:26:35 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 29 Jun 2001 14:26:35 +0100 Subject: PEP scepticism References: <9hfg1n$du33c$1@ID-89274.news.dfncis.de> Message-ID: On Thu, 28 Jun 2001 12:26:08 -0700, stevencooper at isomedia.com wrote: > >Keystroke reduction saves the original programmer time. True. > But it costs >other people more time when they read the code. Really? Is this: self.total[player] += s any harder to understand than this: self.total[player] = self.total[player] + s I don't think so. -- ==== Philip Hunt == philh at comuno.freeserve.co.uk ==== Want to stop global warming? Do you support the Kyoto Treaty? Then boycott Esso (ExxonMobil in the USA). See www.stopesso.com for details. From machin_john_888 at hotmail.com Thu Jun 21 00:53:07 2001 From: machin_john_888 at hotmail.com (John Machin) Date: 20 Jun 2001 21:53:07 -0700 Subject: problem running program References: Message-ID: <92ae279c.0106202053.5a84014a@posting.google.com> Timothy Reaves wrote in message news:... > Hello. I have Python 2.1 installed. I can write python scripts and they > run. However, when I try to run glimmer or gnucash, I get errors. For > example, glimmer gives my the following. > > Do I haev python setup incorrectly? > > [treaves at double treaves]$ export PTYHONHOME=/usr/lib/python2.1/ You have tarnsposition errors in 'haev' and 'PTYHONHOME'. Assuming that what you posted was straight from the output, the latter may well be the cause of the problem. My understanding is that in any case PYTHONHOME is *optional* -- on both *x and Windows, Python expects to find all those goodies in the 'lib' sub-directory of the directory where the executable program finds itself; PYTHONHOME would only be necessary if you were (say) testing a variant installation. > [treaves at double treaves]$ glimmer > Loading font from preferences. > Loading font from preferences. > Loading font from preferences. > Loading font from preferences. > Could not find platform independent libraries > Could not find platform dependent libraries > Consider setting $PYTHONHOME to [:] > 'import exceptions' failed; use -v for traceback My understanding is that the exceptions module is built-in in 2.1, and thus this shouldn't happen. If spelling PYTHONHOME correctly doesn't solve your problem, you need to dig into glimmer & gnucash --- presuming they are shell scripts --- and maybe run python with -v as suggested by the error messages. Are you *sure* that glimmer & friends are not running an old python? > Warning! Falling back to string-based exceptions > 'import site' failed; use -v for traceback > Fatal Python error: could not import _gtk > Aborted (core dumped) > [treaves at double treaves]$ From hoel at germanlloyd.org Fri Jun 8 10:16:02 2001 From: hoel at germanlloyd.org (Berthold Höllmann) Date: 08 Jun 2001 16:16:02 +0200 Subject: HappyDoc formatting docstring References: <9fqj2n$bvk$1@bs19.bs.uva.nl> Message-ID: "Flores Bakker" writes: > I have a problem using HappyDoc: example code lines in docstrings are > appended after each other in HappyDoc generated HTML text.for example: > > class Jantje: > ''' > ExampleCode: > > >>> aBankAccount=BankAccount() > >>> aBankAccount.deposit(30) > >>> aBankAccount.withdrawal(10) > >>> aBankAccount.balance==20 > 1 > ''' The documentation describes how the indicate raw text (for code examples). Us two colons as in: class Jantje: ''' ExampleCode:: >>> aBankAccount=BankAccount() >>> aBankAccount.deposit(30) >>> aBankAccount.withdrawal(10) >>> aBankAccount.balance==20 1 ''' Cheers Berthold -- email: hoel at GermanLloyd.org ) tel. : +49 (40) 3 61 49 - 73 74 ( C[_] These opinions might be mine, but never those of my employer. From aahz at panix.com Fri Jun 29 22:04:03 2001 From: aahz at panix.com (Aahz Maruch) Date: 29 Jun 2001 19:04:03 -0700 Subject: [Python-iterators] While we're at it... References: Message-ID: <9hjc2j$8ck$1@panix6.panix.com> In article , Quinn Dunkan wrote: > >Of course, an iterator map would be useful: > >def iter_map(f, seq): > for o in seq: > yield f(o) This is a generator, not just an iterator. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Nothing fails like prayer" --bumper snicker From tim.one at home.com Sat Jun 23 17:27:45 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 23 Jun 2001 17:27:45 -0400 Subject: PEP 255: Simple Generators, Revised Posting In-Reply-To: Message-ID: [Jeremy Hylton] > Actually, they are in the parse tree. Yikes! That's what I get for reading the code instead of typing what I thought was the case . > The compiler ignores "if 0" blocks by explicitly calling > is_constant_false() in com_if_stmt and in the if_stmt case of > symtable_node(). So it's easy enough to examine that part of the tree. > ... > This would be easy to fix in the case of yield for generators, except > that I'm not sure it's easy to fix for names in general. There are > lots of other strange possibilities: > > def f(): > if 0: > exec foo > def g(y): > return x + y > > Should this get a SyntaxError about the bare exec making resolution > of free variable x ambiguous? Yes. > def g(x): > if 0: > global x > > Should this get a SyntaxError about an argument being declared global? Yes. The answers can only be "no" if you think of "if 0:" as a C "#if 0" preprocessor gimmick. The specific value after a Python "if" should have no effect on statically-determined properties of Python code. > I'm inclined not to worry about them, because they'd be a PITA to > deal with and the "right" choice is far from obvious Agreed it's a PITA, but disagree the right outcomes are unclear: change "0" to "42" or "hmm" and the answers are obvious, yes? > -- unless Guido wants to offer some pronouncements on just what > the heck they mean. I may not be able to read our code, but I can still channel Guido . From aahz at panix.com Fri Jun 22 10:40:34 2001 From: aahz at panix.com (Aahz Maruch) Date: 22 Jun 2001 07:40:34 -0700 Subject: Is this a true statement? References: <9gvb8q$ssl$1@taliesin.netcom.net.uk> Message-ID: <9gvld2$mho$1@panix6.panix.com> In article <9gvb8q$ssl$1 at taliesin.netcom.net.uk>, MDK wrote: > >Python can do everything C++ can do but just slower. No, it's a false statement. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Truth is stranger than fiction, but it is because Fiction is obliged to stick to possibilities; Truth isn't." --Samuel Clemens From alan.gauld at bt.com Mon Jun 4 13:26:08 2001 From: alan.gauld at bt.com (Alan Gauld) Date: Mon, 04 Jun 2001 18:26:08 +0100 Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> Message-ID: <3B1BC4AF.3B6AFC6B@bt.com> Frank Millman wrote: > After 15 years of designing applications using the good > old "seat of the pants" method, I have decided that, > if I am to move forward, I need a more formal methodology. Not a bad idea :-) > I have recently read about UML (Unified Modelling Language), a > standards-based method of designing and documenting any > software project. Actually its only a notation. You have to provide the method yourself. Thats not a bad thing IMHO, the notations are important, the method can vary on every project! > Does anyone have any knowledge or experience of UML I use UML every day. I wrote two articles on it on InformIT.com - you have to register but its free and a great source of free info including entire online books. Search for muy name. You';ll find an article on why UML is good in principle - and whats not so good in practice. There is also an example of usoing UML in a Systems Integration (ie non programming) type project. HTH, Alan G. From wintedk at hotmail.com Tue Jun 12 14:35:27 2001 From: wintedk at hotmail.com (Christer Østergaard) Date: Tue, 12 Jun 2001 20:35:27 +0200 Subject: All functions from self and inherited classes Message-ID: Hey all! I'm currently working on creating a general class (GeneralClass), that has public method named doc(). I have the following inheritance setup: GeneralClass -> A -> B When i create an instance of B, namely b, and call b.doc(), I want to display all methods from self (that's b) including inherited methods (from GeneralClass and A). But... no toast for monty! My code in GeneralClass .doc() is this: aClass = getattr(self, "__class__") print getattr(aClass, "__bases__") Line one finds the class from which self was instanciated from, right? The second should find all bases for that class... My intention is to iterate through all in bases, running dir() on each of them, and thereby getting all methods and compile a list. On that list I want to write all __doc__, and thereby create a function, which returns full documentation. No matter what I do, I cannot get anything from bases. And a dir(self.__class__) returns methods, but only methods defined in B. I've tried this "outside" (in Python interactive mode), and it works (in an alternate version, though) on any class... but in some way, when called from from within a class method, the scope of the class method makes some changes? Please advice me on how to get all methods available for a given class... i promise to follow up and post the entire solution when i get there! Thanks in advance! Christer / Denmark From vj$ri^gg#guess#l55e at mt$*guess#&cn1e#t.! Tue Jun 26 15:46:36 2001 From: vj$ri^gg#guess#l55e at mt$*guess#&cn1e#t.! (Kevin Riggle) Date: Tue, 26 Jun 2001 14:46:36 -0500 Subject: Python for Commercial Games? Message-ID: <9haoiv$jnv$1@mtc1.mtcnet.net> I *do* realize that I'm posting to comp.lang.python , so please humor me anyway... I am in process of designing a computer game; problem is, I want to at least have a snowball's chance in Hades of selling the game. My question: Would it be possible to write the dang thing in Python (PyWin), or is C/C++ the better option in the Windows-centric world of game development right now? Thanks in advance, Kevin From new_name at mit.edu Wed Jun 27 07:34:45 2001 From: new_name at mit.edu (Alex) Date: 27 Jun 2001 07:34:45 -0400 Subject: An approach to building a networkable boardgame... References: <3b392559.9658458@news.lith.com> Message-ID: ZEO might work for you. Check out http://www.amk.ca/zodb/guide/node30.html Alex. From twcinpa at early.com Sat Jun 9 20:46:24 2001 From: twcinpa at early.com (Tom Connor) Date: Sat, 9 Jun 2001 20:46:24 -0400 Subject: newbe question References: Message-ID: I like Core Python Programming by Wesley Chun for that reason. Tom C. "scott snider" wrote in message news:mailman.992020093.3592.python-list at python.org... > is there a good book or web site that explanes and > teaches python in a step by step way so that when you > are finished with the book or site you have a fully > functioning program? > > thank you > scott > > __________________________________________________ > Do You Yahoo!? > Get personalized email addresses from Yahoo! Mail - only $35 > a year! http://personal.mail.yahoo.com/ > From jm7potter at hotmail.com Sat Jun 30 07:02:29 2001 From: jm7potter at hotmail.com (Joe Potter) Date: Sat, 30 Jun 2001 07:02:29 -0400 Subject: newbie with major "lambda" problem (perhaps a scope problem as well) References: <37hmjtk186jsm8k8j0tcq9rvae37mpjb3s@4ax.com> Message-ID: On Fri, 29 Jun 2001 16:44:19 -0700, "John Roth" wrote: >If I understand what you want to do, you want a scrolling panel at the >top, and three command buttons below (or above) the panel, right? >The issue here is that the buttons' action procedures need access to >the class instance, so they should go inside the class. That means the >buttons themselves should go inside the class. > >That means you need to build everything inside the class. In other words, >you can't build the pmw.ScrollingFrame (or whatever) outside it, and then >use the frame for the contents. You need to build it at the same level >as the buttons and the data fields, which means inside the class. > >There's nothing wrong with building two (or more) levels of widget in the >same class. You just need to insure that things nest neatly. > >John Roth > Boy, am I stupid or what? I read you message again ( several times) after I posted to you. Then I started from the beginning rather than try to fix the example code. Worked like a champ. No problems at all! I think I can safely say that my main problem was working with class before I knew what class was! You words have put me on the path, Thanks much. Warmest Regards, Joe PS: just wait, there will be MySQL questions --- never fear! From rdsteph at earthlink.net Tue Jun 19 21:07:32 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Wed, 20 Jun 2001 01:07:32 GMT Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: <73PX6.317$zE1.418988@news.uswest.net> <3B2FE2BD.F210FA8A@home.net> Message-ID: <3B2EA829.39DE6527@earthlink.net> Sounds like some interesting stuff fermenting in your minds ;-)) Well, if I can contribute anything, I certainly will. Although a rank amateur, with enough work who knows? Anyway, I just got my 11 year old son Michael up here to read this thread and comment. Believe it or not, he knows and uses C extensively and is learning C++. (Hey, he'll be 12 in a month and he's lot smarter than I am) ;-))) Perhaps it would be interesting to ask members of this list to list features and/or attributes of an "Ideal" event driven gui creation package for Python. My own simple contribution would be my desire to have a very simple, easy to use, program to create HTML Forms and Table Objects, along with the ability to attach properties, attributes and methods to the objects, and the ability to recognize events and take the called for actions. Couldn't a Hypercard-like system be used to achieve the above aims? If a first-pass , simple form of this program existed that could be used to create user inputs and outputs and web scripts with Python, although that may seem trivial and worthless to advanced programmers, it might attract hordes of Python newbies and webmasters. Would creating such a simple prototype and seeking user feedback be useful to further refinement of more strategic goals, tools and methods??? While my son might someday contribute in C or C++, might a simple Python language prototype reveal interesting outcomes? I am interested in this project. Ron Stephens P.S. I just checked SourceForge and a PythonCard project already exists! The only information about it is, perhaps not surprisingly, not exactly what any of us has in mind ;_))) See below:::: (from SourceForge) """A card file program (in the spirit of Apple's HyperCard) designed to store and search thousands of cards containing megabytes of text. Uses gzip to compress text. Uses superimposed coding (signature file indexing) for fast searching. Written in Python""" Chris Barker wrote: > Kevin Altis wrote: > > what is missing is the tight coupling of a GUI environment. > > I'm not sure if I mean the same thing as Kevin, but this is a big > problem. ALL the GUI options for Python (tkinter, wxPython, PyQT, PyGTK, > etc.) are wrappers around a GUI toolkit made for some other laguage, for > some other purpose. This is a major limitation. What Python needs is a > Native GUI toolkit. Guido talked about it in the past, saying that the > interface would likely be something like tkinter, but nothing is > happening on that front. > > What I imagine is this: > > A GUI library that is built for Python, that interacts well with the > Python library and all the native type. This library would, for > instance, expect to get a Python list whne is needed a list of items. It > would be written in C++ (or maybe C). It would be platform independent. > The strength in this approach is that the core library could just as > easily be extended in either Python or C/C++. This way, the community > could develop nice higher-level widgets and really expand the toolbox. > It could be used from either C/C++ or Python. This way, one could > develop a C/C++ app with an embedded python interpreter, and GUI code > could be run from either language, the transition would be easy. > > Many of these features now exist in wxPython. That is why I am using it. > However, wxPython is a thin wrapper around a C++ class library. This is > a good thing because it allows common documentation and the wrappers can > be produced with SWIG. It is a bad thing because you end up writing > Python code that is not natural (pythonic), and a whole lot more verbose > and complex than it needs to be. It also suffers some from performance > issues do to translating from Python lists to wxLists, generating > wrappers around C++ objects, etc. I don't understand the details, but > the issues are there. wxWindows and Python also share a lot of duplicate > functionality: sockets, database access, process control, file system > manipulations, etc. etc. > > This doesn't mean that we would have to start from scratch, I'm sure a > lot of the underlying code from wxWindows, or Fox, or FLTK, or GTK, or > whatever could be used, but it would be a substantial effort. > > If such a toolkit existed, PythonCard would be a whole lot easier to > write, as would many other tools. > > Unfortunatly, Python is suffering, in this respect, from an Free > Software problem: people build what they need, and putting a wrapper > around an existing toolkit gets them something that works, with a whole > lot less effort than writing something new. So we now have ten wrappers, > and no native toolkit. :-( > > Well, I've proposed, and I've whined, and I have neither the time nor > the skills to do it, so I'm done for the moment. > > -Chris > > -- > Christopher Barker, > Ph.D. > ChrisHBarker at home.net --- --- --- > http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ > ------@@@ ------@@@ ------@@@ > Oil Spill Modeling ------ @ ------ @ ------ @ > Water Resources Engineering ------- --------- -------- > Coastal and Fluvial Hydrodynamics -------------------------------------- > ------------------------------------------------------------------------ From delgado at okeeffe-pc3.la.asu.edu Tue Jun 19 04:46:13 2001 From: delgado at okeeffe-pc3.la.asu.edu (Olaf Delgado Friedrichs) Date: 19 Jun 2001 08:46:13 GMT Subject: PEP 255: Simple Generators References: <3B2EEF5A.8FF0DAFB@cosc.canterbury.ac.nz> Message-ID: On Tue, 19 Jun 2001 18:21:14 +1200, Greg Ewing wrote: >Something is bothering me about this. In fact, >it's bothering me a LOT. In the following, will >f() work as a generator-function: > > def f(): > for i in range(5): > g(i) > > def g(i): > for j in range(10): > yield i,j > >If I understand PEP255 correctly, this will *not* >work. But it seems entirely reasonable to me that >it *should* work. It *has* to work, otherwise how >am I to write generators that are too complicated >to fit into a single function? If I understand correctly, this should work: def f(): for i in range(5): for x in g(i): yield x def g(i): for j in range(10): yield i,j Olaf From sapsi at bigfoot.com Fri Jun 29 04:07:16 2001 From: sapsi at bigfoot.com (Drop Anchor!!) Date: Fri, 29 Jun 2001 13:37:16 +0530 Subject: Setitimer? Message-ID: <9hhcs8$dk56r$1@ID-91520.news.dfncis.de> Hello, I wish to use the setitimer c call , specifically to set off a SIGALRM every 1 second. How would i do this in python, how do i access the setitimer call ? Thanks Saptarshi sapsi at bigfoot.com From aleaxit at yahoo.com Tue Jun 12 10:06:08 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 12 Jun 2001 16:06:08 +0200 Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: <200106112007.f5BK7eW22506@odiug.digicool.com> <3B253031.AB1954CB@lemburg.com> <200106121320.f5CDKCvM032104@smtp5.andrew.cmu.edu> Message-ID: <9g57kh01eol@enews2.newsguy.com> "Brian E Gallew" wrote in message news:200106121320.f5CDKCvM032104 at smtp5.andrew.cmu.edu... ... > I really like Alex's output() (or whatever you want to call it) > function and would use it in a heartbeat. I would also be much more > interested in being able to supply a keyword argument to readlines() > that would have it strip the EOL character(s). An interesting idea would be (yeah, yeah, I know -- my name is Alex, and I am an overgeneralizer) to have a named parameter ln uniformly accepted by all functions and methods dealing with lines. Default would be ln=1 for functions & methods that now respect/don't add newlines (readline, readlines, write, writelines, xreadlines, ...), ln=0 for those that now generally add/remove newlines (print -- or rather its function-equivalent -- say 'output', raw_input). Being "everywhere" would make it easy indeed to teach to newbies. Being a keyword argument would make life easy for advanced users, as suggested in my last post, i.e. rather than if somecondition(): print blah, bloh, else: print blah, bloh or print blah, bloh, if somecondition(): print just output(blah, bloh, ln= somecondition()) ... Akex From threeseas at earthlink.net Sat Jun 16 18:02:55 2001 From: threeseas at earthlink.net (Timothy Rue) Date: Sat, 16 Jun 2001 22:02:55 GMT Subject: Python version of IQ has been updates (IQ v0.34.python) References: <505.566T11T1243597threeseas@earthlink.net> <3B2A7F5E.MD-1.4.4.padf@ihug.com.nz> Message-ID: <3871.567T2214T9794928threeseas@earthlink.net> On 15-Jun-01 04:34:22 Patrick Ford wrote: >Timothy Rue wrote: >> http://www.mindspring.com/~timrue/python/IQ.34.py >Python??? > >Oh no don't go there Tim! >Rebol rocks. There was a recent article on slash dot about Python becomming GPL compatiable. It's open source and has a rich pattern matching module amoung many other note worthy things about it. I recall someone mentioning Python to me in the past and my not looking into it (my mistake, but now corrected). Others have suggested Rebol to me and as anyone who's been around long enough, certainly knows I'm aware of Rebol, though I may not keep up with it as much anymore, I can always search it's mailing list if I have a question. Rebol is very different, it's closed source and free only in a limited version. It also does not have a rich pattern matching facility. Although Rebol has some things easy to do, the overall comparison for what I need of a programming language weighs in favor of python. This includes open support (to give credit to those on the python IRC channel and elsewhere, such as usenet - for help on a GPL project - if even only answering a rookies questions about python.) On the up side, there is nothing stopping the limited but free version of Rebol from being used thru a pipe in order to access the easy internet functionality of rebol, from a python program. But, even the Amiga Version of Python has an Arexx module. If there is any limitation about using systems that don't have something like a user easy to use application arexx port (the doorway to controlling an application externally and in addition to it's usual shell or GUI) it is only thru open source and GPL sided licenses that this limitation can more quickly, broadly and easily be overcome. And I'm sure it will once this third primary user interface is more widely recognized. The general difference between commercial closed source and open source on the GPL side is a result of what is used to cause growth of the product. The commercial side creates limitations that are only removed for a price that inturn is used to expand the product in new limited ways. But on the GPL side, it's the lack of limitations and openness that causes it to grow thru genuine interest in use. Of course if you want to produce a version of IQ usin gthe rebol language, you can. In fact I'd like to see how regular expression pattern matching is emulated thru dialect parsing methods. Today there is another article on slash dot regarding the GPL. http://slashdot.org/article.pl?sid=01/06/15/003248&mode=nocomment But ultimately it should NOT be a matter of which language is used, because it eventually gets either compiled or interpreted down to the language the machine understands. That's binary machine language. Auto-coding focuses on programming concepts, from the user perspective, rather that language specific implimentations of those concepts. Though the genuine software engineer building the underlying auto-coding data bases, dictionaries or vicabularies, will certainly be dealing with language specific issues, these language specific issues are as isolated from the user of auto coding as assembly language or machine language is isolated from the higer level language, such as C, user. The specifics are there if the user wants to get down into them. The auto-coding user only needs to deal with programming concepts or even less when a combination of concepts has already been packaged for easier use. --- *3 S.E.A.S - Virtual Interaction Configuration (VIC) - VISION OF VISIONS!* *~ ~ ~ Advancing How we Perceive and Use the Tool of Computers!* Timothy Rue What's *DONE* in all we do? *AI PK OI IP OP SF IQ ID KE* Email @ mailto:timrue at mindspring.com >INPUT->(Processing)->OUTPUT>v Web @ http://www.mindspring.com/~timrue/ ^<--------<----9----<--------< From m.bless at gmx.de Thu Jun 14 17:25:28 2001 From: m.bless at gmx.de (Martin Bless) Date: Thu, 14 Jun 2001 21:25:28 GMT Subject: base converter References: Message-ID: <3b292aca.35403221@news.muenster.de> [Fredrik Lundh]: >(why has decimal to binary conversion suddenly turned into a >FAQ the last few months? it wasn't this way in the old days, >and I cannot remember ever having to output things as binary >numbers in a real-life project... can anyone explain?) I needed it for analyzing some system data where single bits were important. Martin From James_Althoff at i2.com Fri Jun 15 15:00:54 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Fri, 15 Jun 2001 12:00:54 -0700 Subject: Any other Python flaws? Message-ID: Alex Martelli wrote: >"Steve Holden" wrote in message >news:#72#QIT9AHA.262 at cpmsnbbsa09... > ... >> > That leaves the remaining warts as minor wibbling about 'do' >> > statements, print >>, and the like. Are there any other flaws that >> > should be added? >> > >> Despite the fact that our Fearless Leader and BDFL has already revered >> himself once on this issue, I'd like to see strict syntactical equity >> between function definitions and class definitions, which is to say that a >> class with no superclasses should be declarable as: >> >> class myClass(): >> pass > >Hear, hear!!! It IS a minor but definite wart that those parentheses >are a syntax error in 'class' but mandatory in 'def'. > >Alex I "third" the motion! Jim From junkster at rochester.rr.com Mon Jun 18 19:39:17 2001 From: junkster at rochester.rr.com (Benjamin Schollnick) Date: Mon, 18 Jun 2001 23:39:17 GMT Subject: SNMP OIDs for Cisco 6509 & Cable Modems Message-ID: Folks, I'm working with the PySNMP software, which doesn't yet handle MIB -> OID conversion.... So I'm a little stuck, I'm having difficultly tracking down the actual numeric OID's for a Cisco 6509 & Industry Standard Cable Modems. Does anyone know how to generate the numeric OID's or where I can look up the Numeric OID's? I found several lists on Cisco's web site, but the 6509 is returning that the OID's are not in it's MIB file.... I can do a SNMPwalk fine on the Cisco 6509, but I'm not positive that will corespond with the OID's I downloaded from Cisco... (I haven't had a chance to compare yet). Help? - Benjamin From root at rainerdeyke.com Mon Jun 25 15:37:41 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 25 Jun 2001 19:37:41 GMT Subject: Is this a true statement? References: <8NuZ6.362378$oc7.42924874@news2.rdc2.tx.home.com> <3B3788A2.3BD1D672@tundraware.com> Message-ID: <9qMZ6.368197$oc7.44797813@news2.rdc2.tx.home.com> "Tim Daneliuk" wrote in message news:3B3788A2.3BD1D672 at tundraware.com... > Rainer Deyke wrote: > > To a program, "doing something" means "interacting with the outer world". > > It is a given that, if a program can receive the proper input from the > > world, it can calculate (but not necessarily perform) the proper output. > > Python includes many ways of interacting with the outer world in its > > standard library, but C++ usually includes more. Python can sometimes get > > around this by outputting machine code, but only if the problem is defined > > in a way that allows this. > I still do not understand/agree with this line of reasoning entirely. Your reasoning is flawed. > As I mentioned in a previous post, one has to define what we mean by > "do" or "program". It is a fundamental truth of Computer Science that > all Turing-Complete languages have *exactly* the same computational > abilities - i.e., They all handle the exact same set of algorithms - > in particular, those algorithms which are Turing Computable (which > excludes things like the Halting Problem). This *includes* all > "interactions with the outside world" because such interaction > is, by definition, algorithmic. Interaction with the outside world is, by definition, *not* algorithmic. Consider this diagram of a typical computer program: Input -> Computation -> Output Only the "computation" part is algorithmic, and those who use the term "Turing complete" generally only concern themselves with the computation part. As I understand it, a Turing machine has the ability to input and output single characters/numbers through a single input stream and a single output stream. A Turing machine does *not* have the ability to display graphics of any kind. There is the possibility that another machine turns the output of the Turing machine into graphics, but then it is that machine, not the Turing machine, which is generating the graphics. > (Fine Point: There is a debatable point here about whether adaptive > algorithms like those found in Genetic Programming are really formally > "algorithms" at all because they do not behave consistently when faced with > he same input conditions, but that's way outside the scope of this discussion.) All computer programs are deterministic. Any computer program that generates output O from input I will always generate output O from input I. > Now, back to the debate at hand. We've all agreed that some things > are easier to do in C++ (yuck) than Python. Let's take the example > of writing device drivers. Using today's language and syntax to > handle interrupts in Python, you realistically have only a few > choices: > > 1) Write a library in another language that implements > interrupt handling and then give it a Python interface. > > 2) Have Python write out a set of machine code bits which > are understood by the underlying implementation and > hardware to be the correct handling of an interrupt. Only if the system has a writeable disk with sufficient empty space. This is not a given. > 3) Add a native interrupt object to the language. > > 1) clearly takes us out of "pure Python" and is thus of no further > interest (unless you actually want to *solve* this problem in the > real world, in which case this is probably the best solution ;))) > > 2) Works just fine, but is kind of clumsy and unnatural to use. > Note, however, that it is 2) that gives us the ability to do *anything* > in Python which we can "do" in any other Turing-Complete language. > > 3) is where the rocks start to get thrown. If I do 3), have I "extended" > the language to do something it could not previously? NO! I have > implemented what I could already do with 2) in a more programmer-friendly > manner, but I have not changed the net computational power of the language. "Net computational power" is irrelevant in this context. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From missive at frontiernet.net Wed Jun 27 21:25:27 2001 From: missive at frontiernet.net (Lee Harr) Date: Thu, 28 Jun 2001 01:25:27 +0000 (UTC) Subject: dynamic object persistence Message-ID: <9he127$see$1@node21.cwnet.roc.gblx.net> This is what I am working on: Python 2.1 (#1, Jun 24 2001, 00:39:38) [GCC 2.95.3 [FreeBSD] 20010315 (release)] on freebsd4 Type "copyright", "credits" or "license" for more information. >>> import turtle >>> t = turtle.Pen() >>> def circle(self, r): ... for deg in range(360): ... self.forward(2*3.14*r/360.0) ... self.right(1) ... >>> circle(t, 100) >>> import new >>> t.circle = new.instancemethod(circle, t, turtle.Pen) >>> t.circle(110) >>> now I want to save t. Is this possible? pickle and ZODB do not seem to do what I want to do. Do I need to save the text of the new method and dynamically construct a new subclass and save that? Is this an active area of development? From phd at phd.fep.ru Sat Jun 2 15:17:09 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Sat, 2 Jun 2001 23:17:09 +0400 (MSD) Subject: problems with mod_python In-Reply-To: Message-ID: On 2 Jun 2001, Piet van Oostrum wrote: > OB> AFAIR some docs sais you must recompile Python without threads to use > OB> modpython. I think PyApache can be used with tread-enabled Python. But I > OB> didn't do enough tests. > > I read on the mod_python mailing list that the threading bug has been > fixed. Nice to hear it. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From qrczak at knm.org.pl Mon Jun 25 02:16:45 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 25 Jun 2001 06:16:45 GMT Subject: PEP 255: Simple Generators References: Message-ID: Mon, 25 Jun 2001 08:34:34 +0400 (MSD), Roman Suzi pisze: > Maybe there could be some reason to add "yield" in a > form of function also to make things like: > > [ << x for i in .... ] I don't see why to use a list comprehension instead of a for loop when the result list is not used. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From boud at rempt.xs4all.nl Sat Jun 30 18:23:58 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 30 Jun 2001 22:23:58 GMT Subject: GUI Builder for Python ? References: Message-ID: <9hljhu$moa$1@news1.xs4all.nl> Lothar Scholz wrote: > Is there something other then "Black Adder" which is behind an alpha > version ? You can always use the basic Qt Designer - which is one of the best GUI builders I've ever used - and compile the designs to Python code with pyuic. -- Boudewijn Rempt | http://www.valdyas.org From aleaxit at yahoo.com Wed Jun 20 02:25:48 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 20 Jun 2001 08:25:48 +0200 Subject: call-by-reference (was Re: Any other Python flaws?) References: <9gcu9g$gm4$1@newshost.accu.uu.nl> <9gd4tq$odb$1@news.mathworks.com> <9gdn37$61k$3@newshost.accu.uu.nl> <9gdt4j$b86$1@news.mathworks.com> <9gdtiu$61u$1@newshost.accu.uu.nl> <3B2FF5AB.E5181BC5@my.signature> Message-ID: <9gpfna031k1@enews2.newsguy.com> "Greg Ewing" wrote in message news:3B2FF5AB.E5181BC5 at my.signature... > Martijn Faassen wrote: > > > > I think the use of the word 'variable' is ambiguous. :) > > In Python it's clearer to talk about "names" and "bindings" > rather than "variables" and "values". *Definitely*! If we could get this terminology more widely adopted it would enhance clarity enormously. > The statement then becomes "you can't change the binding > of a name in your caller's namespace", which doesn't > leave much room for misunderstanding. Again, definitely. Alex From meowbot at meowing.net Fri Jun 15 16:10:20 2001 From: meowbot at meowing.net (meowbot at meowing.net) Date: Fri, 15 Jun 2001 20:10:20 GMT Subject: C API missing PyList_Remove() ... References: <3b29a5e6$1@clarion.carno.net.au> Message-ID: Darran Edmundson wrote: >Why has the C equivalent of "list.remove(item)" been >left out of the list of exported functions? Checking the >source, listobject.h exports PyList_Append(). Hovever >listobject.c has no function PyList_Remove(), instead just >the unexported list_remove() function. This is obviously >"by design", but why? Why not? PySequence_Index() and PySequence_DelItem() are probably what you're looking for. From aahz at panix.com Tue Jun 5 14:04:54 2001 From: aahz at panix.com (Aahz Maruch) Date: 5 Jun 2001 11:04:54 -0700 Subject: floating point in 2.0 References: <9fiptc$m9d$1@panix2.panix.com> <3B1D154B.81016685@home.net> Message-ID: <9fj706$27u$1@panix3.panix.com> In article <3B1D154B.81016685 at home.net>, Chris Barker wrote: >Aahz Maruch wrote: >> >> Actually, 2.0 *still* lies: >> >> >>> 0.1 >> 0.10000000000000001 >> >>> '%.55f' % 0.1 >> '0.1000000000000000055511151231257827021181583404541015625' >> >> It just lies less than it used to. > >What the heck are all those digits at the end? Talk about lies, you can >be sure all those digits aren't being stored (at least not in an IEEE >754 64bit double, which stores approx. 16 decimal digits. Approx. >because it is really a given number of binary digits. I don't have the >exact number off of the top of my head). It's 52 binary bits. The decimal 0.1 is converted to the nearest approximation using all 52 bits. The number you see above is the precise conversion of that approximation back to decimal. So yes, all of those digits are being stored. Note carefully that 754 doesn't store *any* decimal digits, it only stores binary digits. What you meant is that up to 16 decimal digits of precision can be *converted* to 52 binary digits with "reasonable" accuracy. Because decimal contains a power of two in its base, the reverse conversion *can* be made precisely. (Did I get it right this time, Uncle Timmy?) -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Do not taunt happy fun for loops. Do not change lists you are looping over." --Remco Gerlich, comp.lang.python From Attila.Feher at lmf.ericsson.se Tue Jun 5 04:55:01 2001 From: Attila.Feher at lmf.ericsson.se (Attila Feher) Date: Tue, 05 Jun 2001 11:55:01 +0300 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3B1B1825.8109BA83@lmf.ericsson.se> <2v4ohtgldvce84sn87kh1eg1lnes37getq@4ax.com> Message-ID: <3B1C9E65.B73A4FE@lmf.ericsson.se> TGOS wrote: > Look, I'm no cracker. I have very little knowledge about how to corrupt a > system, but on my university I'm trying to get root rights for two years now, > without anything even close to success. On a WinNT system of a company (for > that I was doing some network installation is part time job), it took me less > than 24h. No SPs applied... I did the same (not here) when we were supposed to install a Visual C++ but nobody knew the pwd of admin. BTW that was NT4 with some ancient SP. > > Crackers _does_ start on unices, the easiest to crack > > systems. > > All crackers I know started with Windows, because they say that hacking a > private Windows system is a lot more interesting than getting access to most > UNIX systems. Especially when hacking Win9x, as once you are in, there are no > security mechanisms anymore. Don't take here win9x. It is another kind of animal: DOS with bells and whistles. It is not meant to be a secure system (just think about the filesystem). > If you take a look at hacker-pages on the WEB, you'll get hundreds of tools > that corrupt Windows systems (DoS, Nukers, password file cracker, backdoor > access software, etc.) and not even a handful of those tools for UNIX. IOW > everyone can crack a Windows system (even people who don't have the knowledge), > because there are easy to use tools that will do all the work for you. Yep, and good NT admins know what to install to disallow the use of those. Same as with Linux: install right out of the box, connect to the internet and you get cracked within 2 hours. > > If you think they start on VMS, you are alone. > > So are you trying to say that VMS is so secure because it's an unknown system? > Could it be the case, that VMS isn't as secure as you (and many other people > believe) and it's just doesn't get hacked because there are way too little > hackers who try it? How secure a system really is will only get proved if there > are thousands of hacker who try to hack it daily. Since that seems not to be > the case for VMS, you can't make any predictions regarding its security No. It is secure, because it is designed to be secure. There are VMSes on universities and don't think people don't try to get into them :-))) > Despite that, I certainly won't claim that UNIX is more secure than VMS, since > I don't know enough about this system. If VMS main goal during development was > to make it as secure as possible, it's most likely more secure than UNIX, > Windows, Linux and some other systems. Therefor I'm sure it has other > disadvantages. Yep. It is as user friendly as a pitbull on his worse day. :-))) > > The Unix systems are _designed_ to be wide open. > > Usenet was designed for text messages, but it gets used for binary exchange as > well. In reality it plays no role for what something was designed, but rather > for it is used. There are thousands of examples where things are used for > completely different purpose than for what they got designed. I am not talking about the usenet, but the Unix networking, users etc. You know the "format string" attacks (don't remember the correct name) etc. These are possible, because the design had no stress on this kind of issues - there was no need to. BTW the small number of UNIX like systems, where designers did take security seriously it is different. > > So you _do_ need an expert to close them. > > I see, something we can both agree to. > And those experts are named "UNIX system administrator". > Who is hiring a UNIX system admin without the necessary qualification has a > problem, that's no secret. Same with NT. I have seen NT setup taking few thousand steps to make and which was solid as a rock. It was directly connected to the internet and noone has ever cracked into it. Of course: it was a pain in the ass if you wanted to use for anything else. :-)))) > > Not such with VMS. > > I don't know why you always have to mention VMS (probably you are working for > Compaq), but this discussion isn't about which system is more secure, it's > about cross-platform solutions versus single system solutions. Despite that, > since POSIX was added to VMS, it became a lot similar to UNIX and there's even > a GNU project for VMS. No I am not, but I am interested :-)))) YES, YOU ARE RIGHT. I never told cross platform development is bad. :-)) All I have tried to express was: it is not as easy as to say: Windows is better, UNIX is better etc. There is always a market, a set of possible users (payers), a required time to get to the market etc. and that makes it either feasible to be cross platfrom or not. And unfortunately how it goes today is that the big gap is between UNIX and Windows. I guess Mac new OS is more UNIX than it was before... So the primary decision is: is my target group UNIX or Windows or both. How can I get to the market the fastest, get my share of it etc. It is many cases Windows. But of course if there is no hurry, (or no GUI :-)) you _must_ go for corss platform as much as feasible. Different Unices and Windows (NT usually, since these are usually server processes). And here we agree, very much so. I just fed up that there is no other easy cross platform way than Java with its huge (and incompatible) VMs. :-(((( > > Creating a perfectly secured Unix system is equally extremely hard. > > Never said it is easy, but in case of Windows it's sometimes impossible. Hm. I have no such deep knowledge but usually the stuff goes anyway by having a separate FW and then the server... On different machine. > > It is not enough on Windows NT to be an ordinary user to do a crack. > > I only was an ordinary user, which was enough to run a crack. Yep, w/o the latest SP (was it 5??) for NT4 it was possible. _If_ you were sitting next to it. Still, it is _very_ rare that a simple user can sit next to an NT Domain Controller and start whatever he wants. And if you can crack into an NT workstation... It is still possible that the IT guys on the wire get alarm about every admin login :-))) > > You don't even seem to know the diff between hack and crack... > > | A hacker is a clever programmer. A "good hack" is a clever solution to > | a programming problem and "hacking" is the act of doing it. > - Source: "The New Hacker's Dictionary" And the best is: Bill Gates is (_was_) a hacker. :-))) > To hack a system means to > > | A cracker is someone who breaks into someone else's computer system, > | often on a network; bypasses passwords or licenses in computer programs; > | or in other ways intentionally breaches computer security. > - Source: "Whatis.com" > > But in IMHO that's not quite correct. Hackers also break into computer system, > just without malicious intentions and without doing any harm to that system. Yep, let's take the nice example of the calls I get at least twice each year: Attila, do you remember the supervisor password of the Novell at Jaszwhatever? No I say, no. But since the console isn't locked use the cracker NLM and you will get the password supervisor and can go in. :-))) Now that is hacking (altough I did not write this NLM). People lost their password and you still need to open up the system. But the act of using this NLM is a crack, I even hear the sound as the Novell nut cracks :-))) > Hackers are often confused with crackers. Uninformed users usually use "hacking > a system" as synonym for breaking into a system from an external source (via > network) and "cracking a system" as synonym for manipulating software on that > system or circumventing security mechanism within the system. But in fact > that's not really correct. Actually both is cracking. Yep, I agree. > > And on (a well secured) NT it is not enough to get in as an > > ordinary user to crack it. Same as with Unix. :-) > > But the problem is that the majority of WinNT system are a lot less secured > than UNIX system, simply because everyone can administrate a WinNT system (or > at least everyone believes that). And when there's a problem with some software > on your WinNT system (e.g. third party software), you don't have to possibility > to look at the source code, fix it and then recompile it. Yes, it is the fact. Some crackers in Hungary were fed up with it and cracked all the major ISPs in one day and placed a deface listing what SPs and hotfixes they did not install. But... there was Linux included, too. Plain, outofthebox sth. > Not to mention that the user right settings are very problematic on WinNT. In a > really secure system, users don't have enough rights for most tasks what leads > to problems (as I was once told by a company: "We can't use WinNT, because then > we would have to give all users full access and that would destroy any security > concept. Without that all software would have to get rewritten."). Aha. I have never met this problem but yes. Windows programming is like football, raising children and politics. Everyone thinx they know how to do it... and they do. At least a badly configured NT will not start to shoot its schoolmates. :-((( > > > > Not really. Windows code is seen by thousands before release. The fact > > you were not invited to this circle of privileged non-MS people does not > > mean it does not exist. > > But that's exactly the problem: MS choose a few privileged who can see their > code (and they aren't allowed to edit it, just having a look!). Despite that > this isn't valid for all their code. Hm. Secrecy can be good or bad. > So the quality of this "code viewing" depends a lot on "who MS chooses" and how > many. I still say that more people see UNIX code than MS code (I won't even > mention LINUX here, what is seen even by normal users). And the people who are > really interesting (hackers and crackers) will not be able to inspect the code > of Micro$oft and point out possible problems. Maybe, maybe not good that many can see the source. You _never_ know that a guy seeing it and finding something (which has about 1E-10 chance w/o the soruces) will turn to you or start dialing and make some money... [SNIP] > Yes and wanna bet that I can find someone who can crack such a terminal in less > than two hours. I bet if this terminal would run with Linux or maybe with > FreeBSD that wouldn't be that easy. And? You have cracked the terminal. So you can start up the UNIX/VAX terminal window and try to log in :-))) > The terminals at central station also run with Windows and guess how many > pictures I've already seen where those terminals show a "blue screen"? Blue Screen cannot come from user SW. That NT runs on a faulty or non-supported HW or uses a badly written driver. Do any of this with a UNIX and will get the same, but called kernel panic. > One of my friends is working in a computer company, which are offering and they > run a WinNT web server and he told me that it crashes at least once a month, > usually more often. The Solaris server at our university is now running for > years and it never crashed even once. It only was rebooted to add new hardware. Than you must have a real good luck. I use Solaris here and I know what I am talking about :-))) Reboot is once per day on a test machine where "badly behaving" SW can run. > If VMS is really as secure as you always say, it should be no problem to limit > access rights of the JVM via system configuration in such a way that it can't > cause any damage to the system. Despite that you can also write your own > Security Manager for Java and that way further limit access rights. I have no problem with the security manager, I have problem with the Java VM code. It isn't "old enough" and mostly not open source to convince a security-fanatic. There is one guy in Hungary, working for Westel (mobile operator). There is no Java running on anything what people can access from the outside world. :-))) > >> Again, I never said that UNIX is used in all the places you described above. > > > > You implied. > > I did not, I just said Windows ins't used there. Not as server, this is sure. But I also have seen bank which used CA-Clipper solution and a BBS for credit card handling :-))) > My post is about the fact that every user should be free to chouse his/her > favorite OS according to his her personal needs and nobody should be forced to > accept the flaws of a certain OS, just because some shit-head programmers left > him/her no other choice. That is right. And I would say also that no shit-had programmer should be forced to write cross platform code if he cannot. For the Alaska guys (real good guys) it took years to create the first decent version of XBase++ for Windows (NT). They were OS/2 programmers mainly. I would rather use a "Solaris only" thing here working than a "portable" stuff which in turn bound to 1111 GNU things (gawk etc.). But that is not the point. The point is that small businesses will never be able to do the first versions of their product to be fully portable. I am talking about GUI stuff. Of course if they do Java and their customer base can support such HW requirements as: min. 1GHz Pentium III and 2 buckets of memory... > >>> And about Windows being a shit: Just try to look around and find a > >>> portable async gethostbyname or a standard gethostbyname_r for > >>> Unices... Good luck. BTW you can find numerous workarounds which fail > >>> in numerous environments. > > > > > > And the fact that this function (which I personally have never needed up to > > > now) doesn't exist on UNIX is the proof that Windows isn't shit? Funny, but > > > that makes no sense to me. > > > > Did I say it exists in Windows? > > No. Did I? No. We did not say anything :-))) BTW it does exist on Windows. The only "good" point which I like in Win and _very_much_ miss in Unix is the messaging opportunity. Unix has few signals, and that's it. Sad. > But I know that async gethoutbyname exists in Windows. > (I'm doing my homework before replying to a post) :-))) Maladyetz > UNIX is very stable (when not using BETA versions). A crashed thread usually > won't take down the whole system, what happens pretty often in Windows > (especially when a hardware driver crashes). Linux is even better here. I can > even intentionally crash hardware drivers and the system survives it (as long > as I don't crash drivers that the system needs to survive. :-)))) So Solaris 7 is apparently not UNIX. :-)) It does not crash usually, simply stops working. > And UNIX is very well though out, an easy concept that is strictly upheld. It's > like a house build out of LEGO blocks, with clear data paths. Windows is rather > like throwing all blocks into a back, shaking it twenty times and throwing them > onto a table. Data paths are very unclear to normal users. Yep, Windows, it's registry, it's changing (screwed up) APIs, renamed and dumped concepts etc are awful. Still: I very much miss the good message system under UNIX. :-))) > I admit, you need more knowledge to be a UNIX admin than being a Windows admin > (Windows hides its chaos behind a neat, easy to use GUI), but as UNIX admin you > also have a lot more power over the system. And that makes Windows more > insecure, because users often aren't able to see security holes until it's too > late. I would say to be a _good_ NT admin is not easier than being a UNIX one... Only thing is that this kind of guy is rare :-)) > There is no absolute security, it's always just relative. > (How was that? "A PC is only secure when you cut all cables, lock it into a > safe and sink it in the middle of the Atlantic.") Hm. Even than, if you don't have the latest service packs and security fixes.... :-)) > If 20% of your other market is mainly using 4 other platforms and you aren't > able to server all of them, you might have the wrong job. > And your boss might also have the wrong job, because if I were your boss, I'd > look form someone who's able to server 95% of the market. May be. And maybe you can get the 80% of the market if you are out with a solution in 2 month. And spend the next 2 for the other platforms... > Why? What are you developing that the Linux, OS/2, MacOS, BeOS, AIX, HP-UX, > Solaris, BSD, FreeBSD and the users of over 50 other OSes aren't interested in? > And how do you know, have you asked every single user on this planet? Nope. I did not. Let's say I design a very system specific thing, an internet dialer for example. :-))) Let's not go into this. Everyone is on his own to decide whether it is feasible to make 1st release cross platform or not. > Java itself runs on all those systems and it's offering enough elements for > your GUI. Swing is offering enough elements to write your own MS Office. > Only mouse wheel support is currently missing, but Java1.4 will also add mouse > wheel support (right now I'm just playing around with the BETA version). Yes. Still: I have been working with a guy using Java from it's birth... and I did not hear many good things about VM portability, performance etc. Max. size still working (talking about normal WS) Java applet was around 70K. Then performance degraded so much, that is was useless. BTW I wanted to use Java, I have even installed it. But with my 64M PII266 notebook it took 3 minutes to open a source file in the Forte... Thx. > Despite that, you can write 90% of your application in Java and then add the > missing 10% via C++ or even native assembler code (for speed reasons or to add > special OS features that Java doesn't support at the moment). That has the > advantage that you always only need to rewrite 10% of your application for > every new platform. And platforms you don't support directly can still use your > application, in that case just without those special features or without the > additional speed boost. Yep. And have a customer with Crays on every desktop if they want speed :-((( > For C++, try using Qt. > It exists for: > - AIX > - BSDI/OS > - DG/UX > - HP-UX > - Irix > - Linux > - OS/2 (but only with an installation of XFree86) > - QNX > - SCO UNIX > - Solaris > - Tru64 > - Windows 95 > - Windows 98 > - Windows NT and 2000 Tried. They don't have an unlimited trial version for Win and I have no way now to install a Linux at home. :-((( > I think there's even a Palmtop version, maybe other embedded systems will > follow. This will make your GUI run-able on quite a lot of platforms in native > speed, with lots of features (like "skin support"). The free version is of > course limited (I think no 3D support, no network and IO libraries), but a > company that plans to increase their market by 15% of users might as well pay > for the commercial version. Qt is great is what I have heard. I wanted to learn it, but no bonus. If I get a 30 days trial I may have 2 days when I can really look at it :-((( [SNIP] > For what a C++ programmer needs 3 hours is done in one hour by a Java > programmer, not to mention that Java is more than 200% easier to debug in case > of errors. Don't forget you can use Java also server side and there you are > free to use the latest version of it. Yep. And I am also free to see 1 unhandled exception per minute - at least with the Java apps I have tried to use. :-((( > You are even allowed to bundle a JRE (Java Runtime Environment) with your Java > application, meaning the target PC doesn't even need to have an installation of > Java. Yep. First I gave up trying to use Java when I have installed the the JRE and it crashed my whole Windows 95. I had to reinstall. > And depending on task, other programming languages are even more efficient than > Java. A single line of code in some programming languages will do more than 20 > lines of Java, which usually are better than 60 lines of C++. I know one Online Casino SW and it is written in Clipper with Clip4Win :-))) They believe they can port it to Java... I still wait to see the first version which runs in less than 128MBs with acceptable speed. :-))) > China, one billion people. Computer shops in China sell Linux 200 times more > often than Windows. The Chinese government plans to increase the usage of Linux > even more (they don't trust Micro$oft, open source rules, as they can make sure > there's no spyware inside). BTW downloaded distributions aren't counted here. Why don't they trust MS? :-))) I cannot imagine... > You must watch beyond your limited horizon or one day this attitude will break > your neck (or the neck of your company). Others will jump into that gap and > then they will have the market you never had as well as parts of the market you > _do_ have. I program on Solaris and will port to Linux withing few month. :-))) I am not a "Windows only guy". There are still things which I like (love) from Windows and hate in UNIX and vice versa. > If you only want to provide your software *locally* you are limited your market > in two ways (only users of a certain OS and only within one area). What's next? > Only users with a specific first name? :-))) Don't get that far. If one can develop a package for small businesses using MS SW (Program next to Office?) in few weeks and sell it, why not??? The same design (I mean the UML or whatever) can then be used to make the Linux (Unix) version of it, probably based on some other stuff... There can be many cases in business and I am quite sure you don't know them all - like me. > Over web means inside a webpage, IOW inside the browser. > So either within a plugin, server-side or Java. Or ActiveX or C# :-)))) (Just kidding) > Why should 3d access "over web" to a database be limited to x86 or Windows > users? Why can't it be for everyone? Why aren't people in China allowed to use > it? Because you believe that you can save 5 minutes through a win-only solution > (what is not even true)? Windows NT is not limited to x86... About China - you should ask their government. They filter the Web :-))) > > Online application is not necessarily "within the browser". "Withing > > the browser" is Java, ActiveX or C# or goodbye. > > C# ???? > My browser doesn't run C#, not even my system as a whole can run C#. > No system which I ever was using during my whole life was able to run C# up to > now. Yes. And you could say the same when Java was new :-))) Anyway I could trust Java more if it would be a standard language like C++ and Sun would have less influence on it... > And ActiveX...come on, ActiveX is the same as installing a browser plug-in, > there's no difference (there is for the programmer, but not for the user). So > you can as well use any other kind of plug-in. Yeppp. > > Java is still a very unstable > > Hasn't crashed my PC a single time and I use it daily. > I currently develop exclusively in Java and my programming IDE is written > itself in Java. Everything always runs fine and I have no idea what you mean by > unstable. How much memory? 512Ms? Just curious. What CPU? What speed? > > and unsecure stuff where VMs are incompatible etc. > > VMs aren't incompatible in general (leaving bugs aside). > I always test my software on at least 5 different platforms and never ran into > a single problem. Hm. U R a lucky one or you do totally different task than my friend was... [SNIP] > But better supporting only a few platforms (5 to 10) than supporting only a > single platform. You will never be able to support every platform that exists, > but limiting your solution to a single platform right from the start (for > reasons that you weren't even able to make clear up to now) is certainly no > good approach towards a solution. Yep, U R right. Probaly with right decoupling the client/server tasks you may support more client OSs with less effort... Of course, you will have a different GUI for a Java 1.1 only beard-trimmer :-)) A From msandin at hotmail.com Fri Jun 15 03:37:22 2001 From: msandin at hotmail.com (Martin Sandin) Date: 15 Jun 2001 00:37:22 -0700 Subject: Any other Python flaws? References: <3B2914A0.6010902@erols.com> Message-ID: <1996b22d.0106142337.7b70484a@posting.google.com> > ...I got an array with 100 elements, all 0. > > I think python is OK here. Except you didn't =) You got a list of 10 references to a list with 10 references to the number 0. That the inner list is a list of references to the same object doesn't matter much, it's immutable anyhow. But the outer list... I's not strange, but it might be a bit surprising, isn't exactly 'intuitive'. - Martin Sandin http://come.to/vague From andymac at bullseye.apana.org.au Sat Jun 16 20:41:36 2001 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Sun, 17 Jun 2001 10:41:36 +1000 (EST) Subject: os.statvfs on FreeBSD In-Reply-To: Message-ID: On 16 Jun 2001, Martin von Loewis wrote: > t_messmer at yahoo.com (Tom Messmer) writes: > > > For some reason the default installation of python-1.5 and Python-2.0 > > on FreeBSD(From the ports collection) does not include the > > os.statvfs() routine. Does anyone know A. Why? and B. How to fix it? I > > need this thing! > > You probably need to give some more details for those of us without > access to a FreeBSD system. E.g. post some code snippet, and show what > error it produces. FreeBSD doesn't have statvfs(), which is why Python (built from the ports collection, or built with the supplied configure script) doesn't provide this wrapper. It does have statfs(), so someone will need to write the wrapper. [this is the essence of the response I sent the original poster when he opened a FreeBSD-ports PR] -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andrew.macintyre at aba.gov.au (work) | Snail: PO Box 370 andymac at bullseye.apana.org.au (play) | Belconnen ACT 2616 andymac at pcug.org.au (play2) | Australia From see at below Fri Jun 15 02:11:48 2001 From: see at below (Paul Foley) Date: 15 Jun 2001 18:11:48 +1200 Subject: Any other Python flaws? References: <3b296534.514160393@wa.news.verio.net> Message-ID: On Fri, 15 Jun 2001 04:01:49 GMT, Bengt Richter wrote: > The guiding star would be having a platform-independent abstract > hierarchical name space to virtualize access to various > containers and sources and destinations of stuff. Mapping > access to a particular platform's file systems would be one use. > Mapping to unix could be pretty transparent as far as usage > is concerned. > One benefit would be that Python could have its _own_ standard > hierarchical file-and-such-entities-as-my-be-desired name space > independent of platform, or at least more independent. http://www.xanalys.com/software_tools/reference/HyperSpec/Body/chap-19.html -- Nomina stultorum in parietibus et portis semper videmus. -- Cicero (setq reply-to (concatenate 'string "Paul Foley " "")) From akuchlin at mems-exchange.org Wed Jun 20 09:54:07 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 20 Jun 2001 09:54:07 -0400 Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: <3B2EADB0.9DBC6FC8@earthlink.net> Message-ID: <3dlmmndzpc.fsf@ute.cnri.reston.va.us> "Neil Hodgson" writes: > How suitable would ZODB be as the persistence back end? I know nothing about HyperCard, but the ZODB is quite nice for making a set of objects persistent. The only problem is that getting the ZODB without Zope is a pain (which is the reason why I started packaging it), and it needs some polishing to make it a bit more convenient to use. --amk From netmgr at canterburycrest.org Thu Jun 21 18:25:20 2001 From: netmgr at canterburycrest.org (Ross Brattain) Date: Thu, 21 Jun 2001 15:25:20 -0700 Subject: Getting actual name of passed arg References: <3B3272DD.4000308@canterburycrest.org> Message-ID: <3B327450.8060305@canterburycrest.org> Just found it import inspect def bar(a): print inspect.getargvalues(inspect.currentframe())[-1] bar(1) should print out {'a' : 1} Ross Brattain netmgr at canterburycrest.org From jeff at ccvcorp.com Wed Jun 27 14:16:41 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 27 Jun 2001 11:16:41 -0700 Subject: wxPython to create a database front end References: <9hchtv$j9i$1@news6.svr.pol.co.uk> Message-ID: <3B3A2309.D56965B8@ccvcorp.com> Patrick Kirk wrote: > I want to create a database front-end set of forms. If I use the built in > functionality of MSAccess, I can create forms with all the programmable > buttons, then look at the properties of each button and finally write VBA > that does what I want. > > Is this point and click type GUI creation possible with wxPython? I have > Visual C++ but want the application to be portable. Is there a web tutorial > on how to do this? > > Thanks in advance. There is Boa Constructor, but it's still in pretty early stages of development, IIRC. Haven't had a chance to try it out, myself. Yet. Jeff Shannon Technician/Programmer Credit International From m.faassen at vet.uu.nl Thu Jun 14 18:20:20 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 14 Jun 2001 22:20:20 GMT Subject: Upon reflection... References: Message-ID: <9gbdb4$gla$1@newshost.accu.uu.nl> Rod Weston wrote: > Thanks everyone, for your assistance. I have posted messages on > Ada, python and smalltalk groups for other perspectives and have > arrived at the following conclusions. > My objectives are to quickly learn and become productive in a language > that properly supports Object Oriented Programming. I want to use > free or inexpensive toolsets and I want to have a market for my > efforts. I want strong typing because I believe, having worked in a > language without typing, that it provides a strong deterrent to > serious errors. Have you worked with a language that has dynamic typing and good error reporting? I myself have worked with languages like Object Pascal (in Delphi) and C++, but found the run-time error reporting in Python helps me debug more easily. Those may be bad examples of statically checked languages though. > I want a strong debugging tool, compile-time error > trapping and very strong exception handling. I guess you want to try *static* typing. We from comp.lang.python wish you luck; static typing has its advantages, but don't say nobody warned you if you find you have coded yourself into a corner. :) > I believe I have found > the best language to satisfy those objectives in Ada. Do modern Adas support object oriented programming? Polymorphism, inheritance and such? Hm, a quick web search indicates Ada95 apparently does. > The real > bonuses in Ada are the ability to generate code that is capable of > communicating with JavaScript and Cobol (among others) Um, new requirements. What do you mean 'capable of communicating with'? A language like Python has the reputation that it integrates easily with everything else, so what features does Ada offer in this respect? I mean, later on you list professional development, so the ability to produce code that can communicate with Java may be considered an advantage (Jython), or speaking COM or CORBA may be nice. Why JavaScript and Cobol? [Win32 Ada95 development environment, anything forgotten?] I'd add a Unix-y operating system, but that's me. :) > What did I learn from the Python and Smalltalk groups? That they each > love their environments, that Python is too slow for serious > consideration How'd you learn *that*? What kind of applications do you intend to write? Python is fast enough for most tasks, so this is a very serious question. Python development _speed_ is considered to be much higher than that of many other languages after all, and this counts for something. This is all you learned from the Python group, by the way? We should say more interesting things next time. :) > and that Smalltalk would be worthy of future > consideration as an additional language - if I were the type that > 'collected' languages, which I am not. Heh, this gives even less insight on the tradeoffs that you decided on for Smalltalk than your treatment of Python! > Also, that Eiffel seems to be > an excellent pure OOP language, but no one seems to be using it for > professional development and, other than the distinction of being > 'pure OOP', has no powerful arguments for its use over Ada. Hm, what about an excellent debugging environment due to its use of pre- and post conditions? I'd say that's just about the strongest error trapping system you can think of, if you want to go that route. I'm not sure Eiffel sees that much less use than Ada, anyway (or Python for that matter). Comparing the size of communities seems difficult though. > Further discussion? Could you spell out the tradeoffs you decided on a bit more? I'm a bit confused how you came to consider Ada, Python and Smalltalk and Eiffel. Python and Smalltalk don't fit in your static typing requirement at all, and Java and C++, commonly used OO languages that do have static typing are mysterious absent from your considerations. Then when you make the decision the other languages don't get seem to get significant counter arguments (speed really isn't one for most business applications; there are arcade games written in Python these days! :). Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From donn at u.washington.edu Fri Jun 22 14:59:20 2001 From: donn at u.washington.edu (Donn Cave) Date: 22 Jun 2001 18:59:20 GMT Subject: Another Wart! string.find() [ was: namespace issue? ] References: Message-ID: <9h04i8$me8$1@nntp6.u.washington.edu> Quoth "Steven D. Majewski" : | On 22 Jun 2001, Donn Cave wrote: | > | > Given that you can't treat find or index as a boolean, there is | > no fault I can see with its -1 failure return. In fact it would | > be worse if it were false. Usage that doesn't work reliably | > ideally shouldn't work at all, or it's all the harder to diagnose. | > | | That last sentence above is just why I suggested None would be a | better return value. You still can't do "if not string.find(..." | because zero is still a valid return offset, but the problem with | -1 is that it can slip thru since [-1] is a valid string index, | it's valid in a slice expression, and can be added or subtracted | as an offset to another index value, all without giving an exception | anywhere near the error. If you try to use None as an index or add | it to another offset, you get an exception right away. So we could enjoy the best of both if it returned 'not found'. That would support neither incorrect boolean use nor careless use of invalid return. Donn Cave, donn at u.washington.edu From com-nospam at ccraig.org Fri Jun 22 08:05:44 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 22 Jun 2001 08:05:44 -0400 Subject: namespace issue? References: <87k825ljrz.fsf@elbereth.ccraig.org> Message-ID: <87wv64hg87.fsf@elbereth.ccraig.org> Michael Powe writes: > Actually, it doesn't contain the dash. The dash is only inserted if I > press the enter key, leaving the PN string empty. In the case of an I see that now. I was really only paying attention to the conditional... > So now the question is, 'why'? Am I misusing the string.find() > function? Okay, string.find() returns -1 when the string is not found, > which would seem to be what I expected, a false result. Maybe python > doesn't treat -1 as false? Well, I'll try being explicit and testing > for -1 return. I probably have just confused myself hopelessly. As others have pointed out, -1 is not false in Python. I would highly recommend you (and anyone else just learning the language) read section 2 (Built-in types) of the Library reference thoroughly. There is a lot of very useful information on how builtin types and functions work in there. More importantly though your code (which I quote below for readability), does not initialize Ph if the conditional is false. Even if you fix the logic error in the code, you are left with something that possibly returns an uninitialized value, which is bad practice. I presume that you want the program to return a value even when that condition is false, so you should have an else clause. If you want an error condition to occur when the condition is false then you should assert() the condition. --- Your code (fixed) --- >>> def GetNum2(): ... AC = raw_input("Area Code: ") ... PN = raw_input("Phone Number: ") ... if not PN : PN = '000-0000' ... if not AC : AC = '503' ... if len(PN) < 8 and string.find(PN,'-')==-1: ... Ph = PN[:3] + '-' + PN[3:] ... return Ph ... --- end your code --- --- better --- >>> def GetNum3(): ... AC = raw_input("Area Code: ") ... PN = raw_input("Phone Number: ") ... if not PN : PN = '000-0000' ... if not AC : AC = '503' ... if len(PN) < 8 and string.find(PN,'-')==-1: ... Ph = PN[:3] + '-' + PN[3:] ... else ... Ph = PN ... return Ph ... --- end better --- --- assert --- >>> def GetNum4(): ... AC = raw_input("Area Code: ") ... PN = raw_input("Phone Number: ") ... if not PN : PN = '000-0000' ... if not AC : AC = '503' ... assert(len(PN)<8 and string.find(PN,'-')==-1) ... return PN[:3] + '-' + PN[3:] --- end assert --- -- Christopher A. Craig "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." Albert Einstein From cja at well.com Fri Jun 15 15:49:42 2001 From: cja at well.com (Chris Abraham) Date: Fri, 15 Jun 2001 12:49:42 -0700 (PDT) Subject: Reminder for the DC Zope-Python UG Meeting. In-Reply-To: Message-ID: DC PIGgies: I just wanted to remind you about the ZPugDC meeting being hosted by DCLUG . Its this coming Wednesday, 20 June, in Bethesda, MD, at the NIH. Directions and more info can be found on either of the two sites above. The people who created both Zope and Python are going to be there. Guido might or might not, depending on family issues, but even so, the DC crowd is cool! Thanks for your time! Chris -- chris abraham, managing director beehive North America, washington, dc, +1 202 548 0410 wk +1 202 478 0276 From skip at pobox.com Mon Jun 18 17:42:21 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 18 Jun 2001 16:42:21 -0500 Subject: csv-0.3 released In-Reply-To: <3B2E5BFB.F0EAB859@home.net> References: <3B2E5BFB.F0EAB859@home.net> Message-ID: <15150.30141.874526.932953@beluga.mojam.com> Chris> This appears to mean that the CSV parser is slower that Chris> string.split, and as far as I can tell, does pretty much the same Chris> thing. What am I missing? CSV files can be syntactically more complex than simply inserting commas between fields. For example, if a field contains a comma, it must be quoted: 1,2,3,"I think, therefore I am",5,6 Also, you can quote fields (as above, but the quotes are not to be kept in the parsed output. The above should yield ['1', '2', '3', 'I think, therefore I am', '5', '6'] Since fields are quoted using quotation marks, you also need a way to escape them. This is usually done by doubling them: 1,2,3,"""I see,"" said the blind man","as he picked up his hammer and saw" There are probably more rules, but the comma and quoting rules eliminate simple string.split as a possibility. I believe the author was only using his simple example as a bit of input that could be fed to both string.split and csv.parser. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From com-nospam at ccraig.org Thu Jun 21 15:23:12 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 21 Jun 2001 15:23:12 -0400 Subject: namespace issue? References: Message-ID: <87k825ljrz.fsf@elbereth.ccraig.org> Michael Powe writes: > >>> def GetNum2(): > ... AC = raw_input("Area Code: ") > ... PN = raw_input("Phone Number: ") > ... if not PN : PN = '000-0000' > ... if not AC : AC = '503' > ... if len(PN) < 8 and not string.find(PN,'-'): > ... Ph = PN[:3] + '-' + PN[3:] > ... return Ph string.find(PN, '-') succeeds (since PN contains a '-'), so len(PN)<8 and not string.find(PN,'-') returns false, meaning that Ph = PN[:3] + '-' + PN[3:] is never executed, and Ph is not defined when the return statement is reached. So, yes, it is because of the conditional, but no it has nothing to do with namespaces. (unlike in C or C++, in Python not all blocks get their own namespaces, only functions, modules, and classes (and probably something I forgot)) Also, yes, raw_input returns a string. -- Christopher A. Craig Q: What's the difference between Bell Labs and the Boy Scouts of America A: The Boy Scouts have adult supervision From m.faassen at vet.uu.nl Sat Jun 16 15:31:35 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 16 Jun 2001 19:31:35 GMT Subject: Type/Class Distinction References: <9gdpbp$61k$6@newshost.accu.uu.nl> <9gfp64017jh@enews1.newsguy.com> Message-ID: <9ggc6n$f22$1@newshost.accu.uu.nl> Alex Martelli wrote: > "Martijn Faassen" wrote in message > news:9gdpbp$61k$6 at newshost.accu.uu.nl... > ... >> Right now we have to *treat* 'types' differently from 'classes'. For >> built-in objects you have to use the type() construct to check what >> you're dealing with, but for class instances you use isinstance(). >> >> Wouldn't it be nice if the language allowed something like this: >> >> if isinstance(foo, int): > You're behind the times, I think (if I understand you correctly): So I am! I wasn't aware this was the case. Does not seem to be mentioned in Andrew Kuchling's 'What's new in Python 2.1'. Apparently we're on our way already then. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From hamish_lawson at yahoo.co.uk Fri Jun 22 05:15:58 2001 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: 22 Jun 2001 02:15:58 -0700 Subject: Legitimate to raise SyntaxError for non-Python syntax errors? Message-ID: <915a998f.0106220115.2421a360@posting.google.com> Is it legitimate to use the SyntaxError exception for non-Python syntax errors, say by a parser when it encounters violations in the syntax of the data format or mini-language it is parsing? I'd always assumed that SyntaxError was meant for just Python syntax errors, but when I found a respected member of the Python community using it in the broader sense I outlined above, it made me wonder if this broader usage of SyntaxError is in fact considered legitimate. Hamish Lawson From robin at jessikat.fsnet.co.uk Thu Jun 14 15:22:08 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 14 Jun 2001 20:22:08 +0100 Subject: idle BUG Message-ID: I think this must be a bug in Tkinter, but since no one ever responds I thought I'd whine about idle instead. I run python2.1 Win95 OSR2. Start a command window run python idle.py Kill the idle window using the mouse (click on the x). In some unknown percentage of cases (like 50%) the process hangs and doesn't return to the command window. The hung process is very destructive and makes it impossible to reboot the machine properly. This bug has been present for a very long time and I'm fed up with it. It's clearly some kind of race between python and Tcl/Tk. The problem doesn't occur on win2k so I guess there's some difference between the run times that helps. similar apps in pure tcl/tk don't show this behaviour although it's possible to make them do stupid things. -- Robin Becker From dgoodger at bigfoot.com Wed Jun 13 00:42:24 2001 From: dgoodger at bigfoot.com (David Goodger) Date: Wed, 13 Jun 2001 00:42:24 -0400 Subject: PEP 257: Docstring Conventions Message-ID: This is a PEP-ification of part of Guido van Rossum's Python Style Guide (http://www.python.org/doc/essays/styleguide.html), with some modifications with respect to PEPs 256 & 258. I am posting this PEP to comp.lang.python for greatest community exposure. Please direct replies to the Python Documentation SIG's mailing list: mailto:doc-sig at python.org. In addition to the master copy at http://python.sf.net/peps/pep-0257.txt (HTML at http://python.sf.net/peps/pep-0257.html), a working copy is kept at the project web site, http://docstring.sf.net/. -- David Goodger dgoodger at bigfoot.com Open-source projects: - Python Docstring Processing System: http://docstring.sf.net - reStructuredText: http://structuredtext.sf.net - The Go Tools Project: http://gotools.sf.net PEP: 257 Title: Docstring Conventions Version: $Revision: 1.1 $ Last-Modified: $Date: 1935/06/06 05:55:20 $ Author: dgoodger at bigfoot.com (David Goodger) Discussions-To: doc-sig at python.org Status: Draft Type: Informational Created: 29-May-2001 Post-History: Abstract This PEP documents the semantics and conventions associated with Python docstrings. Specification All modules should normally have docstrings, and all functions and classes exported by a module should also have docstrings. Public methods (including the __init__ constructor) should also have docstrings. [+] A package may be documented in the module docstring of the [+] __init__.py file in the package directory. The docstring of a script (a stand-alone program) should be usable as its "usage" message, printed when the script is invoked with incorrect or missing arguments (or perhaps with a "-h" option, for "help"). Such a docstring should document the script's function and command line syntax, environment variables, and files. Usage messages can be fairly elaborate (several screens full) and should be sufficient for a new user to use the command properly, as well as a complete quick reference to all options and arguments for the sophisticated user. For consistency, always use """triple double quotes""" around docstrings. [+] Use r"""raw triple double quotes""" if you use any [+] backslashes in your docstrings. There are two forms of docstrings: one-liners and multi-line docstrings. One-line Docstrings -------------------- One-liners are for really obvious cases. They should really fit on one line. For example: def kos_root(): """Return the pathname of the KOS root directory.""" global _kos_root if _kos_root: return _kos_root ... Notes: - Triple quotes are used even though the string fits on one line. This makes it easy to later expand it. - The closing quotes are on the same line as the opening quotes. This looks better for one-liners. - There's no blank line either before or after the docstring. - The docstring is a phrase ending in a period. It prescribes the function's effect as a command ("Do this", "Return that"), not as a description: e.g. don't write "Returns the pathname ..." [+] - The one-line docstring should NOT be a "signature" reiterating [+] the function parameters (which can be obtained by introspection). [+] Don't do: [+] def function(a, b): [+] """function(a, b) -> list""" [+] This type of docstring is only appropriate for C functions (such [+] as built-ins), where introspection is not possible. Multi-line Docstrings ---------------------- Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line. The entire docstring is indented the same as the quotes at its first line (see example below). Docstring processing tools will strip an amount of indentation from the second and further lines of the docstring equal to the indentation of the first non-blank line after the first line of the docstring. Relative indentation of later lines in the docstring is retained. Insert a blank line before and after all docstrings (one-line or multi-line) that document a class -- generally speaking, the class's methods are separated from each other by a single blank line, and the docstring needs to be offset from the first method by a blank line; for symmetry, put a blank line between the class header and the docstring. Docstrings documenting functions generally don't have this requirement, unless the function's body is written as a number of blank-line separated sections -- in this case, treat the docstring as another section, and precede it with a blank line. The docstring for a module should generally list the classes, exceptions and functions (and any other objects) that are exported by the module, with a one-line summary of each. (These summaries generally give less detail than the summary line in the object's docstring.) The docstring for a function or method should summarize its behavior and document its arguments, return value(s), side effects, exceptions raised, and restrictions on when it can be called (all if applicable). Optional arguments should be indicated. It should be documented whether keyword arguments are part of the interface. The docstring for a class should summarize its behavior and list the public methods and instance variables. If the class is intended to be subclassed, and has an additional interface for subclasses, this interface should be listed separately (in the docstring). The class constructor should be documented in the docstring for its __init__ method. Individual methods should be documented by their own docstring. If a class subclasses another class and its behavior is mostly inherited from that class, its docstring should mention this and summarize the differences. Use the verb "override" to indicate that a subclass method replaces a superclass method and does not call the superclass method; use the verb "extend" to indicate that a subclass method calls the superclass method (in addition to its own behavior). *Do not* use the Emacs convention of mentioning the arguments of functions or methods in upper case in running text. Python is case sensitive and the argument names can be used for keyword arguments, so the docstring should document the correct argument names. It is best to list each argument on a separate line, [-] with two dashes separating the name from the description, [-] like this: def complex(real=0.0, imag=0.0): """Form a complex number. Keyword arguments: real -- the real part (default 0.0) imag -- the imaginary part (default 0.0) """ if imag == 0.0 and real == 0.0: return complex_zero ... [-] The BDFL [3] recommends inserting a blank line between the [-] last paragraph in a multi-line docstring and its closing quotes, [-] placing the closing quotes on a line by themselves. This way, [-] Emacs' fill-paragraph command can be used on it. [+] Attribute Docstrings: see PEP 258, "DPS Generic Implementation [+] Details" [4] [+] Additional Docstrings: see PEP 258, "DPS Generic Implementation [+] Details" [4] References and Footnotes [1] http://www.python.org/doc/essays/styleguide.html [2] http://www.python.org/sigs/doc-sig/ [3] Guido van Rossum, Python's Benevolent Dictator For Life. [4] http://python.sf.net/peps/pep-0258.html Copyright This document has been placed in the public domain. Acknowledgements The "Specification" text comes mostly verbatim from the Python Style Guide by Guido van Rossum [1]. (If it's OK with him, I will add GvR as an author of this PEP. I am quite confident that the BDFL doesn't want to own this PEP :-). Apart from minor editing, proposed additions to the Style Guide text are marked with '[+]' to the left of each line, and proposed omissions are marked with '[-]'. If it is deemed that this PEP is unnecessary, then it can be taken as suggestions for Style Guide modification.) This document borrows ideas from the archives of the Python Doc-SIG [2]. Thanks to all members past and present. Local Variables: mode: indented-text indent-tabs-mode: nil End: From hamish_lawson at yahoo.co.uk Sun Jun 3 14:30:37 2001 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: 3 Jun 2001 11:30:37 -0700 Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> <991574786.733151@nntp01.uskonet.com> Message-ID: <915a998f.0106031030.6eb037d1@posting.google.com> > I realise belatedly that, as this question has got nothing to do with > Python, it should not have been posted to this group. My apologies. > > Having said that, can anyone suggest an appropriate news group for this kind > of question. Probably comp.object. Hamish Lawson From robin900 at yahoo.com Thu Jun 14 10:19:27 2001 From: robin900 at yahoo.com (Robin Thomas) Date: 14 Jun 2001 07:19:27 -0700 Subject: PEP 259: Revise to remove context-driven magic from print References: <486de2.0106131406.5c0cbef9@posting.google.com> Message-ID: <486de2.0106140619.2cb4e8e6@posting.google.com> "Fredrik Lundh" wrote in message news:... > is this a joke of some kind? if not, it's clearly the most ignorant > and arrogant PEP proposal I've ever seen. > Well, that's pretty negative feedback. My apologies for the ignorance and arrogance. From qrczak at knm.org.pl Sat Jun 30 18:38:36 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 30 Jun 2001 22:38:36 GMT Subject: Augmented Assignement (was: Re: PEP scepticism) References: <9hklbe018lu@enews1.newsguy.com> Message-ID: Sat, 30 Jun 2001 15:47:36 +0200, Alex Martelli pisze: >> > + operation is different for different A type. >> >> But it never modifies A, > > "Never? Well, *hardly* ever" (music by Lord Sullivan, of course). Never under a sane design. >> I treat as a wart the fact that augmented assignment has a subtle >> difference between mutable and immutable objects. > > I do not consider polymorphism a wart, not even when it lets > you write horrid code as in "class sic" above. I don't consider polymorphism itself a wart, but this particular misuse of it. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From root at rainerdeyke.com Sun Jun 24 19:58:14 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Sun, 24 Jun 2001 23:58:14 GMT Subject: PEP 255: Simple Generators, Revised Posting References: Message-ID: "Bernhard Herzog" wrote in message news:m3k821snlr.fsf at intevation.de... > Being able to easily write a function that does nothing (in fact it's > the most trivial function one can write) is very useful in practice, so > as a generalization being able to write empty generators might be > useful, too. I'm not sure about that, though, because I don't have > enough experience with them. Of course it is. Consider: class Head: pass class Lion: def __init__(self): self.head = Head() def iter_heads(self, filter_fun): if filter_fun(self.head): yield self.head class Hydra: def __init__(self): self.heads = [Head() for i in range(7)] def iter_heads(self, filter_fun): for head in self.heads: if filter_fun(head): yield head class Slime: def __init__(self): pass def iter_heads(self, filter_fun): return yield None # This is a null generator Note that I *could* have simply returned 'iter([])' from 'Slime.iter_heads' for almost the same effect. I chose not to do this because consistency is a Good Thing. Now consider this: class Lion: def __init__(self): self.head = Head() def iter_heads(self, filter_fun): print 'Started iterating lion heads.' if filter_fun(self.head): yield self.head print 'Finished iterating lion heads.' class Hydra: def __init__(self): self.heads = [Head() for i in range(7)] def iter_heads(self, filter_fun): print 'Started iterating hydra heads.' for head in self.heads: if filter_fun(head): yield head print 'Finished iterating hydra heads.' class Slime: def __init__(self): pass def iter_heads(self, filter_fun): print 'Started iterating slime heads.' print 'Finished iterating slime heads.' return yield None # This is a null generator In this case, the non-generator 'Slime.iter_heads' would be long and messy. I'm almost certain that the non-empty non-yielding generator will become a common idiom. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From whisper at oz.nospamnet Thu Jun 21 17:04:44 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 21 Jun 2001 21:04:44 GMT Subject: Pythoin MUD (PyMUD?) References: <9gqq3t$hvs$1@brokaw.wa.com> <3dg0cvdkcs.fsf@ute.cnri.reston.va.us> Message-ID: <9gtnhc$n2e$0@216.39.170.247> In article <3dg0cvdkcs.fsf at ute.cnri.reston.va.us>, akuchlin at mems- exchange.org says... > Jonathan Gardner writes: > > 1) Is there any existing python muds out there? > > See http://www.strout.net/info/coding/python/poo/index.html. Its > author no longer works on it. (Didn't someone start a project to > continue maintaining POO?) > > --amk > > Poo became Moop and it's on sourceforge. http://sourceforge.net/projects/moop/ Dave LeBlanc From cristion at erols.com Mon Jun 4 13:22:13 2001 From: cristion at erols.com (John Cristion) Date: Mon, 04 Jun 2001 13:22:13 -0400 Subject: Newbie Question Message-ID: <3B1BC3C5.57F98FCD@erols.com> MATLAB vs. PYTHON Please compare and contrast for this MATLAB user and newbie to PYTHON (beyond the obvious cost, etc. issues) John A. Cristion Johns Hopkins University Applied Physics Laboratory 11100 Johns Hopkins Rd. Laurel, MD 20723-6099 Phone: 240-228-4735 FAX: 240-228-5928 email: John.Cristion at jhuapl.edu From kawakami at lead.dion.ne.jp Tue Jun 19 01:47:46 2001 From: kawakami at lead.dion.ne.jp (Toshiya Kawakami) Date: Tue, 19 Jun 2001 14:47:46 +0900 Subject: get class instance from C++ extension? References: <8kiW6.41$%3.2442@news3.dion.ne.jp> Message-ID: Martin von Loewis wrote: > > Is there any simple example for PyObject_CallFunction()? > > Please have a look at Objects/readline.c. There, you have I found Modules/readline.c instead. The PyObject_CallFunction() seems NOT to be a solution for what I want to do. (wrong?) Returning to my first question, > > How can I return a same information with a python class from C++? ---test1.py > > ### I want to call C++ extension and get calss c1 instance to y > > y = myext.meth1( 5, 6, 7.2 ) > > ### and want to print attributes of the got y. > > print y.a1, y.a2, y.m1() ---static PyObject *method() > > // I want to return not an integer but the same structure with > > // the class c1 defined in test.pi file. How can I do that? I want to know how should I write codes of the callee C++ method to return a class instance to the caller python codes, and want to see examples like following process. Are there any examples for this? (1) A python code calls a method extended by C++. (2) The python code gets a class instance from the C++ method. The class instance must be defined in the caller python code, or the caller python code must be able to get class format (what attribute and methods are included in it) from the callee C++ method. (3) The Returned class instance ("y" above) has attribute and methods, and the caller python code can print them as "print y.a1, y.a2, y.m1()". For details about what I want to do, please read my sample codes in the original message. -- From nperkins7 at home.com Sun Jun 3 16:30:45 2001 From: nperkins7 at home.com (Nick Perkins) Date: Sun, 03 Jun 2001 20:30:45 GMT Subject: random References: Message-ID: > "Alex Martelli" wrote: > |"Even given (a powerful army) I could not (defeat Napoleon)". > |Do you read this as "having a powerful army IMPLIES I > |cannot defeat Napoleon"? This doesn't sound right to me. > |Surely it's "NOT (having a powerful army IMPLIES I can > |defeat Napoleon)"? > "Lulu of the Lotus-Eaters" wrote in message news:mailman.991581425.24043.python-list at python.org... .. quanta and Laplacian fantasies.. .. implicature .. interlocutor.. .. negative epistemic attitude.. .. material conditional.. Sounds neat, but I only know simple logic. Here's my take on the difference: P : Powerful army D : Defeat Napoleon A: (P implies (not D)) "Given a powerful army, I could not defeat Napolean" B: (not (P implies D)) "Having a powerful army would not ensure that I could..." truth table: P D A:(P implies (not D)) B:(not (P implies D)) 0 0 1 0 0 1 1 0 1 0 1 1 1 1 0 0 The difference is that statement A is true if P is false, whereas statement B can only be true if P is true. Therefore, statement B implies that P is false. So the statement "NOT( (powerful army)implies(deafeat Napolean))" itself implies that "I do not have a powerful army" And the statement"Having a powerful army implies I could not defeat Napolean" says nothing about whether P (powerful army) is true" Otherwise the two statements are the same. Sorry if i am stating the obvious, I just wanted to convince myself that these things are not so complicated. From kvdwalt at csir.co.za Wed Jun 13 02:52:52 2001 From: kvdwalt at csir.co.za (Karel van der Walt) Date: Wed, 13 Jun 2001 08:52:52 +0200 Subject: Integrating a Python GUI into a PowerBuilder App References: <49624b0b.0106121135.61b6bd6c@posting.google.com> Message-ID: <9g72li$e1$1@newnews.mikom.csir.co.za> Can the java DataWindow not be integrated with (J)Python ? "Brad Bollenbach" wrote in message news:euyV6.14009$SJ1.2493866 at news1.rdc1.mb.home.com... > I work as a full-time Powerbuilder developer, and wish for pretty much *any* > other development tool than it to do my work (even if the language was > excellent, Powerbuilder's IDE is /nasty/. But as it turns out Powerbuilder's > language -- Powerscript -- is even worse anyways :). > > The problem I can see though is coming up for an alternative to datawindow > controls/objects. Unfortunately, I don't have any experience in what you're > trying to do, but am more hoping to gain some insight from anyone else's > replies to this thread. > > "John Urberg" wrote in message > news:49624b0b.0106121135.61b6bd6c at posting.google.com... > > Hi all, > > > > We are looking into languages to replace PowerBuilder in our shop. > > The kicker is that we need to slowly migrate to the new language so > > the choice would have to be able to integrate into a PowerBuilder MDI > > application. I'd really like to push Python as the new language, but > > I need to find a way to seemlessly integrate a Python GUI into the > > PowerBuilder app (i.e. as child windows of the MDI). I would expect > > we would want to use wxPython being as that is the closest to standard > > Windows look and feel. > > > > Any ideas on how I can accomplish this? > > > > Thanks in advance, > > John Urberg > > From Helka.Folch at wanadoo.fr Sun Jun 24 04:57:44 2001 From: Helka.Folch at wanadoo.fr (Helka.Folch) Date: Sun, 24 Jun 2001 10:57:44 +0200 Subject: problem installing PyXML on Linux Message-ID: <9h4au7$2j2$1@wanadoo.fr> I'm trying to install PyXML-0.0.6.5.-1 on linux (suse 7.1). When I tried to install the rpm, I got the following message: dependancy problem /usr/local/bin/python is needed by PyXML-0.0.6.5.-1 (on my system, python exec is /usr/bin/python2.0) On the other hand, when I tried to install PyXML from the source file with : python setup.py -q install I got the following error message: extensions/pyexpat.c:4 Python.h No such file or directory extensions/pyexpat.c:5: Compile.h No such file or directory extensions/pyexpat.c:6: frameobject.h No such file or directory error : command 'gcc' failed with exit status 1 do you know what I've done wrong? Many thanks From tim.one at home.com Thu Jun 7 01:03:37 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 7 Jun 2001 01:03:37 -0400 Subject: Working with paths with spaces in NT In-Reply-To: <9fn0o3$9d3$0@216.39.170.247> Message-ID: [David LeBlanc] > import os > import dircache > import re > > > def getDirs(path, tabs): > dirlist = [] > os.chdir(path) > for dir in dircache.listdir("."): > if os.path.isdir(dir): > dirlist.append(dir) > print dirlist > for dir in dirlist: > print dir > getDirs(dir, tabs + 1) > > getDirs("L:/languages/python", 1) > > This will report: [k:/Python21/Projects]% python FileList.py > ['Apps', 'CVS', 'Database', 'Distributions', 'Docs', 'Tools', 'libs'] > Apps > ['ThoughtStream', 'XML', 'moop'] > ThoughtStream > ["A Gentle Introduction to Ted Nelson's ZigZag Structure_files", > 'ThoughtStream Design notes_fil > es', "ThoughtStream User's Guide_files", 'XML Topic Maps (XTM) 1_0 > errata_files', 'XML Topic Map > s (XTM) 1_0_files', 'XML Topic Maps (XTM) Processing Model 1_0_files'] > A Gentle Introduction to Ted Nelson's ZigZag Structure_files > [] > ThoughtStream Design notes_files > Traceback (most recent call last): > File "k:\python21\projects\FileList.py", line 17, in ? > getDirs("L:/languages/python", 1) > File "k:\python21\projects\FileList.py", line 15, in getDirs > getDirs(dir, tabs + 1) > File "k:\python21\projects\FileList.py", line 15, in getDirs > getDirs(dir, tabs + 1) > File "k:\python21\projects\FileList.py", line 15, in getDirs > getDirs(dir, tabs + 1) > File "k:\python21\projects\FileList.py", line 8, in getDirs > os.chdir(path) > OSError: [Errno 2] No such file or directory: 'ThoughtStream Design > notes_files' > > How do I process directory names with spaces? I looked through the python > doc, but didn't see anything. If you look at your output very carefully, you'll discover this has nothing to do with spaces. After all, you chdir'ed to A Gentle Introduction to Ted Nelson's ZigZag Structure_files just fine. If that's not enough of a hint, try this starting in some deep directory tree that doesn't have any spacey names. don't-use-relative-paths-unless-you're-sure-you-know-where-you- are-ly y'rs - tim From s_gherman at yahoo.com Mon Jun 11 03:00:41 2001 From: s_gherman at yahoo.com (Sorin Gherman) Date: 11 Jun 2001 00:00:41 -0700 Subject: detecting idle processor Message-ID: How can I use Python to detect when the processor is idle? Or when the network traffic is idle, for a given computer? I need this to implement a background program. Thanks in advance, Sorin Gherman From gregory_engel at csgsystems.com Thu Jun 28 14:06:24 2001 From: gregory_engel at csgsystems.com (Gregory Engel) Date: Thu, 28 Jun 2001 12:06:24 -0600 Subject: Building 2.1 Issues Message-ID: <01C0FFCA.C13708E0.gregory_engel@csgsystems.com> I've hit a bit of a wall trying to compile Python 2.1 on a Linux 6.2 box. I first run: rpm --rebuild python2-2.1-5.src.rpm and get back: Installing python2-2.1-5.src.rpm error: failed build dependencies: expat-devel >= 1.1-3tummy is needed by python2-2.1-5 db1-devel is needed by python2-2.1-5 OK. So I run: rpm -q expat and get back: package expat is not installed So I run: rpm --rebuild expat-1.1-3tummy.src.rpm The last few lines read: ... Executing(--clean): /bin/sh -e /var/tmp/rpm-tmp.97776 + umask 022 + cd /usr/src/redhat/BUILD + rm -rf expat + exit 0 Looks OK. So I run: ls -al /usr/src/redhat/RPMS/i386/expat* And get: -rw-r--r-- 1 root root 93246 Jun 28 11:57 /usr/src/redhat/RPMS/i386/expat-1.1-3tummy.i386.rpm So I run: rpm -i /usr/src/redhat/RPMS/i386/expat-1.1-3tummy.i386.rpm rpm -q expat And get: expat-1.1-3tummy Looks good. So I run: rpm --rebuild python2-2.1-5.src.rpm and STILL get back: Installing python2-2.1-5.src.rpm error: failed build dependencies: expat-devel >= 1.1-3tummy is needed by python2-2.1-5 db1-devel is needed by python2-2.1-5 What am I missing? Any suggestions on where to look would be greatly appreciated. C'ya, Gregory Engel Senior Software Engineer Professional Services CSG Systems, Inc. 9555 Maroon Circle Englewood, CO 80112 Voice: 303-200-3426 From trace at reinventnow.com Wed Jun 13 11:15:20 2001 From: trace at reinventnow.com (tracy s. ruggles) Date: Wed, 13 Jun 2001 15:15:20 GMT Subject: Installing new packages on a VPS? Message-ID: Has anyone out there had experience installing new packages on a VPS (virtual private server)? I've posted a few question about trying to install MySQLdb and haven't received any response... Are there any tricks to installing on a VPS? All of the code in distutils/sysconfig.py spits out wrong directory paths for the include and header directories. I've tried altering that code but to no avail... I still get this error: building '_mysql' extension gcc -g -O2 -Wall -Wstrict-prototypes -fPIC -I~/usr/local/mysql-3.23.38/include/mysql -I/usr/home/ol0401/usr/local/Python-2.1/Lib -c _mysql.c -o build/temp.solaris-2.6-sun4u-2.1/_mysql.o _mysql.c:31: Python.h: No such file or directory _mysql.c:40: structmember.h: No such file or directory _mysql.c:41: mysql.h: No such file or directory _mysql.c:42: mysqld_error.h: No such file or directory _mysql.c:43: errmsg.h: No such file or directory error: command 'gcc' failed with exit status 1 Does anyone know what's going? Thanks, Tracy -- Tracy S. Ruggles -- COPI / OutputLinks -- http://www.outputlinks.com Email) TR at 888999copi.com Phone) 888/999.copi ext "TR" From alessandro.manotti at bfeurope.com Fri Jun 8 07:43:39 2001 From: alessandro.manotti at bfeurope.com (MANOTTI Alessandro) Date: Fri, 8 Jun 2001 13:43:39 +0200 Subject: B.Y.P. Server Message-ID: <1B0456E7DDC4D21191810008C70DCB49F92724@ROMENT01> Dear all, I created a very special server: I'm creating a software, written in Python, to mix the advantages of Internet (server web) and a client/server structure. Traditional web servers use a "state-less" system, in-fact when a browser requires some information to the server, in the server machine will be launched a CGI, or PHP/ASP (etc...) script and, when the request was satisfied, the connection can be considered "terminated": the programs (maybe CGI) which answered were terminated. I'm creating a system in which the server launches some threads (programs which substitute the CGI) and they remain active until the client exits from the application or with a time-out. I'm creating the server thinking to Macromedia Flash 5 as client (that's why I'm writing to you) (with this software, I can create very actractive programs, just like a beautiful and very functional graphic terminal client). With my project I intend to join the advantages of an Intranet/Extranet/Internet system with the advantages of a client/server system. One of the major targets is to simplify the server side programming: in-fact I wish let youcreate a program with the same technics that you use to create a local oriented software! Of course, there are a lot of things to do, but I installed this system in my company (a big company) and it functions very well! Furthermore, is very simple to write programs! (There are not the difficults that you can encounter creating programs for standard web servers!!!) Now the biggest problem I have, is maintain updated the documentation! This project is licenced under GPL. If you are interested about my project (my server runs in a 24x7 cycle, since it implements a dynamic loading of new modules, daemons, server routines) please send me an e-mail or visit my site! Thank you very much for the attention you gave me!!! Alessandro Manotti manotti at bigfoot.com http://members.xoom.it/bypserver From m.faassen at vet.uu.nl Tue Jun 19 18:56:52 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 19 Jun 2001 22:56:52 GMT Subject: Upon reflection... References: <20010614163301.G18379@mail.coursepeek.com> Message-ID: <9golbk$e9m$1@newshost.accu.uu.nl> Rod Weston wrote: > I sympathize with your frustrations concerning my methods in my quest. > And I agree that I may end up 'collecting' languages if I become > frustrated with Ada, but I have made a serious effort to minimize the > possibility. [snip] > It's here that I > learned about the apparent slowness of Python - well, that and trying > the Python Solitaire game. Hm, I hadn't noticed any particular slowness with PySol. What's slow in PySol? Perhaps the startup time? It's of course true that Python code currently can't be optimized by compilers like C or C++ or Ada or Java can be. But there's a difference between 'slower' and 'too slow'. That Python is slower than many languages on many tasks can be shown with benchmarks (though I suspect the slowdown on real world applications is actually not as high as some benchmarks would indicate). That Python is *too slow* depends entirely on the task at hand, and for very many applications it isn't too slow. > I'm open to hearing more and I'm not going > to stop reading the newsgroup just because I've made a decision. > Python is very, very popular - Interesting; you got definitely a different impression about Python's popularity than people got even a couple of years ago. [snip] > I just wanted to > provide my feedback to the excellent folk who have generously given of > their time and expertise to my quest. I sort of lamented there was so little of it; also perhaps on the caveats we gave on your criteria; Ada will definitely suit your criteria better than Python, but your criteria are open to questioning themselves. [snip] > I'll give you all some feedback in another > six months, after I have some solid experience under my belt - though > it will not be qualified comparison with Python nor will I represent > it as such. I'm very curious about hearing about your experience. I wish you luck. While I agree that playing with languages (or better yet, code some real project in them) to learn more about them is one of the important things you should do when selecting a language, giving matters some careful thought can't hurt either! At least you're venturing in a different direction than you're used to, so you'll definitely learn a lot. Thanks and regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From kentsin at poboxes.com Mon Jun 18 10:13:14 2001 From: kentsin at poboxes.com (Sin Hang Kin) Date: Mon, 18 Jun 2001 22:13:14 +0800 Subject: How to organize substite function with side effects Message-ID: <9gl2l4$q7j14@ctmsun0.macau.ctm.net> The following code download the file from web, and remove missing tags from it. Since it need to keep track of the link queue, baseurl and localstorage, I decide to warp it in a class: class urlgraber: def __init__(self, baseurl, localpath): self.baseurl = baseurl self.urlq = [] self.localpath = localpath def retrieveimage(self, url): try: (fn, hdr) = urllib.urlretrieve(self.baseurl+url, self.localpath+url) return 1 except: return 0 # retrieve the image, return true if the retrieval success def downloadpage(self, url): # download page .... # now, use re.sub to subst images: re.sub(imagepat, substfunc, page, 0) The idea is that substfunc is called with the . it then extract the url, call retrieve image, and return either or as result. The problem is, it is very confuse to get the localpath and baseurl between them. Can somebody help me re-organize this? What is the proper way to do this in python? -- Rgs, Kent Sin --------------------------------- kentsin at yahoo.com From akuchlin at mems-exchange.org Fri Jun 22 07:10:24 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 22 Jun 2001 07:10:24 -0400 Subject: [OT] MS EULA -- (will ActiveState become outlaws? ;-) References: Message-ID: <3dwv643h3z.fsf@ludwig.cnri.reston.va.us> "Tim Peters" writes: > I don't think so. All the licenses mentioned (including Perl's Artistic > License) obligate (under most circumstances) the licensee to provide source > for any changes they may make; no version of the Python license requires > that. But I'm neither a lawyer nor Bill Gates, so cutting open a chicken The text seems confused; it starts off talking about "Viral Software", and then gives as an example of "Viral Software", software developed "as free software". It also doesn't explain what "in conjunction with" means; on the same CD? Linked together? I assume Dick Hardt of ActiveState is off bending some ears at Microsoft about this, and it'll get clarified or, perhaps, dropped. --amk From db3l at fitlinxx.com Wed Jun 20 20:52:32 2001 From: db3l at fitlinxx.com (David Bolen) Date: 20 Jun 2001 20:52:32 -0400 Subject: PEP 255: Simple Generators References: <9gnv2o$its$1@nntp6.u.washington.edu> Message-ID: "Rainer Deyke" writes: > "David Bolen" wrote in message > news:ur8wevrz0.fsf at ctwd0143.fitlinxx.com... > > But isn't a generator really just a function that is returning an > > iterator? That is, why is it "very" different from a function, > > internal implementation aside, which we agree it's not necessary to > > reveal. > > o = f() > > To the caller, it doesn't matter if 'f' is a function, a generator, a bound > method, a class, or any other callable object. That does *not* mean that > functions, generators, classes and other callable objects should have the > same syntax: they are fundamentally different ways of implementing callable > objects. But neither does it necessarily mean they all need different syntax. It seems that much of the disagreement here lies in whether someone thinks that a function serving as a generator has "crossed the line" beyond what a typical function (using the standard definition syntax) ought to be able to do without special notation (beyond yield). I suppose that means there's no single answer, since I think that line is far from black and white given all the possibilities for functions today. > If generators absolutely have to reuse syntax (which is not the > case), I would prefer the keyword 'class' over 'def', since calling a > generator creates an instance. But so does any number of factory functions that return objects (form closures, etc...), e.g.: def f(): return UserList.UserList([1,2,3]) (using UserList to avoid the type/class question) So do we need different syntax for all types of functions that might return instances of some object? Eventually this could devolve into the point elsewhere in the thread of wanting defint rather than def for functions returning an integer. > Reusing 'class' also increases readability > since it's easier to see the difference between a generator and a class by > looking at the contents. I guess I just don't see why this generator PEP needs such a change, but clearly different people can differ on this :-) -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From legere at adelphia.net Sat Jun 23 06:32:46 2001 From: legere at adelphia.net (Ronald Legere) Date: Sat, 23 Jun 2001 10:32:46 GMT Subject: algebraic datatypes Message-ID: I would like to define something like the scheme 'define-datatype' macro (from Essentials of programming languages 2) in python. Essentially, datatype Tree = Node Tree Tree | Leaf Int should translate into a class structure like this: #class Tree # abstract class Node: def __init__ (self, atree,atree) self.r = atree self.l = atree # and some accessors etc... class Leaf: def __init__ (self,anint) self.aninit = aninit # AND so on.... Is this something that I can do? Should I use the parser library and make a preprocessor? Is this to hard to do that way? Is there an easier way?? Am I missing something? Cheers! From aleaxit at yahoo.com Wed Jun 13 17:42:48 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 13 Jun 2001 23:42:48 +0200 Subject: Inner classes References: <3b27a1aa.6747983@news.laplaza.org> <3dae3cfcl4.fsf@ute.cnri.reston.va.us> <3B27BE5F.4DCB4894@inf.ethz.ch> Message-ID: <9g8mko0ms1@enews1.newsguy.com> "Samuele Pedroni" wrote in message news:3B27BE5F.4DCB4894 at inf.ethz.ch... ... > > class C: > > class inner: > > ... stuff for inner class > > ... stuff for class C > > > > --amk > > Yes, but that's basically a static inner class, you can do > > C().inner() but the created inner instance will not contain any > implicitly created reference to the C instance. > > To have that you must be explicit: > c=C() > i=C.inner(c) Explicit is better than implicit, but it's absolutely no problem to have client-code call C().inner() and have the returned innerclass instance know about the C instance that created it -- you just have to place your explicitness in the classes in question, e.g.: class C: class __inner: def __init__(self, c): self.c = c # add whatever else you want in inner def inner(self): return self.__inner(self) # add whatever else you want in C >>> c=C().inner() >>> c <__main__.__inner instance at 0079B48C> >>> c.c <__main__.C instance at 0079C58C> >>> Alex From curt at hagenlocher.org Tue Jun 12 12:25:49 2001 From: curt at hagenlocher.org (Curt Hagenlocher) Date: 12 Jun 2001 09:25:49 -0700 Subject: OT: Python Twins Message-ID: http://www.spiegel.de/wissenschaft/0,1518,139129,00.html Two Python snakes were born from a single egg -- an extremely rare occurence. An extremely poor English translation is available at http://babel.altavista.com/?urltext=http%3A%2F%2Fwww.spiegel.de%2Fwissenschaft%2F0%2C1518%2C139129%2C00.html&lp=de_en courtesy of Babelfish. Unfortunately, the German word "Schlange" can translate as either "snake" or "queue"... -- Curt Hagenlocher curt at hagenlocher.org From dsh8290 at rit.edu Sat Jun 30 13:15:55 2001 From: dsh8290 at rit.edu (D-Man) Date: Sat, 30 Jun 2001 13:15:55 -0400 Subject: the center of the world (was Re: Check out O'Reilly's Open Source Convention Highlights) In-Reply-To: <9hhvk901f2a@enews2.newsguy.com>; from aleaxit@yahoo.com on Fri, Jun 29, 2001 at 03:24:58PM +0200 References: <3B3AA82D.1A0FE860@seebelow.org> <3B3B2DED.5303198A@seebelow.org> <9hhri7019jd@enews2.newsguy.com> <9hhvk901f2a@enews2.newsguy.com> Message-ID: <20010630131555.A22215@harmony.cs.rit.edu> On Fri, Jun 29, 2001 at 03:24:58PM +0200, Alex Martelli wrote: | "Konrad Hinsen" wrote in message | news:m366df8mcy.fsf at chinon.cnrs-orleans.fr... | > "Alex Martelli" writes: | > | > > to 'population centers'. Of course I could get different | > > centers by choosing different weighing factors (country GNP | > > rather than country population, for example). | > | > Or by Python expertise ;-) | | Know any freely available databases indicating latitude | and longitude of Python experts...? I think you already have all the data points you need from that database . | > What's so bad about it? Searching for a global minimum in two | > variables is not so difficult. All the more within finite coordinate | > intervals. Of course there might be no global minimum at all. | | Think positive -- there may be SEVERAL locations that are | global minima... Must think positive, must think positive, ... maybe the next one will be at my house ! -D From aleaxit at yahoo.com Mon Jun 11 15:00:40 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 11 Jun 2001 21:00:40 +0200 Subject: Global in multiple files References: <9g212o0260r@enews2.newsguy.com> Message-ID: <0a3a01c0f2a9$3c124900$0300a8c0@arthur> "Don Dwiggins" writes: ... > > There is a serious risk in over-designing systems "because > > one day it might be handy". Yeah, right, but meanwhile you're > > paying the price of complexity *RIGHT NOW*!-) > > > "Do the simplest thing that could possibly work", because > > "you ain't gonna need it" (where "it" is the rich, complex, > > over-engineered, over-designed very general solution:-). > > > See http://c2.com/cgi/wiki?YouArentGonnaNeedIt ... > > I agree. And while you're there, check out the other Extreme Programming > principles. To me, the thing that makes this principle "work" is its > combination with the other principles (most directly "Refactor > Mercilessly"). The synergy between the various XP principles and practices is one of its most interesting aspects. Pairwise programming feeds into simplicity-seeking, exhaustive testing secures refactoring isn't breaking things, etc. But the risk of over-ambitious, over-general design is not one that XP "invented" (or even "discovered":-) -- it's there all the time. Simplicity and refactoring are XP's recipes against this risk, but the risk is there no matter what (indeed, it's surely higher the heavier and more invasive your process... in any sort of design-it-all-up-front "waterfall", it's _ruinous_:-). > Also, remember that "simplest thing" doesn't mean "the first thing that > comes to mind". It can take some serious contemplation to come up with the > simplest thing. Einstein's advice is also useful here: "make things as > simple as possible, but no simpler". No doubt. Some are born to simplicity, some have simplicity thrust upon them... and some *achieve* simplicity with much toil. But remember the specifics of what we're talking about: taking a simple list and overgeneralizing it into an ambitious "user-administration subsystem" (and this, *WITHOUT* solving the issue that the original poster had asked about...!-). Alex _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From aleaxit at yahoo.com Mon Jun 18 04:59:32 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 18 Jun 2001 10:59:32 +0200 Subject: Python version of IQ has been updates (IQ v0.34.python) References: <505.566T11T1243597threeseas@earthlink.net> <3B2A7F5E.MD-1.4.4.padf@ihug.com.nz> <3871.567T2214T9794928threeseas@earthlink.net> <87puc3ao42.fsf@pooh.honeypot> <2509.568T2823T9766233threeseas@earthlink.net> Message-ID: <9gkftm026v9@enews2.newsguy.com> "Timothy Rue" wrote in message news:2509.568T2823T9766233threeseas at earthlink.net... ... > Alex Martelli said a few things regarding the RE pattern matching between > Python and Perl and some other comparisons. > > Is Perl syntax as easy to read as python, for the beginner? For regular expressions, they're extremely similar, and both VERY hard-going for a beginner. Outside of regular expressions, I do not think anybody would claim Perl's concise syntax is anywhere near as easy-to-read as Python's clean and spare one. > Can perl be compiled into byte code for faster startup or put into a stand > alone application? Or is Perl strickly an interpreted language? Both:-). You can *buy* "Perl compilers" (e.g. from ActiveState and IndigoPerl -- are there others?) that are roughly equivalent to what you can do with the free py2exe and McMillan's "install" for Python. I doubt those support the Amiga (not sure, though). py2exe is also Windows-only I think. McMillan's stuff is rather cross-platform but, again, I dunno 'bout Amiga support specifically. > So I guess the question is whether or not such translators are available > to perl? Commercially, yes, but maybe not for the platform you desire. > Of course you can port IQ to Perl if you want, but in any case (perl, > python, rebol, arexx) it'd be nice to incorporate into IQ, the ability to > access files thru the internet in a way that is as simple as accessing a > file on the system you are using IQ on. If you use Python, that's trivial -- just open the URL string with urllib.urlopen, exactly like you would open a filepath string with the builtin function open, and you'll get a file(-like) object ready for reading through all the usual fileobject methods (.read, readline, etc etc). If the URL is actually a filepath, urllib.urlopen just delegates the work to the built-in open, so you can also choose to ALWAYS use urllib.urlopen (when you're opening for _reading_, of course -- if you open for *writing*, it's different:-) and it just works. Not sure what the other scripting languages offer for this. Alex From dsh8290 at rit.edu Wed Jun 6 12:54:15 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 6 Jun 2001 12:54:15 -0400 Subject: Grail Python2.1 In-Reply-To: <9flevu$495$1@wanadoo.fr>; from salvatore.didio@wanadoo.fr on Wed, Jun 06, 2001 at 04:41:29PM +0200 References: <9flevu$495$1@wanadoo.fr> Message-ID: <20010606125415.D12381@connecticut.cs.rit.edu> On Wed, Jun 06, 2001 at 04:41:29PM +0200, Salvatore DI DIO wrote: | I'm running Python2.1 on Solaris2.6 with Tkinter. I can't launch Grail. | I have a socket error in MyHTTP module | | Did anybody experienced the same problem | | Thank you very much. | | BTW : All is fine with Python 1.52 Wasn't the socket library one of the places where the type of the argument list was fixed to match the documents in verison 2.0? Something like func( 1 , 2 ) used to be accepted due to an implementation accident, but now it is required to be func( (1 , 2) ) -- a single 2-tuple argument? Grail is, unfortunately, unmaintained anyways. -D From just at letterror.com Fri Jun 8 11:00:58 2001 From: just at letterror.com (Just van Rossum) Date: Fri, 08 Jun 2001 17:00:58 +0200 Subject: How do you develop in Python? References: <050620011516094693%pecora@anvil.nrl.navy.mil> <3B1FCFA5.BA4AF4A0@home.net> <080620010823418583%pecora@anvil.nrl.navy.mil> Message-ID: <3B20E8A8.2A97D9B3@letterror.com> "Louis M. Pecora" wrote: > > Just van Rossum wrote: > > > > > It's simple: if you modify B.py, _run_ B.py to refresh it (*). A.py will see > > > the changes. It's hardly ever neccesary to quit the MacPython IDE. > > > > > > *) In other words: if B.py has already been imported, running it it will > > > execute it in B's old namespace, effectively refreshing it for everybody > > > to see. > > > > This is a classic, why didn't I think of that? solution. I think I will > > still use my method for stuff I'm changing a lot, it is less likely that > > I will forget to do the refresh. > > Just's solution works, but it has the problem that if you change B and > C and D depend on B and are used in A, then C and D have to be run, too > before you run A. I stumbled on that one. It depends: this is only true if C and D either derive from classes in B or do "from B import *". The latter you should avoid anyway, but the former can be a real pain indeed. *However* there is another little known feature in the MacPython IDE that can be extremely handy: you can "reload" individual methods. You do this by selecting the method(s) and choose "Run selection" (or hit enter). This inserts the updated code into the *existing* class object. Beware, though: methods below the section you changed now have different line numbers, but the code objects don't know that, so tracebacks might point you to the wrong line. It's a hack, but I find it extremely useful. Think about it: it even updates existing *instances* as it updates a class in place! It's hacking on live objects... Just From ullrich at math.okstate.edu Sun Jun 24 12:23:51 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 24 Jun 2001 16:23:51 GMT Subject: Is this a true statement? References: <3b34939b.410758@nntp.sprynet.com> <3b35ebc3.1024709@nntp.sprynet.com> <9h516e$c2a4d$1@ID-11957.news.dfncis.de> Message-ID: <3b3611b0.10735139@nntp.sprynet.com> On Sun, 24 Jun 2001 08:28:25 -0700, "Emile van Sebille" wrote: > >"David C. Ullrich" wrote in message >news:3b35ebc3.1024709 at nntp.sprynet.com... >> On Sat, 23 Jun 2001 09:36:13 -0500, "Chris Gonnerman" >> wrote: >> > >> Seriously. _Is_ a "device driver" something other than a file? >> If it _is_ something other than a file I wish someone would >> say so. If a device driver is just a file then I don't see >> how the OS can possibly know or care how that file was >> generated. >> >> > >Of course not. And of course a file can be written by python that the os >can subsequently use as a device driver. To do so, you will have written >both a compile-to-bytes program and a device-driver-source file intended to >be consumed by the compiler piece. That's what I thought. Seems clear. Makes it hard to see how the statement "you cannot write a device driver in Python" can be correct. > When this result is invoked by the os, >it will not be a python program running within the interpreter. And if you write a device driver in C then when that driver is invoked by the OS it _is_ a C program being interpreted by the compiler? Or is it machine code being interpreted by the OS? (The second, of course. So what's the difference between Python and C in this regard?) Whether anyone belives it or not, I _did_ have actual questions at the start of this. It was said that you cannot write a device driver in Python because Python cannot access hardware interrupts (or whatever). I don't see how a program _writing_ a device driver needs to do that, so I don't see what it has to do with whether you can write a device driver in Python. >Generally speaking, writing a device driver is not thought of as similar to >copying a driver file from floppy, then saying that even something as simple >as cp or copy can be used to "write" a device driver. > But to write that device driver in Python or any other language you don't need to have a copy of the driver, you just need a clear specification of exactly what the driver is supposed to do, plus a specification of what machine code is required to get the OS to do a certain thing. >-- > >Emile van Sebille >emile at fenx.com > >--------- > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From tim.one at home.com Wed Jun 27 00:53:33 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 27 Jun 2001 00:53:33 -0400 Subject: PEP 255: Simple Generators In-Reply-To: <3B39596B.D7450A54@cosc.canterbury.ac.nz> Message-ID: [Paul Prescod] > Others seem to want to teach them alongside other flow control > keywords. [Greg Ewing] > You might get away with teaching generators without > mentioning iterator objects if you say that they can > only be called in a special context, i.e. > > for x in g(): > > and that each time you hit a yield, the value gets > bound to x and the for-loop body is executed, then > execution resumes after the yield. That's what works for teaching generators in Icon, except that Icon also has many other kinds of "special context" where generators act reasonably. >From the examples posted here and on the Iterators list, it should be clear that, when you stick to for-in, how you create, call, use, and think about generators is the same as how you do all that stuff for non-generator functions that return a list, s/result.append(x)/yield x/g. The ability to name the iterator object is definitely more advanced. If an educational implementation of Python akin to DrScheme got created, it would be good to make the "beginner's level" raise an exception if a generator were called outside a for-loop context. From rdsteph at earthlink.net Sat Jun 2 22:57:14 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Sun, 03 Jun 2001 02:57:14 GMT Subject: why huge speed difference btwn 1.52 and 2.1? References: <9f8fgs$ooo$1@knot.queensu.ca> Message-ID: <3B18587D.11851C1B@earthlink.net> I'd like to hear an answer to this also. Have you come up with any ideas? Anyone else??? robin senior wrote: > I have a pretty simple script for processing a flat file db, running on > Python 2.1; I tried running it under 1.52 for kicks, and to my surprise it > ran almost 10 times as fast! Could someone let me know why 2.1 would be so > much slower? > > Cheers, > -robin > > ################## > > import re > import string > > states = { > 'ALABAMA':'AL', > 'ALASKA':'AK', > 'ARIZONA':'AZ', > 'WISCONSIN':'WI', > 'WYOMING':'WY'} > > for year in range(1994, 1998): > > f = open('states/USA'+str(year)+'.TXT') > counter = 1 > while(1): > print str(year), counter > counter = counter + 1 > > #convert city name to allcaps (change to string.strip(f.readline()) > in 1.5.2) > line = string.upper(f.readline().strip()) > > #check for EOF > if not line: > break > > for state in states.keys(): > #(STATENAME) OR (STATE ABBREVIATION) > if ( (re.search(' '+state+'( |,)', line, re.IGNORECASE)) or > (re.search(' '+states[state]+'( |,)', line, re.IGNORECASE)) ): > filename = string.replace(state, ' ', '_') > g = open('states/'+filename+'/'+str(year)+'.TXT', "a") > g.write(line) > g.write("\n") > g.close() > f.close() From gregj at pobox.com Sat Jun 16 13:38:53 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Sat, 16 Jun 2001 17:38:53 GMT Subject: Using the While Loop References: <20010616.101117.1469262009.1725@behemoth.miketec.com> Message-ID: Python assignments are statements, not expressions. You are probably used to C, C++, or Java. In Python the statement "line = myfile.readline()" is not an expression and doesn't have a value, so it's not syntactically valid following if or while. Your second example is the canonical Python form for reading lines sequentially from a file. Of course there are alternatives. The file method readlines() reads the entire file into a list of lines, so you can iterate over the file like this: for line in f.readlines(): print line That's not efficient for large files, though, because the entire file is read into memory by readlines(). Python 2.1 introduced the more efficient xreadlines module, which lets you efficiently iterate over lines in a file without reading it all into memory first: import xreadlines for line in xreadlines.xreadlines(f): print line Greg Jorgensen PDXperts LLC Portland, Oregon, USA gregj at pdxperts.com "Mike Johnson" wrote in message news:20010616.101117.1469262009.1725 at behemoth.miketec.com... > Hello all, > > I don't see why this first code snippet won't work, but I can't find any > pointers in the documentation. > > -------------------------------------- > #!/usr/bin/python2.1 > > myfile = open ("/tmp/messages") > > while line = myfile.readline(): > print line > -------------------------------------- > > But this works fine: > -------------------------------------- > #!/usr/bin/python2.1 > > myfile = open ("/tmp/messages") > > line = myfile.readline() > while line: > print line > line = myfile.readline() > -------------------------------------- > > Thanks for any help! > > - Mike Johnson > > > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- > http://www.newsfeeds.com - The #1 Newsgroup Service in the World! > -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From boyd at insultant.net Thu Jun 7 15:49:19 2001 From: boyd at insultant.net (Boyd Roberts) Date: Thu, 7 Jun 2001 21:49:19 +0200 Subject: integers References: <9fjd8q$qb6$1@charm.magnus.acs.ohio-state.edu> <9fjgqf$rp0$2@brokaw.wa.com> <3B1FD0C6.AB148906@home.net> Message-ID: <9folul$6va$1@neon.noos.net> "Chris Barker" a ?crit dans le message news: 3B1FD0C6.AB148906 at home.net... > That would be silly, as neither ++i nor i++ returns a value anyway. They > eouls be indentical. in C they do return a value and they are NOT identical. i don't see the problem with python objects being immutable. just re-write i++ as i = i + 1. From scarblac at pino.selwerd.nl Sun Jun 17 05:44:06 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 17 Jun 2001 09:44:06 GMT Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> Message-ID: David LeBlanc wrote in comp.lang.python: > As for the distinction between const(ant) and alias: Perhaps it's a > matter of aesthetics, but somehow alias is more descriptive then const > since it suggests the substition that's happening. Further, it's > incorrect to call "alias true: not 0" a constant imho. To further > belabour (with a tip of the hat to the english cousins) the point, it > read so nicely to be able to say "if something is true" rather then "if > something is not 0" (saves on typing too :-)). That should read "if something:". I think 'is true' is bad for a few reasons: - You rely on an implementation detail, namely that two instances of the number 1 will be interned to the same object; that might change. '== true' is better. - 2 and "whee" are just as much true in Python, but your 'if' treats them as false. - Something like 'if (a and b) is true:' does not do what it seems to do, since boolean operators don't return 0 or 1, except for 'not'. - The whole test for truth is redundant, since that's what 'if' does... For these reasons, never make #defines (aliases) for true and false. More in general, your constants are just variables that look like variables but are protected from rebinding. That's just not in the Python spirit, imo. Just use some convenction like ALL_CAPS and then don't rebind them... I think you don't have much experience with Python yet, but come from some other language and think you see something missing. In your example aliases, you called a dictionary a tuple (I believe that was you, anyway)... Just code Python for a while and see that it is never a problem. > Finally, this wouldn't break any code, nor would anything (excepting > perhaps peer pressure) force anyone to use it. Introducing a new keyword always breaks lots of code. -- Remco Gerlich From skip at pobox.com Fri Jun 1 14:21:54 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 1 Jun 2001 13:21:54 -0500 Subject: How do I return binary data from a python CGI called from CGIHTTPServer? In-Reply-To: References: Message-ID: <15127.56642.768310.860689@beluga.mojam.com> Mark> out_file.write('Content-type=application/octet-stream\n\n') Should be Content-type: application/octet-stream (colon, then space instead of equals). -- Skip Montanaro (skip at pobox.com) (847)971-7098 From skip at pobox.com Thu Jun 21 14:55:55 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 21 Jun 2001 13:55:55 -0500 Subject: Codeobjects of Modules? In-Reply-To: References: Message-ID: <15154.17211.485984.921451@beluga.mojam.com> >> After finishing the PVM in Python I want to port it to - please do >> not kill me - JAVASCRIPT. Martin> You can already do that, without either Java or JavaScript, Martin> using a Python plug-in. For IE, PythonWin supports Martin> ActiveScripting out of the box. ActiveScripting is hardly a cross-platform solution, though. Java and JavaScript, though both butchered by Microsoft, do provide you with some hope of running code outside of Microsoft's universe. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From altis at semi-retired.com Fri Jun 1 12:58:35 2001 From: altis at semi-retired.com (Kevin Altis) Date: Fri, 1 Jun 2001 09:58:35 -0700 Subject: screenscraping References: <991411356.20275.0.nnrp-10.c1c3e154@news.demon.co.uk> Message-ID: The examples below are converted from MSDN VBScript examples to work with Python on Windows (ActiveState Python (build 210) is what I tested with). It sounds like you are wanting to do SendKeys, so you'll need to launch the app you want to control, switch to it, and do your data entry. If the user starts typing or clicking while the script is running, then you are probably out of luck. Also, you should make sure to use ample delays to avoid events getting "lost". You can use COM in many cases to do safer app control, but it depends on the COM capabilities of the app you are interested in. ka --- example 1 # Python version of MSDN example for SendKeys # uses the Windows calculator and sends keystrokes to execute a simple calculation # http://msdn.microsoft.com/scripting/default.htm?/scripting/windowshost/doc/w sMthSendKeys.htm # the above URL also documents the codes to use with SendKeys import win32api import win32com.client shell = win32com.client.Dispatch("WScript.Shell") shell.Run("calc") win32api.Sleep(100) shell.AppActivate("Calculator") win32api.Sleep(100) shell.SendKeys("1{+}") win32api.Sleep(500) shell.SendKeys("2") win32api.Sleep(500) shell.SendKeys("~") # ~ is the same as {ENTER} win32api.Sleep(500) shell.SendKeys("*3") win32api.Sleep(500) shell.SendKeys("~") win32api.Sleep(2500) --- example 2 # various Windows Script Host (WSH) examples converted to Python # converted from # http://msdn.microsoft.com/scripting/default.htm?/scripting/windowshost/doc/w sMthRun.htm # http://msdn.microsoft.com/scripting/windowshost/doc/wsproenvironment.htm # http://msdn.microsoft.com/scripting/default.htm?/scripting/windowshost/doc/w sMthSendKeys.htm import sys import win32api import win32com.client shell = win32com.client.Dispatch("WScript.Shell") # launch Notepad to edit this script, simple version # sys.argv[0] is WScript.ScriptFullName in WSH #shell.Run("notepad " + sys.argv[0]) # this time set the window type, wait for Notepad to be shut down by the user, # and save the error code returned from Notepad when it is shut down # before proceeding ret = shell.Run("notepad " + sys.argv[0], 1, 1) print ret "Paul Brian" wrote in message news:991411356.20275.0.nnrp-10.c1c3e154 at news.demon.co.uk... > all, > > I may be scraping the bottom of the barrel as well a screen, but I would > like to know if it is possible to (using python) activate a windows > application that takes input from a GUI, and enter in data through the GUI > programmatically. > For example, bring up the address page, "tab" over to Surname and enter in > "foo" > I am prevented from using any kind of API or direct interface to real work. > > Thank you > > > P Brian > > > From sill at optonline.net Sat Jun 2 11:22:44 2001 From: sill at optonline.net (Rainy) Date: Sat, 02 Jun 2001 15:22:44 GMT Subject: create backup script in python References: <7b515e0f.0106011730.6b1aa82d@posting.google.com> Message-ID: On 1 Jun 2001 18:30:48 -0700, eric_brake wrote: > What is the easiest way to write a file copy script in python? I want > to use the script as a way to backup any file I choose on my hard > drive. Binary mode is best while handling this range of file types, > Correct? > > thank you Backup to where? I made a little script that backs up my home directory to a cdrw disk, it uses mkisofs and cdrecord (unix programs). -- Lime and limpid green a second scene A fight between the blue you once knew - Syd From loewis at informatik.hu-berlin.de Thu Jun 7 07:11:55 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 07 Jun 2001 13:11:55 +0200 Subject: WHY is python slow? References: Message-ID: Steven Haryanto writes: > Although it is generally accepted that Python is slower than > Java/Perl/Ruby I don't believe this is "generally" accepted; I don't accept it. In fact, there are numerous examples where Python has been shown to work faster than Java or Perl; I don't know about that many performance comparisons between Ruby and Python to know which of these languages is faster for what algorithms. Regards, Martin From neal at metaslash.com Wed Jun 27 07:48:00 2001 From: neal at metaslash.com (Neal Norwitz) Date: Wed, 27 Jun 2001 07:48:00 -0400 Subject: ANN: PyChecker version 0.6.1 Message-ID: <3B39C7F0.2CA171C5@metaslash.com> A new version of PyChecker is available for your hacking pleasure. PyChecker is a tool for finding common bugs in python source code. It finds problems that are typically caught by a compiler for less dynamic languages, like C and C++. Comments, criticisms, new ideas, and other feedback is welcome. Here's the CHANGELOG: * Check format strings: "%s %s %s" % (v1, v2, v3, v4) for arg counts * Warn when format strings do: '%(var) %(var2)' * Fix Local variable (xxx) not used, when have: "%(xxx)s" % locals() * Warn when local variable (xxx) doesn't exist and have: "%(xxx)s" % locals() * Install script in /usr/local/bin to invoke PyChecker * Don't produce unused global warnings when using a module in parameters * Don't produce unused global warnings when using a module in class variables * Add check when using method as an attribute (if self.method and x == y:) * Add check for right # of args to object construction * Add check for right # of args to function calls in other modules * Check for returning a value from __init__ * Fix using from XX import YY ; from XX import ZZ causing re-import warning * Fix UNABLE TO IMPORT errors for files that don't end with a newline * Support for checking consistent return values -- not complete produces too many false positives (off by default, use -r/--returnvalues to enable) PyChecker is available on Source Forge: Web page: http://pychecker.sourceforge.net/ Project page: http://sourceforge.net/projects/pychecker/ Neal -- pychecker at metaslash.com From arunramu at usa.net Thu Jun 28 23:26:51 2001 From: arunramu at usa.net (Blue whale) Date: 28 Jun 2001 20:26:51 -0700 Subject: threading question? Message-ID: I am relatively new to python. Can anyone guide me to a good resource where I can learn more about the threading module in python. I just know that using threads one can write a program which can perform multiple tasks indepedently and simultaneously. Any help in regard to this is appreciated.. Thanks in advance, Arun From see at my.signature Fri Jun 1 00:50:26 2001 From: see at my.signature (Greg Ewing) Date: Fri, 01 Jun 2001 16:50:26 +1200 Subject: Against PEP 240 References: Message-ID: <3B171F12.6079B37C@my.signature> Tim Peters wrote: > > So > long as we're using HW binary fp, better to face the truths of it from the > start. Yep. Display all floats in binary! -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From sholden at holdenweb.com Wed Jun 13 22:34:46 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 13 Jun 2001 22:34:46 -0400 Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> <9g8q7t0uib@drn.newsguy.com> Message-ID: "thinkit" wrote in message news:9g8q7t0uib at drn.newsguy.com... > In article , > Tom_Good1 at excite.com says... > > > >thinkit wrote in message > >news:<9g5d3p0f0p at drn.newsguy.com>... > >> humans should use a power of 2 as a base. this is more logical because it > >>synchs with binary, which is at the very heart of logic--true and false. it is > >> more natural perhaps, to use decimal--but logic should, and will, win out. > > > >I'm amused by the idea that "humans should [do something] because . . > >. it is more logical." Ah yes, we humans are so extremely logical. > >That's why advertisers -- whose livelihood depends on getting us to do > >things -- inevitably appeal to our highly refined sense of logic, and > >never play to our emotions or baser instincts ;-) > > some of us are...and those that are will easily dominate or destroy the rest. > If you're bent on world domination, perhaps you should apply for a job at Microsoft? regards Steve 239 (decimal) From hannah at schlund.de Mon Jun 18 13:29:40 2001 From: hannah at schlund.de (Hannah Schroeter) Date: 18 Jun 2001 19:29:40 +0200 Subject: pair programming, vim? References: Message-ID: <9gldq4$n61$1@c3po.schlund.de> Hello! In article , Rainy wrote: >Did anyone try pair programming over the net? In particular, is it possible >to set up vim with a shared buffer or, failing that, some other editor? If >so, does anyone want to try pair programming some small project? Another possibility besides those already mentioned would be rather current screen releases which allow more than one terminal to display the same screen "window". In theory, all attached terminals can type to such a shared window while all attached terminals also see the changes there. In practise, you should use some extra coordination to hand over the typing in case you want to exchange r?les. Kind regards, Hannah. From aleaxit at yahoo.com Mon Jun 18 04:07:52 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 18 Jun 2001 10:07:52 +0200 Subject: Two minor syntactic proposals References: Message-ID: <9gkcsn0229c@enews2.newsguy.com> "Barry A. Warsaw" wrote in message news:mailman.992844567.4921.python-list at python.org... ... > def Thing.new_method(self, x): ... > It never caught on, but this was in the (way) pre-PEP days. If > there's interest, I could write up a PEP on this. FWIW, I'd *LOVE* it if there was some relaxation of the current constraint that binding-statements (except assignment, and package-related import) can only affect 'bare' (unqualified) identifiers. It *IS* (from my POV) a wart (albeit a minor one) that, to rebind anything BUT a bare identifier by class/def/import/ from I must do a three-step -- first use the statement to bind a 'temporary' bare-identifier, then assign the bare-identifier to what I *really* want to bind, finally del the temp id. I understand that packages mean "import x.y" has very special meaning, of course -- but "import x as y.z", "from x import y as z.t", "def x.y", and "class x.y" all seem so natural to me, so typically Pythonic, that I do not really understand why they are currently forbidden in favour of, e.g.: from x import y as temporaryname z.t = temporaryname del temporaryname and the like. Where's the added-value in this restriction...? So, yes, I'd *LOVE* it if a PEP could remove at least SOME of these constraints -- I just hope it doesn't have to be as narrowly-worded as "allowing def x.y iff x is specifically a bare identifier that is bound to a class-object and is also the class's classname"...:-). That may be the TYPICAL use, of course, but hopefully it need not be so tightly restricted again...? Alex From sholden at holdenweb.com Wed Jun 27 13:51:51 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 27 Jun 2001 13:51:51 -0400 Subject: Indexing Into A Tuple References: <3B3A0C32.EF179DAE@tundraware.com> Message-ID: "Tim Daneliuk" wrote ... > Hmm, it works, but I don't understand why. I have a tuple of tuples > defined as follows: > > MyTuple = ( ("a", "b"), ("c", "d")...) > > Now, I want to iterate across it to print the pairs. This works as I > would expect: > > for x in MyTuple: > print x[0], x[1] > This says "take each value from MyTuple, assign it to x, and run the loop body". > But so does this: > > for x, y in MyTuple: > print x, y > This says "take each value from MyTuple, assign its first element to x and its second element to y (and there'd better not be any other elements if you don't want an exception), and run the loop body". > Intuitively (and, obviously, incorrectly) it seems to me that the 1st > time through, the second example should return: > > x=("a", "b") and y=("c", "d") > > Instead, it returns x="a", and y="b" just like the first example. > > Why? > -- Basically, because it's mirroring Python's standard binding behavior: >>> a = 'one' >>> b = 'two' >>> a, b = b, a >>> a 'two' >>> b 'one' When there's a tuple on the left of the equals sign the interpreter expects a tuple of equal length on the right, and performs element-by-element binding in a way which makes the above value interchange possible. The absence of parentheses doesn't mean you aren't using tuples... regards Steve -- http://www.holdenweb.com/ From skip at pobox.com Mon Jun 25 14:30:37 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 25 Jun 2001 13:30:37 -0500 Subject: PEP 255: Simple Generators, Revised Posting In-Reply-To: References: <6qk8203myt.fsf@abnoba.intevation.de> Message-ID: <15159.33613.478566.584749@beluga.mojam.com> Rainer> "Bernhard Herzog" wrote in message Rainer> news:6qk8203myt.fsf at abnoba.intevation.de... >> > def emptyg(): >> > return >> > yield None # never reached >> >> Only until the compiler becomes smart enough to remove that unreachable >> yield statement. :) Rainer> By that time, the compiler will hopefully be smart enough to Rainer> perform static analysis *before* removing dead code. My peephole optimizer would have removed it... -- Skip Montanaro (skip at pobox.com) (847)971-7098 From tim.one at home.com Thu Jun 21 22:30:23 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 21 Jun 2001 22:30:23 -0400 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) In-Reply-To: <3B3161F5.89146EB@ActiveState.com> Message-ID: [Paul Prescod] > Did icon switch from eager evaluation of the function to lazy > evaluation based on the occurrence of a keyword somewhere in the > function? FYI, Icon didn't expose the implementation, so there was no way to tell. In Python, we build "the generator part" on top of "the iterator part", and both are visible. The little gap between is the source of both the additional capabilities and potential confusion, compared to Icon's generators. From victor at prodigy.net Thu Jun 14 17:22:49 2001 From: victor at prodigy.net (Victor Muslin) Date: Thu, 14 Jun 2001 21:22:49 GMT Subject: Unexpected floating point results using mxODBC modules Message-ID: <3b292a75.1831245311@localhost> On Windows 2000, using Oracle and Active State's Python 2.1, and mxODBC module, the result returned by the cursor object's fetchall function contains floating point numbers for columns defined as "NUMBER" datatype. This column containing integers only. For example, the following code: import mx.ODBC.Windows, pprint db = mx.ODBC.Windows.connect(dsn, user, password) cursor = db.cursor() cursor.execute('select * from entity_type') results = cursor.fetchall() pprint.pprint(results) returns a result set as follows: [(1.0, 'ADSERVER'), (2.0, 'LOGMANAGER'), (3.0, 'PUSHERSYNC'), (4.0, 'PUSHER'), (5.0, 'DERIVE'), (6.0, 'MEDIASERVER')] At the same time, similar code using ODBC modules that came with Active State's Python 2.1: import odbc, dbi, pprint db = odbc.odbc('%s/%s/%s' % (dsn, user, password)) cursor = db.cursor() cursor.execute('select * from entity_type') results = cursor.fetchall() pprint.pprint(results) returned the expected result set: [(1L, 'ADSERVER'), (2L, 'LOGMANAGER'), (3L, 'PUSHERSYNC'), (4L, 'PUSHER'), (5L, 'DERIVE'), (6L, 'MEDIASERVER')] This does not seem right. Am I misunderstanding something here? TIA From sholden at holdenweb.com Wed Jun 13 07:17:59 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 13 Jun 2001 07:17:59 -0400 Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> Message-ID: <#Ro6Jr$8AHA.259@cpmsnbbsa07> "thinkit" wrote in ... > humans should use a power of 2 as a base. this is more logical because it > synchs with binary, which is at the very heart of logic--true and false. it is > more natural perhaps, to use decimal--but logic should, and will, win out. > And the moon should be made of green cheese, and everyone should be nice to each other. Frankly, I have machines I use for that kind of thing. regards Steve -- http://www.holdenweb.com/ From pete at pdfgroup.com Tue Jun 12 08:57:12 2001 From: pete at pdfgroup.com (Pete Koolish) Date: Tue, 12 Jun 2001 05:57:12 -0700 Subject: Incredible Software just about Free! Save Now References: <4c7733be.0106111614.70c03966@posting.google.com> Message-ID: The sender of this SPAM is Art Schwartz. For information on Art's 'business' go to http://artie2001.exit.mytoday.de Please send a letter to the City Attorney of Hallandale, FL if you are a victim of Art's credit card fraud. The name and address is: Richard Kane 400 S Federal Hallandale, FL 33009 Or use this link: http://ci.hallandale.fl.us/complaints.html From qrczak at knm.org.pl Thu Jun 14 03:32:14 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 14 Jun 2001 07:32:14 GMT Subject: PEP 259: Omit printing newline after newline References: <3dd78ag04f.fsf@ute.cnri.reston.va.us> <9g572b01dal@enews2.newsguy.com> Message-ID: Tue, 12 Jun 2001 15:56:26 +0200, Alex Martelli pisze: > But the differences between your ideas and mine are basically > syntax-sugar. Keep print and softspace as is for compatibility. Have a function similar to this: def get_and_del(dict, key, default = None): if dict.has_key(key): value = dict[key] del dict[key] return value else: return default def output(*args, **kwargs): file = get_and_del(kwargs, 'file', sys.stdout) end = get_and_del(kwargs, 'end', '\n') sep = get_and_del(kwargs, 'sep', ' ') if kwargs: raise TypeError # TODO: build a message first = 1 for arg in args: if not first: file.write(sep) file.write(str(arg)) first = 0 file.write(end) Yes, I'm throwing away the idea of softspace state preserved across output calls. Life will be simpler in overall. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From post_to_usenet at Hotmail.com Mon Jun 11 11:07:25 2001 From: post_to_usenet at Hotmail.com (Toni) Date: Mon, 11 Jun 2001 17:07:25 +0200 Subject: Newbye and packages Message-ID: <3b24e01f@hpb10302.boi.hp.com> Hi, (I have searched for this in the FAQ and groups, but have found no clue) Imagine I want to build a package hierarchy of the kind: image_file gif_file png_file ... with associated classes: class image_file: "Base class for image files hierarchy" class gif_file(image_file): class png_file(image_file): each on an independent package/module, so that it is easy to add more classes as needed I have tried several approaches, but never got to do something like import image_file.gif_file a = image_file.gif_file("test.gif") if (a.transparency()) .... The reason for having the base image_file class is for coding default values for uncommon things. For example, if I coded a bmp_file class, I wouldn't code the transparency() method and let de base class answer 'no'. What would be the right approach? Ideas welcome TIA -- Toni From chris.gonnerman at newcenturycomputers.net Sat Jun 23 10:33:33 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Sat, 23 Jun 2001 09:33:33 -0500 Subject: adding instance methods after instantiation References: <9h1vg2$14cc$1@node21.cwnet.roc.gblx.net> <15156.42187.785702.181258@beluga.mojam.com> Message-ID: <001f01c0fbf1$8009f440$0101010a@local> ----- Original Message ----- From: "Skip Montanaro" > Lee> Is there some way to make m2 an instance method so that it will > Lee> automatically get passed c1 as its first argument? > > Check out the instancemethod function of the new module. Here is code based on Lee's sample: ###################################################### ### adding an instance method after the fact import new class c: def __init__(self): self.a1 = 1 def m1(self): self.a2 = 2 def m2(self): #note, outside of class c definition self.a3 = 3 c1 = c() c1.m2 = new.instancemethod(m2, c1, c) c1.m2() print c1.a3 From aahz at panix.com Fri Jun 15 13:13:05 2001 From: aahz at panix.com (Aahz Maruch) Date: 15 Jun 2001 10:13:05 -0700 Subject: question about threads References: <9gdc68$fhs$1@news.hk.linkage.net> Message-ID: <9gdfn1$ru0$1@panix6.panix.com> In article <9gdc68$fhs$1 at news.hk.linkage.net>, Alan Tsang wrote: > >Is it possible to explicitly tell a thread to pass execution to another >thread in Python? Any help is much appreciated. Depends what you mean. If you simple want the current thread to give up the Global Interpreter Lock, use time.sleep() with a non-zero parameter; however, the current thread may well be the one to reacquire the GIL. If you want a specific other thread to pick up execution, you'll need to use some lock-based mechanism; I generally recommend queues. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista I wasn't licking it, I was chewing it. From gahanr at gofree.indigo.ie Mon Jun 4 16:33:22 2001 From: gahanr at gofree.indigo.ie (Robert Gahan) Date: Mon, 4 Jun 2001 21:33:22 +0100 Subject: formatting numbers References: Message-ID: michael montagne wrote in message news:e5SS6.69668$FS3.619704 at sjc-read.news.verio.net... > Simple question. I am accessing a database of job numbers that take the > form of "00049" and "01049". These values are integers. When I return the > value from the database it reads "49". I need to add the leading digits if > they are there so this number would read "00049". In MSAccess I used > Format(num,"00000"). How can I do that with Python? > > -mjm > > > This (or something similar) might do the trick ... jobNo = 49 key = "%.5d" % (jobNo) print key From nomail at nomail.com Mon Jun 4 14:59:16 2001 From: nomail at nomail.com (Dry Ice) Date: Mon, 4 Jun 2001 11:59:16 -0700 Subject: Reading email and newsgroups from Python? Message-ID: <3b1bd85b_2@news4.newsfeeds.com> Just getting started with Python and wxPython. I'm interested in receiving and managing email and newsgroup posts with these. Will be doing this initially for Win98, but will eventually be doing same for Linux. (Using existing OS services should make Linux easy, I suspect.) Any code snippets you can suggest to get me started? Thanks From aleaxit at yahoo.com Wed Jun 20 08:45:20 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 20 Jun 2001 14:45:20 +0200 Subject: Alternative ReadLine for Windows (was Re: Any other Python flaws?) References: <3b296534.514160393@wa.news.verio.net> <3b2a94a6.591842855@wa.news.verio.net> <636fd38f.0106200145.337888a3@posting.google.com> Message-ID: <9gq5u70k91@enews1.newsguy.com> "Tiago Henriques" wrote in message news:636fd38f.0106200145.337888a3 at posting.google.com... ... > Another annoying missing feature is the absence of command line editing in the > python shell. Perhaps now that the license has been made gnu-compatible it will > be possible to ship python pre-compiled with the readline library, instead of Such a package would be GPL-infected, so I suspect the Python Software Foundation itself will not bundle it, but there's nothing to stop other repackagers from so doing. > having to compile python yourself. I have compiled python with readline support > myself, and it's pretty easy, but for the average user who is afraid of makefiless > and compilations, it would be extra-nice if python were a bit more user-friendly > out-of-the-box. A user afraid of makefiles and compilations is likely to be working on Windows. For *THAT*, I *highly* recommend Gonnerman's "Alternative ReadLine" library. At http://newcenturycomputers.net/projects/readline.html one finds various packages, including self-installing executables for Windows and both Python 2.0 and 2.1, built with the wonderful distutils. It doesn't get much easier than that -- download the exe, run it, you're done -- you have command-line editing and history. I would hope today's average user is not afraid of downloading and running a tiny self-installing executable from a trustworthy site -- the only remaining problem is making it *WIDELY* known that it's not a problem any more (sure, it WOULD be even nicer if it came with the Python distribution for Windows:-). Alex From support at internetdiscovery.com Sat Jun 9 15:18:49 2001 From: support at internetdiscovery.com (Mike Clarkson) Date: Sat, 09 Jun 2001 19:18:49 GMT Subject: Tkinter and Swing performance References: Message-ID: <3b227622.23504736@nntp.ix.netcom.com> On Sun, 27 May 2001 17:11:50 GMT, "C.L" wrote: >Has anyone done a large GUI app with Python and TKinter? So far I have >found that: >1. TKinter is faster (more responsive) than Java's Swing library >2. Tkinter apps use less memory than a similar sized Swing app >3. I find Tkinter is easier to work with than Swing > >Does Tkinter's performance slow down when an app gets large enough? Yes and no (of course). The underlying Tk to Tkinter if very efficient; I've see 100,000 line Tk programs running in 8M virtual under Linux, which is pretty amazing for an interpreted language. > So far, >I am thinking building my client's GUI's in TKinter and Python is the way to >go, and to use Java on the backend where needed. I know that Java has never >been a real good candidate for the client side apps, but now even with >trying my apps on the new JDK 1.4 Beta which is supposed to handle Swing >more efficiently, there doesn't seem to be any noticeable difference, and >the JDK is now 48 meg in size! >Any advice on medium to large Tkinter apps? Problems, issues? You have an alternative with Tkinter if you find your application is getting too memory consuming. As a rule, a lot of UI code is modular and self contained, so if you don't mind mixing languages, you can code self-contained UI portions directly inTk, and call them from Tkinter. You'll be able the Python overhead on the Tk code that is never used by Tkinter. Mike. From cer at tutopia.com Sat Jun 30 00:31:17 2001 From: cer at tutopia.com (Cristian Echeverria) Date: Sat, 30 Jun 2001 00:31:17 -0400 Subject: Python for air traffic control? References: Message-ID: <9hjk9l$dhvem$1@ID-44371.news.dfncis.de> This is the tipical problem to solve with Eiffel. Strong typing and Design by contract are the key and the model to solve problems like this. http://eiffel.com/ Anyway I think C/C++ is not a good choice. "Russ" <18k11tm001 at sneakemail.com> escribi? en el mensaje news:bebbba07.0106291642.6c799d15 at posting.google.com... > I am thinking about using Python for a unique safety-critical > application in air traffic control. It will monitor a few hundred > aircraft for conformance to assigned trajectories, and it will > initiate an automatic alarm (for both controller and pilot) if an > aircraft deviates from its assigned trajectory and is in danger of a > collision. (The trajectory and tracking data will come from existing > C/C++ programs.) The software must be as simple, clean, and robust as > humanly possible. The default languages here are C/C++, but I am > toying with the idea of using Python instead. However, I am a bit > nervous about the lack of type checking and function prototyping, > among other issues. Is Python up to this task? Thanks for your > insights. From altis at semi-retired.com Mon Jun 18 17:28:32 2001 From: altis at semi-retired.com (Kevin Altis) Date: Mon, 18 Jun 2001 14:28:32 -0700 Subject: Is anyone using CGIHTTPServer on a non-Unix/Windows platform? References: Message-ID: Sorry, those should probably be http rather than https http://sourceforge.net/tracker/?func=detail&aid=430160&group_id=5470&atid=10 5470 http://sourceforge.net/tracker/?func=detail&aid=427345&group_id=5470&atid=10 5470 ka --- "Kevin Altis" wrote in message news:MiuX6.1091$Xx.272284 at news.uswest.net... > You might want to read two bug posts I've made to sourceforge > https://sourceforge.net/tracker/?func=detail&aid=430160&group_id=5470&atid=1 > 05470 > I think this is the issue you are seeing. > > https://sourceforge.net/tracker/?func=detail&aid=427345&group_id=5470&atid=1 > 05470 > This one will take care of the binary issue. > > ka > > "Mark Wright" wrote in message > news:f9ff3f62.0106181252.5a048fa1 at posting.google.com... > > I'm having problems getting it to work. I'm running python CGI > > scripts using the execfile() part of CGIHTTPServer (i.e. !has_fork and > > !has_popen2), and it works like a charm when I do a GET. But when I > > try to do a POST, the thing just hangs in telnet and I get the "Page > > could not be displayed" error in IE and a blank page in Mozilla. > > > > (Techinically, I am running on Windows, but I've commented out the > > popen2() section due to text/binary file conversion issues.) > > > > Is anyone else having this problem? The following script is an > > example of one that fails (but works fine in Apache): > > > > import os > > import sys > > import cgi > > > > # ---------------------------------------------------------------------- > > if __name__ == '__main__': > > > > # parse parameters > > form = cgi.FieldStorage() > > > > out_file = sys.stdout > > if os.environ['REQUEST_METHOD'] == 'POST': > > out_file.write('Content-Type: text/html\n\n') > > out_file.write("\n") > > out_file.write(" Did this work? \n") > > out_file.write("\n") > > # keys = os.environ.keys() > > # keys.sort() > > # for key in keys: > > # out_file.write("
" + key + ':' + cgi.escape(os.environ[key]) + > > \ > > # '\n') > > out_file.write("Did this work?\n") > > out_file.write("\n") > > > > else: > > out_file.write('Content-type: text/html\n\n') > > out_file.write("\n") > > out_file.write(" Did this work? \n") > > out_file.write("\n") > > out_file.write( > > """
> >
try this out > > > >
""") > > out_file.write("\n") > > From iain at wombatzone.freeserve.co.uk Fri Jun 22 18:56:35 2001 From: iain at wombatzone.freeserve.co.uk (Iain Calder) Date: Fri, 22 Jun 2001 23:56:35 +0100 Subject: libssl.so & libssl.so req'd for rpm install References: <3b327452.95354923@news1.on.sympatico.ca> Message-ID: <3B33CD23.90A98765@wombatzone.freeserve.co.uk> Ken wrote: > > Hi, > > I guess this is kind of a follow up from my last message; I'm trying > to install python 2.1-5 off the rpm, which I'm assuming will work fine > if it can work out its dependencies. It's failing on the following > dependencies: > > libcrypto.so.0.9.6 > libssl.so.0.9.6 > > I previously didn't have these files installed, but I managed to > install the right RPM, and they are now there: > > /usr/lib/libcrypto.so.0.9.6 > /usr/lib/libssl.so.0.9.6 > > ...yes the RPM install still fails. I'm running on a farily minimal > clean install of RH7.1. > > Any suggestions? > > TIA! > > kc I haven't tried to install 2.1-5, but this worked for me with 2.1-4 on RH 7.1: 1) Download the source rpm python2-2.1-4.src.rpm 2) rpm --rebuild python2-2.1-4.src.rpm 3) rpm -i /usr/src/redhat/RPMS/i386/python2-2.1-4.i386.rpm 4) rpm -i /usr/src/redhat/RPMS/python2-devel-2.1-4.i386.rpm Iain From SBrunning at trisystems.co.uk Tue Jun 5 05:56:57 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Tue, 5 Jun 2001 10:56:57 +0100 Subject: How to get the size of an object? Message-ID: <31575A892FF6D1118F5800600846864D78BCD3@intrepid> > From: stain at prigioniero.it [SMTP:stain at prigioniero.it] > Is there a way to get the size of an object in Python? > I mean something like 'sizeof' C operator... TIA Marc-Andr? Lemburg's mxTools extension includes a sizeof() function. It's available as part of the eGenix mxBASE package, available from . Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From sheila at spamcop.net Sun Jun 10 10:28:39 2001 From: sheila at spamcop.net (Sheila King) Date: Sun, 10 Jun 2001 14:28:39 GMT Subject: New guy question References: Message-ID: On Sun, 10 Jun 2001 13:09:03 GMT, "Glen Mettler" wrote in comp.lang.python in article : :I forgot to ask - what is the purpose of the Python window and the Python :Shell window? : :Can I NOT run a series of scripts from these windows? Must I go to the DOS :window to check my program? : :Glen You do not have to check your scripts from the DOS prompt. You can run them from inside of IDLE. What you should do is this: In IDLE go to the File Menu and choose "Open..." This should pop up a window where you can look on your computer for the file alook.py. When you select that file, it should open in a new window. It will show the code for your file alook.py. In this new window (the title should say alook.py-path/to/alook.py), go to the Edit Menu and choose "Run Script". The output will appear in IDLE's Python Shell window. Hope this helps, -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ :"Glen Mettler" wrote in message :news:TiyU6.127784$I5.32725119 at news1.rdc1.tn.home.com... :> I have a small script I entered from a Python book that works when I run :it :> using F5. :> However, when I go to the console and enter python alook.py, I get an :error :> message: :> :> >>> python alook.py :> SyntaxError: invalid syntax :> :> I am too new to this to know why. :> :> Glen :> :> : From michael at stroeder.com Tue Jun 19 04:31:50 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Tue, 19 Jun 2001 10:31:50 +0200 Subject: Getting all client http headers References: <3B2F1A51.EC21BD1C@nokia.com> Message-ID: <3B2F0DF6.EB339753@stroeder.com> Joonas Paalasmaa wrote: > > How can I get all client http headers in python. > Can I use cgi-module? Assuming that you implement a simple CGI-BIN program you have to stick to the CGI-BIN environment vars which contain some of the HTTP header information (usually prefix HTTP_). Ciao, Michael. From fredrik at pythonware.com Mon Jun 4 14:16:15 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 04 Jun 2001 18:16:15 GMT Subject: disabling DeprecationWarning ? References: Message-ID: Clark C. Evans wrote: > I have alot of older modules (that I'd rather not > upgrade at this time), such as Mailman that > constantly complain about the regex module > DeprecationWarning. Anyway, this stuff generates > huge log files and is distracting. I know > the regex module is deprechated. Is there a way > to re-compile python 2.1 so that it doesn't complain? no. any reason you cannot just leave a 2.0 installation in place, and use it for the old code? if you insist, you can patch your site.py or sitecustomize.py file to switch off warnings, using something like: import warnings warnings.filterwarnings("ignore") also see section 5 of: http://www.amk.ca/python/2.1/index.html and the library reference (the "warnings" module). Cheers /F From tim.one at home.com Sun Jun 3 03:27:12 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 3 Jun 2001 03:27:12 -0400 Subject: random In-Reply-To: Message-ID: [Nick Perkins] > ... > The very idea of 'infinite randomness', in all it's unattainable > glory, is somehow very pure and clear in everyone's mind. It is, after > all, the first concept of randomness that we all learned as children: > that something is simply unpredictable, period. Strange that it takes > centuries of advanced math to try to pin down exactly what randomness > means. Knuth (in volume 2 of TAoCP) has entirely too good a time exploring this question. It's a miserable journey . He picks a few plausible definitions, persuasively argues they're too weak, then presents one that's intuitively on the money. But it turns out nothing can satisfy that definition! So it's on to page after page trying to recapture what was "right" about that defn, but not so much that it's impossible to meet. Here's a good roadmap to recent results on randomness and Chaitan's Omega construction (note that these are research papers, not watered down): http://citeseer.nj.nec.com/calude00randomness.html Over the last few years, lots of alternative constructions have been proved equivalent, sometimes to the surprise of all concerned. That usually means there's a tedious grad-school course in the making, but for *most* Python users random.random() is still good enough . From aleaxit at yahoo.com Thu Jun 21 02:16:56 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 21 Jun 2001 08:16:56 +0200 Subject: Partially evaluated functions References: <9gpf5a0313h@enews2.newsguy.com> Message-ID: <9gs73a05ql@enews1.newsguy.com> "Nick Perkins" wrote in message news:AVdY6.301331$eK2.61274820 at news4.rdc1.on.home.com... ... > I used the following: > ( supplies args left-to-right, with call-time kw args trumping create-time > kw args ) But you do need a copy then, i.e.: > from __future__ import nested_scopes > > def curry(func, *args, **kwds): > def curried_function(*moreargs, **morekwds): > kwds.update(morekwds) > return func(*(args+moreargs), **kwds) > return curried_function Now if we try: def f(**kw): for k,v in kw.items(): print "%s->%s "%(k,v), print cf = curry(f,be='bop') cf(fee='fie') cf(foo='fum') we get: fee->fie be->bop fee->fie foo->fum be->bop I.e., now cf has unwanted state. So the copy is needed. def curry(func, *args, **kwds): def curried_function(*moreargs, **morekwds): kw = kwds.copy() kw.update(morekwds) return func(*(args+moreargs), **kw) return curried_function Now, cf doesn't "accumulate" any more. Still, this class: > class curry_class: > def __init__(self, func, *args, **kwds): > self.func = func > self.args = args > self.kwds = kwds > def __call__(self, *moreargs, **morekwds): > self.kwds.update(morekwds) > return self.func(*(self.args + moreargs), **self.kwds) has the same issue, I think. The copy isn't needed for the version where curry-time keywords take precedence, but if call-time ones must override, then I think that copy we must. > I found that the function-version is significantly faster than the > class-version, in fact, almost twice as fast in the tests that I ran. > > Cool stuff. Nested scopes rule. For the functional-flavoured stuff they're designed to do, it appears that they definitely shine. Alex From JamesL at Lugoj.Com Sun Jun 10 14:14:27 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Sun, 10 Jun 2001 11:14:27 -0700 Subject: Global in multiple files References: Message-ID: <3B23B903.9332CD2D@Lugoj.Com> Artur Skura wrote: > So, any ideas how I should cope with that and be able to use my > global variable in different clases in different files? Create a separate module, say globalVar.py, and put your globals into that (it should set their initial values. E.g. myList = [ ]; myStuff = None). Then use: import globalVar at the top of all your modules that need to access/update the globals. In your code you then just reference as, say, globalVar.myList.append('some value'), globalVar.myStuff = 3, etc. All your modules can now access and update the global variables as needed and their global nature is also self documented. Hope this helps! From slhath at home.com Wed Jun 6 20:11:41 2001 From: slhath at home.com (Scott Hathaway) Date: Thu, 07 Jun 2001 00:11:41 GMT Subject: network configuring through a script References: <3b1e3bf3.3670798@news.laplaza.org> Message-ID: <1FzT6.38531$aA5.233224@news1.rdc1.tx.home.com> What you want to do is pretty complex. There are many different registry keys to change. There is a shareware program ($9) called NetSwitcher (www.netswitcher.com) that works well. Scott "Mats Wichmann" wrote in message news:3b1e3bf3.3670798 at news.laplaza.org... > On Wed, 06 Jun 2001 11:25:04 GMT, "Francis Meyvis" > wrote: > > >Hi, > > > >I've W2k with ActiveState Py 2.1 on my notebook. Python provides some access > >to COM things. > >I'd like to have scripts that configure my notebook for networking at home, > >at work, ... > >This requires now going into the dialog for > >- TCP/IP settings to change the IP address to use DHCP or use a fixed IP > >address, > > automatic DNS or fixed DNS server > >- IE5 properties/connections to setup Dialup or LAN settings. > >- the IE5 LAN settings allow further automatic settings and proxy server > >settings. > > > >Are these two also possible from within COM? > >Or should one directly modify the registry? > > > >Can someone point me to MSDN documentation on the inners of these > >configuration dialogs? > >I look in it but do not find anything usefull (could be that the MSDN I'v > >access to is already to old). > >Just some pointer would do ... > > There's an easier way. > > W2k provides a tool called "netsh" which can change the network > settings from a shell prompt, and can also dump an existing setting > into a file for later reuse. > Mats Wichmann > > (Anti-spam stuff: to reply remove the "xyz" from the > address xyzmats at laplaza.org. Not that it helps much...) From JamesL at Lugoj.Com Fri Jun 15 02:23:53 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Thu, 14 Jun 2001 23:23:53 -0700 Subject: Python 2.0.1c1 - GPL-compatible release candidate References: Message-ID: <3B29A9F9.9E85166F@Lugoj.Com> Will Ware wrote: > But the GPL extends its coverage not only to derived works in the obvious > sense, but also to code which is statically linked with a GPL program. > If my extensions are statically linked to 2.0.1, then by that criterion > they would also be GPL-ware. I haven't examined the GPL text to see if Will's interpretation is remotely correct, but I'd wager good money that such a broad reach by any license agreement would fail miserably in most any court. > I don't know if the same is true of dynamically-linked extensions. Since the only difference is the time at which some symbols are looked up and assigned values, what applies to static linking should also apply to dynamic linking, and vice versa. > Have I got any of that right, or should I go back on my meds now? I sincerely hope you got that wrong Will. Have you checked your medicine? If you got it right, have the GPL authors checked their medicine? From bob at drzyzgula.org Fri Jun 1 22:03:04 2001 From: bob at drzyzgula.org (Bob Drzyzgula) Date: Fri, 1 Jun 2001 22:03:04 -0400 Subject: Makefile I/O module? Message-ID: <20010601220304.B24658@drzyzgula.org> Does anyone know of a module providing classes for parsing standard makefiles, sort of like what the rfc822 module does for mail messages? I don't want to actually do the make logic in Python, I just want to be able to filter and assemble makefile fragments and templates into output makefiles for later processing by make itself; I'm trying to write a GUI configuration utility for a package with tons of options. Perhaps the work that such a module could do is just too straightforward to bother with constructing a formal module, but I'm just trying to avoid reinventing a wheel. I've tried searching for something like this, but, well, *you* put "Python makefile parser module" or some varient thereof into google and see what you come up with... :-) I've seen the Software Carpetry contest stuff, and the recent thread in this list on Python-based make tools. But I haven't found anything simply designed for doing this dumb sort of filtering, where I don't even really need the program to be able to calculate dependancies... Thanks for any hints, --Bob Drzyzgula From mixo77 at usa.net Mon Jun 11 04:26:11 2001 From: mixo77 at usa.net (mixo) Date: Mon, 11 Jun 2001 10:26:11 +0200 Subject: Exceptions Message-ID: <3B2480A3.D6B3E5D6@usa.net> How does one find out the last error that occured or the last exception that was raised? From s713221 at student.gu.edu.au Tue Jun 12 07:04:34 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Tue, 12 Jun 2001 21:04:34 +1000 Subject: tummy compile Mandrake 7.2 References: <20010608.214013.1469262009.16325@K7.atl.mediaone.net> <20010609.104451.1884661237.1229@K7.atl.mediaone.net> <3B24154E.C70211ED@student.gu.edu.au> <20010610.232821.1789366143.1225@K7.atl.mediaone.net> Message-ID: <3B25F742.F4E25C37@student.gu.edu.au> myself wrote: > > It depends on how the tummy-expat spec file was built. Some packagers > > just throw everything in together, binaries, libraries, documents and > > header files into a package called . Others split up a build into a > > .rpm, -docs.rpm, -devel.rpm and maybe even a > > -lib.rpm As well as removing the buildprereq: expat-devel, you can > > also mung it by changing it to expat only (I.E. get rid of the -devel > > bit.). > > > ok, but Sean didn't seem to indicate this was the source of the error, > but perhaps I misunderstood. I installed expat as per instructions on > tummy site- I probably don't "need" it at all at this point- first I need > a *basic* understanding of the language :-). Just out of curiosity, > doesn't the -devel part install the header files necessary to build the > actual expat support? Depends on the package builder's preference. If you look at a spec file, you'll see a whole load of %package directives, which define additional packages such as devel. However, if you're in a hurry to fold a tar source up into an rpm, most people write a basic spec file that installs binaries, libraries and headers in one go. The reason why the build fails is because it looks for the rpm expat-devel, which isn't in your rpm database, even though the files it theoretically would provide are on your system (from the package expat). > > If you want a prebuilt rpm for Mandrake 7.2, I could always email you my > > build, but I understand if you want to build it from source. > > > thanks for the offer. But if you don't mind, since you've sucessfully > built for LM7.2, perhaps you could give me a few pointers on how? I > really don't care if I use srpm or source- my prob. w/ srpm is detailed > to best of my ability in this thread, failure w/ source in a later > thread. Since Sean already pointed out that my prob. w/ srpm seems to be > a Mandrake thing, unless you have further advice on this, would you mind > checking out later post (source compile) and perhaps helping there? For > all I know I don't even really have a problem, maybe this is the way the > install is supposed to act, but so far no response on that topic..... > > BTW, did you update or do you have 1.5.2 and 2.1 coexisting? I'm trying > to do latter, being fearful 2.1 will break something if I replace 1.5.2. > Comments? > > thanks a heap! Good idea to go for the coexistance thing. I ran rpm -q --whatrequires python and got the following list back pygtk-0.6.6-4mdk rpm-devel-3.0.5-27mdk rpm-python-3.0.5-27mdk icepref-1.1-3mdk python-devel-1.5.2-12mdk rpmlint-0.24-1mdk tkinter-1.5.2-12mdk python-imaging-1.1-2mdk pythonlib-1.23-2mdk Theoretically I could do without these, but I'd have to give up some of my favourite Mandrake features. Either that, or rebuild them for python2.1 Anycase, here's my hack on the rpm spec file. After a lot of mucking around, it turns out to be something really insignificant. Look ahead to step 8. 1.First, install the src.rpm under /usr/src/RPM rpm -i python2-2.1-4.src.rpm 2. Cd to the spec file location cd /usr/src/RPM/SPECS 3. Prep and compile the package rpm -bc python-2.1.spec Now begins the hacking on the spec file. 4. Make sure you fix that depend to expat, not expat-devel This next step is optional. I've tried with and without, and it doesn't have any effect whatsoever. If you use emacs however, restoring the colours does make it easier to errorcheck 5. Go through the changelog and backslash all occurances of " and (one) ' (E.g. " -> \"). Add a " to the end of the changelog. I'm not to sure this does anything, but it does restore my emacs colours to what they should be. Again this next step is optional. If you're only going to develop with python 2.1, you're better off leaving it the same, removing your already installed python-tools and replace it with your new 2.1 based python-tools. 6. Replace the "idle" on the ends of lines 191, 192 and 193 with idle%{binsuffix}, so they look like this: ######## # Tools echo '#!/bin/bash' >${RPM_BUILD_ROOT}%{_bindir}/idle%{binsuffix} echo 'exec %{_prefix}/bin/python%{binsuffix} /usr/lib/python2.1/Tools/idle/idle.py' >>${RPM_BUILD_ROOT}%{_bindir}/idle%{binsuffix} chmod 755 ${RPM_BUILD_ROOT}%{_bindir}/idle%{binsuffix} cp -a Tools ${RPM_BUILD_ROOT}%{_prefix}/lib/python2.1 Note that the second echo and the >>${PRM_BUILD_ROOT} line are the one line in the spec file. Netscape is just TOO helpful. 7. In the make files section, do as for step 6 and replace line 208 echo "%{__prefix}"/bin/idle >>tools.files with this echo "%{__prefix}"/bin/idle%{binsuffix} >>tools.files This makes sure your python 2.1 version of idle is installed as idle2. This prevents conflicts when you try to install your new python2-tools rpm with an already installed python-tools. This next step ISN'T optional. I've found (Through a LOT of trial and error) that THIS this that chokes rpm during the install. 8. On line 217 you'll find the following %{__prefix}/man/man1/python%{binsuffix}.1.gz Unfortunatly Mandrake doesn't package man pages as gzips, but as bzip2s. So change this line to %{__prefix}/man/man1/python%{binsuffix}.1.*z* and it work for gzip or bzip2 9. Now we go ahead with our install. rpm -bi --short-circuit python-2.1.spec Now you may see lots of error messages that state: "Finding Provides: (using /usr/lib/rpm/find-provides)... Finding Requires: (using /usr/lib/rpm/find-requires)... line 246: Dependency tokens must begin with alpha-numeric, '_' or '/': %defattr(-, root, root) Failed to find Requires:" This is the bit that really had me stumped. After a LONG time trying to remember how I got around the error messages, I rediscovered that get your RPMS if you just go ahead and build the damn things. 10. rpm -bb --short-circuit python-2.1.spec If you look under RPMS/i586 you should see four python2 rpms. Feel free to check them using package query mode, listing all the files in each. rpm -qpl python2-2.1-4.i586.rpm rpm -qpl python2-devel-2.1-4.i586.rpm rpm -qpl python2-tkinter-2.1-4.i586.rpm rpm -qpl python2-tools-2.1-4.i586.rpm After all that rubbish and it's just a matter of Mandrake using a different file compression tool to mainstream. *sheesh* As you can see, source building is a mixture of applied knowledge (Which usually comes from incomplete documentation and previous attempts), trial-and-error and some days, a good voodoo curse and a heavy dependency on alchohol/coffee/frustration-relief-aid-of-choice. In this case, a blind willingness to do what seems to be a bad thing helps a little, "just to see what happens". *evil grin* Have fun. -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From boyd at insultant.net Thu Jun 7 15:46:37 2001 From: boyd at insultant.net (Boyd Roberts) Date: Thu, 7 Jun 2001 21:46:37 +0200 Subject: termios, Python 2.1 and 1.5.2, AIX and SCO References: Message-ID: <9folpm$6ma$1@neon.noos.net> "MikeK" a ?crit dans le message news: efd753ca.0106071104.dbc5770 at posting.google.com... > Getting the 'termios' module to compile or work on various platforms is > like trying to pass a bowling ball. since system v and posix both stuck their oars in portable tty mangling software has been next to impossible to do. about the only portable, but totally gross, way to do it is to use curses. what an aptly named piece of software. From kamikaze at kuoi.asui.uidaho.edu Fri Jun 29 13:45:54 2001 From: kamikaze at kuoi.asui.uidaho.edu (Mark 'Kamikaze' Hughes) Date: 29 Jun 2001 17:45:54 GMT Subject: Augmented Assignement (was: Re: PEP scepticism) References: Message-ID: 28 Jun 2001 11:32:34 -0700 in , Paul Prescod spake: > I think Python has been getting better and better as time goes on. But I > do have a concern about augmented assignment. How can a newbie > understand that tuples are "immutable" if this works: > mytuple += (foo,bar) What would you expect from "mytuple = mytuple + (foo,bar)", and why would this be different from "mytuple += (foo,bar)"? > Worse, once they've learned that this does NOT affect other references > to mytuple they are bound to be confused by > mylist += [foo, bar] > which does! What would you expect from "mylist = mylist + [foo, bar]", and why would this be different from "mylist += [foo, bar]"? > I've seen this confusion already -- in a draft of a book no less. I'm confused by your confusion. However, it looks like that author should probably make this more clear. -- Mark Hughes "I will tell you things that will make you laugh and uncomfortable and really fucking angry and that no one else is telling you. What I won't do is bullshit you. I'm here for the same thing you are. The Truth." -Transmetropolitan #39 From michael at stroeder.com Sat Jun 2 03:18:15 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Sat, 02 Jun 2001 09:18:15 +0200 Subject: ThreadingTCPServer not working References: Message-ID: <3B189337.1FD2F5DD@stroeder.com> Gustavo Niemeyer wrote: > > >>> s = SocketServer.ThreadingTCPServer(("localhost", 8000), > BaseHTTPServer.BaseHTTPRequestHandler) > >>> s.serve_forever() > [..] > error: (9, 'Bad file descriptor') http://sourceforge.net/tracker/index.php?func=detail&aid=417845&group_id=5470&atid=105470 Ciao, Michael. From michael at stroeder.com Tue Jun 12 05:33:03 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Tue, 12 Jun 2001 11:33:03 +0200 Subject: CGI Empty Form problem (over https) References: <3B2507FE.8838C412@hursley.ibm.com> Message-ID: <3B25E1CF.81F2A255@stroeder.com> Tushar Wagle wrote: > > I'm having a problem with a cgi form in a cgi script. > Running over a secure connection (https:..), my CGI script > gets an empty cgi-form, ie If everything on your web server is configured correctly there's no difference in using your script with or without SSL. Which SSL server are you using? Ciao, Michael. From netmgr at canterburycrest.org Thu Jun 21 19:36:47 2001 From: netmgr at canterburycrest.org (Ross Brattain) Date: Thu, 21 Jun 2001 16:36:47 -0700 Subject: Getting actual name of passed arg References: <3B3272DD.4000308@canterburycrest.org> <3B327450.8060305@canterburycrest.org> <3B327B1D.9020107@canterburycrest.org> <9gtuk0$b94md$1@ID-11957.news.dfncis.de> Message-ID: <3B32850F.4010608@canterburycrest.org> Emile van Sebille wrote: > You could also perhaps start with: > > def debug(**kwargs): > print kwargs > > a,b,c = ('test',123, [1,2,3]) > > debug (a=a,b=b,c=c) > Clever, and useful. I never would have thought of that. Thanks. Ross Brattain netmgr at canterburycrest.org From aaronf at nospam.telusplanet.net Tue Jun 5 00:54:56 2001 From: aaronf at nospam.telusplanet.net (Aaron Fransen) Date: Tue, 05 Jun 2001 04:54:56 GMT Subject: Running an AS/400 CL program via ODBC Message-ID: I have a problem executing an AS/400 CL program from the SQL/ODBC interface in Python. I know the interface on the AS/400 works because I actually wrote the code to do it originally in VB, which has been live on our web site for months. I'm getting sick of the Really Big Visual Basic Corporation though, and am in the process of converting the site to Python, which seemed to me to be about the best/easiest/really cool tools out there. I can run any SQL query via the ODBC 2 interface (Python 2.1) using the following code: dbc=odbc.odbc("datasourcename/as400username/password") cursor=dbc.cursor() cursor.execute("Select * from MYTABLE") result=cursor.fetchall() Works perfectly. However, if I try something like this: cursor.execute("{{Call LIB.PROGNAME(?,?,?,?,?,?)}}",['PARM1','TWO','THREE','1','','']) it bakes with "SQL0204 - PROGNAME in LIB type *N not found. in EXEC". Thoughts? From rjroy at takingcontrol.com Sun Jun 17 11:37:32 2001 From: rjroy at takingcontrol.com (Robert Roy) Date: Sun, 17 Jun 2001 15:37:32 GMT Subject: Pmw: how to clear ScrolledListBox ? References: Message-ID: <3b2ccea6.477584718@news1.on.sympatico.ca> On 16 Jun 2001 08:07:45 GMT, jp at ulgo.koti.com.pl (Jacek =?iso-8859-2?Q?Pop=B3awski?=) wrote: >I add items by .insert, what is correct way to remove all items? > setlist([]) should work. >-- >She never breaks into the conversation He seems to be the reason why she lives >She tries to be the perfect kind of stranger >But we always seem to love the most >The ones who never give "Between Two Hearts" - Ronnie James Dio From chris.gonnerman at newcenturycomputers.net Fri Jun 22 08:43:56 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Fri, 22 Jun 2001 07:43:56 -0500 Subject: File name from file descriptor? References: <3B3333FF.BB019208@snakefarm.org> Message-ID: <004101c0fb19$049c9a20$0101010a@local> What OS? Windows? Linux? In general, you can't under most OS's. In Linux 2.x you can poke around in the /proc filesystem and maybe get it. Why do you need to know? ----- Original Message ----- From: "Carsten Gaebler" Newsgroups: comp.lang.python To: Sent: Friday, June 22, 2001 7:03 AM Subject: File name from file descriptor? > Hi there! > > How can I determine a file's name if I only have the file descriptor? > os.fdopen(fd).name just returns '(fdopen)'. > > Regards > Carsten. > -- > http://mail.python.org/mailman/listinfo/python-list > > From jim at interet.com Thu Jun 28 12:29:37 2001 From: jim at interet.com (James C. Ahlstrom) Date: Thu, 28 Jun 2001 12:29:37 -0400 Subject: Zip problems References: <8cb9792f.0106212156.572e7e17@posting.google.com> Message-ID: <3B3B5B71.380676FE@interet.com> Ford Prefect wrote: > I have problems using zipfile. Script below makes a zip file but when > I try to extract files from the zip with WinAce or Windows Commander I > get CRC error. At first I thought the problem was in Windows Commander > and contacted the author (I also sent him the zip file). This is (part > of) his reply: > > "This ZIP file is indeed faulty. In the header it has a bit set that > the CRC > is stored after the packed data, with header PK#7#8. But this header > is > missing and there is no CRC following the data. The CRC field of the > local header is also empty." > > WinAce also reports CRC error. > I have looked at this, and I believe zipfile.py creates correct zip files. The claim that the header PK#7#8 should preceed the CRC is not correct. The CRC field has no header, and PK#7#8 is a special signature for spanned archives. Please see http://www.pkware.com/appnote.html for the definition of the zip format. Neither WinZip nor InfoZip reports any CRC errors on zipfile.py files. A workaround would be to use zipfile.py to create zip files in which the CRC does not follow the data, but is included in the file header. The zipfile.write() method does not do this, but you can use zipfile.writestr() instead. Use zero for the flag_bits, as the normal 0x08 means the CRC follows the file data. If this isn't clear, send me e-mail. Jim Ahlstrom From laurent.szyster at q-survey.be Fri Jun 29 21:32:32 2001 From: laurent.szyster at q-survey.be (Laurent Szyster) Date: Sat, 30 Jun 2001 03:32:32 +0200 Subject: Python for air traffic control? References: Message-ID: <3B3D2C30.CC00F16B@q-survey.be> Russ wrote: > > I am thinking about using Python for a unique safety-critical > application in air traffic control. (...) However, I am a bit > nervous about the lack of type checking and function prototyping, > among other issues. Is Python up to this task? Thanks for your > insights. Well, Russ if its for Brussels airport I would say no. I don' want to endorse that responsability for my hometown ;-) If this air traffic control system is to be installed in Phoenix Arizona or Salt-Lake City, I would say yes (I don't intend to go there a second time). Laurent From BPettersen at NAREX.com Mon Jun 11 15:45:28 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Mon, 11 Jun 2001 13:45:28 -0600 Subject: EXECing multiple lines. Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D44F@admin56.narex.com> > From: Joonas Paalasmaa [mailto:joonas at olen.to] > > What might be wrong when I get the following error? > > >>> exec """for x in range(5): > print x""" > Traceback (innermost last): > File "", line 1, in ? > exec """for x in range(5): > File "", line 2 > print x > ^ > SyntaxError: invalid syntax > >>> You need to indent the line "print x". -- bjorn From gideon at computer.org Thu Jun 21 02:20:27 2001 From: gideon at computer.org (gideon may) Date: Thu, 21 Jun 2001 08:20:27 +0200 Subject: Dynamic binding of class functions Message-ID: <3B31922A.F03D3DD2@computer.org> Hi, I have the following problem. I would like to dynamically add methods to existing instances of classes. I've succeeded creating a new function on the fly and adding it to the dictionary of the class instance, but when I try to call the method through class.newmethod(), the method doesn't receive the self paramater in the parameter list. I've tried the following code : def makefunc(r): func = 'def ' + r + '(self):\n' func = func + ' print "called ' + r +'"\n' func = func + ' print "dir = ", dir()\n' func = func + ' return "Done ' + r + '"\n' return func class Device: def __init__(self): self.host = "localhost" r = 'xxxx' f = makefunc(r) print f exec f in self.__dict__ if __name__ == "__main__": d = Device() print dir(d) d.xxxx() What am I doing wrong ? From rnd at onego.ru Tue Jun 19 06:19:19 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 19 Jun 2001 14:19:19 +0400 (MSD) Subject: import anydbm In-Reply-To: <3B2F231A.3E8A8A0@pool.informatik.rwth-aachen.de> Message-ID: On Tue, 19 Jun 2001, Morten Gulbrandsen wrote: > #!/usr/bin/python > import anydbm > file = anydbm.open("filename.txt") # link to external file > file['key'] = 'data' # store data by key > data = file['key'] # fetch data by key > > import cgi > form = cgi.FieldStorage() # parse form data (stdin, environ) > if form.has_key('name'): > showReply('Hello, ' + form['name'].value) > > morten at debian:~/Python/lpython/unix/examples$ ./page054.py > Traceback (innermost last): > File "./page054.py", line 5, in ? > file = anydbm.open("filename.txt") # link to external file > File "/usr/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 > morten at debian:~/Python/lpython/unix/examples$ > what am I doing wrong ? You forgot to create database. To do so you need to call anydbm.open("filename.txt", "c") before you could use database. Only once. After that your example will work. .txt is not good name for the db file, BTW. Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From skip at pobox.com Mon Jun 25 00:21:44 2001 From: skip at pobox.com (Skip Montanaro) Date: Sun, 24 Jun 2001 23:21:44 -0500 Subject: Question about profiling In-Reply-To: References: Message-ID: <15158.48216.93947.449572@beluga.mojam.com> TW> When I profile my code I get a lot of TW> :1(?) TW> that takes up alot of time. What does that mean? Patricia> Are you doing exec on a string somewhere? I see tracebacks Patricia> with when I have a error in a string that I exec. I must have missed the original question. I believe this is due to calling profile.run("...") where "..." is the call that is to be profiled. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From bastler at uwnet.nl Tue Jun 26 16:04:29 2001 From: bastler at uwnet.nl (Bastler) Date: Tue, 26 Jun 2001 21:04:29 +0100 Subject: Mutable Strings? References: Message-ID: <3B38EACA.365BC0B8@uwnet.nl> Eric, you wrote: > > Guys, > > I am somewhat new to python and I have a bit of a > question (as a side note, at work, I am a java > programmer mostly). In python, as in java, strings are > immutable objects (types in python I know). In any > case, Java has provided a StringBuffer class that is > basically a mutable string. Allowing you to append, > insert etc without creating a new object. This saves > quite a bit of object creation when any string > processing is required. > > I have been looking for similar functionality in > python and have yet to find it. I tried searching the > archives but any search for terms relating to strings > returns an enormous amount of hits. In any case, are > any of you aware of a anything in python that provides > this type of functionality? I am willing to write my > own I just don't want to reinvent the wheel. > I wrote a jython module stringBuffer.java that wraps a java.lang.StringBuffer in a java class file that can be used as a jython class. In case you are interested, let me know. I have a .tgz file ready (unix tar gzipped), but I could put it into other formats. I wrote it mostly to see how extension should be done in jython. I tried to minimize object creation. It works, some basic tests are there, but I have never checked actual performance. It could well be that the suggested alternative of using a list of non mutable strings is faster in most cases, due to the way the jython interpreter works and due to the overhead of locking done internally in java.lang.StringBuffer. I started writing it when I needed a buffer for socket.recv(), which may return any number of characters depending on network traffic conditions. Having written stringBuffer.java for jython I think an alternative implementation as a java char[] might be worth exploring for performance, provided that there is a very good java compiler to minimize the array boundary checks. As I work on powerpc's, there is no such compiler, so I stopped. Bastler From frankimmich at gmx.de Thu Jun 7 08:12:16 2001 From: frankimmich at gmx.de (Frank Immich) Date: Thu, 7 Jun 2001 14:12:16 +0200 (MEST) Subject: nt-services Message-ID: <23261.991915936@www36.gmx.net> Hello there, I have a question concerning socket connections running as NT-Service. I found the demoscript in win32/demos/service/ PipeService.py and I think (hope) I understood most of it. But transferring this example using sockets instead of named pipes doesn't work. Basically I want to have a little service running on NT which is waiting for a command from a Unix machine, passing back stdin , sdterr .... Without the NT-service-thing it is working fine. I hope you are good address for win32 questions. I have asked this in the german newsgroup too, but most of the guys seem to be more experienced in UNIX/LINUX (thanks for the answers, anyway). Maybe you can give me a clearer hint. Thanks in advance , Ciao Frank This is my little script with a very basic socket: import sys, os, string from socket import * import win32serviceutil import win32service import win32event import pywintypes port = 4127 BUFSIZE = 1024 class TestPipeService(win32serviceutil.ServiceFramework): _svc_name_ = "test" _svc_display_name_ = "test" def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) self.hWaitStop = CreateEvent(None, 0, 0, None) self.overlapped = pywintypes.OVERLAPPED() self.overlapped.hEvent = CreateEvent(None,0,0,None) #I have to use overlapped I/O, right ?? def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) SetEvent(self.hWaitStop) def SvcDoRun(self): s = socket(AF_INET, SOCK_STREAM) s.bind(('', port)) s.listen(1) while 1: conn, (remotehost_ip, remoteport) = s.accept() I don't know how to wait for the connection (accept) "event" and how to process the event ? The guys from the german newsgroup told me to use win32file.AcceptEx ??? but I don't know how... myHandels = self.hWaitStop, self.overlapped.hEvent stp = win32event.WaitForMultipleObjects(myHandels,0,win32event.INFINITE) if stp==win32event.WAIT_OBJECT_0: break else: hostname, aliaslist, ipaddr = gethostbyaddr (remotehost_ip) data = conn.recv(BUFSIZE) if not data: break data = data + " host:" + hostname conn.send(data) conn.close() if __name__=='__main__': win32serviceutil.HandleCommandLine(test) -- Machen Sie Ihr Hobby zu Geld bei unserem Partner 1&1! http://profiseller.de/info/index.php3?ac=OM.PS.PS003K00596T0409a -- GMX - Die Kommunikationsplattform im Internet. http://www.gmx.net From aetodd at wm.edu Tue Jun 19 09:39:59 2001 From: aetodd at wm.edu (Andrew Todd) Date: Tue, 19 Jun 2001 09:39:59 -0400 (EDT) Subject: Serial IO In-Reply-To: References: Message-ID: <992957999.3b2f562f24a8a@webmail1.wm.edu> Hey, I was looking through python.org and I noticed there was a serial io package for python, but it was for version 1.5. Is there going to be a release for python 2.1 or 2.2? or is the code compatible? Also, if anyone knows of any GPIB modules please let me know. Thanks. -Andrew From haaserd at yahoo.com Wed Jun 13 16:38:30 2001 From: haaserd at yahoo.com (haaserd) Date: Wed, 13 Jun 2001 13:38:30 -0700 Subject: os.chdir() and import Message-ID: <3B27CF46.ACA87D53@yahoo.com> Under Windows and Python 2.1, I am sometimes able to use an os.chdir('xxx') and then follow this with an import command for a module located in the 'xxx' directory. However, it seems that when the module doing the os.chdir('xxx') and import-ing is executing because of an execfile() command, this technique doesn't work and an import error occurs. A search of the documentation seems to indicate that the import search path is determined only by the value of sys.path ("...It [import] generally involves searching for a ``built-in'' module with the given name and then searching a list of locations given as sys.path." -- Python Reference Manual 6.11). I think "generally" here may refer to the unique processing used for packages, but...? Can someone clear this up for me? Should sys.path always be modified instead of using os.chdir? Roger Haase From ajm at enteract.com Tue Jun 26 13:03:06 2001 From: ajm at enteract.com (Alan Miller) Date: Tue, 26 Jun 2001 12:03:06 -0500 Subject: Windows Printing using win32print References: Message-ID: Timothy Grant (tjg at hyperlinq.net) wrote: >I'm not much of a windows programmer, but I am in a situation >where I need to write a test programme that does a lot of very >small print jobs from a Windows box. I have downloaded >win32all, and cobbled together a little app that I think >should, maybe work, but doesn't. > >printer = win32print.OpenPrinter('Tektronix Phaser 600 Extended') >jid = win32print.StartDocPrinter(printer, 1, ('TEST DOC', 'c:\\test\\test.tjg', 'RAW')) >bytes = win32print.WritePrinter(printer, text2print) >win32print.EndDocPrinter(printer) >win32print.ClosePrinter(printer) I'm not sure of the details because StartDocPrinter and EndDocPrinter appear to be new additions to win32print and they aren't covered in the documentation on the web site. In a VB program I did some time ago, I wasn't initializing the data type (you're passing 'RAW') and had no problems at all. Looking at some of the online docs from MS, it's not clear that anything other than an empty string is required - they have examples that theoretically do the same thing, but some pass RAW and some pass an empty string. I'd try passing an empty string in that tuple. ajm From gerhard.nospam at bigfoot.de Fri Jun 1 18:02:40 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sat, 2 Jun 2001 00:02:40 +0200 Subject: MONEY 4 U References: Message-ID: On Fri, 1 Jun 2001 23:50:09, mick at hotmail.com wrote: > >------------------------------------------------------------------ > FOR THE BEST A... F... SITE EVER ON THE WEB!!! >[...] Could someone who can get the neccessary information out of the headers please get this spammer f...ed? I am unable to get enough clues out of the posting headers. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://highqualdev.com public key at homepage public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From bokr at accessone.com Wed Jun 20 14:30:25 2001 From: bokr at accessone.com (Bengt Richter) Date: Wed, 20 Jun 2001 18:30:25 GMT Subject: Two minor syntactic proposals References: <9gkcsn0229c@enews2.newsguy.com> <3B301914.7B60E6F7@my.signature> Message-ID: <3b30dfdd.1004313135@wa.news.verio.net> On Wed, 20 Jun 2001 15:31:32 +1200, Greg Ewing wrote: [...] >By the way, here's another possible use -- creating >a dict-of-funcs for simulating a case-statement: > >table = {} > >def table['spam'](): > ... > >def table['eggs'](): > ... [...] This is possible now: table={} table['x2']=lambda x: x*2 but how about this: # using a proposed full def version of lambda: table['spam']=def(optional,arg,list): """I am (possibly) the value of 'spam' in dict table.""" print "I was defined with full function def capabilities." print "I.e., multiple statements, etc." with the effect of define anon_spam(): """I am (possibly) the value of 'spam' in dict table.""" print "I was defined with full function def capabilities." print "I.e., multiple statements, etc." table['spam']=anon_spam del anon_spam The left hand side of a table is actually irrelevant to the main idea of the enhanced lambda capability. I.e., I wouldn't mind in general using foo=def(bar,baz): etc instead of def foo(bar,baz): etc From greg at cosc.canterbury.ac.nz Mon Jun 25 23:56:13 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Tue, 26 Jun 2001 15:56:13 +1200 Subject: Please statement (Re: Is this a true statement?) References: Message-ID: <3B3807DD.B332F0C7@cosc.canterbury.ac.nz> "Steven D. Majewski" wrote: > > ( And I DO wish more languages had adopted Intercal's "Please" > statement -- it would make programs so much nicer to read! ) I can even think of a use for it in Python. Some people feel that it would be useful to have some sort of "directive" or "pragma" statement for specifying compile-time options. Calling it "please" would be a nice way of conveying that the implementation is free to honour it or not, as is convenient. e.g. please: call_del_methods_when_collecting_cycles optimise_integer_variables declare_generators_using_keyword("generator") # :-) -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From BrianQ at ActiveState.com Wed Jun 27 18:05:56 2001 From: BrianQ at ActiveState.com (Brian Quinlan) Date: Wed, 27 Jun 2001 15:05:56 -0700 Subject: Extending python & mutability In-Reply-To: Message-ID: <002201c0ff55$579290a0$b503a8c0@activestate.ca> > When extending python, if I have a function that is expecting > a list whose contents are mutible, can I modify the contents > and will the changes be reflected in back in Python? Yes, any changes that you make to objects that you are passed will be reflected in Python. From bernhard at intevation.de Mon Jun 18 05:27:41 2001 From: bernhard at intevation.de (Bernhard Reiter) Date: 18 Jun 2001 09:27:41 GMT Subject: Python 2.0.1c1 - GPL-compatible release candidate References: Message-ID: <9gkhid$9jcft$3@ID-89274.news.dfncis.de> In article , Guido van Rossum writes: > With a sigh of relief I announce Python 2.0.1c1 -- the first Python > release in a long time whose license is fully compatible with the GPL: Hurray! Thanks for all the work and patience needed to resolve this. Bernhard From aahz at panix.com Thu Jun 28 10:39:12 2001 From: aahz at panix.com (Aahz Maruch) Date: 28 Jun 2001 07:39:12 -0700 Subject: Google results (was Re: PEP 260: simplify xrange()) References: <6qg0ckydud.fsf@abnoba.intevation.de> Message-ID: <9hffig$m17$1@panix6.panix.com> [Just a reminder to please change the Subject: when appropriate.] In article , Michael Hudson wrote: > >I wonder what I did for google to think I'm the most significant >Michael Hudson on the web... It's not what you did, it's what other people did. That is, you've probably got more links *to* you than other people. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Those who do not remember the past are condemned to repeat it." From bokr at accessone.com Thu Jun 14 15:33:55 2001 From: bokr at accessone.com (Bengt Richter) Date: Thu, 14 Jun 2001 19:33:55 GMT Subject: Telling python where to look for a script References: <3B285BFD.D2AC7E26@rk-speed-rugby.dk> <9ga20f02hsk@enews1.newsguy.com> <3B289D8E.96908690@rk-speed-rugby.dk> Message-ID: <3b290e35.491889970@wa.news.verio.net> On Thu, 14 Jun 2001 13:18:38 +0200, Brian Elmegaard wrote: > > >Alex Martelli wrote: >> >> the backslashes:-). A module is meant to be imported. >> A foo.py file can be both, but adapting the path is >> relevant to module-use only, NOT to script-use. All >> clear so far...? >> >No, I'm sorry. > >Being in c:\foo I would like to be able to execute bar.py on baz.dat >being in . just by typing: > >c:\foo>python bar.py baz.dat > >Then I need something path-related with scripts, don't I? If you're on windows, you should be able to type c:\foo>bar.py baz.dat IOW, let the windows shell find python.exe for you when it sees the '.py' on the 'bar' Of course, bar.py must be on your windows PATH for it to find that, and the .py file association must be set up, but baz.dat will have to be in your current working directory or you'll have to specify a full path, unless your bar.py has a programmed search of its own to look for baz.dat. In my case, I'm on NT4sp3 and this shows the associations: -- [12:35] C:\pywk>assoc .py .py=Python.File [12:35] C:\pywk>ftype Python.file Python.file=D:\Python21\python.exe "%1" %* -- The only trouble with this is that you won't be able to redirect or pipe the output if you depend on the windows shell to execute python for you. A PIT* windows 'feature' that affects perl and other similar situations also. For a specific foo.py, you can wrap it in a foo.cmd that exlicitly executes python with the args. Then you can redirect the output of that as normal.E.g., @REM foo.cmd wrapper for foo.py @python foo.py %* You probably will want to put in full paths for python and foo in the above. HTH From aleaxit at yahoo.com Sun Jun 10 11:38:09 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 10 Jun 2001 17:38:09 +0200 Subject: floating point in 2.0 References: <3B2120AF.9306D1E3@home.net> Message-ID: <9g048e0237j@enews2.newsguy.com> "Chris Barker" wrote in message news:3B2120AF.9306D1E3 at home.net... > You know, after reading all this (I do find it interesting), I wonder > why I have never seen a language include an easy way to get/compare a > floating point number in a given precision. One of the first things we ... > if fp1 == fp2 (in the first 5 decimal digits.) ... > Does anyone have any nifty algorithms that they use for this that they > would like to share? I'd at least like to put them into my own toolbox. D:\py21>python Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. Alternative ReadLine 1.4 -- Copyright 2001, Chris Gonnerman >>> import gmpy >>> print gmpy.reldiff.__doc__ reldiff(x,y): returns the relative difference between x and y, where x and y can be any numbers and get coerced to mpf; result is a non-negative mpf roughly equal to abs(x-y)/((abs(x)+abs(y))/2). >>> if gmpy.reldiff(0.6,6/10.)<1e-5: ... print 'ok' ... ok >>> See http:\\gmpy.sourceforce.net. I slipped behind in the schedule I had given myself to release a beta for gmpy, but what is missing is mostly documentation in Python standard form -- latex stuff, docstrings in the nice first-line/rest-of-it split form, &c -- the code seems to work pretty solidly, and relative-difference measurement in particular is useful. Pretty easy to do for Python floats in a tiny C extension, if you use that functionality often, e.g.: ::: setup.py: from distutils.core import setup, Extension reldif = Extension('reldif', sources=['reldifmodule.c']) setup (name = "reldif", version = "0.1", description = "Relative difference of floats", author = "Alex Martelli", author_email = "aleaxit at yahoo.com", ext_modules = [ reldif ] ) ::: reldifmodule.c: #include "Python.h" #include static PyObject * reldif(PyObject *self, PyObject *args) { double x, y, z; if (!PyArg_ParseTuple(args, "dd", &x, &y)) return 0; z = fabs(x)+fabs(y); if(z) { z = 2.0*fabs(x-y)/z; } return Py_BuildValue("d", z); } static PyMethodDef ReldifMethods[] = { {"reldif", reldif, METH_VARARGS}, {0, 0} }; void initreldif() { Py_InitModule("reldif", ReldifMethods); } ::: You may have to add some -lm on Unix (don't have it around to try), but that's all you need on Windows: D:\py21>python setup.py install running install running build running build_ext building 'reldif' extension D:\msdev6\VC98\BIN\cl.exe /c /nologo /Ox /MD /W3 /GX -ID:\PYTHON21\Include /Tcre ldifmodule.c /Fobuild\temp.win32-2.1\Release\reldifmodule.obj reldifmodule.c D:\msdev6\VC98\BIN\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:D:\PYTHON21\li bs /EXPORT:initreldif build\temp.win32-2.1\Release\reldifmodule.obj /OUT:build\l ib.win32-2.1\reldif.pyd /IMPLIB:build\temp.win32-2.1\Release\reldif.lib Creating library build\temp.win32-2.1\Release\reldif.lib and object build\tem p.win32-2.1\Release\reldif.exp running install_lib copying build\lib.win32-2.1\reldif.pyd -> D:\PYTHON21 Now: D:\py21>python Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. Alternative ReadLine 1.4 -- Copyright 2001, Chris Gonnerman >>> import reldif >>> reldif.reldif(2/3.0,0.66666) 1.0000050000148979e-005 >>> You might want to have a "relcmp" that more directly addresses your concerns, taking x and y (and possibly the tolerance, which it might default) and returning -1, 0 or 1 like the builtin cmp. It might be dangerous (in theory) to have that lying around -- if you passed it to a list's sort method it might give strange results as the 'equality' it defines is not transitive... so, I prefer to have the reldiff only and pay the (small) price of comparing it directly with the relative-epsilon I need. Alex From m.linnemann at addcom.de Wed Jun 13 16:45:44 2001 From: m.linnemann at addcom.de (Michael Linnemann) Date: Wed, 13 Jun 2001 22:45:44 +0200 Subject: Postgresql Woes References: <436ad7a4.0106131131.57bc1cd1@posting.google.com> Message-ID: Am 13 Jun 2001 12:31:21 -0700 schrieb Sreekant: >I have made a few web sites with postgresql but never needed to know >the list of tables available in the database through pg module. >I guess you can use psql and \dt command or os.popen('psql ... , to >get the list of tables. But is there a decent way of finding out >through python and postgresql [pg] module , all the tables in a >database! Call psql with the -E parameter and it will tell you all its secrets :-) BTW, I found this in the FAQ. Seems they are well worth reading. Regards Michael From nperkins7 at home.com Wed Jun 13 18:43:51 2001 From: nperkins7 at home.com (Nick Perkins) Date: Wed, 13 Jun 2001 22:43:51 GMT Subject: Decimal can be Binary Too (was decimal or rational) References: Message-ID: "Mikael Olofsson" wrote in message news:XFMail.20010608083930.mikael at isy.liu.se... > .....< about fastest way to multiply by ten>... > What's more expensive here, add or shift? I'm more into hardware, and > hardwired shifts are costless (disregarding overflow checks), while > hardwired adds are not. I am not an expert on modern CPU architechture, but I strongly suspect that things like multiplying two integers are already optimized, and that there would be no advantage to trying to be tricky about it. Besides, you should let the C compiler decide which way is fastest. From jlohr at post9.tele.dk Mon Jun 11 12:02:09 2001 From: jlohr at post9.tele.dk (Jesper) Date: 11 Jun 2001 09:02:09 -0700 Subject: How do you develop in Python? References: <050620011516094693%pecora@anvil.nrl.navy.mil> Message-ID: Don't know if it is any help but I found this on Useless Python (http://www.lowerstandard.com/python/index.html). I have not tried it so I can not tell you if it works as described but it looks straightforward (on second thought I guess it won't work with 'from module import *'. Oh well -- can?t get it all): reloadall.py: import types def status(module): print 'reloading', module.__name__ def transitive_reload(module, visited): if not visited.has_key(module): # trap cycles, dups status(module) # reload this module reload(module) # and visit children visited[module] = None for attrobj in module.__dict__.values(): # for all attrs if type(attrobj) == types.ModuleType: # recur if module transitive_reload(attrobj, visited) def reload_all(*args): visited = {} for arg in args: if type(arg) == types.ModuleType: transitive_reload(arg, visited) if __name__ == '__main__': import reloadall # test code: reload myself reload_all(reloadall) # should reload this, types From ullrich at math.okstate.edu Wed Jun 6 10:52:55 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Wed, 06 Jun 2001 14:52:55 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> <3b19393d.703539923@news.okstate.edu> <9fgkci0gdu@enews2.newsguy.com> <3b1ce391.2243151@nntp.sprynet.com> <9fj24r01hpj@enews1.newsguy.com> Message-ID: <3b1e3e18.160819@nntp.sprynet.com> On Tue, 5 Jun 2001 18:41:54 +0200, "Alex Martelli" wrote: >"David C. Ullrich" wrote in message >news:3b1ce391.2243151 at nntp.sprynet.com... > ... >> [c] >> >> A perfect RNG is one with this property: >> >> If you use it to generate N bits then each >> >> sequence of N bits appears with probability >> >> 1/2^N. It has this property for _every_ N. > ... >> The property you're talking about is that >> all sequences of N bits appear in the >> sequence with frequency 2^(-N) (asymptoticaly). > >Thanks! > >> This is not the same as [c]. > >I fail to see the difference, All I can _guess_ is that you're taking something about frequencies as the definition of "probability". > when I use >my hypothetical normal-but-computable number >(thanks for informing me that pi is not known >to be, just so hypothesized, but that there are >others that are known to be -- and the vaguely >Cantorian construction of just writing the >integers in sequence one after the other, that >you use later, sounds quite a simple example >and rings some vague bell...) Yeah, it's someone's constant. > as a 'generator', >by asking about its next N bits each time. > >I agree there need be nothing random or >non-compressible about the hypothetical >number -- (c) didn't mention anything about >that, just "normality" (normalness?) of >the bitsequence. Nope. [c] says nothing whatever about frequencies. If you use a perfect RNG (which I'm taking as defined by [c]) the ouput _need_ _not_ be normal. It will be normal with probability 1. > Now that we agree that >normalhood (normalance?) of a bitsequence >is achievable by arithmetic generators, If you'd asked whether normality could be achieved by an arithmetic RNG I would have said "yes of course" at any time during all this. Look. Consider the following RNG. At startup we initialize RandSeed to 0. Now we do this def rand(): global RandSeed RandSeed = RandSeed + 1 return RandSeed That is an RNG that _does_ achieve normality. Do you _really_ think that JVN _overlooked_ this admittedly tricky algorithm? Like he says anyone [etc], someone points out the rand() above, and he replies "Oh, scuse me, sorry." >we can presumably lay this sub-sub-sub-part >of the discussion aside (but meanwhile I >have refreshed my dim memories and thereby >benefited -- thanks). > > >> >But isn't that the reason we have Turing machines, >> >their infinite tape?-) >> >> Um, you're absolutely right about this. I guess >> I was assuming a bounded amount of storage in > >If you look at the way disk prices are going, >we might be there: place a sum in a bank, each >time the disk is close to running out take some >of the interest and use it to go buy a new disk... >as long as you only use a finite amount _at a >time_, you're approaching UTM's unboundedness:-). >(hot-swap RAID controllers assumed of course:-). > > >> I still suspect it's true that given anything >> which I would call an arithmetic RNG there >> exists a "randomness test" that the RNG will >> fail, which a "perfectly random" RNG would pass. >> But the proof above is nonsense, because I do >> mean to allow unbounded storage (otherwise >> things are boring). > >And we still need the "perfectly random RNG" >definition to allow us to see if we can prove >we can't do it arithmetically, since [c], >while part of that definition, is not sufficient >for such proof (nor, in fact, to meet what _I_, >with my much-weaker intuitive criteria, would >deem 'random enough for me' -- pi, or whatever >normal number must take its place, being all >too predictable). If simply outputting the bits of a normal number gave something that satisfied [c] you'd have a point. But it doesn't. Look. We make an RNG that returns pi in decimal. If it's an RNG satisfying [c] then the probability that the first digit is 3 is supposed to be 1/10. And the probability that the first digit is 1 is supposed to be 1/10 as well - that's what [c] says. Do you _really_ think it makes sense to talk about the _probability_ that the first digit of pi is 3? Answer the question instead of only replying to the parts you feel like replying to. _Do_ you think it makes sense to talk about the probability that the first digit of pi is 3? (Or rather: Does it really make sense to say that the probability that the first digit of pi is 1/10?) >> To put it another way: Consider the number >> >> 0.0123456789101112131415161718192021222324... >> >> consisting of all the natural numbers written >> one after the other (took decimal to make >> the pattern more clear). This _is_ a normal >> number, which is to say that the digits of >> this number _are_ "random" in the sense >> that we're assuming the digits of pi are >> random. It doesn't really look like a >> "random" number, does it? Seems kind of >> easy to predict the next digit. > >Yep, it has lot of structure and can in fact >be generated by a very small program (as can >pi, but this one looks like I can make an >even smaller program). > >So what is "perfect" in a "perfectly random" >normal real number? I realize you don't >want to talk about random NUMBERS (or >sequences) but random GENERATORS, but if >I have a number I can make a generator and >vv from the actual sequence of bits a >generator gives me I can make a number -- >say there is no "rewind", no time machine >(Guido has the only one and he ain't gonna >lend it to us), so that all we can do is >ask the generator, a black box, for "N >more bits please" and it will comply, >now couldn't we biject between generators >seen this way and real numbers? > >Maybe we can't, but if so I fail to see >why. You could biject this way between numbers and _determinisitic_ generators. > How should we define a "generator" >in a way that's general enough to let us >study under the same hat very different- >nature ones (so we can't peek under the >hood, just look at the output) if not as >a machine that gives me "N more bits" when >I ask for them? Now we can maybe devise a >test that we can prove the machine will >fail if it is generating by using arithmetic >while the "perfect" generator will pass? A test that the bits-of-pi RNG will fail is this: Reboot and check whether the first digit returned is 3. Repeat. If you get 3 more than 1/10 of the time after a large number of trials that's reason to suspect you do not have a perfect RNG. >I don't think it needs to be a finite-time >test, either (else the 'perfect' part >seems to have little use:-). Compressibility >looks nice to me here. No compressibility in >the 'perfect' generator, surely. ??? If we're talking about _sequences_ of bits then I think I know what compressibility means. I don't know what it means for an RNG to be incompressible. (You're the only person here who's insisting that the two are the same - others have pointed out more than once that there's simply nothing "random" about the digits of pi.) What's good enough depends on what you're doing. For many purposes outputting the digits of a normal number _is_ good enough. But there can be a lot of correlation between the digits in a normal number, rendering them not good enough for other purposes. > But is this >the definition of 'perfect' you want to use? I've already given _a_ definition above. (If you note the definition of the word "independent" you see that [c] is the same as saying that the bits returned are independent, and equal to 0 or 1 with probability 1/2.) >Or just a CONSEQUENCE of how you really want >to define it...? > > >Alex > > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From daniels at mindspring.com Tue Jun 5 22:45:00 2001 From: daniels at mindspring.com (Alan Daniels) Date: Tue, 05 Jun 2001 22:45:00 -0400 Subject: integers References: <9fjd8q$qb6$1@charm.magnus.acs.ohio-state.edu> <9fjgqf$rp0$2@brokaw.wa.com> Message-ID: <696rhtkhgtf4o1i5u05e4k9pvujb8kmqaa@4ax.com> On Tue, 5 Jun 2001 13:55:57 -0700, Humanity let out a collective sigh of relief when Jonathan Gardner finally typed: >What is the reason that python doesn't have increment or decrement >operators? Integers in python are immutable (same as strings, floats, tuples, etc). That is, they're objects that cannot have their contents changed once they are created. In other words, having a ++ or -- operator doesn't make any sense since integers can't be changed in place. When you say "x = x + 1", you're really creating a new integer object and assigning over the old one. I believe the new "x += 1" syntax is just synactic sugar which serves as shorthand for "x = x + 1", although I'd have to delve through the interpreter source code to be 100% sure. (This question comes up often enough... I wonder if it should be in the FAQ?) ============================== Alan Daniels daniels at alandaniels dot com From JamesL at Lugoj.Com Fri Jun 15 13:58:12 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Fri, 15 Jun 2001 10:58:12 -0700 Subject: VI References: <3B278900.5828FB59@Lugoj.Com> <9gaunm$mth$3@brokaw.wa.com> <9gdcl10oti@enews1.newsguy.com> Message-ID: <3B2A4CB4.FE31CB72@Lugoj.Com> Alex Martelli wrote: > "Jim Hill" wrote in message > > And since the expected editor war hasn't broken out, I'll launch a > > different offensive by proclaiming absolutely and without room for > > disagreement that it is pronounced "vee eye" and those who say "vye" > > are bloody peasants who should be repressed by the violence inherent > > in the system. > > I thought _everybody_ knew it's pronounced "six" -- like in "Pope > Paul VI", no?! Is the Pope Muslim? (Since Unix is case sensitive, VI is a different command from vi....) From fdrake at acm.org Fri Jun 15 21:42:05 2001 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Fri, 15 Jun 2001 21:42:05 -0400 (EDT) Subject: str smarter than round? In-Reply-To: References: <9F852011A819CAA6.2C9141DBD4DB433F.3BFF2DB5D91E2E16@lp.airnews.net> Message-ID: <15146.47469.407473.251296@cj42289-a.reston1.va.home.com> [Cameron Laird] > Is there or will there be a (more) persistent URL for this > Appendix? I assumer "node14" is likely to vary every few > weeks or so. Unless the structure of the tutorial changes significantly (more chapters or appendices added before this one), the final URL for this in the Python 2.2 documentation will be: http://www.python.org/doc/current/tut/node14.html Since the tutorial is meant to be read linearly, we've passed on trying to maintain specific page names. Our current processing tools aren't sufficiently controlable to generate the right filenames reliably. Hopefully this will change when we move to XML and new tools. -Fred -- Fred L. Drake, Jr. PythonLabs at Digital Creations From alankarmisra at hotmail.com Thu Jun 28 13:23:59 2001 From: alankarmisra at hotmail.com (gods1child) Date: 28 Jun 2001 10:23:59 -0700 Subject: Introspection Message-ID: <25b2e0d9.0106280923.31cadb06@posting.google.com> Is there a good resource that gives comprehensive coverage of Python's introspection capabilities all in one place? Thanx. From ejr at cs.berkeley.edu Sun Jun 10 21:48:35 2001 From: ejr at cs.berkeley.edu (Edward Jason Riedy) Date: Mon, 11 Jun 2001 01:48:35 +0000 (UTC) Subject: Future floating point directions? [was Re: floating point in 2.0] References: Message-ID: <9g181j$pao$1@agate.berkeley.edu> And Tim Peters writes: - - Python has no 754 story -- it doesn't try. Which is really astonishing for a language aiming at ease of use and teaching. Yes, I know, it's someone else's fault. (Not that I've been jumping up and down with code. sigh... C++ sucks my will to code, but I don't know any more flexible language that compiles on both a T3E and an SP.) - (and sorry to say I'm not sure it ever will be -- there too it's an - optional thing). I can think of three companies with test vectors being developed, so I assume there's something to test. Of course, all three also sell hardware with these features. gcc's coming along, but with much more finely stretched resources. - It certainly wasn't. Fusing the mul and add HW wasn't even suggested by - 754, it was something they did to reduce chip real estate, [...] Nope. They happened to have a chunk of space left, someone suggested fma for correctly rounding an iterative division, and an engineer did it over a weekend, fitting it into the add, mul, and extra space. Can't remember his name, but I can dig through my notebook if necessary. Story from Dr. Kahan, who was there. Go fig. - and because they had clear ways in mind to speed math libraries [...] Actually, it was for getting a division without a divider. But your point's mostly valid. The primary push was on getting some extra speed (software-ish, thus pipelined, divide), but the group also wanted to compete on reliability features. Thus the extra breakdown of the invalid flag. Most of the features we want to add will address reliability / debugability in some way. Things like trapping methods that don't require precise interrupts, etc. - Sun is an exception, and I'd guess more due to David Hough's - influence and persistence than to anything else -- Yes, but he's not the only one at Sun. They're mostly ex-students of Dr. Kahan's, though. And I could have drawn an example from HP, and that wouldn't be because of a Kahan student. Surprising, but true. ;) - Virtually all HW FPUs support them, and because they're required. And because rounding modes are nigh impossible to implement in software. I do wish software had access to the three extra bits necessary to round correctly. Compiling without double-rounding on x86 is pretty difficult without them. - Without that C99 wouldn't have even considered it (part of X3J11's - mandate is not to require things that can't be done w/ reasonable - efficiency, so w/o near-universal HW support already in place, they - would have punted on this too). Um, fma is required in C99. It certainly lacks near-universal hardware support... And portability pressures have a way of making optional features required. Look at how many vendors have Linux syscall translation layers. - Tossing "recommended" out the window is the best tool a std has. Considering the groups being targetted have completely ignored REQUIRED pieces, I don't know if it matters. - You said you're introducing a quad format, and I assume that's - "the usual" 15-bit exponent + 113-bit mantissa one, so stop at - required correct rounding to and from no more than 36 decimal - digits, and everyone will be happy (this can be done with code - much simpler than Gay's, and also without bigint arithmetic). Well, if the only defined destinations are single, double, and quad, then you only have to support conversions to those destinations. The standard only defines things in the standard. - > Binary to decimal is constrained so that binary -> decimal -> binary - > produces the same number if both binary numbers are in the same - > precision. - - Users want that, but IIRC 754 already requires it. Not quite. It's required for a smaller range than is now possible. - WRT single default, it doesn't have enough precision to avoid gross - surprises -- newbies aren't forecasting the weather with one-digit - inputs, they're calculating their retirement benefits based on 20% - compound growth for 50 years . Ok. Calculate in double precision with single precision inputs and output. You'll get _much_ more reliable answers. But unfortunately, Python doesn't make that easy. A calculator with that feature (the HP 12C) does use extra precision in the calculation. - Single is a storage-efficiency gimmick for big problems with - low-precision data. Nonsense. Single precision is for limiting the effects of rounding. Single precision without double precision is incredibly silly (although some DSPs seem to survive). Single- precision defaults require a wider evaluation type. - "Number-like types" include things like Dates and Times in Python; - there is no widest numeric type, and the set of numeric types isn't - even known at compile-time (users can add new ones on the fly). At the very worst, you can find the widest common type of all floating-point numbers in a given statement. Consider a statement containing arithmetic-looking operations. The interpreter can evaluate all the methods appearing in the statement first. Then it can examine the objects involved and find anything that's a floating-point type. Dates and times aren't floating-point types. All the floating-point types can be coersed up once. This does require that the floating-point types be comparable, but that's reasonable. Yes, this does change the semantics slightly. Anyone relying on both the order and results of subexpression evaluation to pass information silently between objects should be shot, so I don't think it's a big loss. It also changes the implementation a great deal, which is why there are no patches attached. ;) I'm trying to find a sensible extension outside of statement- level, but it might be hopeless. It certainly can't be perfect, as there is no way to assume that the types involved are at all related to the types of the inputs, but there may be a reasonable compromise for 90% of the code. A run-time type inferencer? Think that could be useful well beyond floating- point expressions. (IMHO, static and dynamic typing is simply a matter of time scale. Everything is statically typed when it is actually executed (run through the processor) and dynamically typed during development.) - Even restricted to floating types, at least two Python GMP - wrappers exist now, at least one of which exposes GMP's - unbounded (but dynamically specified) precision binary fp type. This should _not_ be mixable with typical floating-point numbers without the programmer saying it's ok. The semantics are entirely different. If you want them mixed, you should be promoting everything they touch to the arbitrary length types. Think of the user whose problem is actually in the decimal->binary conversion. Or a case like z = a + b + c, where a is a gmp type. Is it [(a + b) :: gmp-type + c] :: gmp-type, or [a + (b + c) :: Python float] :: gmp-type? Yes, _I_ know it's left-to-right, but must everyone be a language lawyer? What if a user of a routine had input c as a gmp-type, intending for the internals to use arbitrary precision? The routine would have silently used fixed precision intermediates. Makes using these things too painful. Consider too interval arithmetic. For intervals to be really useful, even the decimal->binary conversions touching an interval need to return intervals. Otherwise, you've violated the properties guaranteeing that the answer lies within the result interval. Requiring explicit casts to intervals doesn't mesh well with a dynamically typed language like Python. That makes the code much less reusable. Actually, with a widest-feasible evaluation strategy, you _can_ mix these pretty well. You'll get the most expected results. I'm still not comfortable with mixing random-length floats with fixed-length floats, especially when division, square root, and elementary functions are involved, but intervals and further fixed-length floats work beautifully. On the flip side, complex really shouldn't be silently mixed with real at all. Imagine a beginner trying Cholesky factorizaion in Python. It'll seem to run just fine. Any solve with the factors will give only real numbers from real numbers. But some results are completely, SILENTLY wrong. Why? The matrix wasn't positive definite. It should have choked, but entries silently went imaginary. Solves will still produce real numbers. Now imagine debugging a program that has a symmetric solve somewhere. Would you spend much time looking at one of the best- understood portions? Or would you end up blowing a huge amount of time checking input, data structure conversions, etc.? Most programmers would assume it's a ``problem with floating-point arithmetic.'' There are similar problems with many textbook formulas and complex arithmetic. Perhaps people should know better, but how often do they? Wouldn't it be better for Python to help them learn? It somewhat does by separating math and cmath. This one isn't something that can be handled with a `widest' evaluation scheme; silently mixing these types in any way can lead to horrible bugs. Yeah, this goes against the dynamic typing ideal, but it does bite students in Matlab... A block-level parameter that allows or disallows mixing with complex may be the most useful, but I'm still pondering. So some attempt at a widest-feasible evaluation scheme would greatly help programmers get the results they expect. It also gives tools to avoid silent, incredibly hard to find bugs. Both are good things for Python, and worth some consideration. Jason -- From rgruet at intraware.com Sun Jun 17 22:24:43 2001 From: rgruet at intraware.com (Richard Gruet) Date: Mon, 18 Jun 2001 02:24:43 GMT Subject: why is there no class (static) methods in Python ? References: <3B2D114E.7B39D954@intraware.com> Message-ID: <3B2D6669.7DEFD13F@intraware.com> Martin, Martin von Loewis wrote: > Richard Gruet writes: > > > I (and other people on the Python french mail list) wonder why there > > are no class (static) methods in Python. You cannot define a really > > unbounded (ie to an instance) method within the namespace of a class. > > First of all, you *can* define such a thing if you absolutely want, see > > http://www.python.org/doc/FAQ.html#4.84 > Thanx for the info. But the FAQ confirms that there is no way to define easily a class method. What is recommended (define a module fct) is already what I use. > > It's not natural nor elegant to have to create an instance to call a method > which is not related to a particular instance. We would like to be able to > write things like: > > > > class C: > > def staticFoo(x): print x > > > > C.staticFoo(1) > > I'd like to question why you want to do this. Isn't it much better to write > > class C: > pass > > def staticFoo(x): > print x > > I.e. what has class C to do with staticFoo? Of course, my example is fictitious and was only intended to show the desired syntax. But the reason to choose to define a function as a class method rather than a mere (static) function is -obviously- when this function is closely related to the class itself, not to one of its instances. Some languages like smalltalk even define classes as instances of metaclasses, which makes sense. Then you can see class methods like methods of instances that are actually classes. In fact, constructors (and destructors) are class methods, not instance methods, but they are handled specially in the language so they appear as instance methods.. Typical examples of class methods: loadInstanceFromStream(aStream) # Create an instance from its persistent state read on a stream getInstanceCount() # returns the number of instances of this class getInstanceList() # returns the list of instances of this class getClassName() or getAnyInfoOntheClass() ...... Richard -------------- next part -------------- A non-text attachment was scrubbed... Name: rgruet.vcf Type: text/x-vcard Size: 370 bytes Desc: Card for Richard Gruet URL: From nperkins7 at home.com Fri Jun 1 20:48:47 2001 From: nperkins7 at home.com (Nick Perkins) Date: Sat, 02 Jun 2001 00:48:47 GMT Subject: py2exe - too many Tk files References: <9er9j50uv7@enews1.newsguy.com> <9errhd01gl6@enews1.newsguy.com> <90B2C3EEBgmcmhypernetcom@199.171.54.194> Message-ID: "Gordon McMillan" wrote in message > Installer, by default, excludes /demos and /images. Don't know about > Thomas, but I didn't feel like writing a dependency tracker for Tcl/Tk and > a quick look around didn't find one. ..well, that's a good start. I will have to try your installer, too. ..I was also wondering about all those funky 'encoding' files, eg: macJapan.enc 48 kb cp949.enc 130 kb cp936.enc 132 kb ..and many others They add up to quite a bit, and I sure don't need all of them. I probably need at least one, I suppose, maybe ascii.enc (the smallest one at about 1 kb ). On a related note, will having too many Tk files increase the run-time memory usage of an app? I sent a 'compiled' Tk app to a friend who was surprised that such a simple little program was using 5MB ram on his Win2K. I suppose that's 90% Tk overhead, (or is it Python overhead?) but I was wondering if that memory usage is related to unnecessary Tcl/Tk files being included? Thanks for any advice. From b.e.n. at .r.e.h.a.m.e...c.o.m Tue Jun 26 03:10:47 2001 From: b.e.n. at .r.e.h.a.m.e...c.o.m (Ben) Date: Tue, 26 Jun 2001 17:10:47 +1000 Subject: MS SQL Server Message-ID: <51dgjtsbuureuugfcubid11tldg7077sfa@4ax.com> Hi, Unfortunately I have to upload data to a MS SQL server ... Can anyone recommend a tool for doing this or docs\examples :] ... is it ANSI SQL compliant like MySQL and therefore can use the same commands? greatly appreciate any advice Ben From slinkp23 at yahoo.com Thu Jun 7 01:18:37 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Thu, 07 Jun 2001 05:18:37 GMT Subject: How can I extend raw_input to provide user w/ default input string? References: <9fmgli$43f$1@peabody.colorado.edu> Message-ID: <3B1F0D82.DB10E008@yahoo.com> Edoardo ''Dado'' Marcora wrote: > > I am wondering if it is possible to provide the user with a default input > string using raw_input or similar function. If you just want to show the default, that could be done like this: import sys def raw_input_with_default(prompt, default="yes"): sys.stdout.write(prompt + " [%s] " % default) result = sys.stdin.readline().strip() result = result or default return result So if they don't type any non-whitespace characters before hitting return, default will be used. If you want them to be able to *edit* the printed default string... I have no idea. HTH, PW From sill at optonline.net Thu Jun 7 14:18:43 2001 From: sill at optonline.net (Rainy) Date: Thu, 07 Jun 2001 18:18:43 GMT Subject: print foo, adds a space to beginning of next line? References: <3B1E7D78.53A5BE30@ll.mit.edu> Message-ID: On Wed, 06 Jun 2001 14:59:04 -0400, George Young wrote: > [python 2.1, intel linux] > def f(): > print 'what is your name: ', > x=sys.stdin.readline() > print 'what is your age: ', > y=sys.stdin.readline() > > f() > what is your name: mememe > what is your age: 48 > > Why does it print a space at the beginning of the second line? > > If I use sys.stdout.write('what is your name: ') instead, it > works fine. I think, that's probably an intended effect, as you often need to separate strings by spaces, so instead of doing print something + ' ' + something_else you just do print something, something_else If you don't want that, you use sys.stdout.write. -- Jupiter and Saturn Oberon Miranda And Titania Neptune Titan Stars can frighten - Syd From tim.one at home.com Fri Jun 1 17:15:45 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 1 Jun 2001 17:15:45 -0400 Subject: Obsolesence of <> (fwd) In-Reply-To: <9y/F7kKkX0RK092yn@bellatlantic.net> Message-ID: ]Lulu of the Lotus-Eaters] > Here's an obvious way to well-order two complex numbers: > > def lexigraphic_order(c1,c2): > if c1.real < c2.real: return -1 > elif c1.real > c2.real: return 1 > else: return cmp(c1.imag,c2.imag) > ... Easier is to exploit Python's lexicographic comparison of tuples directly: return cmp((c1.real, c1.imag), (c2.real, c2.imag)) Python *used* to do that for complexes. At the very start of the language, it was impossible (for internal technical reasons) to raise any exception from a comparison function, so at the start all objects had to support consistent (not to say meaningful) comparisons. It later became possible to raise exceptions from comparisons, but still not possible for a comparison function to determine which specific comparison was desired. When "rich comparisons" got added even later, it finally became possible to distinguish == and != from the others, and at that point Guido was eager to stop returning nonsense results for ordered comparisons of complex numbers. Not a pure win, and debatable whether it was even a net win, but so it goes. From aleaxit at yahoo.com Wed Jun 6 05:14:40 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 6 Jun 2001 11:14:40 +0200 Subject: integers ( ++ operator ? ) References: <9fjd8q$qb6$1@charm.magnus.acs.ohio-state.edu> <9fjgqf$rp0$2@brokaw.wa.com> <696rhtkhgtf4o1i5u05e4k9pvujb8kmqaa@4ax.com> Message-ID: <9fksa00db2@enews2.newsguy.com> "Nick Perkins" wrote in message news:rZhT6.142247$eK2.34099848 at news4.rdc1.on.home.com... > > "Alan Daniels" wrote in message > > > I believe the new "x += 1" syntax is just synactic sugar which serves > > as shorthand for "x = x + 1", although I'd have to delve through the > > interpreter source code to be 100% sure. > > ..no need to look at the interpreter source: > > >>> x=10 > >>> id(x) > 3161552 > >>> x+=1 > >>> id(x) > 3161960 > > x does indeed refer to a different object. Ah, but that depends, you see...: D:\ian\good>python Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. Alternative ReadLine 1.4 -- Copyright 2001, Chris Gonnerman >>> class Int: ... def __init__(self, i): self.i=i ... def __iadd__(self, other): self.i+=other; return self ... def __repr__(self): return 'Int('+str(self.i)+')' ... >>> x=Int(10) >>> x Int(10) >>> id(x) 8364268 >>> x+=1 >>> x Int(11) >>> id(x) 8364268 >>> If x belongs to a mutable type defining a suitable __iadd__ (inplace-add), then its id() is NOT changed by +=... to be more precise, x doesn't need to be re-bound then (it's rebound to what __iadd__ returns, which is self, if you prefer:-). So, += is *NOT* just syntax sugar... it's an important polymorphic way to "increment" objects that can be either mutable or immutable, doing the best possible thing in each case!-) Alex From loewis at informatik.hu-berlin.de Sat Jun 16 12:50:17 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 16 Jun 2001 18:50:17 +0200 Subject: Bug in expatreader... References: Message-ID: Achim Gaedke writes: > My intention is to write a recursive parser for nested data > structures. In order to collect the data it is necessary to switch > the contenthandler each step. The bug is in your code, not in the expatreader. After parsing has started, you must not call setContentHandler anymore. The behaviour is undefined if you do. I.e. with SAX, you cannot switch the content handler when parsing. Regards, Martin From michael+gnus at trollope.org Fri Jun 22 10:11:03 2001 From: michael+gnus at trollope.org (Michael Powe) Date: 22 Jun 2001 07:11:03 -0700 Subject: ANNOUNCE: The Neophyte Pythoneers List References: Message-ID: [posted and mailed] >>>>> "Jesse" == Jesse W writes: Jesse> Dear Pythoneers, (Exactly how should you spell Jesse> "Pythoneers", anyway?) Jesse> I have just now created a mailing list via Yahoo for Jesse> the sharing, joint debugging and general discussion of Jesse> Python programs. The list is intended to be primarily for Jesse> those who have not yet reached expert level in Python Jesse> programming, but experts are also very welcome. You can Jesse> join by sending a blank email to: Jesse> neophyte_pythoneers-subscribe at yahoogroups.com Too bad, those people are idiots. You should try setting it up on your own if you have the resources (like a DSL/cable connection). I tried to join your list but the subscription was rejected by yahoo because I have "too many bounced mails." The geniuses sent me an EMAIL telling me that I can't subscribe to a list because I have too many bounced mails. Well, I get about 70-80 emails a day at home & I have yet to have anyone but yahoo tell me there is a problem. (In fact, one of them is a yahoo list! While they are cutting me off, I continue to get mails from that list!) I used to run my mailing list from there but a couple weeks ago, I set up MailMan at home & I'm free of that stupidity. I suggest you do the same. Anyway, good luck with the list. I'm not going to join, after all, because I don't want the aggravation of dealing with those morons anymore. mp From dalke at acm.org Tue Jun 26 17:02:13 2001 From: dalke at acm.org (Andrew Dalke) Date: Tue, 26 Jun 2001 15:02:13 -0600 Subject: Is this a true statement? References: <8NuZ6.362378$oc7.42924874@news2.rdc2.tx.home.com> <3B3788A2.3BD1D672@tundraware.com> <9h89pn$oj5$1@slb2.atl.mindspring.net> <3B38D94E.727A0EEF@tundraware.com> Message-ID: <9hav57$qjr$1@slb4.atl.mindspring.net> Tim Daneliuk wrote: >What prevents me from writing out a byte string from Python which is a set >of primitives for accessing the SM hardware and then building up higher >level Python interfaces from these primitives? Nothing. But it wouldn't be Pythonic -- you would no longer be using Python. What's to prevent you from doing something like import c_compile func = c_compile.function(params = ("i", "j"), defaults = {"j": 10}, returns = types.IntegerType, code = """ return i + j; """) >>> func(i = 3) 13 >>> Again, nothing. But few would say this should be considered a Python program. Whereas in C++ using special per-class allocators is very C++-ic. Andrew From emile at fenx.com Thu Jun 21 12:29:38 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 21 Jun 2001 09:29:38 -0700 Subject: How to convert an object ref to string and the reverse References: <9dab6033.0106210725.935e7c4@posting.google.com> Message-ID: <9gt7ko$asla0$1@ID-11957.news.dfncis.de> Do you mean like this? >>> class C: def __init__(self): self.msg = "hello" def show(self): print self.msg >>> c_i = C() >>> c_i.show() hello >>> d = c_i >>> d.show() hello >>> d <__main__.C instance at 011674EC> >>> -- Emile van Sebille emile at fenx.com --------- "Ivan" wrote in message news:9dab6033.0106210725.935e7c4 at posting.google.com... > Hello, > this is a basic question: > how is it possible to convert an instance > to string and how to do the reverse - convert the > resulting string in a valid object reference. > Example: > > Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 > Type "copyright", "credits" or "license" for more information. > >>> class C: > ... def __init__(self): > ... self.msg = "hello" > ... def show(self): > ... print self.msg > ... > >>> c_i = C() > >>> c_i.show() > hello > >>> c_i > <__main__.C instance at 007DE0FC> > >>> > >>> d = <__main__.C instance at 007DE0FC> <====??? How to do this? > File "", line 1 > d = <__main__.C instance at 007DE0FC> > ^ > SyntaxError: invalid syntax > >>> d.show() From pfortin at pfortin.com Thu Jun 21 10:04:01 2001 From: pfortin at pfortin.com (Pierre Fortin) Date: Thu, 21 Jun 2001 10:04:01 -0400 Subject: Interfacing GUI applications..? References: <3B18032E.21AF631E@pfortin.com> <3b312734.173247661@reading.news.pipex.net> <3B314622.1EB391F5@pfortin.com> <3b31ad12.207484109@reading.news.pipex.net> Message-ID: <3B31FED1.34CA58AB@pfortin.com> Aandi Inston wrote: > > Pierre Fortin wrote: > > >> Why does this need scripting? Isn't this solvable in a supported way > >> using FDF files? ^ > >Say what...?! Are you suggesting I write code which generates hundreds of > >values only to have to manually transcribe the results into a "fill-in" PDF > >file...? If so... :^P > > Where did I say anything about "manually transcribe"? Perhaps you do > not know how to open an FDF file in order to fill in a form. Or > perhaps this does not work in *nix? Sorry, I missed the *F*DF (I read PDF); downloading the *nix SDKs now... Pierre From aahz at panix.com Sun Jun 3 09:38:08 2001 From: aahz at panix.com (Aahz Maruch) Date: 3 Jun 2001 06:38:08 -0700 Subject: httplib design question References: Message-ID: <9fdek0$egc$1@panix3.panix.com> In article , Gustaf Liljegren wrote: > >I have noticed that the HTTP method doesn't try to connect to the server: > >>>> h = httplib.HTTP('abc') >>>> > >So I can give it a bad URL, and things will be fine until I try to get >something with the putrequest() method. > >>>> h.putrequest('GET', '/index.html') >Traceback (most recent call last): > File "", line 1, in ? > File "e:\python20\lib\httplib.py", line 425, in putrequest > self.send(str) > File "e:\python20\lib\httplib.py", line 367, in send > self.connect() > File "e:\python20\lib\httplib.py", line 351, in connect > self.sock.connect((self.host, self.port)) > File "", line 1, in connect >socket.error: host not found >>>> > >Why doesn't the HTTP method handle this check instead? Here's what I'm >trying to do: I'm not the person who wrote it, so I can't give you a definitive answer. However, httplib is intended to be a low-level interface, so it's not surprising that you have to do all this work. Consider using urllib instead. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 I surf faster than you do, monkey boy. (My take on Netscape vs. Lynx) From db3l at fitlinxx.com Thu Jun 14 18:56:35 2001 From: db3l at fitlinxx.com (David Bolen) Date: 14 Jun 2001 18:56:35 -0400 Subject: Unexpected floating point results using mxODBC modules References: <3b292a75.1831245311@localhost> Message-ID: victor at prodigy.net (Victor Muslin) writes: > On Windows 2000, using Oracle and Active State's Python 2.1, and > mxODBC module, the result returned by the cursor object's fetchall > function contains floating point numbers for columns defined as > "NUMBER" datatype. This column containing integers only. Well, although the database column may only have integer values, the NUMBER datatype can be defined to hold just about anything from integer to double precision floating point. So one question would be how is the actual column defined, and not just what does it contain. Perhaps mxODBC is interrogating the server more completely and discovering that the column is actually defined to support floating point precision, and is setting the returned data type appropriately. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From cribeiro at mail.inet.com.br Fri Jun 1 21:39:37 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Fri, 01 Jun 2001 22:39:37 -0300 Subject: screenscraping In-Reply-To: <991411356.20275.0.nnrp-10.c1c3e154@news.demon.co.uk> Message-ID: <5.0.2.1.0.20010601223537.02599510@mail.inet.com.br> At 17:02 01/06/01 +0100, you wrote: >I am prevented from using any kind of API or direct interface to real work. I assume that you mean the API from the program you're trying to automate, not Windows API; it's going to quite difficult to do anything useful without calls to the basic Windows routines. There are some functions on the Windows API that can help you to control generic apps without using DDE or OLE: - Use FindWindow to get the handle of the application you want to control; - Send a message to the given window to bring it to the top; - Control the application by means of keystrokes. I dont remember the funcion key, but I think that it should be SendKeys or something similar. There are examples on how to make it work in VB; you can use the same idea from Python (I assume that pythoncom/win32 area already exposing this function). Carlos Ribeiro From glenfant.nospam at bigfoot.com Wed Jun 20 06:40:41 2001 From: glenfant.nospam at bigfoot.com (Gilles Lenfant) Date: Wed, 20 Jun 2001 12:40:41 +0200 Subject: Class destructors References: Message-ID: <9gpu9t$7e6$1@norfair.nerim.net> Just add a "__del__(self):" method in your class to make a custom cleanup (close file, socket...). It's perhaps what you need. More info at... http://www.python.org/doc/current/ref/customization.html --Gilles "Graham Ashton" a ?crit dans le message news: Se_X6.1458$h45.9288 at news.uk.colt.net... > I understand that Python doesn't have the equivalent of the DESTROY() > method in Perl, as the tutorial says: > > "There are no special constructors or destructors." > > Surely there is a way of executing some code before the garbage collector > destroys the object though? Can anybody give me some pointers? > > Specifically, I want to close a socket when I've finished with my object > without having to do so explicitly from with the program that uses the > object. > > Thanks. > > -- > Graham From richard at NOstarfighterSPAM.freeuk.com Sun Jun 24 13:02:57 2001 From: richard at NOstarfighterSPAM.freeuk.com (Richard Townsend) Date: Sun, 24 Jun 2001 18:02:57 +0100 Subject: Tkinter event time Message-ID: <993405811.403208@dionysos> Is there a way to convert between the time attribute of and Event object and the system time as returned by time.time() ? I know time.time() returns a floating pointing number for seconds elapsed since the epoch, in UTC. However I don't know what the units and baseline are for the Event time. regards, Richard From SBrunning at trisystems.co.uk Wed Jun 13 10:22:11 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Wed, 13 Jun 2001 15:22:11 +0100 Subject: [Python-Dev] PEP 259: Omit printing newline after newline Message-ID: <31575A892FF6D1118F5800600846864D78BD3F@intrepid> > From: ullrich at math.okstate.edu [SMTP:ullrich at math.okstate.edu] > > Some time ago I said something to someone about > the "orthogonality" in Python's design. The guy > I was speaking to had never heard the word > applied in this context - I tried to explain > what it seemed to me the word meant here, he > explained back that he was a professional > programmer and had never heard of the word, > _almost_ stating that it followed that there > was no such use of the word, and there we were. > > So just out of curiosity: Roughly what do you > mean by "orthogonality" above? See . Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From michael at stroeder.com Thu Jun 14 13:27:46 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Thu, 14 Jun 2001 19:27:46 +0200 Subject: Lookup all available registered Codecs at once? Message-ID: <3B28F412.3D36FFA6@stroeder.com> HI! Is there a way to look up all registered Codecs (in module codecs) at once? Ciao, Michael. From johnbabhorsspam at donotspampeakaudio.com Fri Jun 8 11:10:57 2001 From: johnbabhorsspam at donotspampeakaudio.com (JohnB) Date: Fri, 8 Jun 2001 09:10:57 -0600 Subject: ActivePython and WSH problem References: <3B200C2D.5020701@ActiveState.com> Message-ID: Thanks Mark, that got me working with WSH. However, both when executing those commands, and when running the .wsf file, I get the following warning: "d:\python21\lib\regsub.py:15: DeprecationWarning: the regsub module is deprecated; please use re.sub() DeprecationWarning)" It seems that running the .wsf file wants to register something. Do you know what's up with that? Thanks, JohnB "Mark Hammond" wrote in message news:3B200C2D.5020701 at ActiveState.com... > JohnB wrote: > > > However, on running it, the following error is displayed "...pytest.wsf(6, > > 14) Windows > > Script Host: The value for the attribute is not valid : language". > > I've seen it claimed on the net that this should work, so I suspect my > > ActivePython install didn't register something as a script engine for > > Windows Scripting Host, or I'm doing something stupid. Any ideas? > > > Almost certainly a problem with ActivePython (that will be fixed next > version :) > > Go to a command-prompt, change to the win32comext\axscript\client > directory, and execute the following commands: > > python pyscript.py --unregister > python pyscript.py > > And all should be fine. > > Mark. > From nperkins7 at home.com Thu Jun 14 23:09:43 2001 From: nperkins7 at home.com (Nick Perkins) Date: Fri, 15 Jun 2001 03:09:43 GMT Subject: base converter References: Message-ID: ...be careful what you ask for! ..i can't follow that at all--are you a perl programmer? "Marcin 'Qrczak' Kowalczyk" wrote in message news:slrn.pl.9ihj95.lfq.qrczak at qrnik.zagroda... > Thu, 14 Jun 2001 10:15:21 GMT, Fredrik Lundh pisze: > > > (still waiting for someone to come up with a one-liner using > > list comprehensions ;-) > > As you wish :-) > > from __future__ import nested_scopes > import string > def fix(f): return lambda x: f(fix(f), x) > def BaseConvert(x, b, digits=string.digits+string.uppercase): > return [digits[d%b] for d in > fix(lambda iter, y: y and iter(y/b)+[y] or [])(x) or [0]] > > -- > __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ > \__/ > ^^ SYGNATURA ZAST?PCZA > QRCZAK From rnd at onego.ru Fri Jun 29 12:39:48 2001 From: rnd at onego.ru (Roman Suzi) Date: Fri, 29 Jun 2001 20:39:48 +0400 (MSD) Subject: Augmented Assignement (was: Re: PEP scepticism) In-Reply-To: <6qae2r71hd.fsf@abnoba.intevation.de> Message-ID: On 29 Jun 2001, Bernhard Herzog wrote: >"Alex Martelli" writes: > >> "Bernhard Herzog" wrote in message >> news:6qn16r7i69.fsf at abnoba.intevation.de... >> > I think the main problem (in as much as there actually is a problem) is >> > that whether augmented assignment rebinds the left hand side depends on >> > the type of object, i.e. whether the object implements the appropriate >> >> Right! I think the main advantage (in as much as there actually is an >> advantage) is that whether augmented assignment rebids the left hand >> side depends on the type of object. i.e. whether the object implements >> the appropriate methods. This is called *polymorphism* and is a concept >> of *HUGE* power. > >Well, polymorphism is certainly very important and powerful in python >but in an of itself that's no argument in favor of the intricacies of >augmented assignment in Python. Just because something could depend on >the types of the objects involved doesn't mean that it should. In fact, many things depend on the type of the objects. Types of the objects define what operation will be done. For example, in a simple A = A + 1 + operation is different for different A type. It is inevitable that not everything is written every time. Everything could not be explicit in any place. >Augmented assignment doesn't actually offer anything that couldn't have >been done with explicit method calls, They do. Some operations are better defined in terms of "+=". For example, list.append() Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Friday, June 29, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "I failed attitude in school." _/ From brian at sweetapp.com Sat Jun 2 16:07:14 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Sat, 2 Jun 2001 13:07:14 -0700 Subject: Sockets In-Reply-To: <3B193770.30999EAC@telocity.com> Message-ID: Adonis wrote: > *newbie question* > how can i check for errors when using the socket module? > errors like: unable to connect; insufficient memory etc. See http://www.python.org/doc/current/lib/module-socket.html for more details... The basic answer is that the socket module uses exception to indicate errors. The exception thrown will a socket.error and it's value will "...either a string telling what went wrong or a pair (errno, string) representing an error returned by a system call". Here is an example: >>> try: ... socket.socket(1,2,3) ... except Exception,e: ... print e.args (10047, 'Address family not supported') From beazley at cs.uchicago.edu Wed Jun 20 08:57:32 2001 From: beazley at cs.uchicago.edu (David Beazley) Date: Wed, 20 Jun 2001 07:57:32 -0500 (CDT) Subject: ANN: Introducing PLY-1.0 (Python Lex-Yacc) In-Reply-To: <3B306425.1BA938BE@lemburg.com> References: <3B306425.1BA938BE@lemburg.com> Message-ID: <15152.40380.99624.826511@gargoyle.cs.uchicago.edu> M.-A. Lemburg writes: > > Just a suggestion: PLY seems to use the same logic for attaching > grammar snippets to functions as SPARK does. IMHO, this is bad > design since doc-strings should really only be used for documentation > and not include vital information for the program logic. Actually, I thought the doc string hack was one of the neatest programming tricks I've ever seen (which is exactly why I copied it from SPARK). Why would I write a different documentation string for a grammar rule anyways? The grammar rule in the docstring not only tells the parser generator what to do, but it precisely documents what the function does at the same time. I don't know what inspired John to take this approach in SPARK, but it's pure genius if you ask me :-). > Note that in Python 2.1 we have function attributes which were > added for exactly this reason, so the doc-string approach is > not really needed anymore. I'd suggest to move to these for one > of the next releases. A fine idea, but the implementation is completely useless because there is no syntactically convenient way to attach the attributes. IMHO, having to type something like this is an even more horrible design than using the docstrings (not to mention that it looks ugly and unnatural): def p_expr_plus(t): t[0] = t[1] + t[3] p_expr_plus.grammar = 'expr : expr PLUS expr' I don't have any plans to abandon the use of doc strings because I like the way that they work. If I were to use function attributes for anything, I would probably use them for some purpose other than grammar specification. I'd have to think about that however. Cheers, Dave From tim.one at home.com Wed Jun 20 18:35:46 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 20 Jun 2001 18:35:46 -0400 Subject: launching a file with its associated application on windows In-Reply-To: <9gr70q$bac$1@bob.news.rcn.net> Message-ID: [Christian Reyes] > Is there a method that takes a file as an argument and then opens > that file with the its associated viewer? This must be a Windows question, right? If so, in Python 2.0 or later, the Windows-specific os.startfile() does exactly that. From robin at jessikat.fsnet.co.uk Fri Jun 8 05:16:48 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 8 Jun 2001 10:16:48 +0100 Subject: spell method chaining? Message-ID: <19l8IVAAgJI7EwAk@jessikat.demon.co.uk> I wish to create wrapped classes dynamically and have the wrapper class refer to the base wrapee class methods. def gen(B): class W(B): def __init__(self): B.__init__(self) return W this works if nested scopes is on so that the reference to B in the __init__ refers to the argument of gen, but it fails without it unless B happens to be a global. I thought of using self.__class__.__bases__[0] to refer to the dynamic base B, but then that fails if I use the resultant class as a base class. ie if I try def gen(B): class W(B): def __init__(self): self.__class__bases__.__init__(self) return W I get trouble (infinite looping) with gen(gen(B))() What is the correct way for dynamic classes to refer to their immediate base class methods to allow method chaining etc. -- Robin Becker From altis at semi-retired.com Mon Jun 25 13:34:28 2001 From: altis at semi-retired.com (Kevin Altis) Date: Mon, 25 Jun 2001 10:34:28 -0700 Subject: how do i run a script without the console showing?? References: <9h7s9i$khc$1@uranium.btinternet.com> Message-ID: Use the .pyw extension instead of .py when you are done debugging. ka "Gaz" wrote in message news:9h7s9i$khc$1 at uranium.btinternet.com... > how do i run a script without the console showing on winME, im writting a > script using Tkinter and while the console is ok showing while im > developing/debugging it, when im finished i want the console to disappear! > :) how do i do that? > > gaz. > > From nb0klun71q5001 at sneakemail.com Wed Jun 6 14:07:24 2001 From: nb0klun71q5001 at sneakemail.com (Ron Scinta) Date: Wed, 06 Jun 2001 18:07:24 GMT Subject: Newbie: How independent are multiple python processes? Message-ID: I am wondering how much individual python processes are independent? Meaning, if I am running proc1 and proc2, I assume they each have their own python interpreter running. But, what if proc1 crashes the python interpreter and core dumps for example. Are there shared resources between these two processes that could affect proc2? Python Shared Libraries? Thanks! -- Ron Scinta From arthur.haas at westgeo.com Sat Jun 23 10:51:15 2001 From: arthur.haas at westgeo.com (Art Haas) Date: 23 Jun 2001 09:51:15 -0500 Subject: Trouble downloading Python-2.0.1 Message-ID: Hi. I've had a great deal of trouble picking up this version. There seems to be some sort of error in the archive. Downloading from the www.python.org site via http ... $ ls -l Python-2.0.1.tgz -rw-r--r-- 1 cs004 spsd 4136960 Jun 23 09:45 Python-2.0.1.tgz $ gzip -v -t Python-2.0.1.tgz Python-2.0.1.tgz: gzip: Python-2.0.1.tgz: decompression OK, trailing garbage ignored OK $ tar xvfz Python-2.0.1.tgz [ ... lots of output ... ] gzip: stdin: decompression OK, trailing garbage ignored tar: Child returned status 2 tar: Error exit delayed from previous errors $ Picking the file up from sourceforge ... $ ls -l Python-2.0.1.tgz -rw-r--r-- 1 cs004 spsd 3527360 Jun 23 09:40 Python-2.0.1.tgz $ gzip -v -t Python-2.0.1.tgz Python-2.0.1.tgz: gzip: Python-2.0.1.tgz: unexpected end of file $ With the one archive I was able to extract, I'm not sure I have the entire package. Anyone else seeing this? -- ############################### # Art Haas # (713) 689-2417 ############################### From tim.one at home.com Sat Jun 30 02:03:38 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 30 Jun 2001 02:03:38 -0400 Subject: PEP scepticism In-Reply-To: <9hj2p6$bdu$6@newshost.accu.uu.nl> Message-ID: [Martijn Faassen] > Which is why a system more or less *forcing* core developers to look > at these issues *only* for a while may be good. Afraid it can't be done: most development comes from volunteer time, and volunteers can't be forced to do anything. If some area is lacking, what it needs is new volunteers who *want* to work in that area, and, indeed, want to work in that area so much that they'll freely contribute a good part of their lives to do so. it's-not-like-i-got-paid-to-write-tabanny.py-i-only-did-it-to-attract- whitespace-groupies-ly y'rs - tim From sill at optonline.net Mon Jun 11 21:29:09 2001 From: sill at optonline.net (Rainy) Date: Tue, 12 Jun 2001 01:29:09 GMT Subject: How to get current date References: <3b256b54.0@news.tm.net.my> Message-ID: On Tue, 12 Jun 2001 09:02:09 +0800, ykchew wrote: > Hi there, > I'm newbies and i want to know to get current date from python2.0 and > merge it with string > > thanks > > import time time.time() or, formatted: time.ctime(time.time()) -- "Your password must be at least 18770 characters and cannot repeat any of your previous 30689 passwords. Please type a different password. Type a password that meets these requirements in both text boxes." (Error message from Microsoft Windows 2000 SP1) From nperkins7 at home.com Tue Jun 5 22:58:46 2001 From: nperkins7 at home.com (Nick Perkins) Date: Wed, 06 Jun 2001 02:58:46 GMT Subject: Python Equivalent of Matlab's size() References: Message-ID: "Prem Rachakonda" wrote in message news:e56d8da7.0106051355.5dc362c7 at posting.google.com... > Hi, > What is the Python equivalent of Matlab's size() function. I need > to find the confirm the size of an reshaped array. > > Prem. Are you using the Numeric module? >>> import Numeric >>> a = Numeric.array(range(12)) >>> a array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) >>> a.shape (12,) >>> a.shape=(3,4) >>> a array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]]) >>> a.shape (3, 4) From ullrich at math.okstate.edu Fri Jun 1 10:43:24 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Fri, 01 Jun 2001 14:43:24 GMT Subject: Against PEP 240 References: Message-ID: <3b17a7a4.1615461@nntp.sprynet.com> On Thu, 31 May 2001 21:07:26 -0400, "Tim Peters" wrote: >[Tim] >> Jurjen N.E. Bos contributed a Python implementation of the constructive >> reals several years ago. ... > >[David C. Ullrich] >> Really? You don't happen to recall where I can find this, do you? >> >> (Um: or are you referring to the celebrated real.py? > >Right. > >> At least in the version of real.py I have the reals have arbitrary >> but predetermined finite precision. If that's what you meant never mind. > >You have to represent reals as string-form function evaluations, then hook >into the machinery that re-evaluates them with ever-increasing precision. >It's barely documented and difficult to reverse-engineer. The only "out of >the box" way to do it is via the interactive functions that keep printing >more and more digits until you interrupt them. It's not enough *just* to >use the Real class. Yeah, I figured later that I'd thought you were saying more than you actually said here. > If I ever get a free month, I'd like to package that >machinery for non-interactive demand-driven use via a new class (which I >expect is more what you have in mind). Yup. (Don't get the idea I was or am requesting anything here, it's certainly not something I need. Was just curious whether you were talking about new Bos stuff I hadn't heard of. The idea of _reals_ with actual infinite precision is fascinating, but at least from my point of view that's all it is.) >> Those wacky reals. Makes you wonder how they got the name. > >Probably some Dutch guy; heck, they even name languages after snakes. I didn't know that, thanks. David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From gardner at cardomain.com Fri Jun 22 15:08:42 2001 From: gardner at cardomain.com (Jonathan Gardner) Date: Fri, 22 Jun 2001 12:08:42 -0700 Subject: Pythoin MUD (PyMUD?) References: <9gqq3t$hvs$1@brokaw.wa.com> <9gqt0r$1q$1@news.mathworks.com> Message-ID: <9h052d$94o$2@brokaw.wa.com> Courageous wrote: > >>I've been working on one for a bit. Python's an ideal language to >>use--it's dynamicness allows easy updating of areas and such while the >>mud is running. > > You'll also find that if you use Stackless Python (with continuations) > that you can support a truly awesome level of threads. > > C// > > Stackless Python... with continuations... Could you point me to an introduction to that or some docs? -- Jonathan Gardner "Infinity isn't all that large - except at the end." -- Uncle Al Please don't take anything I say seriously, even if you are really gullible. From news at dorb.com Sat Jun 30 14:28:45 2001 From: news at dorb.com (Darrell) Date: Sat, 30 Jun 2001 18:28:45 GMT Subject: _sre recursion limit Message-ID: I was surprised by the recursion limit problem, thinking it was fixed. Discovered the fix disabled and couldn't find bug #133283 Line 1083 in _sre.c /* FIXME: the following fix doesn't always work (#133283) */ if (0 && rp->pattern[2] == 65535) { So I enabled it and the self test passed. "import test.test_re" My needs are meet by this fix. Can we find a test case it breaks? _sre.pyd with the 'if' enabled. http://ezwiki.com/sre --Darrell Gallion From tim.one at home.com Tue Jun 19 19:42:08 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 19 Jun 2001 19:42:08 -0400 Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: [Carsten Geckeler] > ... > But when I'm browsing through a source it may help me very much > if I could see at the `def' line if it's a regular function or a > generator. I simply don't believe it. I used generators very happily for years in Icon, which also makes no syntactic distinction, and it never occurred to me it might help to make one. There's almost nothing interesting about a Python function you can determine without good docs, and it's not PEP 255's burden to repair that for those who feel it's a problem. With optional static typing, you could say that a function returned a generator-iterator, and that would also cover functions that *do* return a generator-iterator but are not *themselves* generator-functions. That is, the ability to return generator-iterators is not limited to generator-functions, so the idea that a "gen" keyword would actually help is straining credibility on that point too. > ... > I want to catch it. So why not raise it explicitly as "raise StopIter" > when I have to catch it explicitly as "except StopIter" anyway? You have unusual uses in mind, then -- I haven't seen an example, either real or proposed, of actual generator use that wants to know about the exception at all. You can raise an exception explictly if you want to, but most people won't even want to know about it -- exactly as *most* Python programmers today don't know that a "for" loop in 2.1 (and before) is actually terminated by a suppressed IndexError exception. From batonn at poczta.fm Fri Jun 29 14:47:33 2001 From: batonn at poczta.fm (baton) Date: Fri, 29 Jun 2001 20:47:33 +0200 Subject: data from Acces to Excel Message-ID: <9hiie0$84o$1@news.tpi.pl> Hi, I wonder if there is a possibilyty to export table from Access database to Excel using python language?? If yes, could you tell me how to do it or where I can find info how to do it? Sorry for my English From m-turk at nwu.edu Sat Jun 9 23:58:29 2001 From: m-turk at nwu.edu (Matthew Turk) Date: 10 Jun 2001 03:58:29 GMT Subject: RPC Server Unavailable Message-ID: Hi there. I was wondering if somebody could help me out -- I'm doing some dispatching in win32com (with Mark H's extension, god bless the man!) but I'm having some problems. Is there a generic method I can call to test if the application is still active? For instance - I call a Word Dispatch. I open a document, then make it visible. The user does whatever, then closes either the document or the application - either way, it returns to the python app. At that point, how can I tell if the user minimized, closed, or what, the application? I'll be doing the same thign with Excel, and up until now I've had good luck with a DispatchDict I experimented with, but Word seems to complicate the matter, as does closing an Excel document. Anyway, the error I get is "RPC Server Unavailable." And a summary of my question - how can I tell if a dispatch, stuck in a variable, is still active? Thanks! mjt -- "Having said that, music is supposed to be in the world for celebration, ritual, and healing - that's the point for me." -- Trey Anastasio From sheila at spamcop.net Mon Jun 11 23:20:21 2001 From: sheila at spamcop.net (Sheila King) Date: Tue, 12 Jun 2001 03:20:21 GMT Subject: What "Tim Peters" really looks like References: Message-ID: When the image first loaded, at first I thought, "Gee, he drew Tim so that he looks an awful lot like Guido..." Then I saw the rest of the picture. LOL, LOL. Yes, I want a t-shirt, too. I need it to wear to the first meeting of the Orange County PIGGies. More info here: http://www.ics.uci.edu/~tshumway/ocpiggies/ -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From tim.one at home.com Sat Jun 23 03:31:58 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 23 Jun 2001 03:31:58 -0400 Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: [Carsten Geckeler] > I think we came to the core point. It seems that some people have > exactly the other oppinion, i.e. that the differences how a generator > is evaluated and used is so different that a different "def" line would > be helpful for many people. Yup, that's it in a nutshell. Generally speaking, though, the people in the latter camp have only read about generators, never used them. > Could you tell me, how e.g. a "generator" statement would > be distracting? Sorry, no: Guido pronounced on this, and that's the end of the argument. It's been debated to death -- see the Python-Iterators list for dozens of repetitions of every argument made here (including this one). > I can't see how a more clearifying statement could possibly distract > people. But it's not really clarifying if it draws a useless distinction . From smnordby at yahoo.com Fri Jun 8 21:00:24 2001 From: smnordby at yahoo.com (SteveN) Date: Fri, 08 Jun 2001 18:00:24 -0700 Subject: Python sighting Message-ID: <3B217528.EE91FBAE@yahoo.com> Glancing through the summer catalog from my local community college: "Programming for Fun: Learn the basics of programming with the Python scripting language. Python is powerful, yet easy to learn and freely available . . . " And here I was thinking I was the only Python lover in town! -SteveN- From anuragved at vsnl.com Thu Jun 7 15:08:35 2001 From: anuragved at vsnl.com (Anurag Ved) Date: 7 Jun 2001 12:08:35 -0700 Subject: getch() of Turbo C in Python? Message-ID: Hi all, I am using the Python interpreter under Windows. When I execute a Python script, the console window that opens up closes immediately after the program terminates, leaving me no time to observe the output. One solution is to append the program with raw_input('') But, this is certainly not elegent and moreover it requires the user to press 'enter' rather than the preferred option of 'any key'. Is there something similar to the getch() function of Turbo C which reads just one key from and returns immediately? Thanx in advance! - Anurag From rnd at onego.ru Sun Jun 10 15:00:30 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 10 Jun 2001 23:00:30 +0400 (MSD) Subject: BUG? list-comprehension's inconsistency? was: Re: list-display semantics? In-Reply-To: <9g0dhl$if1$1@news.nsysu.edu.tw> Message-ID: On Mon, 11 Jun 2001, jainweiwu wrote: BTW, I think it could be list-comprehension's inconsistency (if not a bug!), look: 1->>> [x for x in [1, 2, 3], y for y in [4, 5, 6]] # first try Traceback (most recent call last): File "", line 1, in ? NameError: name 'y' is not defined 2->>> [x for x in [1, 2, 3], [y for y in [4, 5, 6]]] [[1, 2, 3], [4, 5, 6]] 3->>> [[x for x in [1, 2, 3]], [y for y in [4, 5, 6]]] [[1, 2, 3], [4, 5, 6]] 4->>> [x for x in [1, 2, 3], y for y in [4, 5, 6]] # 2nd try [[1, 2, 3], [1, 2, 3], [1, 2, 3], 6, 6, 6] -- and this lead to subtle errors. There are even two things which seem wrong here: A) 1 and 4-s steps differ only because y is now defined. B) results of step 2 and 3 do not differ, while visually I've added [] around first item. (it was a discovery to me to know that I can delimit naked list comprehensions by "," inside list definitions!) Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, June 10, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Computers make very fast, very accurate mistakes." _/ From mal at lemburg.com Fri Jun 8 15:11:40 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 08 Jun 2001 21:11:40 +0200 Subject: Semaphores in Python 1.4 References: <9fr5pe$ti8$07$1@news.t-online.com> Message-ID: <3B21236C.413857BF@lemburg.com> Reiner Bielefeld wrote: > > Hi Folks, > > I have to port a python application from AIX to Linux. > To use semaphores, the application imports a "Semc" which is a buildin > C-module. > I found the module Semcmodule.o in the libModules.a in the config directory > of the installed Python Version 1.4. > Cause its an object module I can't use it under Linux. > > Where can I get this module in source ? Please visit http://www.python.org and download Python 2.1 (!) first. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From dsh8290 at rit.edu Thu Jun 28 14:24:31 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 28 Jun 2001 14:24:31 -0400 Subject: KDE and Windows In-Reply-To: <1ax_6.13372$qJ4.526424@ozemail.com.au>; from pwxau@yahoo.com.au on Thu, Jun 28, 2001 at 01:24:12PM +1000 References: <993660235.135465@seven.kulnet.kuleuven.ac.be> <1ax_6.13372$qJ4.526424@ozemail.com.au> Message-ID: <20010628142431.A19571@harmony.cs.rit.edu> On Thu, Jun 28, 2001 at 01:24:12PM +1000, Patrick Wray wrote: | | "D-Man" wrote in message | news:mailman.993663428.8908.python- | | > [...] However Qt is not free for Windows (as-is). | | There is now a "free beer" version of Qt for Windows (released yesterday). ^^^^^^^^^^^^^^^^^^ That's a bit later than the last discussion on the topic . So I must stand corrected (a good thing for all Qt fans :-)). -D From bh at intevation.de Fri Jun 29 17:51:07 2001 From: bh at intevation.de (Bernhard Herzog) Date: 29 Jun 2001 23:51:07 +0200 Subject: Augmented Assignement (was: Re: PEP scepticism) References: <6qn16r7i69.fsf@abnoba.intevation.de> <9hhu6701d5j@enews2.newsguy.com> <6qae2r71hd.fsf@abnoba.intevation.de> Message-ID: Guido van Rossum writes: > Bernhard Herzog writes: > > > Augmented assignment doesn't actually offer anything that couldn't have > > been done with explicit method calls, at least as far as in-place > > modification is concerned, because under the covers it actually is a > > method call. Explicit is better than implicit. To put this into the right context: I wrote that to illustrate that augmented assignment offers nothing in terms of polymorphism that wasn't already there. > Sorry, I don't understand why people can seriously argue *against* > augmented assignment. It just baffles me. What kind of Spartan > upbringing did you have? Scheme? Really, I just don't get it. That paragraph quoted above makes my position on augmented assignment appear much more radical than it actually is. Augmented assignment does have it's advantages but I don't think that those outweigh the disadvantages. Now that they're in the language I use them occasionally. > This was by far the most asked-for feature ever! IMO, that is not necessarily an argument in favor of adding a certain feature. My recollection is that every time this came up on c.l.py it was explained that there are some design issues with augmented assignment in python which don't appear in C or C++ because of different semantics. That x += 1 should be equivalent to x = x + 1 if x is a number is obvious whereas what x += [1] should mean for a list is not. IIRC for most users that was good enough so they didn't pursue this further. Bernhard -- Intevation GmbH http://intevation.de/ Sketch http://sketch.sourceforge.net/ MapIt! http://mapit.de/ From rdsteph at earthlink.net Sun Jun 17 09:25:36 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Sun, 17 Jun 2001 13:25:36 GMT Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? Message-ID: <3B2B60AD.942719AE@earthlink.net> I am taking a week's vacation the week after next. I plan to spend this week trying to learn event-driven programming using Python. I would sure appreciate any comments or guidance from folks on this list, so that I hopefully can make productive use of my time. I admit to being a little confused or overwhelmed by the many options available to me. I am very happy with my learning of Python as a procedural language. I have committed the core language to memory and can program at will without consulting documentation. I am learning to use library modules. I have never been this successful with any other programming language. I have limited time due to job related travel (I do not work in IT in any way; this is I suppose a hobby, albeit it is becoming a serious one.). I have not been successful heretonow in gui or event driven programming . Learning and using Tkinter is much harder for me that procedural Python. I am doing fine on classes and object oriented Python also, but not event driven programing. Some of the options available to me that I am aware of are: (I am programming on a Windows 98 machine). 1. Tkinter and wxPython. I have not been too successful with Tkinter, but I do not rule it out. I have just begun to look at wxPython. Does anyone think wxPython is easier to learn and use than Tkinter, or about the same? 2. Boa Constructor and wxPython. I have downloaded Boa and it looks complicated, but I like the idea of a VisualBasic like gui designer. Is Boa far enough along to be used? Any comments on Boa? 3. PythonWorks. I just downloaded the evaluation copy. OK, it costs $395, a lot of money to pay for a hobbyist. However, if it were the answer to my prayers and far better, as a gui painter, than any other alternative, I guess I would consider it. Does anyone have experience with Pythonware and could you comment? I am really mainly interested in the gui painter. 4. theKompany's BlackAdder. Same as above. For some reason, I seem more favorably inclined towards Pythonware, btu I don't know why ;-)) Anyone have any experience with BlackAdder and can you comment? 5. I am vaguely aware of other alternatives such as qt toolkits, gtk toolkits, etc. 6. Java based solutions. I am successful in getting my scripts to run under Jython. I am a little, just a little, familiar with Java and the JVM's. It occurs to me that there may be Java based gui painters that I could use as a front end to connect to jython based programs? A few years ago I used a Sun product called Java Studio that fell in this category; I like Java Studio, but Sun discontinued it. Are there any open source or even commercial products I should consider? 7. Someone on the list mentioned they use Jbuilder from Borland as a gui painter for their Python programs. Hmmm, Jbuilder has a boxed package for sale much cheaper than even Pythonworks ;-))) Any comments pro or con???? I doubt that this would fit my definition of "easy" to learn and to use, but who knows??? I would appreciate any comments. Python's ease of learning and ease of use opens new doors for "low IQ" programmers like myself. But much that one might wish to do involves event-driven programming, and Python does not yet, it seems to me, offer the same ease of use in this arena. But I keep searching and hoping. Event driven programming is awful important and it would be nice if Python's core advantages could somehow extend into this area. I would prefer to stick to a solution that is as much Python-like as possible, but a jython-Java GUI solution is also of interest. Maybe I will try one of each. I think this whole topic of discussions of interest to many newbie's and programming hobbyists, not just to myself. A successful address to this "problem" could seriously propel Python even further as an educational and first-learning language. I would really enjoy a discussion of pros and cons and possible directions to explore, both now and also in the future, if anyone can predict future directions of even-driven GUI programming and Python. ;-)))) Ron Stephens From bkc at Murkworks.com Mon Jun 4 15:59:42 2001 From: bkc at Murkworks.com (Brad Clements) Date: Mon, 4 Jun 2001 15:59:42 -0400 Subject: Generating WSDL for Python SOAP services References: <9f8tri$2g1$1@news.jump.net> Message-ID: <3b1bec09$1_2@127.0.0.1> I need WSDL server-side support for Python as well, for use with Zope and IE 5.5 client applications. I'm open to just about any solution that can make this work. -- Brad Clements, DevNet Sysop 5 Developer Network Sysop Team "Preston Landers" wrote in message news:9f8tri$2g1$1 at news.jump.net... > Hi all. > > My company (journyx.com) is planning to use SOAP to expose some methods of > our application server. The goal is to write a client that will ultimately > be embedded in an MS Office application and make calls to installations of > our software. > > We are using the actzero.com SOAP.py 0.9.5 module to implement the server > side, and the MS SOAP 2.0 toolkit on the client side. The MS toolkit "high > level API" requires that services have a WSDL (web services description > language) file that describes the methods that are availible and their > parameters. We are really hoping to use the "high level API" and thus avoid > writing our own handlers in Visual Basic, which is not our forte. (Python > is.) > > Therefore I am planning to write a WSDL generator that will examine our > exposed methods and write out a valid WSDL file. I realize you can compose > a WSDL file by hand, but since our interface is changing rapidly, we think a > generation program is the way to go. > > I am not sure yet it I can generalize it enough to be useful to the general > public or if it will be specific to our application. > > We already have a set of classes in a module that contain the methods > exposed by SOAP. Most of these methods are simple wrappers to the "real" > internal API of our application. It should be easy enough to > programmatically determine the methods. The real trick seems to be > determining the types of the parameters. We are thinking of using the new > function attributes in Python 2.1 give each method a descriptor that defines > its parameters. > > I'm posting to the newsgroup to check if anyone else is already working > along these lines, or has any thoughts on the subject. > > cheers, > > Preston Landers > Software Developer, Journyx Inc. > planders at journyx.com > > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From chris.gonnerman at newcenturycomputers.net Wed Jun 20 22:14:46 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Wed, 20 Jun 2001 21:14:46 -0500 Subject: Help installing pygtk, libglade in Windows - please References: <9gqd28$j36$1@nntp6.u.washington.edu> Message-ID: <011501c0f9f7$f69d0da0$0101010a@local> ----- Original Message ----- From: "Frank Miles" > I'm trying to install pygtk and libglade on a Win9x system. The local > Windows guy advises me that it is necessary to edit the Windows registry > to install DLLs. Is this truly the case with the DLLs associated with > these? No. DLL's only need to be in the PATH or in the current directory. However, note that you need to install a working GTK/GDK/GLIB package BEFORE you install pygtk/libglade. The easiest way is to install the GIMP for Windows (I don't have the URL handy) but you can just install the library packages (from the same place). > Unfortunatley I don't have the tools to build for Windows, so > was trying to use the binaries built for Windows; but these don't seem > to have any installers. I've tried editing a setup.py written for another > program so that I could use distutils, but this hasn't worked. Put the binaries in the Python DLLs folder (default c:\python20\dlls) or in the c:\python20\lib directory (or c:\python21\... if you are in 2.1). > Take pity on a Linux guy (it's _so_ much easier and simpler there)! > I'm developing my app on Linux, but (sigh) others in my organization > run Windows, and they have to be able to use it too... The commonly available package for Windows doesn't contain all the features of the full pygtk on Linux/Unix... be prepared. I have started (but not finished) building pygtk on Windows using MinGW32 tools. What I have works fine, including gdk_imlib (which is missing from Bruer's (sic) port) but I ran into a design flaw in the gdk_imlib bindings which I simply haven't had time to fix. From b.e.n. at .r.e.h.a.m.e...c.o.m Sun Jun 3 06:03:05 2001 From: b.e.n. at .r.e.h.a.m.e...c.o.m (Ben) Date: Sun, 03 Jun 2001 20:03:05 +1000 Subject: PIL and Tif compression Message-ID: Hi, I was wondering if PythonWare had plans to implement a compression standard for writing tif files with. One of the open source standards such as CCITT FAX3, CCITT FAX4 etc would be nice. thanks Ben Catanzariti From bill-bell at bill-bell.hamilton.on.ca Fri Jun 29 10:59:23 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Fri, 29 Jun 2001 10:59:23 -0400 Subject: Terminating a local process COM server In-Reply-To: <993782591.509.96510.l10@yahoogroups.com> Message-ID: <3B3C5F8B.4171.300C3F1@localhost> "Steve Holden" wrote, in part, in a different order: > Anyone help? Or at least explain where I'm mistaken if this isn't a > sensible goal... I dunno whether the following can be considered "help" in itself. (But maybe a little inane discussion will help.) First, makes sense to me. > For debugging purposes I would like to be able to terminate the > current instantiation (i.e. process), so I can start another one with > revised Python code. It would also be nice, in production, to have > some way to terminate the LocalServer process so that the next > instantiation of the COM object restarts the server in a new process. Server side: 1. Use a factory to create the objects needed by the COM client. (As a newbie I've found Chapter 12 of the O'Reilly "Python Win32" book to be very useful.) 2. Add a method to the COM interface that terminates the local server. Client side: 1. Wrap an attempt to execute the server termination method in a 'try...except' and ignore what happens. Execute this only in a special 'test' mode? 2. Instantiate the COM object. Cross your fingers. Bill From matt at mondoinfo.com Sat Jun 30 13:58:51 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Sat, 30 Jun 2001 17:58:51 GMT Subject: How to create Python executable References: <3b3d73cd.48834029@news-server.bigpond.net.au> Message-ID: On Sat, 30 Jun 2001 06:42:29 GMT, sorular wrote: >How to make an executable from a python program? >The code is made up from several python scripts and files in a >directory. It requires ActiveState to run but I want to run it on any >machine as an executable (*.exe) that don't necessarily have python. If your executables end in .exe, it's a fair bet that you're using Windows. In that case, I'm told that py2exe is very handy. It's at: http://starship.python.net/crew/theller/py2exe/ Regards, Matt From shredwheat at mediaone.net Fri Jun 1 11:48:40 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Fri, 01 Jun 2001 15:48:40 GMT Subject: PIL speed and fear References: Message-ID: "akhar" wrote > I noticed that it tries to open > a dos session and then shows me the image in paint. I am afraid that for > phase two when I start using streams of images directly from the camera that > their will be an enormous lag. Is it only because of windows? should I be > using something else for realtime video streams like pySDL? or is it windows > and I should use freebsd to do this? the problem is that the Image.show() command is pretty much a hack to make life easier. it saves the image as a temporary file, then launches a standard image browser in a separate process. this will not do at all for any kind of realtime system. your best bet is to use PIL's interface to Tkinter and make your own small gui, then i believe you can display the PIL images directly in the gui. (saving the save, launch process, load steps) i still don't know if that is going to be fast enough? not because PIL or python are too slow, but because thats a lot of image data to be analyzing and processing realtime From tim.one at home.com Sat Jun 2 19:34:13 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 2 Jun 2001 19:34:13 -0400 Subject: random In-Reply-To: <3b18ea18.332276@nntp.sprynet.com> Message-ID: [David C. Ullrich] > ... > Hanging out on sci.math the things that people said about Chaitin's > work made him sound like a total crackpot. sci.math? Wow -- I thought Congress had voted to ban it. Wishful thinking, I guess . > I was relieved when I saw a little bit of his stuff once - the > ridiculous aspects of what people had said about what he'd done were > not due to him, they were due to people misquoting and oversimplifying > his stuff. Chaitan is a bit of a self-promoter, and his rhetoric is often colorful, but by all indications his work is rock solid. A very nice high-level intro is this transcript of a lecture he gave at CMU: http://www.cs.umaine.edu/~chaitin/cmu.html From tim.one at home.com Mon Jun 4 21:45:38 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 4 Jun 2001 21:45:38 -0400 Subject: Decimal can be Binary Too (was decimal or rational) In-Reply-To: <3B1BB007.966C2746@home.com> Message-ID: [Don O'Donnell] > ... > Do you think it would be possible or desirable to extend/generalize > your FixedPoint class to handle the "floating decimal" as an option? > Or would it be better to make it a separate class or subclass? Any > opinions? Sorry to skip most of the text, but I'm very short on time tonight. The short and the long course is that I don't want Python to reinvent this wheel yet again, so have been arguing for serious consideration of IBM's Standard Decimal Arithmetic proposal: http://www2.hursley.ibm.com/decimal/ Floating decimal is very much a part of that. Aahz is in the process of implementing it as a Python module; see his Decimal.py at http://starship.python.net/crew/aahz/ If, after (it's not done yet) people get to kick Decimal's tires, they're happy (OK, I'll settle for happier ) with this approach, Aahz has been writing in it such a way that the performance-critical parts can be migrated to C easily. If not, hey -- it's Python! It's painless to throw away (and especially if you're not Aahz ). > still-learning-from-reading-your-code-ly y'rs Ah, in *that* case, FixedPoint.py does way too many magical coercions, the test suite should be 100x larger, and I'm not sure the intent of seemingly tautological comments like # n1/10**p / (n2/10**p) = n1/n2 = (n1*10**p/n2)/10**p is obvious to anyone but me -- but you got what you paid for . From quite at dial.pipex.com Wed Jun 20 18:44:26 2001 From: quite at dial.pipex.com (Aandi Inston) Date: Wed, 20 Jun 2001 22:44:26 GMT Subject: Interfacing GUI applications..? References: <3B18032E.21AF631E@pfortin.com> Message-ID: <3b312734.173247661@reading.news.pipex.net> claird at starbase.neosoft.com (Cameron Laird) wrote: >In article <3B18032E.21AF631E at pfortin.com>, >Pierre Fortin wrote: >>Hi, >> >>I've been searching for a couple of days now and must resort asking for help... >> >>Does anyone know if it's possible to interface to a GUI application via a Python >>script? I'm writing an application and would like to invoke Adobe's AcroRead >>(on Linux) and feed data to a "fill-in" PDF file. Why does this need scripting? Isn't this solvable in a supported way using FDF files? ---------------------------------------- Aandi Inston quite at dial.pipex.com http://www.quite.com Please support usenet! Post replies and follow-ups, don't e-mail them. From aleaxit at yahoo.com Thu Jun 7 12:24:40 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 7 Jun 2001 18:24:40 +0200 Subject: Jython book References: <3B18A902.92912FCF@earthlink.net> Message-ID: <9fo9s60gr4@enews2.newsguy.com> "Laura Lewin" wrote in message news:a05ac97c.0106070226.35df80b7 at posting.google.com... > Hi, > I have an eye on Jython as well for a book, and am talking to a few > people. Nothing is set in stone yet, so if anyone has any additional > ideas or suggestions on the topic, please feel free to email me. (Alex > Martelli is quite busy with Nutshell at the moment, but it was a good > thought!) Yep. Jython is such a _lovely_ thing... not speed-wise perhaps (the JVM takes so darn *long*!-), but otherwise, definitely so. But the Nutshell is what I'm doing...!-) Alex From aaronf at nospam.telusplanet.net Tue Jun 5 09:28:30 2001 From: aaronf at nospam.telusplanet.net (Aaron Fransen) Date: Tue, 05 Jun 2001 13:28:30 GMT Subject: Running an AS/400 CL program via ODBC References: Message-ID: <285T6.2595$Jg4.368004@news1.telusplanet.net> The user ID is authorized for the various objects on the AS/400, but interestingly I get a "Syntax Error" when using the LIB/PGM nomenclature. And most surprisingly, there are NO entries in the joblog on the AS/400! In fact event the QZDASOINIT job only shows that it's servicing a request, but not the details of the request. Obviously I've got some logging option turned off so maybe I'll check into that in the meantime. I suspect it has to do with the cursor type, perhaps? I remember having a buggar of a time figuring it out in VB; actually running a program seemed to be so dramatically different in terms of VB's required syntax than simply running an SQL query that it makes me think that there's something more complicated I have to do in Python. "Simon Brunning" wrote in message news:mailman.991730178.25094.python-list at python.org... > > From: Aaron Fransen [SMTP:aaronf at nospam.telusplanet.net] > > I have a problem executing an AS/400 CL program from the SQL/ODBC > > interface > > in Python. I know the interface on the AS/400 works because I actually > > wrote > > the code to do it originally in VB, which has been live on our web site > > for > > months. I'm getting sick of the Really Big Visual Basic Corporation > > though, > > and am in the process of converting the site to Python, which seemed to me > > to be about the best/easiest/really cool tools out there. > > > > I can run any SQL query via the ODBC 2 interface (Python 2.1) using the > > following code: > > > > dbc=odbc.odbc("datasourcename/as400username/password") > > cursor=dbc.cursor() > > cursor.execute("Select * from MYTABLE") > > result=cursor.fetchall() > > > > Works perfectly. However, if I try something like this: > > > > cursor.execute("{{Call > > LIB.PROGNAME(?,?,?,?,?,?)}}",['PARM1','TWO','THREE','1','','']) > > > > it bakes with "SQL0204 - PROGNAME in LIB type *N not found. in EXEC". > > > > Thoughts? > > Is the user ID that you are using authorised to the program? > > Are there any exit programs on your system which could be blocking access? > > Have you tried the LIB/PGM naming convention? > > Anything else in the job log? > > Cheers, > Simon Brunning > TriSystems Ltd. > sbrunning at trisystems.co.uk > > > > > ----------------------------------------------------------------------- > The information in this email is confidential and may be legally privileged. > It is intended solely for the addressee. Access to this email by anyone else > is unauthorised. If you are not the intended recipient, any disclosure, > copying, distribution, or any action taken or omitted to be taken in > reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot > accept liability for statements made which are clearly the senders own. > From kputland at wisen.com Tue Jun 26 17:15:34 2001 From: kputland at wisen.com (Karl Putland) Date: Tue, 26 Jun 2001 21:15:34 GMT Subject: Windows Messaging in Python References: <3b369797.62658481@news-server.bigpond.net.au> Message-ID: "Matthew Gebski" wrote in message news:3b369797.62658481 at news-server.bigpond.net.au... > Hi, I was wondering if there is a Python module that performs various > windows messaging tasks (i think the one in perl is WIN32:GUI) > > thanks > > The Win32all extension includes most of the win32api. http://aspn.activestate.com/ASPN/Downloads/ActivePython/Extensions/Win32all --Karl From tim.one at home.com Fri Jun 8 00:29:11 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 8 Jun 2001 00:29:11 -0400 Subject: floating point in 2.0 In-Reply-To: <9fp4cd$2sgt$1@agate.berkeley.edu> Message-ID: [Edward Jason Riedy] > I've forgotten the exact language, but we're going to strongly > recommend using Steele and White's algorithm by default: > > http://www.acm.org/pubs/citations/proceedings/pldi/93542/p112-steele/ Ack -- if you folks haven't learned anything else from the 16 years of half-baked 754 support so far, believe me when I tell you that when it comes to f.p., most vendors see "strongly recommended" and think "OK, we can skip this one -- next.". Make it required or don't bother -- really. Vendors don't compete on mere "quality of implementation" f.p issues because their customers overwhelmingly can't tell the difference so don't care. But make it a requirement, and it shows up as a checklist item on contracts. They're drawn up by people who don't care either, but who see "must" and think "must". That's why you have near-universal support for denorms and directed rounding modes today, but virtually nothing that makes intended ("recommended") use of the NaN bits for retrospection, and see most vendors punt on implementing ("recommended") double-extended. > Given 0.1 converted to binary, this will print 0.1. Even if I ask for, e.g., a %.55g format? Steele & White think that's appropriate, but they did this work in the context of the then-pending Scheme standard. After their paper appeared, IIRC it got a chilly reception on David Hough's numeric-interest mailing list, because it's not "properly rounded" in a clearly explainable sense. If someone asks for 55 digits, what "excuse" is there for not doing the best possible job of producing 55 digits? There was also concern about needless loss of precision when, e.g., printing an IEEE float on one box and reading it back into an IEEE double. "Round to the number of digits they ask for" allows for no loss of precision when moving across formats. > It's a complicated algorithm, but worth it. "Worth it" surely depends on the goal. The knock against Steele & White's version of this is sloth, not complication; David Gay's faster version can be fairly characterized as (very) complicated, though. > And it's not a lie. It returns the shortest decimal string which > will reproduce the given binary number after a decimal->binary > conversion. Provided that the source and destination formats have the same precision, and assuming correctly-rounded decimal->binary conversion too. > Of course, you may worry about 0.1 + 0.1 + ... != 1.0. We're > also going to be giving a good deal of advice (and some > requirements) on handling arithmetic. I'm working on a paper > with greater detail, but try the following C program for a > taste of some intended advice: > ======== > #include > > /* > Accumulating in more precision than the data `deserves' > AND rounding the output gives the right answer for more > cases. > */ > > int > main (void) > { > int i; > float x = 0.1; > double accum = 0.0; > float accumf = 0.0; > float y; > > for (i = 0; i < 100; ++i) { > accum += x; /* accumulate in double... */ > accumf += x; > } > > y = (float) accum; /* round back to float... */ > printf ("%.36g\n%.36g\n%.36g\n", accumf, accum, y); > } Very good advice indeed. What if they're accumulating in double instead? Without reliable access to double-extended, I'm afraid we're left with obscure transformations. For most Python users, I expect decimal f.p. with user-settable precision is going to be much easier to use. From dale at riverhall.NOSPAMco.uk Mon Jun 25 11:19:57 2001 From: dale at riverhall.NOSPAMco.uk (Dale Strickland-Clark) Date: Mon, 25 Jun 2001 16:19:57 +0100 Subject: Freelance Python programmer required in UK References: Message-ID: <3blejtg528dsegkb53u9mh0l4os1u76srq@4ax.com> Thanks to the several people who have been in touch from the US about this but we can't really entertain the idea of conducting this project completely remotely. -- Dale Strickland-Clark Riverhall Systems Ltd From qrczak at knm.org.pl Fri Jun 15 13:38:25 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 15 Jun 2001 17:38:25 GMT Subject: Build problem with unicode and 2.1 References: <3B264EE9.4010405@lbl.gov> Message-ID: Tue, 12 Jun 2001 10:18:33 -0700, David P Grote pisze: > The Py_UNICODE type is required to be a 16-bit long, unsigned int. BTW, why is this? In Unicode 3.1 characters have numbers in the range U+0000..U+10FFFF. There is UTF-16 which encodes characters above U+FFFF as pairs of words, but it's not a natural representation of characters - character codes have non-uniform lengths, as in UTF-8. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From vgiquel at yahoo.fr Wed Jun 13 09:26:53 2001 From: vgiquel at yahoo.fr (=?ISO-8859-1?Q?Val=E9rie?=) Date: 13 Jun 2001 06:26:53 -0700 Subject: PYTHON: SQL VARIABLES Message-ID: <4b463337.0106130526.5af30bf8@posting.google.com> Bonjour, Nous sommes actuellement face ? un probleme: Nous devons saisir un code produit dans une Entry. Ensuite, nous devons recuperer cette valeur pour ensuite afficher dans une nouvelle fenetre les donnees correpondant ? ce code produit. Avez vous la solution? Merci Hello, we have got a problem: We want to enter a code of product in an Entry. After, we want to recuperate this value for print the correspondant datas in relation to this code of product. Have you got a solution please? Thanks a lot Val?rie & Solenn From ejr at cs.berkeley.edu Tue Jun 12 13:52:01 2001 From: ejr at cs.berkeley.edu (Edward Jason Riedy) Date: Tue, 12 Jun 2001 17:52:01 +0000 (UTC) Subject: Future floating point directions? [was Re: floating point in 2.0] References: Message-ID: <9g5ks0$2q5h$1@agate.berkeley.edu> And Tim Peters writes: - - Which is why I expect Python will sooner grow an 854 story, indeed doing - decimal fp entirely in software. FYI, 854 is expiring. The decimal portions are being folded into an appendix in 754R. The few differences are being resolved in 854's favor. And decimal floating-point has its own share of problems. An error of one ulp becomes substantial, and there are far more rounding options. It's a trade of one expected thing for other unexpected things. - new stds are adopted slowly, which is why you shouldn't be so timid - about requiring what you really want in the end -- Good point; I think I'll steal it at the next meeting. ;) But people weren't sure if correct decimal<->binary was even possible at that point, so it's fair for 754 to have dodged... That's also why we're dodging on elementary functions. Other people are still trying to find reasonable requirements for those. - gcc is important, but before Python can rely on a thing literally dozens of - compilers have to support it, and correctly. Support in gcc is a forcing function. A few proprietary compiler people have said they could easily justify spending money on something gcc supports. - That's 754's fault, because if we had rotten addition they could - have blamed the accounting discrepancies on the hardware . Heh. I was at UF when KSR tried shutting down the machine we had. That was amusing. (What happened to KSR was a shame, though. Nice machine, even with the one magic processor that would bring the whole thing down.) - The paying market for these modes isn't worth the bother. I'm not sure. Sun folks say various additional rounding methods are wanted by financial groups, and they're willing to pay a bit. Perhaps not enough, but I don't know the details. - > I do wish software had access to the three extra bits necessary to - > round correctly. - - So mandate them <0.7 wink>. It's tempting to bring that up. Very tempting. But then I also want per-register sticky flags. I really want those. (They'd make it easy to interleave calculations while maintaining 754 semantics. IA64 has four FP control / flag words for that reason...) - The scientific market-- unlike the Linux market --is a shrinking piece of - the overall pie, though. I'd say binary fp is perceived by the bulk of the - market as a necessary evil for now, but I'm not sure that will last either. It will. Decimal has some odd problems of its own, and we'd just have to go through this all again. Even ARM has a FPU, due to customer demand. (Looks _nice_, too.) - Which modern chips do you have in mind that punt on required 754 pieces? I - know you view 754 as "a systems standard", but most of the world doesn't: The first paragraph is very clear on that matter. Last sentence reads: Hardware components that require software support to conform shall not be said to conform apart from such software. Thus, any gaps are required to be filled. Very, very few architectures handle _everything_ in hardware. If you count the required trap handling portions, then no general-purpose hardware can possibly implement all required portions of 754. That's why I don't feel requirements are much incentive. I understand your point about hardware support, but the primary hardware and requirements are there and have been. The hardware is now starting to _lose_ features because higher levels have refused to support them. Even when a group comes up with nice, pretty easy to implement libraries (Sun's C9x proposals), they get shot down. - (which is the IEEE-like quad format Sun and KSR both implemented - in the early 90's, so I assume it's still in favor). Yup; that's the defacto quad. It's in most architectures as a future possibility now. Sun's compiler now inserts the correct code directly rather than relying on unimplemented insn traps. - (apparently after the point you stopped reading ): No, I was looking in a draft. The section's been re-worded, and the clause was moved into the new parts, and I kinda assumed it was new. Teaches me for working with pre-alpha specs. ;) - There's not enough precision in a single to enter some programmers' salaries - without catastrophic loss of information <0.9 wink>. It's simply too small - for general use. So pay 'em less, give the extra to me, and I'll lobby for a wider single. ;) Financials are an interesting case in general. I see your point, but to me it's more an argument for using quad intermediates when double is necessary than ignoring the existance of single. - Not in my world. In 15 years at Cray and KSR, neither company built a box - with HW support for any fp format other than 64 bit. No offense, but Cray isn't exactly known for caring about floating-point quality. And as a T3E user, the obsession with 64-bit-everything can really, really suck. (When I used a KSR, I didn't really know the difference. But then I mostly worked on non-FP parallel toys.) - > Single precision is for limiting the effects of rounding. - - Why do I need a distinct storage format for that? Good point. hm. Now why didn't I think of that solution... It could work really well with an assertion, and that would generalize to intervals well. thanks! Think I may need to use that idea... - Some DSPs get by with 16-bit integer "block fp" -- but they know what - they're doing, and are designed with specific algorithms in mind. Yeah. I mostly mean the TI series that supports 754. They also have a single-extended, but it's not 754 single-extended. The exponent range stays the same, and they increase the sig. bits. (Ignoring the relationship to your argument... ;) ) - I look forward to the PEP . Seriously, I don't know how to - implement this in Python. I'm not entirely sure yet, either. I want the ability for other reasons (run-time optimization). And it'll be a general paper first, but somehow I need to add ~10 pages to the 20 I already have and end up with at most 10... That'll require interesting arithmetic. - It may also be more promising. For example, a new kind of block, - - with fp_context=double_extended: - all intermediates in the block use double extended Which would suck if one of them were quad. But this type of block is a good idea. Have you looked over Darcy's Borneo? - IBM's Standard Decimal Arithmetic Proposal requires user-settable precision - (akin to, e.g., x86's "precision control" fpu bits) as part of numeric - context, and it's also a puzzle how to work that into Python smoothly. It's a puzzle how that proposal fits into anything other than Rexx smoothly. - In the Java version it looks like a context argument is explicitly - passed to every operation -- brrrrrr. Yeah, the developers (Darcy at sun and Cowlishaw at ibm) hate that too, but trying to change Java is even harder... Steele's all for changing Java to support these things, but he's also for re- introducing UN and OV. Yech. - They're not arbitrary-length, they're fixed-length, but of user-settable - length (fall back on your own view of static vs dynamic here!). "Entirely - different" seems a stretch, as they're as much "as if to infinite precision - with one final rounding" as 754 semantics. Ah, I thought they were the arbitrary-length-until-you-do-something- interesting variety. I know those are in a GMP derivative, so I assumed they were in GMP... I have no real problem with fixed precisions. Some people want to standardize longer fixed precisions, but I don't think we've come to much agreement there. - I don't see a reason "in theory" that intervals couldn't be contagious too. They pretty much need to be, including decimal->binary conversions. - But this is all so far from current Python it's too unreal to get picky - about. Hey, I'm in academia. It's what I do. ;) - > On the flip side, complex really shouldn't be silently mixed - > with real at all. - - Since the way to spell a complex literal in Python does mix them (like - 3+4*j: that's an honest-to-god + and * there, not a lexical gimmick), - that's a hard rule to adopt . And turning it into a lexical gimmick would hurt how many codes? Silently mixing complex and reals is dangerous. It's almost as bad as Matlab's 1x1 matrix <-> scalar problem. - Is this special case important enough to stop mountains of code that mix - real and complex without incident? No, but the list of other cases may be. This is just the one I can defend the best, being a linear algebra person. There are more from various polynomials. - Guido's view of matrix algebra, and complex numbers, be they in combination - or isolation, is that they're not on a newbie's radar. "Don't ask, don't - tell." This is something to take up with the NumPy folks. argh. They are when the person is first learning them. I keep wanting to recommend Python over Matlab, which would also give a way to link everyday programming with numerics, but the only thing Python offers is a bit of speed (and freedom, but that argument goes nowhere here). The separate cmath does attenuate the problem significantly, though. - Any change to Python's core binary fp numerics would likely require - near-universal consensus -- and I just don't see that happening. sigh. Death a-la Scheme. Jason, who promises to shut up until there's a better write-up and hopefully code (though likely ocaml first) available... -- From rsaathof at bintec.de Wed Jun 27 03:27:08 2001 From: rsaathof at bintec.de (Richard Saathoff) Date: Wed, 27 Jun 2001 09:27:08 +0200 Subject: Help: Python 2.1: "Corrupt Installation Detected" References: <3B39721A.DED4E85A@cosc.canterbury.ac.nz> Message-ID: <3B398ACC.D76A3D0@bintec.de> I think you tried a Win NT-Installation without Administrator privileges. The message is a little bit confusing. Richard. From eppstein at ics.uci.edu Fri Jun 29 17:34:44 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Fri, 29 Jun 2001 14:34:44 -0700 Subject: [Python-iterators] While we're at it... References: Message-ID: In article , "Tim Peters" wrote: > - The following functions were generalized to work nicely with iterator > arguments: > map(), filter(), reduce(), zip() Is there a PEP for this? It doesn't seem to be in 234. Can I assume that "work nicely" means they act like simple generators in yielding partial results even when their inputs are infinite sequences? -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From jadestar at idiom.com Thu Jun 28 00:31:01 2001 From: jadestar at idiom.com (James T. Dennis) Date: 28 Jun 2001 04:31:01 GMT Subject: Python embebbed with Oracle SQL*Plus References: Message-ID: <9hebu5$12lo$1@news.idiom.com> In comp.lang.python Olav wrote: > Some time ago I did some Oracle SQL*Plus on UNIX, > and I was able to write quite powerful scripts > embebbed in ksh (Korn Shell). > Is something similar possible with Python? I presume your ksh scripts were passing SQL code to an sql command (possibly in the form of "here" documents). For course you can build arbitrary commands in Python and invoke the system to execute them. (sys.system()?). > Also I have seen that that there is a special Perl > version for Oracle. Is there something similar for > Python (and would it be necessary to make a special > Python for this?). The old "oraperl" was made obsolete (long ago) with the DBI interface and modules. In Perl you have DBI which provides one abstract interface to all SQL-like (and some non-SQL) databases (or things that you treat like databases in PERL) Then you have various DBDs which are called to translate the DBI abstract functions/methods into the appropriate protocol/API for your database system. > Generally, what is the best way to script Oracle with > Python, and how does it compare to the two above? There is a similar set of classes/modules for Python (import db?). I'll let someone else speak to the current state of those. (I've used one of them to access a PostgreSQL system) It seems that there were a few of them competing at that time; and there was some sort of standardization and implementation effort going on (which might have happened in Python 2.x or 2.1.x --- I don't know). > Thanks > Olav From peter at engcorp.com Sun Jun 24 22:48:34 2001 From: peter at engcorp.com (Peter Hansen) Date: Sun, 24 Jun 2001 22:48:34 -0400 Subject: Is this a true statement? (fwd) References: <3b36149c.11483184@nntp.sprynet.com> Message-ID: <3B36A682.78D94F22@engcorp.com> "David C. Ullrich" wrote: > > On Sun, 24 Jun 2001 10:14:31 -0400 (EDT), "Steven D. Majewski" > wrote: > > >I concede, David! > >Your logic is unassailable > >and your point is significant. > > The "point" about device drivers is certainly not > "significant" in any way I can imagine. This _did_ > start with honest _questions_, which actually > nobody's answered. For all I know "write a > device driver" _could_ mean something other > than "write a certain sequence of bytes to > a file". "Write a device driver [in language X]" means to use language X as the *source language*, and with existing (i.e. not theoretical) tools, turn that source into an output file (usually "machine code") capable of performing the functions typically defined as requiring "device drivers". For more of us it does, anyway. It does not mean "using a program written in language X, generate a file containing an identical sequence of bytes to that which would have been generated using the above method with some other language". Or something like that. Really, it isn't that hard. (If it will help, since your words above suggest the possibility you actually might be missing something here, look at the distinction between "write a device driver in Python" and "write a device driver file using Python". The word "in" in the former suggests using Python as the direct source language of the driver, not as a utility or compiler to be used in the process.) Something tells me this won't be an epiphany for you... :) possibility you don't understand From loewis at informatik.hu-berlin.de Tue Jun 5 04:18:22 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 05 Jun 2001 10:18:22 +0200 Subject: DOCTYPE in XML References: <88630c8d.0105301259.55d724ab@posting.google.com> <88630c8d.0105311024.702fb746@posting.google.com> Message-ID: vdanovich at empireone.net (Vyacheslav Danovich) writes: > [ > > > ]> [...] > doc = Sax2.FromXmlFile(file, validate=0) [...] > At the end the values for "text" were the empty string ("") > It seems like the parser doesn't parse the DOCTYPE entities Indeed it doesn't. Only a validating parser is guaranteed to process external entities, so you should set validate to 1 here. That will make you use xmlproc, which does read the external entities. Regards, Martin From root at rainerdeyke.com Fri Jun 15 12:57:44 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 15 Jun 2001 16:57:44 GMT Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> <9gceld02n4c@enews1.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:9gceld02n4c at enews1.newsguy.com... > "Rainer Deyke" wrote in message > news:JjgW6.284889$oc7.18565826 at news2.rdc2.tx.home.com... > ... > > The following two statements are basically identical: > > > > def f(x): return x > > f = lambda x: x > > They're close, with one obvious difference: > > >>> def f(x): return x > ... > >>> f.__name__ > 'f' > >>> f = lambda x: x > >>> f.__name__ > '' > >>> I'm quite aware of that, hence my use of the name 'basically'. In most cases, '__name__' isn't important. In the case of functions, it is almost exclusively used for tracebacks. If the traceback instead printed the line of code from which the function was called, the user would almost always have the same information, so '__name__' becomes redundant. > You consider it a wart that more than one statement can bind > variables? It's not just assignment and def -- class, import > and from behave the same way. Notice one pattern: all kinds > of non-assignment binding-statements deal with objects whose > *NAMES* are significant *BOTH* in deciding the variable-name > to bind *AND* to locating or initializing the object that is > being bound. The f.__name__ issue above is not a "it just > so happens". It's similar to, say: > import mynicemodule > vs > mynicemodule = __import__('mynicemodule') This is similar to what you have to do if you want a named object that is not a class, function, or module: class NamedObject: def __init__(self, name): self.name = name spam = NamedObject('spam') If classes, functions, and modules require syntax sugar to prevent typing the same thing twice, I see no reason why this syntax sugar cannot be generic enough that it can do the same thing for 'NamedObject' above. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From m.faassen at vet.uu.nl Tue Jun 12 19:12:19 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 12 Jun 2001 23:12:19 GMT Subject: PEP 259: Omit printing newline after newline References: <3dd78ag04f.fsf@ute.cnri.reston.va.us> Message-ID: <9g67kk$i4s$2@newshost.accu.uu.nl> Andrew Kuchling wrote: > Guido van Rossum writes: >> I propose to skip printing the newline when it follows a newline >> that came from data. > -1; I'd rather see a strip_trailing_whitespace argument added to > .readlines(), or some alternative idiom encouraged that sidesteps the > issue. Magical behaviour is bad. 'print' seems to attract magical behavior. A widespread idea among Python developers is not to use print for serious programming; this is likely because it's too magic already. I grant that some of print's magic is convenient when doing quick and dirty stuff. That's how I use it. I guess adding more magic wouldn't really harm me, but it also seems completely unnecessary. My favorite thing to do in the current situation is to please leave 'print' alone. If we want particular behavior we can always use sys.stdout.write() wrapped in a clear, explicit function that does exactly what we like. If this is a convenience issue, make a builtin function that does sys.stdout.write(), if we really can't be bothered to import sys. If this is an easier for newbies issue; I think a strong case can be made that more magic confuses newbies. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From ullrich at math.okstate.edu Thu Jun 14 09:11:19 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Thu, 14 Jun 2001 13:11:19 GMT Subject: base converter References: Message-ID: <3b28b7b3.527029@nntp.sprynet.com> On Wed, 13 Jun 2001 22:01:08 GMT, "Fredrik Lundh" wrote: >Jeroen Wolff wrote: >> I looked on the net for a baseconverter written in python. Is there >> any? Something like: >> >> BaseConvert(20,2) --> "10100" > >def BaseConvert(x, b): > out = "" > while x: > x, d = divmod(x, b) > out = str(d) + out > return out > >(why has decimal to binary conversion suddenly turned into a >FAQ the last few months? Because it's recently been determined that using binary is more "logical"? (Maybe not...) > it wasn't this way in the old days, >and I cannot remember ever having to output things as binary >numbers in a real-life project... can anyone explain?) > > > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From phlip_cpp at my-deja.com Fri Jun 8 10:12:10 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 08 Jun 2001 14:12:10 GMT Subject: gc issues References: <655abd4a.0106080504.66a9d6a0@posting.google.com> Message-ID: <9fqmfq$ndh@dispatch.concentric.net> Proclaimed e toffi from the mountaintops: > hello > > lets say i wanted to integrate 2 languages with gc's (lua, > [small]eiffel, python, javascript). > > how do i keep the gc's from eating each other? > > i know this will require some *very* careful prgramming techniques. > can anyone point me in the right direction? No, it requires each gc manages its own heap. Happens all the time. To learn how to patch multiple scripting languages together, research either ActiveX Scripting or SWIG. -- Phlip phlip_cpp at my-deja.com ============== http://phlip.webjump.com ============== -- "In my experience, the customer doesn't know what he wants until you don't give it to him." --David Brady -- From thomas at xs4all.net Fri Jun 29 20:12:55 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sat, 30 Jun 2001 02:12:55 +0200 Subject: [Python-iterators] While we're at it... In-Reply-To: References: Message-ID: <20010630021255.E8098@xs4all.nl> On Fri, Jun 29, 2001 at 10:40:26PM +0000, Quinn Dunkan wrote: > Of course, an iterator map would be useful: > def iter_map(f, seq): > for o in seq: > yield f(o) > which would work with an infinite sequence. It's sort of another way to write > a lazy list, after all. Let's make that: def _getitem(iterator): try: return iterator.next() except StopIteration: return None def map_gen(f, *seqs): iterators = map(iter, seqs) while 1: items = map(_getitem, iterators) if f is None: yield items else: yield f(items) Not *quite* perfect, since it relies on the iterator to stay exhausted after returning StopIteration once, but that could be considered a feature. It also never stops, though it should probably stop when all iterators are exhausted. Fixing those issues is left as an exercise to the reader -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From philh at comuno.freeserve.co.uk Sat Jun 16 16:06:58 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Sat, 16 Jun 2001 21:06:58 +0100 Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> <9geiir$324$1@216.39.170.247> Message-ID: On 16 Jun 2001 03:08:11 GMT, David LeBlanc wrote: >In article , >philh at comuno.freeserve.co.uk says... >> On 15 Jun 2001 02:37:51 GMT, David LeBlanc wrote: >> > >> >Creating an inherent means of creating constants (or my preferred >> >aliases) is good computer science as someone else mentioned in a reply >> >post. Magic numbers are bad - they're sloppy programming and a source of >> >errors if they must be used in several places etc. OTOH, aliases clarify >> >program meaning and imho make things more comprensible to newbies. >> >> Surely a newbie can understand that if you assign a variable to a >> value, and then never change it, then it is working as a constant. >> >> I have no problem having cxonstants like this, e.g. >> >> programVersion = "0.2.7" >> >> it seems to me that: >> >> alias programVersion: "0.2.7" >> >> is no clearer, and is an extra something for a learner to have to learn. >> Entities should not be multiplied unnecessarily! > >I absolutely agree that entities shouldn't be multiplied unnecessisarily! >However your suggestion in fact does just that: there is nothing that >prevents one from reassigning to programVersion in some module you >import On the contrary, there is something that prevents me from reassigning identifiers intended as constants: the fact that it's a silly think to do. -- ## Philip Hunt ## ## philh at comuno.freeserve.co.uk ## From MarkH at ActiveState.com Sat Jun 23 21:10:29 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sun, 24 Jun 2001 01:10:29 GMT Subject: Win32GUI Question... References: <9h0eqp$4c6$1@bob.news.rcn.net> Message-ID: <3B353E09.1080909@ActiveState.com> Bill Rodgers wrote: > I have an app that occasionally puts a notification dialog on the screen of > my PC. I want to create a program that detects the presence of this new > dialog box,then reads the dialog's contents and does some other things with > the data. > > Is there any way to have my Python program detect and examine windows > created by another program? > See my post regarding "closing a windows app" just a few days ago. It demonstrates how to enumerate all top-level windows and get the text of the window. This can be expanded to enumerate children windows and get their text, etc. Mark. From mcfletch at home.com Sat Jun 23 17:26:28 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Sat, 23 Jun 2001 17:26:28 -0400 Subject: newbie question: In-Reply-To: Message-ID: <000001c0fc2b$2cffd190$a9807018@cr706570a> x = [[2,3,4],[5,6,7]] x[0] == [2,3,4] x[0][1] == 3 x[0][2] = 8 # will replace 4 with 8 x[0].append( 9) will grow the list to be [2,3,8,9] There really aren't any "multidimensional lists" in base Python (though the Numeric extensions have multidimensional arrays), just lists that hold objects, with one of the holdable object types being lists. HTH, Mike -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of krel Sent: June 23, 2001 16:31 To: python-list at python.org Subject: newbie question: Um, this is certainly a stupid sounding question, what is the syntax for putting data into and retrieving data from a multidimensional list? I checked the docs, perhaps not well enough? -- Never trust anything with more limbs than you. -krel -- http://mail.python.org/mailman/listinfo/python-list From bob at passcal.nmt.edu Wed Jun 6 12:43:50 2001 From: bob at passcal.nmt.edu (Bob Greschke) Date: Wed, 6 Jun 2001 10:43:50 -0600 Subject: Calling a C function that alters the passed argument? Message-ID: <9flmg3$1s4b$1@newshost.nmt.edu> Here's the C function I want to call from Python: char *boo(ANumber) int *ANumber; { *ANumber = 42; if (something went wrong) return "An error message"; return (char *)NULL; } How would I write the wrapper function for this? All I can find are examples where the wrapper functions deal with the returned value from C functions. ???? Thanks! Bob From gtcopeland at earthlink.net Fri Jun 1 16:52:12 2001 From: gtcopeland at earthlink.net (Greg Copeland) Date: 01 Jun 2001 15:52:12 -0500 Subject: Python + threads + wxWindows = segfault, help! References: <9f8f7j$k5c$1@panix6.panix.com> <9f8otd$1v7$1@panix3.panix.com> Message-ID: No, I've only started trying to figure out exactly where the problem is. I haven't been able to spend much time on it yet. A number of people have told me to get the ActiveState stuff, which I guess I can try just to make sure, but at this point I'm pretty sure it's the application and not python and/or wxWindows (wxPython). BTW, I can't seem to find wxMutexGUI() in wxPython. Is this me overlooking something or is it simply not available yet? BTW, your conclusion is what I've been thinking too, so I guess I'll have to keep looking for this thing. Thanks, Greg aahz at panix.com (Aahz Maruch) writes: > In article , > Greg Copeland wrote: > > > >Arg! In my hurry to get this posted it seems that I left some > >important information out. I'm running Python 2.1 with wxPython > >2.2.5 and wxWindows 2.2.7, though I get the same results with > >2.2.5 as well. > > > >The application design is using the parent for the GUI and > >threads for communication. Data is passed back and forth via > >Python's Queue class. > > > >Most of the segs that I get seemingly have to do with threads. > >I think I'm the only SMP user on the project and oddly enough, > >I think I'm the only user seeing issues like this. > > Are you calling any extensions other than wxPython? It sounds like some > thread is calling into Python when it doesn't have the Global > Interpreter Lock. Are you sure that threads other than main *don't* > make any wxPython calls? > > What OS is this on? (I'm assuming SGI, but....) > -- > --- Aahz <*> (Copyright 2001 by aahz at pobox.com) > > Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ > Hugs and backrubs -- I break Rule 6 > > "Characters exist to suffer, you know. An author needs a little sadism > in her makeup." --Brenda Clough -- Greg Copeland, Principal Consultant Copeland Computer Consulting -------------------------------------------------- PGP/GPG Key at http://www.keyserver.net DE5E 6F1D 0B51 6758 A5D7 7DFE D785 A386 BD11 4FCD -------------------------------------------------- From duncan at NOSPAMrcp.co.uk Fri Jun 29 04:33:01 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Fri, 29 Jun 2001 08:33:01 +0000 (UTC) Subject: Terminating a local process COM server References: Message-ID: "Steve Holden" wrote in news:R4R_6.6433$Gf4.286144 at e420r-atl1.usenetserver.com: > For efficiency reasons I am implementing a credit-card checking > algorithm as a COM LocalServer object. > > For debugging purposes I would like to be able to terminate the current > instantiation (i.e. process), so I can start another one with revised > Python code. It would also be nice, in production, to have some way to > terminate the LocalServer process so that the next instantiation of the > COM object restarts the server in a new process. > > I'm aware that this would invalidate references to any objects created > by the process, but for testing it *would* be "comvenient" not to have > to kill the COM server process manually. > > Anyone help? Or at least explain where I'm mistaken if this isn't a > sensible goal... > In principle you could query the registry to work out the name of the EXE file and then find the relevant process and kill it. In practice this gets difficult if you find more than one matching EXE file: this is especially a problem with COM objects written in Python, as there are quite likely to be other Python or PythonW processes lying around. Another option would be to put the COM object into an NT service. That way you can simply stop and start the service at will. I recently wrote a service containing a COM object, let me know if you want a copy of the code. The downside to this is that it makes it harder to debug the service when things go wrong. -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From sorrell at themail.com Sun Jun 24 01:48:00 2001 From: sorrell at themail.com (sorrell at themail.com) Date: Sun, 24 Jun 2001 05:48:00 GMT Subject: want to become part of flash muti media 1689 Message-ID: Hi there people well this is just a quick msg for any body that wants to build flash websites you only need to use one finger no experince needed and you and eveybody can make fantasitc money from this new idea if you would like more information about this just send email to ezwork at start.com.au or even if you want to see the the fantastic web sites and demo`s. xbhrjewkdmrjntrwppxfxkrsczywzmduedwrhrnycxjbgjkgzhhvnzposmeemxvgxxoovoiivgutbbzfte From glyph at twistedmatrix.com Sun Jun 10 18:37:29 2001 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: Sun, 10 Jun 2001 17:37:29 -0500 (CDT) Subject: Task Isolation in Python (was Re: How do you develop in Python?) In-Reply-To: Message-ID: On Sun, 10 Jun 2001, Nick Perkins wrote: > I want an IDE to provide at least the following: > 1. Each run takes place in a fresh, clean environment. > 2. The IDE stays responsive while a program is run. > 3. The IDE can kill a running program. One idea which I've been kicking around (and finally even started a little implementation of last night) is a Python interpreter in Python. I believe that the existing compiler is relatively robust (at least, I haven't been able to generate any source code that can crash or hang it yet), but the bytecode interpreter can't isolate tasks, which makes it impossible to kill a process or even slow it down to see what it's doing. Stackless seems like it might make this possible, but it's still using essentially the same partially-recursive interpreter. I'm also interested in running completely untrusted code from python bytecode. However, the tricky parts are in making sure that this meta-interpreter isn't recursive. (In particular, I am getting stuck on operator overloading, since it's possible to implement __getattr__...) Some advantages that this approach would have: * .pyc bytecode interpreter for Jython. * untrusted code execution * resource control * mobile code * defined API for communication between isolated tasks * ability to run "blocking" code without threads in a singlethreaded app * educational value; easier to read than ceval.c * task-scheduling in python without continuations * IDEs could safely execute/debug development code w/o a separate process * python code would run 2 orders of magnitude slower, making it even more high-level Has anyone attempted such a thing before, or have any advice to give me? Also, is it easy/possible to crash the "marshal" module with bad data? ______ __ __ _____ _ _ | ____ | \_/ |_____] |_____| |_____| |_____ | | | | @ t w i s t e d m a t r i x . c o m http://twistedmatrix.com/users/glyph From haaserd at yahoo.com Fri Jun 1 13:40:54 2001 From: haaserd at yahoo.com (haaserd) Date: Fri, 01 Jun 2001 10:40:54 -0700 Subject: Zope questions and comments (&Tkinter???) References: <3B158C50.887E3D59@earthlink.net> Message-ID: <3B17D3A6.A99CC842@yahoo.com> I first downloaded Zope in January of this year, tried using it for a couple of weeks, was overwhelmed, gave it up for a month. I tried again, this time giving it a solid month of effort, and managed to get a CGI application converted from PWS (I use Windows ME). I recently discovered Webware and promptly gave up on Zope: (1) DTML is coyote-ugly. (2) I found it really clumsy using the Zope web interface for DTML and pygmy Python scripts and then using another editor for more serious modules which had to go in the extensions directory. (3) For a one person environment, Zope is too complex and the management/security features are of little benefit. I have made more progress in a week of using Webware than I did in a month of using Zope. And that includes downloading and installing Apache. Roger Haase Ron Stephens wrote: > I am interested in Zope and I have few questions. My interest is in > running a "simple" Zope based web server in order to have the ability > to run server side Python scripts; I might eventually be interested in > the object oriented database aspects of Zope, but it is not clear > whether I would be able to devote enough time and energy to actually be > able to do so. Someone recommended a Zope based hosting service named > hurrah.com and it looks good to me at first glance. I downloaded Zope > and fooled around a few weeks ago, it looked good but complex. My > questions: > > 1. Will Zope be too complex for me??? Specifically, if my primary > interest, in the short run, is to be able to run server side scripts > written in Python (or at least in a Python-like language) , will Zope > allow me to do this? Or will writing scripts in Zope be so complex that > it renders void my attraction for writing in Python because it is simple > and intuitive, i. e. , rather easy and enjoyable? > > 2. I have already discovered that the gui type input/output functions of > my scripts are the hardest part for me. I am only interested in simple > input and output by end users, but I want it to look good and be user > friendly. I do not need fancy graphics nor multimedia, just well > designed attractive forms and user input followed by outputed results in > verbal and numerical form. Will this kind of input/output be a big > problem using Zope? I almost don't dare ask, but I assume Tkinter will > not be supported by Zope? Will I really need to resort to other means, > such as JavaScript, to do such things ??? How straight forward is input > and output, in event driven programs, in server side scripting using > Zope??? > > 3. Would I be better served by using CGI, once I find a host that allows > me to do so? If CGI scripts written in Python are just as easy and > flexible as using Zope, maybe that's the way for me to go in the > beginning. I will still need to find a Python CGI friendly host company. > > 4. Any suggestions on host companies for Python and/or Zope? > > 5. I do have an always-on cable modem connection in my home. Should I > consider setting up a very simple web server on my own machine (rather > than finding a Zope Host?). If I could set up such a simple server, > allowing me to run server side Python scripts, or even CGI, I could link > to those pages from my other web site, on my non-Python non-CGI friendly > web host site. > > 6. Is Zope simply so complex that I will soon forget about why I enjoy > Python, i. e., intuitive, easy to use fun coding? > > General and unrelated comment, for no particular reason, but it comes to > mind in thinking about what I want to do in the project I have in > mind::: > > It seems to me that Python offers straight forward, self consistent, > logical coding. I like that! But any kind of GUI coding, including > Tkinter, seems to me to be less intuitive, less consistent; involving > more memorization of lots of non-connected facts. Python allows me to > memorize principles and consistently and easily implement them. Most GUI > programming seems more like I recall Java or even JavaScript coding; > random, unconnected stuff that is no fun because it's detailed and > random > > sorry for the rant. please disregard ;-))))) From aleaxit at yahoo.com Wed Jun 6 18:01:48 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 7 Jun 2001 00:01:48 +0200 Subject: Learning OOP... References: Message-ID: <9fm97e15cl@enews1.newsguy.com> "Rod Weston" wrote in message news:f7ce0059.0106060942.69f28e91 at posting.google.com... > Trying to decide which language to learn first. I have programming > experience in PICKBASIC and now want to learn OOP.At this point, I am > leaning toward learning Ada and then Python. Any ideas on why I > should or should not use these languages in this sequence? I suggest you try Python first as it's far easier -- you can be doing useful & interesting tasks in a very short time. Ada later, if you want (or alternatively any other static-compile-time checking language -- Eiffel would do as well, for example, and it's arguably "more OOP"). It's a bigger and more complex, thus harder, language to learn & to master. Alex From dwig at advancedmp.net Mon Jun 11 13:26:23 2001 From: dwig at advancedmp.net (Don Dwiggins) Date: 11 Jun 2001 10:26:23 -0700 Subject: Global in multiple files In-Reply-To: "Alex Martelli"'s message of "Mon, 11 Jun 2001 10:55:53 +0200" References: <9g212o0260r@enews2.newsguy.com> Message-ID: Alex Martelli writes: > There is a serious risk in over-designing systems "because > one day it might be handy". Yeah, right, but meanwhile you're > paying the price of complexity *RIGHT NOW*!-) > "Do the simplest thing that could possibly work", because > "you ain't gonna need it" (where "it" is the rich, complex, > over-engineered, over-designed very general solution:-). > See http://c2.com/cgi/wiki?YouArentGonnaNeedIt ... I agree. And while you're there, check out the other Extreme Programming principles. To me, the thing that makes this principle "work" is its combination with the other principles (most directly "Refactor Mercilessly"). Also, remember that "simplest thing" doesn't mean "the first thing that comes to mind". It can take some serious contemplation to come up with the simplest thing. Einstein's advice is also useful here: "make things as simple as possible, but no simpler". -- Don Dwiggins "'Tis a gift to be simple, Advanced MP Technology 'tis a gift to be free..." dwig at advancedmp.net -- Shaker hymn From loewis at informatik.hu-berlin.de Sat Jun 16 13:57:14 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 16 Jun 2001 19:57:14 +0200 Subject: Python equivalent of CPAN Library modules (fwd) References: Message-ID: Lulu of the Lotus-Eaters writes: > Having something like CPAN would be a wonderful thing. There is already an effort to create such a thing, the catalog sig: http://www.python.org/sigs/catalog-sig/ However, David Hurt's approach is different in that he wants to offer the libraries themselves, not a similarly-structured repository. Regards, Martin From f91-men at nada.kth.se Fri Jun 15 08:19:50 2001 From: f91-men at nada.kth.se (Mattias Engdegård) Date: 15 Jun 01 12:19:50 GMT Subject: Any other Python flaws? References: <9gcu9g$gm4$1@newshost.accu.uu.nl> Message-ID: In <9gcu9g$gm4$1 at newshost.accu.uu.nl> m.faassen at vet.uu.nl (Martijn Faassen) writes: >I agree that nobody agrees on whatever 'call-by-reference' means, or what >'call-by-value' means. I mean, I'm here confused why you'd say C++ doesn't >support call-by-value while Python apparently does. :) I didn't mean to say that C++ doesn't support call-by-value, but that it also has call-by-reference. Sorry, bad typing. This is the first time I have seen any disagreement of what call-by-{value, reference, name} means since these are fairly standard terms used for decades, but I'm not going to argue further about it In any case this is has no bearing on any Python flaws (on the contrary, I find its argument passing mechanism quite reasonable and better than the explicit-dereferencing that Perl does) so it's very tangential to the subject From dalke at acm.org Thu Jun 21 19:05:19 2001 From: dalke at acm.org (Andrew Dalke) Date: Thu, 21 Jun 2001 17:05:19 -0600 Subject: PEP 255: Simple Generators References: Message-ID: <9gtut6$joc$1@slb7.atl.mindspring.net> Glyph Lefkowitz wrote: >They do not fill my needs, or the needs of anyone working with simulation >code, network dispatching, or massively parallel computing It's been a while since I did massively parallel computing - back when PVM and 128 connected machines was the hot thing. But I still remember a few things about it and I don't see how Python, even with stackless, can handle many of the concerns we had: My code was distributed memory (network-of-workstation model). How would Python handle that? Eg, how would it know which nodes to use and how to start up on those machines? Suppose I'm using a machine with special shared memory hardware to talk between different nodes. How do I put Python objects into shared memory? Is there integration with MPI? Can multiple programs interact? (Eg, our molecular dynamics code started up another PVM job to do fast electrostatics calculations. Both jobs were distributed on the same set of nodes and simply used PVM calls to talk to each other.) If they can interact, do they both need to be in Python? If not, what's the serialization method? Or are you limiting things to a single job on a single multiprocessor node and where all memory is accessible to all the processors? BTW, because I'm used to distributed memory machines, I write my multiple processor code to work on threads through Queues. I've needed something different only once and was considering Stackless. This Simple Generator PEP would have provided all I needed. (My code was something like def find_common_subsets(graph_A, graph_B, callback): loop: loop: common region identified: callback(subset) which I wanted to convert into something like for subset in find_common_subsets2(graph_A, graph_B): print subset The 'yield' statement works admirably for that, and for some other tasks (like XML processing of records) where I want to turn callbacks into iterators. ) So I would like it (or something similar) even if it doesn't solve all of my MP problems. Andrew dalke at acm.org From gerrie at trispen.com Mon Jun 25 03:45:34 2001 From: gerrie at trispen.com (Gerrie Roos) Date: Mon, 25 Jun 2001 09:45:34 +0200 Subject: newbie Q's Boa References: <20010624.162247.1597322404.2060@K7.atl.mediaone.net> Message-ID: <3B36EC1E.F3BF0C42@trispen.com> Ah, I had the exact same problem...its a small bug only on non-windows systems...you were on the right track. In file Help.py, go to this line(roundabout 72 to 75): self.SetDimensions(120, 75, Preferences.wxDefaultFrameSize.x, Preferences.wxDefaultFrameSize.y) and remark it with leading #'s. directly after that you should put: if wxPlatform == '__WXGTK__': self.SetDimensions(120, 75, Preferences.wxDefaultFrameSize[0], Preferences.wxDefaultFrameSize[1]) I can't remember if this bit was there or not, but make sure you've got it in there. Its a small difference in the wxWindows API on MS and UNIX. MS uses .x and .y attributes and UNIX [0] and [1] indexes for wxDefaultFrameSize. lemme know if it helps or not! myself wrote: > I hope this isn't OT, but I can't find an answer doing Google/Groups > searches or in limited docs- using Mandrake7.2, installed following: > > Boa-0.0.5.zip > wxGTK-2.3.0-1.i386.rpm > wxGTK-devel-2.3.0-1.i386.rpm > wxGTK-gl-2.3.0-1.i386.rpm > wxPython-2.3.0-1-Py21.i386.rpm > wxPython-demo-2.3.0.tar.gz > wxPython-docs-2.3.0.tar.gz > wxPython-gl-2.3.0-1-Py21.i386.rpm > > Boa seems to load from shell without error, but clicking Boa-specific help > button I get: > > Traceback (most recent call last): > File "/usr/local/lib/python2.1/site-packages/Boa-0.0.5/Palette.py", line 231, in O > nHelpToolClick > Help.showHelp(self, Help.BoaHelpFrame, '', self.toolBar) > File "/usr/local/lib/python2.1/site-packages/Boa-0.0.5/Help.py", line 38, in showH > elp > help = helpClass(parent, toolbar) > File "/usr/local/lib/python2.1/site-packages/Boa-0.0.5/Help.py", line 267, in __in > it__ > 'Help.ico', paletteToolbar) > File "/usr/local/lib/python2.1/site-packages/Boa-0.0.5/Help.py", line 72, in __ini > t__ > self.SetDimensions(120, 75, Preferences.wxDefaultFrameSize.x, > AttributeError: 'tuple' object has no attribute 'x' > > I tried to trace through various Boa and wxPython modules and wxWindows > headers, but this is way over my head. > > Also, and perhaps related, I'm unclear how to set the help paths for > Python and wxWindows to work within Boa. Docs say to set paths in > PrefsGTK.py in a key:value(path) format, and then run HelpScrpt.py, but I > don't know what format the "key" parts should follow in the dictionary, > and can't find any examples. I'm scattered on my installations, but here > goes: > > Python2.1 docs in ~/python/docs-21-html/, wxPython docs in > ~/python/wxpython-2.3.0/, Python 2.1 in /usr/lib/python2.1/, Boa and > wxPython in respective dirs in /usr/local/lib/python2.1/site-packages. > wxPython docs apparently include the wxWindows docs. wxWindows > is in /usr/include. > > To the limited extent I've run everything, the executables are in order, > i.e. Py2.1 rather than Py1.5.2 loads, the wxPython demo runs ~95% (and > looks awesome BTW). I expect a few of the demos to fail, eg the Win > specific ones, and I think the only other ones not to run were sound and > gl- I'm trying to "fix" both :-). > > > any help appreciated! From hans at inenco.no Tue Jun 5 11:50:28 2001 From: hans at inenco.no (Hans Kristian Ruud) Date: Tue, 05 Jun 2001 15:50:28 GMT Subject: Python on Jornada 710/720 Message-ID: <3B1CFFEC.4030EAA3@inenco.no> Well, what is the status? I had a look at Mark Hammond pages at Starship: http://starship.python.net/crew/mhammond/ce/ I imagine that Microsoft? Windows? for Handheld PC 2000 is a superset of Microsoft Windows CE ( for which Python is available ), but it would be nice to know for sure. Thanx in advance- p? forh?nd takk :-) - hans kristian - From dirck at pacbell.net Wed Jun 6 14:43:08 2001 From: dirck at pacbell.net (Dirck Blaskey) Date: 6 Jun 2001 11:43:08 -0700 Subject: How do I return binary data from a python CGI called from CGIHTTPServer? References: <9f96kb01mq8@enews1.newsguy.com> Message-ID: <6c8b7eb9.0106061043.57104307@posting.google.com> "Alex Martelli" wrote in message news:<9f96kb01mq8 at enews1.newsguy.com>... > "Mark Wright" wrote in message > news:f9ff3f62.0106011427.6243e5e9 at posting.google.com... > ... > > But my original problem/question remains: how does a CGI program > > return binary data on windows? Is it even possible? The problem is > > python.exe must be run with option -u, to have binary standard input > and output streams, rather than text ones as it has by default. In order to send or receive binary files from Python CGIs under IIS (and Xitami) under Win32, I had to do the following in the scripts, instead of using the -u option: try: import msvcrt msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) msvcrt.setmode(sys.stdout.fileno(),os.O_BINARY) except: pass The -u option broke something in cgi.py, I don't remember what. d From gregj at pobox.com Thu Jun 7 03:53:50 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Thu, 07 Jun 2001 07:53:50 GMT Subject: Recursive algorithms anyone? References: Message-ID: How about this. Ignore the "lists" list to get the "other" behavior. from __future__ import nested_scopes def additem(items, k): from types import ListType def _additem(items, k): if id(items) not in lists: lists.append(id(items)) i = 0 for x in items: if type(x) is ListType: _additem(x, k) else: items[i] = x + k i += 1 lists = [] _additem(items, k) -- Greg Jorgensen PDXperts LLC Portland, Oregon, USA gregj at pobox.com From gorny at hobbiton.org Fri Jun 8 14:38:26 2001 From: gorny at hobbiton.org (Gorny) Date: Fri, 8 Jun 2001 20:38:26 +0200 Subject: root.quit Message-ID: Hai, When I'm creating a windows with tkinter and I close it with a Quit command in the menu it quits nicely: self.filemenu.add_command(label='Quit', underline = 0, command=self.master.quit) But when I'm closing the window with the cross (X) in the right-upper-corner of the window the window is gone but pythonw still runs in the background. An root.destory and a root.quit after the root.mainloop won't work.. :( Greetz, Gorny -- Never trust anything that bleeds for 3-5 days and doesn't die... http://gorny.cjb.net From mwh at python.net Wed Jun 20 09:56:26 2001 From: mwh at python.net (Michael Hudson) Date: 20 Jun 2001 14:56:26 +0100 Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: <3B2EADB0.9DBC6FC8@earthlink.net> <3B2EC98E.FE0F1B6E@earthlink.net> Message-ID: "Kevin Altis" writes: > Well, I started a separate mailing list. > http://groups.yahoo.com/group/pythoncard Could you rig it so the archives are publically readable? I can't think of any reason why it shouldn't be (& I've never successfully logged into YahooGroups's website). Cheers, M. -- Programming languages should be designed not by piling feature on top of feature, but by removing the weaknesses and restrictions that make the additional features appear necessary. -- Revised(5) Report on the Algorithmic Language Scheme From sholden at holdenweb.com Thu Jun 14 20:17:10 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 14 Jun 2001 20:17:10 -0400 Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: <9g4nec0cnr@enews2.newsguy.com> <3b266453.317327753@wa.news.verio.net> <3b2768b5.1425762@nntp.sprynet.com> <3b28ed01.483389587@wa.news.verio.net> <3b290162.19392474@nntp.sprynet.com> Message-ID: -- http://www.holdenweb.com/ "David C. Ullrich" wrote ... > On Thu, 14 Jun 2001 17:19:05 GMT, bokr at accessone.com (Bengt Richter) > wrote: > > >On Wed, 13 Jun 2001 13:33:51 GMT, ullrich at math.okstate.edu (David C. > >Ullrich) wrote: > > > >>On Tue, 12 Jun 2001 19:25:25 GMT, bokr at accessone.com (Bengt Richter) > >>wrote: > >> > >>>[...] In general, I'd prefer that a language > >>>provide a clean way to create a solution to a problem, > >>>rather than having a particular solution built in. > >>>I like orthogonality too. > >> > >[...] > >>So just out of curiosity: Roughly what do you > >>mean by "orthogonality" above? > >Roughly, zero dot products ;-) > > Thanks. Best answer so far... (so a language > in which it was essentially impossible to do > mathematical programming would automatically > have achieved this orthogonality: no math, hence > no dot products, for a net total of zero dot > products altogether. Suddenly Perl seems much > more orthogonal than Python, who woulda guessed?) > Nope. "print" is a feature. "exec" is a feature. Changing the "print" statement (i.e. moving the language one way or another along the "print" dimension) does not affect "exec". Hence the two features are orthogonal. If you multiply its "print"ness by its "exec"ness you get zero. Sort of. Heavens, it's a long time since I studied infinite-dimensional Banach spaces. feeling-old-ly y'rs -- stEVe > >That is, if you view program language feature space > >as n dimensional, and writing code using a particular > >feature as movement along a feature vector. > > > >Well, roughly something like that. 8-<:^P From ullrich at math.okstate.edu Thu Jun 7 11:02:33 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Thu, 07 Jun 2001 15:02:33 GMT Subject: random References: <3b1cf00f.5441109@nntp.sprynet.com> <3b1e4957.3040319@nntp.sprynet.com> Message-ID: <3b1f9604.4075981@nntp.sprynet.com> On Wed, 06 Jun 2001 22:27:32 GMT, wtanksle at dolphin.openprojects.net (William Tanksley) wrote: >On Wed, 06 Jun 2001 15:19:36 GMT, David C. Ullrich wrote: >>(William Tanksley) wrote: > >>>On Tue, 05 Jun 2001 15:09:25 GMT, David C. Ullrich wrote: >>>>But this question is not meant to be rhetorical: We have a syntax where >>>>the valid programs are exactly finite sequences of 0's terminated by a 1. >>>>Does this count as "self-delimiting"? > >>>Yes, but I don't think it counts as a UTM program. There are only >>>countably many possible programs for this machine, while a UTM can run >>>uncountably many. > >>Um. Some of these "programs" have infinite length, then? If they all have >>finite length then there's only countably many - that's even if the length >>is unbounded. If a UTM actually runs programs of infinite length then >>fine, but I can't imagine what it means to run such a program. > >Hmm... I'm pretty sure that programs for an UTM could be infinite length; >however, let's suppose that for the purposes of omega they couldn't be >(IMO a reasonable supposition). Then my proof is clearly invalid. You might note for example that Chaitin says out loud that Omega is the sum of 2^(-length(p)), where p runs over all programs that halt. (The notation he uses in the place I saw this is |p|, and I don't recall him defining |p|. But if we set |p| = length(p) then that formula _does_ give Omega. So if he means to allow infinite-length programs he also means to ignore them.) >However, your machine still isn't a UTM, because in order to process an >indefinite number of possible programs it has to have an indefinite number >of states. It has to be able to count up to little-omega (otherwise it >won't know what program it's executing), but the only way to do that is >with an infinite number of states. And an UTM has a finite number of >states. ??? It seems to follow from statements in this paragraph that a UTM does not exist. It would require an "indefinite number" of states, but a UTM has a finite number of states. So there are no UTM's. Huh. Presumable "there are no UTM's" was not the point you were trying to make... >>David C. Ullrich > >-- >-William "Billy" Tanksley David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From glyph at twistedmatrix.com Thu Jun 21 03:18:43 2001 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: Thu, 21 Jun 2001 02:18:43 -0500 (CDT) Subject: PEP 255: Simple Generators In-Reply-To: <3B318449.2492CAD2@cosc.canterbury.ac.nz> Message-ID: My $0.02 on the whole issue: Generators a-la PEP 255 seem like a *very* bad idea to me. Generators can be implemented through continuations (as shown in Stackless) or through microthreads (as shown in the various previous implementations of generators which use *real* threads cooperatively). Neither microthreads nor continuations are implementable through generators. I believe that generators (as described in PEP 255) are a merely a convenience, but real cooperative multithreading could be very useful and we would get generators *for free*. While I am heavily in support of stackless being integrated for many reasons, I can understand the unfavorable sentiments that some harbor towards continuations. They can be nastily abused. They are confusing. They interact very poorly with operator overloading and exception handling. However, yeild adds a way of altering control flow without providing a direct mechanism for accessing that alteration; only using one particular feature of that alteration. One real example -- the reason I'm writing this reponse -- I have written an asynchronous networking library. Currently, the API is that the client "protocol" code handles each chunk of data, maintaining a buffer itself, and then handling an event when a full message chunk of data is received. Certain protocols would be much easier to code with a synchronous view of handling data; indeed, this is the way that most protocol code in Python itself is written. If the protocol code is executing a read(), however, I want control flow to return to my main asynchronous control loop while that code is blocked. There are, unfortunately, many places executing read() and only one execution path which knows which one it wishes to yield *to*. I believe that this is a fairly common application. The motivation for implementing PEP 255 is exactly this -- a situation where execution should proceed asynchronously but the application should be written synchronously for clarity. The general solution to this problem is cooperative multithreading. Benefits to this approach would be: * one-to-many relationships (as described above) are handled as well as many-to-one. * more pythonic: implement a general approach in the core and build upon it rather than a specific approach in the core. Disadvantages to the PEP 255 approach: * we'll probably want microthreads eventually; this feature will bloat the language unnecessarily then. * less pythonic: once we've implemented generators this way, what about simulation loops? Do we need syntax support for those too? The one advantage to the PEP 255 way of doing things is that it looks like it might be slightly easier to implement. However, C. Tismer has already shown it's not insurmountable to implement microthreads in Python, and perhaps some, if not all, of his work could be stolen ;-). the-view-sure-is-nice-up-here-in-the-peanut-gallery-ly y'rs, ______ __ __ _____ _ _ | ____ | \_/ |_____] |_____| |_____| |_____ | | | | @ t w i s t e d m a t r i x . c o m http://twistedmatrix.com/users/glyph From phd at phd.fep.ru Wed Jun 27 07:23:13 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Wed, 27 Jun 2001 15:23:13 +0400 (MSD) Subject: Welcome to the "Python-list" mailing list In-Reply-To: <20010627111656.20262.qmail@web14801.mail.yahoo.com> Message-ID: On Wed, 27 Jun 2001, binto bient wrote: > tes fes. or foobar, whatever you prefer more :) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From James_Althoff at i2.com Tue Jun 19 20:57:05 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Tue, 19 Jun 2001 17:57:05 -0700 Subject: instance as fake module (Re: why is there no class (static) methods in Python ?) Message-ID: Alex Martelli wrote: > wrote in message >news:mailman.992978370.21848.python-list at python.org... > ... >> But more to the point, I think that since in Python "everything is a >> first-class object" -- which is great -- and since classes, therefore, are >> first-class objects it would be nice (and powerful) if you could define >> methods that you could invoke on such class objects. (And such methods >> should support inheritance and override, of course.) > >Dictionaries, lists and functions are also first-class objects, by the >same token. If what you say IS indeed the rationale for having >'methods that you could invoke' on class-objects, then by exactly >the same rationale there must be the same ability on dictionaries, >lists, and functions, right...? Lists and dicts DO have methods, as you know. And it appears that in the future (once the class/type healing is done) we will be able to subclass these and define/invoke new methods on instances of such subclasses. So I guess I am missing your point. In any case, I wasn't trying to say that class objects should have methods *merely* for the sake of some sense of rigid consistency. I was suggesting that invoking methods on class objects would be useful in the same way that invoking methods on objects in general is useful. And that because classes in Python are already first-class objects (unlike the case in some languages), it isn't a far stretch to imagine the ability to invoke methods on them. >That "something is a first-class object" doesn't mean you have to >be able to apply *EVERY* operation to it -- you can't "call" a list >nor can you "slice" a function, for example. Rather, it means that >operations *applicable to objects in general* can also be applied >to that object: passing as function parameter, returning as function >result, more generally binding to any generic kind of reference (item >in a list or tuple, value in a dictionary) -- the ability of being the >_key_ in a dictionary requires hashability (either immutability or >not defining == as different from 'is', in practice:-). I didn't say that it should be possible to invoke *every* method (or operation) on *every* object. That wouldn't make sense would it? >Therefore it >seems that your sillogism is invalid -- "classes are 1st class objs", >"all 1st class objs can have methods defined on them", therefore >"classes must be able to have methods defined on them" -- alas, >or hurrah, the second premise does not hold. Happily, I'm not trying to prove a theorem (it's "syllogism", btw -- unless, of course, you were making a pun on the "silli-ness" of the whole point ) -- just expressing my desire to see class methods in Python. If, for whatever reason, you think that it is unreasonable for Python to support methods on class objects, you are certainly entitled to think that way. My understanding, though, is that if/when the current class/type healing stuff gets into Python, there might indeed be methods associated with types.ClassType which could be invoked on its instances -- namely class objects. I guess we will have to wait and see. :-) > > >Alex Jim From rdsteph at earthlink.net Mon Jun 18 19:06:57 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Mon, 18 Jun 2001 23:06:57 GMT Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directionsof event-driven Python? References: Message-ID: <3B2D3A65.B052808E@earthlink.net> Perhaps if someone could do a PythonCard for event driven gui programs, using the Python syntax and the Hypercard container model, it would be a big hit ;-)))) I wish I had the ability do that kind of coding .... Roman Suzi wrote: > On 18 Jun 2001, Bernhard Reiter wrote: > > >In article <3B2B60AD.942719AE at earthlink.net>, > > Ron Stephens writes: > > > >> I have not been successful heretonow in gui or event driven programming > > > >Event driven GUI programming is not really easy and the tools > >available are complicated. > > I still remember HyperCard with warm feelings. It had very comfortable > look&feel both from developer's and user's perspective. Every object had > it's own script, which contained event handlers. Events were forwarded > automatically from contained objects to containers and if not handled, > Hypercard was the last who intercepted them. (Much like exceptions). > > Very nice scheme, which allowed to concentrate on the GUI and application > logic, and not on the message propagation details. > > What I wanted to say, is that GUI programming is really easy when tools > are like HyperCard: conceptually simple and powerful. Because all that > complication comes from not hiding unnecessary details. Tk is like > Assembly of GUI, while higher level is needed. > > After HyperCard (and SuperCard, HyperStudio to some extent) I have not > seen anything near the quality and simplicity, unfortunately... Well, > probably Squeak (sp?) is near, but it is thing in itself. > > Sy, Roman Suzi > -- > _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ > _/ Monday, June 18, 2001 _/ Powered by Linux RedHat 6.2 _/ > _/ "Nostalgia isn't what it used to be." _/ From Administrator at crescere.co.uk Thu Jun 14 05:55:59 2001 From: Administrator at crescere.co.uk (Administrator) Date: Thu, 14 Jun 2001 10:55:59 +0100 Subject: Help Message-ID: <92B989987BD6D411A1CE00104BB348570332F5@exchange> Hello there We seem to be receiving a lot of mail from yourselves here on my server and I am unable to see whom the listing is actually going to, can you please advise me whom you are trying to send the list to? because it keeps on bouncing. Regards Amanda Cain IT Manager Crescere Resourcing -----Original Message----- From: python-list-request at python.org [mailto:python-list-request at python.org] Sent: 12 June 2001 19:07 To: python-list at python.org Subject: Python-list digest, Vol 1 #6360 - 13 msgs Send Python-list mailing list submissions to python-list at python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/python-list or, via email, send a message with subject or body 'help' to python-list-request at python.org You can reach the person managing the list at python-list-admin at python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Python-list digest..." Crescere Resourcing "Crescere is the premier provider of Technical Recruitment Solutions" To find out more about our services including the most up-to-date vacancies in the industry visit our NEW interactive website at http://www.crescere.co.uk **************************************************************************** IMPORTANT This communication is confidential and intended for the addressee only. If you have received this in error, please delete it and contact the sender as soon as possible. Crescere Resourcing Tel: +44 (0) 1908 393939 Fax: +44 (0) 1908 397474 email: Administrator at crescere.co.uk **************************************************************************** From cribeiro at mail.inet.com.br Tue Jun 26 09:41:31 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Tue, 26 Jun 2001 10:41:31 -0300 Subject: 'with' statement in python ? In-Reply-To: <3b3875f1.110436929@news.tpi.pl> References: Message-ID: <5.0.2.1.0.20010626103003.02841da0@mail.inet.com.br> At 11:49 26/06/01 +0000, Maciej Pilichowski wrote: >I have just started learning Python yesterday but... > > >def with_is_broken(a): > > with a: > > print x > > > >The snippet above assume that "a" must have a member attribute called "x". > >Nope. As you referred to Pascal -- if "a" has a member "x" it is read >as "a.x", if not it is standalone "x". There must be some misunderstanding here. My snippet (incomplete, as I pointed out) assumed that Python had a "with" keyword, just to show the kind of problems that arise. In Python, the compiler/interpreter has no way to tell beforehand if x is a member of a, a local variable, a module level variable, or a global variable. This ambiguity makes the use of with in Python impossible. Now, let us take a look at the "with" block in Pascal: with a do writeln(x); The compiler knows in advance everything about "a". If "a" does define a member called "x", then writeln() will reference "a.x". If "x" is not a member of "a", then the compiler will recursively search on the outer namespaces until it finds a definition for "x". If it does not find, it will stop - it is a fatal error, caught at compile time. Carlos Ribeiro From Attila.Feher at lmf.ericsson.se Wed Jun 6 12:52:16 2001 From: Attila.Feher at lmf.ericsson.se (Attila Feher) Date: Wed, 06 Jun 2001 19:52:16 +0300 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3B1B1825.8109BA83@lmf.ericsson.se> <2v4ohtgldvce84sn87kh1eg1lnes37getq@4ax.com> <3B1C9E65.B73A4FE@lmf.ericsson.se> <3B1DFD87.F3BFDB57@lmf.ericsson.se> <3B1E5912.CBB0BCA9@lmf.ericsson.se> Message-ID: <3B1E5FC0.4F7F1824@lmf.ericsson.se> Rainer Deyke wrote: [SNIP] > From the wxWindows FAQ: > > What platforms are supported by wxWindows 2? > * Windows 3.1, Windows 95/98, Windows NT; > * Linux and other Unix platforms with GTK+; > * Unix with Motif or the free Motif clone Lesstif; > * Mac OS; A Mac OS X port is in progress. > * A BeOS port is being investigated. > * A Windows CE port is being investigated. > * An OS/2 port is in progress, and you can also compile wxWindows for GTK+ > or Motif on OS/2. Thank you very much for your time! I think it is worth to look at it. If it progresses I can probably really make this UML tool I wanted. :-)) A From andymac at bullseye.apana.org.au Sat Jun 23 05:35:58 2001 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Sat, 23 Jun 2001 19:35:58 +1000 (EST) Subject: Numeric 20.0.0 and 19.0.0 crash Python 2.1 In-Reply-To: Message-ID: On Fri, 22 Jun 2001, Daniel Reuter wrote: > When I do the following: > import Numeric > Python 2.1 crashes with a segmentation fault. > This is on a Debian/GNU Linux system, Python is configured --with-pymalloc > --with-cxx=g++ --with-cycle-gc --enable-threads > However Python 2.1 itself compiled perfectly, make test worked well > (except for the two unicode modules, but that's not much of a problem), so > I suspect a problem with Numeric, however as far as I can remember, I > already had Numeric 19.0.0 running with Python 2.0. > Anybody experiencing the same? Solutions? I can confirm what you are seeing, using EMX/GCC on OS/2. The issue is "with-pymalloc". For some reason, Numeric is incompatible with pymalloc :-( Build Python without that option, and it most likely will be fine (it is for me). You didn't see the problem with Python 2.0 as it didn't have "with-pymalloc". I plan to log a bug report against Numeric, unless someone beats me to it. -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andrew.macintyre at aba.gov.au (work) | Snail: PO Box 370 andymac at bullseye.apana.org.au (play) | Belconnen ACT 2616 andymac at pcug.org.au (play2) | Australia From altis at semi-retired.com Wed Jun 20 11:55:13 2001 From: altis at semi-retired.com (Kevin Altis) Date: Wed, 20 Jun 2001 08:55:13 -0700 Subject: PythonCard mailing list References: Message-ID: My apologies, I forgot that Yahoo Groups (eGroups) apparently requires registration even to just read messages. At least one person has already brought this up here on comp.lang.python. If anyone has a suggestion for a forum where we can discuss, either your own listserv or a free listserv service where we can make individual messages and/or the archives available I would like to make the switch now rather than later. I'm not running my own server at this point, so I can't set one up and I don't know of a service offhand that doesn't require some kind of regisration, even for reading. Geograwler and some of the other sites just put a web front end on various lists, I don't think they host the list as well?! Thanks, ka "Kevin Altis" wrote in message news:MBUX6.1875$zE1.693567 at news.uswest.net... > http://groups.yahoo.com/group/pythoncard > > I just created this group so we can take the discussion out of > comp.lang.python. Feel free to start posting. > > ka > > From montagne at boora.com Mon Jun 4 16:21:30 2001 From: montagne at boora.com (michael montagne) Date: Mon, 04 Jun 2001 20:21:30 GMT Subject: formatting numbers Message-ID: Simple question. I am accessing a database of job numbers that take the form of "00049" and "01049". These values are integers. When I return the value from the database it reads "49". I need to add the leading digits if they are there so this number would read "00049". In MSAccess I used Format(num,"00000"). How can I do that with Python? -mjm From max at alcyone.com Mon Jun 18 11:19:30 2001 From: max at alcyone.com (Erik Max Francis) Date: Mon, 18 Jun 2001 08:19:30 -0700 Subject: Aargh! Function takes exactly x arguments, y given.. References: <9gkrud$pru$1@news.inet.tele.dk> Message-ID: <3B2E1C02.109197B5@alcyone.com> Anders And wrote: > I am a happy pythoneer using a combination of C++ and Python for my > everyday > work. > Usually, debugging is easy but every now and then, I get the "function > takes > exactly x arguments, y given" error message, clearly due to some other > problem than what Python thinks. Does anybody have any experience with > this > particular error message? I don't know what triggers it and thinking > back, I > think I have solved most of my problems with this message with a major > code > rewrite. The error means just what it says: You are calling a function with too many or too few arguments. Why you're doing that exactly is something we couldn't tell you without code examples that actually give you the error. Only thing I can think of is that you've got a confusion with bound and unbound methods; if you call an unbound method (C.f where C is a class and f is a method), then you need to provide an instance of C as the first method (the implicit self method becomes explicit). -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ There are defeats more triumphant than victories. \__/ Montaigne Alcyone Systems / http://www.alcyone.com/ Alcyone Systems, San Jose, California. From tony at lsl.co.uk Fri Jun 15 06:45:23 2001 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Fri, 15 Jun 2001 11:45:23 +0100 Subject: Any other Python flaws? In-Reply-To: Message-ID: <012a01c0f588$47fa3070$f05aa8c0@lslp7o.int.lsl.co.uk> The one thing I *really* hate in Python is the fact that starting a number with a zero suddenly magically changes its base - yuck. One thing we could have done with *not* keeping from the C family. I still remember the first time (obviously not in Python itself) I tried to lay a series of numerical choices out neatly (did BCPL have this "feature" too? was it really that far back?), and to make it neat, I naturally padded with spaces on the left. Humph. I just couldn't believe that anyone would create such a daft heffalump trap. Unfortunately, I don't see how we can escape from this one, without overly aggressive use of the time machine (and maybe it's like the quilting tradition (which may originate from the Amish) - every quilt should contain a deliberate mistake, since only God can create something perfect). Otherwise, I'm happy enough (and what with iterators and generators and such like, I'm plainly going to be able to continue my computing science education right around here, which is nice[1]). Tibs [1] Erm - has The Fast Show reached other shores? -- Tony J Ibbs (Tibs) http://www.tibsnjoan.co.uk/ "How fleeting are all human passions compared with the massive continuity of ducks." - Dorothy L. Sayers, "Gaudy Night" My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.) From aleaxit at yahoo.com Fri Jun 1 07:41:45 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 1 Jun 2001 13:41:45 +0200 Subject: continue loop without iteration... References: Message-ID: <9f7v1p02lk0@enews1.newsguy.com> "Roman Suzi" wrote in message news:mailman.991393202.7327.python-list at python.org... ... > x = y = 1 > > while x <= y: > if something: > y=y+1 > else: > dosomething > x=x+1 > > is much clearer, IMHO. > > > therefore, if the if statement is always true, it should never end, > > but as soon as it's false, dosomething will happen and it will stop. If I gather the specs correctly, x and y are purely artificial variables? "As soon as it's false, dosomething will happen and it will stop" doesn't suggest any role for x and y. The above code makes it rather unclear that this is the semantics, although it probably does respect the specs. Why not have the code be a clear and explicit restating of the specs: while something(): pass else: dosomething() This says: "if the something() condition is always true, the loop will never end, but as soon as it's false, the loop exits and dosomething() is called". Pretty much a restatement of the specs, exactly as it should be. One might stylistically prefer: while something(): pass dosomething() which is semantically equivalent and minutely more concise, but that depends on how one views the else: clause on loop statements. If 'x', the number of times the loop is executed, does have a role to play although not mentioned in the natural-language specs, it's easily added, of course: x = 1 while something(x): x += 1 dosomething(x) The y variable does seem completely artificial. Artificial variables introduced to "fake out" control structures are one of my pet peeves, as I think they detract substantially from code clarity and code simplicity -- and therefore readability and ease of maintenance. Alex From mwh at python.net Fri Jun 22 06:18:06 2001 From: mwh at python.net (Michael Hudson) Date: 22 Jun 2001 11:18:06 +0100 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) References: <90C6E61F5gmcmhypernetcom@199.171.54.154> <5em4jtko8c5sag1ap7o0rhtsh1636sf2t6@4ax.com> Message-ID: Paul Moore writes: > On 21 Jun 2001 02:48:42 GMT, gmcm at hypernet.com (Gordon McMillan) wrote: > >James Althoff wrote: > > > >>.... Meanwhile, does anyone know where to find python-iterators and > >>how to read or subscribe? Is there an archive? > > > >Yes, yes and yes. > > Are there downloadable archives? For python-iterators, and also python-sets > and python-numerics? I haven't the time or inclination to read web-based > archives online, but I'd like to grab an archive and read up offline... You can get an mbox of python-sets at: http://lists.sf.net/pipermail/python-sets.mbox/python-sets.mbox for some (irritating) reason the equivalent places for numerics and iterators are empty. Someone who's been subscribed to the lists from the beginning may be able to tar you up an archive (I've got most, but not all of python-iterators). Cheers, M. -- I'd certainly be shocked to discover a consensus. ;-) -- Aahz Maruch, comp.lang.python From jarrett at engineer.com Mon Jun 11 12:21:25 2001 From: jarrett at engineer.com (W. Jarrett Campbell) Date: Mon, 11 Jun 2001 16:21:25 GMT Subject: Basic gadfly question Message-ID: <9e6V6.15027$lq1.4843531@typhoon.austin.rr.com> I'm new to the world of Python, Databases, and SQL but it has been a fun adventure so far! I have basic question regarding the Gadfly package. I'm working with the sample database generated by the gftest.py module. I'm trying to execute an SQL statement such as: INSERT INTO frequents (DRINKER, BAR) values ('Jarrett', 'cheers') When I do this I get an error back saying that I did not define a value for the column 'PERWEEK' My questions are these? Do you have to set all values in the insert statement or is there some way around this? Is this bad database programming form to want to set only some fields? Is this related to gadfly not supporting Null values? When using the ODBC package in the win32all distribution, I can achieve this functionality with MS Access databases. I wanted to stick with gadfly to remain platform independent and not require my users to purchase Access. Any advice? Thanks in advance, W. Jarrett Campbell jarrett at engineer.com From Randy.L.Kemp at motorola.com Tue Jun 26 08:58:50 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Tue, 26 Jun 2001 07:58:50 -0500 Subject: new to python Message-ID: See answers below -----Original Message----- From: jonbeebe at softhome.net [mailto:jonbeebe at softhome.net] Sent: Monday, June 25, 2001 10:18 PM To: python-list at python.org Subject: new to python Hello comp.lang.python, I am a Linux User and I am new to Python Programming and this newsgroup. I don't really know what python is all about so it would be much appreciated if you would answer my following questions. - Is python like c/c++ where you can make pretty much any kind of program you want whether is be games, gui apps, etc. or is it like cgi where you can only use it in websites? ---> like C and C++ <--- - Is python object oriented? ---> yes <--- - Should I develop in Python? Is it good for programming, is it powerfull and are job opportunities good for Python developers? ---> Unfortunately, job opportunities are limited, compared to Java and C++ <--- - When I make a Python program, do I just leave it as a .py file or is there a way to make it into some kind of executable file like in C++? When I make a program in Python, how do I distribute it out to people? Do I just send out the .py file? Does the user need some kind of runtime environment or something? Do they need to download something else rather than my program? ---> Leave the PY extension intact. Users need a python environment, from either www.python.org or www.activestate.com <--- I know that's a lot of questions but I haven't found them on the net yet. Please answer my questions if you will by emailing me at jonbeebe at softhome.net. If you email me, that way I'll be sure to recieve the reply, otherwise, i might miss it. Thank you very much, - Beebe From niemeyer at conectiva.com Fri Jun 1 21:58:41 2001 From: niemeyer at conectiva.com (Gustavo Niemeyer) Date: Fri, 1 Jun 2001 22:58:41 -0300 Subject: ThreadingTCPServer not working Message-ID: <20010601225841.A13690@tux.distro.conectiva> Hello!! Does anyone know if something is wrong here, or I'm just doing something stupid? Python 2.1 (#1, May 8 2001, 16:26:24) [GCC 2.95.3 20010315 (release) (conectiva)] on linux-i386 Type "copyright", "credits" or "license" for more information. >>> import SocketServer >>> import BaseHTTPServer >>> s = SocketServer.ThreadingTCPServer(("localhost", 8000), BaseHTTPServer.BaseHTTPRequestHandler) >>> s.serve_forever() Then, when trying to connect: Exception in thread Thread-1: Traceback (most recent call last): File "/var/tmp/python-2.1-root/usr/lib/python2.1/threading.py", line 378, in __bootstrap self.run() File "/var/tmp/python-2.1-root/usr/lib/python2.1/threading.py", line 366, in run apply(self.__target, self.__args, self.__kwargs) File "/var/tmp/python-2.1-root/usr/lib/python2.1/SocketServer.py", line 246, in finish_request self.RequestHandlerClass(request, client_address, self) File "/var/tmp/python-2.1-root/usr/lib/python2.1/SocketServer.py", line 494, in __init__ self.setup() File "/var/tmp/python-2.1-root/usr/lib/python2.1/SocketServer.py", line 537, in setup self.rfile = self.connection.makefile('rb', self.rbufsize) error: (9, 'Bad file descriptor') Thanks!! -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ] From andreas at digicool.com Fri Jun 1 11:43:38 2001 From: andreas at digicool.com (Andreas Jung) Date: Fri, 1 Jun 2001 11:43:38 -0400 Subject: join does not call __str__ References: Message-ID: <090b01c0eab1$a0649070$0901000a@SUXLAP> Not really. The string.join() documentation says that is joins a sequence of words (strings). There is no implicit conversion of the arguments using str(). Use instead: b=['c','d',str(a)] Andreas ----- Original Message ----- From: "Sasa Zivkov" To: Sent: Friday, June 01, 2001 11:12 AM Subject: join does not call __str__ > > >>> class A: > ... def __str__(self): > ... return "str-a" > ... > >>> a = A() > >>> print a > str-a > >>> b = ['c', 'd', a] > >>> "".join(b) > Traceback (most recent call last): > File "", line 1, in ? > TypeError: sequence item 2: expected string, instance found > > > Somehow I expected that join method would use __str__ method to convert > instance to string... > > Your opinion ? > > -- Sasa > > -- > http://mail.python.org/mailman/listinfo/python-list From johnroth at ameritech.net Thu Jun 7 19:31:33 2001 From: johnroth at ameritech.net (John Roth) Date: Thu, 7 Jun 2001 16:31:33 -0700 Subject: Interesting speed benchmark References: <87elswq9e6.fsf@netcologne.de> Message-ID: "Peter Herth" wrote in message news:87elswq9e6.fsf at netcologne.de... > msoulier at storm.ca (Michael P. Soulier) writes: > > > On Thu, 7 Jun 2001 10:40:04 +1000, Delaney, Timothy > > wrote: > > This makes sense, but if Python is doing less allocation, that should also > > be a time saver, no? Or did the performance increase in lazy GC just so far > > outweight the benefits of less malloc() calls that it didn't matter here? > > > > Mike > > Well that depends very much on the kind of program at hand: > If, as in the example, the allocated pieces of memory have a very > short living and get only referenced once, a reference-counting > implementation of a GC is perhaps the fastest solution. But > reference-counting has 2 big drawbacks: any referencing of > an object has an additional cost of the reference count bookkeeping, > and it cannot deal with cyclic references. Furthermore, memory > might fragment, and this makes malloc() a rather expensive operation. > > Other garbage collection techniques do not have the extra cost at > referencing objects, but cleaning them up usually involves inspecting > part or even the whole heap to determine what can be collected. > This is of course a very time-intensive operation, but depending on > the requirements of the program can still be much faster than > reference counting. > > One common approach taken in modern garbage collectors is generational > collection: objects on the heap are put into "generation" depending on > their age, garbage collection runs mostly look only at the youngest > objects, so all the short-living temporary objects can be cleared > with very low overhead. If the collectors do some compacting of the > heap in the process, the speed of allocation can be *greatly* increased, > to the point where heap allocation is as fast as stack allocation. > (In my experience, most of the impressive speed-up of Hotspot comes > through the generational GC) > > Peter Garbage collection is an interesting topic, however, it seems to me that Python has a major hurdle moving to a modern (i.e. incremental) garbage collection process, namely extension types. Any form of garbage collection has to be able to locate all of the objects. With Python's built-in types, this isn't much of a problem, but for a foreign type, any references to other objects have to be made visible by the implementation of the type, so retrofitting a real garbage collector would break a lot of extensions. The other hurdle is that garbage collectors trade off overhead in collecting garbage by providing a memory model that makes it very fast to allocate new memory. Compacting memory also requires being able to locate all pointers to objects, and with low level extensions, that could present very difficult to debug problems. Python 3000 anyone? John Roth From zihonglu at home.com Sat Jun 23 23:03:39 2001 From: zihonglu at home.com (zihonglu) Date: Sun, 24 Jun 2001 03:03:39 GMT Subject: win32 extension installation problem Message-ID: We are building a product with python and the win32 extension, in win32 environment. I have a problem in shipping the product with win32 extension. What I really want is to have the python interpreter and the win32 extension installed inside our product's directory, say c:\MySoftware\Python, and in the registry, set python's keys under HKLM\Software\MySoftware\Python, instead of the typical HKLM\Software\Python, to avoid conflict with customer's possible existing python installation or possible future python installation change. I can achieve that by change python's source code to look for the new registry key. However, since I am also using the win32 extension, it looks HKLM/Software/Python for its installation and execution, not my new keys. I also use PythonService.exe, which checks for its key under HKLM/Software/Python for registering the service, not the one I set under my new keys. To solve these problems, how many places I need to change the win32 extension source code, if I can find them? Is there a better way? Where do I get the source code? I am aware of McMillan's installer. I am afraid that is not what we need since we want the product to be extensible by our customers, not to be freezed. Any info is highly appreciated. -Zihong From sholden at holdenweb.com Tue Jun 26 08:39:54 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 26 Jun 2001 08:39:54 -0400 Subject: SQL-SELECT against View via ODBC? References: Message-ID: <2l%Z6.22470$g4.740189@e420r-atl2.usenetserver.com> The generic odbc driver (I presume you mean the one from the Windows extensions) is known to be in need of maitnenance, and I understand from a recent posting that Mark Hammond expects to release a slightly updated copy (may even have done so by now). I checked views out using mxODBC (see www.egenix.com, follow the links at the foot of the page) and everything was fine. Using the generic odbc driver I couldn't even access my ODBC source, since I don't use trusted connections! If this isn't a commercial project you might want to consider using mxODBC. It's my ODBC driver of choice. regards Steve -- http://www.holdenweb.com/ "Bill Seitz" wrote in message news:e2491a75.0106251209.c19d5e at posting.google.com... > I'm writing ASP page that uses the generic Python ODBC driver to query > MsSql2K. Have some generic Python that grabs both an array of the > resultSet (cursor FetchAll), plus an array of fieldNames (cursor > Description). > > When I run this code against a view (which just does a pretty simple > join: have queried the view fine in MsSqlQueryAnalyzer), I get an > error message about > > SQL select Failed - "select * from timechargesAsHours" - > [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index in FETCH > > Is there a problem getting cursor descriptions via ODBC? From thomas at xs4all.net Fri Jun 29 18:14:57 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sat, 30 Jun 2001 00:14:57 +0200 Subject: [Python-iterators] While we're at it... In-Reply-To: References: Message-ID: <20010630001457.D8098@xs4all.nl> On Fri, Jun 29, 2001 at 02:34:44PM -0700, David Eppstein wrote: > In article , > "Tim Peters" wrote: > > - The following functions were generalized to work nicely with iterator > > arguments: > > map(), filter(), reduce(), zip() > Is there a PEP for this? It doesn't seem to be in 234. It's one of those things that are so obvious, they aren't PEPed :) > Can I assume that "work nicely" means they act like simple generators in > yielding partial results even when their inputs are infinite sequences? This change was part of the Iterator PEP, not the Generator PEP. They aren't modified to return generators, they are just generalized to work with iterators, and hence accept iterators, as well as sequences with and without their own iterator, as arguments. After all, those functions are just glorified for loops. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From chrishbarker at home.net Mon Jun 11 19:15:01 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 11 Jun 2001 16:15:01 -0700 Subject: is c faster? References: <9ftlpv029hk@enews2.newsguy.com> Message-ID: <3B2550F5.ED7F54D@home.net> Alex Martelli wrote: > a speed up as small as 20% That must have been disapointing! > it's possible) and as big as 1,000%, i.e., 10 times faster (again, > I haven't seen anything more than that on real code, although in I got an approx 100X speedup in my only substantial extension (still not that big). I was already using NumPy arrays, but there was just no way to "vectorize" the whole thing. I may have been able to get a 10X speed-up or so keeping it in just Python if I put some time into it, but I knew I wasn't going to get what I needed, so I went to C. If only there was a Py2C that knew about NumPy arrays, I wouldn't have had to write that darn C code at all! -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From prem at engr.uky.edu Sat Jun 2 23:29:18 2001 From: prem at engr.uky.edu (Prem Rachakonda) Date: 2 Jun 2001 20:29:18 -0700 Subject: Python-GnuPlot : Plotting problems Message-ID: Hi, 1. I have a set of z values in a matrix of [5000,100] from which I have to get the contour of a surface and the lenghts of x and y are 5000 and 100. If I try to plot by using the following function, I am not getting the contour g.splot(Gnuplot.GridData(z,x,y, binary=0)) I tried to use only one set of values ie. The sizes of matrices are given below z[5000,1] x[5000] y[1] This gave me a perfect profile of the contour( It extends in the y direction) When I went for 2 sets of values, ie. z[5000,2], x[5000], y[2] then I get 4 plots of the contours 1st two plots are in the x-z plane (at y[1]), the first one from x[0] to x[2500] and the other from x[2501] to x[5000] 2nd two plots are a mirror of the above 2 plots but at y[2] This is absolutely out of my understanding. Can someone explain why this is happening. 2.Also how to issue command to Gnuplot. I want to change the view of a plot and the Gnuplot's way it to say 'set view 90,0'.How to issue command from Python to execute this command. Prem. From jkraska1 at san.rr.com Sat Jun 9 04:11:50 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 09 Jun 2001 08:11:50 GMT Subject: is c faster? References: Message-ID: <7um3it06b0cj6blpnc4r24co685ktmmsmr@4ax.com> On Sat, 9 Jun 2001 01:43:20 -0700, "akhar" wrote: >I have a script I wrote in python , I love the time it took me to devellop >it faster than i could have done it in C. however after full review of my >code I am not sure I can optimize it any more( it basicaly consist of >importing an image and tranforming into a matrix to perform some for-looped >operations on it) : I went from 20 seconds to 2. There are a variety of native image importing libraries out there already. They are very fast (and coded in C). I think the one you want is called "PIL". C// From michael at stroeder.com Mon Jun 25 12:13:24 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Mon, 25 Jun 2001 18:13:24 +0200 Subject: DistUtils and optimized compile References: <3B375869.E417C833@stroeder.com> <9h7lng$cdpjl$1@ID-59885.news.dfncis.de> <3B375F47.64A232D2@stroeder.com> <9h7nlg$cbtbq$1@ID-59885.news.dfncis.de> Message-ID: <3B376324.7EB0C778@stroeder.com> Thomas Heller wrote: > > python setup.py install -O1 Thanks Thomas, python setup.py install -O2 is exactly what I wanted. But I wonder why this isn't the default. Ciao, Michael. From dgoodger at bigfoot.com Wed Jun 13 00:42:54 2001 From: dgoodger at bigfoot.com (David Goodger) Date: Wed, 13 Jun 2001 00:42:54 -0400 Subject: PEP 258: DPS Generic Implementation Details Message-ID: I am posting this PEP to comp.lang.python for greatest community exposure. Please direct replies to the Python Documentation SIG's mailing list: mailto:doc-sig at python.org. In addition to the master copy at http://python.sf.net/peps/pep-0258.txt (HTML at http://python.sf.net/peps/pep-0258.html), a working copy is kept at the project web site, http://docstring.sf.net/. -- David Goodger dgoodger at bigfoot.com Open-source projects: - Python Docstring Processing System: http://docstring.sf.net - reStructuredText: http://structuredtext.sf.net - The Go Tools Project: http://gotools.sf.net PEP: 258 Title: DPS Generic Implementation Details Version: $Revision: 1.1 $ Last-Modified: $Date: 1935/06/06 05:54:49 $ Author: dgoodger at bigfoot.com (David Goodger) Discussions-To: doc-sig at python.org Status: Draft Type: Standards Track Created: 31-May-2001 Post-History: Abstract This PEP documents generic implementation details for a Python Docstring Processing System (DPS). The rationale and high-level concepts of the DPS are documented in PEP 256, "Docstring Processing System Framework" [1]. Specification Docstring Extraction Rules ========================== 1. If the '__all__' variable is present in the module being documented, only identifiers listed in '__all__' are examined for docstrings. In the absense of '__all__', all identifiers are examined, except those whose names are private (names begin with '_' but don't begin and end with '__'). 2. Docstrings are string literal expressions, and are recognized in the following places within Python modules: a) At the beginning of a module, class definition, or function definition, after any comments. This is the standard for Python __doc__ attributes. b) Immediately following a simple assignment at the top level of a module, class definition, or __init__ method definition, after any comments. See "Attribute Docstrings" below. c) Additional string literals found immediately after the docstrings in (a) and (b) will be recognized, extracted, and concatenated. See "Additional Docstrings" below. 3. Python modules must be parsed by the docstring processing system, not imported. There are security reasons for not importing untrusted code. Also, docstrings are to be recognized in places where the bytecode compiler ignores string literal expressions (2b and 2c above), meaning importing the module will lose these docstrings. Of course, standard Python parsing tools such as the 'parser' library module should be used. Since attribute docstrings and additional docstrings are not recognized by the Python bytecode compiler, no namespace pollution or performance degradation will result from their use. (The initial parsing of a module may take a slight performance hit.) Attribute Docstrings -------------------- XXX A description of attribute docstrings would be appropriate in PEP 257 "Docstring Conventions". (This is a simplified version of PEP 224 [3] by Marc-Andre Lemberg.) A string literal immediately following an assignment statement is interpreted by the docstring extration machinery as the docstring of the target of the assignment statement, under the following conditions: 1. The assignment must be in one of the following contexts: a) At the top level of a module (i.e., not inside a loop or conditional): a module attribute. b) At the top level of a class definition: a class attribute. c) At the top level of a class' '__init__' method definition: an instance attribute. Since each of the above contexts are at the top level (i.e., just inside the outermost suite of a definition), it may be necessary to place dummy assignments for attributes assigned conditionally or in a loop. Blank lines may be used after attribute docstrings to emphasize the connection between the assignment and the docstring. 2. The assignment must be to a single target, not to a list or a tuple of targets. 3. The form of the target: a) For contexts 1a and 1b above, the target must be a simple identifier (not a dotted identifier, a subscripted expression, or a sliced expression). b) For context 1c above, the target must be of the form 'self.attrib', where 'self' matches the '__init__' method's first parameter (the instance parameter) and 'attrib' is a simple indentifier as in 3a. Examples:: g = 'module attribute (global variable)' """This is g's docstring.""" class AClass: c = 'class attribute' """This is AClass.c's docstring.""" def __init__(self): self.i = 'instance attribute' """This is self.i's docstring.""" Additional Docstrings --------------------- XXX A description of additional docstrings would be appropriate in the PEP 257, "Docstring Conventions" [4]. Many programmers would like to make extensive use of docstrings for API documentation. However, docstrings do take up space in the running program, so some of these programmers are reluctant to 'bloat up' their code. Also, not all API documentation is applicable to interactive environments, where __doc__ would be displayed. The docstring processing system's extraction tools will concatenate all string literal expressions which appear at the beginning of a definition or after a simple assignment. Only the first strings in definitions will be available as __doc__, and can be used for brief usage text suitable for interactive sessions; subsequent string literals and all attribute docstrings are ignored by the Python bytecode compiler and may contain more extensive API information. Example:: def function(arg): """This is __doc__, function's docstring.""" """ This is an additional docstring, ignored by the bytecode compiler, but extracted by the docstring processing system. """ pass Issue: This breaks 'from __future__ import' statements in Python 2.1 for multiple module docstrings. Resolution? 1. Should we search for docstrings after a __future__ statement? Very ugly. 2. Redefine __future__ statements to allow multiple preceeding string literals? 3. Or should we not even worry about this? There shouldn't be __future__ statements in production code, after all. Modules with __future__ statements will have to put up with the single-docstring limitation. Choice of Docstring Format ========================== Rather than force everyone to use a single docstring format, multiple input formats are allowed by the processing system. A special variable, __docformat__, may appear at the top level of a module before any function or class definitions. Over time or through decree, a standard format or set of formats should emerge. The __docformat__ variable is a string containing the name of the format being used, a case-insensitive string matching the input parser's module or package name (i.e., the same name as required to 'import' the module or package), or a registered alias. If no __docformat__ is specified, the default format is 'plaintext' for now; this may be changed to the standard format once determined. The __docformat__ string may contain an optional second field, separated from the format name (first field) by a single space: a case-insensitive language identifier as defined in RFC 1766 [5]. A typical language identifier consists of a 2-letter language code from ISO 639 [6] (3-letter codes used only if no 2-letter code exists; RFC 1766 is currently being revised to allow 3-letter codes). If no language identifier is specified, the default is 'en' for English. The language identifier is passed to the parser and can be used for language-dependent markup features. DPS Structure ============= - package 'dps' - function 'dps.main()' (in 'dps/__init__.py') - package 'dps.parsers' - module 'dps.parsers.model'; see 'Input Parser API' below. - package 'dps.formatters' - module 'dps.formatters.model'; see 'Output Formatter API' below. - package 'dps.languages' - module 'dps.languages.en' (English) - others to be added - utility modules: 'dps.statemachine' Command-Line Interface ====================== XXX To be determined. System Python API ================= XXX To be determined. Input Parser API ================ Each input parser is a module or package exporting a 'Parser' class, with the following interface: class Parser: def __init__(self, inputstring, errors='warn', language='en'): """Initialize the Parser instance.""" def parse(self): """Return a DOM tree, the parsed input string.""" XXX This needs a lot of work. What is required for this API? A model 'Parser' class implementing the full interface along with utility functions can be found in the 'dps.parsers.model' module. Output Formatter API ==================== Each output formatter is a module or package exporting a 'Formatter' class, with the following interface: class Formatter: def __init__(self, domtree, language='en', showwarnings=0): """Initialize the Formatter instance.""" def format(self): """ Return a formatted string representation of the DOM tree. """ XXX This also needs a lot of work. What is required for this API? A model 'Formatter' class implementing the full interface along with utility functions can be found in the 'dps.formatters.model' module. Language Module API =================== Language modules will contain language-dependent strings and mappings. They will be named for their language identifier (as defined in 'Choice of Docstring Format' above), converting dashes to underscores. XXX Specifics to be determined. Intermediate Data Structure =========================== A single intermediate data structure is used internally by the docstring processing system. This data structure is a DOM tree whose schema is documented in an XML DTD (eXtensible Markup Language Document Type Definition), which comes in three parts: - the Python Plaintext Document Interface DTD, ppdi.dtd [7], - the Generic Plaintext Document Interface DTD, gpdi.dtd [8], - and the OASIS Exchange Table Model, soextbl.dtd [9]. The DTD defines a rich set of elements, suitable for any input syntax or output format. The input parser and the output formatter share the same intermediate data structure. The processing system may do transformations on the data from the input parser before passing it on to the output formatter. The DTD retains all information necessary to reconstruct the original input text, or a reasonable facsimile thereof. XXX Specifics (about the DOM tree) to be determined. Output Management ================= XXX To be determined. Type of output: filesystem only, or in-memory data structure too? File/directory naming & structure conventions. In-memory data structure should follow filesystem naming; file/directory == leaf/node. Use a directory hierarchy rather than long file names (long file names were one of the reasons pythondoc couldn't run on MacOS). References and Footnotes [1] http://python.sf.net/peps/pep-0256.html [2] http://www.python.org/sigs/doc-sig/ [3] http://python.sf.net/peps/pep-0224.html [4] http://python.sf.net/peps/pep-0257.html [5] http://www.rfc-editor.org/rfc/rfc1766.txt [6] http://lcweb.loc.gov/standards/iso639-2/englangn.html [7] http://docstring.sf.net/spec/ppdi.dtd [8] http://docstring.sf.net/spec/ppdi.dtd [9] http://docstring.sf.net/spec/soextblx.dtd Project Web Site A SourceForge project has been set up for this work at http://docstring.sf.net. Copyright This document has been placed in the public domain. Acknowledgements This document borrows ideas from the archives of the Python Doc-SIG [2]. Thanks to all members past & present. Local Variables: mode: indented-text indent-tabs-mode: nil End: From bill-bell at bill-bell.hamilton.on.ca Fri Jun 15 11:22:15 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Fri, 15 Jun 2001 11:22:15 -0400 Subject: Python-list: the list with everything! In-Reply-To: <992614317.473.32736.l7@yahoogroups.com> Message-ID: <3B29EFE7.15209.8888D6@localhost> Gotta love this list. Brain teasers. Friendly discussion. Intellectual diversion. ... and tips about newly available porno sites. Thanks, everyone! From jeffwong at transmeta.com Thu Jun 21 01:07:20 2001 From: jeffwong at transmeta.com (Jeff Wong) Date: Wed, 20 Jun 2001 22:07:20 -0700 Subject: re.match(...) fails to find a match References: Message-ID: In article , kjcole at well.com (Kevin Cole) wrote: > print p.match('This string & that string') 'match' matches from the beginning of the string. You probably want to use 'search' to find the first one or 'findall' to find all of them. From george at cc.gatech.edu Wed Jun 27 21:57:52 2001 From: george at cc.gatech.edu (George Thomas) Date: Wed, 27 Jun 2001 21:57:52 -0400 Subject: list of dictionaries References: <3B3A4B97.5F4EB1F1@cc.gatech.edu> <9hdjmt$dk0ki$1@ID-11957.news.dfncis.de> <3B3A58A1.AE09529@cc.gatech.edu> <9hdme5$di2n4$1@ID-11957.news.dfncis.de> Message-ID: <3B3A8F20.71F0DE04@cc.gatech.edu> Hi, That makes sense. However, to make sure I understand completely, I'll list the steps in question. Given: A single dict object, call it dict (how original!) 1. Start with empty list 2. Update fields of dict 3. append dict to list. 4. Update fields of dict. 5. append dict to list. The thing I can't understand is: even though dict reflects the change in (4), the append() operation seems to ignore it completely, giving me a copy of the previous contents. Why does this happen ? Thanks for the insight on the alternative solution. I guess I'll rest easy when the issue above has an explanation :) Emile van Sebille wrote: > > It is appended. That's why you see two copies of the same dict in the list. > To get different dicts in the list, you *must* create new dicts for each > entry. Otherwise, each entry simply points to the same dict. You can use > the {}.copy method for this data, but be forewarned that you need to be > careful for nested data structures. > > dict_entry['a'] = a2 > dict_entry['b'] = b2 > dict_entry['c'] = c2 > dict_entry['d'] = d2 > sample_list.append(dict_entry.copy()) ------------------------------------------------------------ George Thomas reduce (lambda c,d:chr(ord(d)-2)+c, 'ofcpqkekhhC"zwpkN"fgtgyqR/pqjv{R') ------------------------------------------------------------ From phd at phd.fep.ru Fri Jun 8 16:22:34 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Sat, 9 Jun 2001 00:22:34 +0400 (MSD) Subject: RS232 support for DOS on 486? In-Reply-To: <3B2131D4.58DA7231@mitre.org> Message-ID: On Fri, 8 Jun 2001, Mike Brenner wrote: > DOS is not dead when Microsoft stops selling it. DOS is dead when people > stop using it and throw away their old computers. No, DOS is dead because there are better OSes - cheaper, and more powerful. You can run Linux on 386SX with 8 megagbytes of RAM, and having enough swap space you can run Python in full 32bit mode (native to Linux) without DOS Extender at all. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From skip at pobox.com Thu Jun 21 08:22:10 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 21 Jun 2001 07:22:10 -0500 Subject: PEP 255: Simple Generators In-Reply-To: <3B317D8B.A729897C@cosc.canterbury.ac.nz> References: <9gnv2o$its$1@nntp6.u.washington.edu> <3B317D8B.A729897C@cosc.canterbury.ac.nz> Message-ID: <15153.59122.156020.275325@beluga.mojam.com> Greg> "Barry A. Warsaw" wrote: >> They are very different because the body of a generator function >> defines the generator object's .next() method, but the def names the >> generator object's factory function. Greg> That's an interesting point -- there are actually two separate Greg> things going on, but the syntax is collapsing them into one Greg> construct. Sounds to me like the obvious analogue is a class definition with a magic method named __next__. When you instantiate the class, __init__ gets called to set up the computation and the caller receives an instance object for its trouble. The __next__ method is then called repeatedly to iterate over the set of possible values, raising StopIter if/when the sequence is exhausted. Seems like a missing alternative way to write tokeneater in the PEP. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From mal at lemburg.com Fri Jun 15 06:19:35 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 15 Jun 2001 12:19:35 +0200 Subject: Office's Access XP ODBC DBI from PythonWin References: <9ga6cd02m44@enews1.newsguy.com> Message-ID: <3B29E137.9473C4FA@lemburg.com> Benjamin Schollnick wrote: > > > mx.ODBC > > instead > > > of ODBC? If you don't plan commercial use it is free, and I can certainly > > > recommend it for ease of use. > > > > Seconded. But a minimally-working free odbc would still be > > a good thing IMHO. Say I write utilities to be internally > > used here at work (commercial use by mx's terms). As long > > as I run them on Windows only, I'm OK -- I can program to > > ADO and connect that to whatever DB engine. But -- no funds > > for mxODBC for that use. So -- no running my utilities on > > Linux boxes. Notch one more black mark discouraging this > > spread of Linux boxes around here:-(. > > Seconded here.... > > I was told point blankly by Marc that even though I was using MxODBC, > for my own non-commercial projects, that since I was using it at work > it had to be commercially licensed.... Even though the app was not be > distributed, and just a simple CGI script... How is this different from using say WinZIP in a commercial environment ? I believe that the mxODBC license is very liberal compared to other commercial software (usage is free for private use, you get the complete source code, etc.) and certainly not too expensive for a company to license. > I don't mind that, I can understand where he was coming from... But > win32's ODBC code seems to work fine for our purposes, and should still > be developed....or maintained... > > MxODBC can't be the only ODBC code out there..... ODBC is *very* complicated and maintaining an interface for it to make the user experience a painless one *very* time consuming. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From emile at fenx.com Fri Jun 1 18:51:11 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 1 Jun 2001 15:51:11 -0700 Subject: spaces and arguements.. References: <3UPR6.243439$Z2.2750797@nnrp1.uunet.ca> <9f93pa11ioh@enews1.newsguy.com> Message-ID: <9f96g7$307e4$1@ID-11957.news.dfncis.de> "Alex Martelli" wrote in message news:9f93pa11ioh at enews1.newsguy.com... > *Used to* because, moving from VB6 to VB7 aka VB.NET, Microsoft > has introduced many incompatible changes in Visual Basic yet again... -- Emile van Sebille emile at fenx.com --------- From samschul at pacbell.net Sun Jun 3 23:25:38 2001 From: samschul at pacbell.net (Samuel Schulenburg) Date: 3 Jun 2001 20:25:38 -0700 Subject: ANN: ASPIPython updated for Python 2.1 Message-ID: I have updated the ASPIPython dlls to function with Python 2.1 library. I would like to thank everyone on this forum who helped me solve an embedded C to python problem. See http://starship.python.net/crew/samschul/ for more information on these libraries, and to download them. Sam Schulenburg From tim at digicool.com Thu Jun 21 11:16:29 2001 From: tim at digicool.com (Tim Peters) Date: Thu, 21 Jun 2001 11:16:29 -0400 Subject: PEP 255: Simple Generators In-Reply-To: <15153.59122.156020.275325@beluga.mojam.com> Message-ID: [Skip Montanaro] > Sounds to me like the obvious analogue is a class definition with a > magic method named __next__. When you instantiate the class, __init__ > gets called to set up the computation and the caller receives an > instance object for its trouble. The __next__ method is then called > repeatedly to iterate over the set of possible values, raising StopIter > if/when the sequence is exhausted. > > Seems like a missing alternative way to write tokeneater in the PEP. I considered it too close to the "maintain a state machine in global variables" way to be worth splitting out as a distinct case: the burden of maintaining a state machine by hand just shifts from mucking with globals to mucking with instance vrbls. The latter is preferable, but the former was easier to explain . From Cayce at actzero.com Tue Jun 19 01:21:24 2001 From: Cayce at actzero.com (Cayce Ullman) Date: Mon, 18 Jun 2001 22:21:24 -0700 Subject: What's the best way to implement a real-world SOAP server? Message-ID: Jim Severino wrote: > I see that Actzero's SOAP.py provides a SOAPServer class that > implements a request handler which handles object and function > registration as well as the network side of things through the > imported BaseHTTPServer class. This works for development and testing, > but what about real-world implementations, where a SOAP server may be > expected to handle hundreds of requests per second? Doesn't the > BaseHTTPServer only execute one request at a time? > > I would like to know what people think would be a suitable SOAP server > (that works with Python modules, of course) for a "real-world" > environment. The ideal server would implement simultaneous processing > of multiple requests, database connection pooling.... all of the > things that a good webserver setup implements. > > I was looking at mod_python + Apache, but I don't see how one can go > about using SOAPServer with them, since SOAPServer provides its own > HTTP server. > Jim, Actzero's implementation of SOAP is just that -- an implementation of SOAP. The goal was to create a SOAP library that would work with anyone's server environment. The SOAPServer is included as an example and is for testing purposes. Of the 3500+ lines of code in SOAP.py less than a 100 are dedicated to mating it with BaseHTTPServer. It should be fairly easy just to use the SOAPServer class (the do_POST method in particular) as an example and use it with mod_python, Medusa, or Zope. That being said we do plan on including some examples using other servers before we get to an 1.0 release. Cayce From nas at python.ca Tue Jun 5 13:32:27 2001 From: nas at python.ca (Neil Schemenauer) Date: Tue, 5 Jun 2001 10:32:27 -0700 Subject: floating point in 2.0 In-Reply-To: ; from msoulier@storm.ca on Tue, Jun 05, 2001 at 03:28:54AM +0000 References: Message-ID: <20010605103227.B3896@glacier.fnational.com> Michael P. Soulier wrote: > Greetings people. > > My apologies if this has been covered. Once or twice: http://marc.theaimsgroup.com/?l=python-list&m=95211106224164 http://marc.theaimsgroup.com/?l=python-list&m=95640521622412 http://marc.theaimsgroup.com/?l=python-list&m=96161791120761 http://marc.theaimsgroup.com/?l=python-list&m=96965473100989 http://marc.theaimsgroup.com/?l=python-list&m=96972867512487 http://marc.theaimsgroup.com/?l=python-list&m=97194862422037 http://marc.theaimsgroup.com/?l=python-list&m=97302703913367 http://marc.theaimsgroup.com/?l=python-list&m=98158294316864 http://marc.theaimsgroup.com/?l=python-list&m=98443389107846 http://marc.theaimsgroup.com/?l=python-list&m=98480121228331 http://marc.theaimsgroup.com/?l=python-list&m=98642228613729 http://marc.theaimsgroup.com/?l=python-list&m=98821363419139 http://marc.theaimsgroup.com/?l=python-list&m=98859525100404 http://marc.theaimsgroup.com/?l=python-list&m=98950628508740 http://marc.theaimsgroup.com/?l=python-list&m=99006377306979 http://marc.theaimsgroup.com/?l=python-list&m=99028749324644 http://marc.theaimsgroup.com/?l=python-list&m=99112962811436 http://marc.theaimsgroup.com/?l=python-list&m=99131963627220 http://marc.theaimsgroup.com/?l=python-list&m=99132810728498 http://marc.theaimsgroup.com/?l=python-list&m=99149772126928 http://marc.theaimsgroup.com/?l=python-list&m=99171217024980 See: http://www.python.org/doc/FAQ.html#4.98 http://www.python.org/cgi-bin/moinmoin/RepresentationError for a summary. Neil From bill-bell at bill-bell.hamilton.on.ca Mon Jun 11 10:50:16 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Mon, 11 Jun 2001 10:50:16 -0400 Subject: Lost between urllib and httplib In-Reply-To: <992221832.705.29435.l8@yahoogroups.com> Message-ID: <3B24A268.19297.D48B549@localhost> Doug Fort wrote, in part: > HTTP results 301 and 302 are redirections. You have to handle them > yourself using httplib. The good news is that httplib gives you > the flexibility to handle them as you want. I have attached one of > our HTTP clients that uses httplib. It handles all three sites > you mentioned. Doug, unfortunately I receive a digest of this list that does not include attachments. Is it possible that the sample client you mentioned is available somewhere on the 'net. Thanks very much in any case. - Bill Bill Bell, Software Developer From robin at jessikat.fsnet.co.uk Fri Jun 1 14:28:35 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 1 Jun 2001 19:28:35 +0100 Subject: win32 libs/Python21.lib Message-ID: This quote appears in a recent Zope article by brian http://www.zope.org/Members/Brian/Misc/ExtensionBuilder/ExtensionBuilderUpdate-053101 Note: if your are attempting to build on win32 and have installed only the standard Python 2.1 for windows, you will need to download an updated python21.lib and replace the version in the 'libs' directory of your Python installation. The version that comes with Python2.1 does not appear to be the correct one for building win32-x86 libraries. I have been using this OK with VC++ 6.0 and have noticed no problems, but what should I be worried about? -- Robin Becker From andreas at andreas-jung.com Thu Jun 14 14:06:03 2001 From: andreas at andreas-jung.com (Andreas Jung) Date: Thu, 14 Jun 2001 14:06:03 -0400 Subject: New statement proposal for Python Message-ID: <04dd01c0f4fc$ae168020$3e17a8c0@SUXLAP> "David LeBlanc" schrieb im Newsbeitrag news:9gao5s$8ft$7 at 216.39.170.247... > One thing that bugs me about Python is that there's no really good way to > have named constants so that magic numbers can be avoided. Assigning to a > variable that (should) never changes is not the same (i.e. the "should > never" part). > > My proposal: > > alias httpport : 80 > alias astring : "Strings are ok too!" > alias alist : [a, b, c] > alias atuple : {one : 1} #etc. > alias aconstant : can be anything not containing an explict nl or # > alias true: 1 # create an alias for 1 > > alias true: not 0 # this is ok too, but not after the previous > # declaration! > >> error: redefinion error! > > alias false: is zero # everything up to the nl or octothorpe is the > # replacement text > Extremly ugly and I don't know what the real benefits are... syntactic sugar. Andreas From steve at hkit.net Thu Jun 21 13:25:53 2001 From: steve at hkit.net (Steve S.L. Wong) Date: Fri, 22 Jun 2001 01:25:53 +0800 Subject: Can anyone build ExtensionClass.c using Borland compiler? Message-ID: Hi, I downloaded ZODB.tar.gz from http://www.amk.ca/files/zodb/. (Z Object Database) I found I have to build "ExtensionClass" included in the distribution (i.e. zodb.tar.gz) before i can use the object database. (It's source code, I need to build it to Win32 binary) I'm using Windows ME and do not have M$VC compiler, so I downloaded the Borland's free compiler (www.borland.com/bcppbuilder/freecompiler). I's using ActivePython 2.1. I follow the instrsuction from http://www.cyberus.ca/~g_will/pyExtenDL.shtml. But this fails: Error: Unresolved external '__Py_DeAlloc' referenced from C:\PYTHON21\ZODB\ZODB\EXTENSIONCLASS\SRC\EXTENSION.OBJ ... (**Note**: this error appears when trying linking with python21.lib which was "coff2omff"ed already. I also compile all the c source code to obj and linking them with python21.lib ) MY QUESTION: Does anyone successfully build ZODB on Win32 for use with ActivePython 2.1? Thanks. Best Regards, Steve From new_name at mit.edu Sat Jun 9 20:03:23 2001 From: new_name at mit.edu (Alex) Date: 09 Jun 2001 20:03:23 -0400 Subject: New guy question References: Message-ID: > However, when I go to the console and enter python alook.py, I get an error > message: > > >>> python alook.py > SyntaxError: invalid syntax Based on the '>>>' prefix It looks like you're entering this into the python interpreter. In that context, to get the same behaviour, you would probably want to do something like "execfile('alook.py')" Try running "python alook.py" from the shell/dos command prompt, instead. It might be helpful to work through a tutorial. The one at www.python.org/doc/tut is pretty good, imo. Alex. From loewis at informatik.hu-berlin.de Tue Jun 12 13:31:49 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 12 Jun 2001 19:31:49 +0200 Subject: 1.5.2, COM, Unicode References: Message-ID: grante at visi.com (Grant Edwards) writes: > I'm pretty sure I got e-mails like that before, and I was > wondering what the COM support library did with them in 1.5.2. > Were all of the Unicode strings in COM objects automagically > converted in to latin-1 encoding? No, the old COM integration library had defined its own custom Unicode type, which is now superceded by the standard Python type. The old Unicode type had a default conversion to MBCS, AFAIK, whereas the Python type's default conversion goes to ASCII. Regards, Martin From jdries at mail.com Tue Jun 12 19:00:07 2001 From: jdries at mail.com (Jan Dries) Date: Wed, 13 Jun 2001 00:00:07 +0100 Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> Message-ID: <3B269EF7.8628786@mail.com> Rainy wrote: > Try writing 1,388,034,093 in binary on a piece of paper > then come back :-). 101,0010,1011,1011,1011,1000,0010,1101-ly y'rs -- Jan From nhodgson at bigpond.net.au Tue Jun 26 22:50:46 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Wed, 27 Jun 2001 02:50:46 GMT Subject: zodb install problem on Windows References: Message-ID: Andy Todd: > Hi all, I'm failing terribly here. I've commented out that section of the > setup.py file for the ZEO module and everything seems to have installed > correctly. But now I am getting an error; > ... > cl.exe /c /nologo /Ox /MD /W3 /GX -IC:\PROGRAMMING\PYTHON21\Include > /Tcsrc/ExtensionClass.c /Fobuild\temp.win32-2.1\Release\ExtensionClass.obj > error: command 'cl.exe' failed: No such file or directory It is failing because it requires a C compiler to build some binary libraries and Microsoft operating systems do not come with a C compiler. If noone else fixes this first and I can find some time I'll try and produce a package that includes binaries for Windows. Neil From guido at python.org Tue Jun 26 20:36:54 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 27 Jun 2001 00:36:54 GMT Subject: Check out O'Reilly's Open Source Convention Highlights Message-ID: I promise this is a one-time ad! Check out the Python track: http://conferences.oreillynet.com/cs/os2001/pub/w/os2001/sessions_python.html and the Python tutorials: http://conferences.oreillynet.com/cs/os2001/pub/10/python_tutorials.html Hope to see you there, --Guido van Rossum (home page: http://www.python.org/~guido/) MEDIA ALERT June 27, 2001 O'REILLY OPEN SOURCE CONVENTION INVITES OPEN DISCUSSIONS Early-Bird Discount Extended through July 2, 2001 "Open Standards let you achieve a level of global acceptance that's impossible for one person promoting a proprietary standard." -Michael Tiemann, CTO, Red Hat Sebastopol, CA--Due to increased www.oreilly.com web traffic, O'Reilly & Associates announced today that the early bird discounted registration for the O'Reilly Open Source Convention and Perl Conference 5 is extended through July 2, 2001. Go to www.conferences.oreilly.com to register for the O'Reilly Open Source Convention and Perl Conference 5, July 23-27, 2001, at the waterfront Sheraton Hotel and Marina in San Diego, California. Register for a press pass at http://conferences.oreillynet.com/cs/os2001/create/e_press Convention Highlights: --This year's Convention offers over 250 sessions in 16 tracks including Perl, Apache, XML, Python, PHP, MySQL, Linux, to name a few. If you're a hard-core system administrator, programmer, or Web developer, this is the place to be. --Don't miss Thursday's keynote. Tim O'Reilly, Craig Mundie and Michael Tiemann squaring off in a debate over open source vs. shared source software. Tim predicts, " It's going to be fabulous to have Craig Mundie and Mike Tiemann going head to head, with a hard hitting panel afterwards and juicy questions from the audience." http://conferences.oreillynet.com/cs/os2001/view/e_sess/1834 --What Would You Ask Craig Mundie? Here's your chance to put your questions to him. Go to: http://oreilly.com/news/mundie_0601.html ---Read Tim O'Reilly's reasons why open source is here to stay. http://conferences.oreilly.com/oscon/tim_letter.html --Preview the O'Reilly XTech 2001 Conference on XML. Conference chair Edd Dumbill checks out the line-up at O'Reilly's XTech 2001 Conference, details aspects of the Full Cutting Edge XML Program, and declares it "the essential meeting for XML developers." http://www.xml.com/pub/a/2001/06/20/xtech2001.html --For a complete list of this year's speakers, see: http://conferences.oreillynet.com/cs/os2001/pub/w/os2001/speakers.html The O'Reilly Open Source Convention and Perl Conference 5 promises to be fun, as well. --Attend a special screening of an open source film--Revolution OS--a documentary that chronicles the open source movement. The filmmaker, J.T.S. Moore, will be on hand for a pre-and post-screening discussion. --Join Chris DiBona of VA Linux and Rob Malda, ("CmdrTaco") of Slashdot, and play the Internet Quiz Show. Will the "The Defending Champions," (TDC) as their name suggests, repeat? Or will one of the new teams rise to glory? "TDC" were the winning team last year and return to battle their former opponents, "The President's Dog," an entirely British team who lost the championship last year to the American team "TDC", due to the cultural bias of the final quiz question. (That question was: President Clinton recently signed a bill that allows for electronic signatures to be as valid as conventional paper signatures. To sign the bill, he used a magnetic card and his personal password. The commander in chief of the armed forces of the United States of America and leader of the free world used a plain five-letter word, all in lower case, and it was the name of his dog. For all twenty points, guess the president's password. Answer: BUDDY). Their well-humored indignation over the question's unfairness is what led to them calling themselves "The President's Dog". For a detailed list of Convention events, go to: http://conferences.oreillynet.com/cs/os2001/pub/w/os2001/events.html For answers to any questions you may have, contact Cammie Noah (707) 829-0515 ext 437 or cammie at oreilly.com # # # O'Reilly is a registered trademark of O'Reilly & Associates, Inc. All other trademarks are property of their respective owners. From bill-bell at bill-bell.hamilton.on.ca Tue Jun 26 11:29:25 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Tue, 26 Jun 2001 11:29:25 -0400 Subject: ActiveX Controls in Python In-Reply-To: <993529234.586.37777.l6@yahoogroups.com> Message-ID: <3B387215.8467.4B9DAB3@localhost> davidw at weblink.com.au (David White) wrote, in part: > I'm really hoping I can do the [hierarchial grid] prototype in > Python, because I don't want to even think about touching Visual > Basic. I ~know~ whatcha mean! What would you think of the following: 1. Use MSVC to create a series of "HTML Control" ActiveX thingys (one item in the series for each time your boss changes his/her mind)--it's relatively easy to play with HTML/JScript. --- The ActiveXWrapper_IE.py code in the wxPython demo says, "The MakeActiveXClass function dynamically builds a new Class on the fly, that has the same signature and semantics as wxWindow." --- 2. So host the ActiveX in Python code written with the aid of wxPython. Overall, make C++ code in the ActiveX as simple as possible and favour development in Python. This topic interests me and I'd value your opinion. Bill Bill Bell, Software Developer From cribeiro at mail.inet.com.br Wed Jun 6 22:55:16 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Wed, 06 Jun 2001 23:55:16 -0300 Subject: priority queue In-Reply-To: References: Message-ID: <5.0.2.1.0.20010606235434.009fe450@mail.inet.com.br> At 00:48 07/06/01 +0000, Courageous wrote: >Use a standard binary heap. It will do absolutely fine in all general >cases. Your other alternative is a fibonacci heap, which is optimized >for insert. I have the binary heap at: > >http://www.sourceforge.net/projects/pythonic > >Checkout the "pythonic" module. The adt submodule is what you >want. It also has a circular dequeue and a specialized python list >which supports O(1) head-push and tail-append. I'm also interested on your binary heap implementation, but I could not get the module at sourceforge. Any problem that you are aware? Carlos Ribeiro From eppstein at ics.uci.edu Sun Jun 17 13:05:13 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Sun, 17 Jun 2001 10:05:13 -0700 Subject: Writing new codecs References: Message-ID: In article , Martin von Loewis wrote: > I think at the minimum, the codec must not be called "utf-7" if it > does not implement RFC 2152/1642. Unfortunately, RFC 2060 does not > give it an encoding name. > > Note that the IANA registry gives "UTF-7" to the encoding described in > RFC 2152, and "UNICODE-1-1-UTF-7" to the one described in RFC 1642. It > doesn't give a name to the encoding of RFC 2060, either. So I think > your patch should use a temporary codec name, until IANA assigns an > official name to it. So call it rfc-2060 ? -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From whats_really_hot at hotmail.com Sat Jun 30 18:22:15 2001 From: whats_really_hot at hotmail.com (whats_really_hot) Date: Sun, 1 Jul 2001 01:22:15 +0300 Subject: any books for python for downloading? Message-ID: <993939668.727430@athnrd02.forthnet.gr> so, are there..........give me a feedback and some help(how about some URL's with books for downloading) for learning Python...... From nospam at nospam.com Fri Jun 22 17:53:17 2001 From: nospam at nospam.com (Bill Rodgers) Date: Fri, 22 Jun 2001 17:53:17 -0400 Subject: Win32GUI Question... Message-ID: <9h0eqp$4c6$1@bob.news.rcn.net> I have an app that occasionally puts a notification dialog on the screen of my PC. I want to create a program that detects the presence of this new dialog box,then reads the dialog's contents and does some other things with the data. Is there any way to have my Python program detect and examine windows created by another program? Thanks, Bill From BPettersen at NAREX.com Mon Jun 11 14:09:43 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Mon, 11 Jun 2001 12:09:43 -0600 Subject: Python and SML Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D44B@admin56.narex.com> > From: Andrew Koenig [mailto:ark at research.att.com] > > Daniel> I am new to Python and was struck by the similarity to > Daniel> a language I learned in a programming languages course, > Daniel> SML/NJ. It, like Python, is an interpreted language... > > SML/NJ interpreted? How's that again? Both interpreted and compiled (even has an interactive shell :-) -- bjorn From whisper at oz.nospamnet Sun Jun 3 16:45:39 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 3 Jun 2001 20:45:39 GMT Subject: (WIBNI) Grail, the Python web browser. References: Message-ID: <9fe7lj$qf5$2@216.39.170.247> In article , ocschwar at mit.edu says... > I see that the Sourceforge project Grail > comes with the disclaimer "we don't have time > to work on it anymore, so knock yourselves out, guys) > (basically). > > But it seems like a nice piece of work. > Would any Pythonist be interested in restarting the > project? > > -- > Omri Schwarz --- > Timeless wisdom of biomedical engineering: "Noise is principally > due to the presence of the patient." -- R.F. Farr > > It looks like Grail @ sourceforge.net was a victim of the recent sourceforge trashing. The sourceforge page now claims that this project has not released any files, but AFAIK it used to offer up at least a couple of different versions. The CVS repository seems to be intact. I wonder if the HTML widget now in WxPython, which inlcudes some tables etc. wouldn't be a better place to start? Dave LeBlanc From junkster at rochester.rr.com Wed Jun 6 16:41:04 2001 From: junkster at rochester.rr.com (Benjamin Schollnick) Date: Wed, 06 Jun 2001 20:41:04 GMT Subject: Trouble with Parsing XML Message-ID: Folks, I'm running into a slight problem here with a XML reply from a semi-WEBDAV server....(A Docushare v2.1 server) This is using Python v2.0..... ---------------- test_data = """ http://xww.psg-techservices.world.xerox.com/docushare/Collection-22 TSA - Material in Transit (Temporary Files) Benjamin Schollnickadmin """ #from xml.dom.minidom import parse, parseString #dom = parseString (test_data) #print dom.getElementsByTagName ("parents") #print dom.getElementsByTagName ("handle") import xml.parsers.expat def start_element(name, attrs): print "Start :",name, "\t\tattrs: ",attrs def end_element(name): #print "End :",name pass def char_data (data): #print "Character : ", repr(data) pass parser = xml.parsers.expat.ParserCreate() parser.EndElementHandler = end_element parser.StartElementHandler = start_element print "XML.Parsers.Expat \n------------------------------------------" parser.Parse (test_data) print "xml.sax \n------------------------------------------" import xml.sax dparser2 = xml.sax.make_parser() ----- Here's the XML code that I was trying to use.... And I decided to try EXPAT... EXPAT does give me a few of the objects data back, but not all of them. Can anyone verify that EXPAT is operating properly? I'm assuming this is a Programmer (my) error, but I'm not familiar enough with EXPAT to decide on what is the problem. - Benjamin From schaffer at optonline.net Thu Jun 14 08:26:12 2001 From: schaffer at optonline.net (Les Schaffer) Date: Thu, 14 Jun 2001 12:26:12 GMT Subject: weird behavior wrapping global functions into classes Message-ID: <0cahit44sql68p8pd2qgt59f600neha687@4ax.com> been losing sleep over this one... why does the following code successfully wrap the built-in open function into a class, but shelve's open method gets incorrectly (??) taken as an instance method? notice that everything works fine for the Flat version, built-in open is called correctly, but the __init__ fails for the Shelf version, since it thinks self.dbopen is now an instance method. ==== my output: === up here, open = up here, shelf_open = in NumFlat class definition, dbopen = in NumShelf class definition, dbopen = but over here self.dbopen = but over here self.dbopen = Traceback (most recent call last): ... === huh???? === weird: self.dbopen knows its the built-in open for the NumFlat case, but gets screwed up in the NumShelf case. what terrible thing have i done? thanks les schaffer p.s. purpose of code was to fool around to see differences in disk space for pickling numeric arrays vs. writing them out flat. ============ from Numeric import arange, Float32, array2string, cos from shelve import open as shelf_open print 'up here, open = ', open # all ok print 'up here, shelf_open = ', shelf_open # all ok class NumStorage: def __init__(self): tup = (self.DB,) if self.mode: tup += (self.mode,) print 'but over here self.dbopen = ', self.dbopen # huh??? self.db = apply(self.dbopen, tup) def close(self): self.db.close() class NumFlat(NumStorage): mode = 'w' DB = 'flat.txt' #db = open(DB, mode) dbopen=open print 'in NumFlat class definition, dbopen = ', dbopen # ok def store(self, key, value): self.db.write(array2string(value, precision=8)) class NumShelf(NumStorage): mode = None DB = 'test.dbm' #db= shelf_open(DB) dbopen=shelf_open print 'in NumShelf class definition, dbopen = ', dbopen # ok def store(self, key, value): self.db[key] = value ## space test ## nf = NumFlat() ns = NumShelf() x = arange(0,1.0,.01, Float32) x = cos(x) for i in range(10): key = '%d'%i ns.store(key, x) nf.store( key,x ) ns.close() nf.close() From db3l at fitlinxx.com Fri Jun 15 14:35:10 2001 From: db3l at fitlinxx.com (David Bolen) Date: 15 Jun 2001 14:35:10 -0400 Subject: WxPython questions. References: Message-ID: Omri Schwarz writes: > So my question is, is there a more interactive way to > play around with wxPython? Because of the need to have at least a basic event loop even to get the interface to do anything responsive, and the need to instantiate at least a few classes just to get anything more than the frame operational, I've found it simpler to just have one editor window open where I'm working on the code, and a console window where I run it from. Even with restarts after making changes, it's a very quick cycle. I have also (for more complicated stuff - say where you have a variety of plugins) written small driver modules that let me load the single plugin that I'm working on thus bypassing other aspects of the application. Then I just restart that driver during development. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From dsh8290 at rit.edu Wed Jun 27 13:13:46 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 27 Jun 2001 13:13:46 -0400 Subject: PEP 260: simplify xrange() In-Reply-To: <20010626191832.B16690@harmony.cs.rit.edu>; from dsh8290@rit.edu on Tue, Jun 26, 2001 at 07:18:33PM -0400 References: <20010626153909.A16590@harmony.cs.rit.edu> <"from rnd"@onego.ru> <20010626191832.B16690@harmony.cs.rit.edu> Message-ID: <20010627131345.B17001@harmony.cs.rit.edu> On Tue, Jun 26, 2001 at 07:18:33PM -0400, D-Man wrote: | | def odd_in_range( n , lower , upper ) : | return 1 <= n <= 101 and n % 2 == 1 Obviously this is a cut-n-paste typo. return lower <= n <= upper and n % 2 == 1 would be better. -D From dnew at san.rr.com Mon Jun 4 12:35:49 2001 From: dnew at san.rr.com (Darren New) Date: Mon, 04 Jun 2001 16:35:49 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> <3B1A82DD.C4D78472@san.rr.com> <9fe2g302841@enews2.newsguy.com> <3B1AE07F.CEDA4A3A@san.rr.com> <9fflo812q4r@enews2.newsguy.com> Message-ID: <3B1BB8E5.D818738A@san.rr.com> Alex Martelli wrote: > Even in a finitistic definition of algorithm, there may still be > parameters needed to describe it completely. Right. That would be the "seed" I was talking abuot. So? > > > > > I still haven't heard your definition of > > > > > 'perfect' randomness, for example. > > > > > > > > Generally, this is something along the lines of: > > > > Given all available information about the mechanism used to generate > the > > > > > > "available" seems to play a rather crucial role here, then. > > > > No. "available" means "possible to be obtained in any way." What you > > So that the randomness of an existing system can suddenly > change if somebody dies, for example? Because, e.g., part > of the information about the system was only "available" by > asking him (he had memorized it) -- with that information, > in this thought-experiment, things were predictable -- now > the designer dies, the information is not available any more, > and it's not predictable anymore thus becomes 'random'? No. Because it was possible for you to ask the designer before he died, which would be "a way". Or you could take the system apart and measure it to reverse engineer it. > I would rather not use a definition of "perfect" that requires > accounting for such factors -- considering human beings as > parts of the system, knowing if they ever wrote somewhere > down that information (it might still be 'obtained in some > way' if I could root through their papers and maybe if I was > able to decipher some private code they used -- or maybe > not) or communicated it to someone else (maybe to their > priest during confession?)... seems a rather shifty base for > a mathematical definition. That's because you're making up strawmen. > Why don't we follow De Finetti's lead? P(x) does not 'exist' > per se, it's just a shorthand for P(x|y) where y is a 'mindset', > a sum total of information about the word, that is being > implicitly assumed. All probabilities are 'subjective' in the > specific sense of depending on that y -- there is no 'perfect > reference y' (God's all-knowing mind) that needs to be taken > as an assumption -- as long as we fix y (ideally, explicitly) > we can do all of our probability computations equally well. > > Now if you believe there is an ideal y such that all P(x|y) > are 0 or 1 for that y, or if you believe it does not exist -- > whether God plays dice or not:-) -- becomes irrelevant > enough so we can do maths without first having to solve > theological questions as a prerequisite. Isn't randomness > (or "perfect" randomness) akin to probability in this? Or > IS it just a theological issue, so that any hope of tackling > it apart from theology is doomed? No. That would be something else. Also, I'm not sure where you keep coming up with the term "perfect randomness". > > > That would only leave the arbitrarily long sequence of generated > > > bits and no other info? Fine, then: > > > > > > I don't think Chaitin's Omega meets this definition, since it is by > > > > definition a single number than anyone can calculate equally well. > > It's one number PER each Universal Turing Machine, I believe. I > do not know if from the first N bits of Omega you get enough > information to reconstruct all parameters of the UTM in question > so as to be able to compute the N+1-th bit, but I believe that > part of the point is that you *don't*. > > > > But from Omega's first N bits, you get no hint at all that lets > > > you predict its N+1-th bit "with > 50% accuracy". > > > > How did you get the first N bits? If you can calculate them, so can I. > > Say I have an idealized black box that was made for me by a > demented but genial Transylvanian dwarf, who, unfortunately, > has since deceased. I do know with certainty (he was a VERY > trustworthy demented but genial Transylvanian dwarf) that > what the box does each time I press the button is compute > the next bit of Omega for some UTM -- alas, I don't know WHAT > Universal Turing Machine encoding it uses, and the box with > the "algorithm" (or effective procedure, whatever) is rigged so > that any attempt to examine its innards will destroy it (I think > my deceased friend didn't believe humanity was ready to learn > how he made the infinite-precision registers that are such a > crucial part of the machine's operation, and, you know, he may > have been right after all). > > So, "all available information" is: this computes Omega for SOME > UTM -- sadly, we don't know WHAT UTM that is. Sorry. That's not "all available information". Your assumption that it is impossible to know what the box is doing is turning it into an opaque physical instantiation of a random number generator, not an algorithm. Your opaque box is not a random number generator, not a deterministic computer. You may assert all you want that it's running a deterministic algorithm, but you have zero proof of that. "Trust the word of this dead guy" is not a mathematical argument. Making up an example like "I have enough proof to know that X is true, but there's no way you can get the same amount of evidence" is making up a straw man. If you are going to postulate such a black box and call it an algorithm, you would have to *prove* for me in a mathematical sense that it's generating bits from an actual Omega calculation. There's no room in mathematics to say "Trust me, this really does work, and given that I can prove X." Instead, you have to say "Assume X, now X implies Y." But you can't prove anything about *X* that way. You're saying "assume I have this box that calculates Omega but nobody can look at it. Therefore, you're wrong because you can't predict its output." You haven't proven anything about the Omega box, nor my ability to predict Omega in general. You've only proven things *assuming* you have such a box. But since you *don't* have such a box, you've proven nothing. Once you *do* have such a box, it's no longer an algorithm, but a physical RNG. > There, you have > all _available_ information. Nope. First you'd have to prove mathematically that it's impossible for me to examine the box. To do that, you'd have to actually have a box, or tell me precisely how to construct such a thing. > Now (assuming you can't come and > steal my treasured little black box -- it's well-guarded, I assure > you... you don't want to brave the killer rabbit, for example, and > that's just the start of it!), how are you going to calculate? I'll > send you the first N bits, for any N, and you just need to give > me the N+1-th one. Again, "assume you can't come and steal my black box". Fine. "Assume I have a magic ray built by the drawf's cousin that makes an exact duplicate of any device." See how silly such an argument is? > Note that 'all available info' does include the algorithm, net of > some numeric parameters. Well, if you're talking about UTMs, then "algorithm" must include all the numeric parameters. > > > So, if the > > > definition does not include the first condition, from the bits > > > only you're not going to get any farther than from N tosses > > > of an idealized coin. > > > > Sure. *I* can write an algorithm to calculate the bits of Omega. Then I > > For what UTM encoding, pray? The same one you're using. > > run my algorithm, see that the first N bits of its output matches the > > first N bits of your sequence, and predict with very high probability > > what the next bit is, right? > > I don't believe so -- I don't think those N bits let you reconstruct > the UTM encoding being used. I hope I'll be more positive about > it once I _have_ received and studied 'Exploring Randomness'. > > Until then, I can only hypothesize -- IF some amount N of bits > was sufficient to let you reconstruct the UTM parameters, and > therefore calculate the N+1-th bit, THEN I would agree that the > Omega's randomness was bounded by N (<=N). IF no amount > N of bits has this property, would you agree in turn as to the > 'perfection' of the randomness (at least once the dwarf has > died, or has irretrievably forgotten how the hep he DID build > the darned algorithmic black box in the first place)? No. First you have to prove he didn't build two. > > If you calculate the first 100,000 bits of > > Omega and give it to me, and you don't tell me that it's the first > > 100,000 bits of Omega, and I think to try calculating the first 100,000 > > bits of Omega and they match, then I guess the 100,001'st bit of Omega, > > then I have a >50% chance of getting the next bit right. > > Again the UTM parameters loom large. At least until some ISO > subcommittee comes up with a standardized Universal Turing > Machine (or maybe the IEEE could do it, as for floating point?-)... Using the same UTM as you do, of course. Or I could just search thru all possible UTMs until I found one that matched your output. > > If, on the other hand, you run a random number generator based on > > quantum radioactive decay, or you flip a coin 100,000 times, and it just > > *happens* to match the first 100,000 bits of Omega, and I notice that, > > and I guess the 100,001'st bit of Omega, then I have still only a 50% > > probability of being right. > > I think the situation, looking at the bits only, would be the same > in both cases. You're mistaken. > Now I'm starting to wonder if a UTM encoding (or > an infinite set of possible such encodings, actually) could be found > to "account" for ANY such given first-100,000-bits. Maybe not -- > perhaps I cannot encode an UTM so that random self-delimiting > programs for it have _any_ prespecified probability of halting > (or at least to N bits' approximation). I think part of the problem is that Omega is unknowable, not just "random". That is, you can't build a machine to calculate what its value is. Since it's construction is based on whether or not a program halts, I can't imagine how you build an algorithm to figure out what its bits are. > > This is why some people say that any given finite string cannot be > > considered random or non-random by itself, without knowing how it's > > generated. > > The 'infinity' aspects with which 'perfect randomness' seems to be > imbued might surely account for that unwillingness to bestow the > now-hallowed monicker 'random' onto any mere finite structure, I > guess. I'm not sure where 'perfect randomness' comes from in that statement. > I still think it's very useful to study the randomness of such > finite sets, Sure. Using a different meaning for the word "random", tho. > and apparently so do Chaitin and all other scholars in > that field. Again, using a different meaning for the term "random". > However it was generated, that bitstring now has its > own intrinsic properties. A man in the street might well call it > 'pretty well-ordered' or 'rather random' -- and why should the word > 'random' be pre-empted, so it has no meaning at all in this context, > when a useful technical sense, that happens to match pretty well > the way the man in the street would use the word, can be applied > instead? Because we already have other words mean the same thing, like "uncompressible". Besides, you're still arguing a different point than I am. The original JVN quote was something equivalent to "deterministic algorithms don't produce randomness". If you want to define "randomness" as "the uneducated guy walking down the street doesn't see a pattern" then obviously JVN is incorrect and would know it. If you want to know what he meant, pick a meaning for "randomness" that makes the quote make sense, assuming JVN has a good idea of how algorithms work: i.e., use the meaning of random that is "unpredictable" rather than "uncompressible" or "uncalculable." -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. This is top-quality raw fish, the Rolls-Rice of Sushi! From tanzer at swing.co.at Mon Jun 25 02:52:29 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Mon, 25 Jun 2001 08:52:29 +0200 Subject: Is this a true statement? In-Reply-To: Your message of "Sun, 24 Jun 2001 13:29:24 EDT." <20010624132924.D13478@harmony.cs.rit.edu> Message-ID: D-Man wrote: > When I read the original question I got the impression that "write a > device driver in Python" meant "A person sits down at a console with a > text editor, writes some Python code that implements the device's spec > in terms of the driver API specified by the kernel". David Ullrich is > taking "write a device driver in Python" to mean "output the bytes > that comprised the finished driver to a file that the kernel can load > and execute". In the former meaning, no a device driver can't be > written in Python. In the latter, then yes, python has the ability to > write binary data to a file. It also goes, then, to say that one > could write the driver using only a hex editor (or the "front panel", > for Steve :-)). > > I think that most people thought the first interpretation of the > original question was obivous and thus did a poor job of answering > David's questions. At the pratical level, (as David also says) a > device driver can't be written in Python. At a more theoretical > level, David is correct, almost. A device driver isn't a file, but a > sequence of bytes in memory in the kernel's address space :-). What about this? A python application generates C code which is compiled and linked with application code supplied by the programmer? In many cases, writing python code generating C code is much faster than implementing the C code by hand. In the particular case I'm thinking about, the generated code is specifically adapted to the properties of the user's application -- writing the C code by hand simply isn't an option (the application domain is distributed hard real-time systems using embedded CPUs, e.g., little memory footprint, low computing power). But to return to the original question: as several people already pointed out, all programming languages are in principle equivalent. Different languages don't differ in what problems you can tackle with them but in how long it takes to do so and what the resulting code base will afford you. IMHO, the question really should be: how do different languages compare for solving a specific problem given a limited amount of resources (programmers, time, memory, CPU cycles, ...)? -- Christian Tanzer tanzer at swing.co.at Glasauergasse 32 Tel: +43 1 876 62 36 A-1130 Vienna, Austria Fax: +43 1 877 66 92 From itamar at zoteca.com Mon Jun 4 12:00:03 2001 From: itamar at zoteca.com (Itamar Shtull-Trauring) Date: Mon, 04 Jun 2001 19:00:03 +0300 Subject: I NEED to TEACH you something, QUICK! References: Message-ID: <3B1BB083.688D723D@zoteca.com> Rainer Deyke wrote: > Did you actually write all that, or was it algorithmically generated? Really... can't you recognize a simple Usenet posting on the subject of "'Usenet discussions about war' as a metaphor for refactoring" when you see one? -- itamar(at)shtull-trauring.org http://itamarst.org From ullrich at math.okstate.edu Sun Jun 24 12:33:59 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 24 Jun 2001 16:33:59 GMT Subject: Is this a true statement? (fwd) References: Message-ID: <3b36149c.11483184@nntp.sprynet.com> On Sun, 24 Jun 2001 10:14:31 -0400 (EDT), "Steven D. Majewski" wrote: > >I concede, David! >Your logic is unassailable >and your point is significant. The "point" about device drivers is certainly not "significant" in any way I can imagine. This _did_ start with honest _questions_, which actually nobody's answered. For all I know "write a device driver" _could_ mean something other than "write a certain sequence of bytes to a file". When people start talking about the difference between writing a file and writing a program I begin to wonder whether in fact there _is_ something going on in the terminology that I'm not aware of. (Then when I see the explanation of the "distinction" I say no, I guess not.) But it does seem related to that other point. The reasons people have given explaining why you cannot write a device driver in Python do sound a lot like the reasons people give to explain why you cannot write a Windows program in Pascal. And the fact that _that_ statement is false has significance to lots of people. >"Uncle" I cry! I'll just repeat myself a few more times and quit then. haha. >-- Steve Majewski > > > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From aleaxit at yahoo.com Fri Jun 1 18:55:15 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 2 Jun 2001 00:55:15 +0200 Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> Message-ID: <9f96f501mkc@enews1.newsguy.com> "David C. Ullrich" wrote in message news:3b17ed86.19508127 at nntp.sprynet.com... ... > >> A physical RNG can have the property that one cannot make > >> any prediction about the value of the next bit even given > >> _complete_ information about how the numbers are being > > > >"From impossibilia sequitur quodlibet". *IF* you could > >have complete information, *THEN* you could predict all > >you want. Problem is, you CANNOT have complete info due > >to that Heisenberg fellow, therefore you cannot predict > >(precisely). > > Huh? You cannot have complete information about a > _physical_ RNG, which is why you _can_ get "really > random" numbers from a physical RNG. But you certainly The quote above contains the premise "even given _complete_ information". Now you say "you cannot have complete information". Well, if this latter statement is true, then the premise is always false, and from a false premise any conclusion follows, as Pseudo-Scotus proved and I recalled in his very words -- except I used 'from' instead of 'ab' as a hint. So, to recap: the post I was replying to states that given [what you now state is] an impossibility, yet a conclusion [predicibility of next bit] does NOT follow. Pseudo-Scotus says that given an impossibility ANYTHING follows (you can prove any theorem and its contrary if your set of axioms include a contradiction). > can have complete information regarding the state > of an _arithmetic_ _algorithm_. I assume that is your definition of "an algorithm"? That its state be finite? While you are absolutely certain that NO physical system can be described in finite terms, EVER? Wow, last time I met anybody so sure of things, it was a priest:-). > > From what I know of Chaitin's life work, > >it started with just the idea of defining randomness in > >terms of minimal amount of information (in bits) you need > >for prediction. If YOUR definition of 'randomness' is > >something that needs INFINITE number of bits to predict, > >go ahead and have fun, but you're unlikely to get some > >constructive results out of it. > > It seems fairly likely that there's a point here, but > I don't see what it is. Given an arithmetic algorithm > it does _not_ take an infinite number of bits to do > any predicting. Agreed (given a definition of algorithm that requires it to be finite, this is a tautology). So, the amount of randomness (which is a finite amount of randomness) is described as the number of bits (a finite one) needed for said prediction. (Over-simplifying a bit here:-). If you think interesting and fruitful mathematical theories can be constructed around measures of randomness which only consider infinities, go right ahead and don't let the mathematicians scoffing at you put you off -- if Feynman could simplify away infinities and come up with stuff, why not you, after all? Meanwhile, some of us working with finite machines, communication channels of finite capacity, and so on, are very interested in the currently accepted, operational definitions of randomness in finite terms given by Chaitin, Solovay, and so on. It's about mathematics rather than physics, and rather 'solid' maths in a sense -- it seems Chaitin's books are chock full of working Lisp code that exemplifies what he's saying. > >A physical system that is macroscopic enough to escape > >Heisenbergian conumdrums > > There is no such system. In this case, no physical computer is predictable, and all we study about algorithms are abstractions -- since a computer system IS a physical system, then ALL bits coming out from it must be random in your sense of the word. Defining things in terms of infinities, absolutes and utter unshakable certainties does tend to have this risk -- discussion is trivialized rather than concrete and fruitful. But, hey, if that's what floats your boat... If, on the other hand, you maintain that the output from a physical system CAN be predictable if that system is a computer running your program, then what makes you SO certain that NO other physical systems can also be predictable in the same sense?-) > > could also be describable in > >a finite number of bits, in terms of enabling somebody > >to predict the 'next outcome'. That was, if I'm not > >mistaken, Laplace's take on probability (and not his > >only), all the way up to Einstein's in this century -- > >that it's all about hidden variables, information that > >we do not happen to have, rather than information that > >intrinsically CANNOT be had. > > I continue to miss your point. See, Einstein was > wrong about quantum mechanics (or so the people best > qualified to know believe). I forget whose theorem > it is (Von Neumann's, I think maybe!) that you > _cannot_ describe "classical quantum mechanics" in > terms of hidden variables. A couple centuries ago all scientists were certain of one thing, now they're all becoming certain of another, and I won't be around in a couple more centuries to laugh at the likely-different certainties they'll have then. Meanwhile, mathematics is far from exempt from paradigm shifts, of course, but those never do 'contradict' the previous certainties (META-maths is different that way of course -- cfr. Russel's well known demolition of Frege's lifework:-), rather extend and generalize on them. I'm currently more interested in what a mathematician like Chaitin has to say about randomness, particularly of the finite kind which I can handle in a computer (if and only if it's a physically predictable system:-) than in what physicists or other philosophers have to say about randomness, particularly if that requires dabbling with infinities. Being an engineer myself, I do place a prize on USEFUL theories, after all. > >Measuring randomness in terms of amount of information > >seems like it works nicely. > > I'm certain it does. I don't see how saying that > says anything about VN being wrong with his comment > about how arithmetic RNG's cannot be perfect. If by "perfect" randomness VN meant an infinite amount thereof (by Chaitin measure), he might have said that (were it not for the little detail that Chaitin was probably not even in primary school back then, I guess). The quote talks generically about "random", without using the word "perfect" you now insert, and without any specification of infiniteness as a prerequisite, and, as such and without the needed qualifications, it is not correct. _with_ the qualifications you want to place, it seems to become tautological ("I define X as being something that requires infinities: no finite system can reach X, it can only approach it") and therefore sterile and uninteresting, unless there are hidden layers of exoteric meaning nesting in it, I guess. Alex From jurberg at my-deja.com Thu Jun 14 11:55:38 2001 From: jurberg at my-deja.com (John Urberg) Date: 14 Jun 2001 08:55:38 -0700 Subject: Need Help building COM server in python References: <844df35f.0106140116.5f706fcf@posting.google.com> Message-ID: <49624b0b.0106140755.c303017@posting.google.com> michiel at htcs.nl (michiel) wrote: > CODE CLASS: > > class HelloWorld: > _reg_clsid_ = "{D4FF29AD-BCDE-4FE2-9896-892D2EBB5180}" > _reg_desc_ = "Python Test COM Server" > _reg_progid_ = "Python.TestServer" > > _public_methods_ = ['Hello'] > _public_attrs_ = ['softspace', 'noCalls'] > _readonly_attrs_ = ['noCalls'] > > def __init__(self): > self.softspace = 1 > self.noCalls = 0 > def Hello(self, who): > self.noCalls = self.noCalls + 1 > return "Hello" + " " * self.softspace + str(who) > > if __name__=='__main__': > import win32com.server.register > print "Registering COM server..." > win32com.server.register.UseCommandLine(HelloWorld) [...] > PROBLEM: > > Registration of the object works. > Creation of the object works (x=createobject("python.object")), > but then there are no methodes I can access: "there is no such method" > > Can someone help me out or send me an example of a useable COM server > object written in python? Try using: x = CreateObject("Python.TestServer"). The value you put in_reg_progid_ is what clients should use to create the object. Regards, John Urberg From bill-bell at bill-bell.hamilton.on.ca Fri Jun 22 07:16:32 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Fri, 22 Jun 2001 07:16:32 -0400 Subject: Python COM: Unable to create server-side object. In-Reply-To: <3B3291FD.6060301@ActiveState.com> Message-ID: <3B32F0D0.14091.229E364@localhost> Your e-mail includes plot, climax and denouement ... . Argh, I'm not observant enough, and too new to Python COM, to have noticed that. On behalf of all in similar circumstances-- THANKS!! Fantastic. Bill On 22 Jun 2001, at 10:31, Mark Hammond wrote: > Bill Bell wrote: > > From the end of your mail: > > > File "c:\python21\win32com\server\policy.py", line 448, in _wrap_ > > raise error, "Object does not support DesignatedWrapPolicy" > > win32com.server.policy error: Object does not support > DesignatedWrapPolicy > > > This means that _public_methods_ does not exist. (hrm - so why > doesn't the error actually say that you ask! It should! It will!) > > >> class Short: > >> _reg_clsid_ = "{74471ADF-9453-4135-87E6-22E1B9499B0D}" > >> _reg_progid_ = "Python.Short" > >> _reg_desc_ = "PythonCOM test" > >> _public_methods = ["isShort"] > > > Trailing underscore missing! From syver at NOSPAMcyberwatcher.com Fri Jun 29 04:08:58 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Fri, 29 Jun 2001 10:08:58 +0200 Subject: SocketServer crash on my machine References: <9hdpu1$o1h$1@troll.powertech.no> <90CDDC8DCgmcmhypernetcom@199.171.54.155> <3b3c1606.28350415@news.supernews.com> Message-ID: Thanks Gordon and Xtian, thanks for good replies, I'll try your suggestions and learn some more about sockets in the process. wrote in message news:3b3c1606.28350415 at news.supernews.com... > On 28 Jun 2001 00:42:06 GMT, gmcm at hypernet.com (Gordon McMillan) > HTH, > Xtian From tim.one at home.com Thu Jun 14 01:39:22 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 14 Jun 2001 01:39:22 -0400 Subject: Garbage collection questions In-Reply-To: <3B2643A9.B5C79E96@scripps.edu> Message-ID: [Sophie Coon] > I have problems to understand how the garbage collector works. > If I understood well the documentation a collectable objects is an > unreachable objects that will be garbage collected. So if I do a > gc.collect() and it returns 280 but the gc.garbage list is empty that > means that the memory taken by these 280 objects has been freed ? Yes. However, there's rarely a good reason to call gc.collect() manually -- collection happens automatically. Note that gc will not collect trash cycles containing objects with destructors (the intended order of destruction is impossible to guess then), and *those* are the (only) things that end up in gc.garbage (if any such exist). From piet at cs.uu.nl Thu Jun 28 06:41:44 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 28 Jun 2001 12:41:44 +0200 Subject: exec "global" problem References: Message-ID: >>>>> Michaell Taylor (MT) writes: MT> I have seen lots of discussion of the problem of executing the following code: MT> global sub MT> sub=['sub1', 'sub2', ...'sub600'] MT> def make(): MT> for X in range(1,600): MT> exec "global sub%s" % (X) MT> exec "sub%s={}" % (X) MT> other stuff If you just want to create these 600 variables do the following: def make(): for X in range(1,600): exec "global sub%s;sub%s={}" % (X,X) -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From matt at mondoinfo.com Fri Jun 29 21:09:21 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Sat, 30 Jun 2001 01:09:21 GMT Subject: Tkinter problem in sizing a frame References: Message-ID: On Fri, 29 Jun 2001 20:58:58 -0400, Joe Potter wrote: >Thanks for the help --- that was the ticket. I did read the fine >manual, but I missed that part! Joe, You're welcome! Speaking of fine manuals, let me recommend two things that you may not have come across yet. Fredrik Lundh's excellent An Introduction to Tkinter is at: http://www.pythonware.com/library/tkinter/introduction/index.htm It's extremely helpful. I generally have a local copy open when I'm doing Tkinter programming. Pmw is also extremely useful. It's a set of compound widgets that would be a big nuisance to build yourself. It's at: http://pmw.sourceforge.net/ Between the two of them, they improve the life of a Tkinter coder hugely. Regards, Matt From pieter at equinox.co.za Fri Jun 8 12:27:58 2001 From: pieter at equinox.co.za (Pieter Nagel) Date: Fri, 8 Jun 2001 18:27:58 +0200 Subject: Just a small quine In-Reply-To: <3b1fa942.11180453@news.t-online.de> References: <3b1fa942.11180453@news.t-online.de> Message-ID: Small? Here's a one-line quine: s="s=%c%s%c; print s%%(34,s,34)"; print s%(34,s,34) But I have to admit it only works in ASCII. -- ,_ /_) /| / / i e t e r / |/ a g e l From clpy at snakefarm.org Sat Jun 16 04:28:19 2001 From: clpy at snakefarm.org (Carsten Gaebler) Date: Sat, 16 Jun 2001 10:28:19 +0200 Subject: statically linking the entire runtime (HPUX Python2.1) References: Message-ID: <3B2B18A3.E7CE525C@snakefarm.org> Andrew MacIntyre wrote: > On Fri, 15 Jun 2001, Carsten Gaebler wrote: > > > I noticed that you can't build the curses module statically. The linker > > then complains about duplicate definitions of 'tputs' in libncurses and > > libtermcap. Is there a way to get around this? > > Do you really need to link in libtermcap?? I had been under the > impression that libncurses contained all necessary functionality. You're right, the curses module does not need libtermcap. The problem actually was that I put the following into Modules/Setup: readline readline.c /usr/lib/libreadline.a /usr/lib/libtermcap.a _curses _cursesmodule.c /usr/lib/libncurses.a So I had a conflicting libtermcap from the readline module which does not need libtermcap either. After deleting that and replacing LIBS= -lpthread -ldl -lutil LIBM= -lm by LIBS= /usr/lib/libpthread.a /usr/lib/libdl.a /usr/lib/libutil.a LIBM= /usr/lib/libm.a in the Makefile, I now have a 5.3 megs python interpreter that depends on no more than ld.so and libc.so. :-) Well, you could probably also say: LIBC=/usr/lib/libc.a but that would be like Monster Truck Madness ... ;-) cg. From nospam at newsranger.com Wed Jun 27 01:40:41 2001 From: nospam at newsranger.com (Levente Sandor) Date: Wed, 27 Jun 2001 05:40:41 GMT Subject: test - please ignore Message-ID: test From geoff at homegain.com Fri Jun 1 19:35:03 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Fri, 1 Jun 2001 16:35:03 -0700 Subject: Why isn't Python king of the hill? Message-ID: <393D961EA4FCD311B03F00D0B746D65803275E5B@HQSXCH01> Martijn writes: > So there's fixed-point, decimal floating-point and rational > arithmetic.. > And plain-old-confusing floats. :) > > They all involve numbers with points in them.. and when you do math > with them, the answers may be different. That's about the extent > of my knowledge. Here's a five minute explanation, and maybe I can dig up a link to a quick tutorial on FP in general. (Ok, maybe it's more like a fifteen-minute explanation. Somebody stop me!) Someone who knows better ought to correct me if I'm talking out my butt. ===== Floating Point systems ===== FP numbers are stored as a mantissa times an exponent: 1.22 * (2 ** 15). Let's look at a base-10 FP system real quick: 1.22 * (10 ** 4) = 12200 We are using 3 digits in the mantissa and 4 in the exponent. If you want to express 1.2 or .012 in this system, no problem. However, if you want to express 1.0002 or 100001, you have a problem. You can't come up with a mantissa that accurately represents that. So you pick a good representation that's close to what you're trying to describe. You get three "zones" of inaccuracy in an FP system. The first is the one you'd expect, at the outside edge of your number system. There's a point at which your exponents can't get any bigger, so you can't get any more positive or any more negative. This is usually represented as an overflow error. In our sample number system, trying to represent 10 million would cause an overflow error, because you really need a 2 digit exponent for that. You also get a zone "between" numbers, where you can't get enough precision in your mantissa to express a certain value. We've seen this already, with 1.0002 or 100001. Generally the solution is to round off, so you get 1.00 * (10 ** 1) = 1.0 and 1.00 * (10 ** 5) = 100000. Making sense so far, right? The other place you get a problem is in fractions close to zero. There's a "hole at zero", where anything smaller than 1.0 times your smallest negative exponent falls into the "hole at zero". This is generally a larger range of values than the range of possible values between two mantissa values. ===== Decimal FP vs. Binary FP ===== In a decimal FP system, your 'hole at zero' and the precision you're working at are values that seem to correspond with the standard base-10 arithmetic you learned in school. You can look at the number of digits in your mantissa and predict where rounding will occur. That rounding will make the same kind of sense it would if you were working with a currency system, or the metric system, or whatever. If the next digit out from your precision is 5 or more, you round up, otherwise round down. Most computers use a binary FP system, though. That means that things that divide nicely by two are expressed quite naturally. On the other hand, values that do not divide nicely by two need to be approximated. The big problem with binary FP is that most people (myself included) don't know when to expect approximation rather than an exact result. Without doing the actual translation math, it's hard to know whether the simple decimal value you're looking at will turn into something big and burly when translated to binary. For example, .1 is an infinitely-recurring binary fraction. If you've got python on hand, type .1 at the prompt, and see what I mean. :) (I note that my version of 1.5.2 doesn't display the problem -- it does some rounding under the covers. I'm not sure why, or how.) ===== Fixed-Point ===== As I understand it, fixed-point arithmetic scales the fractions into integers, and keeps track of the scaling. An example might be that you would represent .12 as 12 with a scaling factor of 10 ** -2. This differs from FP in that the mantissa is always an integer. When you do fixed-point arithmetic, you convert both numbers to an identical scale, then perform integer math on them, then apply scaling to the result. It's accurate in a decimal way, but it doesn't do so well when the numbers have vastly different scales -- you might get overflows with your integer mantissas. I need to be reliably decimal-based for financial transactions, which are all likely to have an identical scale. Fixed point will work fine for me, even though it's not as efficient as a decimal-based floating-point would be. ===== Unbounded rationals ===== Unbounded rationals would basically give the language the power to express any rational number accurately. I confess that I'm not sure how it would go about doing that exactly. I THINK it would do so by maintaining an internal representation of the operation that gives rise to an infinitely-repeating decimal, and use that expression in conjunction with known mathematical properties to join in expressions with other values. This is pretty complicated to do, and, according to several people, has some real problems when common repeating decimals get into your calculations -- like .333 for instance. Your performance is highly variable depending on how hard it is to keep track of the numbers you're using. Ok, so that's more of a tutorial than I intended to provide, but I guess I'm in a wordy mood today. If you're still on sloppy ground, try this: http://www.cs.utah.edu/~zachary/isp/applets/FP/FP.html Then have a read of the FAQ at: http://www2.hursley.ibm.com/decimalj/decfaq.html They may not be any more articulate than I was, but if you get a couple different people trying to explain it, it's sometimes easier to triangulate the truth that lies between. :) Thanks, --G. --- Geoff Gerrietts Software Engineer, HomeGain.com 510-655-0800 x4320 From new_name at mit.edu Thu Jun 7 12:07:21 2001 From: new_name at mit.edu (Alex) Date: 07 Jun 2001 12:07:21 -0400 Subject: How can I extend raw_input to provide user w/ default input string? References: <9fmgli$43f$1@peabody.colorado.edu> <3B1F0D82.DB10E008@yahoo.com> <9fo6g6$36v$1@peabody.colorado.edu> Message-ID: > However, I was thinking about presenting the user with a default input > and give him/her the ability to edit it. Maybe I should think about > using Tkinter if this is impossible to do using a console interface. You might want to check out the readline module. Alex. From kzaragoza at mediaone.net Tue Jun 26 13:22:18 2001 From: kzaragoza at mediaone.net (Kris J. Zaragoza) Date: Tue, 26 Jun 2001 17:22:18 GMT Subject: MS SQL Server References: Message-ID: On Tue, 26 Jun 2001 11:52:51 -0400, Bill Bell wrote: > >Ben wrote, in part: >> Unfortunately I have to upload data to a MS SQL server ... Can anyone >> recommend a tool for doing this or docs\examples :] ... is it ANSI >> SQL compliant like MySQL and therefore can use the same commands? > >Is it possible that the data source you want to process is one of >those provided for by the "Data Transformation Services (DTS) >Wizard" that is (or used to be) shipped with SQL Server? If not, >what is the source of the data you need to process? > >Bill > And if it's something that you need to automate, you may want to look at using the bcp.exe command line tool. Under Windows, you have a number of options for working with SQL Server. Each has its pros and cons: * ADO via win32com automation. This is a nice generic interface that should work across databases, but it's slow as hell for loading lots of data. * ODBC via odbc or mxODBC. I haven't used the mx package myself, but i've read good things about it. Either way, I find using Python's DBI API to be a bit quicker than ADO for moving lots of data around. * SQL-DMO via win32com automation. This gives you access to all sorts of SQL Server specific features, including BulkCopy as mentioned in another reply. However, it does require the SQL-DMO libraries to be installed on the machine using it. * bcp.exe via os.system() or one of the spawn/exec variants. This really becomes more like shell scripting, so it's far from an elegant solution. However, if all you need to do is munge a little data and then slurp it all in, it's probably going to be the fastest solution. If you have lots of data (hundreds of MB and up) to import into a single table, this should beat any solution involving an INSERT hands down. Follow up with more details if you have any problems. I've done lots of data slinging with SQL Server. :-) -Kris -- Kris J. Zaragoza | "Unfortunately, most people can't out-think a kzaragoza at mediaone.net | grapefruit." --Jon Bodner From guido at python.org Wed Jun 20 16:21:08 2001 From: guido at python.org (Guido van Rossum) Date: Wed, 20 Jun 2001 20:21:08 GMT Subject: PEP 255: Simple Generators References: Message-ID: Denys Duchier writes: [Quoting Tim Peters] > > If, e.g., you want to > > build a generator that delivers the results from generators g and h > > alternately, it's easy (although I personally don't want to ): > > > > def zipgen(g, h): > > giter = g() > > hiter = h() > > while 1: > > yield giter.next() > > yield hiter.next() > > which I would write as follows: > > def zipgen(g,h): > def result(yield): > g(yield) > h(yield) > return result Well, that settles it -- I find Tim's version much easier to read than Denys's version. Thanks for playing. :-) --Guido van Rossum (home page: http://www.python.org/~guido/) From grante at visi.com Sat Jun 2 17:52:57 2001 From: grante at visi.com (Grant Edwards) Date: Sat, 02 Jun 2001 21:52:57 GMT Subject: Why isn't Python king of the hill? References: <9fb5fl$26kf$1@agate.berkeley.edu> <9fblqd$2f0u$1@agate.berkeley.edu> Message-ID: On Sat, 2 Jun 2001 21:28:45 +0000 (UTC), E. Mark Ping wrote: >>So do I. But every time I've seen an application _depend_ on exact >>representations, its caused problems. Perhaps the FP code you've >>seen was better, but in my experience code that depends on exact >>represention has caused problems. > >Ah, but your example was exact representation of *integers*, not just >any value. What I've seen happen: code is written by a programmer who knows that the input values are going to be integer values that can be represented exactly. It works fine for a few years. Then the system requirements are changed slightly and an input that was previously integer valued, is now non integer-valued. Or the input scaling is changed so that the integral values can no longer be represented exactly. In either case, the system stops working right. If the original design hadn't assumed exact representation, the problem is avoided. -- Grant Edwards grante Yow! I'm CONTROLLED by at the CIA!! EVERYONE is visi.com controlled by the CIA!! From john.thai at dspfactory.com Wed Jun 6 17:30:16 2001 From: john.thai at dspfactory.com (John) Date: Wed, 6 Jun 2001 17:30:16 -0400 Subject: tokenizer.. Message-ID: Hello, Is there a built in function or module which allows me to get tokens from a string? I know there's the tokenize module but that needs a callable object and it seems to loop forever... John From Attila.Feher at lmf.ericsson.se Mon Jun 4 01:09:57 2001 From: Attila.Feher at lmf.ericsson.se (Attila Feher) Date: Mon, 04 Jun 2001 08:09:57 +0300 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3B1A47EA.AFBD45E8@lmf.ericsson.se> Message-ID: <3B1B1825.8109BA83@lmf.ericsson.se> TGOS wrote: > > On Sun, 03 Jun 2001 17:21:30 +0300, Attila Feher > wrote: > > > > > Just to inform you: the worlds easiest to hack and crack systems are the > > UNIX systems. > > That's absolutely incorrect. That is _absolutely_ correct. There is no system like unices, full with security holes. Crackers _does_ start on unices, the easiest to crack systems. If you think they start on VMS, you are alone. > It's easily provable by having a look at "how" hackers were entering a Unix > system. Whenever a new hack is made public somewhere on the Internet, I first > have a look at "how it was done" because that's most interesting to me (more > interesting than "who was hacking the system" and "for what reason"). And > usually I'll read the following: > "This hack was possible because of a security hole in XYZ, that got fixed in > version 1.234, which was released ". So that is what you find. You don't search hard enough. BTW, commercial Unices are no better than MS: they _only_ publish holes found after they have corrected it. > But that's all only valid for maybe 5% of all hacks, 95% of all hacks are only > possible because the hired system admin wasn't qualified for this job. Come on, > if you leave your UNIX server widely open to the public, it's no wonder if you > get hacked. The Unix systems are _designed_ to be wide open. So you _do_ need an expert to close them. Not such with VMS. > IOW most UNIX hacks only result of poor administration and hacking a perfectly > secured UNIX system is extremely hard. In most cases it's harder than hacking > Windows, because only a "root-hack" is really useful on UNIX systems, whereby > on Windows systems it's enough to be an ordinary user in many cases. Creating a perfectly secured Unix system is equally extremely hard. It is not enough on Windows NT to be an ordinary user to do a crack. You don't even seem to know the diff between hack and crack... So if you are going to compare win9x/me to Unix, you are out of your mind. And on (a well secured) NT it is not enough to get in as an ordinary user to crack it. Same as with Unix. :-) > Despite that, more people will be able to see UNIX source code before it gets > released than are actually working for Micro$oft as whole, so the chance that > they find hidden bugs in network code (for example) is a lot higher than in > case of Windows. Not really. Windows code is seen by thousands before release. The fact you were not invited to this circle of privileged non-MS people does not mean it does not exist. > But leaving this all aside for a second: > *Where* in my post did I say that Unix is extremely secure and hard to hack? > All I said is that Windows isn't secure. You put it as a favour to UNIX! Implying that UNIX is. > PLEASE, don't put words into my mouth that I never used! > I suggest you read my post a second time. Don't be a politician!!! You know if I start defend UNIX based on that Windows _is_not_ secure (WHICH ONE?????) than people automatically think UNIX is. You imply that Unices are used in banks and secure places which is not true either, at least not for most. They use VMS. > > Serious users (security, incl. but > > not limited to NATO, banks etc.) use VMS. Some smaller banks use(d) > > OS/2. > > Same situation as above. > I never said that those use UNIX, did I? > (if you disagree, please post the line!) > All I said was that those don't use Windows. > Are you sure you have read my post? Yes. Your whole post was a defense of Unix (Linux) with comments about why Windows is bad. BTW I have not seen any airport where the terminals were non-Windows... > And speaking about cross-platform development: > OS/2 is a very good Java platform. I don't know anything about VMS, but it's > certainly not impossible to port a Java Virtual Machine for this system as > well. No. And I guess it exists. And I guess it is a security risk as all Java VMs are. > Again, I never said that UNIX is used in all the places you described above. > I get the feeling that you are replying to the wrong post here. You implied. > > So don't take UNIX to any higher level than it is. > > I never did that, you are currently doing that because you assume ... well, I > have no idea what you are assuming. What your post was about. :-) > > And about Windows being a shit: Just try to look around and find a > > portable async gethostbyname or a standard gethostbyname_r for > > Unices... Good luck. BTW you can find numerous workarounds which fail > > in numerous environments. > > And the fact that this function (which I personally have never needed up to > now) doesn't exist on UNIX is the proof that Windows isn't shit? Funny, but > that makes no sense to me. Did I say it exists in Windows? Did I say that? When? _If_ you never needed it how do you know by hearth it does exists as a service in WinSock and does not in Unix??? > > Windows is not better than UNIX and UNIX is not better than Windows and > > none of those are neither secure nor realtime O/Ss. > > 1) I never said that UNIX is better than Windows (correct me if you can!), I > only said that Windows is unstable, insecure and not very well thought out. Just like Unix in general. > 2) I never said that UNIX is secure, neither in my last post nor in this post. You implied > 3) There actually is a realtime version of Linux ... just thought I should > mention that. Which is not "realtime enough". > > Don't make a religious war about this. > > It rather looks like /you/ are making a religious war out of that. > I nowhere said "UNIX is better" and that all people shall use UNIX PC instead > of Windows PCs. I use Windows myself (not as only OS, but still more often). > > I was only pointing out that not 99.9999% of all PCs run with Win32 (the > reality is not even close to that) and that cross-platform development has no > disadvantages. Yep, U R right in that. Only disadvantage is if your market size for Win32 platforms is the 80% of your market and you spend too much time to serve 15% of the rest (you will never have a fully PI SW) and so you loose that whole 80%, too. > > Like online casino SW. Would they survive with a Linux only solution? > > I don't know and I don't care. I'm a supporter of cross-platform solutions and > a Linux only solution is no cross-platform solution. All I was pointing out is that a Windows solution might cover 60-90% of your existing market. Which is usually not true with Unix solutions. But working on Unices: you are right. There is no such thing as Unix. You _must_ do cross platform development, know all the non-standard sh*t and all the errors of all O/Ss you ever want to support. HP-UX fails at different places than Solaris 2.7 etc. > You seem to misunderstands my motives. Saying how shitty Windows is and only > developing Linux software from this day on isn't making the situation any > better. You exchange one "platform dependent solution" with another "platform > dependent solution". Cross-platform development meaning to not develop for any > specific platform. I'd like to see you to make a full featured GUI which runs on Windows (all the 5+1 versions in use plus CEs) _and_ all Unices with all Window Managers with no incompatibilities (clipboard etc.). They are simply way too different to be able to use the same code base. If you can, you end up with: either a Java monster, a ported MFC-crashing monster, or a SW which supports only unacceptable subset of the GUI capabilities of the Windows platform. Business logic can be portable easily. GUI.... maybe if it is HTML based... > It means developing a base version that can run everywhere and then only > fine-tune this base version for different systems. That's cross-platform > development. There is no such thing. If you believe in that... Maybe for very simple applications where it is enough to use what the GUI meant 10 years ago. > To get back to your question: Would the casino SW developers also survive when > creating software that can run on Windows, Linux, Solaris, Irix and OS/2? > Certainly! Maybe even better than they are doing right now. Certainly not. They would be about to finish the first beta version of their SW, when the market is already shared between the players. If my friend would have decided to make a cross platform version he would certainly loose the game. You know individual users don't care if you casino SW will not run on the Mac of somebody else. In that sector cross platform hgas no marketing value in the mass market: the home Windows user. Not even NT needed to be supported for a looong time. :-)))) > > So there is a huge market for Windows apps. > > Just like there's a huge market for other OSes, so why not supplying software > for more than a single market? Because you could gain more customers and earn > more money? Yeah, that would certainly be a big disadvantage. Why not? Because the market compared to the Windows one (depending on your area) might be too small or too far to be worth the effort. Same thing can happen for areas where Windows users have no need but Unix users/systems. > If you are developing a online application that people shall be able to use > within their browser (and that's what this whole thread is all about...but I > assume you don't know that because you haven't read anything within this thread > up to now, including my post to that you are replying), where is the advantage > of limiting it to a single platform? I don't see any. Online application is not necessarily "within the browser". "Withing the browser" is Java, ActiveX or C# or goodbye. Java is still a very unstable and unsecure stuff where VMs are incompatible etc. No 1.3 for IE etc. ActiveX is Windows only. C# - I have not heard much good about it yet. > The cross-platform solution is there, all you need to do is using it! I have been working together with _the_ Java evangelist of Hungary, who was been using, promoting, supporting Java, making large systems for all the years Java existed. If you believe in effortless Java code portability, you did not work enough with Java... esp. between different VMs. A From rnd at onego.ru Fri Jun 29 09:20:10 2001 From: rnd at onego.ru (Roman Suzi) Date: Fri, 29 Jun 2001 17:20:10 +0400 (MSD) Subject: Comment on PEP-0238 In-Reply-To: Message-ID: On Fri, 29 Jun 2001, Guido van Rossum wrote: > "Robert J. Harrison" writes: > > > From recent discussion it is not clear to me if > > PeP 0238 (http://python.sourceforge.net/peps/pep-0238.html) > > has gained favor, or not. I think, "//" could be better used for rational arithmetics to make rational numbers: 1+1//2 ~ 1.5 Thus: 1//2 + 1//2 gives 1//1 or simply 1 ;-) Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From johnroth at ameritech.net Tue Jun 12 23:52:36 2001 From: johnroth at ameritech.net (John Roth) Date: Tue, 12 Jun 2001 20:52:36 -0700 Subject: PEP 259: Omit printing newline after newline References: Message-ID: "Guido van Rossum" wrote in message news:mailman.992290220.14360.python-list at python.org... > Please comment on the following. This came up a while ago in > python-dev and I decided to follow through. I'm making this a PEP > because of the risk of breaking code (which everybody on Python-dev > seemed to think was acceptable). > > --Guido van Rossum (home page: http://www.python.org/~guido/) > > PEP: 259 > Title: Omit printing newline after newline > Version: $Revision: 1.1 $ > Author: guido at python.org (Guido van Rossum) > Status: Draft > Type: Standards Track > Python-Version: 2.2 > Created: 11-Jun-2001 > Post-History: 11-Jun-2001 I think not. Let's consider the possibilities. In existing programs, either the programmer has taken care to remove newlines, or she wants the current behavior, or she doesn't care enough about the output format to fix it so it looks right. The proposed change wouldn't affect case 1. It would change the output of case 2, and probably wouldn't matter in case 3, other than the inevitable questions from users about why their output suddenly changed. Programmer: We need to install Python 2.8! It's got all these cool features! PHB. What do we need to do to make it happen? Programmer: Well, we need to rewrite all thousand scripts because it's got all these incompatible cool features. PHB. OK. Rewrite them in Visual Basic. Corny as the above conversation sounds, I don't know any real world managers who regard spending staff time fixing something that isn't broken as adding value to the project. I grant you that the proposed behavior is "better," for almost all reasonable values of the word "better." However, sometimes the downside of making a change is just too large for the benefit. John Roth From jp at ulgo.koti.com.pl Sun Jun 17 16:40:06 2001 From: jp at ulgo.koti.com.pl (Jacek =?iso-8859-2?Q?Pop=B3awski?=) Date: 17 Jun 2001 20:40:06 GMT Subject: Pmw: how to clear ScrolledListBox ? References: <3b2ccea6.477584718@news1.on.sympatico.ca> Message-ID: Robert Roy wrote: >>I add items by .insert, what is correct way to remove all items? >> > setlist([]) should work. what happen with old list? what happen in Python when I allocate memory for something then use another value? -- The lover of life's not a sinner The ending is just a beginner The closer you get to the meaning "Heaven and Hell" The sooner you'll know that you're dreaming - Ronnie James Dio From Glen.Mettler at home.com Sun Jun 10 09:09:03 2001 From: Glen.Mettler at home.com (Glen Mettler) Date: Sun, 10 Jun 2001 13:09:03 GMT Subject: New guy question References: Message-ID: I forgot to ask - what is the purpose of the Python window and the Python Shell window? Can I NOT run a series of scripts from these windows? Must I go to the DOS window to check my program? Glen "Glen Mettler" wrote in message news:TiyU6.127784$I5.32725119 at news1.rdc1.tn.home.com... > I have a small script I entered from a Python book that works when I run it > using F5. > However, when I go to the console and enter python alook.py, I get an error > message: > > >>> python alook.py > SyntaxError: invalid syntax > > I am too new to this to know why. > > Glen > > From philh at comuno.freeserve.co.uk Sun Jun 17 11:39:00 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Sun, 17 Jun 2001 16:39:00 +0100 Subject: Two minor syntactic proposals References: Message-ID: On Sun, 17 Jun 2001 01:53:43 +0100, Gareth McCaughan wrote: >You can do it, thus: > > def new_method(self, x): > something_else() > return x+1 > Thing.new_method = new_method > >but that's rather ugly. It doesn't look too bad to me. It's not as if you'd be doing it every day, I expect. And i don't think special syntax for operations your rarely use is a good idea -- because people will use them too infrequently to remember the syntax. >Every now and then we get people complaining because it's >too easy for them to forget to include a "self" argument >in a method definition. Every now and then, I suspect that >most Pythonistas forget. (I certainly do.) Suppose there >were an alternative syntax, thus: > > class Thing: > def self.boring_method(): > return 0 I propose a different way of doing this: make 'self' implied in all references to instance variables. This involves definiing 2 new keywords, qclass and insvars. So: qclass Thing: insvar v, w def myMethod(p): print p, v, x def otherMethod(): myMethod(1) someFunction() would be equivalent to: class Thing: def myMethod(self, p): print p, self.v, x def otherMethod(self): self.myMethod(1) someFunction() Note that a qclass definition would have to know what its methods and instance variables were, including those inherited from superclasses, for this to work. Is this feasible? Another thing i would like is multi-line comments. I know you can do this with documentation strings, but |i find them too limiting, because you are only allowed to put thme in certain places, and indenting rules apply to them. I would like to be able to, in a file: #/* comment for MyFirstClass ... #*/ class MyFirstClass: ...definition... #/* comment for MySecondClass ... #*/ class MySecondClass: ...definition... -- ## Philip Hunt ## ## philh at comuno.freeserve.co.uk ## From nikifor at sky.inp.nsk.su Sun Jun 24 12:18:36 2001 From: nikifor at sky.inp.nsk.su (Alex A. Nikiforov) Date: 24 Jun 2001 16:18:36 GMT Subject: shelve ( or bsddb ) problem Message-ID: <9h53ss$3799s$1@sky.inp.nsk.su> That is priogram: $ cat b.py import bsddb import shelve s = shelve.BsdDbShelf(bsddb.hashopen('qqqqa','c')) s['a'] = [3,2,1] print s['a'] s['a'] = [1,2,3] print s['a'] s['a'] = range(1000) print s['a'][500] s['a'] = [1,2,3] print s['a'] That is result: $ python b.py [3, 2, 1] [1, 2, 3] 500 Traceback (innermost last): File "b.py", line 12, in ? print s['a'] File "/usr/lib/python1.5/shelve.py", line 64, in __getitem__ f = StringIO(self.dict[key]) KeyError: a $ ? ? ? ? ? python-1.5.2-30 from RedHat (python-1.5.2-27 has the same problem too) Alexei Nikiforov From Attila.Feher at lmf.ericsson.se Thu Jun 7 13:05:18 2001 From: Attila.Feher at lmf.ericsson.se (Attila Feher) Date: Thu, 07 Jun 2001 20:05:18 +0300 Subject: best language for 3D manipulation over web ? References: <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3B1B1825.8109BA83@lmf.ericsson.se> <2v4ohtgldvce84sn87kh1eg1lnes37getq@4ax.com> <3B1C9E65.B73A4FE@lmf.ericsson.se> <3B1DFD87.F3BFDB57@lmf.ericsson.se> Message-ID: <3B1FB44E.25AD0134@lmf.ericsson.se> TGOS wrote: > Let's assume you need a router...all you need for that is a UNIX/Linux kernel > and a boot script...that's it. > Maybe you also install an SSH client (that only allows connection from the > local network) to change configuration, but despite that you don't need > anything. Such a router easily fit onto a floppy disc...even a router with > extra firewall may fit onto a single floppy disc. > > Now let's build that system with WinNT...how much useless components do you > have to install, that are never used later on, but might cause security holes? > Exactly ^_^ I would not use NT for that :-))) > Despite that, I doubt that WinNT actually has router/firewall functions > implemented into its kernel, so you are forced to install third party software > for this. No 3rd party, just the MS Proxy. Been there, done that. [Huge Snip] > Sure: > Open system.ini and replace "shell=Explorer.exe" with another GUI. > Try "shell=command.com" and you run Windows in text mode. You can start Windows > apps, that's no problem. E.g. type "start winamp" and then you can listen to > MP3 music. You just don't have a Desktop, a Taskbar or a Startbutton. Actually you can replace the DGI itself. You can get a command line only environment and there are little tools one can use to start up new VMs. [SNIPPPP] > Well, there are alternatives to Sendmail. Despite that, I found a webpage that > describes how you can install and use Sendmail, WITHOUT assigning root access > to it. URL? :-))) > > I mean having a web server which > > cannot notify me of events (alarms) is not that good. :-( > > There certainly other ways to notify you. > Despite that, a Unix system can send mails without Sendmail, e.g. via an > external SMTP server (the one where your mailbox is hosted). That's right... [SNIP] > Then use non open source wrappers ^_^ > Or even better, write your own wrapper. To be honest: it would be fun up to 2 OSs but after that... and since I rarely have time for other things than eat, sleep and work. :-((( [SNIPP] > > Anyone making assembly optimizations should be aware of that he creates > > _highly_ nonportable code. > > But also highly speed optimized one. You _might_ need it for games. But I doubt that they are usually needed for anything but picture etc. processing. Etc. might be some other huge data flow, like speech... > > If one goes with C++ (and C) it is many > > times unnecessary, even evil. A well written C/C++ code will provide > > the same ASM stuff. > > That depends. > Most compilers allow you to preview your C++ code in Assembler, the way it is > also translated when getting compiled. If you take a look at that code and > compare it to hand written code, it's quite different. Yep. And some "clever" guys (w/o know 1% of what the compiler authors) starts to make it smaller and ends up with a slower stuff :-))) > A tiny C++ program may result in 1,000 lines Assembler code, while when you > write the same thing directly in Assembler, you may only need 400 lines. And those 400 lines may be way slower! Predictions etc. etc. > Despite that you can make use of processor features like SSE2, which can > perform certain calculations 4 times faster than using classic x86 > instructions; very helpful when applying the same function onto an whole array > of numbers. C++ won't use those features, because therefor it would need to > know how the program behaves during runtime. OK! Correction: well writtenm C++ code awith a well written compiler. Probably none exists :-))) > Sure, this code will only run on a specific platform, often only on a specific > CPU, but nonetheless it's done pretty often. This doesn't mean that your whole > application can't be cross-platform. Yep, if it is well documented, small enough part. [SNIP] [ Windows Registry ] DownWithIt=true ; :-)))) > > > And once it crashes you have to reinstall _everything_, probably > > including nice data loss... > > Exactly, that's why applications shouldn't store their data there. So I can > reinstall Windows, without being forced to reinstall a single application. > That way I would loose file associations, but that's not such a big deal. Yep-yep. Same about DLLs in Windows\system[32] etc. BTW I still would like to see (never tried) that is it actually possible to load 2 different versions of the same DLL (same module name) under windows... Last time I have tried I simply got back the already loaded version. I guess it isn't so in UNIX at all. I don't even see the load .so if I am not in the process started it or in a subprocess... > >> Every user should have his/her own registry (and not just a sub-tree) > > > > TOTALLY agreed. > > See, we can agree to many different things ^__^ Yep! > Especially if every user had his/her own registry, different users could have > different file associations (one user may like to open DOC files with Word, but > someone else may like to open them with StarWriter) and different hardware > settings (sometimes that's an advantage). Oh yeah. But I guess you _can_ have this... though never tried it. But as far as I remember I saw that some SW installed file associations only for 1 user and then they were at a special place in the user part... Would not say it under oath :-))) [SNIP] Thx for the Java URL, I'll check it out. > >> You can't really filter the web. You can try, but it will never be really > >> effective. > > > > Simple. One allows only few addresses/IPs to be reached :-))) Opposite > > filtering :-))) > > I don't think they are doing this...actually I know it. > Do you know Audiogalaxy? Not really. > It's like Napster (sharing MP3 files), but unlike > Napster it's still unfiltered and they even have a client for Linux. > I use it once a while and there you can look who's online at the moment (of > course you don't see the real names of people, just their screen names), sorted > by country. And once a while a few people from China are online ^_^ Ohh. Kids of the Chinese communist party leaders probably :-))) Or the state security... > And as I know the Chinese government, I doubt that they would allow users to > access Audiogalaxy, because they also have discussion forums there. So Chinese > people can discuss with the rest of the world. Yeah. Poor them. I mean it. [SNIP] Thx for Java+RAM advice. > > Now if U have a C++ programmer (experienced, with his nice libraries) I > > guess he will do a better quality work before the new Java guy learn > > what is an array :-))) > > But the C++ programmer may use direct memory access and the result is something > like Sendmail, which doesn't happen when using an array. ^_- Oh yeah. When I have said "experienced C++ programmer" I meant that he is experienced _and_ damn good in C++ programming :-))) > Despite that, C++ programmers don't need to know what an array is? Sure they do. :-) At least I know. And how many arrays one can have! Since array is like container, so... [SNIP] > That's what I'm currently trying. The first thing I did was looking at the > source code of all classes that are shipped with Java and I found out that they > seem to be rather optimized for small size than for high speed. Good luck. > > Ps: Maybe we should go on in private? I am just waiting in fear for the > > first guy from some NG to say: this is not a discussion forum :-(( > > Really? So what is it? > IMHO a Newsgroup *is* the prototype of a discussion forum and Usenet was > created for discussions. > > But the e-mail address in my header is valid, so you can also reply via mail if > you prefer. OK. So let's hang here until we get a "friendly" warning :-)) A From Tom_Good1 at excite.com Tue Jun 5 19:16:24 2001 From: Tom_Good1 at excite.com (Tom Good) Date: 5 Jun 2001 16:16:24 -0700 Subject: I NEED to TEACH you something, QUICK! References: Message-ID: Laura Creighton wrote in message news:... > Do you know that when I sit down with a piece of code and treat it > with the focused anger that I reserve for all new things I have > to fix that somebody left lying around broken they generally end up > 30% smaller? and do more? and fail in a more graceful fashion? > Here is the secret. If you implement the correct elegeant hack > then you can often get 3 done for the price of one. . . . and will often get code that is more abstract, therefore more likely to be re-used in the future. Regarding order vs. chaos, I feel refactoring combines both: bringing in chaos (tearing apart working code) as a way to bring about a new kind of order (more elegant code). Is Extreme Programming more chaotic than Big Design Up Front? Or does it just have a different, more fine-grained kind of order? Tom p.s. Good original post. Metaphorical thinking about programming is interesting. From dsh8290 at rit.edu Mon Jun 18 16:05:11 2001 From: dsh8290 at rit.edu (D-Man) Date: Mon, 18 Jun 2001 16:05:11 -0400 Subject: Best solution ? In-Reply-To: <992890276.155845@seven.kulnet.kuleuven.ac.be>; from nightowl@uk2.net on Mon, Jun 18, 2001 at 08:50:16PM +0200 References: <992890276.155845@seven.kulnet.kuleuven.ac.be> Message-ID: <20010618160511.B4968@harmony.cs.rit.edu> On Mon, Jun 18, 2001 at 08:50:16PM +0200, NightOwl wrote: | I am planning (hoping to) write a database-GUI which would mostly | run in Windows but connect to a Postgressql database on a central | linux-server. If I can write the GUI so that it can also run in | Linux, that would be a big advantage. I was thinking about Python, | since that runs on both platforms. An other option is PHP (which I | have used extensively in webpages but never stand-alone). | | A couple of questions remain : | | 1) Is Python capable of easily accessing a Postgres db? (like PHP?) | (if not, would it work with MySql) ? Yes for both. | 2) would it be possible to design code which would (the same code) | run on Linux X-windows as on Microsoft Windows ? Yes. Now you have your choice -- do you want to use Tkinter, PyGTK, PyQt, wxPython, some other toolkit? | 3) Would these thing (if anybody knows) be possible with PHP ? No clue. | 4) If 3? is yes, what would you prefer ? Python . | Any other suggestions are welcome, as long as I am able to build a | GUI for a central database which would easily print documents too | (Python has Windows COM-support, doesn't it ?) COM support exists with the win32all extension library (free). Of course, this doesn't work under Linux, but you could use MFC for the gui. -D From dedmundson at bigfoot.com Fri Jun 15 02:07:14 2001 From: dedmundson at bigfoot.com (Darran Edmundson) Date: Fri, 15 Jun 2001 16:07:14 +1000 Subject: C API missing PyList_Remove() ... Message-ID: <3b29a5e6$1@clarion.carno.net.au> Why has the C equivalent of "list.remove(item)" been left out of the list of exported functions? Checking the source, listobject.h exports PyList_Append(). Hovever listobject.c has no function PyList_Remove(), instead just the unexported list_remove() function. This is obviously "by design", but why? Cheers, Darran. From phd at phd.fep.ru Fri Jun 8 16:00:45 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Sat, 9 Jun 2001 00:00:45 +0400 (MSD) Subject: DOS Extenders (was: RS232 support for DOS on 486?) In-Reply-To: Message-ID: On Fri, 8 Jun 2001, Oleg Broytmann wrote: > DOS Extenders. http://phd.pp.ru/Software/misc/DOS-Extenders.txt Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From m.faassen at vet.uu.nl Sat Jun 30 21:16:45 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 1 Jul 2001 01:16:45 GMT Subject: PEP scepticism References: <3d1yo2nca4.fsf@ute.cnri.reston.va.us> <9hj3bb$bdu$8@newshost.accu.uu.nl> <9hjj0b$c55$1@panix3.panix.com> <9hk94p$cnu$1@newshost.accu.uu.nl> Message-ID: <9hltlt$gfg$3@newshost.accu.uu.nl> Guido van Rossum wrote: > m.faassen at vet.uu.nl (Martijn Faassen) writes: [I express being mystified over some python-dev subscription policies] > Note that the policy has silently changed: if yourelly want to > subscribe, just do it. The moderator will silently subscribe you. > Please do this only if you are serious though! I'm not serious enough right now (too many interests, too little time and too lazy) to do so, I think, but I'll keep that in mind. Thanks for letting us know! As I'm sure everybody knows now; if people read *my* posts (they seem to!) they'd certainly read yours. :) Thanks, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From dsh8290 at rit.edu Mon Jun 4 15:36:35 2001 From: dsh8290 at rit.edu (D-Man) Date: Mon, 4 Jun 2001 15:36:35 -0400 Subject: Why no 'elif' in try/except? In-Reply-To: <9fgiip$h48$1@neon.noos.net>; from boyd@insultant.net on Mon, Jun 04, 2001 at 08:03:21PM +0200 References: <3B1A06EE.F484930A@snakefarm.org> <3B1A29DE.9876770D@accessforall.nl> <9fgiip$h48$1@neon.noos.net> Message-ID: <20010604153635.B11144@harmony.cs.rit.edu> On Mon, Jun 04, 2001 at 08:03:21PM +0200, Boyd Roberts wrote: | "Marcin 'Qrczak' Kowalczyk" a ?crit dans le message news: slrn.pl.9hnbs9.4l5.qrczak at qrnik.zagroda... | > I don't understand only one thing. Why it is spelled 'elif' and not | > 'else if'? | | may have been influenced by 'elif' from the Bourne shell as well as | the fact that it's simpler to parse, given it's one token and not | two (less look ahead). I think it is also related to Python's block structure. If it was spelled "else if" in the same way C/C++/Java spell it, then your code would have to look like if : else if : else if : else if : else : as this is exactly what the parse tree from C/C++/Java look like. The simple act of indenting "improperly" gives the proper look to the form. I will also point out, before someone else does, that this isn't exactly correct Python indentation because there is no ':' after the 'else' and only simple statements can occur on the same line (the 'if's would need to be on the next line). -D From noselasd at frisurf.no Wed Jun 20 02:59:04 2001 From: noselasd at frisurf.no (Nils O. Selåsdal) Date: Wed, 20 Jun 2001 08:59:04 +0200 Subject: Python to native compilation via java? References: <3B2E65DC.5060209@lindbergs.org> Message-ID: "VanL" wrote in message news:3B2E65DC.5060209 at lindbergs.org... > Hello, > > I was reading about the new gcc 3.0 release, and something that caught > my eye: > > """ > The GNU Compiler for the Java Programming Language > What is GCJ? > > GCJ is a portable, optimizing, ahead-of-time compiler for the Java > Programming Language. It can compile: > > * Java source code directly to native machine code, > * Java source code to Java bytecode (class files), > * and Java bytecode to native machine code. > > Compiled applications are linked with the GCJ runtime, libgcj, which > provides the core class libraries, a garbage collector, and a bytecode > interpreter. libgcj can dynamically load and interpret class files, > resulting in mixed compiled/interpreted applications. > """ > > Would code get any significant speedup by going jython -> .class files > -> native? Yes. Though there are issuses. gcj is buggy, and doesnt implement all the core classes for java1.1 (and by far java2). jython is uses the python language alright, but does only provide a small subset of the core python libraries (you can ofcourse use any java library in jython) From jeff at ccvcorp.com Fri Jun 29 13:35:02 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Fri, 29 Jun 2001 10:35:02 -0700 Subject: module for A/D-converter? References: <20010629.7381058@fb11lfm15.fh-muenster.de> Message-ID: <3B3CBC45.F3C73B2F@ccvcorp.com> Arend von der Lieth wrote: > Hi everybody, > > I am wondering if there is a way to implement a program (with python of > course) that reads values from an A/D-converter card. > More precisely: I want to read data from an oscilloscope and do not want > to use the languages that we used before (C, Pascal, VBS) > > Thanks in advance, > Arend Since you mention VBS ... is it possible that there is a COM object available that represents the i/o to your card? If so, it should be easy to script that COM object from Python. If not... then you probably would be best off writing a simple extension in C (or write your own COM object controller in either C or VB), then calling that from Python. Jeff Shannon Technician/Programmer Credit International From kamikaze at kuoi.asui.uidaho.edu Fri Jun 15 20:29:33 2001 From: kamikaze at kuoi.asui.uidaho.edu (Mark 'Kamikaze' Hughes) Date: 16 Jun 2001 00:29:33 GMT Subject: Tkinter: Lifting window to top? References: <1103_992247080@merak> Message-ID: Mon, 11 Jun 2001 08:11:20 GMT in <1103_992247080 at merak>, Alexander Loehr spake: > I create a toplevel window and display it on the screen. On Unix > everthing works fine. But on WinNT my window is behind all other > windows. How can I lift it? The function lift doesn't work. `top.tkraise()` does what you want. If you want to raise it just above one particular other window, use `top.tkraise(aboveThis=other)`. -- Mark Hughes "I will tell you things that will make you laugh and uncomfortable and really fucking angry and that no one else is telling you. What I won't do is bullshit you. I'm here for the same thing you are. The Truth." -Transmetropolitan #39 From tex at off.org Fri Jun 29 14:27:14 2001 From: tex at off.org (Austin Schutz) Date: Fri, 29 Jun 2001 11:27:14 -0700 Subject: Is this a true statement? References: <3b34939b.410758@nntp.sprynet.com> <9h2nuc$g6g$0@216.39.170.247> <3b35e8fa.311691@nntp.sprynet.com> Message-ID: <3B3CC882.7A690F12@off.org> > >Yes, a device driver has to do this. But I don't see why a > >program that _writes_ a device driver has to do these things. > > Nobody is arging that you can't write a Python program that > generates a sequence of bytes in a file that can be used as a > device driver by some particular OS. You don't seriously think > that anybody is interested in doing this do you? > I'm actually considering doing essentially this very thing, though perhaps indirectly because I want to have it write assembly code which is then assembled to machine language. Essentially the same concept though. It wouldn't be _that_ much of a leap to put the assembler brains into python, at least not for the simple chip I'm working with. One reason I'm considering doing this is to be able to pin down (at compile time) exact timing considerations; I can calculate the time necessary to run a branch of code before I pass it off to the assembler and e.g. add in NOPs as necessary. I may not actually do it, but I am seriously considering it. It's not really _that_ dumb of an idea. :-) Austin From scarblac at pino.selwerd.nl Mon Jun 11 11:05:31 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 11 Jun 2001 15:05:31 GMT Subject: Python for win32 development, GUI, Database, dlls References: <9fi0rm$hpv$1@newnews.mikom.csir.co.za> Message-ID: I see this a week late, but it seems you didn't get many answers. Karel van der Walt wrote in comp.lang.python: > I have been approached in a 'time to market situation'. > > Python appears to me to be a strategic choice, however: > > this is a number crunching application most numeric stuff in existing > (fortran) dll > the new development will entail a lot of visualization, pseudo GIS like, > animation (coloring of contours), plain media (digital picures, video) in > a rich interactive GUI > > then all of this data in MS Access (what else?), with reports and graphs on > top of it. OK the latter can be in a reportwriter as long as one can call an > .exe with commandline parms from python) Integration with MS Office formats > (not ole automation) would be important (thus MS Access for imports > exports). > > Any grave misgivings? You need to glue a lot of things together. That's where Python should shine. > Any pointers? Let's see, the number crunching is in an existing Fortran program, so you need to interact with that. Pyfortran is supposed to do that (I never used it myself, last time the Fortran program had an output file that the script parsed): http://pyfortran.sourceforge.net . You may or may not need NumPy to do number crunching in Python (probably not). For visualization, VTK is very powerful, and scriptable with Python. http://www.kitware.com/vtk.html . You can do animation and contour colouring with it. VTK is cool. For displaying/editing images, the Python Imaging Library might be needed, http://www.pythonware.com/pil/ For plain video I don't know of any Python options. Probably you can control Windows media player through COM, or something like that. There are quite a few options for making a GUI, not going to list them. You can control MS Access from Python using COM (see the book "Programming Python on Win32" for a good explanation). But I believe that's the same as Ole, isn't it? I'm not a Windows man, don't know if there are other options. > Commercial libraries? However the exchange rate doesn't favour that :( Everything above is open source. -- Remco Gerlich From brian at sweetapp.com Sun Jun 17 16:41:11 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Sun, 17 Jun 2001 13:41:11 -0700 Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? In-Reply-To: <3B2D132D.811EDF1A@ActiveState.com> Message-ID: <003c01c0f76d$d8018c90$445d4540@D1XYVL01> Paul wrote: > You are conflating two different things. Visual Python [1] and Python > .NET [2] are completely unrelated (but interoperable, of course) For those of us who don't read dictionaries in our spare time: Main Entry: con.flate Pronunciation: k&n-'flAt Function: transitive verb Inflected Form(s): con.flat.ed; con.flat.ing Etymology: Latin conflatus, past participle of conflare to blow together, fuse, from com- + flare to blow -- more at BLOW Date: 1610 1 a : to bring together : FUSE b : CONFUSE 2 : to combine (as two readings of a text) into a composite whole [Taken from the Merriam-Webster Collegiate dictionary (http://www.m-w.com/)] From GulickDO at uReach.com Mon Jun 18 22:59:57 2001 From: GulickDO at uReach.com (GulickDO at uReach.com) Date: Tue, 19 Jun 2001 02:59:57 -0000 Subject: The Scoop on Python Input? Message-ID: <9gmf7d+cu2p@eGroups.com> Hey gang. I recently fell in love with Python for Linux and have been doing a fair amount of work programming console-based apps. I have about three or four Python reference books and was pretty disappointed how poorly the concept of "input" was covered in the books! So maybe someone here can send me in the right direction. Is there a Python input function that will get just one character from the keyboard without waiting for enter to be pressed? (like getch () in C++?) I found a module that provides getch(), but it is restricted to Window's-based platforms. Any suggestions would be appreciated. Thanks. G. From uioziaremwpl at spammotel.com Tue Jun 19 04:01:42 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Tue, 19 Jun 2001 10:01:42 +0200 (CEST) Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: On Mon, 18 Jun 2001, Tim Peters wrote: > [Russell E. Owen] > > This sounds like an interesting and really useful proposal. However,a > > few details are worrisome to me: > > You should catch up with the discussion on the Python-Iterators list (as > mentioned in the PEP announcement), where these have already been discussed > several times. I'll only give brief summaries here. > > > * A generator looks like a function until you find the "yield" statement > > inside. I think this will make the code much harder to read. One keyword > > buried anywhere in a function totally changes its behavior. If a > > generator acted like a function until it hit "yield", this wouldn't be > > so bad, but it sounds as if generators have enough significant > > differences (such as restrictions on and a changed meaning for return) > > that they are very different beasts. > > > > I'd much rather see a declaration up front that this is going to be a > > generator. E.g. add a new keyword such as "generator". > > Who would this help? Seriously. There's nothing special about a generator > to a caller, except that it returns an object that implements the iterator > interface. While the latter is important to know, there are many ways to > construct iterators in 2.2 without using generators at all. This is better > communicated via documentation (e.g., make the first line of the docstring > "Generate ..." instead of "Return ..."). >From my POV a generator is something special, even -- how you pointed out -- it's not for the caller. But a single "yield" *is* changing the way the function/generator is executed, and this way is really very special compared to normal functions. > On the other end, someone modifying the generator isn't going to miss that > it *is* a generator: all the control flow will focus on feeding > intermediate results to yield statements. IOW, you worry too much . But when I'm browsing through a source it may help me very much if I could see at the `def' line if it's a regular function or a generator. > > * The unusual use of "return" and the associated restriction of no > > expression list. What "return" means in a generator is "raise StopIter", > > not return. I personally really dislike using a keyword for multiple > > vaguely similar purposes. Look at "static" in C++ for an example of > > where this can lead. > > "return" means "I'm done" in any kind of function, generator or not. You > can raise StopIteration instead if you feel you must, but then you're > focusing on an implementation detail, and that's not helping anyone. But I have to rely that a single "return" raises a StopIter exception when I want to catch it. So why not raise it explicitly as "raise StopIter" when I have to catch it explicitly as "except StopIter" anyway? > Guido appears to feel quite strongly about this one, so if you want to > push it I suggest finding a better analogy than C++'s (over)use of > static. > > I'll note that in Icon, "yield" is spelled "suspend", and "return > expression" is allowed, meaning "I'm done, but I have one last useful value > to suspend with". It's possible Python may grow that meaning too, but it > was thought better to keep it more restrictive at first. Bye, Carsten -- Carsten Geckeler From sholden at holdenweb.com Tue Jun 26 09:18:27 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 26 Jun 2001 09:18:27 -0400 Subject: Adding unknown variables to time.mktime() References: <9h9rii$n5v$1@cubacola.tninet.se> Message-ID: "Gustaf Liljegren" wrote ... > "Roman Suzi" wrote: > > > >to be able to give only the 6 first values, since I've never heard of > > >Julian days, and week day is not significant in this case. > > > try with all 9 integers. > > RTFM time module docs. > > Read before you post. I always check the library reference, but it doesn't > give any hints on what I asked for. If mktime() can't do it, maybe there's > anyother way that you could suggest? > > Gustaf > Gustaf: Use zeroes? >>> import time >>> time.asctime( (1999, 2, 12, 1, 34, 12, 0, 0, -1) ) 'Mon Feb 12 01:34:12 1999' Aargh. This is REALLY dumb: >>> time.asctime( (1999, 2, 12, 1, 34, 12, 1, 1, -1) ) 'Tue Feb 12 01:34:12 1999' Have you looked at mxDateTime? regards Steve -- http://www.holdenweb.com/ From wware at world.std.com Wed Jun 20 12:44:44 2001 From: wware at world.std.com (Will Ware) Date: Wed, 20 Jun 2001 16:44:44 GMT Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: <73PX6.317$zE1.418988@news.uswest.net> <3B2FE2BD.F210FA8A@home.net> Message-ID: Chris Barker (chrishbarker at home.net) wrote: > ALL the GUI options for Python (tkinter, wxPython, PyQT, PyGTK, > etc.) are wrappers around a GUI toolkit made for some other laguage... I don't know much about HyperCard (tho back when it was in vogue, I heard various stuff about how cool it was) but it certainly seems that the essential core of its coolness ought to be transferable to Python. Couldn't the kind of system agnosticism you've described here be achieved by using the Glade XML format? It describes a GUI's appearance and design but leaves its implementation largely unspecified. Maybe a good idea for PythonCard would be "Glade for Chimps". Offer a somewhat limited range of functionality (maybe most GUIs can scrape by with menus, text areas, and radio buttons, or something like that) and where you can get something together without firing more than a couple hundred neurons. -- -----------------------------------+--------------------- 22nd century: Esperanto, geodesic | Will Ware domes, hovercrafts, metric system | wware at world.std.com From aa8vb at yahoo.com Fri Jun 1 08:25:49 2001 From: aa8vb at yahoo.com (Randall Hopper) Date: Fri, 01 Jun 2001 08:25:49 -0400 Subject: best language for 3D manipulation over web ? In-Reply-To: ; from jackie@endeavor.med.nyu.edu on Thu, May 31, 2001 at 11:25:38AM -0500 References: Message-ID: <20010601082549.A270383@vislab.epa.gov> Jacqueline L. Spiegel: | |I will be writing a program that needs to be accessible over the web that |will seek to manipulate objects in three dimensions through the access of an |oracle database. I could be manipulating as much as 32 MB of memory (with |respect to data only) in space. I would also need to slice and |interpolate information on the fly. There's not enough detail here about your constraints to get a good feel for your visualization or operating requirements. From your address, I'm guessing medical imaging datasets (CT, MR, etc.). If by "over the web" you mean the web-at-large by DSL, cable modem, and phone modem users alike who don't necessarily have 3D accelerators, then pulling 32MB of data over the net for manip on the client end with Java is probably not realistic. I'm going to guess you want server-side processing. Consider using the free OpenDX package (formerly IBM Data Explorer): http://www.opendx.org/ http://www.research.ibm.com/dx/ http://www.freebsd.org/~rhh/py-opendx/ It has a graphical network editor for fast prototyping, and you can code your network in C or C++ as well. Write a CGI over top and you're set. I've done exactly this for 3D geodata web server. Much, much less effort involved than using a general scene graph or bare-metal graphics rendering library. There's also JavaDX, an OpenDX back-end that allows you to connect a web server up more directly to DX, change the values in the network, and feed images or VRMLs back to the web user. Randall -- Randall Hopper aa8vb at yahoo.com From atodd at spam.free.email.com Wed Jun 27 00:33:25 2001 From: atodd at spam.free.email.com (Andy Todd) Date: Wed, 27 Jun 2001 04:33:25 GMT Subject: zodb install problem on Windows References: Message-ID: "Neil Hodgson" wrote in : >Andy Todd: >> Hi all, I'm failing terribly here. I've commented out that section of >> the setup.py file for the ZEO module and everything seems to have >> installed correctly. But now I am getting an error; >> ... >> cl.exe /c /nologo /Ox /MD /W3 /GX -IC:\PROGRAMMING\PYTHON21\Include >> /Tcsrc/ExtensionClass.c >> /Fobuild\temp.win32-2.1\Release\ExtensionClass.obj error: command >> 'cl.exe' failed: No such file or directory > > It is failing because it requires a C compiler to build some binary >libraries and Microsoft operating systems do not come with a C compiler. >If noone else fixes this first and I can find some time I'll try and >produce a package that includes binaries for Windows. > > Neil > A-ha, I almost suspected as much ;-) Thanks very much for the info. I think I've got an old version of DJGPP knocking about somewhere, would that be up to the job? I'm presuming if I get it installed I will also need to tell distutils where it is? Regards, Andy -- Content free posts a speciality From 18k11tm001 at sneakemail.com Fri Jun 29 20:42:44 2001 From: 18k11tm001 at sneakemail.com (Russ) Date: 29 Jun 2001 17:42:44 -0700 Subject: Python for air traffic control? Message-ID: I am thinking about using Python for a unique safety-critical application in air traffic control. It will monitor a few hundred aircraft for conformance to assigned trajectories, and it will initiate an automatic alarm (for both controller and pilot) if an aircraft deviates from its assigned trajectory and is in danger of a collision. (The trajectory and tracking data will come from existing C/C++ programs.) The software must be as simple, clean, and robust as humanly possible. The default languages here are C/C++, but I am toying with the idea of using Python instead. However, I am a bit nervous about the lack of type checking and function prototyping, among other issues. Is Python up to this task? Thanks for your insights. From root at rainerdeyke.com Mon Jun 25 11:58:30 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 25 Jun 2001 15:58:30 GMT Subject: PEP 255: Simple Generators, Revised Posting References: <6qk8203myt.fsf@abnoba.intevation.de> Message-ID: "Bernhard Herzog" wrote in message news:6qk8203myt.fsf at abnoba.intevation.de... > > def emptyg(): > > return > > yield None # never reached > > Only until the compiler becomes smart enough to remove that unreachable > yield statement. :) By that time, the compiler will hopefully be smart enough to perform static analysis *before* removing dead code. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From bob at staff.cs.usyd.edu.au Mon Jun 25 05:05:56 2001 From: bob at staff.cs.usyd.edu.au (Bob Kummerfeld) Date: 25 Jun 2001 19:05:56 +1000 Subject: Windows Messaging in Python References: <3b369797.62658481@news-server.bigpond.net.au> Message-ID: <9h6utk$647@staff.cs.usyd.edu.au> The best place to look for python libraries etc is The Vaults of Parnassus at http://www.vex.net/parnassus There are a few IRC libraries and a wrapper for icqlib. Bob. -- From ratan at c1592265-a.stcla1.sfba.home.com Tue Jun 5 01:31:31 2001 From: ratan at c1592265-a.stcla1.sfba.home.com (ratan at c1592265-a.stcla1.sfba.home.com) Date: Tue, 05 Jun 2001 05:31:31 GMT Subject: writing gnumeric functions in python References: Message-ID: According to Skip Montanaro : > > 1. Do I have to add functions to the central startup file > (.../python/gnumeric_startup.py) or can I define a Python module > somewhere in my personal directory tree that will get loaded? A quick look at this file shows that it sources $HOME/.gnumeric/rc.py - ratan From atsang at hk.linkage.net Fri Jun 15 12:13:17 2001 From: atsang at hk.linkage.net (Alan Tsang) Date: Sat, 16 Jun 2001 00:13:17 +0800 Subject: question about threads Message-ID: <9gdc68$fhs$1@news.hk.linkage.net> Hi Is it possible to explicitly tell a thread to pass execution to another thread in Python? Any help is much appreciated. Thanks From mdadd329ea at xix.com Fri Jun 29 00:30:22 2001 From: mdadd329ea at xix.com (Manfred Bartz) Date: Fri, 29 Jun 2001 04:30:22 GMT Subject: list of lists, object doesn't support item assignment? Message-ID: >>> xy = (1,2),(2,2) >>> print xy, xy[0] ((1, 2), (2, 2)) (1, 2) >>> xy[1]=(3,4) TypeError: object doesn't support item assignment Is there a way to assign the list (3,4) to an element of xy? What am I missing? -- Manfred ---------------------------------------------------------------- NetfilterLogAnalyzer, NetCalc, whois at: From loewis at informatik.hu-berlin.de Mon Jun 25 10:35:45 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 25 Jun 2001 16:35:45 +0200 Subject: Choosing SAX parsers References: Message-ID: "Graham Ashton" writes: > What's my best bet? Installing PyXML? Yes, that will give you xmlproc, which is a validating parser, and sgmlop, which is a very fast parser. It will also give you a few additional SAX drivers that need some external parser. > If I do, will it overwrite the xml.* Module Tree that I've got > already? No, it won't. Instead, it will install into the _xmlplus directory. > Are there any issues installing it over the top of the stuff in the > standard library (some of which I believe is the same codebase)? Installing PyXML should give you completely compatible implementations. If you find differences other than bugs being fixed in PyXML, that would be considered as a bug. Regards, Martin From bh at intevation.de Wed Jun 13 06:28:20 2001 From: bh at intevation.de (Bernhard Herzog) Date: 13 Jun 2001 12:28:20 +0200 Subject: MapIt! 1.0 - Webapplication for Rastermaps References: <9g5b3t$70ltn$2@ID-89274.news.dfncis.de> <3b26b2af.58266963@news-server.bigpond.net.au> <9g7e5n$7n8d2$2@ID-89274.news.dfncis.de> Message-ID: <6qbsnsd67v.fsf@abnoba.intevation.de> bernhard at intevation.de (Bernhard Reiter) writes: > In article <3b26b2af.58266963 at news-server.bigpond.net.au>, > sorular at netscape.net (sorular) writes: > > Can MapIt work with Zope server? > > There are not explicit provisions to integrate it with Zope. > But there is also nothing stopping you from just calling the python > functions from Zope and use them. :) > > Overall I would say: 80% yes As I've just answered a private mail with the same question, some more specific answer: The form data of a request is represented slightly differently in Zope and the standard CGI module and MapIt! currently expects the latter. It's not difficult to adapt MapIt! to Zope in this regard, you'll just have to modify the module base/common.py (i.e. remove all the ".value"s in Parameters.__init__). There might be other problems, of course. Bernhard -- Intevation GmbH http://intevation.de/ Sketch http://sketch.sourceforge.net/ MapIt! http://mapit.de/ From greg at cosc.canterbury.ac.nz Wed Jun 27 20:35:04 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 28 Jun 2001 12:35:04 +1200 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) References: Message-ID: <3B3A7BB8.F9BAE53B@cosc.canterbury.ac.nz> Tim Peters wrote: > > you can invoke a generator anywhere, but when invoked > outside of a generative control context, the generator would yield its first > result, and that's all. To behave totally like Icon, it would be necessary that given def f(): return 3 + g() where g is a generator, and f is called in an iteration context, then f would be a generator too. But then you would have turned Python into Icon. :-) -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From brakedon at hotmail.com Wed Jun 6 18:27:52 2001 From: brakedon at hotmail.com (eric_brake) Date: 6 Jun 2001 15:27:52 -0700 Subject: Error checking for 'raw_input( )'? References: <7b515e0f.0106060455.4093daa0@posting.google.com> <9flcus01b04@enews2.newsguy.com> Message-ID: <7b515e0f.0106061427.2386067f@posting.google.com> "Alex Martelli" wrote in message news:<9flcus01b04 at enews2.newsguy.com>... > "eric_brake" wrote in message > news:7b515e0f.0106060455.4093daa0 at posting.google.com... > > What is the best way to detect whether number or letter strings were > > entered into the "raw_input( )" field. I want to be able to send a > > error message to the user if they enter the incorrect type > > (numbers,letters,etc). > > import string > transl = string.maketrans('','') # dummy translation > > myline = raw_input() > > noletters = string.translate(myline, transl, string.letters) > nodigits = string.translate(myline, transl, string.digits) > > def check(xname, original, translated): > if original: > print "the line was not empty" > else: > print "the line was empty" > return > if translated==original: > print "there were no", xname > else: > print "there were some", xname > if translated: > print "there were some non-%s"%xname > else: > print "there were nothing but", xname > > check('letters', myline, noletters) > check('digits', myline, nodigits) > > > Is this the sort of thing you want to do...? Of course, > you can structure the code differently, but the general > idea of string.translate with a dummy translation table > to get a version with all characters of a certain kind > removed is pretty good & fast. > > For checks that are much more sophisticated, you may want > to use regular expressions instead -- but in general > they're nowhere as simple as string stuff, for what > you CAN do with strings... and Keep It Simple, S***** > is The Prime Directive of programming...:-) > > > Alex not really, I was hoping there was a way like when I use a "input()" field and someone tries to enter a letter or word. Of course a error occurs then I can catch them with try/except statements. but since "raw_input()" can accept any string, letters or numbers, it doesn't error. From bos at hack.org Thu Jun 14 02:29:41 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Thu, 14 Jun 2001 08:29:41 +0200 Subject: IP address to binary conversion References: <3B27FE3A.D7F9879E@hack.org> <3B27FECA.FD9A7A74@hack.org> <4shgit0hg1t6rc38lp3ba7u0vaj81l3vrv@4ax.com> Message-ID: <3B2859D5.ED320AA3@hack.org> Jeroen Wolff wrote: > Is there a way to make it unsigned? ( a 32 bits unsigned value needed) Change "l" to "I" or "L" in the struct.unpack(), then you will get a Python long integer. -- Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From joonas.paalasmaa at nokia.com Tue Jun 19 04:32:04 2001 From: joonas.paalasmaa at nokia.com (Joonas Paalasmaa) Date: Tue, 19 Jun 2001 08:32:04 GMT Subject: Getting all client http headers References: <3B2F1A51.EC21BD1C@nokia.com> <3B2F0DF6.EB339753@stroeder.com> Message-ID: <3B2F1C80.DF4CEB85@nokia.com> Michael Str?der wrote: > > Joonas Paalasmaa wrote: > > > > How can I get all client http headers in python. > > Can I use cgi-module? > > Assuming that you implement a simple CGI-BIN program you have to > stick to the CGI-BIN environment vars which contain some of the HTTP > header information (usually prefix HTTP_). Do you mean os.environ? Does it contain ALL headers? From cce at clarkevans.com Mon Jun 4 14:21:31 2001 From: cce at clarkevans.com (Clark C . Evans) Date: Mon, 4 Jun 2001 13:21:31 -0500 Subject: disabling DeprecationWarning ? Message-ID: <20010604132131.A19304@doublegemini.com> I have alot of older modules (that I'd rather not upgrade at this time), such as Mailman that constantly complain about the regex module DeprecationWarning. Anyway, this stuff generates huge log files and is distracting. I know the regex module is deprechated. Is there a way to re-compile python 2.1 so that it doesn't complain? In other words, I'd like to start using 2.1, but I don't want to upgrade every python package that I use... Thanks! Clark From gerson.kurz at t-online.de Fri Jun 8 13:22:03 2001 From: gerson.kurz at t-online.de (Gerson Kurz) Date: Fri, 08 Jun 2001 17:22:03 GMT Subject: Just a small quine References: <3b1fa942.11180453@news.t-online.de> Message-ID: <3b21046b.12594390@news.t-online.de> On Fri, 8 Jun 2001 18:27:58 +0200, Pieter Nagel wrote: >Small? Here's a one-line quine: > > s="s=%c%s%c; print s%%(34,s,34)"; print s%(34,s,34) > note about my first one: the stuff at the top defines a brainf*ck interpreter, the stuff at the bottom creates sourcecode for the interpreter and then calls it... but its still python ;) here are two other quines I wrote while brewing up that one: def r(x):x=list(x);x.reverse();return "".join(x) s=""" s tnirp;]:05[)s(r+)01(rhc+'"'*3+s+'"'*3+]25:[)s(r=s )x(nioj."" nruter;)(esrever.x;)x(tsil=x:)x(r fed """ s=r(s)[:52]+3*'"'+s+3*'"'+chr(10)+r(s)[50:];print s and s="""s="s="+3*'"'+s+3*'"'+chr(59)+s print s""";s="s="+3*'"'+s+3*'"'+chr(59)+s print s both use the same basic idea so its kind of a downer once you see whats happening. From gerhard.nospam at bigfoot.de Sat Jun 30 18:48:16 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sun, 1 Jul 2001 00:48:16 +0200 Subject: Python for Windows CE 3.0 References: Message-ID: On Sat, 30 Jun 2001 21:38:44 +0100, Tom wright wrote: >Guys n Gals, > >I have an Compaq Ipaq hand held running Windows CE 3.0 Does any one know of >any ports of python to it ? Yes, I have an iPAQ, too. On Windows CE, there is no Python port. Somebody announced he's planning to work o a port, and if it's ready, we'll most certainly find an announcement in comp.lang.python. To make the port really useful, there needs to be decent UI and ActiveX support. And that's the difficult part. If you want a decent programming language for the iPAQ now, you can downlaod a Personal Java Beta for Windows CE 3.0 from Sun's Early Access pages. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://highqualdev.com public key at homepage public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From nikifor at sky.inp.nsk.su Wed Jun 27 01:25:16 2001 From: nikifor at sky.inp.nsk.su (Alex A. Nikiforov) Date: 27 Jun 2001 05:25:16 GMT Subject: shelve ( or bsddb ) problem References: Message-ID: <9hbqns$3budc$1@sky.inp.nsk.su> Roman Suzi wrote: > On 24 Jun 2001, Alex A. Nikiforov wrote: >> >>That is priogram: >> >>$ cat b.py >>import bsddb >>import shelve >> >>s = shelve.BsdDbShelf(bsddb.hashopen('qqqqa','c')) >>s['a'] = [3,2,1] >>print s['a'] >>s['a'] = [1,2,3] >>print s['a'] >>s['a'] = range(1000) >>print s['a'][500] >>s['a'] = [1,2,3] >>print s['a'] >> >>That is result: >> >>$ python b.py >>[3, 2, 1] >>[1, 2, 3] >>500 >>Traceback (innermost last): >> File "b.py", line 12, in ? >> print s['a'] >> File "/usr/lib/python1.5/shelve.py", line 64, in __getitem__ >> f = StringIO(self.dict[key]) >>KeyError: a >>$ >> >>? ? ? ? ? >> >>python-1.5.2-30 from RedHat >> >>(python-1.5.2-27 has the same problem too) > $ rpm -q python > python-1.5.2-13 Yes, this version has not this problem. > - No problem here: > [3, 2, 1] > [1, 2, 3] > 500 > [1, 2, 3] > Run: > rpm -Vf /usr/lib/python1.5/shelve.py > to check Python installation. >>Alexei Nikiforov >> > Sincerely yours, Roman Suzi > -- > _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ > _/ Sunday, June 24, 2001 _/ Powered by Linux RedHat 6.2 _/ > _/ "Ok, I pulled the pin. Now what? Where are you going?" _/ I have found, the problem is in bsddb hash dictionary in described versions. some thing like following does not work: b = bsddb.hashopen('qqq','c') b['a']=`range(500)` b['a']='[1,2,3]' b['a'] -- error Early and later version seems has not this bag. Alexei From phd at phd.fep.ru Thu Jun 7 16:02:28 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Fri, 8 Jun 2001 00:02:28 +0400 (MSD) Subject: RS232 support for DOS on 486? In-Reply-To: <20010607142730.B17494@harmony.cs.rit.edu> Message-ID: On Thu, 7 Jun 2001, D-Man wrote: > Does Python even run under MS-DOS? Under DOS Extender - no problem. I used Python 1.5.2 quite successfully! Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From gerson.kurz at t-online.de Tue Jun 26 13:47:52 2001 From: gerson.kurz at t-online.de (Gerson Kurz) Date: Tue, 26 Jun 2001 17:47:52 GMT Subject: Threads, Callbacks, Classes [Long] References: <3b3889b9.530187@news.t-online.de> <3b3897be.4119390@news.t-online.de> Message-ID: <3b38ca0c.16997500@news.t-online.de> Found it! The new version in http://www.p-nand-q.com/python/pxfstest.zip now works from a different thread, also. I built the debug binaries, debugged, and saw that some state variable was null: you need to call PyEval_InitThreads(), duh. Thread-support seems to get activated by the first python thread (threading.Thread ??), too. I still have my doubts about the reference counts in the code, but hey the callbacks work, what more can you ask. From phd at phd.fep.ru Wed Jun 13 04:08:32 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Wed, 13 Jun 2001 12:08:32 +0400 (MSD) Subject: Python cgi In-Reply-To: <9g5cv7$um$1@ryu.it> Message-ID: On Wed, 13 Jun 2001, Ryujin wrote: > Does anybody knows any site offering free web space with Python cgi support? hobbiton.org - Python, Perl, shell (telnet/ssh), gcc, no outgoing TCP/IP connections; 25 megs free + 10 megs for mail; MySQL for $10/year. Currently they have 1.5.2, I am going to ask they to upgrade. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From m.faassen at vet.uu.nl Sun Jun 24 10:02:32 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 24 Jun 2001 14:02:32 GMT Subject: What's object-oriented? References: Message-ID: <9h4rto$fmc$1@newshost.accu.uu.nl> zoodoo wrote: > What's the concept/logic behind object-orientation? What is it suppose to > mean? People noticed that good procedural programs often worked this way: * You have defined a bunch of data in a structure. In C, for instance this is a struct definition. In many languages these are called 'records'. * You have a bunch of functions that operate on this data. The program would then be composed of modules, each defining a data structure (or bunch of related ones) and the functions operating on them (creating them, changing them, querying information in them). Good procedural programs tend to look this way, because they're more modular and easier to understand and modify. (this type of modelling becomes especially obvious when you're writing a simulation or a game, but it is useful in many places). So, what we have here is data, and behavior, associated together. It's not hard to treat this as an object; an object can be seen to have attributes (data about it), and behavior (the functions/procedures). Now, many objects are similar in data and/or behavior (or at least aspects thereof). I can 'throw' a stick, but I can also 'throw' a rock. In procedural programming you can write a throw() function that works on both sticks and rocks, but it's a bit tricky: def throw(object): if object.type == "rock": ... do the rock throwing thing elif object.type == "stick": ... do the stick throwing thing and each time you add a new type of throwable object, you have to extend the throw() function this way, and all other functions that you may execute for both rocks and sticks and this new object as well. The solution of object oriented programming is called 'polymorphism', which is basically a trick which allows you to write a separate throw() function (but with the same name!) for each object. Then, if you throw() a rock, the rock's throw function (or method, as we call it in object oriented programming) is executed, but if you throw a stick or something new like a cat, the throw methods of these objects are called instead. Your program doesn't need to know what the object it's dealing with even is; it'll just try the throw() function and assumes that what this does is what should happen. This allows for some powerful abilities to create abstractions (which can increase flexibility and ease of understanding) in your program. There's also a thing in OO called 'inheritance' which can assist in all this; often two types of objects share the exact same behavior. Perhaps the same type of method (some parabola calculation perhaps) needs to be called needs to be called for calling rocks and for calling sticks. You can then use inheritance to make these objects share the same behavior. But, you could make an exception for cats; when they're thrown they'll scratch and yowl and turn in the air to come right back at you. :) This is just scratching the surface of what you can do with these concepts, but I hope it helps. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From jonas.b at home.se Wed Jun 20 13:54:50 2001 From: jonas.b at home.se (Jonas Bengtsson) Date: 20 Jun 2001 10:54:50 -0700 Subject: OOP in Python Message-ID: <4e2ddb70.0106200954.11faa218@posting.google.com> Ok I admit - I am a Python-newbie! What about local variables and class variables when dealing with classes? With local vars I mean temporaryly used variables in a function. Will they be treated as 'normal' instance attributes? Do I have to delete them by myself when I'm leaving a function? With class vars I mean if many class instances of a class may share a variable. In C++ this is accomplished by a static variable. How do I do in Python? Thanks in advance, Jonas B From max at alcyone.com Wed Jun 6 12:27:24 2001 From: max at alcyone.com (Erik Max Francis) Date: Wed, 06 Jun 2001 09:27:24 -0700 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3b1cdc84.5514@bolder.com.co.za> <9fleid$3rp$1@oslo-nntp.eunet.no> <3B1E4951.7F36D4E4@alcyone.com> <3B1E50E1.35AE59C@lmf.ericsson.se> <3B1E52DA.BBC9FC32@alcyone.com> <3B1E580E.D3EE577B@lmf.ericsson.se> Message-ID: <3B1E59EC.2F19C2E0@alcyone.com> Attila Feher wrote: > Having a bad day? Where did you see me writing this??? I _do_ buy > the > games (and then my GF plays them :-((( ), what I have told is that > those > guys I have seen _rarely_ buy the games. Very rarely. Now U can also > pay attention to little nuances like this :-))), which is meant > showing: > no attack etc. BTW the chances that I know enough programmers to make > a > representative selection is very low. So undertstanding what I write > the way you did is plain evil. If you know that your friends are an extremely atypical set, why did you mention it at all, except as an attempt to generalize? I'm "evil" because you made a blatantly sweeping overgeneralization and I called it out? Yeah, that makes sense. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ We're the stars on Earth \__/ Des'ree Alcyone Systems' Daily Planet / http://www.alcyone.com/planet.html A new, virtual planet, every day. From emile at fenx.com Thu Jun 14 00:33:24 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 13 Jun 2001 21:33:24 -0700 Subject: VI References: Message-ID: <9g9f1v$7oqr5$1@ID-11957.news.dfncis.de> I always liked the description that vi has two modes: one beeps at you, and the other destroys your file. ;-) Actually, I use it daily. I'd just prefer something (oh, ok, _anything_) else. -- Emile van Sebille emile at fenx.com --------- "William Park" wrote in message news:mailman.992457560.24310.python-list at python.org... > On Wed, Jun 13, 2001 at 11:28:55AM +0000, Pilgrim wrote: > > Can someone tell me what "vi" is for a text editor to work with python? > > My goodness, how do we answer this. 'vi' is visual screen editor which > superseded a line editor called 'ed'. There are many flavours, but > 'vim' is the best. > > The main distinquishing features for beginners are that 'vi' has many > command modes, so that keys do different things depending on which mode > you are in. In "insert" mode, you type as normally; in "command" mode, > you move about using normal ASCII keystrokes; so on. ESC/Ctrl keys are > used only in special cases. > > In comparison, other editors are always in "insert" mode, so that you > have to press ESC- or Ctrl- key sequences for editing commands since > normal ASCII keys simply go into the file. > > > Where can I get this? > > > > -- > William Park, Open Geometry Consulting, > 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. > From piotr at ak-studio.com.pl Fri Jun 15 11:55:51 2001 From: piotr at ak-studio.com.pl (Piotr Waskiewicz) Date: Fri, 15 Jun 2001 17:55:51 +0200 Subject: Curses question References: <1462444.zMo0RvPX7a@mysiu-pysiu> <3d7kyff75v.fsf@ute.cnri.reston.va.us> Message-ID: <3B2A3007.7EB3A68F@ak-studio.com.pl> Andrew Kuchling wrote: > > Can I resize curses windows without destroying them? > > Or is there bind to curses wresize()? > > In 2.x, Window objects have a resize() method if it's supported by the > curses library. Note that wresize() may be an ncurses extension. > Several SYSV curses implementations don't have a wresize() function, > so the method isn't supported there; Solaris, IRIX and Tru64 are the > relevant platforms here. > Thanks! But I can't find any info about this method, and xxx.resize.__doc__ returns None :( Can you point me to any info about this method? TIA again :) From sholden at holdenweb.com Mon Jun 11 06:53:41 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 11 Jun 2001 06:53:41 -0400 Subject: return from finally clause References: <9fr8u3$gj9$01$1@news.t-online.com> <9frdgk$pnd$1@news.mathworks.com> Message-ID: "D-Man" wrote in message news:mailman.992098154.29963.python-list at python.org... > On Fri, Jun 08, 2001 at 09:16:43PM -0400, Steve Holden wrote: > | "Joshua Marshall" wrote in message > | news:9frdgk$pnd$1 at news.mathworks.com... > | > "J?rgen Hermann" wrote: > | > > | > > That means that if you (accidently?) return within a finally clause, you > | > > effectively eat the exception. This should be documented, or fixed. > | > > | > That's unpleasant. I hope it's a bug. > | > > | Well, I think we can agree that there's a certain inconsistency in > | returning from a function with an exception active like that. So most of all > | it's a programming error. What action would be best? Raise another exception > | when the "return" is executed? > > There is no exception acvite -- you have handled it and now want to > return a value instead of propagating the exception. > Just to pick a nit, the finally clause is being executed in the context of a current exception, and if it hadn't altered the flow of control by executing a return the interpreter's action would have been to automatically re-raise the same exception at the end of the finally suite. This differs from the case where the finally clause is executed after the try suite when no exception has been raised. Hence my mention of an exception "being active". regards Steve regards Steve From davygrvy at pobox.com Thu Jun 14 10:48:50 2001 From: davygrvy at pobox.com (David Gravereaux) Date: Thu, 14 Jun 2001 07:48:50 -0700 Subject: when embedding Python, how do you redirect stdout/stderr? Message-ID: Hi all, The subject says it all. I'm embedding (or trying) and want to have all std traffic sent to a custom textbox in a windows GUI. Is there anyway to do this? A good place for examples for me to read? I played around a little bit with this, but need a more stream'ish way: output = PycStringIO->NewOutput(1024); /* capture all interpreter error output */ PySys_SetObject("stderr", output); /* so that error is printed on standard error, redirected above */ PyErr_Print(); message = PycStringIO->cgetvalue(output); string = PyString_AsString(message); length = PyString_Size(message); I've since updated the exception getting part, so I don't have to redirect, but I do need to have the std traffic now go somewhere. Any ideas? -- David Gravereaux -=[ Ray's Famous and Truly the Original Pizza, NYC ]=- From akuchlin at mems-exchange.org Thu Jun 28 14:23:17 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 28 Jun 2001 14:23:17 -0400 Subject: PEP scepticism References: <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> Message-ID: <3dhex01n1m.fsf@ute.cnri.reston.va.us> bernhard at intevation.de (Bernhard Reiter) writes: > I agree as a python programmer (which I meant by "python user" btw). > There are important additions (e.g. unicode) and the language > has to be maintained. It's also a matter of where effort is expended for the most benefit. The new features such as static scoping, list comprehensions, &c., are nice to have and I'm pleased that the list of language shortcomings is shrinking. But would I rather have had list comprehensions or a catalog of all Python extensions similar to CPAN? I'd have much preferred the latter, because it would make a greater improvement in my programming life than, say, list comprehensions do. This doesn't imply that list comprehensions don't improve my life at all (they do), but I've noticed that in online forums, people now rarely beat up on Python for the language itself, except for the old reliable indentation knee-jerk reaction. Instead people write about how convenient CPAN makes it to find modules, or how useful the XML modules are, or how EJB lets them write elaborate business systems. I don't think improving Python the language will win new converts at this point; improving the standard library, development environments, or the documentation is more likely to bear fruit. --amk From new_name at mit.edu Fri Jun 1 19:26:42 2001 From: new_name at mit.edu (Alex) Date: 01 Jun 2001 19:26:42 -0400 Subject: docstrings, invention there of References: Message-ID: What do you use the cat > /dev/null window for? Typing practice? Alex. From m.faassen at vet.uu.nl Wed Jun 20 18:09:24 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 20 Jun 2001 22:09:24 GMT Subject: call-by-reference (was Re: Any other Python flaws?) References: <9gcu9g$gm4$1@newshost.accu.uu.nl> <9gd4tq$odb$1@news.mathworks.com> <9gdn37$61k$3@newshost.accu.uu.nl> <9gdt4j$b86$1@news.mathworks.com> <9gdtiu$61u$1@newshost.accu.uu.nl> <3B2FF5AB.E5181BC5@my.signature> Message-ID: <9gr6uk$hhq$1@newshost.accu.uu.nl> Greg Ewing wrote: > Martijn Faassen wrote: >> >> I think the use of the word 'variable' is ambiguous. :) > In Python it's clearer to talk about "names" and "bindings" > rather than "variables" and "values". Sure, which is what I usually do. (or references) > The statement then becomes "you can't change the binding > of a name in your caller's namespace", which doesn't > leave much room for misunderstanding. Agreed. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From tgos at spamcop.net Mon Jun 4 22:30:04 2001 From: tgos at spamcop.net (TGOS) Date: 4 Jun 2001 21:30:04 -0500 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3B1B1825.8109BA83@lmf.ericsson.se> Message-ID: <2v4ohtgldvce84sn87kh1eg1lnes37getq@4ax.com> On Mon, 04 Jun 2001 08:09:57 +0300, Attila Feher wrote: > TGOS wrote: >>> Just to inform you: the worlds easiest to hack and crack systems are the >>> UNIX systems. >> >> That's absolutely incorrect. > > That is _absolutely_ correct. There is no system like unices, full with > security holes. Look, I'm no cracker. I have very little knowledge about how to corrupt a system, but on my university I'm trying to get root rights for two years now, without anything even close to success. On a WinNT system of a company (for that I was doing some network installation is part time job), it took me less than 24h. > Crackers _does_ start on unices, the easiest to crack > systems. All crackers I know started with Windows, because they say that hacking a private Windows system is a lot more interesting than getting access to most UNIX systems. Especially when hacking Win9x, as once you are in, there are no security mechanisms anymore. If you take a look at hacker-pages on the WEB, you'll get hundreds of tools that corrupt Windows systems (DoS, Nukers, password file cracker, backdoor access software, etc.) and not even a handful of those tools for UNIX. IOW everyone can crack a Windows system (even people who don't have the knowledge), because there are easy to use tools that will do all the work for you. > If you think they start on VMS, you are alone. So are you trying to say that VMS is so secure because it's an unknown system? Could it be the case, that VMS isn't as secure as you (and many other people believe) and it's just doesn't get hacked because there are way too little hackers who try it? How secure a system really is will only get proved if there are thousands of hacker who try to hack it daily. Since that seems not to be the case for VMS, you can't make any predictions regarding its security Despite that, I certainly won't claim that UNIX is more secure than VMS, since I don't know enough about this system. If VMS main goal during development was to make it as secure as possible, it's most likely more secure than UNIX, Windows, Linux and some other systems. Therefor I'm sure it has other disadvantages. > The Unix systems are _designed_ to be wide open. Usenet was designed for text messages, but it gets used for binary exchange as well. In reality it plays no role for what something was designed, but rather for it is used. There are thousands of examples where things are used for completely different purpose than for what they got designed. > So you _do_ need an expert to close them. I see, something we can both agree to. And those experts are named "UNIX system administrator". Who is hiring a UNIX system admin without the necessary qualification has a problem, that's no secret. > Not such with VMS. I don't know why you always have to mention VMS (probably you are working for Compaq), but this discussion isn't about which system is more secure, it's about cross-platform solutions versus single system solutions. Despite that, since POSIX was added to VMS, it became a lot similar to UNIX and there's even a GNU project for VMS. > Creating a perfectly secured Unix system is equally extremely hard. Never said it is easy, but in case of Windows it's sometimes impossible. > It is not enough on Windows NT to be an ordinary user to do a crack. I only was an ordinary user, which was enough to run a crack. > You don't even seem to know the diff between hack and crack... | A hacker is a clever programmer. A "good hack" is a clever solution to | a programming problem and "hacking" is the act of doing it. - Source: "The New Hacker's Dictionary" To hack a system means to | A cracker is someone who breaks into someone else's computer system, | often on a network; bypasses passwords or licenses in computer programs; | or in other ways intentionally breaches computer security. - Source: "Whatis.com" But in IMHO that's not quite correct. Hackers also break into computer system, just without malicious intentions and without doing any harm to that system. Hackers are often confused with crackers. Uninformed users usually use "hacking a system" as synonym for breaking into a system from an external source (via network) and "cracking a system" as synonym for manipulating software on that system or circumventing security mechanism within the system. But in fact that's not really correct. Actually both is cracking. > And on (a well secured) NT it is not enough to get in as an > ordinary user to crack it. Same as with Unix. :-) But the problem is that the majority of WinNT system are a lot less secured than UNIX system, simply because everyone can administrate a WinNT system (or at least everyone believes that). And when there's a problem with some software on your WinNT system (e.g. third party software), you don't have to possibility to look at the source code, fix it and then recompile it. Not to mention that the user right settings are very problematic on WinNT. In a really secure system, users don't have enough rights for most tasks what leads to problems (as I was once told by a company: "We can't use WinNT, because then we would have to give all users full access and that would destroy any security concept. Without that all software would have to get rewritten."). > Not really. Windows code is seen by thousands before release. The fact > you were not invited to this circle of privileged non-MS people does not > mean it does not exist. But that's exactly the problem: MS choose a few privileged who can see their code (and they aren't allowed to edit it, just having a look!). Despite that this isn't valid for all their code. So the quality of this "code viewing" depends a lot on "who MS chooses" and how many. I still say that more people see UNIX code than MS code (I won't even mention LINUX here, what is seen even by normal users). And the people who are really interesting (hackers and crackers) will not be able to inspect the code of Micro$oft and point out possible problems. > You put it as a favour to UNIX! I'm not in favor for UNIX. I say that UNIX is better than Windows in many cases, but I don't say that it's perfect. I personally am no defender of the idea that the whole word shall start using UNIX, I only pointed out that a lot of people are using UNIX right now. > Implying that UNIX is. Never argue on the base of what people might imply, you can only argue on the base of what they are saying. >> PLEASE, don't put words into my mouth that I never used! >> I suggest you read my post a second time. > > Don't be a politician!!! You know if I start defend UNIX based on that > Windows _is_not_ secure (WHICH ONE?????) than people automatically think > UNIX is. What people think and what I say are two pair of shoes. > You imply that Unices are used in banks and secure places > which is not true either, at least not for most. I never said so. Not in this post and not in my last two posts. To repeat myself: I only said that Windows is NOT used there. > Yes. Your whole post was a defense of Unix (Linux) with comments about > why Windows is bad. My post wasn't a defense of UNIX. My post was just pointing out that plenty of people don't use Windows and they have good reasons why they don't use it. > BTW I have not seen any airport where the terminals were non-Windows... Yes and wanna bet that I can find someone who can crack such a terminal in less than two hours. I bet if this terminal would run with Linux or maybe with FreeBSD that wouldn't be that easy. The terminals at central station also run with Windows and guess how many pictures I've already seen where those terminals show a "blue screen"? One of my friends is working in a computer company, which are offering and they run a WinNT web server and he told me that it crashes at least once a month, usually more often. The Solaris server at our university is now running for years and it never crashed even once. It only was rebooted to add new hardware. >> And speaking about cross-platform development: >> OS/2 is a very good Java platform. I don't know anything about VMS, but it's >> certainly not impossible to port a Java Virtual Machine for this system as >> well. > > No. And I guess it exists. And I guess it is a security risk as all > Java VMs are. If VMS is really as secure as you always say, it should be no problem to limit access rights of the JVM via system configuration in such a way that it can't cause any damage to the system. Despite that you can also write your own Security Manager for Java and that way further limit access rights. >> Again, I never said that UNIX is used in all the places you described above. > > You implied. I did not, I just said Windows ins't used there. >> I never did that, you are currently doing that because you assume ... well, I >> have no idea what you are assuming. > > What your post was about. :-) My post is about the fact that every user should be free to chouse his/her favorite OS according to his her personal needs and nobody should be forced to accept the flaws of a certain OS, just because some shit-head programmers left him/her no other choice. >>> And about Windows being a shit: Just try to look around and find a >>> portable async gethostbyname or a standard gethostbyname_r for >>> Unices... Good luck. BTW you can find numerous workarounds which fail >>> in numerous environments. > > > > And the fact that this function (which I personally have never needed up to > > now) doesn't exist on UNIX is the proof that Windows isn't shit? Funny, but > > that makes no sense to me. > > Did I say it exists in Windows? No. Did I? But I know that async gethoutbyname exists in Windows. (I'm doing my homework before replying to a post) > _If_ you never needed it how do you know by hearth it does > exists as a service in WinSock and does not in Unix??? You said "find [...] for Unices", so I went to Google and started searching for it. And I found an async version working with multiple threads for UNIX/Linux systems. But I'm sorry, I haven't bookmarked the link. >> 1) I never said that UNIX is better than Windows (correct me if you can!), I >> only said that Windows is unstable, insecure and not very well thought out. > > Just like Unix in general. UNIX is very stable (when not using BETA versions). A crashed thread usually won't take down the whole system, what happens pretty often in Windows (especially when a hardware driver crashes). Linux is even better here. I can even intentionally crash hardware drivers and the system survives it (as long as I don't crash drivers that the system needs to survive. And UNIX is very well though out, an easy concept that is strictly upheld. It's like a house build out of LEGO blocks, with clear data paths. Windows is rather like throwing all blocks into a back, shaking it twenty times and throwing them onto a table. Data paths are very unclear to normal users. I admit, you need more knowledge to be a UNIX admin than being a Windows admin (Windows hides its chaos behind a neat, easy to use GUI), but as UNIX admin you also have a lot more power over the system. And that makes Windows more insecure, because users often aren't able to see security holes until it's too late. >> 2) I never said that UNIX is secure, neither in my last post nor in this post. > > You implied There is no absolute security, it's always just relative. (How was that? "A PC is only secure when you cut all cables, lock it into a safe and sink it in the middle of the Atlantic.") > Yep, U R right in that. Only disadvantage is if your market size for > Win32 platforms is the 80% of your market and you spend too much time to > serve 15% of the rest (you will never have a fully PI SW) and so you > loose that whole 80%, too. If 20% of your other market is mainly using 4 other platforms and you aren't able to server all of them, you might have the wrong job. And your boss might also have the wrong job, because if I were your boss, I'd look form someone who's able to server 95% of the market. > All I was pointing out is that a Windows solution might cover 60-90% of > your existing market. Why? What are you developing that the Linux, OS/2, MacOS, BeOS, AIX, HP-UX, Solaris, BSD, FreeBSD and the users of over 50 other OSes aren't interested in? And how do you know, have you asked every single user on this planet? > Business logic can be portable easily. GUI.... maybe if it is HTML > based... Java itself runs on all those systems and it's offering enough elements for your GUI. Swing is offering enough elements to write your own MS Office. Only mouse wheel support is currently missing, but Java1.4 will also add mouse wheel support (right now I'm just playing around with the BETA version). Despite that, you can write 90% of your application in Java and then add the missing 10% via C++ or even native assembler code (for speed reasons or to add special OS features that Java doesn't support at the moment). That has the advantage that you always only need to rewrite 10% of your application for every new platform. And platforms you don't support directly can still use your application, in that case just without those special features or without the additional speed boost. For C++, try using Qt. It exists for: - AIX - BSDI/OS - DG/UX - HP-UX - Irix - Linux - OS/2 (but only with an installation of XFree86) - QNX - SCO UNIX - Solaris - Tru64 - Windows 95 - Windows 98 - Windows NT and 2000 I think there's even a Palmtop version, maybe other embedded systems will follow. This will make your GUI run-able on quite a lot of platforms in native speed, with lots of features (like "skin support"). The free version is of course limited (I think no 3D support, no network and IO libraries), but a company that plans to increase their market by 15% of users might as well pay for the commercial version. >> It means developing a base version that can run everywhere and then only >> fine-tune this base version for different systems. That's cross-platform >> development. > > There is no such thing. If you believe in that... Maybe for very > simple applications where it is enough to use what the GUI meant 10 > years ago. Nonsense. What kind of GUI element do you intent to use that Java doesn't support? Java has even build-in anti-aliasing, alpha transparency and texture support. Also build-in support for common picture formats and HTML rendering. That's additional to all the GUI elements Swing provides. Those are at least as many as you will find in Visual C++, if not even more: - Buttons - Borders - Boxes - CheckBoxes - ColorChooser - ComboBoxes - DialogBoxes - InternalFrames - Labels - Lists - Menus - Panels - PopupMenus - ProgressBars - RadioButtons - ScrollBars - Seperators - SlideBars - Tables - TextAreas - TextFields - TextPanes - ToolBars - Trees - Windows Also the predefined Windows exist, like FileChooser, as well as some other I forgot to mention and non-GUI stuff (like Timers). And every element currently exist in three versions (Windows, Metal and Motif ... others like Macintosh may follow in future Swing versions) and you can switch between those different versions on the fly and even implement own versions, e.g. simply use a picture for every element (so your applet can have a full skin support). >> To get back to your question: Would the casino SW developers also survive when >> creating software that can run on Windows, Linux, Solaris, Irix and OS/2? >> Certainly! Maybe even better than they are doing right now. > > Certainly not. They would be about to finish the first beta version of > their SW, when the market is already shared between the players. For what a C++ programmer needs 3 hours is done in one hour by a Java programmer, not to mention that Java is more than 200% easier to debug in case of errors. Don't forget you can use Java also server side and there you are free to use the latest version of it. You are even allowed to bundle a JRE (Java Runtime Environment) with your Java application, meaning the target PC doesn't even need to have an installation of Java. And depending on task, other programming languages are even more efficient than Java. A single line of code in some programming languages will do more than 20 lines of Java, which usually are better than 60 lines of C++. > Why not? Because the market compared to the Windows one (depending on > your area) might be too small or too far to be worth the effort. Same > thing can happen for areas where Windows users have no need but Unix > users/systems. Look: China, one billion people. Computer shops in China sell Linux 200 times more often than Windows. The Chinese government plans to increase the usage of Linux even more (they don't trust Micro$oft, open source rules, as they can make sure there's no spyware inside). BTW downloaded distributions aren't counted here. You must watch beyond your limited horizon or one day this attitude will break your neck (or the neck of your company). Others will jump into that gap and then they will have the market you never had as well as parts of the market you _do_ have. If you only want to provide your software *locally* you are limited your market in two ways (only users of a certain OS and only within one area). What's next? Only users with a specific first name? To not loose the topic (as I think you are completely losing the point of this discussion), take a look at the subject of this post: "3D manipulation over web" Over web means inside a webpage, IOW inside the browser. So either within a plugin, server-side or Java. Why should 3d access "over web" to a database be limited to x86 or Windows users? Why can't it be for everyone? Why aren't people in China allowed to use it? Because you believe that you can save 5 minutes through a win-only solution (what is not even true)? > Online application is not necessarily "within the browser". "Withing > the browser" is Java, ActiveX or C# or goodbye. C# ???? My browser doesn't run C#, not even my system as a whole can run C#. No system which I ever was using during my whole life was able to run C# up to now. And ActiveX...come on, ActiveX is the same as installing a browser plug-in, there's no difference (there is for the programmer, but not for the user). So you can as well use any other kind of plug-in. > Java is still a very unstable Hasn't crashed my PC a single time and I use it daily. I currently develop exclusively in Java and my programming IDE is written itself in Java. Everything always runs fine and I have no idea what you mean by unstable. > and unsecure stuff where VMs are incompatible etc. VMs aren't incompatible in general (leaving bugs aside). I always test my software on at least 5 different platforms and never ran into a single problem. > ActiveX is Windows only. ActiveX means that the browser downloads and installs a plug-in which then is controlled by script code within the page. Then you can as well offer a real plug-in and you can write that for more than one platform (Flash exists for UNIX, Linux and MacOS for example). But of course Java will save you a lot of work here. >> The cross-platform solution is there, all you need to do is using it! > > I have been working together with _the_ Java evangelist of Hungary, who > was been using, promoting, supporting Java, making large systems for all > the years Java existed. If you believe in effortless Java code > portability, you did not work enough with Java... esp. between different > VMs. All Java code that I was using up to now did at least run on: Win98, WinNT, Linux, Solaris and Irix. (I don't have access to more platforms, otherwise I would test it on those platforms as well) If it will work in a cell phone with Java support is questionable, but such already a way too specific devices. A set top box for your TV will maybe not have a problem if it supports the correct Java version. But better supporting only a few platforms (5 to 10) than supporting only a single platform. You will never be able to support every platform that exists, but limiting your solution to a single platform right from the start (for reasons that you weren't even able to make clear up to now) is certainly no good approach towards a solution. -- TGOS From uioziaremwpl at spammotel.com Fri Jun 22 11:34:35 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Fri, 22 Jun 2001 17:34:35 +0200 (CEST) Subject: PEP 255: Simple Generators Message-ID: On 20 Jun 2001, David Bolen wrote: > "Rainer Deyke" writes: [snip] > > If generators absolutely have to reuse syntax (which is not the > > case), I would prefer the keyword 'class' over 'def', since calling a > > generator creates an instance. > > But so does any number of factory functions that return objects (form > closures, etc...), e.g.: > > def f(): > return UserList.UserList([1,2,3]) > > (using UserList to avoid the type/class question) > > So do we need different syntax for all types of functions that might > return instances of some object? Eventually this could devolve into > the point elsewhere in the thread of wanting defint rather than def > for functions returning an integer. This argument makes no sense. Let us look at class definitions and how to create an instance: class Test: def __init__(self): ... test = Test() So Test is called like a function and returns an instance. But why make a different syntax ("class") for defining it? Just because it returns an instance instead an integer or another object? According to your argument, "def" would be fine. We would just have to insert a magic class statement somewhere, flagging the definition as a class definition (just as yield flags a generator definition). Another problem: Generator definitions are nothing like function definitions. With the same argument (also raised by Tim), that it looks like a function from the caller's POV (like a class), is not sufficient to define it with "def". Because it does not have a "return" statement, which returns the iterator. And that's the difference to any regular function, also to any factory function, because they include an explicit "return" statement. Cheers, Carsten -- Carsten Geckeler From mwh at python.net Mon Jun 18 11:22:19 2001 From: mwh at python.net (Michael Hudson) Date: 18 Jun 2001 16:22:19 +0100 Subject: forcing python to build a static libpython2.1.a References: <878ziqjx46.fsf@speeder.org> Message-ID: Roman Milner writes: > >>>>> "MH" == Michael Hudson writes: > > MH> Roman Milner writes: > >> Is there an easy way to have the build process disable dynamic > >> loading? I just want a plain old static libpython2.1.a. > >> > MH> I think the most efficuient way to do what you want is to > MH> uncomment the modules you want to build statically in > MH> Modules/Setup. Read the comments in the top of > MH> Modules/Setup.dist in the source distribution for more info. > > That doesn't seem to achieve what I want. What you suggest will build > the chosen modules statically into the python executable binary. What > I need is a static libpython2.1.a that I can link against other > things. But building python in this way produces a libpython2.1.a that contains all the symbosl you need, doesn't it? The final build command is only gcc -Xlinker -export-dynamic -o python \ Modules/python.o \ libpython2.2.a -lpthread -ldl -lutil -lm after all. Cheers, M. -- This is not to say C++ = bad, Lisp = good. It's to say C++ = bad irrespective of everything else. -- Alain Picard, comp.lang.lisp From info at itma-uk.org Thu Jun 7 12:13:20 2001 From: info at itma-uk.org (=?Big5?B?sU23fr7Ht3ytXrDqpGq+xw==?=) Date: Fri, 8 Jun 2001 00:13:20 +0800 Subject: =?Big5?B?uNu4db3StXuxwLxzrfs=?= Message-ID: <9fo91e$4qd8312@rain.i-cable.com> ?M?~???|???^???j?? ???u???{???s???A???????H?W?{?? ???????????~???w???????i ?????u?p?A???N???q???????????????? Sunny Cheung ?? _____________________________________________________________ This message posted with trial version of Express News Poster From johnroth at ameritech.net Sun Jun 10 18:10:55 2001 From: johnroth at ameritech.net (John Roth) Date: Sun, 10 Jun 2001 15:10:55 -0700 Subject: New guy question References: Message-ID: "Glen Mettler" wrote in message news:DfKU6.130092$I5.33794657 at news1.rdc1.tn.home.com... > OK...I went back to the beginning and discovered that the author of the > tutorial showed me three windows. > One with a black background that he described as the Python prompt (>>>) > (title is Python) > One with a white background that he described as IDLE - also with a Python > prompt (title is Python Shell) > One with a black background that he described as the "command" window that > in fact is the DOS window (title MS DOS Prompt) > > I went to the MS DOS Prompt ("Command") and typed in python alook.py and got > an error message: Bad command or file name. > > > "Glen Mettler" wrote in message > news:TiyU6.127784$I5.32725119 at news1.rdc1.tn.home.com... This means that Python is not in your path - in other words, Windows can't find out where the program is located. The advice you've gotten up to now is pretty good, but I don't recommend changing Autoexec.bat unless you know what you're doing. It's too easy to drop a semicolon and screw up your system to where it won't boot. In addition, I'm told that Autoexec.bat is ignored on Windows ME (I'm not certain about that, I've never upgraded.) What I'm doing looks a bit more complicated, but it works (something that is always recommended.) 1. Copy an MS-Dos icon into the directory with your test programs. 2. Create a new .txt file there. 3. Put one line in it: path=%path%;c:\python21\bin spelled exactly like that, no spaces. If your Python21 directory is somewhere else, you'll have to change it. 4. change the file type from .txt to .bat 5. Right-click on the Dos icon and select Properties. Make certain it does not specify "close on exit." Also make certain that the working directory box specifies the directory with your Python program. 6. When you want to run a command line, double click on this command icon. It should show you the directory you're working in. 7. type .bat (whatever you named your command file.) That should show you the new path. Even if you make a mistake, it won't affect anything else. The change is completely local to the dos box. 8. type python alook.py That should get you into your program properly. I grant you, this looks messy, and I wish there was an easier way, but this works. John Roth From emile at fenx.com Tue Jun 26 10:12:54 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 26 Jun 2001 07:12:54 -0700 Subject: 'with' statement in python ? References: Message-ID: <9ha5h5$cn58u$1@ID-11957.news.dfncis.de> class test: def __init__(self, ln, wd): with self: ln = ln * 25.4 # keep in mm wd = wd * 25.4 area = ln * wd How could this be sorted out? -- Emile van Sebille emile at fenx.com --------- "Carlos Ribeiro" wrote in message news:mailman.993562981.5640.python-list at python.org... > At 11:49 26/06/01 +0000, Maciej Pilichowski wrote: > >I have just started learning Python yesterday but... > > > > >def with_is_broken(a): > > > with a: > > > print x > > > > > >The snippet above assume that "a" must have a member attribute called "x". > > > >Nope. As you referred to Pascal -- if "a" has a member "x" it is read > >as "a.x", if not it is standalone "x". > > There must be some misunderstanding here. My snippet (incomplete, as I > pointed out) assumed that Python had a "with" keyword, just to show the > kind of problems that arise. In Python, the compiler/interpreter has no way > to tell beforehand if x is a member of a, a local variable, a module level > variable, or a global variable. This ambiguity makes the use of with in > Python impossible. > > Now, let us take a look at the "with" block in Pascal: > > with a do > writeln(x); > > The compiler knows in advance everything about "a". If "a" does define a > member called "x", then writeln() will reference "a.x". If "x" is not a > member of "a", then the compiler will recursively search on the outer > namespaces until it finds a definition for "x". If it does not find, it > will stop - it is a fatal error, caught at compile time. > > > > Carlos Ribeiro > > > From michael+gnus at trollope.org Fri Jun 22 10:18:19 2001 From: michael+gnus at trollope.org (Michael Powe) Date: 22 Jun 2001 07:18:19 -0700 Subject: Another Wart! string.find() [ was: namespace issue? ] References: <9gucf9$ruc$1@slb3.atl.mindspring.net> Message-ID: >>>>> "Andrew" == Andrew Dalke writes: Andrew> Steven D. Majewski wrote: >> It probably *ought* to return None for not found: >> "string"[None] yields an exception: "TypeError: sequence index >> must be integer" while "string"[-1] returns "g" so a coding >> error is likely to slip thru without an exception. >> I'ld love to see it fixed, however, I suspect that in this >> case, many lines of installed code trumps Computer Programming >> for Everybody! >>>> print string.find.__doc__ Andrew> find(s, sub [,start [,end]]) -> in Andrew> Return the lowest index in s where substring sub is found, Andrew> such that sub is contained within s[start,end]. Optional Andrew> arguments start and end are interpreted as in slice Andrew> notation. Andrew> Return -1 on failure. >>>> print string.index.__doc__ Andrew> index(s, sub [,start [,end]]) -> int Andrew> Return the lowest index in s where substring sub is Andrew> found, such that sub is contained within s[start,end]. Andrew> Optional arguments start and end are interpreted as in Andrew> slice notation. Andrew> Raise ValueError if not found. Pardon the dumb question, but can you test this in a conditional, as in if not string.index(s,sub) : /* and so forth and so on */ mp From qrczak at knm.org.pl Mon Jun 4 11:55:53 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 4 Jun 2001 15:55:53 GMT Subject: Why no 'elif' in try/except? References: <3B1A06EE.F484930A@snakefarm.org> <3B1A29DE.9876770D@accessforall.nl> Message-ID: Sun, 3 Jun 2001 22:15:23 -0700, John Roth pisze: > Mixing the two makes no sense. In an except clause, there is no > result to test; in an else clause, there is. Is the elif supposed > to execute when there are exceptions, or when there aren't? Of course it would mean the same as 'else: if', without forcing another level of indentation. > If it's simply an extension to the else clause, then I suppose > it doesn't harm anything, but it adds complexity to the language > definition. At this point in my life, I tend to agree with Einstein - > make everything as simple as possible, but no simpler. Ok, so why elif exists in the first place at all? It's redundant. It can be replaced by 'else: if' and more indents. Answer: convenience, to avoid those indents. I don't understand only one thing. Why it is spelled 'elif' and not 'else if'? -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From sandorlevi at yahoo.com Fri Jun 22 04:35:23 2001 From: sandorlevi at yahoo.com (Levente Sandor) Date: Fri, 22 Jun 2001 01:35:23 -0700 Subject: need help with pythonpath References: Message-ID: <3b33039a.9482954@news.unbc.ca> On Thu, 21 Jun 2001 20:22:38 -0500, "NJM" wrote: >I'm probably over looking something obvious, but I'm not able to modify my >pythonpath. I've tried it every way I can think of with no results. > >I'm on a Win 98 machine > >Can any one help?? > > It can be accessed by sys.path. It's a list so it can be modified though the list operations append, insert, extend, remove etc. See section 2.1.5.4 in the Python Documentation. Example: import sys print sys.path sys.path.append("c:\\myfolder") print sys.path Levi From aleaxit at yahoo.com Sat Jun 2 15:16:00 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 2 Jun 2001 21:16:00 +0200 Subject: iterating over lists References: <1rsnhinct5.fsf@video.bsd.uchicago.edu> Message-ID: <9fbdup01slg@enews2.newsguy.com> "John Hunter" wrote in message news:1rsnhinct5.fsf at video.bsd.uchicago.edu... > I have three lists of equal size: list1, list2 and list3. > > What I want but doesn't work: > > for (x1, x2, x3) in (list1, list2, list3): > print x1, x2, x3 It does work, just doesn't do what you want: it's the same as print list1, list2, list3 Note, btw, that all the parentheses you use in this example are redundant. I think you'd be better off in terms of clarity and readability if you did not use parentheses in this case. > I know I can do it by keeping a index count variable: > > N = len(list1) > for i in range(1,N): > print list1[i], list2[i], list3[i] Almost! you'd better make the range(0,N) or you'll miss out on the first item of each list. > but am wondering if there is way to create a tuple of named variables > as in the (x1, x2, x3) example above. Most likely what you want is: for x1, x2, x3 in zip(list1, list2, list3): print x1, x2, x3 which gives you as many print statements as there are items in the SHORTEST list (doesn't matter if the lists are all the same length, of course). A slightly more obscure alternative: for x1, x2, x3 in map(None, list1, list2, list3): print x1, x2, x3 gives you as many print statements as there are items in the LONGEST list instead, the shorter ones being virtually padded with copies of None. > One final question: If I do: > > for i in range( 1, len(list1) ): > print list1[i], list2[i], list3[i] > > I assume the len(list1) call will only be evaluated once. Is this > correct? Yes, definitely. More generally, "for i in " only evaluates the expression once (before binding or rebinding i, but that's only relevant if uses i:-). Alex From mmueller at dgfz.de Mon Jun 11 04:26:22 2001 From: mmueller at dgfz.de (=?ISO-8859-1?Q?Mike_M=FCller?=) Date: 11 Jun 2001 01:26:22 -0700 Subject: Error connecting to COMServer References: Message-ID: <7049ba55.0106110026.3eca3424@posting.google.com> Stefan Migowsky wrote in message news:... > As you see from the makepy code the ProgId you must use is > "Adder.AddingMachine.1.0". The developer of the COM server > seems not to give a version independent Prog ID. > > So you should use : > >>>from win32com.client import Dispatch > >>>a = Dispatch("Adder.AddingMachine.1.0") > > Changing the interface in the wizard to "dual interface" (IUnkown and IDispatch) does the trick. Now it works as expected. >>> from win32com.client import Dispatch >>> a = Dispatch("Adder.AddingMachine") >>> a >>> a.GetValue() 0.0 >>> a.Add(20) >>> a.GetValue() 20.0 >>> a.Clear() >>> a.GetValue() 0.0 Before obviously only the IUnkown interface was created. (-> Don't blindly follow all the instruction of a wizard for creating a toy example.) Thanks again. Mike From MarkH at ActiveState.com Mon Jun 11 03:21:24 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Mon, 11 Jun 2001 07:21:24 GMT Subject: Error connecting to COMServer References: <7049ba55.0106080434.1bcbc8d2@posting.google.com> <3B21C08F.8080905@ActiveState.com> <7049ba55.0106102135.51a2ef0@posting.google.com> Message-ID: <3B24719A.6050307@ActiveState.com> Mike M?ller wrote: > The wizard that took me through the creation process says > Adder.AddingMachine is the ProgID > and > AddingMachine is the short name. Oh well :) Unfortunately, it appears that this object does not support IDispatch. Therefore it can not be used by Python. Later versions of win32com could probably implement that interface, but not call it :( Now we have the basic technology in place tho I really want to update the COM support to be able to work with this... But given the stuff on my plate, I wouldn't hold your breath :( Mark. From m.faassen at vet.uu.nl Fri Jun 15 15:15:17 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 15 Jun 2001 19:15:17 GMT Subject: Any other Python flaws? References: <9gcu9g$gm4$1@newshost.accu.uu.nl> Message-ID: <9gdms5$61k$2@newshost.accu.uu.nl> Mattias Engdeg?rd wrote: > In <9gcu9g$gm4$1 at newshost.accu.uu.nl> m.faassen at vet.uu.nl (Martijn Faassen) writes: >>I agree that nobody agrees on whatever 'call-by-reference' means, or what >>'call-by-value' means. I mean, I'm here confused why you'd say C++ doesn't >>support call-by-value while Python apparently does. :) > I didn't mean to say that C++ doesn't support call-by-value, but that it > also has call-by-reference. Sorry, bad typing. Let's not go into the discussion. I know the semantics of C++ and I know the semantics of Python, but I don't what semantics you're calling 'call-by-foo' and which you're calling 'call-by-bar'. :) > This is the first time I have seen any disagreement of what call-by-{value, > reference, name} means since these are fairly standard terms used for > decades, but I'm not going to argue further about it Oh, well, look up a thread in groups.google.com. Nobody was agreeing on it. Decades-old books were referenced, but that didn't seem to give some conclusive evidence either. :) > In any case this is has no bearing on any Python flaws (on the contrary, I > find its argument passing mechanism quite reasonable and better than the > explicit-dereferencing that Perl does) so it's very tangential to the > subject I agree Python's argument passing mechanism is nice, whatever we'll call it. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From Daniel.Kinnaer at Advalvas.be Mon Jun 11 14:07:32 2001 From: Daniel.Kinnaer at Advalvas.be (Daniel) Date: Mon, 11 Jun 2001 20:07:32 +0200 Subject: What "Tim Peters" really looks like References: <3B24AB8B.7000507@ActiveState.com> Message-ID: <062ait47om7f82vgpljf4k7s88jv3d8aps@4ax.com> On Mon, 11 Jun 2001 11:28:37 GMT, Mark Hammond wrote: >I-can-see-a-new-tshirt ly, > >Mark. Yes, I want one as well! Daniel From christian at rocketnetwork.com Thu Jun 21 00:21:15 2001 From: christian at rocketnetwork.com (Christian Reyes) Date: Wed, 20 Jun 2001 21:21:15 -0700 Subject: explicitly close an application in windows Message-ID: <9grsp1$s0i$1@bob.news.rcn.net> Is there a method that one can use to explicitly close an application in windows? tia, christian From emile at fenx.com Sun Jun 24 13:42:39 2001 From: emile at fenx.com (Emile van Sebille) Date: Sun, 24 Jun 2001 10:42:39 -0700 Subject: Is this a true statement? References: <3b34939b.410758@nntp.sprynet.com> <3b35ebc3.1024709@nntp.sprynet.com> <9h516e$c2a4d$1@ID-11957.news.dfncis.de> <3b3611b0.10735139@nntp.sprynet.com> Message-ID: <9h5926$c7bg6$1@ID-11957.news.dfncis.de> "David C. Ullrich" wrote in message news:3b3611b0.10735139 at nntp.sprynet.com... > On Sun, 24 Jun 2001 08:28:25 -0700, "Emile van Sebille" > wrote: > > > > >"David C. Ullrich" wrote in message > >news:3b35ebc3.1024709 at nntp.sprynet.com... > >> Seriously. _Is_ a "device driver" something other than a file? > >> If it _is_ something other than a file I wish someone would > >> say so. If a device driver is just a file then I don't see > >> how the OS can possibly know or care how that file was > >> generated. > >> > >> > > > >Of course not. And of course a file can be written by python that the os > >can subsequently use as a device driver. To do so, you will have written > >both a compile-to-bytes program and a device-driver-source file intended to > >be consumed by the compiler piece. > > That's what I thought. Seems clear. Makes it hard to see how the > statement "you cannot write a device driver in Python" can > be correct. > > > When this result is invoked by the os, > >it will not be a python program running within the interpreter. > > And if you write a device driver in C then when that driver > is invoked by the OS it _is_ a C program being interpreted by > the compiler? Or is it machine code being interpreted by the OS? > (The second, of course. So what's the difference between Python > and C in this regard?) None, vis-a-vis a device driver. The difference is the distinction of using python to create a device driver vs a python program that _is_ a device driver. The former is doable and the latter not. (Not at least in the sense of the following paragraph.) > > Whether anyone belives it or not, I _did_ have actual questions > at the start of this. It was said that you cannot write a device > driver in Python because Python cannot access hardware interrupts > (or whatever). I don't see how a program _writing_ a device > driver needs to do that, so I don't see what it has to do with > whether you can write a device driver in Python. > I think we agree that it is possible to create a device driver using python. I suspect we also agree that a python program is not a suitable device driver. >From a similar perspective, I've reverse engineered all sorts of proprietary data structures, then used python to revise and rewrite these files to interface to applications that were reluctant to communicate more openly. -- Emile van Sebille emile at fenx.com --------- From guido at digicool.com Sat Jun 16 11:46:14 2001 From: guido at digicool.com (Guido van Rossum) Date: Sat, 16 Jun 2001 11:46:14 -0400 Subject: 2.0.1's GPL-compatibility is official! Message-ID: <200106161546.LAA05521@cj20424-a.reston1.va.home.com> Richard Stallman, Eben Moglen and the FSF agree: Python 2.0.1 is compatible with the GPL. They've updated the text about the Python license on http://www.gnu.org/philosophy/license-list.html, stating in particular: GPL-Compatible, Free Software Licenses [...] The License of Python 1.6a2 and earlier versions. This is a free software license and is compatible with the GNU GPL. Please note, however, that newer versions of Python are under other licenses (see below). The License of Python 2.0.1, 2.1.1, and newer versions. This is a free software license and is compatible with the GNU GPL. Please note, however, that intermediate versions of Python (1.6b1, through 2.0 and 2.1) are under a different license (see below). I would like to emphasize and clarify (again!) that Python is *not* released under the GPL, so if you think the GPL is a bad thing, you don't have to worry about Python being contaminated. The GPL compatibility is important for folks who distribute Python binaries: e.g. the new license makes it okay to release Python binaries linked with GNU readline and other GPL-covered libraries. We'll release the final release of 2.0.1 within a week; so far we've had only one bug reported in the release candidate. I expect that we won't have to wait long for 2.1.1, which will have the same GPL-compatible license as 2.0.1. --Guido van Rossum (home page: http://www.python.org/~guido/) From mac4-devnull at theory.org Sun Jun 17 00:12:25 2001 From: mac4-devnull at theory.org (Neil Macneale) Date: Sat, 16 Jun 2001 21:12:25 -0700 Subject: += overloading? Message-ID: <3b2c2cbb$0$324$8eec23a@newsreader.tycho.net> I am creating a colored stringbuffer class, and I want to append words to the buffer with the '+=' operator. Ex: >>>csb = CSB("INIT STRING") >>>csb += "Hello" >>>print csb INIT STRINGHello would be the desired effect. I can't seem to find anything in the lib docs about overloading that operator though. Am I looking in the wrong place? It is also important that a new object is NOT created every time the operator is used, because that would be a waste. Suggestions? Thanks for any tips! Neil Macneale -- To reply to me via email, remove the '-devnull' from my address. From Christopher.Cox at honeywell.com Mon Jun 25 12:15:42 2001 From: Christopher.Cox at honeywell.com (Chris) Date: 25 Jun 2001 09:15:42 -0700 Subject: Pythonwin embedded in another program... References: <13bf971.0106211242.d94cf0f@posting.google.com> <3B3297B9.5010505@ActiveState.com> Message-ID: <13bf971.0106250815.1ad0356e@posting.google.com> Thanks Mark...we've got things all ironed out now. I appreciate your help. Chris From kwoeltje at mail.mcg.edu Thu Jun 7 11:03:45 2001 From: kwoeltje at mail.mcg.edu (Keith Woeltje) Date: Thu, 07 Jun 2001 15:03:45 GMT Subject: Windows editor? References: Message-ID: <3B1F981B.AD42B1CC@mail.mcg.edu> actually the URL is http://www.ultraedit.com/ >K Kemp Randy-W18971 wrote: > Ultra Edit (www.ultra.com) with the macro extension developed for Python is > great, and only $30. You have to download the free Python, macro extension. > > -----Original Message----- > From: Wolfgang Lipp [mailto:castor at snafu.de] > Sent: Wednesday, June 06, 2001 6:36 PM > To: python-list at python.org > Subject: Re: Windows editor? > > > > > > >What's a good Python editor for programming under Windows, > specifically > > > > > >Windows 2000? According to Google archives it seems this question > > try www.textpad.com > > -wolf From db3l at fitlinxx.com Wed Jun 27 22:52:55 2001 From: db3l at fitlinxx.com (David Bolen) Date: 27 Jun 2001 22:52:55 -0400 Subject: list of dictionaries References: <3B3A4B97.5F4EB1F1@cc.gatech.edu> <9hdjmt$dk0ki$1@ID-11957.news.dfncis.de> <3B3A58A1.AE09529@cc.gatech.edu> <9hdme5$di2n4$1@ID-11957.news.dfncis.de> <3B3A8F20.71F0DE04@cc.gatech.edu> Message-ID: George Thomas writes: > Hi, > > That makes sense. However, to make sure I understand completely, I'll > list the steps in question. > Given: A single dict object, call it dict (how original!) > 1. Start with empty list > 2. Update fields of dict > 3. append dict to list. > 4. Update fields of dict. > 5. append dict to list. > The thing I can't understand is: even though dict reflects the change in > (4), the append() operation seems to ignore it completely, giving me a > copy of the previous contents. Why does this happen ? > Thanks for the insight on the alternative solution. I guess I'll rest > easy when the issue above has an explanation :) That shouldn't be what you are getting, so you may have to be more explicit (e.g., your original post didn't actually show the contents of the objects after the execution). If I execute the code you had in your original posting: dict_entry = { 'a':'', 'b':'', 'c':'', 'd':'' } a1 = "apples" a2 = "oranges" b1 = "bananas" b2 = "peaches" c1 = "coconuts" c2 = "pears" d1 = "dalmatians" d2 = "pecans" sample_list = [] dict_entry['a'] = a1 dict_entry['b'] = b1 dict_entry['c'] = c1 dict_entry['d'] = d1 sample_list.append(dict_entry) dict_entry['a'] = a2 dict_entry['b'] = b2 dict_entry['c'] = c2 dict_entry['d'] = d2 sample_list.append(dict_entry) then here's what I have in the end in dict_entry and sample_list (either under Python 1.5.2 or 2.0): >>> dict_entry {'d': 'pecans', 'b': 'peaches', 'c': 'pears', 'a': 'oranges'} >>> pprint.pprint(sample_list) [{'d': 'pecans', 'b': 'peaches', 'c': 'pears', 'a': 'oranges'}, {'d': 'pecans', 'b': 'peaches', 'c': 'pears', 'a': 'oranges'}] Both entries in the list (that were appended separately) are references to the same single dictionary (dict_entry), and must reflect the contents of that single dictionary object - which thus will be the second set of values that you stored under the keys 'a' through 'd'. So that's what I'd expect to find, given that you have really just appended to the list two references to the same object. But you seem to be saying that's not the case when you run this, but instead you see the second set of values when you examine dict_entry, but see the first set of values in the dictionary objects within sample_list. If that's really what you are saying, then something is definitely not working as it should, or you're not running exactly the code shown above - perhaps you simplified the example thinking you were removing something innocuous? If you could give an actual example of what values you find in the objects involved, it might help explain further. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From tim.one at home.com Sat Jun 30 21:52:30 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 30 Jun 2001 21:52:30 -0400 Subject: Augmented Assignement (was: Re: PEP scepticism) In-Reply-To: <4Dp%6.408588$oc7.55997471@news2.rdc2.tx.home.com> Message-ID: [Rainer Deyke, on augmented assignments] > ... If anything, I would go the other direction and make it illegal > for mutable types. In my experience, the primary use of augmented > assignment is for integers: > > a += 1 > > vs. > > a = a + 1 > > The augmented assignment version is clearly more maintainable since it > contains less redundancy. On the other hand, augmented assignment is > redundant for mutable types. If I want to extend a list in > place, I'll use the 'extend' method since it more clearly communicates > my intent. OTOH, if you're slinging mega-element conformable arrays x and y, x += y is much more efficient than x = x + y # creates a giant temp array and much clearer than x.add_in_place(y) It's no coincidence that the most motivated constituency for augmented assignment on mutable types was the NumPy camp. As usual in this debate, the participants aren't *themselves* confused about it, they're worried about people much feebler than they are. In this particular case, don't be so sure that isn't an empty set . From altis at semi-retired.com Sun Jun 17 13:42:32 2001 From: altis at semi-retired.com (Kevin Altis) Date: Sun, 17 Jun 2001 10:42:32 -0700 Subject: Python Essential Reference 2d edn. References: Message-ID: There is a sample chapter in PDF format online at http://www.newriders.com/books/title.cfm?isbn=0735710910 If you view at "actual size" that should give you an idea of the type-size readability. ka "Michael Prager" wrote in message news:da5vhtcqa8tafr4edm2l5opnd65gva6osl at 4ax.com... > Can anyone tell me whether the second edition of this book (by > Beazley & Van Rossum, and scheduled for publication next week) > will be printed in a larger type size than the first edition? > -- > Mike Prager > NOAA, Beaufort, NC > * Opinions expressed are personal and not represented otherwise. > * Any use of tradenames does not constitute a NOAA endorsement. From mlh at idi.ntnu.no Sun Jun 10 10:28:00 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Sun, 10 Jun 2001 16:28:00 +0200 Subject: [Python-sets] Dictionary comprehension? [OT?] References: Message-ID: <013201c0f1b9$8cfb0a00$156ff181@idi.ntnu.no> From: "Tim Peters" > > [Magnus Lie Hetland] > > I was thinking about the possibility of dictionary > > comprehension a minute ago (I vaguely recollect doing > > so before...) and came to think of the set comprehension > > syntax... > > Historical note: the dict.update() function was argued over for years > before getting implemented, because it was thought unclear what should > happen if, in x.update(y), y had a key k already in x. Should y[k] "win"? > x[k]? Should x[k] grow a list of associated values? Should overlap raise > an exception? The same arguments apply to dict comprehensions, of course, > but I think we have a clearer model here already: > > >>> {1:1, 2:2, 1:3} > {1: 3, 2: 2} > >>> > > That is, "rightmost wins" is already the rule. Right - that's what my suggestion was for the comprehension too. I've been thinking about an augmented version as well, but I'm not happy with the syntax (which is the only one I can think of) - putting an operator in front of the colon (e.g. +:) would update the entry (by means of that operator) rather than overwriting it. It is assumed that the identity element of the operator (0 for +) is put into the slot before updating is begun... So to invert a dictionary, putting keys with the same value into a set (assuming they exist) could be done like this: reversed = {d[k] +: {k} for k in d} To make a dictionary of word frequencies from a string, you could do this: freq = {w +: 1 for w in s.split()} I guess I'm moving into the Dark Side here... Perhaps I should just stick to for-loops :) > I have no idea what {v for k in dict} is supposed to mean, so I'm not > especially concerned about confusing the interpreter in that case . Sorry about that one... I gues it would be a singleton set if v is already defined, right? :) > The other syntax is natural enough, but I'm not sure it's *useful* enough. You may be right. As long as we get the dict method taking a list of tuples we can do it all with list comprehension, I guess. (But the same thing could be said about set comprehension - why not be consistent? ;) > Inverting a relation does have to worry about what happens when inverting a > many-to-one mapping, and that the order of dict traversal isn't defined > means that inverting a many-to-one mapping may even yield different results > across different releases As you can see, I addressed that problem above... Albeit in a slightly non-Pythonic way, I guess. -- Magnus Lie Hetland http://www.hetland.org "Reality is that which, when you stop believing in it, doesn't go away." -- Philip K. Dick From kkto at csis.hku.hk Wed Jun 13 23:02:21 2001 From: kkto at csis.hku.hk (Isaac To) Date: 14 Jun 2001 11:02:21 +0800 Subject: Inner classes References: <3b27a1aa.6747983@news.laplaza.org> <3dae3cfcl4.fsf@ute.cnri.reston.va.us> Message-ID: <7id787rcg2.fsf@enark.csis.hku.hk> >>>>> "Andrew" == Andrew Kuchling writes: Andrew> xyzmats at laplaza.org (Mats Wichmann) writes: >> Nonetheless, I was challenged by someone to describe how it isn't a >> shorcoming in Python that classes don't work this way and didn't >> convince the guy so I'm looking for a more erudite comparison. Andrew> Work *what* way? It's perfectly legal to do this: Andrew> class C: class inner: ... stuff for inner class ... stuff for Andrew> class C No if the original poster wants a Java-style inner class. Java inner class is a rather strange concept. The idea is for the inner class instance to have a reference to the outer class, and unlock the namespace of the outer class in methods of the inner class. It works like this in Python syntax: class outer: def __init__(self): self.d = 2 def f(self): print self.d # The following does not exist in Python class inner: def __init__(self): # should already got a hidden reference to an outer instance self.d2 = 5 # can also have its own data def g(self): print self.d # should print the d of outer reference self.f() # should call f for the outer reference print self.d2 # print d2 of inner def h(self): # return instance of inner class return self.inner() x=outer() # create instance y=x.h() # y is an inner instance y.g() # print 2 twice and then 5 Of course, currently the above says "Attribute Error: x" in the last line. Regards, Isaac. From timr at probo.com Wed Jun 27 02:22:59 2001 From: timr at probo.com (Tim Roberts) Date: Tue, 26 Jun 2001 23:22:59 -0700 Subject: [OT]: resolution of PerformanceCounter under NT References: <8351bb33.0106250141.7b7aa3d@posting.google.com> Message-ID: jkn at nicorp.f9.co.uk (Jon Nicoll) wrote: >Hello there > Further to my recent posting about using calldll to call the Win32 >API functions QuesryPerformanceCounter()/QueryPerformanceFrequency(): >... >I find that I get a return value, on my Dell Precision 410 running >NT4/SP5, of: > >>>> 448630000 > >ie 448e06, which looks to me rather like the Performance counter is >using the Timestamp Register (via the RDTSC instruction, presumably) >running at the CPU's clock frequency (?). This surprised me, as I'm >used to seeing a resolution of 873nSec or so. It all depends on your HAL. If you are running the multiprocessor HAL, QueryPerformanceCounter does, indeed, use the RDTSC instruction as its source. If you are running the uniprocessor HAL, QueryPerformanceCounter uses the 1.193MHz motherboard timer, which gives you your 873ns resolution. I assume this was done because the multiprocessor HAL could assume a Pentium. It is possible to run the multiprocessor HAL on a uniprocessor system. Some of the high-end servers run this way because the multiprocessor HAL handles some of the more sophisticated motherboard features. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From bernhard at intevation.de Thu Jun 28 13:43:02 2001 From: bernhard at intevation.de (Bernhard Reiter) Date: 28 Jun 2001 17:43:02 GMT Subject: PEP scepticism References: Message-ID: <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> In article , Roman Suzi writes: > On 28 Jun 2001, Bernhard Reiter wrote: >>This a general warning against the second system syndrom in Python. As I wrote in my original post I do not want to actually discuss the advantages or disadvantages of the examples given. This already has been done. Hopefully I can explain my concern on a more general level. > If you do not want to use them - please do so. This is no argument. I will have to read code of other people which will force me to use them. (Now don't tell me: Don't do this.) >>To me it looks like these contructs do not add capabilities to >>python which were missing. They seems to be rare cases in which I > > It depends on the programmer. It is my hope that python gives more clarity to everybody. Right now python already does this compared to other programming languages. > But programmers are lazy Good variables and comments are essential for each program. Nodoy should be to lazy to make a program more clear. >>The new syntatic additions still >>require that the programmer has a full understanding about what is going on. >>On the other the sum of language constructs is growing and harder to >>understand as a complete system. > > Language constructs aren't the pile of features. There is good logic > behind them, if you look with more attention. I know. >>Mainly as a python user I urge you to take this into consideration. > > As a python programmer, I think that Python must live I agree as a python programmer (which I meant by "python user" btw). There are important additions (e.g. unicode) and the language has to be maintained. But as Dennis Ritchie said about the C99 standard commitee: "I wish they had resisted more firmly." http://www.itworld.com/Comp/3380/lw-12-ritchie/ Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) FSF Europe (fsfeurope.org) From m.faassen at vet.uu.nl Fri Jun 29 19:35:07 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 29 Jun 2001 23:35:07 GMT Subject: PEP scepticism References: <3d1yo2nca4.fsf@ute.cnri.reston.va.us> Message-ID: <9hj3bb$bdu$8@newshost.accu.uu.nl> Andrew Kuchling wrote: [snip good analysis] > I suspect that an ambitious person could jumpstart the catalog into > existence, even if they ignored the catalog SIG completely. This of course similar to what happened with the Vaults of Parnassus. We didn't really have a good comprehensive site with links to Python modules before it. Tim Middleton wrote something up and filled it up, and poof, people complain when it's down or slow in accepting submissions. :) > Write an > initial implementation that's reasonably good, seed it with data from > Parnassus or wherever, and push it hard for a few months; if enough > people begin adding their new modules, then it'll just bootstrap > itself into indispensability, much as Parnassus did. That's probably the way to go about it. Now we only need to find a person willing to do all the work. [snip good question] > I've wondered if a document on how to work with the Python dev team > would be a useful thing, and if it would encourage more people to help > out. The somewhat mysterious way to get accepted to the dev mailing list at all is a hurdle all by itself.. Perhaps this document could help there too. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From olaf.meyer at nokia.com Thu Jun 7 11:55:22 2001 From: olaf.meyer at nokia.com (Olaf Meyer) Date: Thu, 07 Jun 2001 15:55:22 GMT Subject: getting current call stack Message-ID: Is there any way to determine the current call stack from a method/function? Thanks, Olaf -- Olaf Meyer <_Q_/ _ ,_~o Nokia Networks \\_/ / //\ /~~\_/~\ ,,, ___ _~o Heltorfer Str. 1 ^ \_ \>> | | #=#==========# | ___ _-\_<, D-40472 Duesseldorf \\ \__/~\_/ ``` (*)/'(*) From tgos at spamcop.net Thu Jun 7 10:02:04 2001 From: tgos at spamcop.net (TGOS) Date: 7 Jun 2001 09:02:04 -0500 Subject: best language for 3D manipulation over web ? References: <9f7eqe$gvd$1@oslo-nntp.eunet.no> <9fldqf$2bo$1@oslo-nntp.eunet.no> <7rutht85arahtvh10eqlel8lpp81f4o9kh@4ax.com> <9fnba7$irt$1@oslo-nntp.eunet.no> Message-ID: On Thu, 7 Jun 2001 09:51:34 +0200, "Thomas Hansen" wrote: > [snip] > I saw the link given further up to the "Burning Metal" game, and it was > quite impressing, but it wasn't even in the nearby of WTGD... Yeah and I repeat myself when saying: Burning Metal doesn't use Java3D, it's just software emulation. If Burning Metal would use Java3D, it had: - Filtered Textures - MIP Mapping - Realistic shading - Alpha transparency and other neat features. The demo racing game of WTGD can use all those features and it hardly looks 10% better than Burning Metal...that's really a pitiful. -- TGOS From schorsch at schorsch.com Wed Jun 13 06:46:49 2001 From: schorsch at schorsch.com (Georg Mischler) Date: Wed, 13 Jun 2001 12:46:49 +0200 Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> Message-ID: <9g7dii$4lr$06$1@news.t-online.com> thinkit wrote: > humans should use a power of 2 as a base. this is more logical because it > synchs with binary, which is at the very heart of logic--true and false. > it is more natural perhaps, to use decimal--but logic should, and will, > win out. I don't feel like arguing on the locical level, my brain is absorbed with more important matter for the moment. But there are also practical aspects. If you want to make mental arithmetic as easy as possible, then you should go with a base of 12. As far as I know, this is the (small) base where the round figures can be divided by the largest amount of other numbers. It's really a pity that humans have only ten fingers, or we'd probably be doing it this way right now... Have fun! -schorsch -- Georg Mischler -- simulations developer -- schorsch at schorsch.com +schorsch.com+ -- Lighting Design Tools -- http://www.schorsch.com/ From mcfletch at home.com Tue Jun 26 01:13:08 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Tue, 26 Jun 2001 01:13:08 -0400 Subject: new to python In-Reply-To: Message-ID: <000501c0fdfe$b0266280$a9807018@cr706570a> - Is python like c/c++ where you can make pretty much any kind of program you want whether is be games, gui apps, etc. or is it like cgi where you can only use it in websites? Python is a general-purpose language (you can use it for just about anything). It is, however, a very high-level language, so very low-level tasks like writing device drivers, game display loops, etceteras are more often coded as C/C++ extensions to Python (or an external app with Python embedded), rather than writing them directly in Python. Python then becomes the control logic which runs the low-level stuff, allowing for rapid revision and extension of that logic. - Is python object oriented? Yes, if you want. See the tutorial. It's fairly natural and simple to work with objects. class x: def hello( self, name = "you" ): print "Hello there, %s" % ( name ) myX = x() myX.hello( "Beebe" ) - Should I develop in Python? Is it good for programming, is it powerful and are job opportunities good for Python developers? Good for programming: I'm obviously biased, I use it :) . Powerful: yes, it's powerful enough that going to C after coding in it feels like you're swimming through molasses. That said, others have different definitions of "power". Job opportunities are trivial in number compared with C/C++/Java. They also tend to be more fun when you get them :) . - When I make a Python program, do I just leave it as a .py file or is there a way to make it into some kind of executable file like in C++? When I make a program in Python, how do I distribute it out to people? Do I just send out the .py file? Does the user need some kind of runtime environment or something? Do they need to download something else rather than my program? See usenet discussions on Py2Exe, and the McMillan Installer. You can distribute as an exe file with either of those (or freeze on non-win32 systems). HTH, Mike -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Beebe Sent: June 25, 2001 23:18 To: python-list at python.org Subject: new to python Hello comp.lang.python, ... I know that's a lot of questions but I haven't found them on the net yet. Please answer my questions if you will by emailing me at jonbeebe at softhome.net. If you email me, that way I'll be sure to recieve the reply, otherwise, i might miss it. Thank you very much, - Beebe -- http://mail.python.org/mailman/listinfo/python-list From rdskar1 at home.com Mon Jun 4 21:39:31 2001 From: rdskar1 at home.com (rdskar1 at home.com) Date: Tue, 05 Jun 2001 01:39:31 GMT Subject: multifile and mimetools to parse email folder Message-ID: I want to read through an email folder (I use mutt on debian, the 'folder' is a text file) and decode the attachments. I understand how mimetools works, but I am having trouble moving from message to message with multifile. I have been trying various combinations off multifile push, pop and readline methods, but I haven't hit on the right combinations. infl=open('emailfile','r') file=multifile.MultiFile(infl) msg=mimetools.Message(file) file.push(msg.getparam('boundary')) file.next() repeat until returns 0 how do I get to the next message? Thanks in advance, Bob From shawntaub at yahoo.ca Fri Jun 8 09:35:42 2001 From: shawntaub at yahoo.ca (Shawn Michael Taub) Date: 8 Jun 2001 06:35:42 -0700 Subject: GROUP TAKEOVER IN PROGRESS References: <902430AC4moondustapexnet@209.99.56.9> <93hn81$l4m$1@nnrp1.deja.com> <9025628F7moondustapexnet@209.99.56.9> <3a5c8520_1@news.foxinternet.com> <902581E21moondustapexnet@209.99.56.9> <3a5ce21b_1@news.foxinternet.com> <4A982771F09.psskvxvn@vluxxijwai.net> Message-ID: The mere fact you don't know makes me want to take of every 'zig'. A little help, you need. http://hubert.retrogames.com/article.php?sid=1 http://members.nbci.com/finagler/base/ http://www.newgrounds.com/frames.php?location=/collections/ayb.html For Great Justice. From wware at world.std.com Tue Jun 12 11:57:07 2001 From: wware at world.std.com (Will Ware) Date: Tue, 12 Jun 2001 15:57:07 GMT Subject: MapIt! 1.0 - Webapplication for Rastermaps References: <9g5b3t$70ltn$2@ID-89274.news.dfncis.de> Message-ID: Bernhard Reiter (bernhard at intevation.de) wrote: > > MapIt! 1.0 > > http://www.mapit.de/ Given the laziness of us numerous American slugs who can't be bothered to learn other folks' languages, there may be some interest as well in the English-language home page: http://www.mapit.de/mapit.en.html -- -----------------------------------+--------------------- 22nd century: Esperanto, geodesic | Will Ware domes, hovercrafts, metric system | wware at world.std.com From cyberlync at yahoo.com Fri Jun 29 23:00:55 2001 From: cyberlync at yahoo.com (Eric Merritt) Date: Fri, 29 Jun 2001 20:00:55 -0700 (PDT) Subject: Python compiler In-Reply-To: <9hjdu1$e1h9l$1@ID-11957.news.dfncis.de> Message-ID: <20010630030055.10593.qmail@web13003.mail.yahoo.com> Hello All, I am new to python after having converted from java. One of the problems I always had with java was the lack of a native code compiler. Will python ever have one of these? I have seen references to projects such as py2c etc, but they all seem dead. Is there an inherent problem in creating a compiler for python or is it just very difficult. Unfortuanatly I am not a big compiler guru though I would be willing to help if I could. Just curious. __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ From johnroth at ameritech.net Wed Jun 27 01:23:18 2001 From: johnroth at ameritech.net (John Roth) Date: Tue, 26 Jun 2001 22:23:18 -0700 Subject: Windows shutdown problem References: Message-ID: "NJM" wrote in message news:tjhq3pmojkjp8c at corp.supernews.com... > My computer locks up in the shutting down screen after I use python. If I > don't use any python, it shuts down fine. > > Does any one have any ideas?? There's a known problem with Tkinter and the command line in windows 9x and ME. It doesn't seem to occur in Windows 2000 and equivalent. Nobody knows whether it's in Tk or Tkinter. As far as I can determine, it only occurs when there's been an uncaught exception, although I'm certainly not an expert on the subject. There was a fairly extensive discussion about two weeks ago, titled "IDLE bug". See that for details. As far as I can tell, it's going to remain until some real Windows guru gets irritated enough to track it down with the heavy duty debug tools. If it's something other than this, no clue. My system shuts down fine as long as I don't use anything that throws an exception in Tkinter. John Roth > Thanks for the help. > > From MarkH at ActiveState.com Wed Jun 6 19:37:50 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 06 Jun 2001 23:37:50 GMT Subject: How to change Pythonwin background colour? References: <3B1E8047.17E114FC@rhystucker.fsnet.co.uk> Message-ID: <3B1EBEF4.6080103@ActiveState.com> rhys wrote: > I need to change Pythonwin's background colour from bright white. I've > managed to change a lot of it through the colour configuration options > but not the interactive window. I'm afraid it can not be done short of hacking the code. Mark. From jkraska1 at san.rr.com Sat Jun 23 22:22:42 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 24 Jun 2001 02:22:42 GMT Subject: How useful do you find the interactive interpreter? References: <4688f24b.0106231658.43d2c446@posting.google.com> Message-ID: <5ujajt4prhi0kffb4qrkm1mb2h16b71d1n@4ax.com> On 23 Jun 2001 17:58:18 -0700, slaytanic_killer at disinfo.net (slaytanic killer) wrote: >Hi, > >I am looking at Python seriously, and I can see that the interpreter >would be really good for testing out ideas. Getting small things to >work and then switching over to a text editor to generalize what I've >learned. Is this how people generally use it? The interpreter is nice; however, do keep in mind that python itself is modify and run. Compiling is automatic, correctly handles the dependencies, is so quick as to not be seen, and therefore doesn't intrude on one's development. All that said, I frequently use the interpreter to test things. The value of probing and interact with software extemporaneously is immense. C// From dirck at pacbell.net Mon Jun 25 04:30:23 2001 From: dirck at pacbell.net (Dirck Blaskey) Date: 25 Jun 2001 01:30:23 -0700 Subject: module __call__ Message-ID: <6c8b7eb9.0106250030.51be556d@posting.google.com> last April I had posted: > > ...Gee-Wouldn't-It-Be-Nice-If... > > modules could def __call__(): > > so you could call a module > It seemed to me like it sort of fit, and would be useful for modules with a very simple interface, so instead of: import module module.function() you could: import module module() Anyway, I would like to thank Alex Martelli for recently posting a clue (for the clueless like myself) (in the thread on const), that makes this possible. Here's the code: (let me know if I screwed it up) ======================================= """ modulecall.py enable def __call__(): at module level thanks to Alex Martelli (aleaxit at yahoo.com) dirck at danbala.com """ import sys class _callable_module: def __init__(self, name): m = sys.modules[name] self.__dict__['_module'] = m self.__dict__['_mdict'] = m.__dict__ def __setattr__(self, name, value): self._mdict[name] = value def __getattr__(self, name): return self._mdict[name] def __call__(self, *pargs, **kargs): """ apply pseudo-module call """ apply(self._module.__call__, pargs, kargs) # make this module callable as a simple interface def __call__(modulename): """ module call """ sys.modules[modulename]=_callable_module(modulename) sys.modules[__name__]=_callable_module(__name__) ================================================ """ test.py test modulecall.py: Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> import test >>> test() module __call__ test >>> """ import modulecall modulecall(__name__) def __call__(): print "module __call__ test" From jdries at mail.com Mon Jun 11 15:53:05 2001 From: jdries at mail.com (jdries at mail.com) Date: Mon, 11 Jun 2001 20:53:05 +0100 Subject: CGI Empty Form problem (over https) References: <3B2507FE.8838C412@hursley.ibm.com> Message-ID: <3B2521A1.B36097F4@mail.com> Tushar Wagle wrote: > > I'm having a problem with a cgi form in a cgi script. > Running over a secure connection (https:..), my CGI script > gets an empty cgi-form, ie > > FieldStorage(None, None, []) > > whereas running the same script in a non-secure environment > works fine. Any ideas on what might be happening (eg is there > something in the cgi module which requires special 'tweaking' > to run over SSL)??... I can't tell you what's going wrong in your case, but I can say that using the cgi module over SSL works out of the box for me, i.e. without any difference between http and https. Regards, Jan From bh at intevation.de Mon Jun 25 05:52:58 2001 From: bh at intevation.de (Bernhard Herzog) Date: 25 Jun 2001 11:52:58 +0200 Subject: PEP 255: Simple Generators, Revised Posting References: Message-ID: <6qk8203myt.fsf@abnoba.intevation.de> "Tim Peters" writes: > [Bernhard Herzog] > > I wasn't aware of that! For that matter, I wasn't even aware that the > > compiler removed "if 0" blocks. When was that introduced. It even > > "works" with 1.5.2. > > It was introduced along with "assert": under the covers, assert gets > changed into > > if __debug__: > do the assert code > > __debug__ is a compile-time constant, and it was thought important that > asserts leave no trace (not even bytecode) under -O. The mechanism for > getting rid of > > if __debug__: > > at compile-time just happens to recognize literal numeric zeroes and empty > strings as meaning "false" too. Thanks. I knew about __debug__ and assert but I thought this optimization would only happen with the -O option. If I understand this correctly the optimization is always done actually, regardless of optimization options and the only reason __debug__ code is not removed when no optimization option is given is that __debug__ is true in that case. > > Being able to easily write a function that does nothing (in fact it's > > the most trivial function one can write) is very useful in practice, so > > as a generalization being able to write empty generators might be > > useful, too. I'm not sure about that, though, because I don't have > > enough experience with them. > > Can't say I see much use for it. If I did, I'd probably write what > everybody hates: > > def emptyg(): > return > yield None # never reached > > Stick that in a utility module and you'll never have to think about it > again. Only until the compiler becomes smart enough to remove that unreachable yield statement. :) Bernhard -- Intevation GmbH http://intevation.de/ Sketch http://sketch.sourceforge.net/ MapIt! http://mapit.de/ From ljohnson at resgen.com Tue Jun 26 19:30:08 2001 From: ljohnson at resgen.com (Lyle Johnson) Date: Tue, 26 Jun 2001 18:30:08 -0500 Subject: python as plugin language References: <993529827.54981@newsmaster-04.atnet.at> Message-ID: > As someone who may need this in a couple of months, I'd like to ask for > a bit of clarification. There may be a real obvious answer, but how do you > get the application and the separately compiled and linked extension module > to talk to each other when you can't pass a communication parameter? Why can't you pass a communication parameter? That is in fact the approach I think they described in "Internet Programming with Python", where they refer to it as registering a "callback" object. Right after you initialize the Python interpreter, you call out to Python to create an instance of your callback object (let's call it "callbackObj") and then register that object with your extension module, e.g. callbackObj = MyCallbackObject() myExtensionModule.setCallbackObject(callbackObj) The rest of this message is a quote from "Internet Programming with Python", Chapter 12: """ After everything has been initialized properly, the Python subsystem and the main program may then communicate as follows. When the main application program desires a service of Python the program calls a method of the callback object, as in: PyObject *dummy = PyObject_CallMethod(callbackObj, "someMethod", ...); To Python, this appears exactly as if a Python program had executed: dummy = callbackObj.someMethod(args) The Python interpreter then performs the requested service by executing the method and returns a value to the main program as the result of the method call. """ > On a first scan, "Programming Python" doesn't deal with this issue at all. > It deals with a lot of other stuff, but if it deals with this, I missed it. I'm looking at "Programming Python", 1st ed.; I don't know how much he changed for the 2nd ed. But in Chapter 15, "Embedding Python", my copy has an extended case study entitled "Embedding User-Coded Validations", which should be useful reading. It's followed up by a section entitled "Other Approaches: Registering Callable Objects", which describes the approach I mentioned earlier. From support at internetdiscovery.com Fri Jun 22 21:29:17 2001 From: support at internetdiscovery.com (Mike Clarkson) Date: Sat, 23 Jun 2001 01:29:17 GMT Subject: Calling TIX in PYTHON ? References: Message-ID: <3b33f0e2.6490158@nntp.ix.netcom.com> On Thu, 21 Jun 2001 11:23:07 GMT, Peter Moscatt wrote: >Ok.... I have finally got used to using Tkinter widgets within Python. Now >I want to use a couple of Tix widgets, namely the tixDirList. > >I have used the "import Tix" command but unsure how I actually write the >code to actually show the Directory list. > >Can anyone help me out here ? > >Pete Take a look at the Demos/Tix directory in the Python 2.1 source distribution. Run tixwidgets.py or take a look at the Samples directory. Mike. From gardner at cardomain.com Wed Jun 20 14:31:25 2001 From: gardner at cardomain.com (Jonathan Gardner) Date: Wed, 20 Jun 2001 11:31:25 -0700 Subject: Pythoin MUD (PyMUD?) Message-ID: <9gqq3t$hvs$1@brokaw.wa.com> I was tinkering around and I got the base skeleton for a python MUD working (you can LOOK and LOOK at something... cool.) 1) Is there any existing python muds out there? 2) Is there any mud hackers out there with advice or ideas? This thing is as fresh as it gets, I want crazy and wacky ideas you've been mulling about in your mind for the past 25 years, and I want this mud to be truly unique. 3) Any newbies want to watch a mud being created? (OR - should I put this on sourceforge? Or will you throw rotten eggs at me?) -- Jonathan Gardner "Infinity isn't all that large - except at the end." -- Uncle Al Please don't take anything I say seriously, even if you are really gullible. From thomas.heller at ion-tof.com Thu Jun 7 14:02:38 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 7 Jun 2001 20:02:38 +0200 Subject: Creating Typeinfo for Python COM servers? References: <9fnocb$550f3$1@ID-59885.news.dfncis.de> <3B1F69CD.5000704@ActiveState.com> Message-ID: <9fofhe$5c8p0$1@ID-59885.news.dfncis.de> "Mark Hammond" wrote in message news:3B1F69CD.5000704 at ActiveState.com... > Thomas Heller wrote: > > > Is it possible to (let python) create type-information for > > a COM server written in python? > > Umm - yes and no :) > > Technically, yes. Everything needed has been exposed, and indeed some > "concept" code has been done. Thanks, Mark. Ok, I found Christian Tismer's code (which seems to be the most recent one?). It looks like it is doable... Next question: Assuming a tlb file is available, how can I plug it into the server, so that GetTypeInfoCount() and GetTypeInfo() return something useful? BTW: Where is actaully the _implementation_ of the COM server object? PyGatewayBase.cpp? Thomas From aleaxit at yahoo.com Sat Jun 30 09:47:36 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 30 Jun 2001 15:47:36 +0200 Subject: Augmented Assignement (was: Re: PEP scepticism) References: Message-ID: <9hklbe018lu@enews1.newsguy.com> "Marcin 'Qrczak' Kowalczyk" wrote in message news:slrn.pl.9jrfp7.4in.qrczak at qrnik.zagroda... > Fri, 29 Jun 2001 20:39:48 +0400 (MSD), Roman Suzi pisze: > > > In fact, many things depend on the type of the objects. Types of the > > objects define what operation will be done. For example, in a simple > > > > A = A + 1 > > > > + operation is different for different A type. > > But it never modifies A, "Never? Well, *hardly* ever" (music by Lord Sullivan, of course). class sic: def __init__(self): self.chip = 0 def __add__(self, other): self.chip += 1 return 23 A=sic() B=A print B.chip A = A + 1 print A print B.chip > and always returns an object which has a > type similar to the type of A (not necessarily exactly, numeric types See above for "always". > I treat as a wart the fact that augmented assignment has a subtle > difference between mutable and immutable objects. I do not consider polymorphism a wart, not even when it lets you write horrid code as in "class sic" above. > Both flavors of appending make sense in isolation. But in 2/3 of cases > the programmer must be aware which flavor is used. Using a wrong Where do you get this datum?! A fast browse of all occurrences of += in the .py files of the standard library appears to confirm my intuition that by far MOST cases of += fall into what you claim is "1/3" of the cases: > The remaining 1/3 is where it doesn't matter which variant is chosen: > where the old reference would be discarded anyway, so indeed += > sometimes gives the best implementation for the given type. _By far most often_. It's the exceptional case where you += to an object that has more than one reference, and the other reference(s) are not just "still around", but actually likely to be used for something later, after the +=. Alex From chrishbarker at home.net Fri Jun 22 15:59:32 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 22 Jun 2001 12:59:32 -0700 Subject: Another Wart! string.find() [ was: namespace issue? ] References: Message-ID: <3B33A3A4.99CDB06@home.net> Tim Peters wrote: > > it is a valid index into a string > > Historical note: at the time these functions were designed, negative > indices were not allowed: sequence[negative_int] raised an exception. I suppose the time machine was not yet functional either... -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From tgos at spamcop.net Sun Jun 3 09:48:12 2001 From: tgos at spamcop.net (TGOS) Date: 3 Jun 2001 08:48:12 -0500 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> Message-ID: On Sat, 2 Jun 2001 22:31:50 +0200, "Polterguy" wrote: > [...snip...] > I agree totally, but fact is 99.99999% of the commersial world uses win32. Are you sure you understand the term "commercial"? Windows is mainly used by private users and not even there 99% of them use it. Do you think a nuclear power plant runs with Windows? Or maybe the software of an airport tower? If that's the case, how many people do you think would die during a blue screen error? Do you think the majority of worldwide banks use Windows? An easy to hack, insecure and not very stable operating system? A blue screen would mean loosing millions of dollars a minute and a single hack would make every hacker a rich man. At my university are over 2,000 PCs and not a single one runs with Windows. On which planet are you living? You probably think that 99% of all CPUs currently in use are x86 CPUs, right? Well, that's damn wrong. Not even 40% of all CPUs are x86 compatible ones. (Source: Market Research of '99...not quite up-to-date, but there hasn't changed that much in the last 1 and half years) And with what OS do you think run the other 60%? Certainly not with Windows. > So why go through the extra trouble adding cross OS programming when it's > going to increase the cost of releasing a product with a factor of 50?!? Have you actually read the first post within the thread you are replying to? Where is the difference for a programmer, whether he uses a Windows only solution or a cross platform solution? He was told to use a Windows-only version, which is rather stupid considering that there's already a cross-platform solution, that is as powerful as the Windows only one. > All game companies founded on cross OS releases have either gone broke or > are soon to become so! Especially ID Software (creators of Doom1/2 and Quake1/2/3), who only use OpenGL and all their games exist for a huge range of platforms (including Linux, Unix and Macintosh). So much to the credibility of your "facts". Despite that, games are really important for "commercial PC users". I mean office workers play Quake all day long, that's what they get paid for, right? How can someone talk about the "commercial world" and then mention games? The fact that most game companies only develop games for Win32 platforms, has a simple reason: only private users play games and there the majority has a Win32 platform. But where is the connection between private users and the "commercial world"? > If you want to be successfule and reach 99.9999% of the world use technology > built on win32, DirectX, C++, hell fucking ay, if you can get away with it > use VB!!. What you say make no sense. You say people shall use a Win-only solution (what will run on Windows, but nowhere else), instead using a cross-platform solution, that will run anywhere, also on Windows. If really 99% of all PCs run with Windows, it's no problem to use a cross-platform solution...it will run on Windows, too. By using a cross-platform solution you *aren't losing* the Windows market, you just add some additional markets to it. By using a Win-only solution, you lose every other market right from the start. IOW throughout your whole post you haven't mentioned a single argument that would speak against cross-platform development. Not to mention that VB uses a Virtual Machine working in a similar manner like Java. So when you use VB, you can also use Java. > Use OBJECT tags in your HTML Object tags got created by the W3C (World Wide Web Consortium) and have nothing to do with Micro$oft in any way. They are part of HTML4 standard, which is no Micro$oft standard, but a cross-platform standard (like all HTML standards). Actually without cross-platform standards and cross-platform software, the INTERNET wouldn't even exist, since Micro$oft hasn't created it! Guess with what software the first Internet servers were running and with what software they are still running? All great inventions that you use every day are cross-platform standards. MP3, MPEG, HTML, EMail, Usenet, etc. If we had waited until MS had created all those things, we would still be in computer stone age. > use ASP (especially the new ASPX and the webforms > i find XTREMELY interresting...). You aren't working for Micro$oft, are you? Why should anyone use ASP? My webserver doesn't even support that, because it runs on Unix...oh, what a coincident, must be one of the 0.000001% of servers that don't use Win32, just like all the other servers I used in past (including the router/file server I'm running at home right now). If really there are only 0.000001% of non Win32 PCs, I must have used every single one of them up to now. I use rather PHP, JSP or SSI when I'll need such a technology (all supported by my webhost). BTW, isn't it funny that non-Windows PCs always support a wide variation of different technologies, while Windows PCs usually are limited to a single one, which always comes from Micro$oft?!? > This is my opinion and I realize this will probably become my own social > suicide, but fact is that every successfule software dealer don't give a > shit about anything but windows... All the computer stores in my town sell Linux (it's in every shop window), only very few sell Windows (why should they? Most people got a free copy with their PC). In some countries there are even more Unix/Linux PCs than Windows PCs. Please never assume that what is valid in your country is valid for the rest of the world as well. You are not living alone on that planet and your country isn't the only one that exists or that is important. Finally, all the companies that were using Win-only solutions til today are now making their solutions cross-platform (as they realized that they are missing an important market otherwise) and that is costing them million of dollars, not to mention a huge amount of work. If they had use cross-platform solutions right from the start, they wouldn't have all those troubles right now. IOW you suggestion to companies is pretty stupid, since what will save them a few bucks right now will cost them million of dollars in a few years. And all the *really* big software companies that exist are all writing cross-platform applications, the ones that create stuff for Windows only are usually the smaller, less important software companies. Even Microsoft is selling their MS Office for Macintosh, just like they have a Mac version of IE and if Linux's popularity will raise a lot the next two years, I bet that they will also write IE and MS Office for Linux (of course not open source ... but not everything that exists for Linux is open source). BTW cross-platform development has nothing to do with Java you can also develop cross-platform applications in other languages. There are lot's of C libraries that exist for more than just a single plattform and it's always a good idea to use those instead of Win32 libraries that exist for Windows only. And _THAT'S_ my opinion! -- TGOS | We've done so much, with so little, such a long time, | that we now can achieve everything with nothing. - RTL2 From paolo_casarini at libero.it Fri Jun 22 08:06:37 2001 From: paolo_casarini at libero.it (paolo_casarini at libero.it) Date: Fri, 22 Jun 2001 12:06:37 +0000 (UTC) Subject: Problem: The python server is still alive! Message-ID: I'm writing an out-of-process COM server using Py2Exe package. In this server I load an external COM object and I have to handle the events fired from it. I testes this server using VB client and all seems work well, but the problem arises when the client is closed : THE PYTHON SERVER IS STILL ALIVE and I have to shut-down it manually with Task-Manager. The same problem happens also if I use the python local server inside a C++ client. In order to check where the problem is I have simplified at maximum the python code and the the external COM object, writing the latter using VB and C++, but the problem does not disappear. Analizing the Python script, the instruction that seems to cause the problem is "connection.Connect(server, ConnectableClient (),IID_IConnectDemoEvents)" : if I comment it the server process ends correctly when the client destroies the python COM object. But, obviously, without this line of code I haven't the possibility to receive events from my external COM object. In my opinion it seems that, after the connection, some new objects are created, but they are not destroyed when the Disconnect() method is called. Here follows the minimal python script. I'm using Python 1.5.2 Is there some istruction missing in my code ?? Does my clean-up is not enough ?? Does anyone know how to get around this problem?? Thank you ######################################################################## ######## ## TechPage.py import sys import os import pythoncom import win32com.server.util import win32com.server.connect import win32com.client.dynamic, win32com.client.connect import win32com.server.policy # This is the IID of the Events interface both Client and Server support. IID_IConnectDemoEvents = pythoncom.MakeIID("{256FE325-2C6B-4E94-A830- B758B95FE779}") # Here is the client side of the connection world. # Define a COM object which implements the methods defined by the # IConnectDemoEvents interface. class ConnectableClient: _public_methods_ = ["Event1"] _dispid_to_func_ = { 0x1 : "Event1" } def _query_interface_(self, iid): if iid==IID_IConnectDemoEvents: return win32com.server.util.wrap(self) # And here is our event method which gets called. def Pippo( self ): a = 100 # Nothing importan to do.... if hasattr(sys, 'importers'): # we are running as py2exe-packed executable pythoncom.frozen = 1 class PythonUtilities: _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER if hasattr(sys, 'importers'): # In the py2exe-packed version, specify the module.class # to use. In the python script version, python is able # to figure it out itself. _reg_class_spec_ = "__main__.PythonUtilities" _public_methods_=['StartServer'] _reg_progid_="PythonDemos.Utilities" _reg_clsid_="{A63C6B16-05A8-4184-931A-D6A92642D7BF}" def StartServer( self ): # I create un instance of my external COM object # ( a very very simple object written both as ATL project and VB OCX ) # but the result is the same..... server = win32com.client.dynamic.Dispatch ("PippoServer.Pippo") connection = win32com.client.connect.SimpleConnection() # if I comment this line of code the server will be correctly discarded connection.Connect(server, ConnectableClient (),IID_IConnectDemoEvents) # a trivial method just to see if the external object is loaded server.Metodo1() # my clean-up: # is there anything else to do ?? connection.Disconnect() connection=None server=None # Add code so that when this script is run by Python.exe, it self- registers. if __name__=='__main__': if hasattr(sys, 'importers'): # running as packed executable. if '--register' in sys.argv[1:] or '--unregister' in sys.argv[1:]: # --register and --unregister work as usual import win32com.server.register win32com.server.register.UseCommandLine (PythonUtilities) else: # start the server. from win32com.server import localserver localserver.main() else: import win32com.server.register win32com.server.register.UseCommandLine(PythonUtilities) ######################################################################## ######### ## Setup.py ## This is the setup script I use to build the executable with py2exe from distutils.core import setup import py2exe setup(name="TechPage", scripts=["TechPage.py"]) ------------------------------------------------------------------------ --------- 'This is the VB code I use to test the python local server generated obove Dim PythonUtils As Object Private Sub Start_Click() Set PythonUtils = CreateObject("PythonDemos.Utilities") response = PythonUtils.StartServer() End Sub -- Posted from 195.223.159.86 by way of smtp3.libero.it [193.70.192.53] via Mailgate.ORG Server - http://www.Mailgate.ORG From rogerb at rogerbinns.com Tue Jun 12 18:42:24 2001 From: rogerb at rogerbinns.com (Roger Binns) Date: Tue, 12 Jun 2001 15:42:24 -0700 Subject: IMAP response parsing Message-ID: The imaplib code seems very incomplete as it provides no functionality at all in order to actually parse imap responses. You generally get back the raw imap response with literals as seperate members of a tuple. However since an imap server *could* return almost everything as a tuple, this is a nightmare to deal with, not to mention the arbitrary use of quotes and parentheses by different server vendors. Has anyone got any parsing code out there that can make more sense? Roger -- Roger Binns rogerb at tarantella.com http://www.tarantella.com Business Development Manager, Tarantella 425 Encinal Street, Santa Cruz, CA 95060, USA Tel 831 427 7367 Fax 831 427 5406 From thecalm at NOSPAM.btinternet.com Thu Jun 21 07:53:59 2001 From: thecalm at NOSPAM.btinternet.com (Gaz) Date: Thu, 21 Jun 2001 12:53:59 +0100 Subject: Standalone .exe's using installer/builder question References: <9gsld3$5n6$1@plutonium.btinternet.com> Message-ID: <9gsn7k$icr$1@uranium.btinternet.com> Hi again, I've also tried this command line too: C:\WINDOWS\Desktop\temp\Standalone.py hello.py -d -tk -runw -win32 i get the .exe building but it just doesn't run? any ideas? Gaz. "Gaz" wrote in message news:9gsld3$5n6$1 at plutonium.btinternet.com... > Hi, > I've recently downloaded the Installer pkg. from mcmillan inc ( > http://www.mcmillan-inc.com/builder.html ) and i wondered if anybody could > give me a little guide to using it. This is the test.py script i am using: > > from Tkinter import * > class App: > def __init__(self, master): > frame = Frame(master) > frame.pack() > self.button = Button(frame, text="QUIT", fg="red", > command=frame.quit) > self.button.pack(side=LEFT) > self.hi_there = Button(frame, text="Hello", command=self.say_hi) > self.hi_there.pack(side=LEFT) > > def say_hi(self): > print "hi there, everyone!" > > root = Tk() > app = App(root) > root.mainloop() > > and this is the command line i use from the RUN promt: > > C:\WINDOWS\Desktop\temp\Standalone.py test.py -tk > > anyideas??? i really would like to distribute standalone .exe's of my > scripts, ta > > gaz. > > From dalke at acm.org Sat Jun 23 15:21:55 2001 From: dalke at acm.org (Andrew Dalke) Date: Sat, 23 Jun 2001 13:21:55 -0600 Subject: the indentaion for grouping thing References: <3b34de9a$1_2@anonymous> Message-ID: <9h2qpa$6bg$1@slb0.atl.mindspring.net> Anonymous: >The >always present python annoyance concerning the >fact that tabs typically look like spaces for >most people and their editors. Use tabnanny, or run Python with the '-t' or '-tt' options. If you're worried, force your version control system to run a validation on the code before checking it in. >On google, I only saw conversations concerning >one author editing one file. I'm more concerned >about multiple people on multiple systems with >various editors trying to maintain the script. It's come up before. To ensure that there is a reference to this in google... In various companies I and others have worked together on projects using Linux, NT, IRIX, Win98 and other OSes, with emacs, vi, nedit, or whatever people's favorite editor is (I think some use Visual C++'s editor). The only time there's been an indentation problem was a couple of times when I cat'ed into a file and inserted hard tabs that I didn't recognized later when I decided to edit it. That must be compared to the problems I've had in C/C++ where the identation didn't match up with the blocks, or where I couldn't fit as much code at one on the screen (because of lines used only to close blocks) making it harder to see all the code at once. >Everytime I look at the file I have to think, >did someone edit this file and use spaces >instead of tabs? In my experience, that's not a problem. I mean, it could be one but people who write enough code for that to be a common problem also use editors which do things the "right" way, or can be told to do so. Even if they adore Notepad, a brief experience with auto-indenting is enough to have most people switch to a more sane editing platform. >If I paste code from one script into another, I >have to worry about tabs and spaces. As Tim was saying, this concern has also come up before many times. Use spaces. Use a reasonable editor (of which there are scores). Or, consider C code where if you copy and paste you have to look real closely to tell if (1) { f(); g(); if (0) g()} f() that the 'if (1)' block ends on the 2nd to last line. For that matter, in C you need to worry about someone doing bizarre things like #define loop for #define begin { #define end } int i, sum; loop(i=0; i<100; i++) begin sum += i; end so that the context of what you copy and paste is not well determined by the block itself. (Yes, macros like that are nasty, but using a better editor doesn't fix it while using a better editor does fix any possible whitespace problems in Python.) >I want braces I guess, or some other short >delimiter, e.g.: > >if 1: { > if 0: { > print '1', > print '2', > print '3', > } > print '4', >} Because then you go back to the "what if the '{' and indentations don't agree with each other?" problem, which is worse than the "what if someone uses tabs?" problem. Unless you force that both delimiters and whitespace must agree with each other, in which case you put more work on the author. And that extra work is not worth the effort or the additional loss of limited screen real estate. >And I want it to complain about syntax errors >regarding the delimiters. A python syntax aware >parser would be required I think. Again, run Python with the -t or -tt option. All this has been covered many times before. Millions of lines of Python code have been written (100s of millions?). In practice, the problems you envision are no worse than different problems in other languages - including problems C/C++ (or whatever your previous language was) has that you've probably forgotten about because you're so use to it. Andrew dalke at acm.org From thomas.heller at ion-tof.com Tue Jun 19 07:56:11 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Tue, 19 Jun 2001 13:56:11 +0200 Subject: why is there no class (static) methods in Python ? References: Message-ID: <9gnehp$9taqj$1@ID-59885.news.dfncis.de> wrote in message news:mailman.992898207.28586.python-list at python.org... > My own metaclass experiments and posts have all tried to provide a > mechanism for true class methods. But all metaclass mechanisms in Python > that I'm familiar with are awkward, IMHO -- and probably don't and won't > get used much (if at all). I'm really satisfied with the following recipe (you will probably remember): class ClassMeta: class Instance: def __init__(self, ...): # initialize the new instance .... def inst_method(self): # an instance method def new(self, *args): # a class method acting as a constructor return self.Instance(arg1, arg2): def a_class_method(self, ...): # another class method .... Class = ClassMeta() It is easy to understand and simulates 'real' class methods very well. I will certainly use them. What's wrong with this pattern? > As far as the class/type healing work that is > underway: I hope class methods will be a part of it. But so far the > messages from Guido that I've seen indicate that though the class/type > healing is a high priority, true class methods as a part of said healing > are not necessarily important (to him). So I'm not optimistic. Even if class methods would be on the list, how would/should the syntax be to create them? Thomas PS: Maybe you've seen Don Beaudry's objectmodule which also provides class methods (via a C-extension). He uses a syntax very similar to the above: He defines the normal (instance) methods in the outer class, and the class methods in a nested class (Should I say 'inner' class?) From smigowsky at dspace.de Thu Jun 21 11:09:05 2001 From: smigowsky at dspace.de (Stefan Migowsky) Date: Thu, 21 Jun 2001 16:09:05 +0100 Subject: Codeobjects of Modules? Message-ID: <84257D042AA7D411B3F700D0B7DB9B7C13AB69@newsintern.dspace.de> Hi, if you want to read the code object from a pyc module use this code. import marshal File = open(r"c:\temp\test.pyc","rb") File.read(8) # Magic number etc. code = marshal.load(File) File.close() The code has the same format as the code objects you find in func_code etc. You can execute the code by simply do an exec import __main__ exec code in __main__.__dict__ Stefan > > > ---------- > > Von: gbgbgb at gmx.de[SMTP:GBGBGB at GMX.DE] > > Gesendet: Donnerstag, 21. Juni 2001 08:29:34 > > An: python-list at cwi.nl > > Betreff: Codeobjects of Modules? > > Diese Nachricht wurde automatisch von einer Regel weitergeleitet. > > > Hi! > I am writing an experimental virtual machine for Python-Byte-Code > in Python. It works fine for Functions (I am using the > f.func_code.co_code Bytecode.) > > Now I want to run entire pyc-Files and/or modules. How do I get the > bytecode from modules and what is the format of the pyc-files. I could > not find any documentation. > > After finishing the PVM in Python I want to port it to - please do not > kill me - JAVASCRIPT. I think this could be interesting to be able to > execute python-byte-code on NS and IE without JAVA. > > Any help is welcome! > > gunter > > > -- > http://mail.python.org/mailman/listinfo/python-list > From chrishbarker at home.net Thu Jun 7 14:54:43 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 07 Jun 2001 11:54:43 -0700 Subject: floating point in 2.0 References: <9fiptc$m9d$1@panix2.panix.com> <3B1D154B.81016685@home.net> <9fj706$27u$1@panix3.panix.com> Message-ID: <3B1FCDF3.6DBFABF8@home.net> Aahz Maruch wrote: > >> >>> 0.1 > >> 0.10000000000000001 > >> >>> '%.55f' % 0.1 > >> '0.1000000000000000055511151231257827021181583404541015625' > >> > >> It just lies less than it used to. > > > >What the heck are all those digits at the end? Talk about lies, you can > >be sure all those digits aren't being stored (at least not in an IEEE > >754 64bit double, which stores approx. 16 decimal digits. Approx. > >because it is really a given number of binary digits. I don't have the > >exact number off of the top of my head). > > It's 52 binary bits. The decimal 0.1 is converted to the nearest > approximation using all 52 bits. The number you see above is the > precise conversion of that approximation back to decimal. So yes, all > of those digits are being stored. Note carefully that 754 doesn't store > *any* decimal digits, it only stores binary digits. What you meant is > that up to 16 decimal digits of precision can be *converted* to 52 binary > digits with "reasonable" accuracy. Because decimal contains a power of > two in its base, the reverse conversion *can* be made precisely. > > (Did I get it right this time, Uncle Timmy?) I'm pretty sure that a 52 binary bit mantissa will never create 52 decimal digits of accuracy. YOu can only get about 17 digits. However, I forgot that pesky exponent, as Helen Dawson so kindly pointed out. IN fact, here example with a 1 bit mantissa resulting in a decimal representation with a whole lot of accurate digits makes the point: the number of digits in one base has no default direct coorespondace to the number of digits in another base. I should have know this from the reverse case that this whole discussion started with: 1 / 10 takes only one digit to represent accurately in base ten but takes as many bits as you have to not precisly represent in binary. A similar situation can be true in the reverse direction. Python's display of 50 decimal digits is essentially arbitrary, not a function of the 52 bits that are used to store a Float (on my machine). >From the library reference, see my previous post -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From nperkins7 at home.com Wed Jun 20 23:51:34 2001 From: nperkins7 at home.com (Nick Perkins) Date: Thu, 21 Jun 2001 03:51:34 GMT Subject: Partially evaluated functions References: Message-ID: Rainer Deyke: > > >>> def f(self, **kwargs): > > ... print self, kwargs > > ... > > >>> f(f, self=5) > > Traceback (most recent call last): > > File "", line 1, in ? > > TypeError: keyword parameter redefined: self Carsten Geckeler: > Probably you mean > curry(f, self=5) > and not > f(f, self=5) > > But you are right that you get a TypeError due to the __init__ function in > the class. Of course you get an error when you try to pass a keyword argument to a function that does not take any keyword arguments. ( and why are you trying to pass 'self'?) What does work, for the cookbook version, and Alex's functional version, is any of the following: def print_thing( thing='boat' ) print thing print_plane = curry( print_thing, thing='plane' ) print_plane() ..now calling print_plane() will simply print 'plane' or, the same thing without the keywords: def print_thing( thing ): print thing print_plane = curry( print_thing, 'plane' ) print_plane() or.. you can even do this: def print_thing( thing='boat' ): print thing print_plane = curry( print_thing, 'plane' ) print_plane() ..with a positional arg being 'promoted' to a keyword arg. From stadt at cs.utwente.nl Mon Jun 25 18:21:01 2001 From: stadt at cs.utwente.nl (Richard van de Stadt) Date: Tue, 26 Jun 2001 00:21:01 +0200 Subject: Sorting Apache Log Files References: Message-ID: <3B37B94D.E444BC5D@cs.utwente.nl> Lenny Self wrote: > > Thanks for your help. This is what I ended up doing... It seems to work > quite nicely and seems fast enough. Although, I'm not sure how fast its > going to be with 20MB of logs :) > > #!/usr/bin/pyton > > import string > > # Reading file into list > list = open("d:/work/access.log","r").readlines() > def compare (line1,line2): > # Nicely sucks out the apache date stamp > datestamp1 = line1[string.find(line1,"[") + 1:string.rfind(line1,"]")] > datestamp2 = line2[string.find(line2,"[") + 1:string.rfind(line2,"]")] > # Compare the date stamps and return appropriate value > if datestamp1 < datestamp2: [...] That only works in case you have 2 log files from the same month. >>> date1='12/Jan/2001:11:30:31 -0500' >>> date2='01/Feb/2001:00:02:47 -0500' >>> date1 < date2 0 >>> date2 < date1 1 >>> Or does your log contain dates in this format: 2001/01/12:11:30:31 In that case, it works. >>> date1='2001/01/12:11:30:31' >>> date2='2001/02/01:00:02:47' >>> date1 < date2 1 >>> Richard. From rsenior at hotmail.com Mon Jun 4 14:22:00 2001 From: rsenior at hotmail.com (Robin Senior) Date: Mon, 04 Jun 2001 18:22:00 GMT Subject: why huge speed difference btwn 1.52 and 2.1? References: <9f8fgs$ooo$1@knot.queensu.ca> <9fdjsc$pn4$1@panix2.panix.com> Message-ID: <3b1bcf7a.12528354@news.ccs.queensu.ca> On 3 Jun 2001 08:07:56 -0700, aahz at panix.com (Aahz Maruch) wrote: >In article <9f8fgs$ooo$1 at knot.queensu.ca>, >robin senior wrote: >> >>I have a pretty simple script for processing a flat file db, running on >>Python 2.1; I tried running it under 1.52 for kicks, and to my surprise it >>ran almost 10 times as fast! Could someone let me know why 2.1 would be so >>much slower? > >This script is so poorly formatted that I can't read it. Sorry, I was at work and using IE to post; this should be better: import re import string states = { 'ALABAMA':'AL', 'ALASKA':'AK', 'ARIZONA':'AZ', 'WISCONSIN':'WI', 'WYOMING':'WY'} for year in range(1994, 1998): f = open('states/USA'+str(year)+'.TXT') counter = 1 while(1): print str(year), counter counter = counter + 1 #convert city name to allcaps (db outputs in allcaps) line = string.upper(f.readline().strip()) #check for EOF if not line: break for state in states.keys(): #(STATENAME) OR (STATE ABBREVIATION) if ( (re.search(' '+state+'( |,)', line, re.IGNORECASE)) or (re.search(' '+states[state]+'( |,)', line, re.IGNORECASE)) ): filename = string.replace(state, ' ', '_') g = open('states/'+filename+'/'+str(year)+'.TXT', "a") g.write(line) g.write("\n") g.close() f.close() From fgeiger at datec.at Tue Jun 12 01:58:31 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Tue, 12 Jun 2001 07:58:31 +0200 Subject: Enterprise Python on NT, W2K? References: <9g3dn8$uan$1@nntp1.ba.best.com> Message-ID: <9g4b3l$8nc$1@newsreaderg1.core.theplanet.net> Look at www.activestate.com. AFAIK they even are a part of the "MS family". Regards Franz "David White" wrote in message news:9g3dn8$uan$1 at nntp1.ba.best.com... > I checked out the page on python.org listing companies deploying python. I'm wondering if anyone > knows of any well known enterprise deployments of python on Windows NT or 2000 I could cite. I've > developed a python app for a client who's pretty much 100% Microsoft and I want to be able to show > them that its safe and reasonable to install python on their servers... > > thanks, > dave white From not.this at seebelow.org Wed Jun 27 23:35:51 2001 From: not.this at seebelow.org (Grant Griffin) Date: Wed, 27 Jun 2001 22:35:51 -0500 Subject: PEP 260: simplify xrange() References: Message-ID: <3B3AA617.8A9B56B7@seebelow.org> Roman Suzi wrote: > > On Wed, 27 Jun 2001, Guido van Rossum wrote: > > >I haven't heard any real objections here, so I'm going to go ahead and > >make this change (ripping the fancy stuff from xrange()) later this > >week. Boy does that feel good. ;-) > > Yes, no objections from me too. > > Though I would like PyChecker to score programs on the basis the features > they use and warn if some features are being phased out soon ;-) > Like: Hehe. BTW, can PyChecker do Python-version enforcement? Specifically, I think it would be great if we had a gizmo at least to enforce 1.5.2 (besides 1.5.2 itself ). Even cooler would be if Python had some sort of feature for this. (I'd write a PEP for that, but I fear that it might lead to a new version .) But I guess for reasons of efficiency something like this should be an "offline" tool anyway rather than pollute the innards of Python. just-trying-to-reallocate-xrange's-cruft--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From garry at sage.att.com Thu Jun 21 16:45:37 2001 From: garry at sage.att.com (Garry Hodgson) Date: Thu, 21 Jun 2001 20:45:37 GMT Subject: problem building 2.1 on SunOS 5.7 Message-ID: <3B325CF1.9A970D6D@sage.att.com> i'm trying to download python 2.1 on a new machine, and having some problems. i do a configure, then a make, and get: ->make gcc -c -g -O2 -Wall -Wstrict-prototypes -I. -I./Include -DHAVE_CONFIG_H -o Modules/python.o Modules/python.c In file included from /usr/local/lib/gcc-lib/sparc-sun-solaris2.4/2.7.2/include/time.h:90, from /usr/include/sys/time.h:405, from /usr/include/sys/select.h:17, from /usr/local/lib/gcc-lib/sparc-sun-solaris2.4/2.7.2/include/sys/types.h:274, from /usr/include/sys/wait.h:20, from /usr/local/lib/gcc-lib/sparc-sun-solaris2.4/2.7.2/include/stdlib.h:17, from Include/Python.h:50, from Modules/python.c:3: /usr/include/sys/siginfo.h:74: parse error before `pthread_attr_t' /usr/include/sys/siginfo.h:74: warning: no semicolon at end of struct or union /usr/include/sys/siginfo.h:76: parse error before `}' *** Error code 1 make: Fatal error: Command failed for target `Modules/python.o' the same thing happens with 1.6.1 it works ok on another machine running SunOS 5.6. does anyone know of a fix/workaround? thanks -- Garry Hodgson sometimes we ride on your horses Senior Hacker sometimes we walk alone Software Innovation Services sometimes the songs that we hear AT&T Labs are just songs of our own garry at sage.att.com From romain.guy at jext.org Thu Jun 21 07:17:55 2001 From: romain.guy at jext.org (Romain Guy) Date: Thu, 21 Jun 2001 13:17:55 +0200 Subject: String --> int Message-ID: <9gsl08$gsl$1@wanadoo.fr> Assuming fsock is a File objet, when I do: var = fsock.read(4) I get a String. I'd like to convert it into an integer. I haven't found any method for this so I built this one: def _buildInteger(bytes): if len(bytes) != 4: return -1 else: return ord(bytes[0]) | ord(bytes[1]) << 8 | ord(bytes[2]) << 16 | ord(bytes[3]) << 24 It works perfectly but I'd like to use one internal to Python if possible... -- Romain "Java Swinguer !" Guy romain.guy at jext.org www.jext.org "Now, don't you worry. The saucers are up there. The graveyard is out there. But I'll be locked up safely in there." - Paula Trent, Plan 9 From Outer Space From wtanksle at dolphin.openprojects.net Tue Jun 5 16:42:47 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Tue, 05 Jun 2001 20:42:47 GMT Subject: random References: <3b1cf00f.5441109@nntp.sprynet.com> Message-ID: On Tue, 05 Jun 2001 15:09:25 GMT, David C. Ullrich wrote: >But this question is not meant to be rhetorical: We have a syntax where >the valid programs are exactly finite sequences of 0's terminated by a 1. >Does this count as "self-delimiting"? Yes, but I don't think it counts as a UTM program. There are only countably many possible programs for this machine, while a UTM can run uncountably many. >David C. Ullrich -- -William "Billy" Tanksley From new_name at mit.edu Mon Jun 25 14:02:05 2001 From: new_name at mit.edu (Alex) Date: 25 Jun 2001 14:02:05 -0400 Subject: Can I start asynchronous threads in .pythonrc? Message-ID: I have some slightly time consuming administrative stuff that I'm doing to my source tree each time I start python. I'm running it in my .pythonrc file, which means there's a delay of a few seconds before I get the python prompt. Is there any way to get stuff in my .pythonrc to run in the background? Alex. From dsh8290 at rit.edu Fri Jun 1 22:16:15 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 1 Jun 2001 22:16:15 -0400 Subject: Why isn't Python king of the hill? In-Reply-To: ; from dwig@advancedmp.net on Fri, Jun 01, 2001 at 04:48:32PM -0700 References: <9f7ai7$b4e$1@newshost.accu.uu.nl> <20010601155530.C7896@harmony.cs.rit.edu> Message-ID: <20010601221615.B8321@harmony.cs.rit.edu> On Fri, Jun 01, 2001 at 04:48:32PM -0700, Don Dwiggins wrote: | D-Man writes: | > My question for you is : What about J2EE makes it so great? What | > are the features that you really need/want? Why not start an | > "Enterprise Python" spec, or something, to provide those features in | > Python? If J2EE is the main reason to use Java (excluding the reason | > in your next section), then let's take all the good ideas from it and | > make them part of Python too. If Python had "PyEE" then it might be | > easier to sell to management . | | How about "EnterPy"? Easy to say, and fits nicely with Starship Python... I like that. (I used to watch Star Trek: The Next Generation sometimes and some of the newer ones occasionally) -D From mwh at python.net Tue Jun 19 14:15:20 2001 From: mwh at python.net (Michael Hudson) Date: Tue, 19 Jun 2001 19:15:20 +0100 (BST) Subject: disable line wrap in xterm?? In-Reply-To: Message-ID: On Tue, 19 Jun 2001, Scherer, Bill wrote: > On 19 Jun 2001, Michael Hudson wrote: > > > To turn auto-wrap off: > > > > print "\033[?7l" > > > > to turn it on: > > > > print "\033[?7h" > > That does it. Thanks! No problem! > > > > Do you have the ctlseqs.TXT document? It's handy for this sort of > > thing. > > Never heard of it. This: http://www.giccs.georgetown.edu/~ric/howto/Xterm-Title/ctlseq2.txt seems to be a copy. Cheers, M. From thomas at xs4all.net Sun Jun 3 19:27:45 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 4 Jun 2001 01:27:45 +0200 Subject: Why isn't Python king of the hill? In-Reply-To: ; from tim.one@home.com on Sat, Jun 02, 2001 at 06:12:59PM -0400 References: <393D961EA4FCD311B03F00D0B746D65803275E5F@HQSXCH01> Message-ID: <20010604012745.T690@xs4all.nl> On Sat, Jun 02, 2001 at 06:12:59PM -0400, Tim Peters wrote: > sum = 0 > for i in range(1, 101): > sum += 1/i > In floating-point instead they'd get > > 5.1873775176396206 This must be a very hypothetical python, given that in current Python they'd get 1 instead . -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From ralf.muschall at alphasat.de Fri Jun 29 12:09:21 2001 From: ralf.muschall at alphasat.de (Ralf Muschall) Date: 29 Jun 2001 18:09:21 +0200 Subject: functional programming and default parameters References: Message-ID: "Nick Perkins" writes: > >>> fns = [lambda:i for i in range(3)] > >>> fns[0]() > 2 > >>> fns[1]() > 2 > but this does work: > >>> fns = [lambda i=i:i for i in range(3)] > >>> fns[0]() > 0 > >>> fns[1]() > 1 > from __future__ import nested_scopes > def fnlist(n): > list =[] > for i in range(n): > def fn(): #or: def fn(i=i) > return i (The easy part of) this problem is very old and also bites newbies in Lisp. The variable "i" is created only once (at the top of the loop), the only thing that changes later is the value. As a result, all closures share the same thing "i" (you can check this by creating functions gn(j) which make i=j -- changing the "i" once causes all "fn"s to return the new value). The solution is to create a fresh variable *in* the loop and use this for the closure. In CL, a common idiom is this: (let ((fns (make-array (list 3)))) ; bad (do ((i 0 (1+ i))) ((> i 2)) (setf (aref fns i) (lambda () i))) ; shared i fns) wrt. (let ((fns (make-array (list 3)))) ; good (do ((i 0 (1+ i))) ((> i 2)) (let ((j i)) (setf (aref fns i) (lambda () j)))) ; fresh j fns) The top example makes an array of three functions, each one returning the value of the common "i" (which is 3 after the loop ended). The bottom example does the right thing. Of course, real programmers would write (let ((i i)) ...) Unfortunately, in Python writing for i in range(3): j=i fns[i]()=lambda:j fails, and even this fails too: for i in range(3): j=i+10 a[i]=lambda:j map(x:x(),fns) gives [12,12,12]. My guess is that the interpreter detects the *creation* of the variable "j" in the loop and optimizes by shifting that in front of the loop, leaving only the *assignment* in the loop body. (I have no idea how this is supposed to happen in interpreted code - maybe it detects the creation during the first loop body traversal, or it starts interpreting only after the complete loop has been typed in.) Probably one needs to play nasty tricks against the optimizer (as Tim's solution does) in order to enforce the creation of a fresh variable during the loop execution. Ralf From stephane.bausson at free.fr Wed Jun 13 16:05:29 2001 From: stephane.bausson at free.fr (=?iso-8859-1?Q?St=E9phane?= BAUSSON) Date: Wed, 13 Jun 2001 20:05:29 GMT Subject: how to get teh path of a script Message-ID: <3B27C7A9.3B9D3F4B@free.fr> Hello I would like to get for exemple in my_script.py located at /home/toto/my_script.py to get in my_script.py the value "/home/toto" ... Any hint ? Thanks Stephane -- stephane.bausson at free.fr - Toulouse (France) From root at rainerdeyke.com Wed Jun 20 00:16:08 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 20 Jun 2001 04:16:08 GMT Subject: Partially evaluated functions References: Message-ID: "Venkatesh Prasad Ranganath" wrote in message news:m3sngw12ce.fsf at boss.dreamsoft.com... > Hi, > > I have used ML and it is interesting how it is possible to specialize a function > by partially evaluating when in curried form. > > Is partially evaluated functions possible in python? If there has been a > discussion about it, where can I find the jist of the discussion? > > def conv(a, b, c): > return (a + b) * c > > faren2cel = conv(b = -32, c = 5 / 9) class curry: def __init__(*args, **kwargs): self = args[0] self.function = args[1] self.args = args[2:] self.kwargs = kwargs def __call__(*args, **kwargs): kwargs.update(self.kwargs) return self.function(self.args + args, kwargs) faren2cel = curry(conv, b = -32.0, c = 5.0 / 9) -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From katiki at kodak.com Tue Jun 12 09:01:02 2001 From: katiki at kodak.com (Karim) Date: Tue, 12 Jun 2001 15:01:02 +0200 Subject: New to python Message-ID: <9g53qh$qhl$1@news.kodak.com> Hi all, I'm a new beginner to python. In fact, I'll have to use itfor a next project. But I don't know antything about python. Can someone write me in few lines why Python has been created ? What for ? For what kind of applications ? Thanks a lot. Karim From paulp at ActiveState.com Wed Jun 6 17:01:20 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Wed, 06 Jun 2001 14:01:20 -0700 Subject: Generating Multiple Class Instances References: <3B1E9271.B05CC4E3@fnal.gov> Message-ID: <3B1E9A20.A9647C06@ActiveState.com> Julie Torborg wrote: > > What I want to do is: > > class Quark: > def __init__(self): > self.color=getcolor() > self.mass=getmass() > There's something funny there. How does each Quark know what its color and mass is? What is the definition of getcolor and getmass? A more common solution is: class Quark: def __init__(self, color, mass): self.color=color self.mass=mass But I guess you've already got this part working.... > ... > > flavor=['up', 'down', 'strange', 'charm', 'top', 'bottom'] > for each in flavor: > each=Quark() You aren't changing the list. You're just reading from it, never writing to it. Here's a straightforward way to do it: flavornames = ['up', 'down', 'strange', 'charm', 'top', 'bottom'] flavors = [] for each in flavornames: flavors.append(Quark()) for each in flavors: print each.color I still don't know where to get the colors or masses. Also, don't you want to somehow associate the flavornames with the quarks you create? -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From kens at sightreader.com Mon Jun 4 17:11:34 2001 From: kens at sightreader.com (Ken Seehof) Date: Mon, 4 Jun 2001 14:11:34 -0700 Subject: formatting numbers Message-ID: <010401c0ed3a$fa569c00$a325fea9@his> >>> num = 49 >>> print "%05d" % num 00049 The % operator is popular for C/C++ programmers like me, who are used to the standard library C function "printf". Otherwise you may prefer a somewhat more pythonic approach: >>> print ("0000" + `num`)[-5:] # works for num >= 0 00049 ----- Original Message ----- From: "michael montagne" Newsgroups: comp.lang.python To: Sent: Monday, June 04, 2001 1:21 PM Subject: formatting numbers > Simple question. I am accessing a database of job numbers that take the > form of "00049" and "01049". These values are integers. When I return the > value from the database it reads "49". I need to add the leading digits if > they are there so this number would read "00049". In MSAccess I used > Format(num,"00000"). How can I do that with Python? > > -mjm > > > > -- > http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From skip at pobox.com Thu Jun 21 11:26:07 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 21 Jun 2001 10:26:07 -0500 Subject: How to call cleanup code in a Python extension module In-Reply-To: <9gt0sd$lfc$1@news.tuwien.ac.at> References: <9gt0sd$lfc$1@news.tuwien.ac.at> Message-ID: <15154.4623.444106.182370@beluga.mojam.com> Markus> ... I wonder where to put the cleanup code when the module is Markus> unloaded since I have not found a delxxx() function. Take a look at the C atexit(3) library function. Note that it will only get called if your program terminates by a call to exit(3), which may not be the case when an exception is raised. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From geoff at homegain.com Mon Jun 11 16:32:08 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Mon, 11 Jun 2001 13:32:08 -0700 Subject: Why should i use python if i can use java Message-ID: <393D961EA4FCD311B03F00D0B746D65803275E81@HQSXCH01> James Althoff writes: > From: James_Althoff at i2.com [mailto:James_Althoff at i2.com] > > Geoff Gerrietts wrote: > > >In Python, I know how to write classes whose instances are > >other classes. > > Do you mean "whose instances are *themselves* classes"? And if > so, How do you do this? > (Can you do this in *Python* -- without doing a C extension?) Yes, I really meant that. :) This is the "metaclass" facility -- you can get a much more formal description of how that works from looking at those docs (and playing with the examples). To use metaclasses, you need a metaclass and a helper class. Your code will instantiate the metaclass. Subclasses of the metaclass will be operated on ('rewritten') by the helper. An example appears below. The metaclass feature is not generally useful. It can be useful in certain very specific cases, especially if you're writing toolkits -- you can build functionality into your (meta)superclass that will "subvert" later declarations. I've appended an example to this message. It's heavily indebted to the example used in Guido's paper on metaclasses, found at: http://www.python.org/doc/essays/metaclasses That's a good place for further reading -- in my experience, the toughest part about metaclasses was figuring out what happened where -- the sequence of calls and what role each of the players played. I've tried to make that as clear as possible in this example.... Thanks, --G. --- Geoff Gerrietts Software Engineer, HomeGain.com 510-655-0800 x4320 #!/usr/bin/python -i print print "defining MetaClass" class MetaClass: def __init__(self, name, bases, namespace): """ for creation of class-level instances """ print "Called MetaClass.__init__ for %s" % name def __call__(self): """ for creation of instances of instances """ print "Called MetaClass.__call__" return Helper(self) print print "defining Helper" class Helper: def __init__(self, meta): """ invoked from MetaClass.__call__ for inst of inst """ self.meta = meta print "Called Helper.__init__ for ", meta def bungee(self, *args): print "Helper.bungee called" # here we directly instantiate a class by passing it a name, a # list of base classes, and a namespace. we call # MetaClass.__init__ just like we'd expect here print print "defining MetaInst (instantiating MetaClass)" MetaInst = MetaClass('MetaInst', (), {}) # here MetaClass.__init__ gets called again! note that the # __init__ must accept name, bases, namespace or else this # will flop print print "defining MyStuff" class MyStuff (MetaInst): def myMethod(self, *args): print "MyStuff.myMethod called" # the actual instance of our child class invokes the __call__ # routine on our MetaClass. The instance itself is the return # value from that __call__. print print "instantiating MyStuff" mine = MyStuff() print "Class of our instance ", mine.__class__ # now if you've been following me, you'll be thinking that our # instance 'mine' is an instance of 'Helper' (the return value # from MetaClass.__call__), so we can call mine.bungee and see # what we expect. print print "calling bungee" mine.bungee() # here's the thing that kinda sucks -- unless you've saved the # class information in MetaClass.__init__ (and you've overridden # __getattr__ to get at that stored info), you've lost your # subclass. print print "calling myMethod" mine.mymethod() # here's a better init: class BetterMetaClass: def __init__(self, name, bases, namespace): self.__name__ = name self.__bases__ = bases self.__namespace__ = namespace # if you want to muck around with the namespace, # this might be a good place to do it. def __call__(self): return BetterHelper(self) # and here's a Helper that uses it. note that this Helper # won't look in its own namespace for matches! class BetterHelper: def __init__(self, meta): self.__meta__ = meta def __getattr__(self, name): try: value = self.__meta__.__namespace__[name] except KeyError: raise AttributeError, name return value From rajarshi at presidency.com Sun Jun 3 23:27:16 2001 From: rajarshi at presidency.com (Rajarshi Guha) Date: Mon, 4 Jun 2001 08:57:16 +0530 Subject: Python output for Glade References: <9fdprb$3hpec$2@ID-91520.news.dfncis.de> <9fea4t$cbi$1@newshost.accu.uu.nl> Message-ID: <9fev1v$3p334$1@ID-91520.news.dfncis.de> Martijn Faassen wrote in message news:9fea4t$cbi$1 at newshost.accu.uu.nl... > > http://www.russnelson.com/pyglade-tutorial/pyglade-tutorial > > Sample sources: > > http://www.russnelson.com/pyglade-tutorial/ > > And another tutorial: > > http://laguna.fmedic.unam.mx/~daniel/pygtutorial/pygtutorial/ > > There's quite a bit out there. I recall seeing a few more. > > Alternatively there's also an actively being developed (latest release > *today*) code generator that generates Python code from Glade XML > files. I've never used it, but here's the homepage: > > http://www.fcoutant.freesurf.fr/gladepyc.html Thanks a lot for the pointers -- ------------------------------------------------------------- Rajarshi Guha email: rajarshi at presidency.com web: http:/www.psynet.net/jijog From root at rainerdeyke.com Sun Jun 24 23:03:33 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 25 Jun 2001 03:03:33 GMT Subject: Pmw: how to clear ScrolledListBox ? References: <3b2ccea6.477584718@news1.on.sympatico.ca> Message-ID: <9SxZ6.363467$oc7.43400786@news2.rdc2.tx.home.com> wrote in message news:wk7ky1paha.fsf at mail.connact.com... > >>>>> "JP" == Jacek Pop?awski writes: > > JP> Robert Roy wrote: > >>> I add items by .insert, what is correct way to remove all items? > >>> > >> setlist([]) should work. > > JP> what happen with old list? what happen in Python when I allocate memory for > JP> something then use another value? > > Garbage collection. In this case the old list is immediately destroyed. Garbage collection collects objects, not memory used internally by a single object. In Python, there is no way to allocate memory. You can only create objects (which are garbage collected). That these objects use memory behind the scenes is an implementation detail. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From jsteve17 at tampabay.rr.com Sat Jun 23 14:14:34 2001 From: jsteve17 at tampabay.rr.com (Jeffrey Stephens) Date: Sat, 23 Jun 2001 18:14:34 GMT Subject: Missing file Python.h Message-ID: I am running Redhat 6.2 and just downloaded and tried to compile the files sip-2.4.tar.gz and PyQt-2.4.tar.gz. Running the configure script after unzipping and untaring either of these produces the error that I am missing the file Python.h. Running rpm -qa | grep python indicates that I have the following packages installed: python-1.5.2-27.6.x python-docs-1.5.2-13 pythonlib-1.23-1 rpm-python-3.0.4-0.48 openssl-python-0.9.5a-2.6.x python-tools-1.5.2-13 python-numpy-15.2-2 None of these seems to contain a file Python.h. I also ran find /usr -name Python.h with negative results. What rpm should contain this file? Can someone point me in the right direction? Many thanks. Regards, Jeff Stephens From emile at fenx.com Sun Jun 24 11:28:25 2001 From: emile at fenx.com (Emile van Sebille) Date: Sun, 24 Jun 2001 08:28:25 -0700 Subject: Is this a true statement? References: <3b34939b.410758@nntp.sprynet.com> <3b35ebc3.1024709@nntp.sprynet.com> Message-ID: <9h516e$c2a4d$1@ID-11957.news.dfncis.de> "David C. Ullrich" wrote in message news:3b35ebc3.1024709 at nntp.sprynet.com... > On Sat, 23 Jun 2001 09:36:13 -0500, "Chris Gonnerman" > wrote: > > Seriously. _Is_ a "device driver" something other than a file? > If it _is_ something other than a file I wish someone would > say so. If a device driver is just a file then I don't see > how the OS can possibly know or care how that file was > generated. > > Of course not. And of course a file can be written by python that the os can subsequently use as a device driver. To do so, you will have written both a compile-to-bytes program and a device-driver-source file intended to be consumed by the compiler piece. When this result is invoked by the os, it will not be a python program running within the interpreter. Generally speaking, writing a device driver is not thought of as similar to copying a driver file from floppy, then saying that even something as simple as cp or copy can be used to "write" a device driver. -- Emile van Sebille emile at fenx.com --------- From duncan at NOSPAMrcp.co.uk Tue Jun 26 12:30:34 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Tue, 26 Jun 2001 16:30:34 +0000 (UTC) Subject: Mutable Strings? References: Message-ID: Eric Merritt wrote in news:mailman.993568720.15029.python-list at python.org: > I have been looking for similar functionality in > python and have yet to find it. I tried searching the > archives but any search for terms relating to strings > returns an enormous amount of hits. In any case, are > any of you aware of a anything in python that provides > this type of functionality? I am willing to write my > own I just don't want to reinvent the wheel. > The usual solution to this is to build a list of strings, which makes insert and append nice and easy, and then use the join method of a string, or the join function in the string module, to concatenate the list when you want a string. You may also find that in some cases the StringIO or cStringIO modules provide what you need. These let you create a file like object that either reads from a string, or writes to a string. -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From greg at cosc.canterbury.ac.nz Thu Jun 21 01:16:56 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 21 Jun 2001 17:16:56 +1200 Subject: PEP 255: Simple Generators References: Message-ID: <3B318348.E4D5E5D6@cosc.canterbury.ac.nz> Bob Alexander wrote: > > 2. As an Icon programmer, it never occurred to me that there was a need for a > syntactic distinction. As I pointed out in an earlier message on python-iterators at lists.sourceforge.net, the Icon situation doesn't carry over to PEP255, because the semantics are different. There's no semantic difference between them in Icon, but there is in PEP255. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From erno-news at erno.iki.fi Thu Jun 21 11:14:26 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 21 Jun 2001 18:14:26 +0300 Subject: Packing a long long type References: <5c8ecb0b.0106191444.53054b47@posting.google.com> Message-ID: In article , Martin von Loewis writes: | crj003 at yahoo.com (Rich J) writes: || Does anyone know how it would be possible to pack a list containing || 'long long' types (like 111111111111111L) [...] | The Python version in the CVS supports a 'q' format, see | http://python.sourceforge.net/devel-docs/lib/module-struct.html note that python longs don't necessarily fit in a long long, since the c long long is of limited width (often 64 bits) and python longs can be arbitrary length. one representation that works for all python longs is what you get from repr(), although it is not too space-efficient. -- erno From JamesL at Lugoj.Com Tue Jun 26 22:42:20 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Tue, 26 Jun 2001 19:42:20 -0700 Subject: PEP 260: simplify xrange() References: Message-ID: <3B39480C.F4808C1F@Lugoj.Com> Tim Peters wrote: > [James Logajan] > > Are there still known bugs that will take some effort to repair? Is > > xrange constantly touched when changes are made elsewhere? If no to > > both, then I suggest don't fix what ain't broken; life is too short. > > (Unless it is annoying you to distraction, then do the deed and get > > it over with.) > > I think it's more the latter. I partly provoked this by bitterly pointing > out that there's more code in the CVS tree devoted to supporting the single > xrange() gimmick than Neil Schemenauer added to support the get-out-of-town > more powerful new generators. Masses of crufty code nobody benefits from > are a burden on the soul. Design mistakes one has made do tend to weigh on one's soul (speaking from more than two decades of programming experience) so I understand the primal urge to correct them when one can, and even when one shouldn't. So although I'm quite annoyed by all these new-fangled gimmicks being added to the language (i.e. Python generators being added to solve California's power problems) I have no problem with xrange being fenced in. (I find the very existence of the PEP process somewhat unsettling; there are now thousands of programmers trying to use the language. Why burden them with insuring their programs remain compatible with yet-another-damn-set-of-proposals every year? Or worse: trying to rewrite their code "more elegantly" using all the latest gimmicks. Why in my day, if you wanted to, say, save execution state, you figured out how to do it and didn't go crying to the language designer. Damn these young lazy programmers. Don't know how good they have it. Wouldn't know how to save their execution state if their lives depended on it. Harumph.) Speaking of "generators", I just want to say that I think that "generator" makes for lousy terminology. If I understand correctly, "generators" are coroutines that have peer-to-peer synchronized messaging (synchronizing and communicating at the "yield" points). To my mind, "generators" does not evoke that image at all. Assuming I understand it in my early senility.... > although-it-would-be-impolite-to-ask-we-why-still-ship-a-directory- > full-of-crufty-old-irix5-demos-in-the-std-library-ly Perhaps because the Irix community would be quite Irate if they were removed? From grumble at usa.net Fri Jun 15 10:08:58 2001 From: grumble at usa.net (jcm) Date: 15 Jun 2001 14:08:58 GMT Subject: call-by-reference (was Re: Any other Python flaws?) References: <9gcu9g$gm4$1@newshost.accu.uu.nl> Message-ID: <9gd4tq$odb$1@news.mathworks.com> Martijn Faassen wrote: > I agree that nobody agrees on whatever 'call-by-reference' means, or what > 'call-by-value' means. I mean, I'm here confused why you'd say C++ doesn't > support call-by-value while Python apparently does. :) In my experience, there's good agreement about what call-by-reference means just about everywhere but in newsgroups. Python supports only call-by-value -- you can't change the value of a variable in your caller's scope (globals aside). From ullrich at math.okstate.edu Mon Jun 4 10:22:11 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 04 Jun 2001 14:22:11 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> <3B1A82DD.C4D78472@san.rr.com> <9fe2g302841@enews2.newsguy.com> <3B1AE07F.CEDA4A3A@san.rr.com> Message-ID: <3b1b98fa.4361196@nntp.sprynet.com> On Mon, 04 Jun 2001 01:12:32 GMT, Darren New wrote: [...] > >Sure. *I* can write an algorithm to calculate the bits of Omega. If I have the "definition" of Omega straight actually you can't. (If an "algorithm" is required to halt, which is part of "my" definition...) > Then I >run my algorithm, see that the first N bits of its output matches the >first N bits of your sequence, and predict with very high probability >what the next bit is, right? If you calculate the first 100,000 bits of >Omega and give it to me, and you don't tell me that it's the first >100,000 bits of Omega, and I think to try calculating the first 100,000 >bits of Omega and they match, then I guess the 100,001'st bit of Omega, >then I have a >50% chance of getting the next bit right. > >If, on the other hand, you run a random number generator based on >quantum radioactive decay, or you flip a coin 100,000 times, and it just >*happens* to match the first 100,000 bits of Omega, and I notice that, >and I guess the 100,001'st bit of Omega, then I have still only a 50% >probability of being right. > >This is why some people say that any given finite string cannot be >considered random or non-random by itself, without knowing how it's >generated. > >-- >Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. > San Diego, CA, USA (PST). Cryptokeys on demand. > This is top-quality raw fish, the Rolls-Rice of Sushi! David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From aleaxit at yahoo.com Thu Jun 14 12:37:32 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 18:37:32 +0200 Subject: PEP 259: Revise to remove context-driven magic from print References: <486de2.0106131406.5c0cbef9@posting.google.com> <9gamor$8ft$6@216.39.170.247> Message-ID: <9gap8i0fss@enews1.newsguy.com> "David LeBlanc" wrote in message news:9gamor$8ft$6 at 216.39.170.247... ... > makes sense to me. I also liked someone's idea of __print__ - if that The 'someone' was me ("was I"...?). > idea was in respect of giving objects the power to (as it where) print > themselves (return their string representation - so call it asstring()). How would that differ from the existing __str__ and __repr__ methods? No, __print__ would rather underlie the print statement just like __import__ underlies the import (and from) statements. But I guess I gotta write a PEP about it... Alex From wtanksle at dolphin.openprojects.net Wed Jun 6 18:27:32 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Wed, 06 Jun 2001 22:27:32 GMT Subject: random References: <3b1cf00f.5441109@nntp.sprynet.com> <3b1e4957.3040319@nntp.sprynet.com> Message-ID: On Wed, 06 Jun 2001 15:19:36 GMT, David C. Ullrich wrote: >(William Tanksley) wrote: >>On Tue, 05 Jun 2001 15:09:25 GMT, David C. Ullrich wrote: >>>But this question is not meant to be rhetorical: We have a syntax where >>>the valid programs are exactly finite sequences of 0's terminated by a 1. >>>Does this count as "self-delimiting"? >>Yes, but I don't think it counts as a UTM program. There are only >>countably many possible programs for this machine, while a UTM can run >>uncountably many. >Um. Some of these "programs" have infinite length, then? If they all have >finite length then there's only countably many - that's even if the length >is unbounded. If a UTM actually runs programs of infinite length then >fine, but I can't imagine what it means to run such a program. Hmm... I'm pretty sure that programs for an UTM could be infinite length; however, let's suppose that for the purposes of omega they couldn't be (IMO a reasonable supposition). Then my proof is clearly invalid. However, your machine still isn't a UTM, because in order to process an indefinite number of possible programs it has to have an indefinite number of states. It has to be able to count up to little-omega (otherwise it won't know what program it's executing), but the only way to do that is with an infinite number of states. And an UTM has a finite number of states. >David C. Ullrich -- -William "Billy" Tanksley From s713221 at student.gu.edu.au Fri Jun 1 07:11:59 2001 From: s713221 at student.gu.edu.au (s713221 at student.gu.edu.au) Date: Fri, 01 Jun 2001 11:11:59 +0000 Subject: Obsolesence of <> References: Message-ID: <3B17787F.266644CB@student.gu.edu.au> > "Alex Martelli" wrote: > | Sorry, you're behind the times: > | > | Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 > | Type "copyright", "credits" or "license" for more information. > | Alternative ReadLine 1.1 -- Copyright 2001, Chris Gonnerman > | >>> x=2+3j > | >>> y=5+8j > | >>> x | Traceback (most recent call last): > | File "", line 1, in ? > | TypeError: cannot compare complex numbers using <, <=, >, >= I haven't checked the PEP's (I'm down to 4 h on my uni network account, so I'm being conservative), but I'd hasard a guess this is because there's several ways to compare complex numbers. 5 + 8j is obviously larger than 2 + 3j because both the real and imaginary values are larger, but what about x = 2 + 3j and y = 5 + 1j where one has a larger real value and another has a larger imaginary value? Do you take y to be larger than x because |y| is larger than |x|? What if you've got two values that have the same |z| but different theta angles? Eg. x = 2 + 3j and y = 3 + 2j? My two cents worth, Joal Heagney/AncientHart From waydwolf at hotmail.com Tue Jun 19 15:35:52 2001 From: waydwolf at hotmail.com (Wayd Wolf (spam)) Date: Tue, 19 Jun 2001 19:35:52 GMT Subject: SNMP OIDs for Cisco 6509 & Cable Modems References: Message-ID: "Benjamin Schollnick" wrote in message news:junkster-00E689.19403918062001 at typhoon4-0.nyroc.rr.com... > Folks, > > I'm working with the PySNMP software, which doesn't yet handle MIB -> > OID conversion.... > > So I'm a little stuck, I'm having difficultly tracking down the > actual numeric OID's for a Cisco 6509 & Industry Standard Cable Modems. > > Does anyone know how to generate the numeric OID's or where I can > look up the Numeric OID's? > > I found several lists on Cisco's web site, but the 6509 is returning > that the OID's are not in it's MIB file.... > > I can do a SNMPwalk fine on the Cisco 6509, but I'm not positive that > will corespond with the OID's I downloaded from Cisco... (I haven't had > a chance to compare yet). > > Help? > > - Benjamin Yeesh. Hate to follow your cross-post like this, but I'll make it short and sweet. Don't know why you're using the NMS you're using, but any SNMP browser which allows for import of ASN1 compliant MIBs should would with the MIBs from Cisco. As far as I know. I've imported dozens with some of the software I'm testing and they all worked. I'd open the MIB in a text editor first though to confim ASN1 notation. -Wayd Wolf From bos at hack.org Fri Jun 15 00:36:06 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Fri, 15 Jun 2001 06:36:06 +0200 Subject: Regexp-problem Message-ID: <3B2990B6.88DC8126@hack.org> I have some problem with a regexp. re.compile(r'^(.*?)(.*° F / .*° C).* hPa(.*?).*') That line matches: Bach Long Vi81° F / 27° C83%1005 hPaPartly Cloudy07:00 AM ICT but not: Alturas73° F / 23° C20%30.03 in / 1016 hPaClear7:56 PM PDT
 
In case the lines got split, they should be on the same line. The regexp seem to fail near the temperature on the second one, but I can't see why since it's the same as the first one. Ideas? -- Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From sill at optonline.net Sun Jun 17 00:28:55 2001 From: sill at optonline.net (Rainy) Date: Sun, 17 Jun 2001 04:28:55 GMT Subject: qt or gtk? References: Message-ID: On Sat, 16 Jun 2001 13:29:12 +0200, Lothar Scholz wrote: > On Sat, 16 Jun 2001 05:52:12 GMT, sill at optonline.net (Rainy) wrote: > >> >>I want to learn python gui programming in linux. I think tk looks too ugly, so >>I narrowed down the choice to two main contenders, qt and gtk. Which of these >>has more complete and up-to-date python bindings? Are there other reasons >>to prefer one of these over another for python gui work? > > Why are you always selecting between QT and GTK ?????? > > There is for example www.fox-toolkit.org with a python binding. Because they're the most popular ones and unless there's particular reason not to use the most popular tool, i think one should default to it. > -- Delay not, Caesar. Read it instantly. -- Shakespeare, "Julius Caesar" 3,1 Here is a letter, read it at your leisure. -- Shakespeare, "Merchant of Venice" 5,1 [Quoted in "VMS Internals and Data Structures", V4.4, when referring to I/O system services.] From jeff at ccvcorp.com Thu Jun 28 12:49:18 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Thu, 28 Jun 2001 09:49:18 -0700 Subject: KDE and Windows References: <993660235.135465@seven.kulnet.kuleuven.ac.be> Message-ID: <3B3B600E.D4670EA3@ccvcorp.com> NightOwl wrote: > Is it possible to develop a GUI which runs in Windows aswell as in KDE with > the same code ? I don't want to have to re-write all code just because I use > an other OS ... ? (Not using the COM-functions of Windows). In addition to QT (mentioned by others), there's also Tk/Tkinter (included with the standard Python distribution), and wxPython (www.wxpython.org -- my preference). Note that, as this is the c.l.py newsgroup, I'm assuming that you wish to use Python--a wise choice for x-platform coding in any case. Jeff Shannon Technician/Programmer Credit International From wart at softhome.net Mon Jun 18 08:14:52 2001 From: wart at softhome.net (Wartan Hachaturow) Date: 18 Jun 2001 16:14:52 +0400 Subject: Comprehensive Python Archive Network Message-ID: <87n1762ddv.fsf@penguin.aktivist.ru> Hello, everybody. Yes, yes, I know I'm not the first to post with such a subject :) But maybe we should write such a thing for the benefit of everyone, and cut off one of the strongest Perler's argument against Python? -- Regards, Wartan. echo "Your stdio isn't very std." -- Larry Wall in Configure from the perl distribution From aahz at panix.com Fri Jun 29 15:33:52 2001 From: aahz at panix.com (Aahz Maruch) Date: 29 Jun 2001 12:33:52 -0700 Subject: Is this a true statement: Part II References: <9hiifr$sjs$1@taliesin.netcom.net.uk> Message-ID: <9hil70$rng$1@panix3.panix.com> In article <9hiifr$sjs$1 at taliesin.netcom.net.uk>, MDK wrote: > >"Python can do everything C++ can do but just slower." > >I am not sure after reading all the replies that I can say with confidence >yes or no. I think that I can at least say this (if I understand most of >what was said): > >1. Excluding writing device drivers the answer is a clear yes. If you can say that with confidence, you did not understand most of what was said. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Nothing fails like prayer" --bumper snicker From mwh at python.net Thu Jun 28 08:30:29 2001 From: mwh at python.net (Michael Hudson) Date: 28 Jun 2001 13:30:29 +0100 Subject: PEP 260: simplify xrange() References: <3B39480C.F4808C1F@Lugoj.Com> <9hc97q$rpt$1@slb6.atl.mindspring.net> <3B3A9C39.64C3E1C6@seebelow.org> <9hef08$urt$1@slb3.atl.mindspring.net> <9hf5ru$5el$1@animus.fel.iae.nl> Message-ID: Carel Fellinger writes: > Michael Hudson wrote: > ... > > Google confuses me; if you search for "michael hudson" my page is the > > third hit - but my name doesn't actually appear anywhere on the linked > > page! > > probably it's in a hidden field, like Nope. These are my web pages we're talking about here! My name appears on various bits of my pages (my CV, the python-dev summaries), but definitely not on the page google points you to. $ lynx -source http://starship.python.net/crew/mwh/ | grep -i hudson $ > > The "did you mean to search for ..." feature is also downright > > uncanny. > > can't find this option, mind to explain? Try: http://www.google.com/search?q=ken+macloed then just above the results is a little suggestion: Did you mean: ken macleod which of course I did (many of the hits are for the right man; it seems I'm not the only person in the world who can't type). Cheers, M. -- ARTHUR: Yes. It was on display in the bottom of a locked filing cabinet stuck in a disused lavatory with a sign on the door saying "Beware of the Leopard". -- The Hitch-Hikers Guide to the Galaxy, Episode 1 From jm7potter at hotmail.com Wed Jun 13 13:27:03 2001 From: jm7potter at hotmail.com (jm7potter at hotmail.com) Date: Wed, 13 Jun 2001 13:27:03 -0400 Subject: a newbie question about gadfly References: <9g7ter$iqo$1@plutonium.compulink.co.uk> Message-ID: On 13 Jun 2001 14:30:51 GMT, gbreed at cix.compulink.co.uk wrote: >In article , >jm7potter at hotmail.com () wrote: > >> On 12 Jun 2001 15:34:16 GMT, gbreed at cix.compulink.co.uk wrote: >> >> >In article , >> >jm7potter at hotmail.com () wrote: >> > >> >> Why? is namex not a direct replacement for "donna" ???? >> > >> >Um, no, not the way you're doing it. Try replacing that >magic >> >line with >> > >> > >> >Or even >> > >> >cursor.execute("insert into students (name, grade) values >> >(%(namex)s, %(gradex)s)" % vars()) >> > >> >(that's sure to wordwrap!) >> > >> > >> > Graham >> >> >> Thanks for the help Graham, >> >> However, your code did not work either. The little program >chokes every >> time I try to >> do anything that is not "hard-wired" into the script. > >Oops! There is an error: > >cursor.execute( > "insert into students (name, grade) values ('%s', '%s')" > % (namex, gradex)) > >might be better. I forgot to quote the arguments, and at least >one of them is a string. > It Works?!?!! It is alive!! Now, if you have the time and inclination --- could you explain why your first code failed and the second worked? (I hate magic) And further, could you explain to a newbie why *my* code failed? By the way --- thank you so very much for your effort on my behalf. I really do appreciate it much. >> Oddly, the books that mention gadfly do not attempt anything >but >> hard-wired code. >> Perhaps they know something? >> >> Hammond & Robinson cover gadfly in their "Python: programming >on Win32" >> (pp. 256 >> -259) but never attempt to get data from a user and send it to >the >> database. > >Oh, you have that? I think the example right at the bottom of >p.257 should do what you want. In your case > >insertstat = "insert into students (name, grade) values (?, ?)" >cursor.execute(insertstat, (namex, gradex)) > This does not work. I tried it before asking here on this ng. In fact, your suggestion is the very code I tried. I am at a loss as to why it does not work in Python. It shows that I am missing some big deal in my understanding of the language. Some major flaw in my understanding. > >Just in case that doesn't work, I ran this code on the test >database as set up in the middle of p.257 > >>>> bar = 'guiodos' >>>> drinker = 'tim' >>>> perweek = 35 >>>> cursor.execute("insert into Frequents(perweek, bar, drinker) >values (%s, '%s', '%s')"%(perweek, bar, drinker)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Yes, I see how this would work --- I did not even need to try it. But, this is not what was used on page 257. Only the very generous Mr. Graham showed me how to do it. Perhaps you should do a book? >>>> cursor.execute('select * from frequents') >>>> print cursor.pp() >PERWEEK | BAR | DRINKER >============================ >1 | lolas | adam >3 | cheers | woody >5 | cheers | sam >3 | cheers | norm >2 | joes | wilt >1 | joes | norm >6 | lolas | lola >2 | lolas | norm >3 | lolas | woody >0 | frankies | pierre >1 | pans | peter >35 | guiodos | tim > > >> For that matter, in "Learning Python" I see that Lutz & >Ascher do not >> even attempt >> to get user input until page 200 when as an aside to exception >handling >> they tell us >> about raw_input. Well, they do get user input via command line >> arguments, but that >> can take one only so far. > >And raw_input can only get you so far as well, so the emphasis >is on GUIs for user input. > I learned C about 15 years ago. I learned to use the language with very simple i/o --- and later explained to more sophisticated GUI interfaces. Some of us old guys may need to do the same with Python. > > Graham Thank you very much --- your willingness to help out an old newbie is greatly appreciated. Regards, Joe From llothar at mailandnews.de Sat Jun 9 20:17:08 2001 From: llothar at mailandnews.de (Lothar Scholz) Date: Sun, 10 Jun 2001 02:17:08 +0200 Subject: Has anyone used UML? References: <9flodi$32m$1@brokaw.wa.com> <3b228485.13884244@news.laplaza.org> Message-ID: On Sat, 09 Jun 2001 20:18:20 GMT, xyzmats at laplaza.org (Mats Wichmann) wrote: >either, but it seems to be something that benefits Rational most of >all... on the other hand, it may be that Rational Rose really is >"that damn good" (personally, I have zero experience with it). > No its not ! From chad at linuxsupreme.homeip.net Fri Jun 15 17:44:17 2001 From: chad at linuxsupreme.homeip.net (Chad Everett) Date: 15 Jun 2001 14:44:17 -0700 Subject: Do Nested try: ... except: 's work? Message-ID: <20010615214417.17313.cpmta@c017.sfo.cp.net> An embedded and charset-unspecified text was scrubbed... Name: not available URL: From khairy at magnet.fsu.edu Mon Jun 18 14:56:32 2001 From: khairy at magnet.fsu.edu (Khaled Khairy) Date: Mon, 18 Jun 2001 11:56:32 -0700 Subject: Calling MatLab from Python and Back Message-ID: <3B2E4EE0.52AC5A20@magnet.fsu.edu> Hi everyone, I know some effort has been done before to interface Matlab with Python ( specifically for the NumPy arrays). If this group here is not the appropriate one for my problem, I'd appreciate you pointing me to where you think I should go. I have my own matrix classes that I would like to interface. I used the MatLab provided "Engine.h" then I wrap my own API calls with BOOST, and it works fine when I export matrices to MatLab, when I send calls using engEval etc... (as long as I don't try to Plot anything). The problem : engGetArray crashes when the matrix is changed in the Matlab workspace. Either directly or through an engEvalCall Example: ----------- In Python ----------------------- >> x = api_rand(3,3) # this should return a 3x3 random matrix. ----------- In the C++ API ----------------- matrix api_rand_py1() // return a random matrix from Matlab { Engine *ep = mat_open(); //get handle on the MatLab session engEvalString(ep,"InvM = rand(4,4)"); mxArray * MxHandle = engGetArray(ep,"InvM" ); <-----CRASHES HERE matrix mx = mlab_to_gamma(MxHandle); //convert to my own class -- this works and has been tested return mx ; //Return the resulting matrix } ________________________________________________________________ The confusing part is that this function works matrix api_diag_py1(matrix& mx, std::string mx_str) //retrieve the diagonal elements and put them into a vector { Engine *ep = mat_open(); //get handle on the MatLab session gamma_to_mlab(ep,mx, "G" ); //Convert from GAMMA format to MATLAB format engEvalString(ep,"G = diag(G);"); //Perform the actual call -- Note: aren't we changing the matrix here too mxArray * MxHandle = engGetArray(ep,"InvM" ); <-----CRASHES HERE matrix mx = mlab_to_gamma(MxHandle); //convert to my own class -- this works and has been tested return mx ; //Return the resulting matrix } ------------------------------------------------ I tried to make this message short .... sorry ... I failed. I would appreciate any feedbackthogh. Thank you all. Khaled Khairy NHMFL Tallahassee, Fl From philh at comuno.freeserve.co.uk Tue Jun 19 19:53:37 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Wed, 20 Jun 2001 00:53:37 +0100 Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: Message-ID: On Tue, 19 Jun 2001 13:22:06 -0500, Spicklemire, Jerry wrote: > >So, as for Python Card- Go For It! If HyperCard faded due to >"extenuating circumstances", perhaps a comeback is in order. What would a PythonCard be like? Would it be designed more or less as a clone of Hypercard? Or would it keep the ideas, but be a reimplemenation from the ground up, scriptable in python and drawing lessons from the success of the WWW (and possibly having a web interface)? Thoughts, anyone? -- ## Philip Hunt ## ## philh at comuno.freeserve.co.uk ## From BPettersen at NAREX.com Tue Jun 12 21:38:01 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Tue, 12 Jun 2001 19:38:01 -0600 Subject: BIG problem if readline strips newlines Message-ID: <6957F6A694B49A4096F7CFD0D900042F27DB75@admin56.narex.com> > From: Alex Martelli [mailto:aleaxit at yahoo.com] > > "Bjorn Pettersen" wrote in message > news:mailman.992379739.20351.python-list at python.org... > ... > """ > > >standard python idioms will no longer work... > > > > > >for line in file.readlines(chomp=1): > > > pass > > > > Um. Think again? Why wouldn't this work? > > I think he meant: > > while 1: > line = file.readline(chomp=1) > if not line: break > """ > > So if you want your lines pre-chomped you have to use > the faster .xreadlines() approach -- doesn't seem a bad > thing to me... incentive towards progress!-) I seem to recall that 2.2 would allow: for line in file: which IMHO looks much better and is supposed to be just as fast. -- bjorn From andymac at bullseye.apana.org.au Sun Jun 17 04:34:12 2001 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Sun, 17 Jun 2001 18:34:12 +1000 (EST) Subject: ANN: port of Python 2.1 to OS/2+EMX In-Reply-To: Message-ID: I have uploaded a port of Python 2.1 to the incoming directories of the Hobbes (http://hobbes.nmsu.edu) and LEO (http://archiv.leo.org/) OS/2 software archives. This port supports the case sensitive module import semantics introduced in Python 2.1 for case-insensitive but case preserving file systems (such as used by the MS-Windows family of OSes, as well as OS/2). The distributed archives are: python-2.1-os2emx-bin-010617.zip (binary installation package, 2.9MB) python-2.1-os2emx-src-010617.zip (source patches and makefiles, 108kB) More info available at http://www.pcug.org.au/~andymac/software.html; the above archives are also available there if you can't find them at Hobbes or LEO. OS/2 users enjoy! -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andrew.macintyre at aba.gov.au (work) | Snail: PO Box 370 andymac at bullseye.apana.org.au (play) | Belconnen ACT 2616 andymac at pcug.org.au (play2) | Australia From bobhicks.nospam at adelphia.net Mon Jun 4 21:11:51 2001 From: bobhicks.nospam at adelphia.net (Robert Hicks) Date: Tue, 05 Jun 2001 01:11:51 GMT Subject: PMW and Python 2.1 Message-ID: Are there any problems running the latest PMW with Python 2.1? Bob From donn at u.washington.edu Fri Jun 22 12:03:04 2001 From: donn at u.washington.edu (Donn Cave) Date: 22 Jun 2001 16:03:04 GMT Subject: Another Wart! string.find() [ was: namespace issue? ] References: <9gucf9$ruc$1@slb3.atl.mindspring.net> Message-ID: <9gvq7o$hm0$1@nntp6.u.washington.edu> Quoth Michael Powe : | >>>>> "Andrew" == Andrew Dalke writes: | Andrew> Steven D. Majewski wrote: | >> It probably *ought* to return None for not found: | >> "string"[None] yields an exception: "TypeError: sequence index | >> must be integer" while "string"[-1] returns "g" so a coding | >> error is likely to slip thru without an exception. | | >> I'ld love to see it fixed, however, I suspect that in this | >> case, many lines of installed code trumps Computer Programming | >> for Everybody! | | >>>> print string.find.__doc__ | Andrew> find(s, sub [,start [,end]]) -> in | | Andrew> Return the lowest index in s where substring sub is found, | Andrew> such that sub is contained within s[start,end]. Optional | Andrew> arguments start and end are interpreted as in slice | Andrew> notation. | | Andrew> Return -1 on failure. | >>>> print string.index.__doc__ | Andrew> index(s, sub [,start [,end]]) -> int | | Andrew> Return the lowest index in s where substring sub is | Andrew> found, such that sub is contained within s[start,end]. | Andrew> Optional arguments start and end are interpreted as in | Andrew> slice notation. | | Andrew> Raise ValueError if not found. | | Pardon the dumb question, but can you test this in a conditional, as | in | | if not string.index(s,sub) : /* and so forth and so on */ Nope. If sub occurs at the beginning of s, then the result will still be 0. That's false, but I assume the sense of your program would want it to be true. So I find no wart. A function that returns string indices must be expected to return 0 as a valid result. Its return cannot be treated as a boolean. The only way out is to a) ban functions that return string indices, or b) start indices at 1. The latter would make some sense, but 0 works for me, even if after all these years it sometimes bites too. The former is kind of silly, but you could imagine a slice return that would be false on failure. Given that you can't treat find or index as a boolean, there is no fault I can see with its -1 failure return. In fact it would be worse if it were false. Usage that doesn't work reliably ideally shouldn't work at all, or it's all the harder to diagnose. Donn Cave, donn at u.washington.edu From john.thai at dspfactory.com Mon Jun 11 17:27:18 2001 From: john.thai at dspfactory.com (John) Date: Mon, 11 Jun 2001 17:27:18 -0400 Subject: Python grammar.. Message-ID: Hi, I previously asked whether Python accepts function arguments without the opening/closing brackets and commas, like so: foo(x,y) would become foo x y. The answer to this was no. So, I am wondering if it would be easy to modify the source and rebuild the interpretor to accept this format? I tried modifying the Grammar file but that didn't seem to work... Thanks, John From tim.one at home.com Fri Jun 1 02:09:04 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 1 Jun 2001 02:09:04 -0400 Subject: Obsolesence of <> (fwd) In-Reply-To: <9f798k$hc4$1@panix2.panix.com> Message-ID: [Lulu of the Lotus-Eaters] > Huh? What does Unicode have to do with anything? The below works fine, > for example: > > Python 2.0.42-S1.2.23 (#0, Apr 25 2001, 20:59:49) [GNU C/C++] on os2 > Type "copyright", "credits" or "license" for more information. > >>> x = u"spam" > >>> y = "spam" > >>> z = 1+1j > >>> w = u"eggs" > >>> x < y > 0 > >>> x < z > 0 > >>> x < w > 0 >>> chr(128) < u"a" Traceback (most recent call last): File "", line 1, in ? UnicodeError: ASCII decoding error: ordinal not in range(128) >>> From bill-bell at bill-bell.hamilton.on.ca Mon Jun 18 15:35:43 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Mon, 18 Jun 2001 15:35:43 -0400 Subject: Help, pls: COM local server factory class In-Reply-To: <992888416.1575.78261.l8@yahoogroups.com> Message-ID: <3B2E1FCF.10029.442DE43@localhost> Esteemed Pythonistas: The code that appears below is intended to define a COM local server. (My understanding of some earlier messages on this list is that it should result in a singleton by default.) There are two classes in the server, one of them being a factory for the other (and defined near the end of the code). Two questions I'd appreciate answers to (bearing in mind I'm new to Python): 1. How close is the factory class to what I ~should~ be doing? 2. What is the meaning of the following? >>> import win32com.client, msvcrt, pythoncom >>> factory = win32com.client.Dispatch("WebPASS.ServerFactory1") >>> server = factory.Factory() Traceback (most recent call last): File "", line 1, in ? File "", line 2, in Factory com_error: (-2147352567, 'Exception occurred.', (0, 'Python COM Server Internal Error', 'Unexpected Python Error: exceptions.TypeError: Objects for SAFEARRAYS must be sequences (of sequences), or a buffer object.', None, 0, - 2147467259), None) >>> Thanks for any help you can render. Bill def GUI(): try: WebPASSPath = os.path.split(__file__)[0] os.chdir(WebPASSPath) except: pass global app app = WebPASSApp(0) app.MainLoop() from threading import Thread class GUIThread(Thread): def _init_(self): Thread._init_(self) def run(self): GUI() def main(): t = GUIThread() t.start() time.sleep(5) app.frame.ReportActivity("... from main()") class COMServer: _reg_clsid_ = "{D471BE26-C3C8-4773-B438-041BA612C563}" _reg_desc_ = "WebPASS COM Server" _reg_progid_ = "WebPASS.Server1" _public_methods_ = ['Report'] _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER def __init__(self): main() def Report(self, msg): app.frame.ReportActivity("... from COMServer.Report(self) " + str(msg)) class COMServerFactory: _reg_clsid_ = "{ED8F1767-4035-4c20-8162-24C2EE9E380C}" _reg_desc_ = "WebPASS COM Server Factory" _reg_progid_ = "WebPASS.ServerFactory1" _public_methods_ = ['Factory'] _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER def __init__(self): self.theCOMServer = None def Factory(self): if self.theCOMServer == None: self.theCOMServer = COMServer() return self.theCOMServer if __name__ == '__main__': import win32com.server.register win32com.server.register.UseCommandLine(COMServer) win32com.server.register.UseCommandLine(COMServerFactory) From tim.one at home.com Sun Jun 24 22:01:49 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 24 Jun 2001 22:01:49 -0400 Subject: Is this a true statement? In-Reply-To: Message-ID: Hmm. Has anyone in this thread written a device driver? If not, I'd like to point out that PEP 255 generators are ideally suited to the task . although-that's-awaiting-a-"dev"-keyword-ly y'rs - tim From tim.one at home.com Tue Jun 19 19:32:11 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 19 Jun 2001 19:32:11 -0400 Subject: PEP 255: Simple Generators In-Reply-To: <3B2EC6BA.4D504554@alcyone.com> Message-ID: [Erik Max Francis] > This is an extremely clever idea. Indeed it is, but you can thank Ralph Griswold (Icon's dad) for most of the Python inspiration; Sather and CLU played indirect roles (most visibly, both of those use "yield"; Icon uses "suspend"). Note that in Knuth's terminology, they're simply "semi-coroutines". These ideas used to be more common in programming! We're just trying to bring Python up to 1960 . From ullrich at math.okstate.edu Mon Jun 25 10:32:29 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 25 Jun 2001 14:32:29 GMT Subject: Is this a true statement? (fwd) References: <3b36149c.11483184@nntp.sprynet.com> <3B36A682.78D94F22@engcorp.com> Message-ID: <3b374961.3150243@nntp.sprynet.com> On Sun, 24 Jun 2001 22:48:34 -0400, Peter Hansen wrote: >"David C. Ullrich" wrote: >> >> On Sun, 24 Jun 2001 10:14:31 -0400 (EDT), "Steven D. Majewski" >> wrote: >> >> >I concede, David! >> >Your logic is unassailable >> >and your point is significant. >> >> The "point" about device drivers is certainly not >> "significant" in any way I can imagine. This _did_ >> start with honest _questions_, which actually >> nobody's answered. For all I know "write a >> device driver" _could_ mean something other >> than "write a certain sequence of bytes to >> a file". > >"Write a device driver [in language X]" means to use >language X as the *source language*, and with existing >(i.e. not theoretical) tools, turn that source into >an output file (usually "machine code") capable of >performing the functions typically defined as requiring >"device drivers". For more of us it does, anyway. > >It does not mean "using a program written in language X, >generate a file containing an identical sequence of bytes >to that which would have been generated using the above >method with some other language". > >Or something like that. Something like that indeed. > Really, it isn't that hard. > >(If it will help, since your words above suggest the >possibility you actually might be missing something here, >look at the distinction between "write a device driver >in Python" and "write a device driver file using >Python". The word "in" in the former suggests using >Python as the direct source language of the driver, >not as a utility or compiler to be used in the process.) If someone had said this yesterday would have saved a lot of space. (Not a complaint, there's no way anyone could realize that this actually is what I was missing about the terminology.) >Something tells me this won't be an epiphany for you... :) And exactly what tells you that? Up to this line my reaction was "thank you very much". My reply to this bit would be a little different... >possibility you don't understand I asked _repeatedly_ whether "write a device driver" means something other than "write a certain sequence of bytes to a file". Nobody answers the question. I point out it hasn't been answered and ask again. Nobody answers the question. Yes, I did have a hard time understanding answers that did not exist. "Really, it isn't that hard" is really not condescending, I guess. If you think it's possible to deduce what people mean by a phrase when they're not telling you you're wrong. David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From jeff at ccvcorp.com Wed Jun 20 13:12:18 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: 20 Jun 2001 10:12:18 -0700 Subject: Interfacing GUI applications..? References: <3B18032E.21AF631E@pfortin.com> Message-ID: <16074dce.0106200912.7b9bc793@posting.google.com> claird at starbase.neosoft.com (Cameron Laird) wrote in message news:... > In article <3B18032E.21AF631E at pfortin.com>, > Pierre Fortin wrote: [snip] > >The minimum requirement is to make AcroRead think it's coming from the > >keyboard. Extra points for mouse events (or shortcuts, though not all menus > >items have shortcuts). [snip] > If you're operating under Windows (I speculate you > are), and if AcroRead is a COM server (I anticipate > that it is), then you're in luck; Python is a GREAT > language for COM scripting. > > If not ... we'll try something else. One suggestion for "something else"... there is a Visual Basic function "sendkeys()" that does exactly what is requested--it simulates keyboard input to another application. At one point I downloaded a COM object that wrapped this function (plus ActivateApp(), IIRC) from Clarence Washington's Windows scripting site (http://cwashington.netreach.net); I would presume that the download is still available there. Using this COM object (from Python) lets me send simulated keystrokes to any Windows app, and I believe that it also allows sending ctrl-keys as well. Of course, if the app you're interested in (AcroRead) *is* a COM server, then you'll be much better off controlling it directly. One word of warning--the scripting site uses DHTML tricks, or some such, that crash Netscape upon loading, so it may be necessary to use IE... > Incidentally, ReportLab might interest you. 'Any- > one out there have any user reports on ReportLab? > I've cobbled together some of my own PDF manipula- > tions, but I'll happily discard all of them for a > well-done package. I'd be interested in hearing reviews/testimonials on ReportLab as well. Somewhere down near the bottom of my list of projects, I'm looking to create PDF docs automatically. At first glance, ReportLab looks ideal, but reports of firsthand experiences are always good.... Jeff Shannon Technician/Programmer Credit International From tim.one at home.com Thu Jun 28 00:24:09 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 28 Jun 2001 00:24:09 -0400 Subject: exec "global" problem In-Reply-To: <01062719055701.09000@penguin> Message-ID: [Michaell Taylor] > I have seen lots of discussion of the problem of executing the > following code: That's odd -- I haven't seen any! Where are you hiding it ? > global sub > sub=['sub1', 'sub2', ...'sub600'] > def make(): > for X in range(1,600): > exec "global sub%s" % (X) > exec "sub%s={}" % (X) > other stuff > > The problem is the > > exec "global sub%s" % (X) > > line which doesn't execute ... Sure it does. But it has nothing to do with the next line: each exec creates a new code block, and calling a thing "global" in one block has no effect on its local-vs-global status in any other code block. You can study the reference manual to try to sort that all out (it's functioning as documented), but it's much easier not to use exec at all: def make(): g = globals() for i in range(1, 600): g["sub%d" % i] = {} Run that and you'll find it creates 599 dicts in your global namespace. > ... > These 600 dictionaries are subsequently passed to a variety of > functions. You should really say something about what you're trying to accomplish in the *end*, so c.l.py can help. Think of this as the c.l.py Suicide Prevention Line . not-even-mother-earth-is-*that*-global-ly y'rs - tim From rnd at onego.ru Mon Jun 25 00:34:34 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 25 Jun 2001 08:34:34 +0400 (MSD) Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: On Sun, 24 Jun 2001, Tim Peters wrote: >[Roman Suzi, on my gcomb example] >> This implementation is cool, but how fast will be recursive generators? >> How large is the overhead to defrost execution frame each time? Will it >> be faster than functional gcomb? Well, of course memory usage of generators is minimal. But the version I posted was made more compact because I used list comprehension and no "insert", etc Maybe there could be some reason to add "yield" in a form of function also to make things like: [ << x for i in .... ] possible? (here "<<" denotes proposed systax, unary "shift") Or something like: [yield(x) for x in ....] Of course, I am aware that "yield" is flow control operator, but there are equivalents of almost all other operators for use in functional style programs. And it seems that to make them use generators will mean rewrite them in .append/.extend/.insert fasion... >On my box at the moment (Win98SE), the generator version below-- and on the >test case shown --is about a 50% speedup over the recursive version (about >.16 seconds for gcomb and .24 for rcomb). > >less-filling-and-tastes-great-ly y'rs - tim > >PS: In rcomb, a good speedup can be obtained by replacing > > for c in rcomb(rest, k): > result.append(c) >by > result.extend(rcomb(rest, k)) Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Monday, June 25, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Darth Vader sleeps with a Teddywookie." _/ From piet at cs.uu.nl Sat Jun 2 14:14:51 2001 From: piet at cs.uu.nl (Piet van Oostrum) Date: 02 Jun 2001 20:14:51 +0200 Subject: problems with mod_python References: Message-ID: >>>>> Oleg Broytmann (OB) writes: OB> On 29 May 2001 piet at cs.uu.nl wrote: >> Now hope you don't get any problems with multithreading. Mod_python on MS >> Windows tends to give intermittent problems when 2 or more requests come in >> at approximately the same time and Apache serves them in different threads. OB> AFAIR some docs sais you must recompile Python without threads to use OB> modpython. I think PyApache can be used with tread-enabled Python. But I OB> didn't do enough tests. I read on the mod_python mailing list that the threading bug has been fixed. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From ken_chiba at hotmail.com Sun Jun 24 22:35:35 2001 From: ken_chiba at hotmail.com (Ken) Date: Mon, 25 Jun 2001 02:35:35 GMT Subject: installing MySQLdb with Python 2.1 Message-ID: <3b36a319.369414049@news1.on.sympatico.ca> Hi, I'm trying to install MySQLdb for use with Python 2.1, on a RH 7.1 system. Unfortunately, I succeeded using the RPM, and it embedded it into the Python 1.5.2 release (and not the 2.1). How would I get this to work with 2.1? (ie. when I type "import MySQLdb" in python2, there is an error...). Thanks! kc From rnd at onego.ru Wed Jun 20 11:25:54 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 20 Jun 2001 19:25:54 +0400 (MSD) Subject: Suggested amendment to PEP 255 In-Reply-To: <4abd9ce7.0106200638.5896c8@posting.google.com> Message-ID: On 20 Jun 2001, damien morton wrote: Could't there be some reuse of << and >> operators, but in unary notation, for "yield"? Like: ... >> x and then somewhere else: << g() -- this will be more natural than thinking of some new keywords! every func will be a generator, but most will produce [] >Simon Brunning wrote in message news:... >> > From: Greg Ewing [SMTP:greg at cosc.canterbury.ac.nz] >> > I suggest dropping the "def" altogether and using: >> > >> > generator foo(args): >> > ... >> > yield x >> > ... >> >> This gets my vote. Or it would. If I had a vote. Which I don't. >> >> *Excellent* PEP, BTW! >> >> Cheers, >> Simon Brunning >> TriSystems Ltd. >> sbrunning at trisystems.co.uk > >Im 100% with this too. doubleplusgood would be my vote, if I had one. >Generators do seem different enough from functions to warrant a different syntax. > >some other syntax possibilities: > >gen foo(args): > yield x > >def foo(args) generator: > yield x > >def foo(args) as generator: > yield x > >def generator foo(args): > yield x > Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Wednesday, June 20, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Is it possible to feel gruntled?" _/ From thomas at cintra.no Sat Jun 16 13:55:49 2001 From: thomas at cintra.no (Thomas Weholt) Date: Sat, 16 Jun 2001 17:55:49 GMT Subject: Question about profiling Message-ID: When I profile my code I get a lot of :1(?) that takes up alot of time. What does that mean? Thomas From jkraska1 at san.rr.com Tue Jun 26 02:14:05 2001 From: jkraska1 at san.rr.com (Courageous) Date: Tue, 26 Jun 2001 06:14:05 GMT Subject: ActiveX Controls in Python References: <4dfd15be.0106251529.54b71a63@posting.google.com> Message-ID: >(convincing my boss to give >me time to extend Python in win32 when I'm meant to be writing a >C++/win32 application would be difficult to say the least!) While I'm sure every situation differs, one truth I've found over the years: do not convince, PRODUCE. C// From mertz at gnosis.cx Sat Jun 2 12:51:10 2001 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Sat, 02 Jun 2001 12:51:10 -0400 Subject: random (fwd) Message-ID: <+lRG7kKkXI5L092yn@bellatlantic.net> Coming, admittedly, a bit late to the conversation on this topic, I'm surprised to find Alex a bit too dedicated to his point... and making a few errors about which he knows better: Someone wrote: >A physical RNG can have the property that one cannot make >any prediction about the value of the next bit even given >_complete_ information about how the numbers are being >generated. "Alex Martelli" wrote: |This says "GIVEN _complete_ information". Now you say |you CANNOT "have complete information". The two |statements are in contradiction. No contradiction in this. "If you COULD have complete information you can not make a prediction" does not imply that you CAN have complete information. If I COULD lift 1000 lbs, I still couldn't lift my car. But then, I CAN'T lift 1000 lbs anyway. Not so complicated. |I _think_ -- but am not a philosopher or mathematician |so cannot feel sure -- that part of what Goedel shows is |that arithmetic is powerful enough to model any other |formal system. Well... I *am* a philosopher, and have occassionally pretended to be a mathematician (not the most convincing pretense though). But I don't think one needs to be to see what's wrong with the above. Assuming "Goedel" means his incompleteness theorem in the above, he really doesn't show anything like the above. The Incompleteness of Arithmetic simply says: ANY (finite axiomatic) system powerful enough to model arithmetic must contain statements that are not derivable from the axioms of that system. So, for example, ZF can model the Peano axioms, and therefore gets stung by the incompleteness bug. But this much leaves open the possibility that ZF is strictly more powerful than arithmetic. (question though: is this actually true of ZF--can it be modelled with the Peano axioms?). Moreover, it is easy enough to construct a system that is strictly more powerful than arithmetic, at least if one means something specific and axiomatic by "arithmetic." Let's say, for example, that the Peano axioms model arithmetic for our standard. Given the Goedel machinery, we can derive a specific statment of Peano arithmetic, _I_, that is neither a theorem nor a contradiction of Peano arithmetic. Therefore, we can create a new system Peano+_I_, that is both consistent (if arithmetic is) and not modelled by arithmetic. Moreover, we can now derive an infinite number of new theorems of Peano+_I_ that utilize _I_ in their derivation and that are independent of Peano arithmetic. Yours, Lulu... From root at rainerdeyke.com Fri Jun 29 21:09:03 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Sat, 30 Jun 2001 01:09:03 GMT Subject: PEP scepticism References: Message-ID: "phil hunt" wrote in message news:slrn9jq3rc.qg9.philh at comuno.freeserve.co.uk... > On Fri, 29 Jun 2001 17:43:34 -0400, Tim Peters wrote: > >Or the other existing method: > > > > # This is a multi-line comment. > > # Although it sure looks like a sequence of > > # single-line comments . > > This is truly bad, because it makes it harder to add new lines; > you have to type "# " repeatedly when adding new comment text, which > breaks the flow of thought -- at least it dores for me. Strange. In C++, I always use '//' for multiline comments in favor of '/**/'. ('//' in C++ is equivalent to '#' in Python.) This makes the comment more readable IMO. Why not just type the comment text first, and add '#' marks later? -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From wroot at my-deja.com Fri Jun 8 01:40:35 2001 From: wroot at my-deja.com (Wroot) Date: 7 Jun 2001 22:40:35 -0700 Subject: GROUP TAKEOVER IN PROGRESS References: <902430AC4moondustapexnet@209.99.56.9> <93hn81$l4m$1@nnrp1.deja.com> <9025628F7moondustapexnet@209.99.56.9> <3a5c8520_1@news.foxinternet.com> <902581E21moondustapexnet@209.99.56.9> <3a5ce21b_1@news.foxinternet.com> <4A982771F09.psskvxvn@vluxxijwai.net> Message-ID: shawntaub at yahoo.ca (Shawn Michael Taub) wrote in message news:... > All your base are belong to us, Where is this from? I keep seeing it everywhere. Must be a classic. Something Pr. Nixon used to say, perhaps? Wroot From SBrunning at trisystems.co.uk Fri Jun 1 04:40:16 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Fri, 1 Jun 2001 09:40:16 +0100 Subject: Parameter passing in python Message-ID: <31575A892FF6D1118F5800600846864D78BCB2@intrepid> > From: Jacob Hallen [SMTP:jacob at hq.workspot.com] > > In Python 2, > > Pmw.ButtonBox.__init__(self, parent, **kw) > > is equivalent to the apply you have written. > This does indeed work. Thanks! > > However there is no mention at all of this in the Python Reference > Manual. I have checked both the 2.0 and 2.1 versions. It ought to > be in section 5.3.4, as far as I can understand. It's in the Python *Quick* reference, though - . Hmmm, it's in the wrong place though. I think. A call is an expression rather than a statement, isn't it? Oh well, I'll fix this for the 2.1 version. Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From tim.one at home.com Sun Jun 24 05:05:37 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 24 Jun 2001 05:05:37 -0400 Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: [David Eppstein] > ... > Why is tail recursion somehow unPythonlike? It's not, where it's appropriate -- but it's not appropriate in Python nearly as often as in languages like Scheme or Haskell. It starts with the builtin collection types: Python lists (and tuples) aren't cons cells, they're contiguous vectors, and so for-loops are the *natural* way to process them. Tail-recursion is pretty much insane for that in Python, as processing list[0] then recursing on list[1:] turns a speedy task into a quadratic-time mess. Then, as below, so above . > Or, more to the point, why should it remain that way? Most Python programmers use tail recursion rarely or never, so there's little demand to change it. There's also no volunteer to work on it. > If it's merely that it is implemented inefficiently (i.e. piling up > unnecessary stack frames) When something raises an uncaught exception, "unnecessary" become highly debatable (thinking of the diagnostic traceback here, and of the debugger). Python's WYSIWYG tracebacks are an important feature; "losing frames" to tail-recursion optimization would likely need to be optional, and disabled by default, because of this. > then that can be fixed, no? It hasn't been yet, and the prospects are nil in the absence of a PEP. From SBrunning at trisystems.co.uk Wed Jun 20 03:48:41 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Wed, 20 Jun 2001 08:48:41 +0100 Subject: Suggested amendment to PEP 255 Message-ID: <31575A892FF6D1118F5800600846864D78BD62@intrepid> > From: Greg Ewing [SMTP:greg at cosc.canterbury.ac.nz] > I suggest dropping the "def" altogether and using: > > generator foo(args): > ... > yield x > ... This gets my vote. Or it would. If I had a vote. Which I don't. *Excellent* PEP, BTW! Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From elf at halcyon.com Mon Jun 18 02:53:34 2001 From: elf at halcyon.com (Elf Sternberg) Date: 18 Jun 2001 06:53:34 GMT Subject: qt or gtk? References: Message-ID: <9gk8he$8gl$1@brokaw.wa.com> In article sill at optonline.net (Rainy) writes: >> Qt is distributed under the GNU Public License and TrollTech's >> Commercial License. What this means is that if you write a program >> using Qt, you have two choices: you can distribute your program in the >> whole, source code and all, or your can pay TrollTech's licensing >> contract and keep your source code secret. >Is this true for both qt for X and qt for windows or only for X qt? The GNU Public License does not specify what operating systems it applies to. If you can build or modify the GPL version of QT to work with the Windows operating system, then you can build GPL programs for Windows with QT. Elf -- Elf M. Sternberg, rational romantic mystical cynical idealist http://www.halcyon.com/elf/ Dvorak Keyboards: Frgp ucpoy ncb. ru e.u.bo.v From timr at probo.com Fri Jun 15 02:10:29 2001 From: timr at probo.com (Tim Roberts) Date: Thu, 14 Jun 2001 23:10:29 -0700 Subject: PEP 259: Revise to remove context-driven magic from print References: <486de2.0106131406.5c0cbef9@posting.google.com> <9g8tve$8ft$0@216.39.170.247> Message-ID: <1h9jit45iin7m2bmc49oaj4j2p3cla91sg@4ax.com> David LeBlanc wrote: > >Examples: > >a = "foo" >b = "bar" >raw_print foo bar ->> foobar #no newline! >raw_print foo,bar ->> foo bar #no newline! >raw_print \n #newline! in quotes if needed. Actually, I believe this will result in: Traceback (most recent call last): File "", line 1, in ? NameError: name 'foo' is not defined. On the other hand, raw_print a b # foobar no newline raw_print a,b # foo bar no newline -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From jmurray at agyinc.com Thu Jun 7 14:57:59 2001 From: jmurray at agyinc.com (Joe Murray) Date: Thu, 07 Jun 2001 11:57:59 -0700 Subject: PortableUnixMailbox problem References: Message-ID: <3B1FCEB7.37B2649C@agyinc.com> Gustaf Liljegren wrote: > > Guess I don't understand how to use it, but I get this error when trying to > use the new (2.1) PortableUnixMailbox class: > > E:\test>python pum.py > Traceback (most recent call last): > File "pum.py", line 4, in ? > m = mb.next() > File "e:\python\lib\mailbox.py", line 19, in next > self.fp.seek(self.seekp) > AttributeError: seek > > And my code: > > from mailbox import PortableUnixMailbox > > mb = PortableUnixMailbox('in.mbx') > m = mb.next() > > The problem appears on the line "m = mb.next()", where I try to create a > rfc822.Message object from the mailbox. > > Regards, > > Gustaf Liljegren > -- > http://mail.python.org/mailman/listinfo/python-list Try using a file-like object as the argument to the PortableUnixMailbox function: >>> from mailbox import PortableUnixMailbox >>> mb = PortableUnixMailbox(open('nsmail/Sent')) >>> m = mb.next() >>> m >>> That should work. So would a StringIO object, or any object that implements the necessary file-like read, readline methods (and maybe a few other methods I'm forgetting...). joe -- Joseph Murray Bioinformatics Specialist, AGY Therapeutics 290 Utah Avenue, South San Francisco, CA 94080 (650) 228-1146 From planders at journyx.com Fri Jun 1 16:27:12 2001 From: planders at journyx.com (Preston Landers) Date: Fri, 1 Jun 2001 15:27:12 -0500 Subject: Generating WSDL for Python SOAP services Message-ID: <9f8tri$2g1$1@news.jump.net> Hi all. My company (journyx.com) is planning to use SOAP to expose some methods of our application server. The goal is to write a client that will ultimately be embedded in an MS Office application and make calls to installations of our software. We are using the actzero.com SOAP.py 0.9.5 module to implement the server side, and the MS SOAP 2.0 toolkit on the client side. The MS toolkit "high level API" requires that services have a WSDL (web services description language) file that describes the methods that are availible and their parameters. We are really hoping to use the "high level API" and thus avoid writing our own handlers in Visual Basic, which is not our forte. (Python is.) Therefore I am planning to write a WSDL generator that will examine our exposed methods and write out a valid WSDL file. I realize you can compose a WSDL file by hand, but since our interface is changing rapidly, we think a generation program is the way to go. I am not sure yet it I can generalize it enough to be useful to the general public or if it will be specific to our application. We already have a set of classes in a module that contain the methods exposed by SOAP. Most of these methods are simple wrappers to the "real" internal API of our application. It should be easy enough to programmatically determine the methods. The real trick seems to be determining the types of the parameters. We are thinking of using the new function attributes in Python 2.1 give each method a descriptor that defines its parameters. I'm posting to the newsgroup to check if anyone else is already working along these lines, or has any thoughts on the subject. cheers, Preston Landers Software Developer, Journyx Inc. planders at journyx.com From mwh at python.net Thu Jun 14 03:35:30 2001 From: mwh at python.net (Michael Hudson) Date: 14 Jun 2001 08:35:30 +0100 Subject: PEP 259: Revise to remove context-driven magic from print References: <486de2.0106131406.5c0cbef9@posting.google.com> Message-ID: robin900 at yahoo.com (Robin Thomas) writes: > Feedback, please. If you all are positive about the proposal below, > I'll work it up into a new PEP. IMHO, starting afresh would be a better idea. > Summary: > > PEP 259 should be reworked to remove contextual magic from print > statement, which was the main demand made by the Python community > when *rejecting* the PEP. Then it could be resurrected from > rejection. I'm very much in the "ain't broke, don't fix it" category. > Opinions: > > 0) We don't need another built-in function that echoes what print > does. Please. Probably not. > 1) We can't get rid of "print". It is a very common idiom in many > languages. Backwards compatibility? Removing print would be *insane*, for several reasons. > 2) Python coders learn to avoid print because a print statement's > behavior changes with a run-time context that the coder cannot > necessarily control. To rehabilitate print, remove the context > magic. Not true, in my case. I do use it mainly as a debugging tool, though. > 3) Whenever I have a string of bytes that I wish to write to > sys.stdout, without any formatting magic such as space characters or > newlines, I cannot use the print statement, because it offers me no > way to "turn off" all the formatting magic. Thus I am required to > absorb the conceptual overhead of the sys module, sys.stdout and > "standard output", file objects, and the write() method, just so that > I can avoid having Python prepend a space character to my output in > certain cases. For a novice Python coder, that sucks. Oh please. Novices can just use print. Certainly, if you always write print a, b, c rather than print a, b, c, you're pretty unlikely to get into problems. In fact the only way I can conceive of problems arising is when you are writing code that prints to stdout and interleaving that with calls to code that also prints to stdout - and that's never going to work is it? > 4) "softspace" has always seemed to me quite a lame thing to be part > of the official file object API. What should file objects care about > some cheesy report-printing operation like "print"? I agree it's a hack, but thinks it's a reasonably clever one. How else do you avoid >>> print "a", a>>> whilst also avoiding >>> print "a" a >>> ? I'm not convinced this is all worth the effort, mind. > 5) The "am i at the start of a line context" only helps me when I want > > print 1,2, > print 3,4, > print 5 > > to be equivalent to > > print 1,2,3,4,5 > > ...and I have never exploited that feature of Python print, even in > lazy report scripting, the application for which the feature seems to > be intended. I have. [...] > Proposed "new" PEP 259 > --------------------------------- [...] > 5) It is suggested that the values for "space separator" and "newline" > be system-dependent, settable at run-time, and available in modules > sys or os. Your feedback is welcome on this issue. Hah! You make an argument for removing complexity from print, and then propose adding more! If you want to print "0-1-2-3+4-5-6+2" you can do it yourself. Furrfu. [...] > Again, print is not important enough to demand attention from > designers of file-like objects. You do realize that the softspace magic "just works" with most user implemented files? (ie. ones implemented in Python). [...] Run out of energy, sorry. Cheers, M. -- FORD: Just pust the fish in your ear, come on, it's only a little one. ARTHUR: Uuuuuuuuggh! -- The Hitch-Hikers Guide to the Galaxy, Episode 1 From aleaxit at yahoo.com Wed Jun 13 04:03:08 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 13 Jun 2001 10:03:08 +0200 Subject: Python grammar.. References: Message-ID: <9g76nr0212s@enews1.newsguy.com> "Delaney, Timothy" wrote in message news:mailman.992393599.3573.python-list at python.org... ... > way to do it - a subroutine may or may not return a value, at its > discretion, and I should be able to ignore any returned value. Yes, but if I were designing a language today, I think I would request you to be EXPLICIT about "ignoring the return value" -- explicit is better than implicit. It IS an occasional cause of errors in Python (particularly with newbies) that an expression statement's value is silently and implicitly ignored... Alex From noselasd at frisurf.no Wed Jun 20 08:52:26 2001 From: noselasd at frisurf.no (Nils O. Selåsdal) Date: Wed, 20 Jun 2001 14:52:26 +0200 Subject: qt or gtk? References: Message-ID: "D-Man" wrote in message news:mailman.992727265.27933.python-list at python.org... > On Sat, Jun 16, 2001 at 05:52:12AM +0000, Rainy wrote: > | > | I want to learn python gui programming in linux. I think tk looks too ugly, so > | I narrowed down the choice to two main contenders, qt and gtk. Which of these > | has more complete and up-to-date python bindings? Are there other reasons > | to prefer one of these over another for python gui work? > > Personally I like GTK better. I don't like the way Qt tries to look > like MS Windows. Glade+libglade make a great combination for rapid Use the Motif look'n'feel, or the SGI look'n'feel... > coding. Use glade (a gui) to build the static parts of the interface, > then load them at runtime with libglade. You simply write the event > handlers and connect them to the events in your code. You can > completely change the look of the UI without changing any code as long > as the names of widgets and their type match (ie you don't change from > a tree to a list). QT designer also does this. > wxWindows and wxPython look nice, though I haven't worked with them > enough to know if I like the style of the interface. It looks like MFC to mee, and MFC is NOT nice... From chrishbarker at home.net Thu Jun 21 15:14:52 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 21 Jun 2001 12:14:52 -0700 Subject: Managing Python sources in CVS & whitespace References: Message-ID: <3B3247AC.620751B6@home.net> Ville Vainio wrote: > Are there any issues with Python sources and CVS (I'm thinking of the > whitespace thing here)? Do the diffs or merging branches get screwed > up? Are there any special considerations? No. Why would there be? CVS handles any text file format just fine. > This is a kind of thing that should appear in the FAQ... It doesn't because it is a non-issue. I've been using cvs ro manage a Python project for a while, it's well worth it. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From yozh at mx1.ru Mon Jun 18 04:27:41 2001 From: yozh at mx1.ru (Stepan Koltsov) Date: Mon, 18 Jun 2001 08:27:41 +0000 (UTC) Subject: libiconv & python Message-ID: <9gke1t$2bbo$1@proxy.niit.ru> Hi, All. I wrote a small wrapper for libiconv, is it needed to anybody? Or maybe it was written earlier (I could not find) ? in any case it can be find at http://www.mx1.ru/iconv/iconv-0.1.0.tar.gz. -- mailto:yozh at mx1.ru ICQ:26521795 http://www.mx1.ru/ From itamar at zoteca.com Tue Jun 5 13:02:03 2001 From: itamar at zoteca.com (Itamar Shtull-Trauring) Date: Tue, 05 Jun 2001 20:02:03 +0300 Subject: Recovering memory from loaded modules Message-ID: <3B1D108B.19B2508C@zoteca.com> Hiya everyone, I've got a long running process that uses lots of modules (XML, wxPython). Therefore, memory usage is really high (17MB). Now, I don't actually need all the modules at all times - so, how can I unload modules from memory? Delete all references, and delete from sys.modules? This doesn't seem to help. -- itamar(at)shtull-trauring.org || itamar(at)zoteca.com http://itamarst.org || http://www.zoteca.com From skip at pobox.com Mon Jun 11 19:56:57 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 11 Jun 2001 18:56:57 -0500 Subject: metaclasses -- aka Don Beaudry hook/hack (was RE: Why should i use python if i can use java) In-Reply-To: References: Message-ID: <15141.23241.997292.55633@beluga.mojam.com> James> I have found is that "the hook" doesn't seem to be complete in James> the sense that only the "class" statement seems to know about the James> hook. Jim Fulton's ExtensionClass stuff knows about the Don Beaudry hook. ExtensionClasses are used in Zope (you can get the source from any Zope distribution) and by the latest Python wrappers for Gtk. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From kirk at strauser.com Sat Jun 16 21:31:25 2001 From: kirk at strauser.com (Kirk Strauser) Date: 16 Jun 2001 20:31:25 -0500 Subject: Python version of IQ has been updates (IQ v0.34.python) References: <505.566T11T1243597threeseas@earthlink.net> <3B2A7F5E.MD-1.4.4.padf@ihug.com.nz> <3871.567T2214T9794928threeseas@earthlink.net> Message-ID: <87puc3ao42.fsf@pooh.honeypot> At 2001-06-16T22:02:55Z, "Timothy Rue" writes: > There was a recent article on slash dot about Python becomming GPL > compatiable. It's open source and has a rich pattern matching module > amoung many other note worthy things about it. Tim, Have you ever looked into Perl? We use it almost exclusively for integrating large distributed systems, and its regular expression system is second-to-none in my experience. Python's a good language (from what I hear - I keep meaning to look into it), but Perl has a lot going for it also. It isn't GPL (it's distributed under the Artistic License), but even RMS agrees that it is Free in every sense of the word. -- Kirk Strauser From alan.gauld at bt.com Mon Jun 4 13:18:01 2001 From: alan.gauld at bt.com (Alan Gauld) Date: Mon, 04 Jun 2001 18:18:01 +0100 Subject: screenscraping References: <991411356.20275.0.nnrp-10.c1c3e154@news.demon.co.uk> Message-ID: <3B1BC2C9.17BF45AB@bt.com> Paul Brian wrote: > like to know if it is possible to (using python) activate a windows > application that takes input from a GUI, and enter in data through > the GUI programmatically. If you are using a reasonable terminal emulator you should find there is an API to control the screen. For example most 3270 TEs come with HLLAPI intefaces to set cursor positions, read fields etc. Again if its a modern API you should be able to control that via a COM interface in which case the winall package will do the job. Thats two big ifs but not unreasoinable ones. Check your TE documentation. If there is no API or you are using something really dumb then you will be stuck with saending keystrokes via the Win32 API - ugh a maintenance nightmare...! > I am prevented from using any kind of API or direct interface I assume here you mean an API to the underlying app not an API to the terminal emulator... Alan g. From cfelling at iae.nl Thu Jun 28 14:45:29 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 28 Jun 2001 20:45:29 +0200 Subject: What is my module name? References: Message-ID: <9hfu09$c59$1@animus.fel.iae.nl> Clark C . Evans wrote: > I have a module with a function below I > use __name__ to return the module name. > However, when I call the function from > outside, it returns '__builtin__'. Is I wonder how you get those results. $ python >>> __name__ '__main__' $ cat a.py def name(): return __name__ print "a:", name() $ python a.py a: __main__ $ cat b.py import a print "b", a.name() $ python b.py a: a b: a -- groetjes, carel From m.faassen at vet.uu.nl Wed Jun 20 18:40:08 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 20 Jun 2001 22:40:08 GMT Subject: Any other Python flaws? References: Message-ID: <9gr8o8$hhq$4@newshost.accu.uu.nl> Bruce Sass wrote: [snip] > If you want to use someone's GPLed lib, or GPLed software that > exposes its libs APIs so others can make use of it, in your > proprietary project, make sure you release the source for the libs you > used and for any tweaks you may have made to it. Not to get into an endless GPL debate here, so I won't say anything more about this, but what you say here is not the common interpretation of the GPL. The common interpretation of the GPL is that your software should be GPLed or GPL-able if it links to a GPL-ed library. What you say is true for the LGPL. That's the last I'll say in this particular thread about the GPL. :) The PSU Public License is an open source licence even more infectuous than the GPL. Even software that does not link to it must be released under the PSUPL. Even software on a completely different computer, even on a completely different planet. The PSU therefore holds the exclusive rights over very advanced Klingon first person shooters, which will blow away Quake & co in gore and impressiveness when the PSU releases it to the market. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From Tom_Good1 at excite.com Wed Jun 13 20:59:40 2001 From: Tom_Good1 at excite.com (Tom Good) Date: 13 Jun 2001 17:59:40 -0700 Subject: Working with paths with spaces in NT References: <9fol5s$9d3$3@216.39.170.247> <3b279eaf.5984935@news.laplaza.org> <9g8gkk$cir$1@216.39.170.247> Message-ID: David LeBlanc wrote in message news:<9g8gkk$cir$1 at 216.39.170.247>... [... code deleted ...] > spaces = tabs[0:(depth * 2)] # kludge - there's a better way, > # but i'm not clear on how to use it. maybe do something along the lines of: spaces = " " * (depth*2) instead? Tom From boyd at insultant.net Wed Jun 6 07:20:38 2001 From: boyd at insultant.net (Boyd Roberts) Date: Wed, 6 Jun 2001 13:20:38 +0200 Subject: integers References: <9fjd8q$qb6$1@charm.magnus.acs.ohio-state.edu> Message-ID: <9fl3og$ct0$1@neon.noos.net> "Locke" a ?crit dans le message news: 9fjd8q$qb6$1 at charm.magnus.acs.ohio-state.edu... > is there such thing as > someint++ > or > someint-- > or > someint += 2 > in python?? > > it is a pain in the butt writing > someint = someint + 1 the real reason it's in C is that the PDP-11 had autoincrement and autodecrement instructions and it stayed 'cos it's easy to type. From max at alcyone.com Fri Jun 8 11:58:54 2001 From: max at alcyone.com (Erik Max Francis) Date: Fri, 08 Jun 2001 08:58:54 -0700 Subject: Reraising exceptions "intact" References: <3B20F235.1FC3A9A@argo.es> Message-ID: <3B20F63E.54E76628@alcyone.com> Jesus Cea Avion wrote: > I'd like to know how to reraise a "catched" exception, intact: > > while 1 > try : > func() > except exceptions.KeyboardInterrupt : > raise exceptions.KeyboardInterrupt > except : > pass > > Here we keep "func" running except if the user press CONTROL+C. But in > this case I'd like to see a traceback for the original interrupt > point, > not the "artificial" "raise". In an except block, just use `raise' to reraise the caught error: while 1: try: func() except exceptions.KeyboardInterrupt: raise except: pass -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Honesty has nothing to hide \__/ Joi Esperanto reference / http://mirror/alcyone/max/lang/esperanto/ An Esperanto reference for English speakers. From akhar at videotron.ca Sun Jun 3 19:33:01 2001 From: akhar at videotron.ca (akhar) Date: Sun, 3 Jun 2001 16:33:01 -0700 Subject: matrices and graphic cards Message-ID: I was just wandering if it is possible to use the cpu power on a 3D accelerated graphic's card to boost a script performances? I have an image manipulation script that converts the image into 3 matrrices and then performs some operations on it and it takes about 20 seconds of execution per image, and knowing that 3d gaming can get a lot of frames per second well.... I was hoping it might help. If it is possible how can I achieve this? I am using PIL and Numeric. Akhar From rnd at onego.ru Sun Jun 10 09:21:18 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 10 Jun 2001 17:21:18 +0400 (MSD) Subject: Global in multiple files In-Reply-To: Message-ID: On 10 Jun 2001, Artur Skura wrote: >I'm not a fan of OO but I decided to give it a try. After all, Python >makes it elegant. > >So I wrote a program usuing classes, methods etc. All nice. Then it >grew up and I decided to split it in several files - one class into >each class as Guido asked us to do. > >And then, I came across my first problem: I had had a global variable >(just one!) and it wouldn't work anymore. At all. Any 'global' >declarations wouldn't help, and without it I'm lost. Probably, you have 3 different globals: one per module. >So, I thought I might be smarter than it. I would pass this >variable to where I need it, but... it stil obstinately refuses to >work. But then, my ex-global is a list of instances of a class, >and methods in instances of another class won't accept it as >an argument. Why do you need global variable in the OOP design anyway? Maybe, it belongs to os.environ or some container class? I blame myself each time I maintain code with global variables: the code can't be easily reconfigured, creates other problems. Globals are allright only in short scripts which has no chance to grow larger. >So, any ideas how I should cope with that and be able to use my >global variable in different clases in different files? > >Regards, >Artur Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, June 10, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Computers make very fast, very accurate mistakes." _/ From gerson.kurz at t-online.de Thu Jun 7 12:22:15 2001 From: gerson.kurz at t-online.de (Gerson Kurz) Date: Thu, 07 Jun 2001 16:22:15 GMT Subject: Just a small quine References: <3b1fa942.11180453@news.t-online.de> Message-ID: <3b1fa9ab.11285312@news.t-online.de> On Thu, 07 Jun 2001 16:19:13 GMT, gerson.kurz at t-online.de (Gerson Kurz) wrote: a quine. Sorry folks, the sh*t newsreader split the lines. the lines for c in s[:604]+'s='+3*'"'+s.replace(chr(92),chr(92)*2)+3*'"'+s[-118:]: must be on just one line (its a for loop after all). Note that there are two of those at the bottom. You can also download a working copy here: http://www.p-nand-q.com/python/quine6.py.txt From michael at stroeder.com Mon Jun 25 11:56:55 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Mon, 25 Jun 2001 17:56:55 +0200 Subject: DistUtils and optimized compile References: <3B375869.E417C833@stroeder.com> <9h7lng$cdpjl$1@ID-59885.news.dfncis.de> Message-ID: <3B375F47.64A232D2@stroeder.com> Thomas Heller wrote: > > [posted and mailed] > "Michael Str?der" wrote in message news:3B375869.E417C833 at stroeder.com... > > > > I'd like to use DistUtils for a pure Python module package. > > Everything seems to be ok so far but when doing python setup.py > > install only the .pyc byte-code is compiled and installed. I'm > > missing the .pyo files with the optimized compiled byte-code. > > Use the -O1 or -O2 command line flag: > python install -O2 ??? I already tried python -O setup.py install but that did not help. python setup.py -O install seems to be invalid. Ciao, Michael. From emile at fenx.com Tue Jun 19 11:02:42 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 19 Jun 2001 08:02:42 -0700 Subject: Simple example that won't work! References: Message-ID: <9gnpqo$a0rr0$1@ID-11957.news.dfncis.de> Your code works fine for me when I give it a valid URL I can get to and returns: -- Emile van Sebille emile at fenx.com --------- "Jay Parlar" wrote in message news:mailman.992962109.31012.python-list at python.org... > > From greg at cosc.canterbury.ac.nz Thu Jun 21 01:02:32 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 21 Jun 2001 17:02:32 +1200 Subject: PEP 255: Simple Generators References: <9gnv2o$its$1@nntp6.u.washington.edu> Message-ID: <3B317FE8.31809873@cosc.canterbury.ac.nz> David Bolen wrote: > > def f(): > return UserList.UserList([1,2,3]) But f isn't *creating* an instance here, it's just passing on the one created by calling UserList.UserList(). If you were to look at the definition of the latter, you would find that it was defined using a "class" statement, making it rather clear what sort of thing it is. Similarly, there's nothing wrong with def f(): return g() generator g(): ... Even though f happens to return a generator-iterator when you call it, that doesn't mean I think it needs a special syntax. > Eventually this could devolve into > the point elsewhere in the thread of wanting defint rather than def > for functions returning an integer. No, it couldn't -- at least, not to anyone who really understands what I'm saying. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From aleaxit at yahoo.com Thu Jun 28 11:32:27 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 28 Jun 2001 17:32:27 +0200 Subject: WIN32: How to control another windows application References: <3B3B45C3.59825716@gdp-group.com> Message-ID: <9hfimv050c@enews1.newsguy.com> "Thomas Volkmar Worm" wrote in message news:3B3B45C3.59825716 at gdp-group.com... > Hi, > > I want to control another application from a python script by sending > key events and mouseclicks to it. The script should do what I normally > do when I work with this application interactively. Is this possible and > how do I do this. Does anybody has example scripts or can give me some > hints where I can find further information? It's a very fragile approach (you're *WAY* better off using the Automation interface of the other application -- just about every application on Windows exposes some object model via Automation), but if you have some legacy app and absolutely must control it that way, see for example: http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/65107 Alex From m.bless at gmx.de Thu Jun 7 16:01:29 2001 From: m.bless at gmx.de (Martin Bless) Date: Thu, 07 Jun 2001 20:01:29 GMT Subject: Bios calls in Python? References: <3b1e6611.6945219@news.muenster.de> <72e66889.0106061446.5ffae35e@posting.google.com> Message-ID: <3b1fdb3b.472708@news.muenster.de> [mb] >> What about DOS calls? >> I know the DOS interrupt "get truename of a file" still exists, and >> that's exactly what I'm looking for. (In case of substituted drives). >> But I don't know how to call from Python. [Dr. Faustus] >>This will only work on 95/98/Me. It will not work on NT/2K/XP. Are you sure? Does that mean my oh so very important dos application (no joke) won't run with XP any more? >There is definitely a Win32 API call that will do this on all those >platforms. Ha, I'd love to see it! >Depending on exactly what you want, this is probably >GetFullPathName, which is wrapped in the win32api library. Unfortunately IT'S NOT GetFullPathName. The business is not expanding from relative to absolute, like in: win32api.GetFullPathName('m:\\') -> 'm:\\' but from substituted to unsubstituted: rem Working dos example: m:>truename m:\x.bat -> c:\somewhere\x.bat It's a pity I don't have it. The idea is to have something like os.samefile() on the windows platform. I'd like to prevent accidental overwriting of files. So the questions is still open. Martin From mlunnay at bigpond.net.au Wed Jun 6 00:12:27 2001 From: mlunnay at bigpond.net.au (Michael Lunnay) Date: Wed, 06 Jun 2001 04:12:27 GMT Subject: Interesting speed benchmark References: <3B1D6FED.4070506@nospam.yahoo.com> Message-ID: Having just finished working on 2 assignments in java, solidly for the last month, I can see a major flaw in that benchmark. That is the javac time, that seems to take a hell of a long time, and as python compiles to byte code (assuming the code was a first run) you would need to add that, and even for a 10 line file (the smallest I had to compile) javac takes an eternity... Michael "Mahesh Padmanabhan" wrote in message news:3B1D6FED.4070506 at nospam.yahoo.com... > Hello, > > To email me remove "nospam" from the email address. > > I came across this web site: > http://www.twistedmatrix.com/~glyph/rant/python-vs-java.html > > in which the author does some (by his own admission) subjective > benchmarks between java and python. While most of it is usual stuff, the > one test that stood out was the following: > > (I am using a Debian woody system with Python 2.1 and JDK 1.3 from > blackdown on an Intel system) > > Python program: > --------------- > > class ObjectTest: > pass > > for i in xrange(1000): > root=ObjectTest() > for j in xrange(10000): > root.next=ObjectTest() > root=root.next > > Time: > > real 1m23.326s > user 1m23.290s > sys 0m0.060s > > > Java program: > ------------- > > public class ObjectTest { > public ObjectTest next; > public static void main(String[] args) { > for (int i = 0; i < 1000; i++) { > ObjectTest root = new ObjectTest(); > for (int j = 0; j < 10000; j++) { > root.next=new ObjectTest(); > root=root.next; > } > } > } > } > > Time: > > real 0m2.428s > user 0m2.190s > sys 0m0.220s > > There is a huge difference in performance. In fact I tried this under > Windows NT 4 SP5 with Python 2.1 and jdk1.3 from SUN and got similar > results. > > I am very curious to know why Python takes so much time. > > Thanks > > Mahesh > From deltapigz at telocity.com Wed Jun 20 12:14:17 2001 From: deltapigz at telocity.com (Adonis) Date: Wed, 20 Jun 2001 12:14:17 -0400 Subject: Tkinter & Text object Message-ID: <3B30CBD8.B836A9CC@telocity.com> anyone know how to set color to a line after it was added to a Text object? for example; im writting a small IRC client in Python and want to be able to encode my text with color in the case an irc client sends color codes my way. i.e. hey chr(2)!chr(2) (chr(2) bold code or \x02) this is what i would receive from he server thus i display Hi; I'd like to propose (or at least enquire when/if) Unicode become the default character encoding for Python. By this, I mean that an otherwise unadorned string is implicitly Unicode, not ascii as I believe it is now. I'll omit all the usual remarks about how great that would be etc. Has anyone taken a look at using the International Components for Unicode with/as part of Python: "The International Components for Unicode(ICU) is a C and C++ library that provides robust and full-featured Unicode support on a wide variety of platforms. The library provides: Calendar support Character set conversions Collation (language-sensitive) Date & time formatting Locales (170+ supported) Message catalogs (resources) Message formatting Normalization Number & currency formatting Time zones Transliteration Word, line & sentence breaks" http://oss.software.ibm.com/developerworks/opensource/icu/project/ It uses the X-Consortium license which I think is 100% compatible with the Python License. Seems to add a lot of yummie stuff pretty instantly (of course I haven't looked at python's code to say this with even the slightest confidence). Dave LeBlanc From gmcm at hypernet.com Wed Jun 20 16:31:31 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 20 Jun 2001 20:31:31 GMT Subject: Sufficient conditions for COM local server to be singleton References: Message-ID: <90C6A2F3Egmcmhypernetcom@199.171.54.154> Bill Bell wrote: >My essential question is: I had understood from reading previous >discussions on this list that, by default, to make a COM local >server fire up in only a single copy it is only necessary to declare >"_reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER". However, >this doesn't seem to do the trick. No, not quite. Using CLSCTX_LOCAL_SERVER is enough to ensure that there's only a single copy of your module loaded. If you want only one copy of your instance, you'll have to use a singleton pattern. Try registering a ParentFactory class that does nothing but return the one and only instance of Parent (wrapped, of course). class ParentFactory: _public_methods_ = ["GetTheParent"] _reg_clsid_ = .... - Gordon From sholden at holdenweb.com Fri Jun 8 21:16:43 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 8 Jun 2001 21:16:43 -0400 Subject: return from finally clause References: <9fr8u3$gj9$01$1@news.t-online.com> <9frdgk$pnd$1@news.mathworks.com> Message-ID: "Joshua Marshall" wrote in message news:9frdgk$pnd$1 at news.mathworks.com... > "J?rgen Hermann" wrote: > > > That means that if you (accidently?) return within a finally clause, you > > effectively eat the exception. This should be documented, or fixed. > > That's unpleasant. I hope it's a bug. > Well, I think we can agree that there's a certain inconsistency in returning from a function with an exception active like that. So most of all it's a programming error. What action would be best? Raise another exception when the "return" is executed? regards Steve From andmalc-ns1 at NoSPaMmalcolmson.ca Tue Jun 26 15:13:38 2001 From: andmalc-ns1 at NoSPaMmalcolmson.ca (Andrew Malcolmson) Date: Tue, 26 Jun 2001 15:13:38 -0400 Subject: VI References: <9g9f1v$7oqr5$1@ID-11957.news.dfncis.de> <9gaul7$mth$2@brokaw.wa.com> <52e5ab5f.0106182325.4d1fe0d0@posting.google.com> <9h0kjj$h7f$1@brokaw.wa.com> Message-ID: <4b5_6.880$QB2.277593@news.total.net> > "And this is good for indenting. Don't need no advanced features. > set ai > If I could only figure out how to get it to indent the next line when I end > a line with ":"... Smartindent + cinwords effectively does this: set smartindent cinwords=def,class,if,elif,for,while,else You would make these settings effective only when starting to edit a Python script with autocmd BufRead,BufNewFile *.py set ... > :he folding > > I like to do this for python: > :set foldmethod=indent > :set minfoldlines=4 I think this last directive should be "foldminlines" > > zc to close a fold > zC to close it all the way > zo to open it > zO to open it all the way > zR to open every fold > zM to close all the folds. > > Pretty easy to pick it all up. > -- > Jonathan Gardner Thanks for your ideas, Andrew From aleaxit at yahoo.com Thu Jun 7 16:04:39 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 7 Jun 2001 22:04:39 +0200 Subject: WHY is python slow? References: Message-ID: <9foms911hod@enews1.newsguy.com> "D-Man" wrote in message news:mailman.991931952.3023.python-list at python.org... > On Thu, Jun 07, 2001 at 12:34:09PM +0000, Mitchell Morris wrote: > | As a single point of data, may I present the language-specific pages from > ... > | if-you'd-only-claimed-Jython-was-slow-ly y'rs, > > Check the list archives from the jython-users list. Not too long ago > Finn Bock posted a message that someone sent him. The other person > had a beta release of jdk1.4 and using pystong Jython came out well > ahead of CPython. A hypothesis thinks that the hotspot JIT is getting > better. I wonder how the IBM JVM does with Jython -- anybody tried it? I've only used the Javasoft one, as recommended on the Jython site, but I hear the IBM one is very speedy... Alex From thomas.heller at ion-tof.com Mon Jun 25 12:10:03 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Mon, 25 Jun 2001 18:10:03 +0200 Subject: DistUtils and optimized compile References: <3B375869.E417C833@stroeder.com> <9h7lng$cdpjl$1@ID-59885.news.dfncis.de> <3B375F47.64A232D2@stroeder.com> Message-ID: <9h7nlg$cbtbq$1@ID-59885.news.dfncis.de> > I already tried > python -O setup.py install > but that did not help. > > python setup.py -O install > seems to be invalid. > > Ciao, Michael. I made a typo, correct would be: python setup.py install -O1 See also the online-help for the distutils commands: python setup.py --help python setup.py install --help Thomas From mats at laplaza.org Fri Jun 8 19:29:38 2001 From: mats at laplaza.org (Mats Wichmann) Date: Fri, 08 Jun 2001 23:29:38 GMT Subject: Commercial: Python training in Chicago 6/26 Message-ID: <3b215f03.28972550@news.laplaza.org> Don't intend to make a habit of these postings, but just this once: I'm doing a Python Programming class for Learning Tree in NW Chicago (Schaumberg to be precise) June 26-29. Class is running for sure, and there are seats available. So if you know anyone out there who's interested in Python ....drop 'em a line. For more details, http://www.learningtree.com/us/ilt/courses/430.htm -ly-yours Mats Wichmann From GeorgLohrer at gmx.de Mon Jun 18 09:51:04 2001 From: GeorgLohrer at gmx.de (Georg Lohrer) Date: Mon, 18 Jun 2001 15:51:04 +0200 Subject: Aargh! Function takes exactly x arguments, y given.. References: <9gkrud$pru$1@news.inet.tele.dk> Message-ID: <8i1sit891nf3gtlqdh91dvve63nfkb2gi7@4ax.com> On Mon, 18 Jun 2001 14:26:13 +0200, "Anders And" wrote: >Hi! > >I am a happy pythoneer using a combination of C++ and Python for my everyday >work. >Usually, debugging is easy but every now and then, I get the "function takes >exactly x arguments, y given" error message, clearly due to some other >problem than what Python thinks. Does anybody have any experience with this >particular error message? Of course everybody who write Python code will come into contact with these messages. But what's up? The messages stands for itself. You have not passed the correct amount of arguments to a function/method-call, don't you. So, fix your amount of arguments and you'll get into the right way. But pay attention. It's somewhat confusing that calling classes-methods, always the passed 'self'-parameter counts as well. Look at this: class foo: def foo_method1(self, p1, p2): pass f = foo() f.foo_method(1) will yield: "function takes exactly 3 parameters, 2 given". If writing code like: def foo_function(p1, p2): pass foo_function(1) will yield: "function takes exactly 2 parameters, 1 given". Ciao, Georg From salvatore.didio at wanadoo.fr Wed Jun 6 16:01:23 2001 From: salvatore.didio at wanadoo.fr (Salvatore DI DIO) Date: Wed, 6 Jun 2001 22:01:23 +0200 Subject: Grail Python2.1 References: <9flevu$495$1@wanadoo.fr> Message-ID: <9fm1no$gtc$1@wanadoo.fr> Thanks for your response, I will check tomorrow Salvatore > Wasn't the socket library one of the places where the type of the > argument list was fixed to match the documents in verison 2.0? > Something like func( 1 , 2 ) used to be accepted due to an > implementation accident, but now it is required to be func( (1 , 2) ) > -- a single 2-tuple argument? > > Grail is, unfortunately, unmaintained anyways. > > -D > > From barry at digicool.com Mon Jun 25 16:53:32 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Mon, 25 Jun 2001 16:53:32 -0400 Subject: Is this a mimetools/rfc822 bug? References: <15159.41247.812177.613322@anthem.wooz.org> <673D8B1EC8@kserver.org> Message-ID: <15159.42188.101154.983856@anthem.wooz.org> >>>>> "SK" == Sheila King writes: SK> But, according to the RFC's a header is required. A message SK> body is not required. SK> According to RFCs I recall: Your message header must have at SK> least one of the following headers: To, Bcc, or CC. I believe SK> that is the minimal header: any one of the To-type fields. No SK> other headers are required, and no message body is required. True, but the rfc822 module doesn't enforce any of these requirements, AFAIK. So it's really much more of an issue of the rfc822.py module's API than it is of the actual RFC. Cheers, -Barry From m.faassen at vet.uu.nl Fri Jun 15 15:20:53 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 15 Jun 2001 19:20:53 GMT Subject: call-by-reference (was Re: Any other Python flaws?) References: <9gcu9g$gm4$1@newshost.accu.uu.nl> <9gd4tq$odb$1@news.mathworks.com> <3b2a1aea.6118580@nntp.sprynet.com> Message-ID: <9gdn6l$61k$4@newshost.accu.uu.nl> David C. Ullrich wrote: > On 15 Jun 2001 14:08:58 GMT, jcm wrote: >>Martijn Faassen wrote: >> >>> I agree that nobody agrees on whatever 'call-by-reference' means, or what >>> 'call-by-value' means. I mean, I'm here confused why you'd say C++ doesn't >>> support call-by-value while Python apparently does. :) >> >>In my experience, there's good agreement about what call-by-reference >>means just about everywhere but in newsgroups. Python supports only >>call-by-value -- you can't change the value of a variable in your >>caller's scope (globals aside). > It's call-by-value all right. The confusion is caused > by the fact that the values are references. But passing > a reference "by value" is not a call by reference. I think the confusion makes it not worth saying things like "It's simple! Python does call-by-value only!". :) Better be more specific about the behavior. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From skip at pobox.com Sat Jun 23 10:16:43 2001 From: skip at pobox.com (Skip Montanaro) Date: Sat, 23 Jun 2001 09:16:43 -0500 Subject: adding instance methods after instantiation In-Reply-To: <9h1vg2$14cc$1@node21.cwnet.roc.gblx.net> References: <9h1vg2$14cc$1@node21.cwnet.roc.gblx.net> Message-ID: <15156.42187.785702.181258@beluga.mojam.com> Lee> Is there some way to make m2 an instance method so that it will Lee> automatically get passed c1 as its first argument? Check out the instancemethod function of the new module. Lee> Is this a reasonable thing to want to do? Yup, people ask about it from time-to-time. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From grante at visi.com Tue Jun 26 15:23:47 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 26 Jun 2001 19:23:47 GMT Subject: 'with' statement in python ? References: <3b3875f1.110436929@news.tpi.pl> <5.0.2.1.0.20010626103003.02841da0@mail.inet.com.br> Message-ID: <7j5_6.3581$B7.544005@ruti.visi.com> In article , D-Man wrote: >After stating that it _could_ be implemented, I think it is a >BAD idea because it is just some more magic and can make it >really hard to trace through how the code will act. It's just like the implicit "with self" at the beginning of a C++ method. It makes it hard to tell by inspection what a piece of code does. Making code easy to read/inspect is (or should be) of upmost importance. -- Grant Edwards grante Yow! Hello. Just walk at along and try NOT to think visi.com about your INTESTINES being almost FORTY YARDS LONG!! From paulp at ActiveState.com Fri Jun 22 14:51:47 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 22 Jun 2001 11:51:47 -0700 Subject: Python equivalent of CPAN Library modules References: <718A0962DFC2D4119FF80008C7289E4701A01FC1@ICICIBACK3> Message-ID: <3B3393C3.EC0B3B24@ActiveState.com> > GADGIL PRASAD /INFRA/INFOTECH wrote: > > hello, > > I kinda find larry wall's thaught very interesting. And his complete > openness of ppl choosing lang other than perl. > > So, what I wanna ask is, > is it technically possible to use perl modules from python programs.. > ? You want pyperl! http://www.cpan.org/modules/by-module/LWP/GAAS/pyperl-1.0.readme -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From Gareth.McCaughan at pobox.com Sun Jun 17 19:18:07 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Mon, 18 Jun 2001 00:18:07 +0100 Subject: Two minor syntactic proposals References: Message-ID: phil hunt wrote: [I expressed distaste for the following and proposed another syntax:] > > def new_method(self, x): > > something_else() > > return x+1 > > Thing.new_method = new_method > > It doesn't look too bad to me. It's not as if you'd be doing it > every day, I expect. And i don't think special syntax for > operations your rarely use is a good idea -- because people > will use them too infrequently to remember the syntax. I think it would be used more if it didn't feel like grovelling around in the insides of things you're not supposed to touch. Of course, maybe that's an argument for leaving things as they are. :-) > >Every now and then we get people complaining because it's > >too easy for them to forget to include a "self" argument > >in a method definition. Every now and then, I suspect that > >most Pythonistas forget. (I certainly do.) Suppose there > >were an alternative syntax, thus: > > > > class Thing: > > def self.boring_method(): > > return 0 > > I propose a different way of doing this: make 'self' implied in all > references to instance variables. This involves definiing 2 new keywords, > qclass and insvars. So: > > qclass Thing: > insvar v, w > def myMethod(p): > print p, v, x > def otherMethod(): > myMethod(1) > someFunction() > > would be equivalent to: > > class Thing: > def myMethod(self, p): > print p, self.v, x > def otherMethod(self): > self.myMethod(1) > someFunction() I confess that my initial reaction is "eeurgh", which may well be how others react to my proposals. I think your qclass/insvar proposal breaks the following principles of Pythonic style: - "Explicit is better than implicit" (one of the timbots rules from way back). "self" really *is* a function argument, and eliminating all mention of it feels uncomfortable. Not to mention that "qclass" binds "self" without saying so. Is there anything else in Python that binds things that it doesn't mention? I can't think of any right now. - "No cryptic identifier names". Why "qclass"? Why not "xclass" or "zclass"? (Does the "q" actually stand for something?) How easy will it be to remember that it's "insvar", not "instvar" or "insvars"? > Note that a qclass definition would have to know what its methods and instance > variables were, including those inherited from superclasses, for this to work. > Is this feasible? I don't understand what you mean by "know what its instance variables are"; new instance variables can materialize on the fly on a per-class or per-instance basis. Anyway, why would it need to know that? -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From mwh at python.net Wed Jun 27 09:14:15 2001 From: mwh at python.net (Michael Hudson) Date: 27 Jun 2001 14:14:15 +0100 Subject: regex scanner question References: Message-ID: Roman Suzi writes: > hi! > > (After the PEP 260 I am not sure I can use anything less common > than things with established use practice... So I better ask.) Well, PEP 260 isn't accepted yet, but it's probably sensible in general to avoid using undocumented functions... > I've found SRE_Scanner object which gets birth from scanner() > method of SRE_Pattern object. ... as here. It's my understanding that these features are experimental, possibly buggy and certainly not documented. OTOH, if you (or anyone else) think they're useful, can get them to work and (especially) write some docs, there's every chance thay will become a standard feature. [...] > Is it standard Python feature I could safely use or will it be dropped > soon as it happened to xrange as a sequence type? It might get binned if noone makes use of it. But if there's a move to get rid of it, I'm sure it would be preceded by a "is anyone using sre.scanner?" query. > Could use of .scanner be recommended or not recommended? If it solves your problem, I'd recommend it. They're not going to go away before 2.2, you can be sure . > BTW, generators could be very useful if applied inside regex routines. > They will make it easy to hop from ane finding to another without taking > too much memory. Example? Cheers, M. -- Well, yes. I don't think I'd put something like "penchant for anal play" and "able to wield a buttplug" in a CV unless it was relevant to the gig being applied for... -- Matt McLeod, alt.sysadmin.recovery From brian at rk-speed-rugby.dk Thu Jun 14 07:18:38 2001 From: brian at rk-speed-rugby.dk (Brian Elmegaard) Date: Thu, 14 Jun 2001 13:18:38 +0200 Subject: Telling python where to look for a script References: <3B285BFD.D2AC7E26@rk-speed-rugby.dk> <9ga20f02hsk@enews1.newsguy.com> Message-ID: <3B289D8E.96908690@rk-speed-rugby.dk> Alex Martelli wrote: > > the backslashes:-). A module is meant to be imported. > A foo.py file can be both, but adapting the path is > relevant to module-use only, NOT to script-use. All > clear so far...? > No, I'm sorry. Being in c:\foo I would like to be able to execute bar.py on baz.dat being in . just by typing: c:\foo>python bar.py baz.dat Then I need something path-related with scripts, don't I? -- Brian (remove the sport for mail) http://www.et.dtu.dk http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug \TeX, tak From davygrvy at pobox.com Tue Jun 12 13:16:04 2001 From: davygrvy at pobox.com (David Gravereaux) Date: Tue, 12 Jun 2001 10:16:04 -0700 Subject: ANNOUNCE: Itclpython 0.2 Message-ID: Host a Python interpreter from Tcl: http://sourceforge.net/project/showfiles.php?group_id=13244&release_id=39101 This is new and experimental, but appears to be working OK. The standard channels haven't been linked together, yet. Unicode transfer from Python to Tcl appears to be working... This is actually an [Incr Tcl] extension using its OO services. Here's a screen shot of it in action: D:\>tclsh84 % package require itclpython 0.2 % set i [python::interp #auto] interp0 % $i exec {import sys} % $i eval {sys.executable} C:\PROGRA~1\Tcl\bin\tclsh84.exe % catch {$i eval {eval("import random")}} err 1 % set err File "", line 0, in ? File "", line 1 import random ^ SyntaxError: invalid syntax (line 1) % itcl::delete object $i % exit I don't know much Python, as I'm a newbie, and would appreciate people trying this. -- David Gravereaux >>> The Original Famous Beyond Compare and Absolutely the First Ray's Pizza, NYC <<< From tim.one at home.com Sun Jun 24 22:29:01 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 24 Jun 2001 22:29:01 -0400 Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: [Roman Suzi] > ... > Probably, [g]comb could be added to regression tests of generators. Thanks to the magic of doctest , gcomb was added to the std test_generators.py test (in the CVS tree, under Lib/test/) a few minutes after it was posted here. BTW, there are several other nifty examples of generators in the test. From jmurray at agyinc.com Wed Jun 6 17:06:49 2001 From: jmurray at agyinc.com (Joe Murray) Date: Wed, 06 Jun 2001 14:06:49 -0700 Subject: Generating Multiple Class Instances References: <3B1E9271.B05CC4E3@fnal.gov> Message-ID: <3B1E9B69.6D1D6F7E@agyinc.com> Julie Torborg wrote: > > I'm no wiz at OOP, but I have the following problem: > > I have a list of some hundreds of items, each of which has several > attributes,What I want to do is peg each of the values to the list item > and move it around my program. This seems like the perfect opportunity > to take advantage of the OOP aspect of Python by setting up a class, but > I can't create or use instances without hard-wiring it for every list > item. What I want to do is: > > class Quark: > def __init__(self): > self.color=getcolor() > self.mass=getmass() > > flavor=['up', 'down', 'strange', 'charm', 'top', 'bottom'] > for each in flavor: > each=Quark() This loop does not really do what you want it to do! > ###Then later: > for each in flavor: > print each.color > > ###What I'm relegated to doing is: > > up=Quark() > down=Quark() > strange=Quark()... > > print up.color > print down.color > print strange.color... > > Which works, but with hundreds of list items, gets messy in a hurry. > I've also tried messing around with using something that looks more like > quark=Quark() several times, but then all the info stored in the > previous instance gets obliterated. I've also tried using lists and > dictionaries, but they're bulky and what's the point of using an OOP > language if there's no additional functionality or elegance? > > -- > http://mail.python.org/mailman/listinfo/python-list I think you were on the right track, but you relegated yourself to doing something you need not do! :) This should work: -----CODE----- def getColor(): return raw_input('Enter a color: ') def getMass(): return raw_input('Enter a mass: ') class Quark: def __init__(self, color, mass): self.color = color self.mass = mass flavor = ['up', 'down', 'strange', 'charm', 'top', 'bottom'] # create a list of quarks, based on the elements of flavor, I suppose quarks = [] for each in flavor: quarks.append(Quark(getColor(), getMass())) # print the colors of all the quarks for quark in quarks: print quark.color -----END OF CODE----- Note, this simply creates an instance of the Quark class for every element in flavor. I don't know if this is what you want to do, but I hope this helps. Note that Quark instantiations are stored in their own list. Note that the placeholder 'each' can NOT be used to do an inplace replacement of the elements of flavor. Lists are generally not bulky; dictionaries can get bulky. They are standard python datatypes which are generally very helpful. Lists and dictionary objects provide functionality and elegance in many situations. Note that 'flavor' is a list and so is 'quarks'. quarks.append(...) is a method of the python list object. That's pretty functional and elegant, right ;) ? Good luck, feel free to ask more questions, the python-list is a helpful bunch... joe -- Joseph Murray Bioinformatics Specialist, AGY Therapeutics 290 Utah Avenue, South San Francisco, CA 94080 (650) 228-1146 From gmcm at hypernet.com Wed Jun 20 22:48:42 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 21 Jun 2001 02:48:42 GMT Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) References: Message-ID: <90C6E61F5gmcmhypernetcom@199.171.54.154> [posted and mailed] James Althoff wrote: >.... Meanwhile, does anyone know where to find python-iterators and >how to read or subscribe? Is there an archive? Yes, yes and yes. - Gordon Oh, OK. http://sourceforge.net/mail/?group_id=5470 If you poke around, you can find a link on python.org. From sabren at manifestation.com Wed Jun 20 00:14:14 2001 From: sabren at manifestation.com (Michal Wallace) Date: Tue, 19 Jun 2001 23:14:14 -0500 (CDT) Subject: Properties in Python In-Reply-To: Message-ID: On Wed, 20 Jun 2001, Peter Caven wrote: > So, instead of allowing direct access to the instance attributes, C# > actually executes 'get' and 'set' methods (if defined) for the attributes. > This lets a programmer change the behavior of the attributes defined in the > class (to have side-effects for example) without changing any code written > by users of the class. > > Does anyone have any ideas on how to do this (elegantly) in Python? > __getattr__ and __setattr__ don't seem to quite do it (ie. inheritance). > > Or, do the Python experts here think that this is not really such a good > idea? I use a class that overrides __getattr__ and __setattr__ .. It looks first for a get_XXX or set_XXX method... The only trick is that you can't store the actual data in __dict__ this way, because __dict__ gets accessed before __getattr__ (at least it did back in 1.52).. You have to maintain your own dictionary instead. The code below is the base class I use. Probably could use a cleanup, but there you go.. Cheers, - Michal ------------------------------------------------------------------------ www.manifestation.com www.sabren.net www.linkwatcher.com www.zike.net ------------------------------------------------------------------------ """ zdc.Object - a base class for building database objects """ __ver__ = "$Id: Object.py,v 1.15 2001/02/11 06:20:51 sabren Exp $" import Record class Object: """ A base class for building business objects. zdc.Object is a generic base class for business objects. It has the ability to reject adding attributes that don't apply to it. see RecordObject and ModelObject (?) for examples.. """ __key__="ID" # field that uniquely identifies this object _links = {} _locks = [] def __init__(self, key=None, **where): """ Don't override this! override _init(), _new() or _fetch() instead. """ self.__dict__['_data']={} self._link() self._init() if key is None: if where: apply(self._fetch, (), where) else: self._new() else: self._fetch(key) self._lock() ### Abstract Protected Methods ########################## def _link(self): """ Set up the links (relationships) between the objects. This is pretty generic, so you probably don't need to override it. Just populate class._links. Structure is: _links = { collectionName : (linkClass, params, to, linkClass's, constructor) } linkclasses (eg, zdc.LinkSet) Should take the left-hand object (self, from our perspective) as the first parameter. You don't have to include self in the param list. eg: _links = { 'details': (zdc.LinkSet, SomeDetailClass, 'ID', 'summaryID') } """ for item in self._links.keys(): setattr(self, item, apply(self._links[item][0], (self,) + tuple(self._links[item][1:]))) def _init(self): """ Override this to initialize an Object before the data is filled in by _new or _fetch. """ pass def _new(self): """ Override this to initialize a new instance of an object.. This is NOT called for objects that already exist in storage. """ pass def _fetch(self, key=None, **kw): """ Override this to initialize fetched instances of an object. This is ONLY called for objects that already exist in storage. """ pass def _lock(self): """ This just locks the object. You probably don't want to override it. """ self.__dict__["_isLocked"] = 1 ### Abstract Public Methods ############################ def save(self): raise NotImplementedError, "Object.save()" def delete(self): raise NotImplementedError, "Object.delete()" def getEditableAttrs(self): raise NotImplementedError, "Object.getEditableAttrs()" def getEditableTuples(self): raise NotImplementedError, "Object.getEditableTuples()" ### private Methods #################################### def get__isLocked(self): """ Makes sure we're unlocked by default. we can't put this in __init__ because child classes might want to do stuff before calling _new() or _save() and therefore, before __init__.. """ if not self.__dict__.has_key("_isLocked"): self.__dict__["_isLocked"] = 0 return self.__dict__["_isLocked"] def _findmember(self, member): """ self._findmember(member) : does self define or inherit member? with subclasses, It's hard to tell if we have get_XXX, because we have to iterate through all the base classes. This ought to be built in to python, but it isn't.. :/ """ # __bases__ is only the IMMEDIATE parent, so we have # to climb the tree... #@TODO: handle multiple inheritence ancestors = [self.__class__] while ancestors[-1].__bases__ != (): ancestors.append(ancestors[-1].__bases__[0]) for ancestor in ancestors: if member in dir(ancestor): # grab the first one we find: return ancestor.__dict__[member] return None def __setattr__(self, name, value): ## case A: there's a set_XXX method. meth = self._findmember('set_' + name) if meth is not None: meth(self, value) ## case B: object is locked, so be careful elif self._isLocked: ## B1: locked (read only) attribute if name in self._locks: raise AttributeError, name + " is read-only." ## B2: editable object attribute elif self._data.has_key(name): self._data[name] = value ## B3: normal python attribute: elif self.__dict__.has_key(name): self.__dict__[name] = value ## B4: Attribute isn't part of the object else: raise AttributeError, \ "can't add new attribute '%s' to locked object." \ % name ## case C: unlocked, so do whatever you want else: self.__dict__['_data'][name] = value def __getattr__(self, name): ## case A: the name is already in __dict__ ## python (1.52 anyway) won't call __getattr__, ## and there's not a damn thing we can do about it. ## case B: there's a get_XXX method: meth = self._findmember('get_' + name) if meth is not None: return meth(self) ## case C: the attribute is in _data elif self._data.has_key(name): return self._data[name] ## case D: it does not have the attribute else: raise AttributeError, "no such attribute [" + name + "]" From whisper at oz.nospamnet Fri Jun 8 15:13:24 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 8 Jun 2001 19:13:24 GMT Subject: Apology to Tim Message-ID: <9fr84k$9d3$4@216.39.170.247> Tim; When I read your response to my post about what I thought was a problem with accessing paths with spaces in them, I replied inferring that you where really condescending. I re-read it today, and I can't for the life of me figure out why I would have thought that. It must have been a worse day then I thought. I hope you will accept my sincere apology. Regards, Dave LeBlanc From scarblac at pino.selwerd.nl Sun Jun 17 06:21:15 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 17 Jun 2001 10:21:15 GMT Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> <9geiir$324$1@216.39.170.247> Message-ID: David LeBlanc wrote in comp.lang.python: > In article , > philh at comuno.freeserve.co.uk says... > > I have no problem having cxonstants like this, e.g. > > > > programVersion = "0.2.7" > > > > it seems to me that: > > > > alias programVersion: "0.2.7" > > > > is no clearer, and is an extra something for a learner to have to learn. > > Entities should not be multiplied unnecessarily! > > I absolutely agree that entities shouldn't be multiplied unnecessisarily! > However your suggestion in fact does just that: there is nothing that > prevents one from reassigning to programVersion in some module you > import. Oops... The important difference is that you can't change the > replacement text of an alias once set: it's immutable. But does that belong in *Python*? Where you can delete builtin functions, add and remove methods to classes on the fly, change any imported module's functions from the outside, change a class' parent classes, change an instance's class... *Nothing* is restricted in Python. That's what the language is about. It comes from the view point that programmers are mature individuals who can be held responsible for their own actions. As for newbies, it teaches them that they have to think for themselves, and that coding style guides (like ALL_CAPS for things you shouldn't change, or starting a method name with _ if it shouldn't be called from the outside) are Good Things. It's explicit, not only at the place where the thing is defined, but also where it is used! Readable. Adding a way to block rebinding of a name would be a horribly inconsistent wart on the language. > > When I hear that phrase, I reach for my gun. Go and use Pascal or > > Eiffel if you're into bondage-and-discipline. > > Oh god am I tempted... but i'll refrain. Why? I really don't see how you could find Python usable. Please, if a language has a philosophy almost totally opposite from yours, go find a language that better suits your needs instead of starting a flamewar in comp.lang.python trying to fundamentally change the language... -- Remco Gerlich From ullrich at math.okstate.edu Sun Jun 24 09:31:12 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 24 Jun 2001 13:31:12 GMT Subject: Is this a true statement? References: Message-ID: <3b35e9b7.501104@nntp.sprynet.com> On Sat, 23 Jun 2001 14:38:24 -0400 (EDT), "Steven D. Majewski" wrote: > > >On 23 Jun 2001, Carl Fink wrote: > >> In article , Chris >> Gonnerman wrote: >> >> > Writing TO a device driver is easy enough... the previous poster >> > was talking about writing the DRIVER in Python. No OS I'm aware >> > of takes device drivers in any languages other than assembler, C, >> > and/or C++. >> >> He's making a very finicky, nitpicking, and frankly silly point [...] > >I don't think the point was entirely silly! It wasn't supposed to be a "point" at all. Various explanations have been given for why you can't write a device driver in Python. I see why a device driver has to do various things that Python cannot do, but I don't see why a program that _writes_ a device driver has to do these things. Hence the _question_. The point to the question being to try to learn whether there's an aspect of this that I'm missing. (Yes, of course it's clear that it's not _practical_ to write device drivers in Python, like something you could do in an afternoon in C would take years in Python because the "compilers" support different things. But I didn't think the question was about what was easy or a good idea, I thought the question was about what's possible.) >It was a valid and interesting point (despite being finicky and >nitpicking!) It's not at all clear to me whether the original question was about what's literally "possible" or what's possible in practical terms. If the first then it's an inherently nitpicky question. I'm still not at all clear on what I meant to be asking about. When we say "write a device driver" here _are_ we talking about something other than creating a file containing a certain sequence of bytes or not? >> Essentially he's deliberately misunderstanding what "write" means, >> using the "write to a file" meaning instead of "create a new program" >> meaning. > >I just don't think that point had much to do with what the original >poster wanted to know. I wouldn't know. Possibly not. > ( I'ld like to think he just left off the >smirking smiley at the end for better effect -- it's much funnier >delivered deadpan! ) I'm not sure whether you're wondering whether I or the original poster omitted a smiley. >-- Steve Majewski > > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From bernhard at intevation.de Mon Jun 18 05:47:48 2001 From: bernhard at intevation.de (Bernhard Reiter) Date: 18 Jun 2001 09:47:48 GMT Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? References: <3B2B60AD.942719AE@earthlink.net> Message-ID: <9gkio3$9jcft$5@ID-89274.news.dfncis.de> In article <3B2B60AD.942719AE at earthlink.net>, Ron Stephens writes: > I have not been successful heretonow in gui or event driven programming Event driven GUI programming is not really easy and the tools available are complicated. > 1. Tkinter and wxPython. I have not been too successful with Tkinter, > but I do not rule it out. I have just begun to look at wxPython. Does > anyone think wxPython is easier to learn and use than Tkinter, or about > the same? WxPython is IMO harder to learn, but offers more. GUI kits which are conceptually easy to understand and therefore easy to learn are not suitable for real-life GUIs as a rule of thumb. WxPython also is more difficult to learn, because it is based on a C++ class library (wxWindows). Having said this, I still thinkg wxPython is your best choice given the circumstances I know. > 2. Boa Constructor and wxPython. I have downloaded Boa and it looks > complicated, but I like the idea of a VisualBasic like gui designer. Is > Boa far enough along to be used? Any comments on Boa? Boa is a nice piece of software but it is overly complicated. You can use it when you know what you are doing. So I do not recomment it for you as you are in the leaning stage. > 3. PythonWorks. I just downloaded the evaluation copy. OK, it costs $395, I stick to Free Software exclusively. Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) FSF Europe (fsfeurope.org) From samschul at pacbell.net Sun Jun 3 04:11:03 2001 From: samschul at pacbell.net (Samuel Schulenburg) Date: 3 Jun 2001 01:11:03 -0700 Subject: Embedded 'C' problem? References: <3b195197.147691268@wa.news.verio.net> Message-ID: bokr at accessone.com (Bengt Richter) wrote in message news:<3b195197.147691268 at wa.news.verio.net>... > On 2 Jun 2001 00:09:22 -0700, samschul at pacbell.net (Samuel > Schulenburg) wrote: > > >Given the following string: > >EB70:|30 E8 8A 17 00 00 66 89 04 9F 83 C4 08 43 3B 5C > >0.....f......C;\ > > > >and using the following 'C' wsprintf() function to build ucPyString > >causes a print format error. > > > >wsprintf(ucPyString,"print \"\"\"%s\"\"\"",ucMsgStr); > >PyRun_SimpleString(ucPyString); > > > >ERROR: > > > > File "", line 1 > >print """EB70:|30 E8 8A 17 00 00 66 89 04 9F 83 C4 08 43 3B 5C > >0.....f......C;\""" > > > > ^ > >SyntaxError: invalid token > > > >The problem is final "\" in the origional string is interfering with > >the final tripple quote forming a \""" which is interprited as an > >escape sequence. > > > Looks to me like you'd have a problem with """ embedded in ucMsgStr > too. Apparently what you want is a python statement which when > executed will put exactly the original characters of ucMsgStr to > stdout. So the question is how to represent the string when you don't > know what it contains. Any escape or quotes characters could > potentially interfere. Also if you have special characters > OTTOMH, [no warranty, not checked!] I'd try > something like the following to escape double quotes and backslashes: > > #include > ... > #define UCPYSTRINGMAX -- whatever your buffer size, min 40 for err msg > unsigned int i = wsprintf( ucPyString,"print \"\"\"" ); > > for(const char *p= ucMsgStr; *p; ++p ){ > if( i >= UCPYSTRINGMAX-4-3-1 ){ //4hex+3"'s+term > i = wsprintf( ucPyString,"print \"\"\"Insufficient Buffer\"" > ); > break; > } > if( !isprint(*p) ){ > i += wsprintf( ucPyString+i,"\\x%02x",*p ); // hex if weird > } else { > if( *p == '\\' || *p == '"' ){ // escape dquote and backslash > i += wsprintf( ucPyString+i,"\\%c",*p ); // escaped > } else { > i += wsprintf( ucPyString+i,"%c",*p ); // plain > } > } > } > i += wsprintf( ucPyString+i, "\"\"\"" ); // indent and \n up to you > ... > > wsprintf is kind of overkill, but if you need to change to wide chars > maybe it's easier than leaner string routines. > > Alternatively you could brute force escape every character in hex. > Either way MAKE SURE YOU HAVE THE SPACE for worst case expansion if > you don't know what's coming. > > The raw string format would still leave you with an escaping problem > somewhere, UIAM. > >My question is. How can I generate a format specifier so I can have a > >ucMsgStr that contains any printable characters, and does not interfer > >with the Python print function? > > > It's not the print function per se, it's the interpreter > reading the print statement source that you've generated, and > interpreting the string literal in it to make the string constant > that becomes the argument for print when it executes. It doesn't > like the generated string syntax. If you put "s=" in place of "print" > I would expect the same problem. I would like to give a big thanks to your post. You hit the solution right on the head. I ennded up escaping \" \' \\ and that fixed the problem. Samuel Schulenburg From wart at softhome.net Mon Jun 18 20:53:23 2001 From: wart at softhome.net (Wartan Hachaturow) Date: 18 Jun 2001 17:53:23 -0700 Subject: Python equivalent of CPAN Library modules References: Message-ID: <5f61bb6c.0106181653.273c7085@posting.google.com> davehurt at flash.net (David Hurt) wrote in message news:... > One such source may be the perl CPAN repository. The CPAN has a collection of > very high quality libraries for a variety of applications. If these libraries > could be converted to equivalent python, then the libraries could be used for > python programs :) I do think that there is no need to translate module names, but there is a certain need for such an archive at all, i.e. with the same access methods, search & testing abilities, quick access to the documentation etc. That would also be a good demonstration of Python as a Web scripting language ;) -- Regards, Wartan. From grakker at softhome.net Sun Jun 24 16:23:42 2001 From: grakker at softhome.net (grakker) Date: 24 Jun 2001 13:23:42 -0700 Subject: gadfly cgi update Message-ID: <56817b75.0106241223.4cdf544a@posting.google.com> I'm trying out my first python program this weekend. I have a calendar, which when you click on the day, it opens a window which lets you edit information about that day. The submit calls a script which should update the database. But it doesn't. It just stops at the line. Here is the code in question (place here the customary appologies for ugly code): print form_custody_value, print form_month_value, print form_day_value, print form_year_value print "'%s'" % form_custody_value print "'%s'" % form_notes_value db_update = "\"update custody set cstdy='%s', notes='%s' where \ mnthdt=%d and dydt=%d and yrdt=%d\"" % (form_custody_value, \ form_notes_value, form_month_value, form_day_value, \ form_year_value) print db_update db.execute(db_update) print "updated" I have all the print statements in there so that I could see what was going on. Here is the output: custody=Lang Lang 7 8 2001 'Lang' 'Birthday' "update custody set cstdy='Lang', notes='Birthday' where mnthdt=7 and dydt=8 and yrdt=2001" This works from the python command line, and very similiar select statements work on my other pages. Any help would be appreciated. -Lang BTW Python is pretty sweet if I'm able to get as close as I have in one weekend of coding... From grante at visi.com Sun Jun 24 20:38:46 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 25 Jun 2001 00:38:46 GMT Subject: Is this a true statement? References: <3b34939b.410758@nntp.sprynet.com> <9h2nuc$g6g$0@216.39.170.247> <3b35e8fa.311691@nntp.sprynet.com> Message-ID: On Sun, 24 Jun 2001 13:22:46 GMT, David C. Ullrich wrote: >On 23 Jun 2001 18:42:20 GMT, David LeBlanc >wrote: > >>In article <3b34939b.410758 at nntp.sprynet.com>, ullrich at math.okstate.edu >>says... >>> On Fri, 22 Jun 2001 12:47:23 -0400 (EDT), "Steven D. Majewski" >>> wrote: >>> >[...] >>> >>The reason why you can't write a device driver in pure Python >>is simple: a device driver requires the ability to read to and >>write from specific pre-determined locations in the processor's >>memory and/or I/O space. > >Yes, a device driver has to do this. But I don't see why a >program that _writes_ a device driver has to do these things. Nobody is arging that you can't write a Python program that generates a sequence of bytes in a file that can be used as a device driver by some particular OS. You don't seriously think that anybody is interested in doing this do you? -- Grant Edwards grante Yow! PARDON me, am I at speaking ENGLISH? visi.com From junkster at rochester.rr.com Tue Jun 12 20:06:15 2001 From: junkster at rochester.rr.com (Benjamin Schollnick) Date: Wed, 13 Jun 2001 00:06:15 GMT Subject: Plugins in Python References: <9g5hvq$ird$2@216.39.170.247> Message-ID: In article , David Bolen wrote: > One approach is that the __init__ file in the package can inspect the > package directory for other modules, and then use __import__ to import > them. I normally then populate a well-known dictionary within the > __init__ module that applications can use to determine what plugins > were loaded. You can also decide to set up the modules for lazy > loading using a proxy class if you want to avoid the overhead of > actually importing the plugin until needed. > > Note that one major negative with this approach is that it confuses > Python installation tools like py2exe and installer, as they can't > follow the dynamic importing, and also because the directory structure > may not be similar during execution. Now, I haven't checked this out too throughly, but I've built a server structure that uses standard EXEC calls to load additional plugins, and I don't remember seeing any problems with the installer...... Now it's been a while since I've modified it and tested it, so I maybe misremembering the situation.... - Benjamin From qrczak at knm.org.pl Sat Jun 2 03:43:45 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 2 Jun 2001 07:43:45 GMT Subject: Obsolesence of <> (fwd) References: <9f6el30dv5@enews2.newsguy.com> <3B16D681.E12A4554@Lugoj.Com> Message-ID: Fri, 1 Jun 2001 10:25:32 -0400, D-Man pisze: > If we were talking about C/C++/Java then it makes more sense : '!' is > the logical not operator so != means "not ,erm, assignment". Ok, > how about !== for "not equals" ? But in Python "not" is spelled 'not', not '!'. So "not equal" should be 'not =='. Looks bad. > You wouldn't prefer to use '/=' as Eiffel did, now would you? Haskell uses '/=' too, but it doesn't have augmented assignments (nor non-augmented asignments). OCaml uses '<>' and '!=' for Python's '!=' / '<>' and 'is not' respectively. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From aleaxit at yahoo.com Sat Jun 16 09:55:12 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 16 Jun 2001 15:55:12 +0200 Subject: New statement proposal for Python References: Message-ID: <9gfoia016rm@enews1.newsguy.com> "Tim Peters" wrote in message news:mailman.992695645.13636.python-list at python.org... ... > That leaves the only post-1.0 addition, "assert". It took years to get that > in -- although it's hard now to remember exactly why. The primary reason > it's a keyword is so the compiler can eliminate it under -O. Not sure I understand that motivation... the compiler under -O can eliminate non-keyword stuff too: D:\py21>python -O Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. Alternative ReadLine 1.4 -- Copyright 2001, Chris Gonnerman >>> def f(): ... print 'before' ... if __debug__: ... print 'inside' ... print 'after' ... >>> import dis >>> dis.dis(f) 0 LOAD_CONST 1 ('before') 3 PRINT_ITEM 4 PRINT_NEWLINE 5 LOAD_CONST 2 ('after') 8 PRINT_ITEM 9 PRINT_NEWLINE 10 LOAD_CONST 0 (None) 13 RETURN_VALUE >>> ...the whole "if __debug__:" statement being 'eliminated', no? I do understand that identifiers with __ in front and back are 'sort of reserved', but, not keywords, aren't they? I'm *NOT* arguing against assert, mind you -- one of my favourite statements -- just trying for better understandings of the why's and wherefore's. > Guido should have made "keyword" a keyword too. Then we could have had a > keyword statement at the top of each module, identifying all the post-1.0 > keywords your code wants to use <0.9 wink>. That COULD be done by having the module assign a literal to __keywords__ at the top -- the leading & trailing underscores making it magic and 'reserved', no 'clean' code can get broken (for some definition of 'clean'). Despite that missing wink-fraction, this doesn't appear to be highly Pythonic though. > "const frameworks" get invented routinely, but their inventors appear to > drop them after the heat of argument fades. Why bother? A universal In my case, mostly a (vain) hope of stifling a yet-one-more-round-of- "enhancement"-demands. Silly of me to hope, but... > convention supplies all of maintainability, clarity, consistency, and a > foundation for good programming habits too. What it doesn't do is insist > that you follow it against your will. That's Python! > > Guido once said that protection mechanisms in Python are like bicycle locks > in Amsterdam: they're advisory. That's what a __setattr__ method in a class does inter alia -- it ADVISES against not-meant-to-happen accidental bindings/rebindings (by raising an exception) while still letting you access the __dict__ when you really need to get around it. A pure convention is weaker than an advisory mechanism. There is no advisory mechanism for "constants" (except as attributes in a suitable object) -- JUST the convention. That may be a tad too weak in some cases (I'm neutral on that). It sure discourages some people from learning enough Python to see it doesn't matter. The advisory __whatever mechanism, which supplemented the purely- conventional _whatever one, did help to make a couple Python converts in my experience already -- they'd walk away BUT, when they saw there WAS a way to make stuff private-enough (C++'ists DO know that deep down there's no real guarantee, just convention;-), they kept going for long enough to see it's not a big issue either way. I suspect similarly weak-but-not-totally-inexistent mechanisms for other kinds of advisory protection would have similarly positive effect. > to *really* frustrate your errant coworkers. If you can't trust *yourself* > to adhere to simple conventions, though, Python isn't your language. > > otoh-keep-using-it-and-you'll-change-so-that-it-is-ly y'rs - tim That's why it's worth luring people into Python with bait-and-switch tactics IMHO. Alex From rjpeters at goethe.klab.caltech.edu Tue Jun 26 19:25:51 2001 From: rjpeters at goethe.klab.caltech.edu (Robert J. Peters) Date: 26 Jun 2001 16:25:51 -0700 Subject: python2.1 and RedHat7.1 References: Message-ID: <6g8zieescg.fsf@goethe.klab.caltech.edu> Michael Ackerman writes: > I tried to install the python2.1 rpm for RedHat7.0 on my 7.1 system > but got a "failed dependency" message saying that it wants: > libcrypto.so.0.9.6, libssl.so.0.9.6 > But these files are present, in /usr/lib. So what's going on? > Any help will be appreciated. This was my situation exactly yesterday, when I was trying to install python2.1 from the rpm onto a RedHat 7.1 system, and got the same error messages... yet searching in /usr/lib showed the libs were in fact there: [hume 16:14 284]% ls /usr/lib | grep ssl libssl.a libssl.so@ libssl.so.0.9.6* libssl.so.1@ [hume 16:14 285]% ls /usr/lib | grep crypto libcrypto.a libcrypto.so@ libcrypto.so.0.9.6* libcrypto.so.1@ So, I poked around with and "rpm --help" and decided to try the install with the "--nodeps" option (i.e. rpm --nodeps --install .rpm ) to tell rpm ignore whatever failed dependencies it discovered, since the necessary libraries were plainly present... that command worked without error, and the installation seems to be working fine (at least for the first 24 hours...). Cheers, Rob -- **************************************************************** Robert J. Peters Computation and Neural Systems rjpeters at klab.caltech.edu Caltech www.klab.caltech.edu/rjpeters/ Mail Code 139-74 (626) 395-2882 Pasadena, CA 91106 From rnd at onego.ru Thu Jun 28 12:57:56 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 28 Jun 2001 20:57:56 +0400 (MSD) Subject: PEP scepticism In-Reply-To: <9hfg1n$du33c$1@ID-89274.news.dfncis.de> Message-ID: On 28 Jun 2001, Bernhard Reiter wrote: >This a general warning against the second system syndrom in Python. >Maybe I am a hypocritical sceptic, but I have the impression that >some feeping creatureism is introduced into Python. >This might reduce the main advantage of Python to be clear and easy >and mostly have one good formulation on how to express what you want >to program in a structured way. > >Examples are: > - augmented Assigments > - Lists comprehensions > - Simple Generators I can't see these as bad things which make Python worse! If you do not want to use them - please do so. I do like functional style of Python and list comprehensions make the approach more powerful and clear. Augmented assigments are so common that their lack in Python looked like a hole. Generators make Python iteration facilities _much_ more robust without sacrificing clarity for the users of such constructs. >To me it looks like these contructs do not add capabilities to >python which were missing. They seems to be rare cases in which I It depends on the programmer. If you came from vanilla Pascal, maybe you will avoid lot of things at first. But programmers are lazy -- thus they use list comprehensions and augmented =s. >prefer that the programmer got to have the overview anyway and >should use a longer version which is more explicit and explains more >about what is actually being done. There is limit after which more explanation is worse than less: processed_list = [] for i in old_list: processed_list.append(func(i)) adds nothing but noise, while: processed_list = [func(i) for i in old_list] makes it clear as day! (I prefer map(), but this is personal) >The new syntatic additions still >require that the programmer has a full understanding about what is going on. >On the other the sum of language constructs is growing and harder to >understand as a complete system. Language constructs aren't the pile of features. There is good logic behind them, if you look with more attention. >Please to not respond giving me the very good reasons on why these >features I have given as examples have been added or will be added >to python. I know that the reasons are well worked out and make sense. >You can easily convince me as I have to admit that I do not have the >time to follow all the arguments and work out my opinion. Ok. Do not read then. >On the other hand this is excatly the danger I want to warn you about. >It is a social reason for being careful: > > Participation in the PEP debates about Python-enchancements > requires a certain level of knowledge and interest > about computer language design. And intuition too. > >It is most likely that the participants >do understand complicated language constructs easily and >are python wizards. They might just not see how the addition >of syntatic sugar will lead to a higher learning curve for the masses. As I said, features of Python aren't illogical pile of things. So, adding more features doesn't touch the mentioned curve. >(And we are missing the ability to make usability tests for these >kind of features because it is very hard to show and would require >tests with many programmers over long test periods.) > >Mainly as a python user I urge you to take this into consideration. As a python programmer, I think that Python must live, because it is live language. Even latin has recent additions to it, which undoubtly lead to "higher" curve. Every language which is practical and useful changes over the time. If you are dissatisfied with this, please fork Eternal Python project. > Bernhard >ps.: I have similiar thoughts about some recent strategic >development ideas for Zope. Python and Zope both have 2.x version >number, please fight the 2nd system syndrom. :) I myself sometimes wish some things to be eternal. At least to code eternal cybernetic soul and preserve it in a mausoleum ;-) Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Thursday, June 28, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "It is better to wear out than to rust out." _/ From pfortin at pfortin.com Sat Jun 2 10:02:42 2001 From: pfortin at pfortin.com (Pierre Fortin) Date: Sat, 02 Jun 2001 10:02:42 -0400 Subject: Executing a shell command References: <9f901k$ffa$1@mtc1.mtcnet.net> Message-ID: <3B18F202.5CE01862@pfortin.com> Kevin Riggle wrote: > > Is there any way to take a command in a string in Python, execute it in the > shell, and read the output into a variable of some sort, like > > result = execute(cmdline) result = os.popen(cmdline).read() Pierre From rsteiner at visi.com Fri Jun 8 05:51:47 2001 From: rsteiner at visi.com (Richard Steiner) Date: Fri, 08 Jun 2001 04:51:47 -0500 Subject: All your base are belong to us -- an explanation. References: <902430AC4moondustapexnet@209.99.56.9> <93hn81$l4m$1@nnrp1.deja.com> <9025628F7moondustapexnet@209.99.56.9> <3a5c8520_1@news.foxinternet.com> <902581E21moondustapexnet@209.99.56.9> <3a5ce21b_1@news.foxinternet.com> <4A982771F09.psskvxvn@vluxxijwai.net> Message-ID: Here in comp.os.linux.misc, wroot at my-deja.com (Wroot) spake unto us, saying: >shawntaub at yahoo.ca (Shawn Michael Taub) wrote > >> All your base are belong to us, > >Where is this from? I keep seeing it everywhere. Must be a classic. >Something Pr. Nixon used to say, perhaps? It's a line from a poorly translated game (ZeroWing) that was a standing joke on some of the Starsiege:Tribes forums a while back. Seems it took on a life of its own, and someone created a whole pile of fake photos that showed the phrase in all sorts of interested contexts. A web site outlining some of the history is here: http://hubert.retrogames.com/article.php?sid=1 -- -Rich Steiner >>>---> rsteiner at visi.com >>>---> Eden Prairie, MN OS/2 + BeOS + Linux + Solaris + Win95 + WinNT4 + FreeBSD + DOS + PC/GEOS + Fusion + vMac + Executor = PC Hobbyist Heaven! :-) The meek will inherit the earth; the rest of us will go to the stars! From aleaxit at yahoo.com Thu Jun 14 06:08:45 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 12:08:45 +0200 Subject: Python grammar.. References: Message-ID: <9ga2fo02i9m@enews1.newsguy.com> "Delaney, Timothy" wrote in message news:mailman.992496201.11915.python-list at python.org... ... > I'm merely holding up VB as an example of what *not* to do with a language. > I believe even MS has finally seen the error of this, and VB7 will not be at > all backwards compatible ... Right: it has removed a couple dozens of the worst warts (try saying these last words three times fast:-), by making incompatible changes that take it closer to Python in each case. (It still has warts enough to keep MS haters happy, I guess:-). Alex From gmcm at hypernet.com Thu Jun 21 16:34:46 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 21 Jun 2001 20:34:46 GMT Subject: Standalone .exe's using installer/builder question References: <9gsld3$5n6$1@plutonium.btinternet.com> <90C76054Egmcmhypernetcom@199.171.54.155> Message-ID: <90C7AD776gmcmhypernetcom@199.171.54.155> Cameron Laird wrote: >In article <90C76054Egmcmhypernetcom at 199.171.54.155>, >Gordon McMillan wrote: >>>C:\WINDOWS\Desktop\temp\Standalone.py test.py -tk >>> >>>anyideas??? >> >>Yes. Due to a Windows problem, you have to say: >> >>python C:\WINDOWS\Desktop\temp\Standalone.py test.py -tk >>^^^^^^ >> >>or the command line args don't make it to Standalone.py. >Let me be sure I understand: it's not a "problem" in the >sense that there is a fault specific to the installer or >Python that anyone expects to change, right? Windows is >*designed* in such a way that natural installations, in >effect, discard command-line arguments--correct? I'm not sure I *understand* any better than you :-). Especially when I misspoke on this one... [BTW, in private email, I got the actual error messages, and was able to straighten things out. Knowing things like what OS, and the actual errors encountered helps a whole lot.] It appears that when you use file associations, various operations are done at a higher level than they need to be. The big screw up is redirection. If you manage to convince Windows that .py files are executable, things work more reasonably. >Incidentally, I believe there's a tweak we can make to the >Windows installation (basically, complexifying some of the >data inserted in the Registry) to allow such shortcuts to >work as those of us coming from Unix expect. I've never >pursued it, out of fear for what could go wrong once we >get intimate with the Registry. Actually, it's on (other peoples') Unixen that I learned to type everything out. Uncooperative cshell bigots for sys-admins, and all that. - Gordon From gbreed at cix.compulink.co.uk Wed Jun 13 05:20:38 2001 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: 13 Jun 2001 09:20:38 GMT Subject: Traceback output References: <3B272970.4BA5D01C@usa.net> Message-ID: <9g7b96$t0a$1@plutonium.compulink.co.uk> In article <3B272970.4BA5D01C at usa.net>, mixo77 at usa.net (mixo) wrote: > How can I catch output from "traceback.print_exc()"? I would > to be able to do is write the information in a file . > I > from sys import exc_info from traceback import format_exception ... ex1, ex2, ex3 = exc_info() exceptionString = format_exception(ex1, ex2, ex3) Graham From phd at phd.fep.ru Mon Jun 18 12:09:56 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Mon, 18 Jun 2001 20:09:56 +0400 (MSD) Subject: Any other Python flaws? In-Reply-To: <3B2E26D7.DA3BD20D@bioreason.com> Message-ID: On Mon, 18 Jun 2001, Mitch Chapman wrote: > > 2. Even on an OS that allows killing blocked threads you are guaranteed to > > have problems due to insufficient cleanup. If you need to kill blocking > > process make it real forked process. Or use non-blocking approach > > (non-blocking sockets, e.g.) > > All of this tends to reinforce Andrew Kuchling's opinion that > threads were "a mistake". I'm still unsure whether he meant > threads in general were a mistake or whether he meant that > platform-independent threads facilities should be augmented with > platform-specific facilities. I don't think that threads are "mistake", but for most things threads are unneccessary. And for blocking calls threads are just bad, really mistake. Do not block a thread - use select/poll/whatever. Or fork a process and set watchdog. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From bos at hack.org Fri Jun 15 01:35:30 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Fri, 15 Jun 2001 07:35:30 +0200 Subject: Regexp-problem References: <3B2990B6.88DC8126@hack.org> Message-ID: <3B299EA2.CCF7E897@hack.org> Rikard Bosnjakovic wrote: > I have some problem with a regexp. Found the problem. Disregard this and the last post. -- Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From fredrik at pythonware.com Mon Jun 4 10:08:44 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 04 Jun 2001 14:08:44 GMT Subject: How to unpack data to unicode string? References: <3b1b7e04.5677574@news.muenster.de> Message-ID: Martin Bless wrote: > I'm doing a bit of analyzing TrueType files. (BTW, there's some good > information at www.microsoft.com/typography). There can be chunks of > unicode data inside truetype files which I can extract via slicing: > > rawText = data[start:end] > > Now, how do I do the transformation of rawText > '\x00N\x00o\x00r\x00m\x00a\x00l' -> u'Normal' ? try this: u = unicode(s, "utf-16-be") also take a look at TTX/TTLib: http://www.letterror.com/code/ttx/index.html From phrxy at csv.warwick.ac.uk Fri Jun 1 10:35:39 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Fri, 1 Jun 2001 15:35:39 +0100 Subject: printing sequences Message-ID: I've just had an attack of boredom about this simple problem that's been annoying me for a bit. I suspect there must be a simple solution, but I can't think what it is at the moment: t = (1.34, 2.02, 2.3) l = [1.34, 2.02, 2.3] print "foo: %s, bar %s" % t, l Which, of course, produces long strings with spurious precision where the sequences contain floating point numbers having no exact binary representation. It's very convenient to be able to print sequences, but can anyone tell me what simple construction I'm missing, or, if there is no such thing, supply the needed function that somebody surely must have written already?? John From rsenior at hotmail.com Fri Jun 1 12:21:31 2001 From: rsenior at hotmail.com (robin senior) Date: Fri, 1 Jun 2001 12:21:31 -0400 Subject: why huge speed difference btwn 1.52 and 2.1? Message-ID: <9f8fgs$ooo$1@knot.queensu.ca> I have a pretty simple script for processing a flat file db, running on Python 2.1; I tried running it under 1.52 for kicks, and to my surprise it ran almost 10 times as fast! Could someone let me know why 2.1 would be so much slower? Cheers, -robin ################## import re import string states = { 'ALABAMA':'AL', 'ALASKA':'AK', 'ARIZONA':'AZ', 'WISCONSIN':'WI', 'WYOMING':'WY'} for year in range(1994, 1998): f = open('states/USA'+str(year)+'.TXT') counter = 1 while(1): print str(year), counter counter = counter + 1 #convert city name to allcaps (change to string.strip(f.readline()) in 1.5.2) line = string.upper(f.readline().strip()) #check for EOF if not line: break for state in states.keys(): #(STATENAME) OR (STATE ABBREVIATION) if ( (re.search(' '+state+'( |,)', line, re.IGNORECASE)) or (re.search(' '+states[state]+'( |,)', line, re.IGNORECASE)) ): filename = string.replace(state, ' ', '_') g = open('states/'+filename+'/'+str(year)+'.TXT', "a") g.write(line) g.write("\n") g.close() f.close() From olafb+usenet at pvv.org Mon Jun 25 11:04:08 2001 From: olafb+usenet at pvv.org (Olaf Trygve Berglihn) Date: 25 Jun 2001 17:04:08 +0200 Subject: Scripts (running once) References: <3B37271F.759B0236@usa.net> <3B374CA4.A01F113C@usa.net> Message-ID: mixo writes: > If you send a hangup signal, for instance, 'killall -HUP python' > (not the best way to do things) the lockfile won't be removed. How > then , would you cater for system signals or system crash? Check my - a followup on Carsten Gablers post. Not totally bulletproof, so it might be an idea to check PID _and_ command (with args) in the process table. Unless you have overlapping command names and arguments, that should work better. Olaf -- Olaf Trygve Berglihn From stianh at ifi.uio.no Tue Jun 12 06:01:27 2001 From: stianh at ifi.uio.no (Stian Husemoen) Date: 12 Jun 2001 10:01:27 GMT Subject: PEP 259: Omit printing newline after newline References: Message-ID: [Guido van Rossum] >I propose to skip printing the newline when it follows a newline >that came from data. Gustaf Liljegren wrote: >I like consistency, so I think either 'print' should add a newline, or it >shouldn't. Whatever you choose, it shouldn't do things "behind the scenes". I must agree with Gustaf here.. Making decisions like that for the user are just adding more special cases and confusion. >If it depends on the line before, it won't be so self-explanatory if you >see a 'print' statement with no arguments. And to qoute the Zen of Python: Explicit is better than implicit. >If you make rstrip() a built-in function, you get something like chomp() in >Perl. :-) No need to make it a builtin.. We already have string methods. If this proposed behavior is really needed, how about adding another magic operator like '>>' or ',' to the print statement? Then I can go on pretending that this new operator doesn't exist either -- Stian Husemoen From pkalliok at cc.helsinki.fi Fri Jun 1 08:14:39 2001 From: pkalliok at cc.helsinki.fi (Panu A Kalliokoski) Date: 1 Jun 2001 12:14:39 GMT Subject: O(n^2) is bad - can it be fixed? References: <3B09FBF9.8691EBFE@accessone.com> <2s5kgtggf47hsvg944npqllsob95hefkpn@4ax.com> Message-ID: <9f80vf$qim$1@oravannahka.helsinki.fi> Courageous wrote: > The correct thing to do if performance becomes important > to you in this context is to convert the string to a list, > manipulate it as a list, and then convert it back to a string. Interesting that nobody mentioned this: because strings are immutable, a string produced by concatenation could be represented by a tree node of the two substrings instead of a copy of the original character arrays. This works because the substrings are guaranteed to remain the same. String handling will become more complex so that this might not be worth doing, but in the example case it would keep the performance O(n) for the test. Panu Kalliokoski From barry at digicool.com Fri Jun 1 10:50:53 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Fri, 1 Jun 2001 10:50:53 -0400 Subject: docstrings, invention there of References: <200106010601.IAA08860@boris.cd.chalmers.se> Message-ID: <15127.43981.921007.235051@anthem.wooz.org> >>>>> "TP" == Tim Peters writes: TP> Guido wouldn't claim that docstrings were original with TP> Python. I'm not sure who "we" refers to here, or to what "the TP> interpreter"; Python's docstrings were most directly inspired TP> by the similar facility in Emacs's elisp interpreter (and it TP> wasn't original there either, of course -- the idea of TP> attaching doc properties to Lisp atoms and extracting them via TP> introspection must go back several decades). Tim's got the lineage correct here. At the first Python workshop at NIST in 1994, the subject of docstrings came up. Emacs Lisp was the example model pointed to most often, not surprisingly because the percentage of Emacsheads in attendance was quite high. :) We couldn't agree on the structure of the strings, except for two things, both taken from our experience with Emacs Lisp: they should be the very first thing in the block (except perhaps for comments), and that the first line should be a complete, and short sentence. -Barry From dnew at san.rr.com Sun Jun 3 14:33:01 2001 From: dnew at san.rr.com (Darren New) Date: Sun, 03 Jun 2001 18:33:01 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> Message-ID: <3B1A82DD.C4D78472@san.rr.com> Alex Martelli wrote: > So what does the "GIVEN _complete_ information" above > is, if not a statement that you CAN be given complete > information about I interpreted it as meaning "given that you know everything about the system that it's possible to know." If you have complete information, then you know the exact probabilities that any particular item is in any particular state. Just like if you have "perfect dice", it means that all the probabilities are exactly 1/6. This doesn't tell you which number a perfect die will roll next. > And quips apart, what's "sinful" about dealing with > randomness this way? If the underlying maths are sound > (and that, I surmise, IS what Chaitin has to do with it: > showing the soundness of this finite-maths approach > to randomness), why shouldn't RNG's be feasible and > sin-less that are based on these techniques? Well, it's not something you'd want to use to encrypt documents that the bad guys will kill you over if they ever read them. > I still haven't heard your definition of > 'perfect' randomness, for example. Generally, this is something along the lines of: Given all available information about the mechanism used to generate the bits, and an arbitrarily long sequence of generated bits, it's impossible to predict with >50% accuracy what the next bit in the sequence will be. I'm not sure it always includes the first condition. I don't think Chaitin's Omega meets this definition, since it is by definition a single number than anyone can calculate equally well. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. This is top-quality raw fish, the Rolls-Rice of Sushi! From ralf.muschall at alphasat.de Fri Jun 15 15:09:22 2001 From: ralf.muschall at alphasat.de (Ralf Muschall) Date: 15 Jun 2001 21:09:22 +0200 Subject: Status of cephes? Message-ID: Does anybody know which version of cephes is the current one, and where to get it? I found cephes-1.15.tar.gz somewhere, but it doesn't even compile (using linux 2.2.16, libc.so.6, python 2.1, Numeric 20.0.0 (the latter two built from source)). The problem seems to be that some of the libc/libm-functions mentioned in cephes/protos.h became macros in /usr/include/math.h in the (looooong) time since the creation of that version of cephes (around March 1999), and that the arg list of PyUFunc_FromFuncAndData(...) (and probably mny more) has changed. Unfortunately, oliphant.netpedia.net (the official home of cephes) requires a password and seems not to accept the usual combinations like ("guest","guest"), ("guest,"") etc., so I cannot verify the version. Ralf From ykingma at accessforall.nl Thu Jun 21 14:43:41 2001 From: ykingma at accessforall.nl (Ype Kingma) Date: Thu, 21 Jun 2001 19:43:41 +0100 Subject: problems with jython References: Message-ID: <3B32405D.1730A079@accessforall.nl> Tyler, When during jython startup the sys-package-manager encounters a jar that it has not seen before on the class path, it will process the jar so you can easily import from it in jython. For large jars this may require more memory than java has available, which seems to be the problem causing the SIGSEGV. Just retry with more memory allocated to the JVM. Type 'java -h' to find out how to do this. Tyler Coumbes wrote: > > I got jython 2.0 and am trying to run it with IBMJava2-13. > I get this error > *sys-package-mgr*: processing new jar, > '/home/flounder/jython-2.0/jython.jar' > SIGSEGV 11 (*) segmentation violation > stackpointer=0xbffc1cf8 > > and it just keeps going at 100% cpu and doesn't stop > What could cause that? > > -- > Tyler Good luck, Ype -- email at xs4all.nl From ralph at inputplus.demon.co.uk Thu Jun 14 15:14:22 2001 From: ralph at inputplus.demon.co.uk (Ralph Corderoy) Date: 14 Jun 2001 20:14:22 +0100 Subject: socket, UDP, SO_MAX_MSG_SIZE ??? References: <9ebgb0$eb5$s@216.39.170.247> Message-ID: <9gb2ee$jnh$1@inputplus.demon.co.uk> Hi, David LeBlanc wrote: > IP packet size is generally ~1500 bytes by default. Don't know if > that's a given on all tcp/ip stacks or just Windows specific (I got > the impression that it was a standard default though). Sounds like you're getting confused with the size of the network packet, e.g. on Ethernet. A large IP packet will be fragmented into many parts to travel across the underlying network. $ ifconfig | grep MTU UP BROADCAST LOOPBACK RUNNING MTU:3584 Metric:1 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 UP POINTOPOINT RUNNING MTU:2500 Metric:1 Ralph. From aleaxit at yahoo.com Wed Jun 20 09:15:02 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 20 Jun 2001 15:15:02 +0200 Subject: Embedding References: <3b305ce7@news.actrix.gen.nz> Message-ID: <9gq7lq0lvl@enews1.newsguy.com> "Mark Rowe" wrote in message news:3b305ce7 at news.actrix.gen.nz... > Hey all, > > Just been fiddling round with embedding Python in a C program, and one thing > has me stuck. I would like the user to be able to enter some python code > containing functions, then at a later point execute one of these functions > by name. I'm not really sure what i need to do for this to work You don't have to do much. Collect the source code that the user enters (e.g. in a text-entry window in a GUI?), into one big Python string (make sure there's a '\n' at the end:-), feed it to builtin function compile() and make sure to catch a SyntaxError that will be raised if the code has syntax errors, and let the user know. If there are no errors, compile() returns a code-object. Stash it away, and at any later time you can pass it to statement 'exec' (you may want to pass specific dictionaries to control execution namespaces). Again, be sure to catch and report any exceptions that may arise. This is all at the Python-level, where it's easiest, but of course there is equivalent functionality accessible from the C API, too -- it's just more work (as usual for C vs Python:-) so, the more you can do in Python, the merrier, no?-) Alex From mal at lemburg.com Fri Jun 22 16:03:01 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 22 Jun 2001 22:03:01 +0200 Subject: Unexpected import behavior References: <5.0.2.1.0.20010622135426.03413ec0@mail.mindspring.com> Message-ID: <3B33A475.BD274840@lemburg.com> Chuck Esterbrook wrote: > > Under the old mxDateTime, I had: > > import DateTime > from DateTime import now, RelativeDateTime > > The new one is inside a package. No problem, I thought: > > from mx import DateTime > from DateTime import now, RelativeDateTime You have to rewrite this as: from mx.DateTime import now, RelativeDateTime > But that gives me this: > > Traceback (most recent call last): > File "./DailyLinks21.py", line 24, in ? > from DateTime import now, RelativeDateTime > ImportError: No module named DateTime > > Obviously there is a DateTime variable by the time we get to the second > statement and it points to a module. I printed the repr() and type() to > make sure. > > An examination of sys.modules.keys() shows, however, that there is no > 'DateTime', but only 'mx' and 'mx.DateTime'. Python will (almost) always register the modules under their absolute dotted path names. > Using a Python package containing a package containing a module, I created > the same problem. I then created it with Python 2.0 and 1.5.2. > > The behavior seems rather non-intuitive (although easily fixed in this > case). I guess the explanation from those familiar with Python internals > will be something along these lines: > - import uses sys.modules.keys() not the symbols where it is located Right. > - "from pkg import module" does not "unqualify" the module for future > imports even in the module where this statement appears Right again ;-) It does however make the "from" name available, e.g. import mx.DateTime from mx.DateTime import now will work. You can also do: from mx import DateTime from mx.DateTime import now > So at this point, I'm wondering if you think this behavior is > intuitive/"correct" and whether or not it would make any sense to change > it. For example, could import look at local symbols before sys.modules? I don't think it would be a good idea to start mixing scopes here. Using the absolute package names gives you a very good idea of where the different APIs in your namespace are coming from. Also, I am not sure whether the import hook has access to the current scope. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From s713221 at student.gu.edu.au Wed Jun 13 08:08:09 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Wed, 13 Jun 2001 22:08:09 +1000 Subject: Mandrake 8, where is IDLE? References: Message-ID: <3B2757A9.4AE92C6A@student.gu.edu.au> Alan Garrison wrote: > > Hi, I installed Mandrake 8 (off CD 1 only) on my workstation. Python > itself is installed (2.0-9), but no IDLE. I can't find any IDLE rpm > files on the rpmfind sites. Python.org seems to say that IDLE is now > a part of the python dist. Did IDLE not make it into Mandrake 8, or > is it on CD 2? > > Thanks. > > -- > alan at alangarrison dot com > "Have I mentioned I'm immense and immortal?" - Joel R. Have you checked to see if there's a python-tools package? -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From sholden at holdenweb.com Wed Jun 27 14:00:47 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 27 Jun 2001 14:00:47 -0400 Subject: PEP 260: simplify xrange() References: <3B398BBE.A2D455C9@darwin.in-berlin.de> <9hclc1$qv5$1@panix2.panix.com> <3B3A08B5.3C142546@darwin.in-berlin.de> <3B3A193F.AAFB31D5@darwin.in-berlin.de> Message-ID: "Dinu Gherman" wrote in message news:3B3A193F.AAFB31D5 at darwin.in-berlin.de... > Michael Hudson wrote: > > > > >>> len(frange(0,1.,0.1)) > > 11 > > >>> len(frange(0,1.,0.2)) > > 5 > > So what? > Michael was just underlining the semi-random sequence lengths you will get when using decimal floating-point representations. If you're aware of that and it doesn't matter, then it doesn't matter :-) In integer-land one would expect that len(range(x, i, y)) == len(range(10*x, 10*i, 10*y)) for all x, i and y. This clearly wouldn't be true for frange(). regards Steve -- http://www.holdenweb.com/ From gustafl at algonet.se Tue Jun 19 18:33:45 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 19 Jun 2001 22:33:45 GMT Subject: Extremely strange problem with httplib/urllib References: Message-ID: gustafl at algonet.se (Gustaf Liljegren) wrote: > Also, if I write the above script in Idle or on the command line, this > error don't appear. It's no first time problem -- I have used these > modules extensively before. Any ideas? Just a correction: Idle *do* in fact crash too, when I close the window. Gustaf From gtalvola at nameconnector.com Tue Jun 19 11:29:37 2001 From: gtalvola at nameconnector.com (Geoff Talvola) Date: Tue, 19 Jun 2001 11:29:37 -0400 Subject: What's the best way to implement a real-world SOAP server? In-Reply-To: <23422f46.0106182014.6218d2ef@posting.google.com> Message-ID: <5.1.0.14.0.20010619111655.034ab140@infratest1> At 09:14 PM 6/18/01 -0700, Jim Severino wrote: >Hello everyone > >I see that Actzero's SOAP.py provides a SOAPServer class that >implements a request handler which handles object and function >registration as well as the network side of things through the >imported BaseHTTPServer class. This works for development and testing, >but what about real-world implementations, where a SOAP server may be >expected to handle hundreds of requests per second? Doesn't the >BaseHTTPServer only execute one request at a time? > >I would like to know what people think would be a suitable SOAP server >(that works with Python modules, of course) for a "real-world" >environment. The ideal server would implement simultaneous processing >of multiple requests, database connection pooling.... all of the >things that a good webserver setup implements. > >I was looking at mod_python + Apache, but I don't see how one can go >about using SOAPServer with them, since SOAPServer provides its own >HTTP server. > >I may be missing something obvious. Please tell me if I am. Here's one option: Webware lets you write servlets that do XML-RPC, and Webware provides an efficient threaded application server and lets you do database connection pooling, etc. If you can get by with XML-RPC, this works great as-is. If you really need SOAP, it should be pretty easy to write a SOAPServlet base class just like the XMLRPCServlet class that is already in Webware. I've thought about writing it myself, but XML-RPC suits my purposes just fine so I haven't bothered. But this would be a nice addition to Webware. If you want to try this, I recommend going to http://webware.sourceforge.net/ and getting the tip of CVS, as I think the XML-RPC functionality has been enhanced significantly in CVS since the last Webware release. Also I recommend joining the webware-discuss mailing list. -- - Geoff Talvola gtalvola at NameConnector.com From boyd at insultant.net Mon Jun 4 07:28:31 2001 From: boyd at insultant.net (Boyd Roberts) Date: Mon, 4 Jun 2001 13:28:31 +0200 Subject: I NEED to TEACH you something, QUICK! References: Message-ID: <9ffreg$j4s$1@neon.noos.net> a ?crit dans le message news: mailman.991648868.22464.python-list at python.org... > Did you take yourself off Lithium? i don't think she's suffering from mania so lithium is unlikely. > Run to your local drugstore and get yourself on Thorazine > as soon as you can. nor from psychotic episodes. From apost at cbmi.upmc.edu Tue Jun 26 21:32:24 2001 From: apost at cbmi.upmc.edu (Andrew Post) Date: Tue, 26 Jun 2001 21:32:24 -0400 Subject: How to determine if something is hashable? References: <3B377987.4010304@cbmi.upmc.edu> Message-ID: <3B3937A8.4070009@cbmi.upmc.edu> That's what I was looking for. Thanks for the tip! Andrew Remco Gerlich wrote: > > In that case, I don't see what else could raise TypeError though. > > But you can try more explicitly with: > > try: > hash(valList[i]) > except TypeError: > ... > > From Denys.Duchier at ps.uni-sb.de Wed Jun 20 12:05:40 2001 From: Denys.Duchier at ps.uni-sb.de (Denys Duchier) Date: 20 Jun 2001 18:05:40 +0200 Subject: PEP 255: Simple Generators References: Message-ID: "Tim Peters" writes: > [Denys Duchier] > > The one thing that rubs me the wrong way with this proposal is that it > > is not compositional. Unless I misread the PEP, the entire generation > > logic must be defined in a single function (because the `yield' > > keyword must statically occur within the body of the generator > > function). This makes it impossible to use higher-order programming > > to assemble complex generators from smaller blocks. > > Since higher-order programming is an aberration (meaning > statistically rare) in idiomatic Python, a specific example would > help. Think for example of a tree traversal algorithm that is parametrized by a procedure to be applied to each node. My reading of the PEP does not allow a procedure to be passed in that `yields' the node. While possibly aberrant, let me suggest a higher-order programming approach that would not even require a new keyword but merely a new primitive which I'll call `generator'. This primitive takes a unary procedure as argument and returns an iterator. The unary procedure takes itself a `yield' procedure as argument. Here is the fib example of the PEP written with my proposal: def fib(yield): a, b = 0, 1 while 1: yield(b) a, b = b, a+b g=generator(fib) It's straightforward (in an implementation) to check that the yield procedure which is invoked actually corresponds to the generator that is currently executing. If that's not the case, an exception should be raised. This proposal has the advantage that the boundary of the generator is fixed late, namely at the time the `generator' primitive is invoked. It also support full compositionality. > If, e.g., you want to > build a generator that delivers the results from generators g and h > alternately, it's easy (although I personally don't want to ): > > def zipgen(g, h): > giter = g() > hiter = h() > while 1: > yield giter.next() > yield hiter.next() which I would write as follows: def zipgen(g,h): def result(yield): g(yield) h(yield) return result Cheers, -- Dr. Denys Duchier Denys.Duchier at ps.uni-sb.de Forschungsbereich Programmiersysteme (Programming Systems Lab) Universitaet des Saarlandes, Geb. 45 http://www.ps.uni-sb.de/~duchier Postfach 15 11 50 Phone: +49 681 302 5618 66041 Saarbruecken, Germany Fax: +49 681 302 5615 From tgos at spamcop.net Thu Jun 7 00:11:07 2001 From: tgos at spamcop.net (TGOS) Date: 6 Jun 2001 23:11:07 -0500 Subject: best language for 3D manipulation over web ? References: <9f7eqe$gvd$1@oslo-nntp.eunet.no> <9fldqf$2bo$1@oslo-nntp.eunet.no> Message-ID: <7rutht85arahtvh10eqlel8lpp81f4o9kh@4ax.com> On Wed, 6 Jun 2001 16:22:06 +0200, "Thomas Hansen" wrote: > [snip] >>> PS! >>> It's an ActiveX object, >> >> Ergo it won't work in my browser, nor in any other browser except IE. >> > > Who cares if they're making games since EVERYBODY that play games on > something else then a Sony, GameBoy (or similar) sits in front of a PC... Who is talking about games here? This post is about a person who tries to realize a 3D access interface for a database from within a browser. Please read a thread carefully before replying to it. Despite that, I play games and I also play games within my browser. And when the game uses Java3D, I can play it on every PC I like. The WT games don't run on the PCs I usually use, because they either run with Solaris, Irix or Linux. >>> wraps around DirectX to make scripting 3D games >>> possible. >> >> Ergo it won't work on any plattforms except Windows. > > Same as above, except exchange PC with WIN32 system... Why should only Win32 users be allowed to access this database via their browser? Because some stupid Windows user think that they rule the planet? > DirectX have had hardware acc. T&L since version 6 or seven I think... No, DirectX7 is the first version with T&L support in hardware. All older games use software T&L in DirectX (IOW your CPU is doing all the work) and to make use of the new hardware T&L, programmers have to rewrite their code, while OpenGL applications automatically make use of this feature, without altering their code. (and that also OpenGL is older than DirectX1...so much to Micro$ofts great libraries) >> I've seen that too and it even works without hardware acceleration. >> http://www.minatrix.com/burningmetal2.html > > It was very nice, and I was actually very impressed, but it's not even in > the same league as the WTGD... It also doesn't make use of Java3D, IOW that was plain software emulation. So before you haven't even seen Java3D action, you aren't in the position to judge about it. -- TGOS From aleaxit at yahoo.com Mon Jun 18 04:15:40 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 18 Jun 2001 10:15:40 +0200 Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? References: <3B2B60AD.942719AE@earthlink.net> Message-ID: <9gkdbb022u4@enews2.newsguy.com> "Paul Prescod" wrote in message news:mailman.992841807.926.python-list at python.org... [mostly snipped excellent explanation] > Visual Python is an IDE plug-in for Visual Studio.NET. Visual Studio.NET > is an IDE from Microsoft that has the four letters .NET at the end to > convince you that it is sufficiently different from Visual Studio 7 that I think you mean 6 where you wrote 7 here...? > you should buy it. You can develop .NET applications with Visual Studio > .NET but you can also develop old fashioned Windows applications or raw I find it incredible that MS mktg doesn't understand the deep (and justified on the burned-once principle) *CONSERVATISM* of many, many development organizations. Those "four letters at the end", as you so well put it, ARE convincing many that the IDE "is sufficiently different from VS6" that they *WON'T* buy it -- or, at least, not yet. If they've made the strategic decision not to develop for the .NET platform YET (quite a reasonable one for many development orgs at this point -- experimentation is one thing, but production SW on which big money depends needs to proceed very cautiously), and the 'brilliant' folks at MS mktg manage to convince them that VS.NET *IS* about .NET, then it follows that development will remain on good old VS6 -- period. *sigh*. What a mktg *GOOF*...!-( Alex From urpala at ampeeri.ee.tut.fi Tue Jun 5 12:54:34 2001 From: urpala at ampeeri.ee.tut.fi (Uoti Urpala) Date: 5 Jun 2001 16:54:34 GMT Subject: random References: <3b1cf00f.5441109@nntp.sprynet.com> Message-ID: In article <3b1cf00f.5441109 at nntp.sprynet.com>, David C. Ullrich wrote: >Indeed the exact value of Omega depends on the details of the >encodings. What I'm wondering today is how many of his conclusions >also depend on the details of the encoding. >Suppose I have a syntax where a valid program is precisely >a sequence of 0's terminated by a 1. Any such string is a >valid program. Does this count as "self-delimiting"? That probably does count as self-delimiting, but it doesn't fill other requirements of the results. The encoding must allow "arbitrary binary data" to be included. The proof basically says "you need n bits of program to calculate n bits of Omega". This is a strong result if the encoding is efficient, but the above encoding needs a lot of bits to calculate anything, so in that case the result doesn't say much about the associated Omega (and the same proof wouldn't work, since it depends on the ability to give an arbitrary program as an argument to another with limited overhead). Proving the randomness of Omega basically works like this: You can create a program that, given the first n bits of Omega, solves the halting problem for all programs of size <= n. (Details below) If you can calculate the first m bits of Omega with a program of size p, you can add a bit of extra code to create a program of size p+e (e constant) that solves the halting problem for itself and then does the opposite (the standard contradiction for a program solving the halting problem for itself). So p+e must be greater than m to avoid a contradiction, and a program to calculate the first m bits of Omega must have size at least m-e. (You can generalize this to calculating _any_ bits of Omega in whatever position - if you can calculate some with a short program, you can hardcode the missing ones to get a full initial segment). Solving the halting problem for a program P of size s given the first s bits of Omega: Calculate lower bounds for Omega (as mentioned in other posts) until the first s bits agree with the known bits. Now you have either found that program P halts, or you know that it halting would raise the lower bound so much that it could no longer match the known bits, so P cannot halt. Exercise: Show that the first bit of Omega whose value is independent of ZFC is a 0. -- Uoti Urpala From rnd at onego.ru Sat Jun 2 13:50:21 2001 From: rnd at onego.ru (Roman Suzi) Date: Sat, 2 Jun 2001 21:50:21 +0400 (MSD) Subject: Against PEP 240 In-Reply-To: <20010602113558.A25579@doublegemini.com> Message-ID: On Sat, 2 Jun 2001, Clark C . Evans wrote: >On Thu, 31 May 2001, Tim Peters wrote: >> [Roman Suzi] >> > Rounding and formating is a MUST in anything nrealy financial ;-) >> > So, lets not put additional burden on the Python and >> > just put "%11.2f" % round(var, 2) were due. >> >> I doubt that's going to make Clark feel better, as I can't >> imagine a context in which that code snippet would make good sense. >> That's the kind of thing he's doubtless suffering from: >> well-intentioned attempts to worm around problems too >> dimly understood. > >Nod. You'd be amazed what kind of "tricks" people use >to get the "right" answer. It works in the short term, >but when the money is aggregated, taxes are calculated, >and other numeric operations are carried out these >"tiny" errors do accumulate. One "minor" mistake in >an accounting program and it brings into question the >data integrety of evertyhing... > >Further, I've seen far enough of the the above >"well-intensioned" attempts to use floating point >representations for currency. For me, this is the >type of stuff nightmares are made of... And I am >not claiming the high ground here -- in my first few >years I was as guilty as the next fella. Python >should not require the nasty initiation that I >was faced with. > >... > >There are two general approaches: (a) do all of your >calculations in "cents", or (b) use a BCD (binary >coded decimal) library. > >Unfortunately the former isn't always an option... >for two reasons, first people don't think in cents >so it makes calculations quite a bit harder. Second, >for some currencies, numeric overflows are too common. >Let's say the annual revenue of your company was >1.5 million dollars. This is 342,540,983,606 Lire*100. >With this number, you just had an overflow if you >were using long (32) bit integers (4,294,967,296) > >... > >More and more people will be using Python for financial >applications, from accounting to purchase order processing. >Must we require each of these programmers, who perhaps >have business degrees, to completely "grok" all of the >subtleties of numeric analysis before they can write >their first invoice? Certainly we could write and >publish a "BCD" library... but I question how many >junior programmers would know what BCD is... let alone >taking active initiative to look for BCD. > >I'd rather have the default be some sort of BCD >representation... where the programmer has to "work" >to get the innaccuracy of a floating point representation. >I'm not too worried about speed. If it's slow then >the programmer will search the documentation to find >out why. And, after some looking will stumble across >the "bcd vs float" distinction and then make the >'conscious' choice to use a floating point representation >and having to concern themselves with all of its >idiosyncrasies. This said, what is the right way to deal with currencies in Python right now? Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Saturday, June 02, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Without my ignorance, your knowledge would be meaningless.." _/ From m.faassen at vet.uu.nl Sun Jun 3 17:27:57 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 3 Jun 2001 21:27:57 GMT Subject: Python output for Glade References: <9fdprb$3hpec$2@ID-91520.news.dfncis.de> Message-ID: <9fea4t$cbi$1@newshost.accu.uu.nl> Rajarshi Guha wrote: > Hi, > does anybody know of patches etc that can give me Python source for a > Glade project. I tried using glade.py but it gives a number of errors and > suggests I use libglade. Is there any docs/webpages available showing how to > use libglade? I'm not sure what tutorial I used, but it isn't very hard. A web search found me this tutorial: http://www.russnelson.com/pyglade-tutorial/pyglade-tutorial Sample sources: http://www.russnelson.com/pyglade-tutorial/ And another tutorial: http://laguna.fmedic.unam.mx/~daniel/pygtutorial/pygtutorial/ There's quite a bit out there. I recall seeing a few more. Alternatively there's also an actively being developed (latest release *today*) code generator that generates Python code from Glade XML files. I've never used it, but here's the homepage: http://www.fcoutant.freesurf.fr/gladepyc.html Regards and good luck, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From s713221 at student.gu.edu.au Thu Jun 14 06:32:13 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Thu, 14 Jun 2001 20:32:13 +1000 Subject: tummy compile Mandrake 7.2 References: <20010608.214013.1469262009.16325@K7.atl.mediaone.net> <20010609.104451.1884661237.1229@K7.atl.mediaone.net> <3B24154E.C70211ED@student.gu.edu.au> <20010610.232821.1789366143.1225@K7.atl.mediaone.net> <3B25F742.F4E25C37@student.gu.edu.au> <20010612.203418.76065818.14030@K7.atl.mediaone.net> Message-ID: <3B2892AD.5BE6D30D@student.gu.edu.au> myself wrote: > *Joal blushes* > hey Joal, I hate to break it to ya, but YOU'RE DA MAN!! I never would have > figured all that out, and certainly would never have proceeded to the rpm > -bb stage after what looked like a total failure of the rpm -bi. So far it > looks good, but even if it turns out things aren't exactly right, I > learned a lot, and could go back in and try again. I can't remember what first triggered me to try it. I think it was the point that rpm still built dependencies based on what was in the spec file, after the auto-dependencies chucked a wobbly. > A few notes- used python2-2.1-5.src.rpm- changelog looked ok, so why not; > along the way installed openssl & -devel-0.9.6-7, expat & -devel-1.95.1-3, > and libgmp3-3.11-3, all mdk.i586.rpm, mostly cooker IIRC, no dep. probs. > w/ any. Line #'s were different in spec file, but your instructions were > clear enough that it didn't matter. Yep. Unfortunatly you usually have to build rpms from source to maintain Mandrake's optimisations and enhancements, but if you can only get a binary i386.rpm, don't be too troubled about using it. If the dependencies are satisfied, it should work, and the optimisations that Mandrake uses doesn't actually get you that much extra speed. Keep those built rpms lying around somewhere though. You wouldn't believe how they can speed up system recovery if you do something silly. (And if you don't, you're not trying hard enough!) > from reprtest: > > 122 tests OK. > 1 test failed: test_socket ("already in use"). > 14 tests skipped: test_al test_bsddb test_cd test_cl test_dbm test_dl > test_gl test_idev test_sundry test_winreg test_winsound > > which is vast improvement- as user I previously had more skips and > crashes on some imp't ones like _builtin_ and _types_! Okay, the test_socket one probably isn't too important, though I'd be curious to know what caused it. The skipped tests are because the build didn't make certain modules. If you want those modules, such as the gl-module, rpm -bp (prep), then go into the build directory and run a normal source compile, ensuring you alter Modules/Setup first. (Or whatever. You'll have to read the build instructions or ask someone who's build python from source recently.) Then go back to the spec file and rpm -bi --short-circuit etc. Of course you could try to alter that by creating a patch file and learning the %patch LM macros, but I usually just fiddle by doing the build myself and then handing everything back to rpm for the install and packaging steps. > many thanks! and to the group- in most other ng's, there are always folks > whose purpose in life seems to be ridiculing the newbie (and other lost > souls). That almost never happens here; I've only posted in two threads, > and already given you guys ample opportunity. Thank you for your civility > and patience. Most of the people here remember when they were newbies and how well we were treated ourselves. Additionally, most of us secretly watch responses to new users avidly because we nearly always learn something new from them ourselves. Of course we do ask that new users visit www.python.org and search the documentation where possible, but building on a Mandrake system brings up problems slightly out of the ordinary. (Like that *#@$ bz2 thing. *sighs*) > ps- do toilets *really* flush clockwise in the land downunder? *groans in pain* Yes they do, and vines also tend to climb trees clockwise as well. Happy indenting. -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From new_name at mit.edu Fri Jun 15 22:49:31 2001 From: new_name at mit.edu (Alex) Date: 15 Jun 2001 22:49:31 -0400 Subject: setattr too promiscuous? Message-ID: Would it be sensible to amend setattr so that it only permitted assignment to attribute names that can be used with the . construction without causing a syntax error? The possibility of doing this took me by suprise a bit: >>> class A: pass ... >>> setattr(A, '/', 'test') >>> dir(A) ['/', '__doc__', '__module__'] >>> print A./ File "", line 1 print A./ ^ SyntaxError: invalid syntax >>> I guess such a patch would break existing code, but maybe extra argument checking in setattr it could be turned on by the "import __future__" command. If people think this is a good idea, I'll submit a patch at some point. Alex. From donn at drizzle.com Wed Jun 27 01:22:58 2001 From: donn at drizzle.com (Donn Cave) Date: Wed, 27 Jun 2001 05:22:58 -0000 Subject: Python on BeOS References: <9hb0ib$d4i6k$1@ID-22517.news.dfncis.de> Message-ID: <993619377.780885@yabetcha.drizzle.com> Quoth "Harvest T. Moon" : | "Andrew Todd" schrieb |> I haven't found much on the net concerning Python on the |> BeOS. I think Python v2.1 has been released for it, but I'm |> not sure. | | Python 2.1 compiles out-of-the-box on BeOS (5), there are also | binary-releases available @ http://www.bebits.com | one is bundled with Bethon (a GUI modul for BeOS, wrapper for the native C++ | calls, which i found not that usefull as it is not thread-safe) and one | comes with the Pygame module (a wrapper to SDL). Bethon is not a GUI module, and it sure is thread-safe, but indeed it is wrappers for the native BeOS API. What did you do, that led you to think it was not thread-safe? |> Anyway, I was just wondering if anyone had any |> experience with the language in this OS. Is the language |> just as solid as it is in most of the other platforms? It works fine on BeOS. Python's core is eminently portable, that might be for me its finest virtue. There isn't all that much in it to go wrong. Donn Cave, donn at drizzle.com From gmcm at hypernet.com Sun Jun 24 21:58:59 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 25 Jun 2001 01:58:59 GMT Subject: PEP 255: Simple Generators References: Message-ID: <90CAD6A43gmcmhypernetcom@199.171.54.194> Glyph Lefkowitz wrote: >[generators] will hinder the future >implementation of microthreads should they happen and probably cause some >pretty fruity interoperability issues (if it's a syntax feature). Disagree completely. Generators are a pale shadow of what you can do with Stackless, but one of the issues about Stackless is acceptance. People trained in structured or OO (without exposure to languages that have these strange control flow features) tend to think of it as silliness (much the way you dismiss generators). And, actually, I think that's the main reason that people are interested in microthreads instead of coroutines - it follows a familiar model. I'm not dissing microthreads (they certainly have many uses), but for much of what I've seen microthreads used for, coroutines would be more efficient and cleaner. So generators are an important step in getting people to see that there are other forms of control flow. The other main issues are Jython compatibility and implementation complexity (dealing with interpreter recursions). Christian payed no attention to the former, and only handled a couple cases of the latter. That's certainly no criticism of Christian - it's a measure of how difficult the task is (it took a genius to give us a usable proof-of-concept). - Gordon From gustav at morpheus.demon.co.uk Sat Jun 2 17:21:53 2001 From: gustav at morpheus.demon.co.uk (Paul Moore) Date: Sat, 02 Jun 2001 22:21:53 +0100 Subject: Against PEP 240 References: <9f155606df@enews2.newsguy.com> Message-ID: On Wed, 30 May 2001 22:42:59 GMT, "Nick Perkins" wrote: >What about a user using a built-in sqrt(x) function, who supplies a rational >argument? Will the naive user be aware that the result is not rational? Or >would that function actually return a rational which is close to the anser? Now *that* is a real issue. Using R for rationals, and F for floats (to avoid grief from either side of the default type argument :-)), we have sqrt(0.25F) = 0.5F, which is reasonable and acceptable. But having sqrt(0.25R) = 0.5F is worrying, and an easy way of introducing "scary" floats into "nice, simple" rational calculations. On the other hand, having sqrt(0.25R) = 0.5R begs the question of what sqrt(2R) should be... (The type of the result depends on the value of the argument? I hope not.) The risk is that we trade one can of worms for another. I'm all in favour of having exact types (and my preference strays to making the unadorned form of literals denote those exact types, FWIW) - however, there are still areas of the language where there is no exact answer - and these areas can't avoid being "scary". OK, so there is the argument that things like sqrt() are in the math module, and the documentation for that module could start with warnings about floating point issues. But there's still the case of 2R**0.5R... there's-always-something-irrational-even-if-it's-only-my-prejudices-ly y'rs Paul. From rnd at onego.ru Sat Jun 16 17:34:32 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 17 Jun 2001 01:34:32 +0400 (MSD) Subject: in statement and namespace type ideas In-Reply-To: <6957F6A694B49A4096F7CFD0D900042F27DB78@admin56.narex.com> Message-ID: On Sat, 16 Jun 2001, Bjorn Pettersen wrote: >> From: Roman Suzi [mailto:rnd at onego.ru] >> >> Hello, >> >> right now namespace handling in Python uses dicts, >> however, docs say it could change. >> >> I can't be sure that my code which uses globals() to merge, >> for example, >> cgi-form variables with globals namespace will work with future Python > >I think this is a Perl'ism which we shouldn't repeat here (it only works >if the cgi vars are valid Python vars, otherwise it will blow up rather >ungracefully). I do not want it to be automatic. I just want to avoid things like this: add_here(globals(), ["action", "name",...]) because it repeats too often in cgi scripts. (I simplified my example. In reality I have defaults parameters and sanitize function hooks). The other aplication is storing or communicating names (by pickling or other means). Again, name = p['name'] action = p['action'] ... or: name = p.name action = p.action ... look ugly, add noise. Just imaging if one needed these to import names from the module instead of just from module import a, b, c or even with "as". >> versions. There are other examples where I need to transfer some >> variables from one namespace to another. Dict is good type >> for namespace, >> but maybe it's time to propose new mapping type - namespace - >> to do things I described? >> >> I also thought about absent "with" operator and how it could be used >> in Python. Maybe it is beneficial to have "with" syntax like in the >> followin example: > >[snip example] > >> Are these ideas worth serious consideration? > >Perhaps, although I didn't find anything particularly compelling in your >argument. Moving values from one namespace to another is easily handled >by return values and assignment -- or if you're returning a large number >of variables, by wrapping them in an object or a dictionary. > >The "with" keyword leads to a lot of implied context (especially when >nested). While it may make code easier to write for a "lazy" programmer, >readability and maintainability suffers. I think "explicit is better >than implicit" is the better alternative here. The main application for the things proposed is for small scripts, like CGI-scripts, embedded things, database works, and such, where there are some flows of names which need merging, reorginizing, etc by some more automated means than just lots of assignments. some kind of: from DICT import "name" as "username", "action" ... or just: from DICT import * Maybe module-like object could help here? >-- bjorn Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Saturday, June 16, 2001 _/ Powered by Linux RedHat 6.2 _/ From chat at linuxsupreme.homeip.net Fri Jun 22 16:37:49 2001 From: chat at linuxsupreme.homeip.net (Chad Everett) Date: 22 Jun 2001 15:37:49 -0500 Subject: Numeric 20.0.0 and 19.0.0 crash Python 2.1 References: Message-ID: SuSE 7.1 Linux version 2.4.3-pre6 (gcc version 2.95.2 19991024 (release)) #1 SMP Wed Mar 21 17:18:55 MST 2001 I just installed Numeric-20.0.0 in my Python 2.1 (#1, Apr 18 2001, 12:17:25) and it is smooth. My python 2.1 was just configured and built with: ./configure --prefix=/opt/Python-2.1 On Fri, 22 Jun 2001 19:16:31 +0200 (MET DST), Daniel Reuter wrote: >Hello there, > >When I do the following: >import Numeric >Python 2.1 crashes with a segmentation fault. >This is on a Debian/GNU Linux system, Python is configured --with-pymalloc >--with-cxx=g++ --with-cycle-gc --enable-threads >However Python 2.1 itself compiled perfectly, make test worked well >(except for the two unicode modules, but that's not much of a problem), so >I suspect a problem with Numeric, however as far as I can remember, I >already had Numeric 19.0.0 running with Python 2.0. >Anybody experiencing the same? Solutions? > >Regards, >Daniel > > > > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From offer at sgi.com Fri Jun 1 12:27:08 2001 From: offer at sgi.com (Nhi Vanye) Date: 1 Jun 2001 16:27:08 GMT Subject: Python equivilent to dlopen/dlsym ? Message-ID: <9f8fos$cuh4d$1@fido.engr.sgi.com> What would be the python equivilent of dlopen()/dlsym(). I'm trying to prototype some C code that will use dlopen to open a shared library and ldsym() to call a particular function in it. The python file that implements the functions is listed in a runtime configuration file. Because the configuration file will list multiple python modules that each have the same function defined (I'll will chain them when I call them) I don't want to pollute the name spaces. Any clues ? richard. -- Richard Offer Technical Lead, Trust Technology. "Specialization is for insects" __________________________________________http://reality.sgi.com/offer/ From paulp at ActiveState.com Mon Jun 18 01:25:53 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sun, 17 Jun 2001 22:25:53 -0700 Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? References: <3B2B60AD.942719AE@earthlink.net> Message-ID: <3B2D90E1.E75F9686@ActiveState.com> bradclark1 wrote: > >... > > Am I missing something here? From what I read at the above it > says for .net. > I didn't see anything else about it? Visual Python: [1] http://aspn.activestate.com/ASPN/Downloads/VisualPython/ Visual Python is an IDE plug-in for Visual Studio.NET. Visual Studio.NET is an IDE from Microsoft that has the four letters .NET at the end to convince you that it is sufficiently different from Visual Studio 7 that you should buy it. You can develop .NET applications with Visual Studio .NET but you can also develop old fashioned Windows applications or raw text files. Or, thanks to Visual Python, Python programs. Those Python programs are exactly the same as those you would create with Komodo, or PythonWin, or IDLE. It is just a Python development environment embedded in Visual Studio. If you want, you could copy the scripts to Unix and use them there. There is nothing .NET about them. Python for .NET: [2] http://aspn.activestate.com/ASPN/NET/ Python.NET is an experimental *re-implementation* of Python for the .NET framework. It allows Python programs to be first-class .NET citizens alongside C#, C++ and Visual Basic. You could use Visual Studio.NET to create Python.NET programs but you could also use notepad or IDLE or anything else that can edit Python programs. It's just a new interpreter for Python programs. It isn't tied to any development environment. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From m.bless at gmx.de Tue Jun 19 18:40:53 2001 From: m.bless at gmx.de (Martin Bless) Date: Tue, 19 Jun 2001 22:40:53 GMT Subject: calldll: given a longint (=pointer) - howdoi access the data? Message-ID: <3b30d4f2.21236779@news.muenster.de> The code below is a complete and working example (victory!!! I'm making progress!!!) of how to call the german "KlickTel" cdrom (all german telephone numbers and addresses) from Python using calldll.pyd and windll.py (To be able to do this you additionally have to buy and own the necessary ktdev32.dll, which is 499,-DM :-( *** One problem: The dll calls the callback function with a pointer to a 860-byte data structure. *** How do I turn this longint (being a pointer) into a Python data structure (let's say string)? In other words, I need the opposite of what calldll.membuf(860).address() does. How can I do this? Hhm, hope I made my problem clear! Can't wait for someone helping me to make the final little step, now that I've gotten that much far! Martin A few lines may be wrapped: """Trying to call and use ktdev32.dll from Python callKtel.py, mb, 2001-06-19 """ import windll, gencb #KtelDLLRec = calldll.membuf(860) def callback( PKtelDLLRec): print "Hi, here's the callback function!" print "PKtelDLLRec:", hex(PKtelDLLRec), PKtelDLLRec return 0 ## Sample output: ## Hi, here's the callback function! ## PKtelDLLRec: 0x63f140 6549824 cb = gencb.generated_callback ('l', callback) kt = windll.module('ktdev32') print "kt:", kt print "Version:", kt.KTVersion() ktPath = windll.cstring(r'd:\ProgrammeC\klickTel\klickTel April 2001',remember=1).address() ktCaption = windll.cstring('ktdev32 called from Python',remember=1).address() result = kt.klickTelInit( ktPath, cb.address, ktCaption) adLastName = windll.cstring('b',remember=1).address() print "SetLastName:", kt.SetLastName( adLastName) adFirstName = windll.cstring('m',remember=1).address() print "SetFirstName:", kt.SetFirstName( adFirstName) adPostcode = windll.cstring('4',remember=1).address() print "SetPostcode:", kt.SetPostcode( adPostcode) adStreet = windll.cstring('v',remember=1).address() print "SetStreet:", kt.SetStreet( adStreet) adTown = windll.cstring('m',remember=1).address() print "SetTown:", kt.SetTown( adTown) result = kt.SearchAssistant() input = 'x' while not input: print "result:", result input = raw_input() print "klickTelDone:", kt.klickTelDone() print "unload:", kt.unload() From mwright at pro-ns.net Fri Jun 1 11:54:38 2001 From: mwright at pro-ns.net (Mark Wright) Date: 1 Jun 2001 08:54:38 -0700 Subject: How do I return binary data from a python CGI called from CGIHTTPServer? Message-ID: I'm trying to return a zip file from from a python CGI script being called by CGIHTTPServer on Windows2000 and I'm not having much luck. My CGI-script creates the zip file in a temporary directory and then returns it to the client like this: out_file = sys.stdout ... indata = open(filename, 'rb').read() out_file.write('Content-type=application/octet-stream\n\n') out_file.write(indata) This just creates a mess on the browser screen - I am assuming because of CRLF conversion issues. Is there a way to do this? I have the same problem with 'application/zip'. Mark From dsh8290 at rit.edu Mon Jun 11 16:27:32 2001 From: dsh8290 at rit.edu (D-Man) Date: Mon, 11 Jun 2001 16:27:32 -0400 Subject: Newbie In-Reply-To: <20010611151900.11318.00004174@ng-mp1.aol.com>; from justsurfn2004@aol.com on Mon, Jun 11, 2001 at 07:19:00PM +0000 References: <20010611151900.11318.00004174@ng-mp1.aol.com> Message-ID: <20010611162732.A23938@harmony.cs.rit.edu> On Mon, Jun 11, 2001 at 07:19:00PM +0000, Justsurfn2004 wrote: | Hello, im a newbie to all this programming stuff and i just downloaded python | and i want to know how to use it. Can anyone reccommend any websites for me to | go to on how to use it? My email address is pcgamesrule at hotmail.com | Thanks Alan Gauld's tutorial : http://www.crosswinds.net/~agauld Also try the tutor list : tutor at python.org (subscribe on the python.org website like you did for this list) HTH, -D From phd at phd.fep.ru Sun Jun 17 05:23:48 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Sun, 17 Jun 2001 13:23:48 +0400 (MSD) Subject: Any other Python flaws? In-Reply-To: <3B2BCBAD.E278E78A@bioreason.com> Message-ID: On Sat, 16 Jun 2001, Mitch Chapman wrote: > > while not self._cancel: > > do_more_computation() > > Yep, this is a common approach. See Xt work procedures, > Gtk+ idle tasks, or even guides to programming in Oberon. > Unfortunately, this method doesn't work very well when your > background thread needs to do blocking operations, e.g. reading > from a socket. But you cannot safely interrupt such a blocking thread because: 1. It is VERY OS-dependent, and 2. Even on an OS that allows killing blocked threads you are guaranteed to have problems due to insufficient cleanup. If you need to kill blocking process make it real forked process. Or use non-blocking approach (non-blocking sockets, e.g.) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From skip at pobox.com Thu Jun 21 08:31:49 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 21 Jun 2001 07:31:49 -0500 Subject: String --> int In-Reply-To: <9gsl08$gsl$1@wanadoo.fr> References: <9gsl08$gsl$1@wanadoo.fr> Message-ID: <15153.59701.559092.484026@beluga.mojam.com> Romain> Assuming fsock is a File objet, when I do: Romain> var = fsock.read(4) Romain> I get a String. I'd like to convert it into an integer. Check out the struct module. From rdsteph at earthlink.net Sun Jun 10 21:47:07 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Mon, 11 Jun 2001 01:47:07 GMT Subject: Libraries implementation in C or in Python? Evolution of Python, Jython... Message-ID: <3B22D3FE.9FDA579A@earthlink.net> Are Python's libraries generally written in C or in Python, and why? Someone commented on another thread that the re.search() function ran faster in its 1.5.2 version than in its 2.1 version, because in 1.5.2 it was implemented in C and in 2.1 it was implemented in Python. It was suggested to instead use the "pre" module, but I see it is old and may become obsolete? I am curious as to the reasoning behind why these kinds of changes and decisions are made? In general, as Python evolves from version to version, is Python code likely to get slightly faster in execution time, or slightly slower? Mind you, I am a Pythonista because of the numerous other beauties of the language, not because of any speed issues; and I can certainly see why Python should be and is optimized for other criteria, not speed, and if this sometimes means a little step backwards in speed of code execution then so be it. But I am just curious about the trade-offs, and why such decisions are made. There have been a few threads about 2.x versions of Python being a little slower, in terms of the execution speed of similar code, than 1.5.2. Is this speed decrement likely to be permanent? Can anyone comment on this? I hesitate to ask any of this, because my extreme state of newbieness and lack of knowledge do not give me any right to even speak up and ask such questions. I only rush in where I should fear to tread because the tangible beauty of the evolutionary process of a work of art such as the Python programming language excites my curiosity and sense of wonder. And then there is Jython. Is Python the mother and Java the father, or is it the other way around? Does anyone else see the evolution of Python, Jython and future offspring as a living work of art? Ron Stephens "...And from the heights of Mount Olympus, the mighty Patriarch C looks on with pride as His progeny mutate under the new arts of cryo-genetic surgery, His chromosomes are mixed-in, multiply inherited, and ultimately transcended..." quoted from the Ars Cryogenia, Class Phylogeny, opus five. From not.this at seebelow.org Sat Jun 30 22:51:58 2001 From: not.this at seebelow.org (Grant Griffin) Date: Sat, 30 Jun 2001 21:51:58 -0500 Subject: PEP 260: simplify xrange() References: Message-ID: <3B3E904E.B5ECFFDB@seebelow.org> Robin Becker wrote: > > In article , Guido van > Rossum writes > >Here's another sweet and short PEP. What do folks think? Is > >xrange()'s complexity really worth having? > > > ... > yes, if it works now and has been used, put in some tests to ensure it > doesn't break in the future and leave alone. Needless minimalism is as > bad as excessive maximalism. Or, as a wise man once said: Carry only moderation to extremes. wise-man-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From dnew at san.rr.com Fri Jun 1 13:22:33 2001 From: dnew at san.rr.com (Darren New) Date: Fri, 01 Jun 2001 17:22:33 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> Message-ID: <3B17CF5A.91A415F9@san.rr.com> Alex Martelli wrote: > it started with just the idea of defining randomness in > terms of minimal amount of information (in bits) you need > for prediction. If YOUR definition of 'randomness' is > something that needs INFINITE number of bits to predict, > go ahead and have fun, but you're unlikely to get some > constructive results out of it. Actually, there's apparently two common "randomness" words that mean different things. Chaitin is talking about finite-length random numbers. These are "random" if you can't compress them, very basically. Others talking about random talk about random processes, which is unbounded in output length. Random numbers are numbers from a random process. A number isn't random in and of itself, but rather random if it comes from a random process. In this sense of "random", you don't use bits at all to determine if the number is random. You inspect the source. People doing crypto would never call a finite string "random", for example, but only a finite piece of a random string. :-) -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. This is top-quality raw fish, the Rolls-Rice of Sushi! From ullrich at math.okstate.edu Wed Jun 6 11:15:48 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Wed, 06 Jun 2001 15:15:48 GMT Subject: random References: <3b1cf00f.5441109@nntp.sprynet.com> Message-ID: <3b1e43f4.1661099@nntp.sprynet.com> On 5 Jun 2001 16:54:34 GMT, urpala at ampeeri.ee.tut.fi (Uoti Urpala) wrote: >In article <3b1cf00f.5441109 at nntp.sprynet.com>, David C. Ullrich wrote: >>Indeed the exact value of Omega depends on the details of the >>encodings. What I'm wondering today is how many of his conclusions >>also depend on the details of the encoding. > >>Suppose I have a syntax where a valid program is precisely >>a sequence of 0's terminated by a 1. Any such string is a >>valid program. Does this count as "self-delimiting"? > >That probably does count as self-delimiting, but it doesn't fill other >requirements of the results. The encoding must allow "arbitrary binary >data" to be included. I didn't bother mentioning the semantics before getting straight whether the syntax counted as "self-delimiting". It is very easy to design a Turing-complete programming language where the syntactically valid programs are exactly the bitstrings consisting of all 0's terminated by a 1. Assunming that "arbitrary binary data" means only finitely much binary data that's no problem. (It's not going to be an easy programming language to read or write but a syntax checker is easy...) >The proof basically says "you need n bits of >program to calculate n bits of Omega". This is a strong result if the >encoding is efficient, but the above encoding needs a lot of bits to >calculate anything, so in that case the result doesn't say much about >the associated Omega (and the same proof wouldn't work, since it >depends on the ability to give an arbitrary program as an argument to >another with limited overhead). What I'm trying to track down is what does make the proof work. In particular what I'm curious about is whether the requirments that make the proof of the randomness work are really all that natural, or whether they were just chosen to make the randomness come out right in the end... I can easily give an argitrary program to another in the silly 0000....1 syntax, but not with limited overhead. (I think.) Looking through more of Chaitin yesterday it seemed like the bit about how H((X,Y)) <= H(X) + H(Y) + O(1) was probably kind of important (the complexity of a program generating the concatentation of two lists is bounded by the sum of the complexities, more or less.) I should probably either just give up on extracting an understanding of this or give up and dive into the actual stuff, as has been suggested. Not really motivated enough to learn LISP - also I don't care much about results that are valid for one particular LISP encoding. You know a place to start that's going to be proving things based on _assumptions_ about an arbitrary encoding (as opposed to proving things about a specific encoding, where one then has to dig in and figure out what aspects of the encoding are relevant)? >Proving the randomness of Omega basically works like this: >You can create a program that, given the first n bits of Omega, solves >the halting problem for all programs of size <= n. (Details below) >If you can calculate the first m bits of Omega with a program of size >p, you can add a bit of extra code to create a program of size p+e (e >constant) that solves the halting problem for itself and then does the >opposite (the standard contradiction for a program solving the halting >problem for itself). So p+e must be greater than m to avoid a >contradiction, and a program to calculate the first m bits of Omega >must have size at least m-e. (You can generalize this to calculating >_any_ bits of Omega in whatever position - if you can calculate some >with a short program, you can hardcode the missing ones to get a full >initial segment). > >Solving the halting problem for a program P of size s given the first >s bits of Omega: >Calculate lower bounds for Omega (as mentioned in other posts) until >the first s bits agree with the known bits. Now you have either found >that program P halts, or you know that it halting would raise the >lower bound so much that it could no longer match the known bits, so P >cannot halt. > >Exercise: Show that the first bit of Omega whose value is independent >of ZFC is a 0. Obvious nonsense. No wait, not nonsense. Trivial. No, there's a little error there... Is there a due date? >Uoti Urpala David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From mal at lemburg.com Wed Jun 20 04:51:49 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Wed, 20 Jun 2001 10:51:49 +0200 Subject: ANN: Introducing PLY-1.0 (Python Lex-Yacc) References: Message-ID: <3B306425.1BA938BE@lemburg.com> David Beazley wrote: > > June 18, 2001 > > Announcing : PLY-1.0 (Python Lex-Yacc) > > http://systems.cs.uchicago.edu/ply > > Just when you thought it was safe, I'm pleased to announce the availability > of an entirely new Python parser construction tool. > > PLY is a 100% Python implementation of the common parsing tools lex > and yacc. Although several other parsing tools are available for > Python, there are several reasons why you might want to consider PLY: > ... > - Like John Aycock's excellent SPARK toolkit, PLY uses Python > reflection to build lexers and parsers. This greatly simplifies > the task of parser construction since it reduces the number of files > and eliminates the need to run a separate lex/yacc tool before > running your program. Just a suggestion: PLY seems to use the same logic for attaching grammar snippets to functions as SPARK does. IMHO, this is bad design since doc-strings should really only be used for documentation and not include vital information for the program logic. Note that in Python 2.1 we have function attributes which were added for exactly this reason, so the doc-string approach is not really needed anymore. I'd suggest to move to these for one of the next releases. > ... > More information about PLY can be obtained on the PLY webpage at: > > http://systems.cs.uchicago.edu/ply > Great package ! Just trying to get rid off doc-string overloading, -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From alan at alangarrison.com Tue Jun 12 13:27:51 2001 From: alan at alangarrison.com (Alan Garrison) Date: Tue, 12 Jun 2001 12:27:51 -0500 Subject: Mandrake 8, where is IDLE? Message-ID: <20010612122751.A3076@alangarrison.com> Hi, I installed Mandrake 8 (off CD 1 only) on my workstation. Python itself is installed (2.0-9), but no IDLE. I can't find any IDLE rpm files on the rpmfind sites. Python.org seems to say that IDLE is now a part of the python dist. Did IDLE not make it into Mandrake 8, or is it on CD 2? Thanks. -- alan at alangarrison dot com "Have I mentioned I'm immense and immortal?" - Joel R. From jmarshal at mathworks.com Thu Jun 7 08:20:44 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 7 Jun 2001 12:20:44 GMT Subject: the definition of "strong" (was Re: Why isn't Python king of the hill?) References: Message-ID: <9fnris$mea$1@news.mathworks.com> Steven Haryanto wrote: > Sorry for bringing back an oldish post, but how does one define > "strong typing" and "weak typing" vs "static typing" and "dynamic > typing"? I've always thought that Python has _strong_ typing, > but it is not static. Right. > So it is unlike Perl which has weak and dynamic typing (although > under -w Perl will issue warnings if you try to mix string and > numeric in expressions). I don't know Perl well, but I think I'd say it also has strong typing. There is some automatic conversion between strings and numbers, but this doesn't violate strong typing. C, on the other hand, is weakly typed--you can create an instance of one type then cast it and interpret the same bits in a totally different way. From pete at visionart.com Tue Jun 5 20:59:27 2001 From: pete at visionart.com (Pete Shinners) Date: Tue, 5 Jun 2001 17:59:27 -0700 Subject: Interesting speed benchmark References: <3B1D6FED.4070506@nospam.yahoo.com> Message-ID: <9fjuhh$ghu$1@news.unitel.co.kr> "Mahesh Padmanabhan" wrote > in which the author does some (by his own admission) subjective > benchmarks between java and python. While most of it is usual > stuff, the one test that stood out was the following: > > Python program: > --------------- > > class ObjectTest: > pass > > for i in xrange(1000): > root=ObjectTest() > for j in xrange(10000): > root.next=ObjectTest() > root=root.next i did some fiddling with your program. first i just put a "pass" on the inner loop to see what the loop overhead was. on my system it turned out the looping takes about 10% of the runtime. then i did a little fiddling to see what we could do. i wrapped the code into a small function so i could make local variables for xrange and ObjectTest. this shaved about 10% off the runtime. then i changed the inner loop to "root.next=root=ObjectTest()" this dropped another 5% of the runtime out. well thats the best i could do tuning the loop. it looks to me like all the time is spend in the object instancing. to test it ran it using a dictionary instead of an instance, that dropped the total runtime to about 50% of the original. so here's my final code that did run about 50% of your original one. note that it's really the same thing anymore, but it may help lock down where some of the bottlenecks are. it's still a whole lot slower than the java version :[ def fulltest(): X = xrange for i in xrange(1000): root = {} for j in X(500): root{'next'} = root = {} From ngps at madcap.dyndns.org Sat Jun 9 10:56:05 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 9 Jun 2001 14:56:05 GMT Subject: [Announce] pgnotify 0.1 Message-ID: <9ftde5$5ea$1@coco.singnet.com.sg> Hello, I am pleased to announce the release of pgnotify 0.1. pgnotify is a PostgreSQL client-side asynchronous notification handler for Python. Typically, asynchronous notification is used to communicate the message "I changed this table, take a look at it to see what's new" from one PostgreSQL client to other interested PostgreSQL clients. pgnotify is developed on this platform: - FreeBSD 4.0 - Python 2.1 - PostgreSQL 7.1.1 - PyGreSQL 3.2 At present, pgnotify works with PyGreSQL only. It should work with PoPy and psycopg when those modules provide Pythonic interfaces to additional necessary PostgreSQL client-side functions, as described in the README. Get pgnotify here: http://www.post1.com/home/ngps/pgnotify As usual, feedback is welcome. -- Ng Pheng Siong * http://www.post1.com/home/ngps Quidquid latine dictum sit, altum viditur. From max at alcyone.com Wed Jun 6 11:16:33 2001 From: max at alcyone.com (Erik Max Francis) Date: Wed, 06 Jun 2001 08:16:33 -0700 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3b1cdc84.5514@bolder.com.co.za> <9fleid$3rp$1@oslo-nntp.eunet.no> Message-ID: <3B1E4951.7F36D4E4@alcyone.com> Thomas Hansen wrote: > But fact is : For some peculiar meaning of "fact." > -If you have a computer and you play games, you probably (80% or > something) have bought it as a "package" from some kind of > hoover-salesman... > -If you buy from a hoover-salesman you WILL have windows installed > default... > -If you play alot of games, you're probably having a lot of spare > time. > -If you have alot of spare time you probably don't know much > computer. Either that or you like playing games. Competent computers users and programmers play games too, you know. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Experience is the name everyone gives to their mistakes. \__/ Oscar Wilde The laws list / http://www.alcyone.com/max/physics/laws/ Laws, rules, principles, effects, paradoxes, etc. in physics. From paulp at ActiveState.com Sat Jun 30 23:55:35 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sat, 30 Jun 2001 20:55:35 -0700 Subject: Augmented Assignement (was: Re: PEP scepticism) References: Message-ID: <3B3E9F37.613E479E@ActiveState.com> Tim Peters wrote: > >... > > OTOH, if you're slinging mega-element conformable arrays x and y, > > x += y > > is much more efficient than > > x = x + y # creates a giant temp array > > and much clearer than > > x.add_in_place(y) It is much clearer in isolation but not when placed in the context of the rest of the language. It has different behavior than "x = x + y" which is what most people will think x += y means. Someone even posted on this thread: "I don't understand what's so complicated x+=y is the same as x = x + y". >... > > As usual in this debate, the participants aren't *themselves* confused about > it, they're worried about people much feebler than they are. In this > particular case, don't be so sure that isn't an empty set . I only became skeptical of augmented assignment when I actually ran into someone who was confused (other than the participant in this thread!). -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From jh at web.de Tue Jun 19 13:24:31 2001 From: jh at web.de (Jürgen Hermann) Date: Tue, 19 Jun 2001 19:24:31 +0200 Subject: Extracting words from a string : *fast* References: <0UEX6.268$8H6.170349568@news.telia.no> Message-ID: <9go1sg$gr9$02$1@news.t-online.com> "Thomas Weholt" schrieb im Newsbeitrag news:0UEX6.268$8H6.170349568 at news.telia.no... > I need to extract words from a string. This method will be used extensivly > in a indexer so it needs to be as fast as possible. Then you should use re.split() From Gareth.McCaughan at pobox.com Mon Jun 4 18:32:41 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Mon, 4 Jun 2001 23:32:41 +0100 Subject: infinite precision (was Re: Against PEP 240) References: <9f0fc80280a@enews2.newsguy.com> <9f3sa5$45p$1@panix6.panix.com> <9f51p601lqg@enews2.newsguy.com> <9f5fpf$qo9$1@panix2.panix.com> <9f5lrt026g6@enews2.newsguy.com> Message-ID: Alex Martelli wrote: > > >>>provide infinite-precision INTEGRAL arithmetic, what Roman was asking, > > >> > > >> C'mon, Alex, you know better than that: longs are unbounded precision, > > >> not infinite precision. > > > > > >http://www.dictionary.com/cgi-bin/dict.pl?term=infinite: > > > > The dictionary definitions don't represent the standard distinctions > > used in CS. > > Can you back up this bold assertion with quotes supporting > your contention that (if I get you right?) "infinite precision" > means nothing attainable on a (necessarily finite) computer > while "unbounded precision" means something attainable? I > have quite a few counter-examples, such as: [SNIP quite a few counter-examples] For what it's worth, in mathematicians' usage there is definitely a big difference between "infinite" and "unbounded". I conjecture, without good evidence, that the same is true in computer science apart from ... the very specific phrase "infinite precision". :-) -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From phrxy at csv.warwick.ac.uk Tue Jun 12 16:59:46 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Tue, 12 Jun 2001 21:59:46 +0100 Subject: WHY is python slow? In-Reply-To: <9g5j3p$ird$3@216.39.170.247> References: <9g5j3p$ird$3@216.39.170.247> Message-ID: On 12 Jun 2001, David LeBlanc wrote: > In article , > tim.one at home.com says... > > > C++ adds nothing to C that can't be done just as well with > > preprocessor macros, > > > there's-no-accounting-for-mass-delusion-ly y'rs - tim [...] > Aside from massive code bloat and agonizingly slow compiles, there are > just some things in C++ that cannot be expressed using the C > preprocesser. I think you missed the flashing 'sarcasm' sign. John From qrczak at knm.org.pl Sun Jun 3 03:38:58 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 3 Jun 2001 07:38:58 GMT Subject: I had a thought ... (I know, call the newspapers). References: <3B172894.9B64F46F@my.signature> Message-ID: Sat, 2 Jun 2001 15:29:37 -0500, Clark C . Evans pisze: > Why not... > > my = USD$0.02 > my = EUR$0.0235877 > my = JPY$2.38420 This is exactly how Rebol spells it. (But I don't see the need of such type in the core language.) -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From m.hadfield at niwa.cri.nz Wed Jun 13 17:06:22 2001 From: m.hadfield at niwa.cri.nz (Mark Hadfield) Date: Wed, 13 Jun 2001 21:06:22 +0000 (UTC) Subject: IDL and NetCDF References: <002c01c0f44b$babf7d10$d938a8c0@Hadfield> Message-ID: <004401c0f44c$b248c820$d938a8c0@Hadfield> Er, wrong group. Sorry about that. What's odd is that I sent it comp.lang.idl-pvwave at mailgate.org as I intended (I checked the copy in my Sent Items folder), but it seems to have gone to comp.lang.python --- Mark Hadfield m.hadfield at niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield National Institute for Water and Atmospheric Research -- Posted from clam.niwa.cri.nz [202.36.29.1] via Mailgate.ORG Server - http://www.Mailgate.ORG From graham at coms.com Mon Jun 25 03:34:39 2001 From: graham at coms.com (Graham Ashton) Date: Mon, 25 Jun 2001 08:34:39 +0100 Subject: Alternative location of mx extensions? Message-ID: I'm trying to get hold of the mxDateTime package from www.lemburg.com but it appears to be down. All packets that I've sent to the host for the last couple of days have been dropped. Does anybody know if there's a mirror, or where I could grab the original source from? Thanks. -- Graham From pecora at anvil.nrl.navy.mil Fri Jun 8 08:23:44 2001 From: pecora at anvil.nrl.navy.mil (Louis M. Pecora) Date: Fri, 08 Jun 2001 12:23:44 GMT Subject: How do you develop in Python? References: <050620011516094693%pecora@anvil.nrl.navy.mil> <9fjfer$gt0$1@nereid.worldonline.nl> Message-ID: <080620010825546562%pecora@anvil.nrl.navy.mil> [[ This message was both posted and mailed: see the "To," "Cc," and "Newsgroups" headers for details. ]] In article <9fjfer$gt0$1 at nereid.worldonline.nl>, Gerrit Muller wrote: > "Lou Pecora" schreef in bericht > news:050620011516094693%pecora at anvil.nrl.navy.mil... > > I program in Python occassionally and would like to do more of it. But > > here's a development conundrum I run into a lot (there are more complex > > examples, but I'll give an easy one). I am developing module A.py > > which imports B.py in the IDE. I am running test code which is also in > > A.py as I incrementally develop A.py. Then I need to change B.py and, > > of course, the import does not import the new changes since import only > > works once. Hence, to "refresh" B.py I have to quit the IDE and > > restart, open A.py and run. This is clumsy. However, the above > > scenario is not uncommon and more complex interdependencies of modules > > appear to make it unavoidable. Anyone know a way to get around this > > "import" problem? I know there is a "reload", but then I have to > > import and change my modules' code to "reload" or something each time I > > work with them. Any help appreciated. > > > > I use Python on a Macintosh. Nice IDE, otherwise. > > I certainly recognize your problem. Occasionaly I have used reload() to > "solve" this behavior. However for more "naive" programmers (CP4E-like) this > behavior can give many unexpected results. I do recognize the power of the > current dynamic loader behavior, but I think that a more "cold" runscript > command in IDLE, which imports/reloads anything again (and maybe clears the > rest of the environment as well) would make IDLE even more accessible for > this type of programmers. > > Regards Gerrit Good point. I agree. From aahz at panix.com Fri Jun 1 12:58:13 2001 From: aahz at panix.com (Aahz Maruch) Date: 1 Jun 2001 09:58:13 -0700 Subject: infinite precision (was Re: Against PEP 240) References: <9f51p601lqg@enews2.newsguy.com> <9f5fpf$qo9$1@panix2.panix.com> <9f5lrt026g6@enews2.newsguy.com> Message-ID: <9f8hj5$3f5$1@panix3.panix.com> [posted & e-mailed] First of all, let me apologize. My original comment was intended to be teasing, and I'm sorry this has descended into heavy-handedness. In article <9f5lrt026g6 at enews2.newsguy.com>, Alex Martelli wrote: >Aahz: >> >> The dictionary definitions don't represent the standard distinctions >> used in CS. > >Can you back up this bold assertion with quotes supporting >your contention that (if I get you right?) "infinite precision" >means nothing attainable on a (necessarily finite) computer >while "unbounded precision" means something attainable? I >have quite a few counter-examples, such as: > > [snippety-doo-dah] Well, I guess you're right. It's not what I was taught in my CS program, but I can't argue with the weight of publications you found. It still doesn't feel right to me, though. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Characters exist to suffer, you know. An author needs a little sadism in her makeup." --Brenda Clough From wtanksle at dolphin.openprojects.net Thu Jun 7 17:28:35 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Thu, 07 Jun 2001 21:28:35 GMT Subject: random References: <3b1cf00f.5441109@nntp.sprynet.com> <3b1e4957.3040319@nntp.sprynet.com> <3b1f9604.4075981@nntp.sprynet.com> Message-ID: On Thu, 07 Jun 2001 15:02:33 GMT, David C. Ullrich wrote: >(William Tanksley) wrote: >>On Wed, 06 Jun 2001 15:19:36 GMT, David C. Ullrich wrote: >>>(William Tanksley) wrote: >>>>On Tue, 05 Jun 2001 15:09:25 GMT, David C. Ullrich wrote: >>>>>But this question is not meant to be rhetorical: We have a syntax where >>>>>the valid programs are exactly finite sequences of 0's terminated by a 1. >>>>>Does this count as "self-delimiting"? >>Hmm... I'm pretty sure that programs for an UTM could be infinite length; >>however, let's suppose that for the purposes of omega they couldn't be >>(IMO a reasonable supposition). Then my proof is clearly invalid. This turns out to be a reasonable assumption; I've done some research, and sure enough, TM programs are "defined" to be countable (it's actually an unavoidable result). >>However, your machine still isn't a UTM, because in order to process an >>indefinite number of possible programs it has to have an indefinite number >>of states. It has to be able to count up to little-omega (otherwise it >>won't know what program it's executing), but the only way to do that is >>with an infinite number of states. And an UTM has a finite number of >>states. >??? It seems to follow from statements in this paragraph that a UTM does >not exist. It would require an "indefinite number" of states, but a UTM >has a finite number of states. So there are no UTM's. Huh. It would have been polite of you to continue talking -- either explain how you reached that rather bizzare and obviously unintended conclusion, or go on assuming that I meant something else (if you could figure out what that something else was). Keep in mind that I'm trying to figure this out, too. Bringing ego into it won't help. I think you're questioning why you'd need an infinite number of states to run your 'programs'. The reason is that your programs aren't programs; they're only data. They have to be processed, converted into programs somehow. I'm not certain that this is computable; but if it is, it requires some record of all the programs, since writing programs is definitely not computable. And /that/ is countably infinite. >David C. Ullrich -- -William "Billy" Tanksley From chris at alaska.cert.siemens.de Tue Jun 12 17:07:16 2001 From: chris at alaska.cert.siemens.de (Christian Schaller) Date: 12 Jun 2001 21:07:16 GMT Subject: Python & vim Message-ID: <9g60a4$24t$1@news.mch.sbs.de> Dear Pythoners, I've seen already some threads about configuring vim that it is comfortable editing Python programs, so let's get one step further! Use the following script to be able moving up and down the same indentation level of the line the cursor is on (just press F10 for down and Shift-F10 for up). Have fun! bye Chris... """ fu! Block(indent, dir) let line = getline(".") let blankCount = matchend(line, a:indent) let nr = line(".") let lastPos = nr let maxLine = line("$") while nr <= maxLine && nr > 0 let nr = nr + a:dir let curr = getline(nr) if curr == "" continue endif if matchend(curr, a:indent) == blankCount break elseif matchend(curr, a:indent) < blankCount let nr = lastPos break endif endw exe nr endfu map :call Block("^[ ]*", 1) map :call Block("^[ ]*", -1) """ From eldavo at shell4.ba.best.com Mon Jun 11 17:37:44 2001 From: eldavo at shell4.ba.best.com (David White) Date: Mon, 11 Jun 2001 21:37:44 +0000 (UTC) Subject: Enterprise Python on NT, W2K? Message-ID: <9g3dn8$uan$1@nntp1.ba.best.com> I checked out the page on python.org listing companies deploying python. I'm wondering if anyone knows of any well known enterprise deployments of python on Windows NT or 2000 I could cite. I've developed a python app for a client who's pretty much 100% Microsoft and I want to be able to show them that its safe and reasonable to install python on their servers... thanks, dave white From catunda at pobox.com Mon Jun 18 14:42:46 2001 From: catunda at pobox.com (Marco Catunda) Date: Mon, 18 Jun 2001 15:42:46 -0300 Subject: SMNP Interface(s)? References: Message-ID: <20010618.154246.1351797369.7366@supgr05.uni.embratel.net.br> I am developing a wrapper for net-snmp using swig, if you have interesting i can send to you. regards -- Marco Catunda In article , "Benjamin Schollnick" wrote: > I just checked over at the Vaults & couldn't find any, does anyone know > of any SMNP modules for python? And of course, where to find them? > > - benjamin From DavidLNoSpammy at raqia.com Thu Jun 21 19:50:22 2001 From: DavidLNoSpammy at raqia.com (David Lees) Date: Thu, 21 Jun 2001 19:50:22 -0400 Subject: Installation problem with Win32Comm Message-ID: <3B32883E.29DA9AB4@raqia.com> I must be doing something incorrect with the setup of Win32Comm. I unzipped it and am trying to run the test demo: commtest.py and get the following stack traceback. I am running under NT, with active state Build 210 Python Thanks in advance. David Lees Traceback (most recent call last): File "g:\python21\pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript exec codeObject in __main__.__dict__ File "G:\Python21\Scripts\PythonSerial\commtest.py", line 88, in ? _test_() File "G:\Python21\Scripts\PythonSerial\commtest.py", line 36, in _test_ dcb = win32comm.DCB() AttributeError: 'win32comm' module has no attribute 'DCB' From rnd at onego.ru Tue Jun 26 05:49:06 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 26 Jun 2001 13:49:06 +0400 (MSD) Subject: Adding unknown variables to time.mktime() In-Reply-To: Message-ID: On 26 Jun 2001, Gustaf Liljegren wrote: >I have a problem with time.mktime(): > >>>> t = ('1999', '02', '12', '01', '34', '12', '', '', '-1') >>>> myTime = time.mktime(t) >Traceback (most recent call last): > File "", line 1, in ? > myTime = time.mktime(t) >TypeError: an integer is required > >I have tried integers too, in the touple, but then there's a syntax error, >as you can't have empty fields in the touple like that. Ideally, I'd like >to be able to give only the 6 first values, since I've never heard of >Julian days, and week day is not significant in this case. try with all 9 integers. RTFM time module docs. >Regards, > >Gustaf Liljegren > Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, June 26, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "It is better to be brief than boring." _/ From Attila.Feher at lmf.ericsson.se Fri Jun 8 10:24:55 2001 From: Attila.Feher at lmf.ericsson.se (Attila Feher) Date: Fri, 08 Jun 2001 17:24:55 +0300 Subject: best language for 3D manipulation over web ? References: <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3B1B1825.8109BA83@lmf.ericsson.se> <2v4ohtgldvce84sn87kh1eg1lnes37getq@4ax.com> <3B1C9E65.B73A4FE@lmf.ericsson.se> <3B1DFD87.F3BFDB57@lmf.ericsson.se> <9fpra3$352$1@oslo-nntp.eunet.no> <3B2083A5.15B40637@lmf.ericsson.se> <9fqi1i$dsq$1@oslo-nntp.eunet.no> Message-ID: <3B20E037.D3A98DA9@lmf.ericsson.se> Thomas Hansen wrote: > > "Attila Feher" wrote in message > news:3B2083A5.15B40637 at lmf.ericsson.se... > > Thomas Hansen wrote: > > > > > > > >> Every user should have his/her own registry (and not just a > sub-tree) > > > > > > > > > > TOTALLY agreed. > > > > > > > > See, we can agree to many different things ^__^ > > > > > > > > > > Not possible unless you want to install a billion ActiveX/COM components > x > > > times where x is the number of users on that computer... > > > > Due to bad design... > > > > A > > Might be, but if every user were supposed to have a completely custom > registry, and info about COM servers were supposed to be stuffed in that > registry, it wouldn't be possible to have their own version of the registry > without multiple install of COM servers... I don't think so :-))) _If_ they guy has his own key, that is used. Otherwise the main key is used. That simple - but of course for that the OS has to be real multiuser :-))) A From tim.one at home.com Sun Jun 3 22:43:21 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 3 Jun 2001 22:43:21 -0400 Subject: random In-Reply-To: <3B1AE78E.8FED9B4C@san.rr.com> Message-ID: [Darren New] > how random is the binary string "1001010010011100100"? How > random is the binary string "0000000000000000000"? Such questions > don't make any sense. BTW, you can find attempts to answer such questions in Knuth, Vol 2. The questions not only make sense, but finding non-trivial answers is important in real life: even if you have a theoretically perfect physical RNG, how can you have confidence in a specific real implementation? As you said in another reply, measurement isn't perfect, and I'll add that the person implementing it may have made mistakes, misundertood the theory, or overlooked a source of gross physical interference, or malfunctioning equipment. Before deciding to use it or not, all you can do is sample some finite number of outputs and decide whether or not they're consistent with the hypothesis that the source is truly random. Saying "well, *any* sequence of N bits is equally likely from a truly random source, so they both look random enough to me!" should leave you at least a little uncomfortable, if not downright embarrassed . [Nick Perkins] > They do make sense, according to Chaitin. [back to Darren] > Well, sure, with Chaitin's definition (redefinition?) of the word > "random", that makes sense. But in what sense is Chaitin's "random" > different from "compressible"? Given suitable pages of preliminary definitions, none. > Why does he use a different word when we already have a perfectly > good word for it? "random"? But you know that's used to mean different things by different people. This whole thread is a long demonstration of that <0.5 wink>. At the start of the field, they didn't know that "compressibility" would be a good measure of randomness, but they *suspected* it. It wasn't proved until later, and it turns out that "a random sequence" (according to the compressibility view) passes all computable tests for randomness (according to the view of randomness that falls out of statistical testing). I'm not sure whether that matches your view today, but since computable statistical testing is all I can *do*, if it doesn't match your view I'll never be able to detect the difference. > It sounds wierd to me to say "'Pi' is more random than 'e'." Even > stranger to say "'Pi' is more random than 'e' *because* they are both > algorithmically calculable." Does it sound wierd to say that the decimal digits of pi are more random than the decimal digits of sqrt(2)? Of 1/7? Of 42? Such statements make plain sense to most people on first hearing, although making precise just what that sense consists of isn't so easy. Tossing it aside as meaningless may be convenient but isn't compelling. > But if that's how you want to redefine the word "random" then go > for it.:-) > > This is obviously not the sense of "random" that JVN was talking about. Indeed it was not. In context, JVN's quip was very funny at the time. But most jokes lose their power to tickle after 50,000 words of analysis . From whisper at oz.nospamnet Wed Jun 13 15:05:58 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 13 Jun 2001 19:05:58 GMT Subject: Plugins in Python References: <9g5hvq$ird$2@216.39.170.247> Message-ID: <9g8dim$cir$0@216.39.170.247> [This followup was posted to comp.lang.python and a copy was sent to the cited author.] In article , db3l at fitlinxx.com says... > David LeBlanc writes: > > > How would one generally code something that would look at some dir (or > > list of dirs), and dynamically load .py or .pyc modules found there that > > where not previously known to the program. Obviously following a standard > > API... > > I tend to make plugins for an application a package. > > One approach is that the __init__ file in the package can inspect the > package directory for other modules, and then use __import__ to import > them. I normally then populate a well-known dictionary within the > __init__ module that applications can use to determine what plugins > were loaded. You can also decide to set up the modules for lazy > loading using a proxy class if you want to avoid the overhead of > actually importing the plugin until needed. > > Note that one major negative with this approach is that it confuses > Python installation tools like py2exe and installer, as they can't > follow the dynamic importing, and also because the directory structure > may not be similar during execution. > > So in the cases that I need to package things, I instead write my > __init__ such that it contains explicit imports for supported plugins, > but nothing more. Then instead of looping through the filesystem, I > loop through my local dictionary looking for modules, and then import > them (or call well defined entry points in them to let them identify > what they support). This does mean they all get imported, but it > works regardless of directory structure, and can be packaged. > > -- > -- David > Thanks David! That's exactly what i'm looking for. Python the ever flexible snake! I sort of thought that (dunno why, just didn't occur to me) that import wouldn't take a variable as in: mymodule = "c:/boo/yikes.py" import mymodule I gather that's what you mean? >From what you're telling me, the general idea is (or could be)?: import standardplugin1 import standardplugin2 #etc # Inspect some known directory or set of directories for *.py files plugins = getplugins() # assume "./plugins" # alternative 1 for plug in plugins import plug try plug.registerplugin() # or if not plug.hasmethod("registerplugin") # is this possible? hasattribute()? except unload plug # alternative 2 - this one seems potentially faster or maybe less memory # intensive - does unload really reclaim memory used by the module # unloaded? for plug in plugins if grep("registerplugin" plug) == 1 # or whatever means is # appropriate to check # perhaps arranging a comment # as the first line of the file # would be fastest and simplest # of all - and extra info too! import plug plug.registerplugin() # on with the show... ------------------------- I take your point about the installer issue, and it's something i'd have to live with I guess. I want to be able to dynamically download a new plugin and have the user take no further action then putting it in the plugins directory. This might even be done automagically as part of a dynamic update or install feature and then the user couldn't even get putting it in the right directory wrong ;-) Thanks for the help David and to the other posters too! Regards, David LeBlanc P.S. Tim Delany's idea only works when the list of plugins is known in advance. From new_name at mit.edu Sun Jun 24 13:07:16 2001 From: new_name at mit.edu (Alex) Date: 24 Jun 2001 13:07:16 -0400 Subject: Should "import site" fail if the cwd no longer exists? Message-ID: On RH linux 6.2, if the cwd is removed, and python is started, "import site" fails with an OSError. Perhaps this exception could be caught, instead, as it's quite confusing, otherwise. Alex. Example: athena$ cd /tmp athena$ mkdir test athena$ cd test /tmp/test athena$ rmdir /tmp/test/ athena$ pyth python python1.5 python2.1 athena$ python2.1 -v # /mit/python/arch/i386_linux22/lib/python2.1/site.pyc matches /mit/python/arch/i386_linux22/lib/python2.1/site.py import site # precompiled from /mit/python/arch/i386_linux22/lib/python2.1/site.pyc # /mit/python/arch/i386_linux22/lib/python2.1/os.pyc matches /mit/python/arch/i386_linux22/lib/python2.1/os.py import os # precompiled from /mit/python/arch/i386_linux22/lib/python2.1/os.pyc import posix # builtin # /mit/python/arch/i386_linux22/lib/python2.1/posixpath.pyc matches /mit/python/arch/i386_linux22/lib/python2.1/posixpath.py import posixpath # precompiled from /mit/python/arch/i386_linux22/lib/python2.1/posixpath.pyc # /mit/python/arch/i386_linux22/lib/python2.1/stat.pyc matches /mit/python/arch/i386_linux22/lib/python2.1/stat.py import stat # precompiled from /mit/python/arch/i386_linux22/lib/python2.1/stat.pyc # /mit/python/arch/i386_linux22/lib/python2.1/UserDict.pyc matches /mit/python/arch/i386_linux22/lib/python2.1/UserDict.py import UserDict # precompiled from /mit/python/arch/i386_linux22/lib/python2.1/UserDict.pyc 'import site' failed; traceback: Traceback (most recent call last): File "/mit/python/lib/python2.1/site.py", line 82, in ? dir = makepath(dir) File "/mit/python/lib/python2.1/site.py", line 70, in makepath return os.path.normcase(os.path.abspath(dir)) File "/mit/python/lib/python2.1/posixpath.py", line 380, in abspath path = join(os.getcwd(), path) OSError: [Errno 2] No such file or directory Python 2.1 (#3, Jun 22 2001, 14:35:17) [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2 Type "copyright", "credits" or "license" for more information. From gardner at cardomain.com Tue Jun 12 18:51:33 2001 From: gardner at cardomain.com (Jonathan Gardner) Date: Tue, 12 Jun 2001 15:51:33 -0700 Subject: Review my async socket server (Caution: 5 kB attachment) References: <9fma5s$bcn$1@brokaw.wa.com> <9fonn4$shm$1@brokaw.wa.com> <9g00iu$ktr$1@tyfon.itea.ntnu.no> Message-ID: <9g669b$pab$1@brokaw.wa.com> Magnus Lie Hetland wrote: > "Jonathan Gardner" wrote in message > news:9fonn4$shm$1 at brokaw.wa.com... >> Jonathan Gardner wrote: > [...] >> One thing I was wondering how to do... is there an easy to print >> warnings? In Perl you have warn "Something", but I didn't see anything >> that stuck > out >> in Python. Do you have to print to STDERR in order to do this? > > Have you seen this? > http://www.python.org/doc/current/lib/module-warnings.html > >>>> from warnings import warn >>>> warn('Something') > __main__:1: UserWarning: Something > Now I really need new glasses. Blame my myopia. From bokr at accessone.com Wed Jun 20 14:54:59 2001 From: bokr at accessone.com (Bengt Richter) Date: Wed, 20 Jun 2001 18:54:59 GMT Subject: Two minor syntactic proposals References: Message-ID: <3b30f08b.1008583957@wa.news.verio.net> On Mon, 18 Jun 2001 02:07:54 -0400, barry at digicool.com (Barry A. Warsaw) wrote: > > GM> Suppose you have a class and want to add a new method to > GM> it. (Why? It's someone else's, you aren't allowed to change > GM> the source, and subclassing won't do because these things are > GM> created by code you don't control.) > > GM> You can do it, thus: > > | def new_method(self, x): > | something_else() > | return x+1 > | Thing.new_method = new_method > >Long ago, I propsed being able to do something like > >class Thing: > pass > >def Thing.new_method(self, x): > something_else() > return x+1 > >No new syntax is necessary, and it would allow more separation of >interface and implementation, allowing the /interface/ to be the class >definition, maybe even scarecrow-ish in nature, while the >implementation could be completely separated into a separate file, or >farther down in the same file. > >It never caught on, but this was in the (way) pre-PEP days. If >there's interest, I could write up a PEP on this. I think my enhanced lambda version of def would work in this context too: class Thing: pass Thing.new_method=def(self, x): something_else() return x+1 From sill at optonline.net Fri Jun 1 13:32:43 2001 From: sill at optonline.net (Rainy) Date: Fri, 01 Jun 2001 17:32:43 GMT Subject: Obsolesence of <> References: Message-ID: On Thu, 31 May 2001 19:24:09 -0400, Lulu of the Lotus-Eaters wrote: >> It is very easy to read "<>" as "is less than or greater than" on the >> analogy of ">=" reading "is greater than or equal to." Since all Python >> values can be compared, every two unequal things are indeed less than or > > "Alex Martelli" wrote: >| Sorry, you're behind the times: >| >| Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 >| Type "copyright", "credits" or "license" for more information. >| Alternative ReadLine 1.1 -- Copyright 2001, Chris Gonnerman >| >>> x=2+3j >| >>> y=5+8j >| >>> x| Traceback (most recent call last): >| File "", line 1, in ? >| TypeError: cannot compare complex numbers using <, <=, >, >= >| >| Here, I cannot write x>y, nor x| reasoning, I shouldn't be able to write x<>y either, right?-) > > Yeah. I missed this change. It does reduce the consistency of the > iconography. But I still think that the "<>" spelling looks more > intuitive than the "!=" spelling by way of its nonetheless greater > consistency with the spelling of other operators, as discussed > previously. > > In the end, spelling is arbitrary, of course. But having families of > corresponding spellings for corresponding semantics makes it easier to > remember a language, and to teach it. > > FWIW. I'm not really sure I like the change Alex points to. It makes > something like the below fail: > > l = [(1+1j),(2-2j),Klass(),Klass(),Klass,5,4,3,'c','b','a'] > l.sort() > > In a list like this, many of the comparisons have no particular meaning. > I have no idea whether an instance of Klass is more than a complex > number. And in most cases, I don't even have any idea whether one > instance is meaningfully greater than another. But it is nice to have > everything have some arbitrary inequality relation in order to create > partial orderings on the subsets of things that really do have an order. > It makes perfect sense to me to want the numbers and strings to occur in > order, even while not caring exactly -where- in the sorted list they > occur as a sublist. > > Is l.sort() a special case that avoids the non-comparison, btw? If so, > substitute similar generic comparisons. I don't have 2.1 handy to try > out the example. > > Yours, Lulu... > Could it be that people like <> better because it's easier to type? I personally never used it, but now that I tried it, it is quite a bit easier. -- Delay not, Caesar. Read it instantly. -- Shakespeare, "Julius Caesar" 3,1 Here is a letter, read it at your leisure. -- Shakespeare, "Merchant of Venice" 5,1 [Quoted in "VMS Internals and Data Structures", V4.4, when referring to I/O system services.] From gmcm at hypernet.com Fri Jun 8 12:09:24 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 08 Jun 2001 16:09:24 GMT Subject: Win32 Installer on 2.1? References: <50be6f7c.0105220115.612c9912@posting.google.com> <50be6f7c.0106062352.a6f2670@posting.google.com> <50be6f7c.0106071259.13fcbfc3@posting.google.com> Message-ID: <90BA710B4gmcmhypernetcom@199.171.54.154> Matt Butler wrote: [Benjamin Schollnick guesses Installer 4 works with 2.1] >Thanks for your response, I have actually not had a problem yet with >2.1, it's just that the readme omits 2.1 from the list of >configurations on which Installer has been tested. I'm finally testing with 2.1 (I use *lots* of C extensions in my work, and recompiling for a new release of Python is a royal PITA). So far I've found some minor stuff in doing Windows version resources (which slipped by me in testing Python 2.0, where it also fails). If anyone needs that, drop me a note. Otherwise, I'll keep plugging and roll it into 4a2. - Gordon From junkster at rochester.rr.com Thu Jun 7 06:20:50 2001 From: junkster at rochester.rr.com (Benjamin Schollnick) Date: Thu, 07 Jun 2001 10:20:50 GMT Subject: Win32 Installer on 2.1? References: <50be6f7c.0105220115.612c9912@posting.google.com> <50be6f7c.0106062352.a6f2670@posting.google.com> Message-ID: In article <50be6f7c.0106062352.a6f2670 at posting.google.com>, foo at ix.netcom.com (Matt Butler) wrote: > Is it true that "still" no one has tried to get it working with 2.1 yet??? > > foo at ix.netcom.com (Matt Butler) wrote in message > news:<50be6f7c.0105220115.612c9912 at posting.google.com>... > > The following quote appears in the Announcements for Gordon McMillan's > > Installer, "Version 4 handles all Python versions from 1.5 onward > > (it's been tested with 1.5 and 2.0).". > > > > Has anyone out there actually tested on 2.1? No idea.... I know that I have it working fine under v2.0, and actually have not had a problem with v4 with python v1.52, & v2.0.... But that doesn't exactly answer your question.... I haven't been following the conference too well lately, was there a specific problem you are having with Installer under v2.1? I did have a slight problem with v2.0, but contacted Gordon, and he issued me a test Beta that fixed my problem.... You might want to contact Gordon directly, to see if you are hitting a bug.... - Benjamin From junkster at rochester.rr.com Wed Jun 13 19:17:32 2001 From: junkster at rochester.rr.com (Benjamin Schollnick) Date: Wed, 13 Jun 2001 23:17:32 GMT Subject: Detect DNS Server online.... Message-ID: Folks, I've found the DNS code in the Demo\DNS directory, but it appears to be totally overkill, and certainly a little bit more convulted then I need. Does anyone know where I can find some basic code (it could be as simple as just validating that a particular DNS server is online). - Benjamin PS -> The http://alumni.dgs.monash.edu.au/~anthony/python/ website doesn't appear to be online, anyone know where the "Enhanced" version of the code is currently maintained? From graham at coms.com Tue Jun 19 21:20:36 2001 From: graham at coms.com (Graham Ashton) Date: Wed, 20 Jun 2001 02:20:36 +0100 Subject: Loading select queries into objects References: Message-ID: In article , "Graham Ashton" wrote: > The code printed looks like this: > > apply(self.col1(), (self, dict['col1'])) > > The only problem is that when it's evaluated the self.col1() method > doesn't get passed the value of dict['col1']... Sorry folks - I've just noticed that I shouldn't be passing self explicitly there. It works fine now. Ooops. Graham From aleaxit at yahoo.com Mon Jun 11 10:27:34 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 11 Jun 2001 16:27:34 +0200 Subject: Global in multiple files References: Message-ID: <01b201c0f282$aac918f0$102b2bc1@cadlab.it> "Roman Suzi" writes: ... > >There is a serious risk in over-designing systems "because > >one day it might be handy". Yeah, right, but meanwhile you're > >paying the price of complexity *RIGHT NOW*!-) > > I always try to choose more flexible way as long as > it doesn't add to complexity. When it is style of If it adds NO complexity, why, sure. It just doesn't work that way _most often_, though. The natural temptation of the battle-scarred designer is to overdesign "just in case" -- because the hundred times where simple design had to be extended later apparently burn themselves in our neural circuits more than the thousand times where rich and complex design just didn't pull its weight and never really provided any added value. > >"Do the simplest thing that could possibly work", because > >"you ain't gonna need it" (where "it" is the rich, complex, > >over-engineered, over-designed very general solution:-). > > That is why Microsoft systems still have those funny > A:, B:, C: letters before file paths ;-) Nope, this has absolutely nothing to do with it. Backwards compatibility with externally-visible interfaces to previous releases of your software (and older software you choose to be similar/compatible to: CP/M, in Microsoft's case) are (as should be obvious -- I'm amazed I have to point this out) a completely different issue. Want to see Microsoft-based examples of over-design versus simplicity? Just look at the sheer amount of "reserved, must be 0" parameters in their Win32 API's. By far most of those parameters have been mandatory zeros for close to ten years now -- and meanwhile the places that would have needed extra options didn't have them, so we have a zillion cases of UglyMultiWordNameEx2. Unix syscalls are spare and functional, and have withstood the test of time much more effectively than kernel-Win32 API's (despite the notorious "I should have spelled 'creat' with an e" admission of a design error by Thompson:-). But, again, the issue of externally-exposed interfaces is quite different from that of implementation architecture. When you publish an interface, if your program meets with any success, that interface has to stay forever. When you make a design choice regarding your implementation, you're NOT etching anything into stone -- and that is what we're talking about here: whether to use a simple global list, to do the job of a simple global list, OR overdesign and overarchitect a whole subsystem to take the place of the simple, obvious approach. Want more examples? Of course they'll again be from the real of externally-exposed interfaces, because that is where it's easier to share them:-), but that's OK, since if some simple architecture works well in a relatively unfavourable case (externally exposed itf) it will work even better in favourable ones (internal implementation choices). How does Python let you know what built-in modules it has? A simple global list, sys.builtin_module_names. How does it let you know what arguments your program was called with? A simple global list, sys.argv. How does it let you know AND AFFECT where modules will be imported from? A simple global list, sys.path. How does it let you know what modules have been imported os far? A simple global _dictionary_ (aha, a variant!-), sys.modules. Simplicity WORKS WELL. Simplicity is the backbone of Python, what really makes it great -- wonderful to use, powerful AND easy, peerless. Want to learn to design programs really well? You could do worse than to study what Guido and friends did in Python. You will find the small errors and debatable decisions, you will find the huge numbers of "just right" design choices, large and small. Notice how many times those "just right" choices end up delivering *SIMPLICITY* over and over again...!-) > Because "right yesterday" 640K was enough for everything. Furthermore, the choice of drive-letters for file paths, and the issue of amount of addressable memory, are also quite obviously independent. As, again, this is utterly obvious, I do not understand why you appear to assert causal dependency between these design choices ('Because'?!). > >See http://c2.com/cgi/wiki?YouArentGonnaNeedIt ... I reiterate this advice... the Wiki is really a good place to see these issues discussed -- as open to all sides as a newsgroup, but building up to more permanent documents... but not so permanent that you can't always enhance them (be it only with your questions and open issues). Alex From calisha at *SPAMFREE*.calishar.com Tue Jun 5 20:38:59 2001 From: calisha at *SPAMFREE*.calishar.com (Calishar) Date: Tue, 05 Jun 2001 20:38:59 -0400 Subject: A question about MySQLdb and SSH Message-ID: Hi Folks, I'm looking at setting up an Administration application for a remote database running on a Redhat Linux 6.2 box. The admin client will probably be running on Windows to start with, maybe being preted to Linux later on. One thing I have to make sure of is that data transmitted from the admin client to the database server is secure. I know that it is possible to use SSH to setup an ODBC connection to the remote server. What I am wondering is if there is anything similar using the MySQLdb library. Ideally it would not require setting up a seperate SSH application (the application is for an end-user). I guess what this question boils down to is: 1. Is there a way I can make an SSH connection from within a Python App 2. Is there a way that a MySQLdb python App can be setup to use the SSh connection rather than a straight TCP/IP connection/ Thanks in advance, Calishar From ryu-jin at bigfoot.com Wed Jun 13 02:27:46 2001 From: ryu-jin at bigfoot.com (Ryujin) Date: Wed, 13 Jun 2001 06:27:46 GMT Subject: Python cgi Message-ID: <9g5cv7$um$1@ryu.it> Does anybody knows any site offering free web space with Python cgi support? Thx a lot Matte -- --------------------------------------- Memelli Matteo Could u imagine a world without Windoz? ryu-jin at bigfoot.com --------------------------------------- From rnd at onego.ru Sat Jun 16 16:24:25 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 17 Jun 2001 00:24:25 +0400 (MSD) Subject: in statement and namespace type ideas Message-ID: Hello, right now namespace handling in Python uses dicts, however, docs say it could change. I can't be sure that my code which uses globals() to merge, for example, cgi-form variables with globals namespace will work with future Python versions. There are other examples where I need to transfer some variables from one namespace to another. Dict is good type for namespace, but maybe it's time to propose new mapping type - namespace - to do things I described? I also thought about absent "with" operator and how it could be used in Python. Maybe it is beneficial to have "with" syntax like in the followin example: class Example: a = 1 b = 2 def aaa(self): k = 3 def bbbb(self): e = Example() # 1 in e.__namespace__: # temparary change locals() with Example.__dict__ c = 3 aaa() print k # or 2: in e: c = 4 This will be almost equivalent to: exec """ c = 3 ... """ in e.__dict__ except it will be compiled at compile-time. The problem I see is that #1 is too verbose and #2 is not always useful. For example, if I need e to be mapping type object, I will assume that in e: ... will mean "in namespace, which e defines" not "in namespace of e". This could, of course, be resolved, for example, if namespace type will have some attribute, say, __i_am_namespace__. It could also be arranged that namespaces could be merged like that: in e+local(): # locals() has more priority ... or in locals()+e: # e overrides locals() and so on. (Syntax could be different). in-statement could be useful inside method defs: class AAA: _delta = 1 def met(self, a, b, c): in vars()+self: print a + _delta return b + c + _delta "in" is in kwlist already, though, no problem here. in could be called "temporary namespace application". I even think, in-statement could be used in the mode of "with" (as in Pascal), that is, always: in locals()+e, globals()+g: ... by writing only: in e, g: ... But I think my scheme is more explicit. Or, maybe, it is possible to do it this way: in additional, locals(), globals(): ... with all new variables considered in "additional" namespace? * * * Are these ideas worth serious consideration? Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Saturday, June 16, 2001 _/ Powered by Linux RedHat 6.2 _/ From gustafl at algonet.se Thu Jun 7 14:34:39 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 7 Jun 2001 18:34:39 GMT Subject: PortableUnixMailbox problem Message-ID: Guess I don't understand how to use it, but I get this error when trying to use the new (2.1) PortableUnixMailbox class: E:\test>python pum.py Traceback (most recent call last): File "pum.py", line 4, in ? m = mb.next() File "e:\python\lib\mailbox.py", line 19, in next self.fp.seek(self.seekp) AttributeError: seek And my code: from mailbox import PortableUnixMailbox mb = PortableUnixMailbox('in.mbx') m = mb.next() The problem appears on the line "m = mb.next()", where I try to create a rfc822.Message object from the mailbox. Regards, Gustaf Liljegren From support at internetdiscovery.com Sat Jun 23 23:16:36 2001 From: support at internetdiscovery.com (Mike Clarkson) Date: Sun, 24 Jun 2001 03:16:36 GMT Subject: New windows case sensitivity in Python 2.1? References: Message-ID: <3b355b8c.16707301@nntp.ix.netcom.com> On Fri, 22 Jun 2001 22:28:26 -0400, "Tim Peters" wrote: >[Mike Clarkson] >> I seem to be seeing a new case sensitivity to the import command under >> windows (Win98 FAT 32). ... > >Yes, this was the topic of PEP 235 (Import on Case-Insensitive Platforms), >implemented for Python 2.1. See > > http://python.sourceforge.net/peps/pep-0235.html Thanks Tim, but I think what I'm seeing is not what PEP 235 intended, or there is an imprecision in the PEP that needs elucidating. In my example of trying to 'import _tkinter' failing, when I open a DOS command window, and change to the Dll's directory, a DIR shows me _TKINTER PYD 22,528 06-13-01 10:53p _TKINTER.PYD Now the thing that decided _tkinter.pyd should be stored as _TKINTER.PYD was the M$ installer that put the file there (AS binary), or my WinZip and/or tar in the case of a source distribution. Needless to say, I think Python should work on Windows no matter what archiver is used to unpack or install it. The PEP wanted: it can't cause any existing non-exceptional Windows import to fail, because any existing non-exceptional Windows import finds a case-sensitive match first in the path -- and it still will. but it's now failing because the so-called long file name is all upper case, due to the archiver/installer. I think for a 'non-exceptional Windows import' the comparison to 8.3 compliant targets (_tkinter.pyd) must be first case-INsensitive match, no matter what PYTHONCASEOK is. When I do a (case sensitive) DOS command in the Dll's directory: rename _tkinter.pyd foo rename foo _tkinter.pyd DIR shows me _TKINTER PYD 22,528 06-13-01 10:53p _tkinter.pyd and the import works, so the import is matching against the long filename; i.e. "if long_filename == short_filename", can't be used as a test of 8.3 names. I think for DOS 8.3 file names with no mixed case on Windows VFAT, case itself is undefined, which is why different installers/archivers give different results (not to mention NTFS :-<). >for the full story. If for some reason you can't, or don't want to, use >matching case, you'll have to set the envar PYTHONCASEOK (to anything -- >just so long as it's defined). Setting PYTHONCASEOK works, but we can't set it on Windows no matter what archiver is used to unpack or install Python. Set PYTHONCASENOTOK instead :-)? The ugly exception gets uglier. Many thanks, Mike. From dsh8290 at rit.edu Thu Jun 7 15:30:24 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 7 Jun 2001 15:30:24 -0400 Subject: getch() of Turbo C in Python? In-Reply-To: ; from anuragved@vsnl.com on Thu, Jun 07, 2001 at 12:08:35PM -0700 References: Message-ID: <20010607153024.B17612@harmony.cs.rit.edu> On Thu, Jun 07, 2001 at 12:08:35PM -0700, Anurag Ved wrote: | Hi all, | I am using the Python interpreter under Windows. When I execute a | Python script, the console window that opens up closes immediately | after the program terminates, leaving me no time to observe the | output. One solution is to append the program with | | raw_input('') | | But, this is certainly not elegent and moreover it requires the user | to press 'enter' rather than the preferred option of 'any key'. | | Is there something similar to the getch() function of Turbo C which | reads just one key from and returns immediately? It's always possible to wrap the desired C function using the extending API. The alternative is to fix WIndows. This default behavior of not letting one see the error message is a royal pain. You can either open a shell window, then run your program from it (this is what I do because I use bash extensively) or configure the shortcut that launches Python to not close the DOS box automatically. -D From thinkit8 at lycos.com Mon Jun 18 01:53:39 2001 From: thinkit8 at lycos.com (thinkit) Date: 17 Jun 2001 22:53:39 -0700 Subject: humans should use a power of 2 References: <9gjqh201q0o@drn.newsguy.com> Message-ID: <9gk51301up@drn.newsguy.com> In article <9gjqh201q0o at drn.newsguy.com>, thinkit says... > >please stop using decimal. most people already only use hexadecimal. "0x" is >your friend...soon enough humans will be only using powers of 2 as general >purpose bases. > *bump*...don't ppl bump on newsgroups? hee hee. From kalath at lycos.com Fri Jun 15 06:09:59 2001 From: kalath at lycos.com (Mark Brady) Date: 15 Jun 2001 03:09:59 -0700 Subject: crypt module on win32? References: <3B299A96.C42FC98C@senux.com.NOSPAM> Message-ID: I have the latest and greatest Crypto module (amkCrypto- 0.1.3 http://www.amk.ca/python/code/crypto.html) compiled for win32 (using the free borland compiler). I'll mail you it. I'll put it online sometime next week or people can mail me if they are interested. I intend to recompile it using VC++ as I suspect this might make it slightly more efficient. I also plan on compiling PyAES (http://sourceforge.net/projects/pyaes)for Python 2.1 as it currently only comes in binary for Python 2.0. M2Crypto (http://www.pobox.org.sg/home/ngps/m2/)is also very good but it seems to only have very limited support for symmetric cipers (it's got lots of PKI ciphers) so I think amkCrypto is the best general purpose Crypto module for python at the moment. When I get PyAES working with 2.1 I might package the two together as AES is very important. Thanks go to Ng Pheng Siong, Bryan Mongeau, Marc-Andre Lemburg and of course Andrew Kuchling for giving Python decent crypto. Mark. Brian Lee wrote in message news:<3B299A96.C42FC98C at senux.com.NOSPAM>... > Hi, I want to use some Python code on MS-Windows. The code use crypt > module > but there is no such module on Python for MS-Windows. Any other modules > which > works like crypt module? Or... any ideas? > - Brian,. From aleaxit at yahoo.com Thu Jun 14 06:00:36 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 12:00:36 +0200 Subject: Telling python where to look for a script References: <3B285BFD.D2AC7E26@rk-speed-rugby.dk> Message-ID: <9ga20f02hsk@enews1.newsguy.com> "Brian Elmegaard" wrote in message news:3B285BFD.D2AC7E26 at rk-speed-rugby.dk... > Hi, > > I would like to make python aware of where my scripts are located. I > have set pythonpath to \python20\scripts, but I can imagine how this > could be filled up by numerous scripts over time, so can python search > it recursively? > > I also tried to copy the way it is done by pmw, which is found, but is > not in any pythonpath? Can I do it the same way and how is it done? There is an important difference between scripts and modules. A script is meant to be run as an argument to python.exe (assuming you're on Windows because of the backslashes:-). A module is meant to be imported. A foo.py file can be both, but adapting the path is relevant to module-use only, NOT to script-use. All clear so far...? For sys.path adaptation, simplest is to use .PTH files. Any textfile with an extension of .PTH found in the Python home directory (e.g. C:\Python20 in your case, I guess) is read on startup: each line is the full path of a directory to be added to sys.path (the .PTH file may also include empty lines and comment lines starting with #). Alex From emile at fenx.com Wed Jun 20 21:24:06 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 20 Jun 2001 18:24:06 -0700 Subject: Interfacing GUI applications..? References: <3B18032E.21AF631E@pfortin.com> <16074dce.0106200912.7b9bc793@posting.google.com> <9gqs2c01c2m@enews1.newsguy.com> Message-ID: <9griip$aca65$1@ID-11957.news.dfncis.de> For non-standard (older) windows applications that do not appropriately respond to key-stroke instructions, take a look at mSched from http://www.mjtnet.com/ . I've just completed "automating" a windows app with this, and found it more than up to the task. -- Emile van Sebille emile at fenx.com --------- "Alex Martelli" wrote in message news:9gqs2c01c2m at enews1.newsguy.com... > "Jeff Shannon" wrote in message > news:16074dce.0106200912.7b9bc793 at posting.google.com... > ... > > One suggestion for "something else"... there is a Visual Basic function > > "sendkeys()" that does exactly what is requested--it simulates keyboard > > Easily usable from Python too (as it's packaged as part of the Windows > Scripting Host, a free download from Microsoft if you don't have it > already installed). See an example, e.g., at: > http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/65107 > > Pity it won't help the original poster (who's on Linux) -- unfortunately, > generic scriptability under Unix-y systems tends to be horrible for all > non-text-mode applications (except, I'm told, those built with certain > clever toolkits -- no direct experience, sorry). Ah, *COM*...! > > > Alex > > > From sholden at holdenweb.com Fri Jun 29 17:17:05 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 29 Jun 2001 17:17:05 -0400 Subject: getopts confusion References: Message-ID: Not familiar with the gnome.ui module, but you could import it in an interactive session then see whether it has anything which conflist with your code (using dir()). The from ... import * usage is dangerous, especially when the module concerned has not been carefully designed not to pollute its host namespace. I don't know whether that's the case for gnome.ui. regards StEVe -- http://www.holdenweb.com/ "Rob Brown-Bayliss" wrote in message news:mailman.993845146.8762.python-list at python.org... > On 29 Jun 2001 08:13:50 -0400, Steve Holden wrote: > > > Error on option -s: unknown option. > > > Run './gearbox.py --help' to see a full list of available command line > > > options. > > I have checked indentation, it's fine. > > > > I conclude that the getopt code is working correctly, but your application > > is somehow failing to test for the options. > > > > Hope this helps. > > Yes, some. I played around some more, and the app that fails has a GUI, > the other is a command line app. There is a single import I do (from > gnome.ui import *) that stuffs it up, if the getopt stuff comes before > this import I don't get that error, if I cut and paste the getops till > after this import I get the above error. > > Does any one know why? > > -- > > Rob Brown-Bayliss > ---======o======--- > www.ZOOstation.cc > From robin at jessikat.fsnet.co.uk Fri Jun 8 14:43:47 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 8 Jun 2001 19:43:47 +0100 Subject: spell method chaining? References: <19l8IVAAgJI7EwAk@jessikat.demon.co.uk> <3B2111FF.D998EEE4@letterror.com> Message-ID: In article <3B2111FF.D998EEE4 at letterror.com>, Just van Rossum writes .... >s inheriting it) > >You can avoid that by spelling it like this: > >def gen(B): > class W(B): > __base = B > def __init__(self): > self.__base.__init__(self) > return W > >Just this nearly works fine in 2.1 if I have a from __future__ import nested_scopes, but gives a shadowed variable warning if not. In any case from __future__ import nested_scopes def gen(B): class W(B): __base = B def __init__(self): self.__base.__init__(self) return W class C: def __init__(self): pass gen(gen(C))() recurs infinitely. In 2.1 with nested scopes my original formulation is OK, from __future__ import nested_scopes def gen(B): class W(B): def __init__(self): B.__init__(self) return W class C: def __init__(self): pass gen(gen(C))() but the following gives a compile error for some reason. from __future__ import nested_scopes def gen(B): class W(B): __base=B def __init__(self): B.__init__(self) return W class C: def __init__(self): pass from __future__ import nested_scopes def gen(B): class W(B): __base=B def __init__(self): B.__init__(self) return W Fatal Python error: non-string found in code slot abnormal program termination -- Robin Becker From jbellprj at iinet.net.au Thu Jun 7 09:10:52 2001 From: jbellprj at iinet.net.au (John Bell) Date: Thu, 07 Jun 2001 21:10:52 +0800 Subject: Python and databases References: <991557251.316332@seven.kulnet.kuleuven.ac.be> <9fcv2j021uk@enews2.newsguy.com> Message-ID: <3B1F7D5C.CCB4E95F@iinet.net.au> Harry George wrote: > It is only a "problem" if you need every nuance of DBI 2.0. You can > get a whole lot of work done using what is available in, e.g., psycopg > (for Postgresql) and MySQl-python (for MySQL). I think this is missing the key point (in a practical sense) of the standard. If you're going to take a significant body of code from one DB to another or support multiple databases for different customer needs then you are much better off with standard interfaces. Unless you're in the unusual position of being able to dictate technology choices to your customer this is an important issue in S/W businesses. John > > > "Alex Martelli" writes: > > > "Pieter Laeremans" wrote in message > > news:991557251.316332 at seven.kulnet.kuleuven.ac.be... > > > Hi, > > > > > > Does python has something like perl 's DBI? > > > I can 't find any documentation about it in the python docs. > > > > http://www.python.org/topics/database/ > > > > The problem may be finding complete implementations of > > the current (release 2.0) DB-API spec, but that depends on > > a lot of factors: are you going to make commercial use of > > it, and in that case do you have funding -- for non-commercial > > use, OR for pay in the case of commercial use, you can get > > Lemburg's excellent mxODBC implementation (if ODBC is > > what you want to use). You can also get implementations > > for quite a few specific database engines. > > > > > > Alex -- Regards, John Bell From aahz at panix.com Fri Jun 1 13:07:39 2001 From: aahz at panix.com (Aahz Maruch) Date: 1 Jun 2001 10:07:39 -0700 Subject: Against PEP 240 References: <3b16a5e2.10711472@wa.news.verio.net> <9f6lge$doe$1@panix6.panix.com> <3b17ca9e.47602448@wa.news.verio.net> Message-ID: <9f8i4r$9m6$1@panix3.panix.com> In article <3b17ca9e.47602448 at wa.news.verio.net>, Bengt Richter wrote: > >Well, I was talking about using an error-correcting-code (ECC) concept >to prevent propagation of errors, not just finessing the final output. >I guess my tail end example was misleading 8-<:^) Ah. I've seen things like that, but IIRC you can't use the hardware FP, so you might as well go to decimal. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Characters exist to suffer, you know. An author needs a little sadism in her makeup." --Brenda Clough From macias at bp.com.pl Tue Jun 26 07:49:50 2001 From: macias at bp.com.pl (Maciej Pilichowski) Date: Tue, 26 Jun 2001 11:49:50 GMT Subject: 'with' statement in python ? References: Message-ID: <3b3875f1.110436929@news.tpi.pl> On Mon, 25 Jun 2001 21:30:36 -0300, Carlos Ribeiro wrote: I have just started learning Python yesterday but... >def with_is_broken(a): > with a: > print x > >The snippet above assume that "a" must have a member attribute called "x". Nope. As you referred to Pascal -- if "a" has a member "x" it is read as "a.x", if not it is standalone "x". have a nice day bye -- Maciej "MACiAS" Pilichowski http://www.torun.pdi.net/~macias/ z a k u p i e : Wyklady Feynmana: tIIcz1; pisma Komputer: 3/86,4/87 From tjg at hyperlinq.net Tue Jun 26 13:28:47 2001 From: tjg at hyperlinq.net (Timothy Grant) Date: Tue, 26 Jun 2001 10:28:47 -0700 Subject: readline, python 2.1 and LFS In-Reply-To: <3dpubr1ek8.fsf@ute.cnri.reston.va.us>; from akuchlin@mems-exchange.org on Tue, Jun 26, 2001 at 10:49:43AM -0400 References: <3B35B57F.1E0F956B@nospam.de> <3dpubr1ek8.fsf@ute.cnri.reston.va.us> Message-ID: <20010626102847.G5596@trufflehunter.hyperlinq.net> On Tue, Jun 26, 2001 at 10:49:43AM -0400, Andrew Kuchling wrote: > Timothy Grant writes: > > ncurses v5.2 > > readline v4.2 > > python v2.1 > > > > I'm sure I'm missing a configuration option or something > > similar, but I can't figure out what. > > Did you edit Modules/Setup to enable the readline module there, and to > link with termcap or terminfo? > > --amk My understanding was the configure was smart enough to figure this out, and my testing has shown that it does seem to be so. However, when things didn't work correctly, I did go and hack Modules/Setup (probably incorrectly). My confusion comes with the termcap and terminfo stuff. When I link against termcap the build works perfectly. I don't generate an error until I actually try and import readline. I don't have a terminfo library installed at the moment. It appears that tputs is an ncurses function though, so that it what is really stumping me. Thanks for taking the time to assist, much appreciated. New Topic: I read a few posts back that you are doing stuff with the ZODB on a stand-alone basis. Do you have a paper, README, instructions or anything that detail the procedure of using it by itself? -- Stand Fast, tjg. Timothy Grant www.hyperlinq.net Chief Technology Officer tjg at hyperlinq.net HyperLINq Technologies, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 21 days 17:24 hours ago<< From djc at object-craft.com.au Tue Jun 26 21:29:47 2001 From: djc at object-craft.com.au (Dave Cole) Date: 27 Jun 2001 11:29:47 +1000 Subject: MS SQL Server References: <51dgjtsbuureuugfcubid11tldg7077sfa@4ax.com> Message-ID: >>>>> "Ben" == Ben writes: Ben> Hi, Unfortunately I have to upload data to a MS SQL server Ben> ... Can anyone recommend a tool for doing this or docs\examples Ben> :] ... is it ANSI SQL compliant like MySQL and therefore can use Ben> the same commands? Ben> greatly appreciate any advice You don't say which platform you are using as the source for the data... The Sybase module which I wrote can be compiled on Linux or NT (so I hear) and it has bulkcopy support. In my limited experience of using it to talk to MS SQL server I was able to bulkcopy data into tables which did not have IDENTITY columns. There seems to be some difference between Sybase and MS SQL server in their handling of that column type. http://www.object-craft.com.au/projects/sybase/ An example of bulkcopy from the README file: >>> import Sybase >>> >>> data = (('pencils', 5), >>> ('books', 300), >>> ('videos', 11)) >>> >>> db = Sybase.connect('SYBASE', 'user', 'password', bulkcopy = 1, auto_commit = 1) >>> db.execute('create table #bogus (name varchar(40), num int)') >>> >>> bcp = db.bulkcopy('#bogus) >>> for line in data: >>> bcp.rowxfer(line) >>> print 'Loaded', bcp.done(), 'rows' The auto_commit is needed because bulkcopy does not work inside a transaction. Sybase 11.0.3 is a free download from http://linux.sybase.com/ It is free for development and deployment. If your source data is CSV format then you can use another one of the modules I wrote to load it into a format suitable to feeding the bulkcopy object in the Sybase module. The module was written specifically to handle data type data produced by Access and Excel. http://www.object-craft.com.au/projects/csv/ The above bulkcopy example enhanced to use the csv module would look something like this: >>> import Sybase, csv >>> >>> db = Sybase.connect('SYBASE', 'user', 'password', bulkcopy = 1, auto_commit = 1) >>> db.execute('create table #bogus (name varchar(40), num int)') >>> >>> p = csv.parser() >>> bcp = db.bulkcopy('#bogus') >>> for line in open('datafile').readlines(): >>> fields = p.parse(line) >>> if fields: >>> bcp.rowxfer(line) >>> print 'Loaded', bcp.done(), 'rows' - Dave P.S. Ob.Vapour #1: I have some more appropriate software under development but do not want to announce it until it is ready... Ob.Vapour #2: I just tested the above and realised that I had not added support for the optional bulkcopy = 1 argument. I have since fixed that and it will be in the next release. Two releases in two days - oops. -- http://www.object-craft.com.au From philh at comuno.freeserve.co.uk Fri Jun 29 14:20:58 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 29 Jun 2001 19:20:58 +0100 Subject: PEP scepticism References: <9hfg1n$du33c$1@ID-89274.news.dfncis.de> <3B3BB077.1E51F2C9@ActiveState.com> Message-ID: On Fri, 29 Jun 2001 11:50:13 -0400, Barry A. Warsaw wrote: > >>>>>> "ph" == phil hunt writes: > > ph> Is there a PEP for multi-line comments? > > ph> Or one for making ``pass'' optional? > >Nope, so obviously no one thought there was enough controversy or need >in either of these two areas. > >The only requirements for PEP authors is that you have some ability to >write well, can communicate your ideas clearly and succinctly, and >that you be open to criticism and discussion from the community. IOW, >almost /anybody/ can be a PEP author. > >If you think multiline comments or optional-pass are subjects worthy >of PEP-hood, follow the guidelines in PEP 1 and submit your own >offerings! Now there's a challenge! PEP1 says: The PEP champion (a.k.a. Author) should first attempt to ascertain whether the idea is PEP-able. Small enhancements or patches often don't need a PEP and can be injected into the Python development work flow with a patch submission to the SourceForge patch manager[2] or feature request tracker[3]. How do I ascertain this? Who decides whether something is a "small enhancement"? The changes i propose would be two separate PEPs (I assume) -- or would they be added to PEP-42 (which is a list of small features)? It seems to me that optional-pass is obvious in its meaning, but multi-liner comments aren't. There are three issues: 1. what should be the character sequences to begin/end multi line comments I propose /* to start multi-line comments and */ to end them. Eg: /* this is a multi-line comment. this is part of the samer comment. so is this. */ Rationale: similar to C and many other languages; the combination /* isn't legal anywhere in current python code (AFAIK) so won't break it. I did consider using one of @$? which are not currently used by python, but it's best to leave these unused so they are still available for extra operators (or whatever) at a later date. 2. how will this interact with python's indent/dedent mechanism In particular, how do we treat this: def myfunction(): print "hello" print "start" /* start of comment middle of comment end of comment */ print "goodbye" IMO the best way to prevent unexpected wierdness like this is to forbid any code in any line after the */ closing-comment sequence; or perhaps to give a warning and ignore it (it shouldn't just be silently ignored, as this will confuse people familiar to how it works in C). 3. will it break any old code AFAIK my proposal as it stands won't. -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From m.faassen at vet.uu.nl Wed Jun 6 15:55:08 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 6 Jun 2001 19:55:08 GMT Subject: Why should i use python if i can use java References: <9flu5i$c61$1@news.tudelft.nl> Message-ID: <9fm1qs$hbm$1@newshost.accu.uu.nl> mik wrote: > i' m a python newbie but I've this prob. i have seen Jython .. I'm not sure how that is a problem. Is it a problem? > what has python dat java does not????????? Python has everything Java has got (through Jython) and then some! Of course Java has a lot of what Python has got (through Jython) as well. Python is a more pleasant and easy to use language than Java, according to many of its users. It's easier for beginners and doesn't stand in the way of more experienced programmers either. People claim they can develop software more quickly using Python. Python takes another approach than Java; Java is a "We are the World" language; in Java land, virtually everything is supposed to be in Java or at least have a very thick layer of Java covering it. This has advantages (compatibility and portability can sometimes be easier to ensure), but also disadvantages (integration with other tools and systems is more difficult). Python is a far more open language and integrates well with a lot of external tools and libraries. Java code is reputed to execute faster than Python code; though this depends on the algorithm a lot, and many claim it's easier to be smarter in Python about it (and thus faster) than in Java. Python tends to consume less memory than Java does. If Java or Python or some other language is best for you depends on what you'd like to do, so you'll have to figure that out first. Regards, Martijn From emile at fenx.com Thu Jun 21 14:24:15 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 21 Jun 2001 11:24:15 -0700 Subject: namespace issue? References: Message-ID: <9gtebl$b10e7$1@ID-11957.news.dfncis.de> The problem is likely that your 'if len(PN)...' test is false, leaving Ph unassigned when the return executes. HTH, -- Emile van Sebille emile at fenx.com --------- "Michael Powe" wrote in message news:uwv65ivfc.fsf at trollope.org... > Hello, > > This looks like a namespace issue described in but > it doesn't make sense to me and I don't know how to fix it. > > ex 1: > > >>> def GetNum(): > ... AC = raw_input("Area Code: ") > ... PN = raw_input("Phone Number: ") > ... if not AC : AC = '503' > ... if not PN : PN = '000-0000' > ... Ph = AC + PN[:3] + '-' + PN[3:] > ... return Ph > ... > >>> ok = GetNum() > Area Code: 503 > Phone Number: 2243187 > >>> ok > '503224-3187' > > ex 2: > > >>> def GetNum2(): > ... AC = raw_input("Area Code: ") > ... PN = raw_input("Phone Number: ") > ... if not PN : PN = '000-0000' > ... if not AC : AC = '503' > ... if len(PN) < 8 and not string.find(PN,'-'): > ... Ph = PN[:3] + '-' + PN[3:] > ... return Ph > ... > >>> ok = GetNum2() > Area Code: 434 > Phone Number: 2243187 > Traceback (most recent call last): > File "", line 1, in ? > File "", line 8, in GetNum2 > UnboundLocalError: local variable 'Ph' referenced before assignment > > The issue is, I don't understand why the problem appears with variable > 'Ph' in the second instance but not in the first. It seems obvious > that it comes about because of the conditional. > > Also, on a side note, what is the default data type for input gathered > from raw_input()? Is it a string? > > Thanks for any help. > > mp > > From dalke at acm.org Mon Jun 25 17:08:35 2001 From: dalke at acm.org (Andrew Dalke) Date: Mon, 25 Jun 2001 15:08:35 -0600 Subject: Is this a true statement? References: <8NuZ6.362378$oc7.42924874@news2.rdc2.tx.home.com> <3B3788A2.3BD1D672@tundraware.com> Message-ID: <9h89pn$oj5$1@slb2.atl.mindspring.net> Tim Daneliuk wrote: >I still do not understand/agree with this line of reasoning entirely. >As I mentioned in a previous post, one has to define what we mean by >"do" or "program". ... >Now, if we say "Language X can "do" things we cannot "do" in Language Y" we >are saying one of several possible things: ... >3) There is something about how X and Y are *implemented* which causes > this disparity (almost certainly the case). ... >3) is where the rocks start to get thrown. If I do 3), have I "extended" >the language to do something it could not previously? NO! I have >implemented what I could already do with 2) in a more programmer-friendly >manner, but I have not changed the net computational power of the language. > >So, I close with this claim (which I believe is well supported by >the theory): Define "Computational Power" to be the number of >algorithms a given language can compute. Then: Increasing >"Computational Power" for a given language is only possible if >that language is less than Turing-Complete. In every other case, >all we are doing is changing the *programmer's* perception and >paradigm of work, not the net "Computational Power" of the language. Software is used for more things than "Computational Power." Take again the example I posted a few days ago on allocating in shared memory. Suppose I have a hardware environment where there is special shared memory hardware which can be used to pass data between otherwise different processors. One example is the CAVE visualization system, which is an immersive reality system where images are projected on the walls of a room to make it look like you are inside of a synthetic environment -- the closest we can get to Star Trek's holodeck. One processor is used to generate the visualization model into shared memory, then other CPUs (one for each wall) gets the model to generate the appropate image with the correct viewpoint. In C++ I can define how 'new' and 'delete' work on a given class, so that I can allocate and deallocate the objects to be shared from the shared memory arena while leaving the other objects (like file I/O) in local non-shared (and more plentiful and cheaper) memory. There is no way nor even a proposal of a way to use special memory allocation routines for specific object, at least not in a very Pythonic fashion. So using different memory arenas is an example where you can "do" something in C++ which is much harder to do in Python. It is not a limitation or restriction of the implementation of Python - it's in the language itself. To bring it back to Turing machines, the concept of "shared memory" or "I/O ports" or "interrupts" or "signals" does not exist in a TM. To talk about them in a TM context requires emulating their physical behaviour, and it is that emulation - that translation from a language description to a physical device - that some languages do not provide. Andrew dalke at acm.org From boyd at insultant.net Mon Jun 4 14:19:04 2001 From: boyd at insultant.net (Boyd Roberts) Date: Mon, 4 Jun 2001 20:19:04 +0200 Subject: Using SMTPlib References: <9fg915$jho$1@news.inet.tele.dk> Message-ID: <9fgjg7$j73$1@hadron.noos.net> "Brian Andersen" a ?crit dans le message news: 9fg915$jho$1 at news.inet.tele.dk... > I've tried the SMTPlib and it work out fint, but the mails I send don't have > a subject. > > I've tried the example that is in the Pythondocumentation for the SMTPlib > and it works well, but how do I insert a subject field? > > The same goes for CC end BCC-fields. Are they handled by the SMTPlib or is > it something that I must handle in my program? that sounds like a good idea. perl has one too. why not just construct the message and pipe it into something that reads the message from stdin? what you want to know is that an RFC 822 / STD 11 message contains the Cc:, Bcc: and Subject: fields. they are out of the scope of SMTP as it just says who it's from and who it should be delivered to which is managed by the MTAs (initially being picked out of the To:, Cc: and Bcc: fields or later managed by info given to the MTA via SMTP). From rnd at onego.ru Sun Jun 24 12:59:06 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 24 Jun 2001 20:59:06 +0400 (MSD) Subject: PEP 255: Simple Generators In-Reply-To: <20010624082350.A29837@glacier.fnational.com> Message-ID: On Sun, 24 Jun 2001, Neil Schemenauer wrote: >Roman Suzi wrote: >> This implementation is cool, but how fast will be recursive generators? >> How large is the overhead to defrost execution frame each time? Will it be >> faster than functional gcomb? > >Why don't you write one and we will compare it to Tim's generator >version? :-) I'll stick my neck and speculate that resuming a generator >is measurably faster than calling a function. Could you try my comb version? I am sure it's faster! (I used the same algorithms in it. Only implementation differs) #!/usr/bin/python2.1 def comb(x, k): "Generate all combinations of k elements from list x." if k > len(x): return [] if k == 0: return [[]] first, rest = x[0:1], x[1:] return [first+w for w in comb(rest, k-1)] + comb(rest, k) # Tim's code below this line unchanged: seq = range(1, 5) for k in range(len(seq) + 2): print "%d-combs of %s:\n " % (k, seq), for c in comb(seq, k): print c, " ", print """ Which prints: 0-combs of [1, 2, 3, 4]: [] 1-combs of [1, 2, 3, 4]: [1] [2] [3] [4] 2-combs of [1, 2, 3, 4]: [1, 2] [1, 3] [1, 4] [2, 3] [2, 4] [3, 4] 3-combs of [1, 2, 3, 4]: [1, 2, 3] [1, 2, 4] [1, 3, 4] [2, 3, 4] 4-combs of [1, 2, 3, 4]: [1, 2, 3, 4] 5-combs of [1, 2, 3, 4]: """ Probably, [g]comb could be added to regression tests of generators. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, June 24, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Ok, I pulled the pin. Now what? Where are you going?" _/ From JamesL at Lugoj.Com Tue Jun 12 02:17:17 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Mon, 11 Jun 2001 23:17:17 -0700 Subject: [Python-Dev] Feedback on new floating point info in tutorial References: Message-ID: <3B25B3ED.59D7114@Lugoj.Com> "Delaney, Timothy" wrote: > > > Tim Peters wrote: > > > > > god-created-the-integers-from-1-through-3-inclusive-and-that's-it-ly > > > y'rs - tim > > > > > I thought "many" came after two ... > > Well, that's true, but large numbers of people forget that "many" itself is > a number ... > > 1, 2, many, many 1, many 2, many many, many many 1, many many 2, many many > many, lots! George Gamow wrote a book titled "One Two Three... Infinity". So there seems to be some authority behind things getting rather innumerable after three! (Gamow being one of the three involved in the famously named Alpher-Bethe-Gamow theory of the origin of the elements (the real names of the authors being a play on the first three letters of the greek alphabet).) Sorry, not sure what this has to do with Python.... From nweissma at mathlab.sunysb.edu Mon Jun 18 23:35:42 2001 From: nweissma at mathlab.sunysb.edu (Neal Weissman) Date: Mon, 18 Jun 2001 23:35:42 -0400 Subject: Newbie seeking warm bodies Message-ID: would anyone in the long island or nyc area consider having an annoying newbie user (a newbie asking a lot of annoying questions) dwelling amongst them? i am reading the official python documentation, by Guido van Rossum and Fred L. Drake, and have just hit a brick wall. please respond directly to my email. thanks. /s/ neal weissman From fredrik at pythonware.com Tue Jun 5 12:59:11 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 05 Jun 2001 16:59:11 GMT Subject: How to get a unicode degrees symbol? References: <9fj0j6$e7m$1@nntp6.u.washington.edu> Message-ID: Russell E. Owen wrote: > I'm obvious missing some important bit of documentation, but I looked > through the manuals and can't seem to figure out how to get unicode > character constants into python strongs. not sure how you managed to miss this one: http://www.python.org/doc/current/ref/strings.html but here's a summary: either use a 2, 4 or 8-digit hexadecimal character code: u"\xb0", u"\u00b0", u"\U000000b0" or a named unicode character: u"\N{DEGREE SIGN}" > For instance I'd like to create a string that contains a degree symbol > (that would show up correctly on all platforms). Right now I'm > generating a character constant whose contents are set differently > depend on the platform. It works but is rather lame. if you need different *content* for different platforms, unicode won't help you. it's only a character encoding, after all... if you want the same content, but want to print it in different ways depending on the platform's display encoding, you can use the encode method on the way out. examples: u = u"\N{DEGREE SIGN}" print u.encode("iso-8859-1") # unix (us/western europe) print u.encode("cp1252") # windows print u.encode("macroman") # macintosh print u.encode("cp850") # dos window if the target encoding doesn't have a degree sign, encode will raise an exception. if you don't want that, pass "replace" or "ignore" as the second argument. From cyblue at a-lab.co.kr Wed Jun 20 22:22:46 2001 From: cyblue at a-lab.co.kr (ÃÖÁø¿ì) Date: Thu, 21 Jun 2001 02:22:46 GMT Subject: [Q] python embedding in C Message-ID: I want to embedding python in C program under Linux. But How? I couldn't search about a embedding HOWTO. Pleez Help me. From sheila at spamcop.net Mon Jun 18 19:26:50 2001 From: sheila at spamcop.net (Sheila King) Date: Mon, 18 Jun 2001 23:26:50 GMT Subject: Sorting Apache Log Files References: Message-ID: On 18 Jun 2001 15:55:53 -0700, lenny.self at qsent.com (Lenny) wrote in comp.lang.python in article : : I was planning on loading each of the log files :into a list and then sorting the list. Unfortualy, I am unaware of :how to do that when the value I wish to search on isn't at the :beginning of the line. I need to search on Apache's date string. How about this? Create a list of tuples, where the tuple is: (datestamp, full_line) So, as you put each line from the log into the list, grab the datestamp from the line, make a tuple and then sort the list on the first element of each tuple? -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From sholden at holdenweb.com Wed Jun 27 13:46:15 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 27 Jun 2001 13:46:15 -0400 Subject: KDE and Windows References: <993660235.135465@seven.kulnet.kuleuven.ac.be> Message-ID: Both Tkinter and wxPython are available for both the environments you mention. Their respective merits have been endlessly debated before your question arose, so a search of Google should give you some help. regards Steve -- http://www.holdenweb.com/ "NightOwl" wrote in message news:993660235.135465 at seven.kulnet.kuleuven.ac.be... > Is it possible to develop a GUI which runs in Windows aswell as in KDE with > the same code ? I don't want to have to re-write all code just because I use > an other OS ... ? (Not using the COM-functions of Windows). > > > From tundra at tundraware.com Sun Jun 24 16:40:01 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 24 Jun 2001 20:40:01 GMT Subject: Is this a true statement? References: Message-ID: <3B364F79.F20EFAB0@tundraware.com> "Steven D. Majewski" wrote: > Be careful, Tim! > > David was very precise in his wording and we were talking about a > specific example with no precise requirements. ( Somebody one said > that vague requirements are easy to fill -- for a *perfectly* vague > specification, any program will suffice! ) > > [ See my other posts for my concession. ] > > I don't retract the statement that the fact that you can compute > any computable function in any Turing complete does not mean that > you can *DO* the same thing in any language. > > The one is a theoretical statement that has a formal proof. > The other is a practical statement that requires a empirical proof. > ( "DO" means to perform. ) > > If you disagree, I'll be happy to provide a challenge task for you > to perform that will leave you mired in the "Turing Tar-pit" ! > > -- Steve Majewski Well, I'll certainly stipulate that there is a difference between the definition of a language and its implementation which could lead to practical limitations. Similarly, there are also clearly algorithms which operate only "in principle" in any language: the NP-Complete problems leap to mind here. I also have no doubt that there are some things that are highly impractical to "do" in Python and that you can also find such an example for any language. (As you point out, part of the problem here is a precision problem.) However, in principle at least, all T-C languages do exactly the same things or they wouldn't be T-C. I think your argument hinges more upon what is practical to do vs what is possible in principle. For instance, I would guess that any problem you threw my way to toss me into the Turing Tar Pit *does* have a solution in Python - it would just be really complex and ugly (and not worth doing). So, the real difference is one of how the language is *implemented*, not how it is defined (assuming it is T-C). For example, in my previous post, I suggested you could embedd a Python runtime in the kernel and thereby write driver code in Python - this has nothing to do with language per se, but rather how it is realizes. In any case, I will humbly admit to going off on a theoretical tangent when the original poster was probably asking a practical question about what we can "do" with Python... But to the larger point of the original poster's question: I cannot conceive of ANY reason to use C++ for ANYTHING and I've felt that way from the day Stroustrup first exposed it to the rest of us. It is an abomination on the face of programming, there were and are much better choices if you insist on using OO (which I do not think is the Silver Bullet is has been proclaimed to be), and it has the worst of all worlds: the complexity of an OO infrastructure, the ease of self-annihilation of a systems language, and a syntax so awful as to be virtually unreadable. The answer I should have posted to the original poster should have been: For most people, most of the time, and with the exception of some systems programming problems, Python will "do" what C++ will. It will require less effort by the programmer, will be less prone to bugs as it is written, and will be more maintainable in the long run. For computationally-intensive problems, the Python programmer may have to replace selected sections of code with hand optimized code written in some more runtime-efficient language such as C or even assembler. This preceding is not just a comment on the virtues of Python so much as it is a condemnation of C++. Any number of languages can (mostly) "do" what C++ does, only better, faster, and with fewer bugs: Eiffel, Java, Visual Basic are all in that category IMHO... -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From jeff at ccvcorp.com Wed Jun 27 13:22:25 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 27 Jun 2001 10:22:25 -0700 Subject: Should I use a dictionary? References: <9h91pb$e3k$1@panix6.panix.com> <9h9ckq$nf$1@apollo.csd.net> <9hc2m2$gtf$1@news.service.uci.edu> <9hca9i$dmb$1@cubacola.tninet.se> Message-ID: <3B3A1651.3EE97769@ccvcorp.com> Gustaf Liljegren wrote: > "As Kosh said, it will improve performance to do the sorting with integers. > You're right that it may be confusion, but I think a comment in the right > place will prevent that. :-) After doing the sorting, the integer is to > be transformed into a date again, using the mkdate function: > > d = time.mkdate((date[:4],date[5:6],date[7:8],date[9:10],date[11:12])) > > The remaining question is if the time saved on sorting integers is more than > the time it takes to convert from and to a date before and after sorting. > I'll try this later today. Any particular reason to recreate the date, instead of grabbing it out of the message again? I would think that leaving the original date intact, and using a strptime()'d copy of it as your sorting index, would be the best solution. Then you can throw away the sorting index once the list is sorted, and you still have a useable date in your data. Of course, if you'd still need to convert to a different date format than your source data, the benefits of doing this would diminish considerably.... Jeff Shannon Technician/Programmer Credit International From jmarshal at mathworks.com Sat Jun 16 11:36:30 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 16 Jun 2001 15:36:30 GMT Subject: call-by-reference (was Re: Any other Python flaws?) References: Message-ID: <9gfudu$7q3$1@news.mathworks.com> Tim Peters wrote: > I usually say Python does "call by object". ... Way to confuse the issue with new terminology :) From BrianQ at ActiveState.com Tue Jun 12 17:42:37 2001 From: BrianQ at ActiveState.com (Brian Quinlan) Date: Tue, 12 Jun 2001 14:42:37 -0700 Subject: Reference Counts & Extensions.. In-Reply-To: Message-ID: <003801c0f388$996e5320$b503a8c0@activestate.ca> Alex wrote: > > Will this cause a memory leak? Should I be doing this: > > It's probably still prudent to worry about this if you have the time, > but I had the impression that with garbage collection in > python2.0, you > didn't have to. You do have to! The garbage collector in CPython 2.0 will free cyclic memory references but it cannot free objects whose reference count is simply too high. How could it? It doesn't have any way of inspecting your C code to see if you really wanted that object to stay around or if it is safe to collect it because you lied when incrementing the reference count. From owen at astrono.junkwashington.emu Tue Jun 19 12:36:39 2001 From: owen at astrono.junkwashington.emu (Russell E. Owen) Date: Tue, 19 Jun 2001 09:36:39 -0700 Subject: PEP 255: Simple Generators References: Message-ID: <9gnv2o$its$1@nntp6.u.washington.edu> In article , "Tim Peters" wrote: >[Russell E. Owen] >> This sounds like an interesting and really useful proposal. However,a >> few details are worrisome to me: > >You should catch up with the discussion on the Python-Iterators list (as >mentioned in the PEP announcement), where these have already been discussed >several times. I'll only give brief summaries here. > >> * A generator looks like a function until you find the "yield" statement >> inside. I think this will make the code much harder to read. One keyword >> buried anywhere in a function totally changes its behavior. If a >> generator acted like a function until it hit "yield", this wouldn't be >> so bad, but it sounds as if generators have enough significant >> differences (such as restrictions on and a changed meaning for return) >> that they are very different beasts. >> >> I'd much rather see a declaration up front that this is going to be a >> generator. E.g. add a new keyword such as "generator". > >Who would this help? Seriously. There's nothing special about a generator >to a caller, except that it returns an object that implements the iterator >interface. While the latter is important to know, there are many ways to >construct iterators in 2.2 without using generators at all. This is better >communicated via documentation (e.g., make the first line of the docstring >"Generate ..." instead of "Return ..."). > >On the other end, someone modifying the generator isn't going to miss that >it *is* a generator: all the control flow will focus on feeding >intermediate results to yield statements. IOW, you worry too much . In my opinion, "use the documentation", "if you are modifying it then you'd better know what it does", "it'll be clear from context" are all red flags. That sort of thinking leads to confusing write-only code. Since a generator is very different than a function, why not mark it as such right up front? >> * The unusual use of "return" and the associated restriction of no >> expression list. What "return" means in a generator is "raise StopIter", >> not return. I personally really dislike using a keyword for multiple >> vaguely similar purposes. Look at "static" in C++ for an example of >> where this can lead. > >"return" means "I'm done" in any kind of function, generator or not. You >can raise StopIteration instead if you feel you must, but then you're >focusing on an implementation detail, and that's not helping anyone. Guido >appears to feel quite strongly about this one, so if you want to push it I >suggest finding a better analogy than C++'s (over)use of static. I agree that revealing the internal implementation is bad. I disagree that return is reasonable, though it is much less of a concern if a generator doesn't look like a function right up front. >I'll note that in Icon, "yield" is spelled "suspend", and "return >expression" is allowed, meaning "I'm done, but I have one last useful value >to suspend with". It's possible Python may grow that meaning too, but it >was thought better to keep it more restrictive at first. Makes sense. I like the icon design, but one can always add complexity later. -- Russell From bernhard at intevation.de Sat Jun 30 16:28:20 2001 From: bernhard at intevation.de (Bernhard Reiter) Date: 30 Jun 2001 20:28:20 GMT Subject: PEP scepticism References: <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> Message-ID: <9hlcp4$eiphi$2@ID-89274.news.dfncis.de> In article , Guido van Rossum writes: > Andrew Kuchling writes: > >> It's also a matter of where effort is expended for the most benefit. > Thanks, Andrew. That was a very good point you made in an otherwise > "same-old-same-old" thread. Having started the topic I cannot remember the original point having been made ever before. And I explicitly wrote that I did not want to discuss the advantages and disadvantages of certain features again. :) Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) FSF Europe (fsfeurope.org) From greg at cosc.canterbury.ac.nz Wed Jun 20 02:21:42 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 20 Jun 2001 18:21:42 +1200 Subject: PEP 255: Simple Generators References: Message-ID: <3B3040F6.58E6D4C8@cosc.canterbury.ac.nz> Carsten Geckeler wrote: > > But I have to rely that a single "return" raises a StopIter exception when > I want to catch it. You don't have to catch it -- the for-loop implementation does that. This part of the proposal is exactly right, IMO -- the generator uses "yield" to produce values, and returns normally when it has finished. Any exceptions involved are an implementation detail, hidden behind the scenes. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From nperkins7 at home.com Tue Jun 12 10:56:35 2001 From: nperkins7 at home.com (Nick Perkins) Date: Tue, 12 Jun 2001 14:56:35 GMT Subject: Recursive algorithms anyone? References: <1f0uhtgmhb0vlud6pof6i4mctqjdq8l2eu@4ax.com> Message-ID: "Kirby Urner" wrote in message ... > E.g. >>> additem(1,[1,2,[3,4,[5,6]],7]) > [2,3,[4,5,[6,7]],8] > def additem(x): if type(x) is type([]): return map(additem,x) else: return x+1 From tundra at tundraware.com Wed Jun 27 12:39:25 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 27 Jun 2001 16:39:25 GMT Subject: Indexing Into A Tuple Message-ID: <3B3A0C32.EF179DAE@tundraware.com> Hmm, it works, but I don't understand why. I have a tuple of tuples defined as follows: MyTuple = ( ("a", "b"), ("c", "d")...) Now, I want to iterate across it to print the pairs. This works as I would expect: for x in MyTuple: print x[0], x[1] But so does this: for x, y in MyTuple: print x, y Intuitively (and, obviously, incorrectly) it seems to me that the 1st time through, the second example should return: x=("a", "b") and y=("c", "d") Instead, it returns x="a", and y="b" just like the first example. Why? -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From aleaxit at yahoo.com Sun Jun 10 10:57:33 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 10 Jun 2001 16:57:33 +0200 Subject: New guy question References: Message-ID: <9g01v4020s7@enews2.newsguy.com> "Glen Mettler" wrote in message news:DfKU6.130092$I5.33794657 at news1.rdc1.tn.home.com... ... > I went to the MS DOS Prompt ("Command") and typed in python alook.py and got > an error message: Bad command or file name. Then the directory with Python.Exe (e.g. C:\Python21 in a typical Python 2.1 installation) is not in your PATH. You can remedy this differently in different versions of Windows. Easiest in NT/2000 (and I assume XP): Start/Settings/Control Panel/System/ Environment -- you'll find a PATH among the user and/or system environment settings, a list of directories separated by semicolons (;), and you can add c:\Python21 to it. Easiest in 95/98/ME: edit c:\Autoexec.bat. It probably already exists and already includes a PATH statement of a form such as PATH c:\foo;d:\bar;%PATH% edit it to PATH c:\Python21;c:\foo;d:\bar;%PATH% or if no such statements were there, create one PATH c:\Python21;%PATH% Rebooting after such setting-change is not strictly necessary for NT (it is for 95) but is advisable anyway. There are alternatives (that involve editing the Windows registry, for example) but I think they're less simple. Alex From mixo77 at usa.net Thu Jun 14 01:50:09 2001 From: mixo77 at usa.net (mixo) Date: Thu, 14 Jun 2001 07:50:09 +0200 Subject: Sockets Message-ID: <3B285091.8B0C506D@usa.net> I create a socket and listen for connections in try and , close socket in a except. Also, within the try I have a while loop that I create a socket once a connection has been made to a client., and close the socket once data has been sent to a client. Now, my problem is, if at least one connection is made, when the server dies, I can't restart it as I can't create a new socket for the server.. Is there something that hapens when a connection is accepted that prevents a restart of the server? P.S I am using the socket module. From danny.ayers_nospam at btinternet.com Wed Jun 13 10:22:36 2001 From: danny.ayers_nospam at btinternet.com (Danny Ayers) Date: Wed, 13 Jun 2001 14:22:36 GMT Subject: UML from Python? Message-ID: <3b27769a.16649510@news.btinternet.com> Hi, I was wondering whether there were any tools around for generating UML or similar diagrams from Python source. Cheers, Danny. From feedback at netlcr.de Thu Jun 14 11:07:44 2001 From: feedback at netlcr.de (Florian Scholz) Date: Thu, 14 Jun 2001 17:07:44 +0200 Subject: cPickle - stack overflow Message-ID: <3B28D340.F1A9AC17@netlcr.de> hi, when i save a class with cPickle.dump(net,file); i get a stack overflow in the case there is too much data in the net-class. i also tried picle, but that's the same. (the data is a network...) is there a work- around, or something to change the behaviour ? cPickle is very comfortabel, and so i like to use is. tnx for any hints, From llothar at mailandnews.de Sat Jun 9 20:15:30 2001 From: llothar at mailandnews.de (Lothar Scholz) Date: Sun, 10 Jun 2001 02:15:30 +0200 Subject: Python Shareware? References: <9fr2jm$16v$1@brokaw.wa.com> Message-ID: <7ve5its4q2jirnp5f0htn1drokfq8nqqsv@4ax.com> On Sat, 9 Jun 2001 09:19:08 -0400, D-Man wrote: >On Sat, Jun 09, 2001 at 04:09:11AM +0000, Brad Bollenbach wrote: >| "Jonathan Gardner" wrote in message >| news:9fr2jm$16v$1 at brokaw.wa.com... > >| > There is another benefit to you of free software: If you are >| > really good at programming, you can show off with your GPL'ed >| > code, and use that to get into a company that is willing to pay >| > you to code stuff for them. You can't show off code that is >| > closed-source, like code from, say, your previous job. So, with >| > your GPL'ed code (which has been tested and developed by people >| > who are actually interested in using it, so it will be much better >| > than anything you can write on your own) you can claim a lot of >| > credit for it, and demand $100,000 or more for salary. If they >| > think you are crazy, tell them to read the code and try the >| > software. If they want to produce software like that, then they >| > have to hire you. >| >| Other than the really big names (a la Torvalds, GvR, Wall et al.) this >| rarely happens. At the very least, when good programmers get good jobs, it's >| because they are very bright people who have a lot to offer, not because of >| the license they choose for their software. Realistically, most PHB's have >| less than half-a-clue about what the GPL is (*hyuck* *hyuck* isn't that >| onnuh them globawl pawsitioning thingmahoots?) > >I think Jonathan's point was mainly "how are you going to convince a >company that you really are a good programmer if you can't show them >any of the code you have written?" (aside from discussing personal >beliefs wrt the problems with shareware). If your code is GPL'd (or, >more precisely, free / open source) then you _can_ show it to a >prospective future employer, but if all the code you have written is >either owned by a previous employer, or part of your closed-source >shareware then you can't show them. The main issue, apart from issues >with the way shareware works from a business perspective, is to create >a way to demonstrate that you are a good programmer. > >-D > If it's my code i can show them to any emplyer i want ! I can choose my friends and companies. From justsurfn2004 at aol.com Mon Jun 11 15:19:00 2001 From: justsurfn2004 at aol.com (Justsurfn2004) Date: 11 Jun 2001 19:19:00 GMT Subject: Newbie Message-ID: <20010611151900.11318.00004174@ng-mp1.aol.com> Hello, im a newbie to all this programming stuff and i just downloaded python and i want to know how to use it. Can anyone reccommend any websites for me to go to on how to use it? My email address is pcgamesrule at hotmail.com Thanks From aleaxit at yahoo.com Tue Jun 12 03:57:09 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 12 Jun 2001 09:57:09 +0200 Subject: metaclasses -- aka Don Beaudry hook/hack (was RE: Why should i use python if i can use java) References: Message-ID: <9g4i0l14r3@enews2.newsguy.com> "Skip Montanaro" wrote in message news:mailman.992303958.16837.python-list at python.org... > > James> I have found is that "the hook" doesn't seem to be complete in > James> the sense that only the "class" statement seems to know about the > James> hook. > > Jim Fulton's ExtensionClass stuff knows about the Don Beaudry hook. > ExtensionClasses are used in Zope (you can get the source from any Zope > distribution) and by the latest Python wrappers for Gtk. The Boost Python Library (www.boost.org) for extending Python with C++ also uses the hook (if I understand it correctly:-). Alex From rumjuggler at cryptarchy.org Fri Jun 29 19:44:19 2001 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Fri, 29 Jun 2001 23:44:19 GMT Subject: PEP scepticism References: <3dbsn71iac.fsf@ute.cnri.reston.va.us> Message-ID: On Fri, 29 Jun 2001 15:56:21 -0400, "Tim Peters" wrote: [CPAN-for-Python] >The real question is why someone else hasn't popped up to do these things. I thought Sean Reifschneider DID pop up and do those things. Has Swalow development stopped? -- Barnabas T. Rumjuggler Yet when he came down from the mountain, he had not gained any wisdom. In no way had he been able to solve the riddle of this story. And he had lost his faith. But he had discovered that he had an affinity for Dixieland music. -- Joe Frank, "The Road to Calvary" From ocschwar at mit.edu Fri Jun 1 20:02:14 2001 From: ocschwar at mit.edu (Omri Schwarz) Date: 01 Jun 2001 20:02:14 -0400 Subject: (WIBNI) Grail, the Python web browser. Message-ID: I see that the Sourceforge project Grail comes with the disclaimer "we don't have time to work on it anymore, so knock yourselves out, guys) (basically). But it seems like a nice piece of work. Would any Pythonist be interested in restarting the project? -- Omri Schwarz --- Timeless wisdom of biomedical engineering: "Noise is principally due to the presence of the patient." -- R.F. Farr From mwh at python.net Tue Jun 12 22:52:14 2001 From: mwh at python.net (Michael Hudson) Date: 13 Jun 2001 03:52:14 +0100 Subject: is c faster? References: <9ftlpv029hk@enews2.newsguy.com> <3B2550F5.ED7F54D@home.net> <9g4jh20712@enews2.newsguy.com> <3B26AE16.7186810B@home.net> Message-ID: Chris Barker writes: > Alex Martelli wrote: > > whatnot. I think this is the kind of benefit one > > might expect from a simpleminded 'compiler':-). > > That's why we need a not so simple minded compiler. I have a friend that > keeps harping on the fact that LISP can be as fast as C and as dynamic > as Python. Why can't Python do that? IHMO: Money, and brains. The people who developed the techniques for optimizing lisp working for Symbolics et al. were very very smart, and were paid to work on such things. There's just not the money in the Python industry. Also, Common Lisp isn't as, or rather is differently dynamic to Python. For instance you can't redefine (any of the many spellings of) equality in CL; if yow wanted to do that you'd be more likely to shadow cl:= inside your package, and this has got to be easier to spot at compile time. Cheers, M. -- I'm a keen cyclist and I stop at red lights. Those who don't need hitting with a great big slapping machine. -- Colin Davidson, cam.misc From twofingersalute at atl.mediaone.net Sun Jun 10 23:25:08 2001 From: twofingersalute at atl.mediaone.net (myself) Date: Mon, 11 Jun 2001 03:25:08 GMT Subject: tummy compile Mandrake 7.2 References: <20010608.214013.1469262009.16325@K7.atl.mediaone.net> <20010609.104451.1884661237.1229@K7.atl.mediaone.net> <3B24154E.C70211ED@student.gu.edu.au> Message-ID: <20010610.232821.1789366143.1225@K7.atl.mediaone.net> In article <3B24154E.C70211ED at student.gu.edu.au>, "Joal Heagney" wrote: > myself wrote: > >> thanks for your reply! well I guess I could have phrased the >> expat-devel Q a little better- if devel is a build require, why isn't >> it included, or offered as a separate srpm in ftp directory? Or are you >> saying I need the "standard" expat pkgs in addition to the tummy ver? >> (but that's confusing, as >=1.1-3tummy implies that there *is* a >> 1.1-3tummy devel available)?? WRT line 246, surely someone here will be >> able to shed some light for both our benefits- I haven't seen many >> problems go unsolved in this ng (hint-hint). Actually I don't expect a >> necessarily specific answer, just a clue where to look would suffice >> (hopefully). > > It depends on how the tummy-expat spec file was built. Some packagers > just throw everything in together, binaries, libraries, documents and > header files into a package called . Others split up a build into a > .rpm, -docs.rpm, -devel.rpm and maybe even a > -lib.rpm As well as removing the buildprereq: expat-devel, you can > also mung it by changing it to expat only (I.E. get rid of the -devel > bit.). > ok, but Sean didn't seem to indicate this was the source of the error, but perhaps I misunderstood. I installed expat as per instructions on tummy site- I probably don't "need" it at all at this point- first I need a *basic* understanding of the language :-). Just out of curiosity, doesn't the -devel part install the header files necessary to build the actual expat support? >> OTOH, this gives me an opportunity to actually post here- this really >> is an _excellent_ group! > > If you want a prebuilt rpm for Mandrake 7.2, I could always email you my > build, but I understand if you want to build it from source. > thanks for the offer. But if you don't mind, since you've sucessfully built for LM7.2, perhaps you could give me a few pointers on how? I really don't care if I use srpm or source- my prob. w/ srpm is detailed to best of my ability in this thread, failure w/ source in a later thread. Since Sean already pointed out that my prob. w/ srpm seems to be a Mandrake thing, unless you have further advice on this, would you mind checking out later post (source compile) and perhaps helping there? For all I know I don't even really have a problem, maybe this is the way the install is supposed to act, but so far no response on that topic..... BTW, did you update or do you have 1.5.2 and 2.1 coexisting? I'm trying to do latter, being fearful 2.1 will break something if I replace 1.5.2. Comments? thanks a heap! > Lotsa pythonieering, > From PoulsenL at capecon.com Fri Jun 8 09:52:39 2001 From: PoulsenL at capecon.com (PoulsenL at capecon.com) Date: Fri, 8 Jun 2001 09:52:39 -0400 Subject: More fun with Derivatives of Matrices Message-ID: I have a very complex function for which I would like to take the first derivative. The problem is that involves the inverse of a Matrix. DerivVar chokes on Numpy's inverse because it is not implemented in Python. Upon some advice from Konrad Hinsen I retrieved the matfunc.py module with high hopes. Unfortunately, these hopes were soon dashed due to the absence of the __float__ attribute in the DerivVar object. Any advice would be greatly appreciated. C = matfunc.makeMat([[DerivVar(1.0,0),2],[3,5]]) >>> C.mmul(C.inverse()) Traceback (most recent call last): File "", line 1, in ? File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py", line 183, in inverse return self.solve( eye(self.rows) ) File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py", line 143, in solve if isinstance(b,Mat): return makeMat( map(self.solve, b.tr()) ).tr() File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py", line 145, in solve x = self._solve( b ) File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py", line 139, in _solve Q, R = self.qr() File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py", line 127, in qr v, beta = R.tr()[i].house(i) File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py", line 81, in house v = Vec( Elementwise([0]*index).concat(self[index:]) ).normalize() File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py", line 72, in normalize def normalize( self ): return self / self.norm() File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py", line 71, in norm def norm( self ): return math.sqrt(abs( self.dot(self.conjugate()) )) AttributeError: DerivVar instance has no attribute '__float__' >>> Loren Poulsen -------------- next part -------------- An HTML attachment was scrubbed... URL: From samschul at pacbell.net Sun Jun 3 23:20:35 2001 From: samschul at pacbell.net (Samuel Schulenburg) Date: 3 Jun 2001 20:20:35 -0700 Subject: Embedded 'C' problem? References: <3b195197.147691268@wa.news.verio.net> <3b1a6f43.220823978@wa.news.verio.net> Message-ID: > Your application did seem a little odd, but I suppose it was > a test thing ;-) The application was a real world requirment, where I have an embedded C dll that allows me to execute python script command to a SCSI disk drive, via the windows ASPI interface. This C dll has routines to perform hex memory dumps of the data returned from a drive i.e. "30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 0123456789ABCDEF" The problem was that I could log correctly the above string using fprintf, but trying to pass the same string to python caused the problem. Thanks to all the replies I was able to see the need to escape the python deliminators single quote, double quote and back slash. Again thanks to everyone who spotted the solution. Samuel Schulenburg From Israel at lith.com Tue Jun 26 20:19:10 2001 From: Israel at lith.com (Israel) Date: Wed, 27 Jun 2001 00:19:10 GMT Subject: An approach to building a networkable boardgame... Message-ID: <3b392559.9658458@news.lith.com> Hello... I'm in the design phase of translating a Boardgame, my wife and our exchange student made up this year, to a python app that people can play over the internet. I was wondering what the best appoach to this would be. I could make this a webrowser based thing where the server does a lot of the work, or I could make this a downloadable python distribution that has the ability to connect two players, one of which would be the server and the other would be the client.. I'm really not sure as this is a challenge I'm setting myself to help me to better understand not only Python but programming in General. Any opinions, suggestions, free associations?? ~Israel~ From phawkins at connact.com Fri Jun 29 22:24:41 2001 From: phawkins at connact.com (phawkins at connact.com) Date: 29 Jun 2001 22:24:41 -0400 Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: <3B2EADB0.9DBC6FC8@earthlink.net> <3B2EC98E.FE0F1B6E@earthlink.net> Message-ID: I'd be careful about public archives on Yahoo, the Yahoo TOS says Yahoo owns anything posted to public spaces. >>>>> "MH" == Michael Hudson writes: MH> "Kevin Altis" writes: >> Argh, yes you do need to register, sorry. MH> It says in the heading under "group settings" "Archives for members MH> only" which suggests that there's some other option (& in fact I know MH> there's some other option - MH> qv. http://groups.yahoo.com/group/python-list ) -- Patricia J. Hawkins Hawkins Internet Applications, LLC From vvainio at karhu.tp.spt.fi Thu Jun 21 06:16:54 2001 From: vvainio at karhu.tp.spt.fi (Ville Vainio) Date: 21 Jun 2001 13:16:54 +0300 Subject: Managing Python sources in CVS & whitespace Message-ID: Are there any issues with Python sources and CVS (I'm thinking of the whitespace thing here)? Do the diffs or merging branches get screwed up? Are there any special considerations? This is a kind of thing that should appear in the FAQ... -- Ville Vainio - http://www.tp.spt.fi/~vvainio - ICQ #115524762 Wild geese have no intention to cast a reflection Water has no mind to assume their form From new_name at mit.edu Tue Jun 12 16:57:15 2001 From: new_name at mit.edu (Alex) Date: 12 Jun 2001 16:57:15 -0400 Subject: Reference Counts & Extensions.. References: <6fvV6.248430$Z2.2868464@nnrp1.uunet.ca> Message-ID: > Will this cause a memory leak? Should I be doing this: It's probably still prudent to worry about this if you have the time, but I had the impression that with garbage collection in python2.0, you didn't have to. Alex. From cjc26 at nospam.cornell.edu Sat Jun 16 20:07:49 2001 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Sun, 17 Jun 2001 00:07:49 GMT Subject: PostgreSQL, Python and BLOBs References: <3B2775C0.D2460A6C@cybertec.at> <3B278D55.8A370BD5@cybertec.at> Message-ID: * Hans-J?rgen Sch?nig menulis: | Thank you ... | Do you know an easier example? | I don't know how to insert BLOBs yet. It works for me with C but I think | some information is missing in the Python docs. In PostgreSQL you can only access large objects within a transaction, i.e. you need to do something like this: import pg db = pg.connect(dbname="...") db.query("BEGIN;") lo = db.locreate(pg.INV_READ|pg.INV_WRITE) lo.open(pg.INV_WRITE) lo.write(binary_data) lo.close() db.query("INSERT into blob_table VALUES (%d);" % lo.oid) db.query("COMMIT;") Note the two lines 'db.query("BEGIN;")' and 'db.query("COMMIT;")' -- if you leave those out then the call to lo.open() will fail. -- Cliff Crawford http://www.sowrong.org/ "Cliff, you're a god. I want to bear your child." -- Ed From tim.one at home.com Thu Jun 21 23:22:13 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 21 Jun 2001 23:22:13 -0400 Subject: Odd behaviour from re In-Reply-To: <9gubmh$6cd$1@tyfon.itea.ntnu.no> Message-ID: [Magnus Lie Hetland] > I'm looping through a string with match - thinking > that if I specify a starting position beyond the end > of the string, no match would be returned... But > the darn thing still matches, and gives me both > a start and an end at position len(string)... Is > this intentional? If your regexp can match an empty string, yes. String slices beyond the end of a string are defined to return an empty string in all contexts: >>> s = "abc" >>> s[3:100] '' >>> > ... > but that's not how it is with the string-method find... Not so, but of course string.find can (just like regexps!) find *only* an empty string then: >>> "abc".find("", 3) 3 >>> From sdm7g at Virginia.EDU Mon Jun 25 10:25:19 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Mon, 25 Jun 2001 10:25:19 -0400 (EDT) Subject: Is this a true statement? In-Reply-To: Message-ID: On Sun, 24 Jun 2001, Tim Peters wrote: > Hmm. Has anyone in this thread written a device driver? If not, I'd like > to point out that PEP 255 generators are ideally suited to the task . Only in assembler. ( I have written a Python program to contol the scan of an electron microscope, but I had to cheat and use an extension written in C -- but I wouldn't actually call that a "device driver" -- to me that term has connotations of kernel space and interrupt vectors -- I'ld call it a device controller. ) However, now that I've been told that all programming languages are equivalent, I'm going to write my next device driver in Intercal. ( I already have to say "Please" to my computer to get it to work sometimes -- I might as well put it in the source code! ) -- Steve Majewski From arisen at start.no Fri Jun 22 06:29:31 2001 From: arisen at start.no (=?ISO-8859-1?Q?Andr=E9?=) Date: 22 Jun 2001 03:29:31 -0700 Subject: Python COM: Unable to create server-side object. References: Message-ID: Mark Hammond wrote in message news:... > > This means that _public_methods_ does not exist. > Argh! Thanks, i would never have spotted that! An argument for pair programming i guess. Well, it works fine now :-) Btw, thanks to PythonWin i've been able to use Python on succcessfully on several projects at work, and i've never had any problems with it. Good stuff! :-) -- Regards Andr? Risnes From MrTJC at TimChristian.com Wed Jun 20 11:07:42 2001 From: MrTJC at TimChristian.com (Tim Christian) Date: 20 Jun 2001 10:07:42 -0500 Subject: [repost] Embedding menus in frames prevents alt+key defaults? References: Message-ID: >>>>> "Tim" == Tim Christian writes: Tim> Howdy, I'm learning how to use Python and Tkinter using Mark Tim> Lutz' _Programming_Python_ (2nd edition) and have run into an Tim> odd side effect. It may be Tk specific (OT?), but I'll ask Tim> here anyway. Lutz discusses the relative merits of embedding Tim> menus into top level windows versus frames. The frames route Tim> seems like a good idea for reusable objects. However, after Tim> I embed menus into frames, I notice that the menu items, Tim> though underlined, are no longer selectable via the Alt key Tim> (eg, Alt+F doesn't bring up the "File" menu, though the "F" Tim> character is underlined). Is this typical behavior? Perhaps Tim> it's just a problem under my development platform (Windows Tim> 2000, Python 2.1)? Tim> Thanks, Tim. From PoulsenL at capecon.com Wed Jun 6 10:55:38 2001 From: PoulsenL at capecon.com (PoulsenL at capecon.com) Date: Wed, 6 Jun 2001 10:55:38 -0400 Subject: need help inverting DerivVar array (Numpy/Scientific Python Q uestion) Message-ID: Scientific provides a derivable object which can be operated upon. The problem is that it does not implement an invert method and I was wondering if there was a workaround. -----Original Message----- From: Robin Becker [mailto:robin at jessikat.fsnet.co.uk] Sent: Wednesday, June 06, 2001 5:21 AM To: python-list at python.org Subject: Re: need help inverting DerivVar array (Numpy/Scientific Python Quest ion) In article , PoulsenL at capecon.com writes > Are you trying to differentiate the inverse of a matrix? What are DerivVars? > I am having trouble inverting an array of DerivVar objects.? Here is > the code and error: > > ? > > >>> a = > Numeric.array([[DerivVar(-2.5,0,1),DerivVar(.45,1,1)],[DerivVar(5.5,2,1),Der ivVar(-4.5,3,1)]]) > > >>> Numeric.sum(a) > > array([(3.0, [1, 0, 1]) , (-4.0499999999999998, [0, 1, 0, 1]) > ],'O') > > >>> Numeric.invert(a) > > Traceback (most recent call last): > > ? File "", line 1, in ? > > AttributeError: DerivVar instance has no attribute '__invert__' > > ? > > Any help would be greatly appreciated. > > ? > > Thanks, > > ? > > Loren Poulsen -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list From heikowu at ceosg.de Fri Jun 29 10:26:15 2001 From: heikowu at ceosg.de (Heiko Wundram) Date: Fri, 29 Jun 2001 16:26:15 +0200 Subject: OT: Python user groups Message-ID: <9hi32d$58a$06$2@news.t-online.com> Hello to all! Could anyone direct me to a list of registered Python User Groups in Europe? (preferably accessible via HTTP ;)) Thanks in advance! Heiko W. From BrianQ at ActiveState.com Fri Jun 29 14:22:30 2001 From: BrianQ at ActiveState.com (Brian Quinlan) Date: Fri, 29 Jun 2001 11:22:30 -0700 Subject: Augmented Assignement (was: Re: PEP scepticism) In-Reply-To: Message-ID: <000c01c100c8$75c7c490$b503a8c0@activestate.ca> Tim Peters wrote: > PS: If "+=" isn't explicit, I have a hard time understanding what > "explicit" means. Maybe that Python should be coded at > bytecode level, so that STORE_FAST (and friends) always punch you > in the face? How about we take the performance hit, remove them all together, and save our faces :-) From eppstein at ics.uci.edu Thu Jun 21 11:49:25 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Thu, 21 Jun 2001 08:49:25 -0700 Subject: PEP 255: Simple Generators References: <3B303FE5.735A5FDC@cosc.canterbury.ac.nz> <90C65699Dgmcmhypernetcom@199.171.54.194> <16074dce.0106201512.5459e720@posting.google.com> <3B3181D1.BFB73057@cosc.canterbury.ac.nz> Message-ID: In article <3B3181D1.BFB73057 at cosc.canterbury.ac.nz>, Greg Ewing wrote: > Your proposal might work in the case where the recursion > involved is tail-recursion, but using tail-recursion in > place of iteration is a functional idiom that doesn't fit > very well in Python, IMO. I'm sorry, this was a little too densely packed for me, could you expand it? Why is tail recursion somehow unPythonlike? Or, more to the point, why should it remain that way? If it's merely that it is implemented inefficiently (i.e. piling up unnecessary stack frames) then that can be fixed, no? And anyway we were discussing a situation (PEP255) where stack frames are not really at issue. I have been using Python a very short time, but one thing I like very much about it is its spirit of allowing all sorts of programming idioms -- it doesn't force object orientation etc down your throat but it allows you to write each program the way it makes the most sense. If a program makes the most sense tail-recursively, why should that be discouraged? -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From BPettersen at NAREX.com Wed Jun 20 14:35:12 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Wed, 20 Jun 2001 12:35:12 -0600 Subject: Dynamically importing modules Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D4A2@admin56.narex.com> > From: Jared Lee Peterson [mailto:jared at difinium.com] > > I have a quick question about importing modules. I would > like to have a > script that in sitting in a directory and in this directory I want to > have sub directories that represent modules to that script. However > I do not want this script to have any prior knowledge of what modules > may exist. So I would like for the script to look at it > current working > directory and then try to load each module that does exist through the > use of import. But I can not seem to figure out how to get import to > work for me. Because I need to be able to loop through a list > (os.listdir()) of the subdirectories/modules that the script has found > and try to import them. Does anyone have any suggestions? Does this > even make sense? you can use the __import__ function to import a module based on it's name (as a string), ie. the following two statements are equivalent: mymodule = __import__('mymodule') and import mymodule -- bjorn From emile at fenx.com Wed Jun 27 18:19:43 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 27 Jun 2001 15:19:43 -0700 Subject: list of dictionaries References: <3B3A4B97.5F4EB1F1@cc.gatech.edu> <9hdjmt$dk0ki$1@ID-11957.news.dfncis.de> <3B3A58A1.AE09529@cc.gatech.edu> Message-ID: <9hdme5$di2n4$1@ID-11957.news.dfncis.de> It is appended. That's why you see two copies of the same dict in the list. To get different dicts in the list, you *must* create new dicts for each entry. Otherwise, each entry simply points to the same dict. You can use the {}.copy method for this data, but be forewarned that you need to be careful for nested data structures. dict_entry['a'] = a2 dict_entry['b'] = b2 dict_entry['c'] = c2 dict_entry['d'] = d2 sample_list.append(dict_entry.copy()) Note that even here, a new dict is created, as you can verify with print type(sample_list[0]), id(sample_list[0]) print type(sample_list[1]),id(sample_list[1]) HTH, -- Emile van Sebille emile at fenx.com --------- "George Thomas" wrote in message news:3B3A58A1.AE09529 at cc.gatech.edu... > Hi, > I wanted to avoid the creation of a new dict per entry. What I haven't > been able to understand is why the "updated" dict is not appended. > > ------------- Emile van Sebille wrote: > > > > Note changes below > > > > -- > > > > Emile van Sebille > > emile at fenx.com > > > > #This creates a single dict that gets appended each time > > #by creating a new dict for each entry as per below > > #you don't really need this anymore. > > > regards > ------------------------------------------------------------ > George Thomas > ------------------------------------------------------------ > reduce (lambda c,d:chr(ord(d)-2)+c, 'ofcpqkekhhC"zwpkN"fgtgyqR/pqjv{R') > ------------------------------------------------------------ From chrishbarker at home.net Thu Jun 14 16:17:11 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 14 Jun 2001 13:17:11 -0700 Subject: Passing back an array from an extension module? References: <9fqqqo$1p3e$1@newshost.nmt.edu> <9fr8mp$219g$1@newshost.nmt.edu> <9frdtl$25gh$1@newshost.nmt.edu> <3B214BCF.8393A2AC@home.net> <9g8r9m$66v$1@newshost.nmt.edu> Message-ID: <3B291BC7.19A04F22@home.net> Bob Greschke wrote: > All right, stop twisting my arm. :-) I'll give it a try. Actually, > the initial reading of the file in C goes very quickly. I didn't mean to be that forcefull! > I can run everything on the same file and it eventually crashes on > about the 6th or 7th reading. I am free()ing up the C array, but I > suspect that I have to do something with the reference count of the > tuple that I create. Maybe? I'm still not clear on all of that. Check your memory use after each reading to make sure this is what's casueing your crash. I don't remember what OS you are running this on, but on Linux, I can have a massive memory leak, and the process will get large enough to swap like crazy and slow the system to crawl, but it still doesn't crash. You may have another problem. It is confusing to keep track of when you need to DECREF. It sounds like this should not be required, as you are passing it back to Python. It should get DECREFed by Python when it is no longer referenced there. What I sometimes do is create my Arrays in Python and pass them into the extension to be populated. That way you don't have to deal with the reference counting at all. > I'll still need to call the C stuff to read, and decode, the file. How complex is the decoding? You might be surprised what you can do with NumPy. Of course, if the C code is allready written,this should be easy! Good luck, -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From aleaxit at yahoo.com Wed Jun 6 12:35:03 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 6 Jun 2001 18:35:03 +0200 Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> <3b19393d.703539923@news.okstate.edu> <9fgkci0gdu@enews2.newsguy.com> <3b1ce391.2243151@nntp.sprynet.com> <9fj24r01hpj@enews1.newsguy.com> <3b1e3e18.160819@nntp.sprynet.com> Message-ID: <9flm3p01p1n@enews2.newsguy.com> "David C. Ullrich" wrote in message news:3b1e3e18.160819 at nntp.sprynet.com... ... > Answer the question instead of only replying > to the parts you feel like replying to. This thread is long enough without going around commanding each other what to answer, but for once I'll make an exception:-) [not fully responding to this post -- yet -- but only to the 'mandatory' parts:-)]: > _Do_ you think it makes sense to talk about > the probability that the first digit of pi > is 3? Yes! Or rather it makes sense to talk of P(first digit of pi is 3 | y) for any y representing (if I recall De Finetti's formula correctly) "a self-consistent set of beliefs about the state of the Universe". I do not believe that it REALLY makes sense to talk about any P(x), rather than P(x|y), unless the y can reasonably be taken as given by the context. I do realize that for some strange reasons this De Finetti idea is not universally accepted (yet:-), but it IS widely accepted enough among scholars of probability theory that I don't think I need to defend it in depth -- or is my hope unfounded and do we need to branch off into ANOTHER huge subthread about whether _unconditional_ probabilities "exist"...?-) > (Or rather: Does it really make sense > to say that the probability that the first > digit of pi is 1/10?) It surely "makes sense" (like many false statements can "make sense") but may be false for any y, if we carefully constrain all relevant definitions (i.e., it is quite possible that no y such that the P(x|y), for the x we've been talking about, which is self-consistent in the De Finetti sense). Alex From mal at lemburg.com Tue Jun 19 07:56:19 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 19 Jun 2001 13:56:19 +0200 Subject: Comprehensive Python Archive Network References: <87n1762ddv.fsf@penguin.aktivist.ru> Message-ID: <3B2F3DE3.C782C3E7@lemburg.com> Wartan Hachaturow wrote: > > Hello, everybody. > > Yes, yes, I know I'm not the first to post with such a subject :) > But maybe we should write such a thing for the benefit of everyone, > and cut off one of the strongest Perler's argument against Python? There are plans to work into this direction and some progress has already been made, e.g. Python's distutils enable easy installation of Python Add-ons, ActiveState's .ppm archive is very close to a CPAN for Python and there are other tools on the way. The basic building blocks are all readily available, what missing now is infrastructure to get the ball rolling and then some standard tools in the Python core which allow to download, compile and install Python extensions with the same ease as Perl's CPAN module. AFAIK, ActiveState will contribute its PPM tools back to Python, so those may become what we all have been dreaming of the last few years ;-) -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From barry at digicool.com Tue Jun 12 20:28:28 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Tue, 12 Jun 2001 20:28:28 -0400 Subject: Getting "Recieved:" headers from rfc822 Message objects? References: Message-ID: <15142.45996.275622.997117@anthem.wooz.org> >>>>> "GL" == Gustaf Liljegren writes: GL> Python 2.1, regarding the rfc822 module: GL> I have found some mails in my inbox that have no "Date" GL> header. So instead, I though about using the date in the last GL> recieved header of a Message object. How do you recieve the GL> "Recieved: " headers? I have tried GL> m.getallmatchingheaders('recieved'), but it returns an empty GL> list. Oops, check your spelling there. It should be "received". Cheers, -Barry From offer at findmybusienss.com Thu Jun 28 05:05:18 2001 From: offer at findmybusienss.com (offer at findmybusienss.com) Date: Thu, 28 Jun 2001 05:05:18 Subject: Sell Your Business? Place your ads... Free Offer Message-ID: Save your money & time!! Place your LISTINGS or AD for FREE and Find your buyers.. -------------------------------------------------------------------------------------------------- Businesses for sale, Investment Properties, Franchises, Homebased businesses, Distributors, Wholesales, M&A, Other Special Businesses... Visit our website http://www.findmybusiness.com **30 days free trial for 4zip.net the broker's website listing services** Find our features and maximize your business while you save a lot on your high cost of marketing. Check our service at http://4zip.net --------------------------------------------------------------------------------------------------- He will never let you down, Trust in the Lord with all your heart... From just at letterror.com Thu Jun 21 03:44:06 2001 From: just at letterror.com (Just van Rossum) Date: Thu, 21 Jun 2001 09:44:06 +0200 Subject: PEP 255: Simple Generators References: Message-ID: <3B31A5C6.1699306C@letterror.com> Roman Suzi wrote: > I've not been heard or commented. It seems that everybody is happy with > simple generators (and discuss syntax) while I am not. > > I dare think that proposed gen/generator/def-yield thing is doomed to be > phased out in some future Python version, because it creates frozen > context for very narrow task of providing generators and in the future (I > hope) there will be normal parallel programming in Python, which will > solve the problem simply and efficiently. > > I am not against PEP 255. The feature is cool. But it is a feature which > requires new keyword, new function class, etc. In one way or another, it > modifies function and it implicitely lead to the same syntax beasts > as in C++/Java/Pascal. > > PEP 255 is not Pythonish enough. > > Let's better think about more general things like: > * co-routines (which "generator" is an example, if I understand it > correctly) > * adding parallel programming paradigm (which is even better > for long term), where objects live their lifes and could serve > other objects as generators, gatherers, services, etc. > > OOP was made easy by python. I hope parallel programming > to be added and made equally easy, without all those > modifiers and zillion of new keywords and modifiers. All interesting points, but the point of "Simple Generators" is that they were implementable in CPython without a major overhaul of the interpreter. For the things you suggest you need Stackless Python, which *is* indeed a major overhaul of the interpreter... Just From greg at cosc.canterbury.ac.nz Tue Jun 26 23:35:44 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 27 Jun 2001 15:35:44 +1200 Subject: Pythoin MUD (PyMUD?) References: <9gqq3t$hvs$1@brokaw.wa.com> <3B36D220.52C5CB86@cosc.canterbury.ac.nz> Message-ID: <3B395490.89B5AA18@cosc.canterbury.ac.nz> Courageous wrote: > > It's peudo-preemption, really. Time spent in external modules > and the like is not preempted, so unexpected behaviors can > arise. Presumably wizards won't be allowed to call code in arbitrary extension modules, so it shouldn't be too much of a problem in this case. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From mal at lemburg.com Tue Jun 12 10:10:26 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 12 Jun 2001 16:10:26 +0200 Subject: Compiling Python2.1 under HP-UX with threads ? References: <3b20c450$1@hpb10302.boi.hp.com> Message-ID: <3B2622D2.AB94C8A1@lemburg.com> Peter Stoldt wrote: > > Hello, > > Philipp Jocham wrote: > > > On Thu, 07 Jun 2001 20:08:00 +0200, M.-A. Lemburg wrote: > > >I am having trouble compiling Python 2.1 under HP-UX 11.00 > > >with threads. > > > > > >Even though the compile runs fine (ok, termios and _curses fail > > >to compile, but I don't need those), the test suite fails to > > >pass all tests which try to use threads. The error I get is: > > Compiling Python 2.1 on HP-UX 11.00 works for me. I have used > the following compler: > > B3899BA B.11.01.07 HP C/ANSI C Developer's Bundle for HP-UX 11.00 (S700) > B3911DB B.11.01.06 HP aC++ Compiler (S700) > > I found a solution for the _curses problem. For that, a Python header > file has to be changed. In py_curses.h exchange the line with > > #include > > with > > #include Could you give me a compiler #define to use for #ifdef which identifies the machine ? I would like to check in a fix for this. > This will include a matching header file for HP-UX 11.00. To get _termios > to work, I have no idea. BTW, do you have a binary for this available somewhere (I guess a simple .tar.gzu of the /usr/local/ subdirs for Python would work) ? Thank you, -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From Eugene.Leitl at lrz.uni-muenchen.de Wed Jun 13 04:53:00 2001 From: Eugene.Leitl at lrz.uni-muenchen.de (Eugene Leitl) Date: Wed, 13 Jun 2001 10:53:00 +0200 (MET DST) Subject: humans and logic In-Reply-To: Message-ID: On Tue, 12 Jun 2001, Rainy wrote: > >> Try writing 1,388,034,093 in binary on a piece of paper > > 101,0010,1011,1011,1011,1000,0010,1101-ly y'rs -- Jan > > That's much more unweildy, isn't it? It's not the representation, it's the operation. Try adding these things manually, or, worse, multiplying, or dividing them. Lots of little bitsys to keep track of. If you want it compact, or succinct, that's what octal or hex is for. Decimal needs not apply, because you can't just take three or four groups of bits, and convert them back and forth via lookups. And of course the question is not for people using the numbers daily (though binary should be the first number system taught in school), but for digital hardware (hint: it's called digital for a reason. No, it hasn't got fingers, guess again). -- Eugen* Leitl ______________________________________________________________ ICBMTO : N48 10'07'' E011 33'53'' http://www.lrz.de/~ui22204 57F9CFD3: ED90 0433 EB74 E4A9 537F CFF5 86E7 629B 57F9 CFD3 From danny.ayers_nospam at btinternet.com Wed Jun 13 11:13:40 2001 From: danny.ayers_nospam at btinternet.com (Danny Ayers) Date: Wed, 13 Jun 2001 15:13:40 GMT Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> Message-ID: <3b27823b.19626140@news.btinternet.com> On 12 Jun 2001 08:39:37 -0700, thinkit wrote: >humans should use a power of 2 as a base. this is more logical because it >synchs with binary, which is at the very heart of logic--true and false. it is >more natural perhaps, to use decimal--but logic should, and will, win out. the main use of numbers is in numerical operations such as counting, not logical ones what would tbe he advantage in using powers of 2 be anyway? isn't the idea of computers for them to do this kind of work for us? From writeson at earthlink.net Mon Jun 18 01:06:42 2001 From: writeson at earthlink.net (Doug Farrell) Date: Mon, 18 Jun 2001 05:06:42 GMT Subject: Python 2.0 and wxPython 2.0 Message-ID: Hi all, I have Mandrake 8.0 installed on my system and I'm a little confused. I went to try and install wxPython (which I downloaded from the website) and the system tells me it's already installed, which is great! However, I downloaded the demo and I can't seem to run any thing there. Does anyone know what's going on and how I might fix this? I'm a relative linux newbie... Thanks in advance, Doug Farrell From kbk at float.ne.mediaone.com Mon Jun 11 16:16:47 2001 From: kbk at float.ne.mediaone.com (Kurt B. Kaiser) Date: Mon, 11 Jun 2001 20:16:47 GMT Subject: Newbie References: <20010611151900.11318.00004174@ng-mp1.aol.com> <3A9V6.11832$Dd5.3141345@ruti.visi.com> Message-ID: Amazon says June 13, you can pre-order. Definitely worth getting the 2nd ed. Most of the "beginner" books are *way* too wordy! It would be better to be concise like Beazley and take the space to teach more general programming ideas. From ullrich at math.okstate.edu Sat Jun 2 10:50:27 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sat, 02 Jun 2001 14:50:27 GMT Subject: random References: Message-ID: <3b18f6e4.3608974@nntp.sprynet.com> On Fri, 1 Jun 2001 17:56:26 -0400 (EDT), "Steven D. Majewski" wrote: > > >On Fri, 1 Jun 2001, David C. Ullrich wrote: > >> On Thu, 31 May 2001 19:52:28 -0400 (EDT), "Steven D. Majewski" >> wrote: >> > >> >On 31 May 2001, Mark 'Kamikaze' Hughes wrote: >> > >> >> "Anyone who considers arithmetical methods of producing random numbers >> >> is, of course, in a state of sin." -John Von Neumann >> >> >> >> Unless you have random-number-generating hardware, you don't really >> >> have truly random numbers. >> > >> >That's what I was always taught, however in the light of >> >Gregory Chaitin's work or randomness in arithmetic: >> > >> > >> > >> >JVN may have been wrong. >> >> ??? There's a _lot_ of stuff there. >> >> Could you give us a hint regarding exactly what work >> of Chaitin's shows we can get "truly random" numbers from >> arithmetic algorithms? > >Pick any one at random, David! I've read some of his stuff. I didn't see anything there that gave me any indication to me that JVN was wrong. When you say something follows from his work it would be a lot more credible if you could be specific. >( Starting from the top down isn't a bad strategy either. ) > >I'm not sure that there is a practical method for a RNG there, Well then I have no idea whatever what you could mean by saying that he's shown JVN wrong. >and I certainly don't grasp it all, but Chaitin asserts that >mathematics is essentially a random process. And you ought >to be able to get random numbers out of a random process -- >right ? Maybe yes, maybe no - the word "random" is awfully slippery. I've seen a lot of misquotation of Chaitin in various places. "Mathematics is essentially a random process?" I'd want to see a much more precise statement of that before deciding that it meant that you could get a perfect RNG from an arithmetic algorithm. (We must be talking about "perfectly random", right? Because if we're talking about "somewhat random" it's clear we can get that from arithemtic. >Some of the interest from Physicists in Chaitin's work >is that if mathematics is a random process, then that may be >at the root of quantum randomness. *IF* you can believe his >assertion, then that source of randomness is easier to swallow >than the idea that the act of abservation causes some magical >effects. That's interesting. Seriously. (But it's a comment about how physics works, I don't see any direct relevance...) > The arguments that go with that assertion are more than I >could summarize here, even if I did grasp it all myself. > >From the Nature article "Randomness everywhere" >: > >| This recent work reinforces the message of algorithmic information >| theory that randomness is as fundamental and as pervasive in pure >| mathematics as it is in theoretical physics. In our opinion it also >| gives further support to `experimental mathematics', and to the >| `quasi-empirical' view of mathematics which says that although >| mathematics and physics are different, it is more a matter of degree >| than black and white Yeah. I was hoping you could give a hint _how_ his work supported what you said, not just a quote of his "opinion" on the matter. >> A physical RNG can have the property that one cannot make >> any prediction about the value of the next bit even given >> _complete_ information about how the numbers are being >> generated. An arithmetic algorithm with this property seems >> obviously impossible - if you know the algorithm and you >> know the current state of the RNG you can predict the >> next number... whatever the algorithm is, someone with all >> this information can devise a "randomness test" that the >> RNG will fail miserably. Or so it seems. > >Chaitin's Omega number is basically the probability that a >randomly generated program will halt -- which is undecideable, >but can be approximated experimentally and observing it -- >each binary digit of that probability is random. I don't think this is quite accurate. (I _know_ it's at least a huge oversimplification; for example there's no such thing as the probability of a program halting until we specify how the programs are generated.) But even if this is exactly right I do not see _at_ _all_ how it shows that JVN was wrong and a perfect arithmetic RNG is possible! >But, how this ties into a basic randomness at the root of >mathematics is more than I can grok yet, but some of it is >in "Randomness and Complexity in Pure Mathematics" >: > >| One normally thinks that everything that is true is true for a >| reason. I've found mathematical truths that are true for no reason at >| all. This is the sort of statement that leads some mathematicians to scoff at the guy somewhat. >|These mathematical truths are beyond the power of mathematical >| reasoning because they are accidental and random. If he has proofs then they're not beyond mathematical reasoning. If he has no proofs then they're not "discoveries", they're at best _conjectures_. >| Using software written in Mathematica that runs on an IBM RS/6000 >| workstation, I constructed a perverse 200-page algebraic equation with a >| parameter N and 17,000 unknowns: >| >| Left-Hand-Side(N) = Right-Hand-Side(N). >| For each whole-number value of the parameter N, ask whether this >| equation has a finite or an infinite number of whole number >| solutions. The answers escape the power of mathematical reason because >| they are completely random and accidental. Saying that the results escape the power of mathematical reasoning is just silly. If Mathematica derived the results correctly then the results are not beyond the power of mathematical reasoning, (and if Mathematica is just guessing then they're not "results".) What can be is that the results are "incompressible", in that there's no way even in theory to predict in advance what the answer is for a given N... >| This work is an extension of famous results of Gdel and Turing using >| ideas from a new field called algorithmic information theory. There's no doubt whatever that Chaitin has done a lot of extremely important and fundametally interesting work. I didnt mean to ask about that, what I was wondering was how his work led to a perfect arithmetic RNG, as you seemed to be claiming (and regarding which I haven't seen anything yet that seems like an explanation.) There's no doubt that he's done a great deal of fabulous and important stuff. But it seems clear to a lot of people that informal statements about what he's done are very often simplified beyond the point where they really make sense. It's like with Godel's incompleteness Theorem(s), as long as he mentions the subject: Extremely basic and important. And you see people all the time deducing things from the incompleteness theorem that simply do not follow at all - reasoning by very weak analogy, thinking it's a mathematical proof because the weak analogy involves something that's been proven. I know in any case that when you see claims about Godel and Chaitin in places like sci.math what's claimed is often ridiculous (and often is not something he said). Hence my skepticism when I see statements about what does and what does not follow from his work. (You said you don't see exactly how all this leads to an RNG, right? Fine then... note that I never claimed it didn't, just that I can't see how it does.) >-- Steve Majewski > > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From aleaxit at yahoo.com Sat Jun 16 10:08:20 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 16 Jun 2001 16:08:20 +0200 Subject: VI References: <3B278900.5828FB59@Lugoj.Com> <9gaunm$mth$3@brokaw.wa.com> <9gdol3$8i7$1@brokaw.wa.com> Message-ID: <9gfp6b117jh@enews1.newsguy.com> "Jonathan Gardner" wrote in message news:9gdol3$8i7$1 at brokaw.wa.com... ... > Does this mean "Vim" is "vee eye em" or "vim"???? "vim" is a perfectly good Latin word (in the accusative case) meaning "strength". As it happens it's ALSO a perfectly good English word (no doubt a late formation from the Latin one, mid-1800's) meaning "robust energy and enthusiasm"... Alex From meyer at kampsax.dtu.dk Thu Jun 14 19:22:59 2001 From: meyer at kampsax.dtu.dk (Jonas Meyer Rasmussen) Date: Fri, 15 Jun 2001 01:22:59 +0200 Subject: All functions from self and inherited classes References: Message-ID: <9gbgvb$mjg$1@eising.k-net.dk> Hey! Maybe this will help you? class a: def a( self ): print "a" class b( a ): def b( self ): print "b" class c( b ): def c( self ): print "c" class d( c ): def d( self ): print "d" class x( d ): def x( self ): print "x" def test( self ): clss = self.__class__ bases = clss.__bases__ print 'self:', clss.__name__, 'methods:', dir( clss ) print 'inherited' while bases != (): base, = bases print 'class:',base.__name__, 'methods:', dir( base ) bases = base.__bases__ test = x() print "initiating test" test.test() It works fine here(2.0)...although if you are going to use multiple inheritance there will probably be some problems, because the touple bases will then not be ( base1, ) but ( base1, base2... ) and i dont know how to handle that ;) McEinar From MarkH at ActiveState.com Mon Jun 11 07:28:37 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Mon, 11 Jun 2001 11:28:37 GMT Subject: What "Tim Peters" really looks like References: Message-ID: <3B24AB8B.7000507@ActiveState.com> Jarno J Virtanen wrote: > I've actually seen "Tim Peters" live. "He" was walking with Guido > in the XXXXXXXXXXX park in XXXXXXXXXXX. I didn't have a camera with > me, but I did do a drawing of the scene. For only a short period of > time was "Tim Peters" visible, so all the nuts and bolts may not be > exactly in their place. Here's the picture: > > http://www.hole.fi/jajvirta/gandtim.jpg That is excellent! This newsgroup never ceases to amaze me :) I-can-see-a-new-tshirt ly, Mark. From alankarmisra at hotmail.com Fri Jun 15 17:49:33 2001 From: alankarmisra at hotmail.com (gods1child) Date: 15 Jun 2001 14:49:33 -0700 Subject: str smarter than round? References: Message-ID: <25b2e0d9.0106151349.7282976f@posting.google.com> Cowabunga! Yep that link most definitely answered my questions. Thanx Tim. > Congratulations! You've elected yourself to be a guinea pig for reading > this new Tutorial Appendix: > > http://python.sourceforge.net/devel-docs/tut/node14.html > > never-ask-a-question-unless-you-really-want-an-answer-ly y'rs - tim From ullrich at math.okstate.edu Mon Jun 25 09:57:18 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 25 Jun 2001 13:57:18 GMT Subject: Is this a true statement? References: <3b34939b.410758@nntp.sprynet.com> <3b35ed3b.1401529@nntp.sprynet.com> <3b360fba.10233292@nntp.sprynet.com> Message-ID: <3b373e35.290229@nntp.sprynet.com> On Sun, 24 Jun 2001 13:29:24 -0400, D-Man wrote: >On Sun, Jun 24, 2001 at 04:12:49PM +0000, David C. Ullrich wrote: >[snipped long discussion] > >When I read the original question I got the impression that "write a >device driver in Python" meant "A person sits down at a console with a >text editor, writes some Python code that implements the device's spec >in terms of the driver API specified by the kernel". David Ullrich is >taking "write a device driver in Python" to mean "output the bytes >that comprised the finished driver to a file that the kernel can load >and execute". In the former meaning, no a device driver can't be >written in Python. In the latter, then yes, python has the ability to >write binary data to a file. It also goes, then, to say that one >could write the driver using only a hex editor (or the "front panel", >for Steve :-)). To be fair, I think that using Python to write a device driver would be a lot easier than using a hex editor. But never mind that: >I think that most people thought the first interpretation of the >original question was obivous and thus did a poor job of answering >David's questions. At the pratical level, (as David also says) a >device driver can't be written in Python. At a more theoretical >level, David is correct, almost. A device driver isn't a file, but a >sequence of bytes in memory in the kernel's address space :-). This seems like a reasonable place to insert my retraction: Ohhh... So _that's_ what we mean. Well of course no, we cannot write a device driver in Python! The problem was a single huge misconception - I was right when I continually speculated that I was missing something. I don't think that what I was missing was ever explained, which is not a criticism, what I think is that people reasonable assumed I understood the one thing that I didn't. Can you write a GIF in C? I imagine people would say yes - I know I would, or would have until recently. If someone says you can write a GIF in C they mean that you can use C to write a program that writes GIF's. If someone says you can write a PDF file in C they mean that you can write a program that writed PDF files... Believe it or not, I was taking "write a device driver in C" to mean "use C to write a program that writes device drivers". The huge misconception at the bottom of all this was I didn't realize that a device driver (typically) _is_ a program, in the same format as typical executables (or close enough to the same format that a C compiler with an appropriate switch will ouput a device driver instead of a program.) The idea that we actually meant "write C code which the compiler will turn into a device driver" did not occur to me, simply because I was thinking of device drivers as something on a totally different level from ordinary executable programs. (Yes, people did try to explain the difference between writing a program and writing a file. But since I thought that we were taking "write a device driver" to mean "write a program that writes a device driver" the explanations made no sense to me...) Who said you should never attribute to trollery that which can be explained by awesome ignorance? Wasn't trollitudinously blurring the distinction between "write a file" and "write a program" as was suggested. Also wasn't actually unable to comprehend simple English. The "distinction" between "write a file" and "write a program" _is_ blurry, since when we write a program we _are_ writing a file. The relevant distinction is between "write a program which writes a file" and "write a program". Certainly did not mean to be blurring _that_ distinction, rather I've been wrongly thinking through all of this that we were talking about writing programs which write files. So maybe I am unable to comprehend simple English. Or maybe "write a file" is an incomprehensibly simple way to say "write a program that writes a file". In any case, I don't think that the answers I got were all that bad, assuming that I was aware of things that it would be quite reasonable to assume I must be aware of. Almost everything almost everyone has said makes much more sense than it did yesterday. Never mind. >I hope the original poster now understands the answer to his question >and not too many people have been upset by the miscommunication in the >discussion. I figured all along I must be missing something. >-D > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From matthew.russell at securetrading.com Wed Jun 13 05:47:49 2001 From: matthew.russell at securetrading.com (Matt Russell) Date: 13 Jun 2001 02:47:49 -0700 Subject: memory profiling References: Message-ID: I am also interseted to see how this achieved! Does the resource.c module need to be compiled into the python interpreter before such memory leak chasing can be performed successfully or is their another tool that can help? TIA. Matt Geoffrey Gerrietts wrote in message news:... > I'm sure this question has been asked and answered a few times now, but I > can't seem to find an answer for it, either in the FAQ or in the newsgroup > archives. > > How do people do memory profiling in python? I'd like to compare, for > instance, the memory consumed by a dictionary-based approach versus a list > or tuple based approach. I've seen the tool in mxTools, sizeof, which is > nice, but that doesn't seem to address the big "random" factor, the empty > pointers in the dictionary. > > Does a tool exist that will let me measure this in some reasonably > straightforward way? Are other people doing any kind of memory profiling, or > do folks just "eyeball it"? Am I missing something blatantly and plainly > obvious that I should be embarassed for not seeing? > > Thanks in advance, > --G. > > --- > Geoff Gerrietts > Software Engineer, HomeGain.com > 510-655-0800 x4320 From bokr at accessone.com Mon Jun 11 23:47:45 2001 From: bokr at accessone.com (Bengt Richter) Date: Tue, 12 Jun 2001 03:47:45 GMT Subject: Misaggregation of symbols from disparate namespaces? was: Re: Global in multiple files References: Message-ID: <3b257b6e.257706041@wa.news.verio.net> On Mon, 11 Jun 2001 16:27:34 +0200, "Alex Martelli" wrote: >"Roman Suzi" writes: [...] [unattributed quote, sorry] >> >"Do the simplest thing that could possibly work", because >> >"you ain't gonna need it" (where "it" is the rich, complex, >> >over-engineered, over-designed very general solution:-). >> >> That is why Microsoft systems still have those funny >> A:, B:, C: letters before file paths ;-) > >Nope, this has absolutely nothing to do with it. Backwards >compatibility with externally-visible interfaces to previous >releases of your software (and older software you choose >to be similar/compatible to: CP/M, in Microsoft's case) are >(as should be obvious -- I'm amazed I have to point this out) >a completely different issue. > "A:, ..." accidentally poked one of my hot buttons ;-) IMHO "A:, B:, C:" prefixes for file paths are evidence of a serious problem with name spaces: Applications have to handle symbols that should really only be the business of the OS and special utilities. You will note that Unix has a mount function to keep '/dev/hdc0' and such out of path strings like '/home' etc. The conventions of using container names (file names and extensions) to identify and carry type information about the content is also dangerous IMHO, however convenient. Magic numbers and special prefixes embedded in the data at least survive a simple renaming of the container. (I'm tempted to ramble about what we could do with one or two sectors as data prefix instead of a few bytes, but I'll restrain myself ;-) Python name spaces seem to be a product of thoughtful design, so I wonder if it has succeeded in avoiding the pitfalls of misaggregating symbols from different kinds of namespaces in what should be abstract path representations. From ullrich at math.okstate.edu Sun Jun 24 09:37:44 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 24 Jun 2001 13:37:44 GMT Subject: Is this a true statement? References: <3b34939b.410758@nntp.sprynet.com> Message-ID: <3b35ebc3.1024709@nntp.sprynet.com> On Sat, 23 Jun 2001 09:36:13 -0500, "Chris Gonnerman" wrote: >----- Original Message ----- >From: "David C. Ullrich" >> ??? I thought a device driver was just a file, hence a finite >> sequence of bytes. You can certainly use Python to write an >> arbitrary sequence of bytes to a file. No doubt it's much easier >> in C++ (or rather in typical implementations of C++?) to decide >> _what_ sequence of bytes to write to that file, but if we're >> talking about what's literally possible and impossible I don't >> see how writing a device driver can be impossible in Python. > >Writing TO a device driver is easy enough... the previous poster >was talking about writing the DRIVER in Python. No OS I'm aware >of takes device drivers in any languages other than assembler, C, >and/or C++. I wasn't aware that any OS used device drivers in _any_ of those languages! I would have thought that compilers and assemblers accepted code in those languages, and OS's used the files that were output by those compilers and assemblers. Seriously. _Is_ a "device driver" something other than a file? If it _is_ something other than a file I wish someone would say so. If a device driver is just a file then I don't see how the OS can possibly know or care how that file was generated. David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From graham at coms.com Mon Jun 25 04:48:23 2001 From: graham at coms.com (Graham Ashton) Date: Mon, 25 Jun 2001 09:48:23 +0100 Subject: Defining accessor methods Message-ID: I've been trying to come up with an idiom for defining accessor methods, as outlined here: http://www.object-arts.com/EducationCentre/Patterns/AccessorMethods.htm I don't think that my knowledge of Python is quite there yet though. I've got as far as: def my_attribute(self, val=None): """Set or return the _my_attribute instance variable.""" if not val is None: self._my_attribute = val return return self._my_attribute I'd then have code that would use it, like this: print "value is: %s" % self.my_attribute() self.my_attribute("13") print "value is now: %s" % self.my_attribute() The obvious problem with the above is that you can't use it to set an attribute to None. The method itself also reads rather strangely. Is there a better (concise) way to write it so that you can actually pass in None, and not set the attribute's value to None inadvertently whenever you try and access it? I thought of having get_my_attribute() and set_my_attribute() but I don't really like the idea because it just makes code that uses them more (unnecessarily) long winded, and the author of the above URL advises against it (though they don't say why). I've not noticed any use of accessor methods in sample Python code (i.e. in books/tutorials); do people use them much in Python? Thanks. -- Graham From fredrik at pythonware.com Tue Jun 5 04:25:40 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 05 Jun 2001 08:25:40 GMT Subject: Wadda ya mean it's not defined? Impossible Error? References: <3B1C2727.D9E746CB@dsl.ca> Message-ID: <8I0T6.1933$WW6.228052@newsb.telia.net> David Gilbert wrote: > I'm getting what appears to be an impossible error. Here's a code > snippet: > > def parseLogs(paths, custs): > > ipfRecord = re.compile("^([0-9]+)[ ]+([0-9]+)[ > ]+([0-9a-z]+)([+-])") > > last = {} > for i in range(len(paths)): # Create start times > ... and so on. is that code cut and pasted from your actual program? the easiest way to get that error is to make a typo in the argument list, e.g: def parseLogs(path, custs): another way is to put the for loop inside another loop, and put a "del paths" somewhere in there... if the error persists, cut out as much stuff as possible from the parseLogs function, and post the whole thing. From ljohnson at resgen.com Wed Jun 20 14:55:05 2001 From: ljohnson at resgen.com (Lyle Johnson) Date: Wed, 20 Jun 2001 13:55:05 -0500 Subject: for i in References: Message-ID: > what was overloaded in UserList so its items could be extracted when you do > > for i in UserList([1,2,3]) > ? To emulate sequence types (like lists and tuples) you can overload the __len__() and __getitem__() magic methods. See "Emulating sequence and mapping types", section 3.3.4 of the Python Language Reference Manual, for more details. From aleaxit at yahoo.com Wed Jun 20 02:40:05 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 20 Jun 2001 08:40:05 +0200 Subject: Loading select queries into objects References: Message-ID: <9gpgde02rc6@enews1.newsguy.com> "Graham Ashton" wrote in message news:WyRX6.1453$h45.9142 at news.uk.colt.net... ... > {'col1': 234, 'col2': 'foo', 'some_col': 9473.0} > > No, my question would be how would I take the above dictionary and convert > it into calls to a col1(), col2() and some_col() methods (in the current > class). Assuming you mean "on the current instance", there is absolutely no need for eval & friends -- the following will do just fine: def applydict(self, adict): for name, value in adict.items(): try: method = getattr(self, name) except AttributeError: print "Warning: no method",name else: method(value) Alex From aleaxit at yahoo.com Mon Jun 4 04:28:17 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 4 Jun 2001 10:28:17 +0200 Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> <3B1A82DD.C4D78472@san.rr.com> <9fe2g302841@enews2.newsguy.com> <3B1AE07F.CEDA4A3A@san.rr.com> Message-ID: <9fflo812q4r@enews2.newsguy.com> "Darren New" wrote in message news:3B1AE07F.CEDA4A3A at san.rr.com... ...[snip: assertions on the deep properties of physical reality that I am not qualified to argue]... > > That's like saying that > > "perfect information" about an algorithm tells me only it's a good > > one, and gives me no information about the state it starts in. > > No, it's not. I'm not sure why you assert this. An algorithm is a > mathematical concept, and hence fully defined. Even in a finitistic definition of algorithm, there may still be parameters needed to describe it completely. > > > > I still haven't heard your definition of > > > > 'perfect' randomness, for example. > > > > > > Generally, this is something along the lines of: > > > Given all available information about the mechanism used to generate the > > > > "available" seems to play a rather crucial role here, then. > > No. "available" means "possible to be obtained in any way." What you So that the randomness of an existing system can suddenly change if somebody dies, for example? Because, e.g., part of the information about the system was only "available" by asking him (he had memorized it) -- with that information, in this thought-experiment, things were predictable -- now the designer dies, the information is not available any more, and it's not predictable anymore thus becomes 'random'? I would rather not use a definition of "perfect" that requires accounting for such factors -- considering human beings as parts of the system, knowing if they ever wrote somewhere down that information (it might still be 'obtained in some way' if I could root through their papers and maybe if I was able to decipher some private code they used -- or maybe not) or communicated it to someone else (maybe to their priest during confession?)... seems a rather shifty base for a mathematical definition. Why don't we follow De Finetti's lead? P(x) does not 'exist' per se, it's just a shorthand for P(x|y) where y is a 'mindset', a sum total of information about the word, that is being implicitly assumed. All probabilities are 'subjective' in the specific sense of depending on that y -- there is no 'perfect reference y' (God's all-knowing mind) that needs to be taken as an assumption -- as long as we fix y (ideally, explicitly) we can do all of our probability computations equally well. Now if you believe there is an ideal y such that all P(x|y) are 0 or 1 for that y, or if you believe it does not exist -- whether God plays dice or not:-) -- becomes irrelevant enough so we can do maths without first having to solve theological questions as a prerequisite. Isn't randomness (or "perfect" randomness) akin to probability in this? Or IS it just a theological issue, so that any hope of tackling it apart from theology is doomed? > > That would only leave the arbitrarily long sequence of generated > > bits and no other info? Fine, then: > > > > I don't think Chaitin's Omega meets this definition, since it is by > > > definition a single number than anyone can calculate equally well. It's one number PER each Universal Turing Machine, I believe. I do not know if from the first N bits of Omega you get enough information to reconstruct all parameters of the UTM in question so as to be able to compute the N+1-th bit, but I believe that part of the point is that you *don't*. > > But from Omega's first N bits, you get no hint at all that lets > > you predict its N+1-th bit "with > 50% accuracy". > > How did you get the first N bits? If you can calculate them, so can I. Say I have an idealized black box that was made for me by a demented but genial Transylvanian dwarf, who, unfortunately, has since deceased. I do know with certainty (he was a VERY trustworthy demented but genial Transylvanian dwarf) that what the box does each time I press the button is compute the next bit of Omega for some UTM -- alas, I don't know WHAT Universal Turing Machine encoding it uses, and the box with the "algorithm" (or effective procedure, whatever) is rigged so that any attempt to examine its innards will destroy it (I think my deceased friend didn't believe humanity was ready to learn how he made the infinite-precision registers that are such a crucial part of the machine's operation, and, you know, he may have been right after all). So, "all available information" is: this computes Omega for SOME UTM -- sadly, we don't know WHAT UTM that is. There, you have all _available_ information. Now (assuming you can't come and steal my treasured little black box -- it's well-guarded, I assure you... you don't want to brave the killer rabbit, for example, and that's just the start of it!), how are you going to calculate? I'll send you the first N bits, for any N, and you just need to give me the N+1-th one. Note that 'all available info' does include the algorithm, net of some numeric parameters. If I (oops, I mean my dwarvish friend) had used a "weaker" algorithm, say a linear-congruential generator, you would be well placed indeed in a totally similar situation (where you know 'the algorithm' but not the numeric parameter, e.g. the 'seed' as you put it). Analyzing the N bits for a high-enough N might suffice, etc. > > So, if the > > definition does not include the first condition, from the bits > > only you're not going to get any farther than from N tosses > > of an idealized coin. > > Sure. *I* can write an algorithm to calculate the bits of Omega. Then I For what UTM encoding, pray? > run my algorithm, see that the first N bits of its output matches the > first N bits of your sequence, and predict with very high probability > what the next bit is, right? I don't believe so -- I don't think those N bits let you reconstruct the UTM encoding being used. I hope I'll be more positive about it once I _have_ received and studied 'Exploring Randomness'. Until then, I can only hypothesize -- IF some amount N of bits was sufficient to let you reconstruct the UTM parameters, and therefore calculate the N+1-th bit, THEN I would agree that the Omega's randomness was bounded by N (<=N). IF no amount N of bits has this property, would you agree in turn as to the 'perfection' of the randomness (at least once the dwarf has died, or has irretrievably forgotten how the hep he DID build the darned algorithmic black box in the first place)? > If you calculate the first 100,000 bits of > Omega and give it to me, and you don't tell me that it's the first > 100,000 bits of Omega, and I think to try calculating the first 100,000 > bits of Omega and they match, then I guess the 100,001'st bit of Omega, > then I have a >50% chance of getting the next bit right. Again the UTM parameters loom large. At least until some ISO subcommittee comes up with a standardized Universal Turing Machine (or maybe the IEEE could do it, as for floating point?-)... > If, on the other hand, you run a random number generator based on > quantum radioactive decay, or you flip a coin 100,000 times, and it just > *happens* to match the first 100,000 bits of Omega, and I notice that, > and I guess the 100,001'st bit of Omega, then I have still only a 50% > probability of being right. I think the situation, looking at the bits only, would be the same in both cases. Now I'm starting to wonder if a UTM encoding (or an infinite set of possible such encodings, actually) could be found to "account" for ANY such given first-100,000-bits. Maybe not -- perhaps I cannot encode an UTM so that random self-delimiting programs for it have _any_ prespecified probability of halting (or at least to N bits' approximation). > This is why some people say that any given finite string cannot be > considered random or non-random by itself, without knowing how it's > generated. The 'infinity' aspects with which 'perfect randomness' seems to be imbued might surely account for that unwillingness to bestow the now-hallowed monicker 'random' onto any mere finite structure, I guess. I still think it's very useful to study the randomness of such finite sets, and apparently so do Chaitin and all other scholars in that field. However it was generated, that bitstring now has its own intrinsic properties. A man in the street might well call it 'pretty well-ordered' or 'rather random' -- and why should the word 'random' be pre-empted, so it has no meaning at all in this context, when a useful technical sense, that happens to match pretty well the way the man in the street would use the word, can be applied instead? Alex From rneely at home.com Wed Jun 27 02:07:26 2001 From: rneely at home.com (Rob Neely) Date: 26 Jun 2001 23:07:26 -0700 Subject: Dynamically deleting widgets and redrawing a GUI Message-ID: <6f0b3be9.0106262207.51aadaa4@posting.google.com> Hi, I am developing a small Tkinter application where I have a frame that contains one widget (button) for each file in a directory. One of the options is to be able to select some set of files (by selecting their buttons) and delete them. i.e. physically delete the files from the disk. At that point, I would like to "redraw" the frame with the buttons representing the deleted objects no longer there. Can anyone point me in the right direction on how to go about this? My closest attempt was a complete hack, and involved destroying the frame and reinstantiating it (thus forcing it to generate it's widget tree from scratch) - but I couldn't even get that to work too smoothly... If more info is needed, please let me know (I tend to ramble and lose people, so I'm purposefully trying to keep this short and sweet. :-)) Thanks in advance. --Rob From mitchell.morris at cingular.com Thu Jun 7 08:34:09 2001 From: mitchell.morris at cingular.com (Mitchell Morris) Date: 7 Jun 2001 12:34:09 GMT Subject: WHY is python slow? References: Message-ID: Steven Haryanto wrote in : > Although it is generally accepted that Python is slower than > Java/Perl/Ruby, a layman like me would be curious to know why > exactly this is so. In other words, why is the implementation > of a language like Ruby (which is on par with Python in terms > of 'everything is an object', strong reflection, dynamic > nature). > > My first guess would be the ubiquitous use of dictionaries? > > Steve > http://stevne.haryan.to/ > > Well, perhaps your population sample isn't actually representative. I, for one, don't believe that your speed ordering is accurate, and I would further postulate that few other people on this newsgroup would agree with you. My second observation is that constructing a group of languages that includes Java, Perl, and Ruby as members but doesn't include Python must be using a very fine discriminant indeed . As a single point of data, may I present the language-specific pages from Bagley's "Computer Language Shootout" . Each presents the finishing place for that language on each specific test. In addition, the average finishing place is calculated through an unspecified method (I'm assuming it's the arithmetic mean, but I'm not sure) in three categories: CPU usage, memory usage, and lines of code. Perl: CPU: 14, Memory: 17, LOC: 7 http://www.bagley.org/~doug/shootout/lang/perl/ Python: CPU: 17, Memory: 12, LOC: 7 http://www.bagley.org/~doug/shootout/lang/python/ Ruby: CPU: 18, Memory: 14, LOC: 5 http://www.bagley.org/~doug/shootout/lang/ruby/ Java: CPU: 12, Memory: 20, LOC: 15 http://www.bagley.org/~doug/shootout/lang/java/ Tcl: CPU: 19, Memory: 12, LOC: 12 http://www.bagley.org/~doug/shootout/lang/tcl/ OCaml: [my new favorite toy -- ed.] CPU: 3, Memory: 5, LOC: 10 http://www.bagley.org/~doug/shootout/lang/ocaml/ Under this ranking, Java is barely faster than Perl which is even more barely faster than Python which just as barely faster than Ruby which is (once again) only barely faster than Tcl. Mr.Bagley neglected to provide summary statistics for inter-language comparisons on these pages, so I have to provide my own: Language Mean Std.Dev -------- ---- ------- Perl 13.6 6.2 Python 16.6 3.8 Ruby 18.0 4.6 Java 11.5 4.2 Tcl 20.8 4.0 (Warning: undocumented math and unwarranted jumping-to-conclusions ahead) Notice the large standard deviation for Perl's results, especially compared to the standard deviation of the other datasets. This suggests that there are some outliers in the Perl dataset which are skewing the mean, and that generally the other languages perform more consistently over these tests. In addition, the mean/std.dev comparisons suggest that we can't yet conclude that Perl actually finshes ahead of either Python or Ruby in the general case, but they do suggest that we can tentatively say that Perl finshes ahead of Tcl for these tests. (Isn't it wonderful how statistics lets you be so certain about making such sweeping statements? <0.1 wink>) I have my own reservations about the applicability of this shootout to anything but Usenet arguments, but since that *IS* what we're having I'm delighted to wield it . if-you'd-only-claimed-Jython-was-slow-ly y'rs, +Mitchell P.S. Keep in mind that all this is based on the finishing placements in the elements of the test suite, not the raw performance numbers which I didn't feel like extracting from all over the entire website. Jiggery-pokery, indeed! From hgg9140 at fred.local Mon Jun 4 18:54:49 2001 From: hgg9140 at fred.local (Harry George) Date: 04 Jun 2001 15:54:49 -0700 Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> <3B1A5D10.A7139942@iinet.net.au> <3b1aa80b.14709421@news.laplaza.org> Message-ID: See Dia, the GNU Diagramming Tool. I took a course on UML and used Dia, and it did everything I needed. Dia 0.88.1 (new release) has just obtained python plugins (I haven't tried them yet). see: http://www.lysator.liu.se/~alla/dia/dia.html xyzmats at laplaza.org (Mats Wichmann) writes: > >If you're interrested in Software then I know of the following that's not in > >the commercial arena: > > > >* I read the other day that the new version of dia (0.88.1) to some degree > >supports UML for Python specifically! I downloaded it yesterday (from > >Sourceforge I think) but haven't looked at it yet. > > > >* There are a couple of Python specific UML projects underway on sourceforge > >but they seem to be pre-alpha. > > How about some pointers? > > =================================================== > > There's a kit floating around called ArgoUML. It seems pretty > functional, but as far as generating anything, it's Java-based. > (Surprise!). On their wishlist, though, is something like "add > support for another language". Hmmm...there might be an opportunity > there for someone with lots of time on their hands... > > As far as books, "UML Distilled" is supposed to be pretty good, but > it's not going to go into the whole modelling/development methodology > thing, just scratch the surface. > > Mats Wichmann > > (Anti-spam stuff: to reply remove the "xyz" from the > address xyzmats at laplaza.org. Not that it helps much...) From ullrich at math.okstate.edu Tue Jun 26 09:35:59 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Tue, 26 Jun 2001 13:35:59 GMT Subject: Is this a true statement? References: <3B3805DF.A6741B80@cosc.canterbury.ac.nz> Message-ID: <3b388f42.830578@nntp.sprynet.com> On Tue, 26 Jun 2001 15:47:43 +1200, Greg Ewing wrote: >"Dr. David Mertz" wrote: >> >> claim there is no way "that naturally maps the program constructs to the >> memory accesses involved." The last is probably something true... but >> it is only true as long as no one writes a devicedriver.py extension >> module that contains some functions like "access_memory_address()." > >Strictly speaking, the C language doesn't provide any >way of accessing specific memory addresses, either. >Techniques for doing so rely on knowledge of details >of the implementation being used. I was wondering about that, actually. Kinda reminds me of years ago when someone wanted to know why they could not do something with a zero-width pen in VB (or something like that). The guy was puzzled because he said he could do it in C. I was then puzzled because I didn't realize that C _had_ a concept of "pen"... >Greg Ewing, Computer Science Dept, University of Canterbury, >Christchurch, New Zealand >To get my email address, please visit my web page: >http://www.cosc.canterbury.ac.nz/~greg David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From tom at nospam.scheper.net Fri Jun 8 08:27:34 2001 From: tom at nospam.scheper.net (-[tCs]-) Date: Fri, 08 Jun 2001 14:27:34 +0200 Subject: All your base are belong to us -- an explanation. References: <902430AC4moondustapexnet@209.99.56.9> <93hn81$l4m$1@nnrp1.deja.com> <9025628F7moondustapexnet@209.99.56.9> <3a5c8520_1@news.foxinternet.com> <902581E21moondustapexnet@209.99.56.9> <3a5ce21b_1@news.foxinternet.com> <4A982771F09.psskvxvn@vluxxijwai.net> Message-ID: <95h1itkt9avq4927vc3l3cs15i7pdi9guo@4ax.com> On Fri, 08 Jun 2001 04:51:47 -0500, rsteiner at visi.com (Richard Steiner) wrote: >Here in comp.os.linux.misc, wroot at my-deja.com (Wroot) spake unto us, saying: > >>shawntaub at yahoo.ca (Shawn Michael Taub) wrote >> >>> All your base are belong to us, >> >>Where is this from? I keep seeing it everywhere. Must be a classic. >>Something Pr. Nixon used to say, perhaps? > >It's a line from a poorly translated game (ZeroWing) that was a >standing joke on some of the Starsiege:Tribes forums a while back. >Seems it took on a life of its own, and someone created a whole pile of >fake photos that showed the phrase in all sorts of interested contexts. > >A web site outlining some of the history is here: > > http://hubert.retrogames.com/article.php?sid=1 I particularly like the Mr. T version of the story.. -=Cornelis -- ____ __ ___ ___(_ _) _) __) ___ (___) )(( (_\__ \(___) (__)\__|___/ = = = Narc Narc (???)? "Better bongs than bombs" = = = "half a joint in my ashtray, hooray! I didn't know I hadn't finished you." -Raven -------------------------------------------- This message is made out of 100% recycled and happy electrons From loewis at informatik.hu-berlin.de Thu Jun 7 05:42:59 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 07 Jun 2001 11:42:59 +0200 Subject: How to get a unicode degrees symbol? References: <9fj0j6$e7m$1@nntp6.u.washington.edu> <9flnr5$bag$1@nntp6.u.washington.edu> Message-ID: "Russell E. Owen" writes: > My main goal is to display the degree symbol (for example) on the > current platform -- in a way that Tk, etc. can all handle it as a normal > thing. > > Apparently this requires encoding the data as an ascii string. No. First, an ASCII string (as in "American Standard Code for Information Interchange") does not support the degree symbol. You probably meant a "byte string encoded as Latin-1". However, since Python 2.0 (and Tk 8.x), displaying Unicode objects in Tk windows is the best option. You don't need to care at all what font to chose and what encoding; Tk will do the right thing (most of the time). > OK, but surely there must be some simple way to do this that doesn't > require a big case statement (if platform x then use encoding y...) > and knowing the name of the most appropriate encoding for each > platform? Indeed there is, the code >>> import Tkinter >>> l=Tkinter.Label(text=u"\N{DEGREE SIGN}") >>> l.pack() should work on every system (provided a Tk port and proper fonts are available). Regards, Martin From root at rainerdeyke.com Sun Jun 10 16:01:36 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Sun, 10 Jun 2001 20:01:36 GMT Subject: Global in multiple files References: Message-ID: "Roman Suzi" wrote in message news:mailman.992195796.5861.python-list at python.org... > On 10 Jun 2001, Artur Skura wrote: > > >>Why do you need global variable in the OOP design anyway? > > > >I knew you would say that! ;) > > Yes, of course. Because in True Object Design there is no place for > anything global. That's a silly philosophy. Classes are objects; are they allowed to be global? What about objects that provide a higher level of abstraction than classes? -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From lac at cd.chalmers.se Mon Jun 4 01:30:41 2001 From: lac at cd.chalmers.se (Laura Creighton) Date: Mon, 4 Jun 2001 07:30:41 +0200 (MET DST) Subject: random Message-ID: <200106040530.HAA13207@boris.cd.chalmers.se> Gang, you have forgot what I said about sampling error. Lets try a different thought experiment. If you decide to go north or south based on whatever train arrives first, randomly arriving at the train station will not help you because if the trains run 1 an hour and at the 00 going n and the 10 going s you are 5 to 1 more likely to find the next train is north no matter how crazy your work schedule is. Laura From bob at passcal.nmt.edu Wed Jun 13 19:02:40 2001 From: bob at passcal.nmt.edu (Bob Greschke) Date: Wed, 13 Jun 2001 17:02:40 -0600 Subject: Passing back an array from an extension module? References: <9fqqqo$1p3e$1@newshost.nmt.edu> <9fr8mp$219g$1@newshost.nmt.edu> <9frdtl$25gh$1@newshost.nmt.edu> <3B214BCF.8393A2AC@home.net> Message-ID: <9g8r9m$66v$1@newshost.nmt.edu> "Chris Barker" wrote in message news:3B214BCF.8393A2AC at home.net... > Bob Greschke wrote: > > Hmmm...I was wrong. Creating a tuple object, then creating long > > objects and adding them to the tuple 1,600,000 times doesn't take very > > long. On > > the order of about 5 seconds (on a Sun Ultra10). > > It would probably be a whole lot faster with a NumPy Array, and a lot > cleaner, you don't have to create long objects, just make a NumPy array > with your C array directly. But 5 seconds is probably a lot faster than > it takes to read from disk anyway. All right, stop twisting my arm. :-) I'll give it a try. Actually, the initial reading of the file in C goes very quickly. > > But it takes it > > about 10 seconds if I do the same thing a 2nd, 3rd, 4th, etc. time. > > Is it leaking memory, > > Check your memory use. With tuples of this size, you should notice real > quick! Have you freed up the C array the you allocate? I can run everything on the same file and it eventually crashes on about the 6th or 7th reading. I am free()ing up the C array, but I suspect that I have to do something with the reference count of the tuple that I create. Maybe? I'm still not clear on all of that. > > or is it just taking that long to garbage > > collect the old tuple? There is a lot of more disk activity on the > > sebsequent runs than there is the first time through. > > Swapping? this would be explained by the memory leak option. Maybe the > first file was in the disk cache already. It's the same file each time, so it should get faster, but then it crashes. > I'm still curious whether you could do the whole thing in NumPy, and > forget all this C stuff altogether. Once you are using NumPy, you really > don't need to write C very often at all. I'll still need to call the C stuff to read, and decode, the file. Bob From vgiquel at yahoo.fr Wed Jun 13 09:23:17 2001 From: vgiquel at yahoo.fr (=?ISO-8859-1?Q?Val=E9rie?=) Date: 13 Jun 2001 06:23:17 -0700 Subject: PYTHON: SQL QUERY Message-ID: <4b463337.0106130523.18e8dc76@posting.google.com> Bonjour, Nous sommes actuellement face ? un probleme: Nous devons saisir un code produit dans une Entry. Ensuite, nous devons recuperer cette valeur pour ensuite afficher dans une nouvelle fenetre les donnees correpondant ? ce code produit. Avez vous la solution? Merci Hello, we have got a problem: We want to enter a code of product in an Entry. After, we want to recuperate this value for print the correspondant datas in relation to this code of product. Have you got a solution please? Thanks a lot Val?rie & Solenn From aleaxit at yahoo.com Mon Jun 18 03:38:05 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 18 Jun 2001 09:38:05 +0200 Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? References: <3B2B60AD.942719AE@earthlink.net> Message-ID: <9gkb4s01vql@enews2.newsguy.com> "bradclark1" wrote in message news:ePZ#Y669AHA.266 at cpmsnbbsa07... ... > Am I missing something here? From what I read at the above it says for .net. > I didn't see anything else about it? *sigh* once again, trust Microsoft's marketing to make an unholy mess of things. Microsoft .NET is a specific platform architecture with an intermediate-language (MSIL), a common runtime library, &c. So "of course" MS's marketing immediately went and stuck a ".NET" affix to the next releases of a slew of Microsoft products that do *NOT* require or mandate this new platform architecture (though they may to some degree support it -- but not necessarily), such as the new releases of many "Microsoft Backoffice" servers, and the new release of Microsoft Visual Studio (it's not going to be VS7, as it's coming after VS6 -- it's going to be VS.NET...). Activestate's Visual Python supports and relies on Microsoft Visual Studio 7, and unfortunately the latter *IS* named "Microsoft Visual Studio .NET". Activestate's Visual Python does ***NOT*** require you to install Microsoft's .NET *PLATFORM* nor to develop for it -- because "VS.NET" doesn't. The naming of "VS.NET" is basically just the usual geniuses in MS's mktg at work -- like back when they managed to muddy the waters enough between COM and Active/X (two related technologies with *BIG* differences -- COM being the platform upon which you might OR MIGHT NOT choose to further deploy/support ActiveX) as to set widespread adoption of COM back...:-(. The overall technical picture and the strategical prospects are complicated enough that the last thing the industry needs is brilliant marketeers throwing spanners in the work by creative naming. To be honest, although MS's mktg does have this "endearing" habit, they're far from alone -- one of the worst examples of this creative naming was Netscape's renaming of livescript to "Javascript", which is ***STILL TODAY*** a source of confusion for Dynamic HTML students who believe they may have to study some Java to control their webpages because it "sounds" like Javascript has something to do with Java (it doesn't, besides the thinnest syntax-sugar similarity, but...). Alex From bos at hack.org Tue Jun 19 06:08:53 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Tue, 19 Jun 2001 12:08:53 +0200 Subject: import anydbm References: <3B2F231A.3E8A8A0@pool.informatik.rwth-aachen.de> Message-ID: <3B2F24B5.70B0FE88@hack.org> Morten Gulbrandsen wrote: > > Hello, > > I have a small python problem, ... > File "/usr/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 ------------ 1) *Read* what error message you get ---------- 2) Check the doc-string for anydbm.open: >>> import anydbm >>> print anydbm.__doc__ Generic interface to all dbm clones. Instead of import dbm d = dbm.open(file, 'w', 0666) use import anydbm d = anydbm.open(file, 'w') The returned object is a dbhash, gdbm, dbm or dumbdbm object, dependent on the type of database being opened (determined by whichdb module) in the case of an existing dbm. If the dbm does not exist and the create or new flag ('c' or 'n') was specified, the dbm type will be determined by the availability of the modules (tested in the above order). It has the following interface (key and data are strings): d[key] = data # store data at key (may override data at # existing key) data = d[key] # retrieve data at key (raise KeyError if no # such key) del d[key] # delete data stored at key (raises KeyError # if no such key) flag = d.has_key(key) # true if the key exists list = d.keys() # return a list of all existing keys (slow!) Future versions may change the order in which implementations are tested for existence, add interfaces to other dbm-like implementations. The open function has an optional second argument. This can be 'r', for read-only access, 'w', for read-write access of an existing database, 'c' for read-write access to a new or existing database, and 'n' for read-write access to a new database. The default is 'r'. Note: 'r' and 'w' fail if the database doesn't exist; 'c' creates it only if it doesn't exist; and 'n' always creates a new database. ---------- I think you can solve the rest. -- Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From matt at mondoinfo.com Sun Jun 10 14:41:14 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Sun, 10 Jun 2001 18:41:14 GMT Subject: spawning unix command processes which run in parallel and simultaneously References: <9fvhqj$57m$1@news.hk.linkage.net> Message-ID: On Sun, 10 Jun 2001 18:23:38 +0800, Alan Tsang wrote: >HI, I am learning to code with Python and I encounter a technical >problem. Hi and welcome. >I want to spawn a few unix command processes from a python script so >that I can get the output from the unix command processes and use >them in python. >But I don't want to wait for the completion of one process at a time >and then start another. I want the python script to start the >processes simultaneously and monitor whether anyone of them have >finished and if so, get the output from the finished one. >It seems to me that the os and popen2 module is useful in this >respect but I am not sure how to do it. You can do what you want using popen (maybe popen2) and select. I'll append a simple example. Unfortunately, with pipes and subprocesses, once you go beyond a deliberately simple example, things can get messy. Unless you and -- much harder to control -- your subprocesses get buffering just right, programs that want to be interactive can block waiting for input that you think you've sent and waiting for you to read output that you haven't seen. Happily, other folks have written code to deal with this nuisance. The Vaults of Parnassus (www.vex.net/parnassus/) is a very valuable resource. If you have a look in the Tools/Extensions section there you'll find several modules inspired by Tcl's Expect (the canonical program-that-controls-programs). I don't know which of them is best but there aren't so many that it would be hard to try them out. Tim O'Malley's event loop that's there looks like it might be of use to you too. Regards, Matt import random import os import select import string def getCommand(): return "sleep %i;echo %s" % \ (random.randint(0,10),random.choice(string.hexdigits)) def main(): readPipes=[] for count in range(5): readPipes.append(os.popen(getCommand())) while 1: # Could put a timeout here if we had something else to do readable,writable,errors=select.select(readPipes,[],[]) for p in readable: print p.read() readPipes.remove(p) os.wait() # Don't want zombies if len(readPipes)==0: break if __name__=="__main__": main() From James_Althoff at i2.com Mon Jun 11 20:20:56 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Mon, 11 Jun 2001 17:20:56 -0700 Subject: metaclasses -- aka Don Beaudry hook/hack (was RE: Why should i use python if i can use java) Message-ID: Skip Montanaro wrote: > James> I have found is that "the hook" doesn't seem to be complete in > James> the sense that only the "class" statement seems to know about the > James> hook. > >Jim Fulton's ExtensionClass stuff knows about the Don Beaudry hook. >ExtensionClasses are used in Zope (you can get the source from any Zope >distribution) and by the latest Python wrappers for Gtk. > >-- >Skip Montanaro (skip at pobox.com) >(847)971-7098 Thanks, Skip. Before I head too deeply into Zope dependencies, I would be interested in knowing whether or not "type(MyClass) == types.ClassType" and "isinstance(myInstance,MyClass)" work for classes derived from ExtensionClass. (And if so, why do these work for C extension classes using the Don Beaudry hook but not for Python classes using the same hook?) Thanks, Jim From Attila.Feher at lmf.ericsson.se Tue Jun 5 09:40:15 2001 From: Attila.Feher at lmf.ericsson.se (Attila Feher) Date: Tue, 05 Jun 2001 16:40:15 +0300 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3b1cdf94.55bd@bolder.com.co.za> Message-ID: <3B1CE13F.F9734F10@lmf.ericsson.se> goose wrote: [SNIP] > serious multi-user environments, unlike windows which evolved from a single-user > single-tasking os with no security at all ... I am not talking about Windows, I talk about NT where it is not true at all. NT was never a single user OS. A From sburr at nospammac.com Mon Jun 18 02:34:41 2001 From: sburr at nospammac.com (Steven Burr) Date: Mon, 18 Jun 2001 06:34:41 GMT Subject: Two more questions, and a comment: Cross-Platform... References: <3B2B60AD.942719AE@earthlink.net> <3B2BF029.14AAF29E@earthlink.net> Message-ID: <170620012336202508%sburr@nospammac.com> In article <3B2BF029.14AAF29E at earthlink.net>, Ron Stephens wrote: > 1. Is Tkinter likely to be ported over to MacOS X soon? In a sense, it already has been. XFree86 has been ported to Darwin in a form that runs side-by-side with Aqua. (You can switch to X Windows by clicking a button and back to Aqua by typing cmd-opt-A.) Tcl/tk is also available for Darwin. With XFree86, tcl/tk and the Darwin version of Python, I've been able to run Python/Tkinter apps in X Windows on my Mac. On the other hand, based on what I've read in the Mac-Python SIG and elsewhere, nobody seems to be working on a port of tcl/tk to Carbon or Cocoa. From chris.gonnerman at newcenturycomputers.net Mon Jun 11 22:20:48 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Mon, 11 Jun 2001 21:20:48 -0500 Subject: Tree Library References: <3B17EB76.560C6302@iems.nwu.edu> Message-ID: <00a501c0f2e6$4d22cca0$0101010a@local> Well, I got it done. At http://newcenturycomputers.net/projects/rbtree.html is my Red/Black Tree implementation. It's based directly on code by Thomas Niemann (from his "Cookbook") and implements a mapping class. Take a look... I don't know if this is what you want, but perhaps it will help. I'm afraid I don't remember much about "basic things like depth, completeness, degree, etc." ----- Original Message ----- From: "Leonardo B Lopes" Newsgroups: comp.lang.python To: Sent: Friday, June 01, 2001 2:22 PM Subject: Tree Library > Does anyone know of a decent, simple, tree library, which implemented > basic things like depth, completeness, degree, etc...? > -- > ======================================================================= > Leonardo B. Lopes leo at iems.nwu.edu > Ph.D. Student (847)491-8470 > IEMS - Northwestern University http://www.iems.nwu.edu/~leo > -- > http://mail.python.org/mailman/listinfo/python-list > > From Attila.Feher at lmf.ericsson.se Sun Jun 3 10:21:30 2001 From: Attila.Feher at lmf.ericsson.se (Attila Feher) Date: Sun, 03 Jun 2001 17:21:30 +0300 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> Message-ID: <3B1A47EA.AFBD45E8@lmf.ericsson.se> TGOS wrote: > > On Sat, 2 Jun 2001 22:31:50 +0200, "Polterguy" > wrote: > > > [...snip...] > > I agree totally, but fact is 99.99999% of the commersial world uses win32. > > Are you sure you understand the term "commercial"? > Windows is mainly used by private users and not even there 99% of them use it. > > Do you think a nuclear power plant runs with Windows? Or maybe the software of > an airport tower? If that's the case, how many people do you think would die > during a blue screen error? > > Do you think the majority of worldwide banks use Windows? An easy to hack, > insecure and not very stable operating system? A blue screen would mean loosing > millions of dollars a minute and a single hack would make every hacker a rich > man. [SNIP] > In some countries there are even more Unix/Linux PCs than Windows PCs. Please > never assume that what is valid in your country is valid for the rest of the > world as well. You are not living alone on that planet and your country isn't > the only one that exists or that is important. [SNIP] Just to inform you: the worlds easiest to hack and crack systems are the UNIX systems. Due to the fact that they have been designed for university (friendly) environment. Serious users (security, incl. but not limited to NATO, banks etc.) use VMS. Some smaller banks use(d) OS/2. But what is sure: Linux (UNIX) with sources is ony used (at serious places) as firewall (where the actuall OS is inspected and corrected line by line) and as a Web Server with no online connection to the real internal network. So don't take UNIX to any higher level than it is. And about Windows being a shit: Just try to look around and find a portable async gethostbyname or a standard gethostbyname_r for Unices... Good luck. BTW you can find numerous workarounds which fail in numerous environments. Windows is not better than UNIX and UNIX is not better than Windows and none of those are neither secure nor realtime O/Ss. Don't make a religious war about this. BTW 1 addition: there are numerous Internet SW which run only on Windows (some only on win9x series) and they do survive. Like online casino SW. Would they survive with a Linux only solution? So there is a huge market for Windows apps. There is also a market for UnIX apps, although usually different one. Apple is somewhere in the "still present" area thanx mostly to education facilities having Apple, people buying them for they look good and CEOs buying them for they look expensive... I am not saying they are not good. I am in this business for more than 10 years and as far as I see all O/Ss suck. You either don't have a market with them or they simply suck due to bad design or due to being "compatible" to some old stds. A From twofingersalute at atl.mediaone.net Thu Jun 14 08:35:54 2001 From: twofingersalute at atl.mediaone.net (myself) Date: Thu, 14 Jun 2001 12:35:54 GMT Subject: tummy compile Mandrake 7.2 References: <20010608.214013.1469262009.16325@K7.atl.mediaone.net> <20010609.104451.1884661237.1229@K7.atl.mediaone.net> <3B24154E.C70211ED@student.gu.edu.au> <20010610.232821.1789366143.1225@K7.atl.mediaone.net> <3B25F742.F4E25C37@student.gu.edu.au> <20010612.151135.165344818.1845@K7.atl.mediaone.net> <3B288E62.FC946467@student.gu.edu.au> Message-ID: <20010614.083914.1875335928.1071@K7.atl.mediaone.net> In article <3B288E62.FC946467 at student.gu.edu.au>, "Joal Heagney" wrote: >> I can't thank you enough for this generous and thorough post. I thought >> I had it licked from a source install, but there are problems which I >> don't have the expertise to resolve- hope you'll bear with me if I ask >> just a *couple* more Q's...and yep, I got similar dependencies as >> above, plus a few more. > >> > 1.First, install the src.rpm under /usr/src/RPM rpm -i >> > python2-2.1-4.src.rpm >> > >> you certainly have more knowledge/success/experience than me, but >> according to the advice from LM: > > Nah I just hack about a lot, and encountered a lot of the pitfals. Also > I had a lot of experience building packages from tar.gz source - I just > got sick of building and rebuilding every time I wiped out my machine so > now I use rpm and save the packages. (A bit of free advice, don't touch > rpm's --buildroot option as superuser without reading the docs. I > managed to wipe out my entire /usr directory tree with that one.) > you nailed one of my main motivations in wanting to learn the rpm building methodology- unless something radical has changed (eg LM changing to an incompatible gcc in 8.0), it sure looks easier to save the pkg for my incessant upgrades and occaisional re-installs. BTW, you've given me plenty of pointers, not to mention confidence, and I really don't expect you to respond to my incessant Q's (unless you particularly feel like it! ). Obviously I need to do a bit of digging on my own. Having said that...... >> Building RPM's as root is dangerous, because the binary files are >> installed on the system before being packaged, thus you must always >> build as normal user so you won't accidentally pollute your system >> >> http://www.linux-mandrake.com/howtos/mdk-rpm/ >> >> please don't take this as criticism, it's more a question, as i haven't >> seen this advice elsewhere. For all I know, building as user is part of >> my problem? > > Most packages are "supposed" to be buildable as user or root, that's > what the %defattr(-,root,root) option in the %files section is for, to > ensure that the built package files have the correct owner/group > settings when you install them. It is safer to build a package as user. > This is where you use --buildroot and related options, but beware. At > the end of a build, the --buildroot option deletes EVERYTHING in the > directory you point it at. *sighs* As normal user, you just risk > loosing some data. As superuser or root, you risk taking out parts of > your system. That's how I wiped out my /usr partition. However, on some > packages, it's very difficult for a package creator to build a spec file > that will work as a non-root user. > I'll try and heed your advice; of course, I'll need to do a bit more reading first. Looking at man rpm, the danger you warn of isn't even suggested :-( ! >> > Now begins the hacking on the spec file. 4. Make sure you fix that >> > depend to expat, not expat-devel >> >> still not totally clear on this, but I'll try (actually might try to >> satisfy the darn thing first- generic rpm or source install) > > If you go to /usr/src/RPM/SPECS there should be a file called > python.spec. If you open it with an editor, you'll find the > following at line 41: > BuildPrereq: expat-devel >= , though using > python-2.1-4.src.rpm it actually reads what it should BuildPrereq: expat > >= 1.1-3tummy > >> I'm automatically impressed with *anyone* who uses emacs :-) > > *chuckles* Nahh. The X-version has handy dandy menus. If you took my > little Unix Pocket Book and killed my X-server, I'd be helpless. > >> Okay, here's my main question, and I think it goes to all the "idle" >> stuff above- when I installed source build, I chose "altinstall" >> -obviously to allow a non-replacement- it doesn't create a hard link to >> "python" named "python". Sounds reasonable. But doing: >> >> [root at K7 test]# find /usr/local/lib -type f -print0 | xargs -r -0 grep >> "#! /usr/bin/env" >> /usr/local/lib/python2.1/site-packages/idle/PyShell.py:#! /usr/bin/env >> python >> /usr/local/lib/python2.1/site-packages/idle/eventparse.py:#! >> /usr/bin/env python/ >> /usr/local/lib/python2.1/base64.py:#! /usr/bin/env python >> /usr/local/lib/python2.1/difflib.py:#! /usr/bin/env python >> >> and *dozens* more of similar nature- they all call python, which would >> be my 1.5.2, rather than the python2.1 which the install created. I >> can't create a symlink, otherwise the system will call 2.1, which I'm >> trying to avoid. E.g., if I run "python2.1 regrtest.py" or >> "./regrtest.py" from the test directory, which ver. is running?? >> Perhaps after studying Python and bash for another year I'd know for >> myself :-). Is this an issue? If it is, does your method address it? > > This isn't really a bad question, as it goes into shell scripts and > other key features of unix systems, things that will help you when you > build your own programs. > > When you call python2.1 regrtest.py, the bash shell looks along the > directories specified in your PATH variable for a file called python2.1 > and then tries to execute it. If it has execute permissions set, the > shell/system/kernel looks to see if it's a binary or a text file. If > it's a binary, the system runs the binary, passing the rest of the words > as arguments to the program, in this case regrtest.py. So in this > example python 2.1 is running, and it processes the file regrtest.py. If > you use this functionality, you will always get python 2.1. > > However, if the file is an executable text file, the shell looks to see > if it can find something like this as the first line: > #!/a/path/to/an/executable > If it finds such a thing, it will run the program specified at this path > to process the rest of the file. In your first example it will be the > program env, which will execute the program python (actually a symlink > to python1.5). Env is often used because bash requires an exact path to > the executable, and python can shift around on the system a lot. > However, it will be version 1.5 in this example. If you want a program > to run on python 2.1, you will either have to specify as python2.1 *.py, > or go into all the *.py files and change the first line to point to > python2.1 rather than python. > well, I apologize for even asking- if I'd thought about it before hitting the "post" button, my Q would have been "do you have a good Perl script to change all these python's to python2's?" . Excellent explanation, though, and I must admit my understanding of *all* things Linux is spotty at best. > Annoying, ain't it? Wish the distributors would hurry up and loose > python1.5 already. > >> I'm way cofused on the purpose of the LM rpm macros and how exactly >> they're used (or not), but looks like /usr/lib/rpm/brp-compress is >> 'sposed to handle that...... > > *shrugs* Probably. If you bounce over to the rpm home page (sorry, can't > remember the URL, you'll have to use a search engine), they have a > document called Maximum RPM which explains the main macros. > thanks; already got it from Redhat site, but haven't read it yet. After your earlier admonishments, I guess it'd be a good idea to get a better grasp of this process before I get carried away. >> > 10. rpm -bb --short-circuit python-2.1.spec >> > >> again my ignorance probably shows, but man rpm says --short-circuit is >> only valid w/ -bc and -bi......and another thing- after all that, >> couldn't you find a stronger expletive than "damn"? ;-) > > So it does. I've always assumed that it applied. *hmmm* Maybe reading > the man pages isn't always as useful as we'd like to believe. *grins* I > may have to get in contact with the rpm guys and find out why. I've > always found that if I don't use the --short-circuit I have to watch as > the package loads, compiles and installs itself - which can be very > undesirable if the build process doesn't occur automatically and I've if I understand- say I do "rpm --rebuild prog.src.rpm"- it actually installs the resulting prog.rpm that it builds? Is there a way to prevent the final pkg install using --rebuild? Sometimes I like to examine an rpm before installing just to see what the potential for damage is (config files, libraries, locations, etc). I know I can go through the process you recommend, look at the spec and configure files, and then install- just was hoping using src.rpm would do *everything* I want *exactly* the way I want it to :-). > gone and babysitted it through manually. And no. *grins* As you comment > lower, this is a polite newsgroup, and I'm going to do my best to > maintain that. > >> I'm glad this is somebody's idea of "fun"! But, good explanation of the >> necessary ingredients. Python2.1 Will Get Installed on my box; maybe >> not today, maybe not this week, but I'm gonna persevere! I'll post >> results, hopefully positive. I know there are others who'll benefit >> from your post as well- I'm seeing more Python q's on a.o.l.m.... >> >> kind sir, may your tracebacks be few and far between > > Just passing the favour forward. And what's a.o.l.m? Another python > newsgroup *starts salivating* well, since you offered a pre-built LM binary, I assumed you were using Mandrake, no? We could really use another knowledgeable poster such as yourself on alt.os.linux.mandrake. peace From nperkins7 at home.com Sun Jun 10 01:04:43 2001 From: nperkins7 at home.com (Nick Perkins) Date: Sun, 10 Jun 2001 05:04:43 GMT Subject: priority queue References: Message-ID: Thanks to all who replied! (I have been away from the computer for a couple of days--graduation,parents,etc) I have a first version of the program working now, using the heap.Heap mentioned by Alex. The heap works fine for now, but I will keep in mind the other possibilities. The game/puzzle that my program solves is Sokoban. Sokoban is Japanese for 'warehouse-keeper'. The task is to push a number of square blocks through a maze-like area, until all blocks are on designated target squares. I did this project for AI class last fall. I became completely absorbed in it for about three weeks, and came up with some (IMO) clever optimizations, including a custom compression routine for states, and a custom hash implementation for states. The program never actually used up available ram because the nature of the game is that there are many re-occurences of the same state, which can be discarded. Due to another optimization that I came up with, a re-occuring state may actually be found with a lower g value than the existing state, and should therefore replace it. So, yes, I need to detect repreated states (many of them). For now, I am using a dictionary, in tandem with the heap. I need to key on two values: one is the sokoban position, a tuple(int,int), but the other is a Numeric.array of Int, containing either 0 or 1. (the positions of the blocks). I am not sure if that array is 'the way to go' or not, but it keeps things simple, for now. So I need a hashable value out of the Numeric.array.... I am currently using: def unique_hash(soko,blocks): return (soko,blocks.tostring()) but I could also try: def unique_hash(soko,blocks): return (soko,tuple(map(tuple,tuple(blocks)))) (works like... >>> a array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) >>> tuple(map(tuple,tuple(a))) ((0, 1, 2, 3), (4, 5, 6, 7), (8, 9, 10, 11), (12, 13, 14, 15)) ..but with zeros and ones, of course. (...seems strange, but maybe as good as anything,..?) So I have a heap for the queue, and also a dict, running in tandem. Odd, but it works. I used a similar method in C, which worked because this particular A* problem tended to run for a long time without using up memory, so speed was more important than space. When I did the C version, I found that my biggest improvement in performance came from changing the way I generated new states. Originally, I would generate a new state for each move of the sokoban. This lead to much waste, as the program tried every possible way to walk accross an empty space. I decided to skip all those steps, and just figure out how many would be needed to get to the next block. Specifically, not generating states in which the sokoban has merely taken a step, but only those where he pushes a block, allowed the program to run up to a thousand times faster (or more), for the problem sizes I was working with. Since the problem is to find the shortest number of steps (push or not), to a solution, the number of intermediate steps needed between states is calculated separately, and that value is added to the g-value of the new state. (Hence the need to sometimes replace a state in the queue: a shorter path to that state can be found at a later time). Another useful thing was checking for 'deadlock' condiditions: situations where two blocks are pushed together against a wall, making them impossible to move further. This pattern matching can be expanded to find larger patterns that also cause deadlock, but I have not done that (yet). Another thing I have not tried is using dynamic techniques to save solutions to 'mini-problems': parts of the full problem, possibly recognized as patterns. And of course, any 'static analysis' of the map (maze), is more-or-less 'free' in the long run, (runs once), and so can get as involved as you like, while not hurting performance. It's a seemingly simple puzzle, which actually turns out to be quite hard (NP hard, i think). It is the type of problem that you can think about ever more deeply, until your head hurts. It sure is fun, and will keep me thinking until I get a job and have to divert my attention. From James_Althoff at i2.com Thu Jun 7 14:31:12 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Thu, 7 Jun 2001 11:31:12 -0700 Subject: Why should i use python if i can use java Message-ID: Alex Martelli wrote: >Absolutely! But does any commercial IDE, as you earlier >referenced, support Jython yet? I don't know of any. > >Alex I use a hybrid approach. For example, I run JBuilder and use its design layout tool (using Swing components) to do some GUI design: start with a JPanel, add a JSplitPane, drop in a JTree, and a JTable, some JButtons, etc. Use the property editor to set property values. Give each component a name. (I frequently use GridBagLayouts to position things nicely, btw.) Then I compile and run it in JBuilder until it looks ok. Now I start writing in Jython. I import the class created by JBuilder, make an instance of it -- a JPanel subclass typically -- and add in handlers for the buttons, trees, lists, tables, etc. Each of these (JComponents) I reference using the name that I assigned to the component when using JBuilder (I have a little utility method that can search a JComponent and all of its child components to find a component with a given name). From there on out, its all Jython. Works like a charm! (Actually, pdb doesn't work very well when using Swing -- which can be a major pain sometimes.: -( ) Jim From deltapigz at telocity.com Mon Jun 4 20:33:23 2001 From: deltapigz at telocity.com (Adonis) Date: Mon, 04 Jun 2001 20:33:23 -0400 Subject: Wadda ya mean it's not defined? Impossible Error? References: <3B1C2727.D9E746CB@dsl.ca> Message-ID: <3B1C28D2.E4378E31@telocity.com> just initialize paths; like in C/C++ (in idea) def parseLogs(paths = '', custs): # should initialize path to NULL and your error should go away... im new to Python; but ive encountered this a few times. hope this helps. Adonis David Gilbert wrote: > I'm getting what appears to be an impossible error. Here's a code > snippet: > > def parseLogs(paths, custs): > > ipfRecord = re.compile("^([0-9]+)[ ]+([0-9]+)[ > ]+([0-9a-z]+)([+-])") > > last = {} > for i in range(len(paths)): # Create start times > ... and so on. > > Here's the error snippet: > > File "../devel/ditty/bandsaw2.py", line 37, in parseLogs > for i in range(len(paths)): # Create start times > UnboundLocalError: local variable 'paths' referenced before assignment > > Just when should "paths" be assigned? > > Dave. From root at rainerdeyke.com Tue Jun 26 15:40:28 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Tue, 26 Jun 2001 19:40:28 GMT Subject: Is this a true statement? References: <8NuZ6.362378$oc7.42924874@news2.rdc2.tx.home.com> <3B3788A2.3BD1D672@tundraware.com> <9qMZ6.368197$oc7.44797813@news2.rdc2.tx.home.com> <3B37A15D.DF05A331@tundraware.com> <3B38D606.DA5886BE@tundraware.com> Message-ID: "Tim Daneliuk" wrote in message news:3B38D606.DA5886BE at tundraware.com... > Rainer Deyke wrote: > > Which part of the Turing machine can emmit light? > > None of them can - Including C++. You are begging a ridiculous > point. To generate graphics there has to be the preceding computation > and then the actual analog event. All T-C languages are equally > able, in principle, to to the former. None can do the latter. 'None' is too strong a term. It's all a question of how the language is defined. Almost all implementations of C++ can phsyically write to arbitrary memory locations (although the standard does no guarantee this), while Python cannot (without an exension module). If I take a Turing machine and add an "emit light" opcode, it will still be Turing complete. More interesting than physical actions are interactions with other programs. A C++ program (in most implementations; not guaranteed by the standard) can act as a device driver; a Python program cannot. This is a question of which interfaces to the outside world a language exposes (directly or through its standard library). -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From tim.one at home.com Wed Jun 27 00:07:59 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 27 Jun 2001 00:07:59 -0400 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) In-Reply-To: <3B3950ED.8002AF8@cosc.canterbury.ac.nz> Message-ID: [Tim] > We didn't *have* to expose Python's generator-iterator object > either [Greg Ewing] > Out of curiosity, what would a Python generator implementation > look like that didn't expose generator-iterators? What would > happen if you called a generator outside of a for-loop > context? The implementation would probably be almost exactly the same, but the *visible* behavior would probably look like either Icon or, less likely, CLU. In CLU it was impossible (a compile-time error) to invoke an iterator outside of an iterative control context; that would correspond in Python terms to raising an exception if you tried to use a generator anywhere but after the "in" of a for/in loop (easily arranged by the PVM, if that was desired). The Icon version can't know at compile-time, so I bet Python would have acted more like that: you can invoke a generator anywhere, but when invoked outside of a generative control context, the generator would yield its first result, and that's all. You couldn't resume it -- without the possibility for a *named* resumable object, only magical control contexts can manage to tickle the thing more than once under the covers. IOW, without exposing the generator-iterator object, all the concern about functions and generators being "radically different" would have been a non-issue -- but generators would have been truly *usable* only in for-loops (Icon has many kinds of generative control context, though, so the limitation isn't so severe there). The only thing the generator-iterator object buys you is a user-invocable .next() method, but that packs a lot of bang for the buck. In return, it's *visible* that a generator-function returns a generator-iterator, hence all the "radically different" stuff. From swank at swink.com Fri Jun 8 05:26:27 2001 From: swank at swink.com (swank) Date: Fri, 08 Jun 2001 09:26:27 GMT Subject: DOWNLOAD WHATEVER YOU WANT!!!!! Message-ID: <7T0U6.22079$V5.521585@typhoon.columbus.rr.com> DOWNLOAD NEW MOVIES! NEW SOFTWARE! OR WHATEVER YOU FIND! FREE!!! GOTO: www.jows.isbad.net _____________________________________________________________ This message posted with trial version of Express News Poster From qrczak at knm.org.pl Thu Jun 14 10:41:42 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 14 Jun 2001 14:41:42 GMT Subject: base converter References: Message-ID: Thu, 14 Jun 2001 10:15:21 GMT, Fredrik Lundh pisze: > (still waiting for someone to come up with a one-liner using > list comprehensions ;-) As you wish :-) from __future__ import nested_scopes import string def fix(f): return lambda x: f(fix(f), x) def BaseConvert(x, b, digits=string.digits+string.uppercase): return [digits[d%b] for d in fix(lambda iter, y: y and iter(y/b)+[y] or [])(x) or [0]] -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From tim.one at home.com Sun Jun 17 19:43:48 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 17 Jun 2001 19:43:48 -0400 Subject: Why should i use python if i can use java In-Reply-To: <9gaf9d$fsa$1@newshost.accu.uu.nl> Message-ID: [Martijn Faassen] > ... > Python doesn't really do any type checking for class instances; it > checks whether there is a method that is of the right name and has > the right amount of arguments somewhere on the instance or its > superclasses, and calls it if so. There is no 'is this the expected > class?' check anywhere, not even at runtime. If I do instance.xyz() and it succeeds, then xyz is necessarily known to instance's class (whether directly or via a base class). What else is there *to* check in that case? Try fooling it instead: class A: def xyz(self): print "A.xyz" class B: def xyz(self): print "B.xyz" a = A() B.xyz(a) and you'll discover that Python refuses to run B.xyz() with an instance of A, even though A has a method of the same name and signature: "is this the expected class?" checks are done at runtime. From gustin at pcpm.ucl.ac.be Wed Jun 27 04:09:54 2001 From: gustin at pcpm.ucl.ac.be (Cédric Gustin) Date: Wed, 27 Jun 2001 10:09:54 +0200 Subject: Windows Registry References: Message-ID: <9hc4gq$1bq$1@estragon.sri.ucl.ac.be> It's in the _winreg module http://www.python.org/doc/current/lib/module--winreg.html You might also want to consider the higher level module winreg, which is available at http://www.ficom.net/members/york/software/ Good luck, Bonne chance ! Cedric "Alexandre Fayolle" wrote: > Could someone tell me how to access the windows registry with python > (or point me to the right section of the manual). From m.faassen at vet.uu.nl Mon Jun 4 17:50:44 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 4 Jun 2001 21:50:44 GMT Subject: I NEED to TEACH you something, QUICK! References: <9fgiae$av0$3@newshost.accu.uu.nl> <9fglsi$ava$1@newshost.accu.uu.nl> <9fgmc6$ckd$1@panix3.panix.com> Message-ID: <9fgvrk$geo$1@newshost.accu.uu.nl> Aahz Maruch wrote: > In article <9fglsi$ava$1 at newshost.accu.uu.nl>, > Martijn Faassen wrote: >>Martijn Faassen wrote: >>> >>> old computer displays, or whatever. It nips flamewars in the >>> butt. >> >>'bud'. Sorry about that. Please don't flame me now. :) [refactored: there was some mistake about which section of the building I needed to be, now resolved] No problem, thanks! Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From ullrich at math.okstate.edu Sun Jun 3 11:49:38 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 03 Jun 2001 15:49:38 GMT Subject: random (fwd) References: <9fbdhl01s6r@enews2.newsguy.com> Message-ID: <3b1a5b8e.4330511@nntp.sprynet.com> On Sat, 2 Jun 2001 21:07:57 +0200, "Alex Martelli" wrote: [...] > > >> |I _think_ -- but am not a philosopher or mathematician >> |so cannot feel sure -- that part of what Goedel shows is >> |that arithmetic is powerful enough to model any other >> |formal system. >> >> Well... I *am* a philosopher, and have occassionally pretended to be a >> mathematician (not the most convincing pretense though). But I don't >> think one needs to be to see what's wrong with the above. >> >> Assuming "Goedel" means his incompleteness theorem in the above, he >> really doesn't show anything like the above. > >Sorry, I wasn't thinking specifically of his theorem but rather >of his way of operating towards it. Given any (finite) axiomatic >system, even 'richer' than arithmetic, can't we MODEL that >richer system with arithmetic, numbering well-formed >formulas &c, by just the same process as Goedel uses to >model arithmetic in itself? So my guess what you meant by that was correct. So was my reply, which is still missing: No, but yes under some weak technical conditions (like the language needs to be countable. Uncountable languages actually come up in logic.) > The fact that we added a few >primitive symbols and axioms to the set we started with >for arithmetic (be that Peano's or whatever) doesn't appear >to me to break down the process. Precisely. The words "a few" are important - if we added really really a _lot_ of primitives we run out of Godel numbers. David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From aleaxit at yahoo.com Fri Jun 1 18:58:52 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 2 Jun 2001 00:58:52 +0200 Subject: How do I return binary data from a python CGI called from CGIHTTPServer? References: Message-ID: <9f96kb01mq8@enews1.newsguy.com> "Mark Wright" wrote in message news:f9ff3f62.0106011427.6243e5e9 at posting.google.com... ... > But my original problem/question remains: how does a CGI program > return binary data on windows? Is it even possible? The problem is python.exe must be run with option -u, to have binary standard input and output streams, rather than text ones as it has by default. Alex From BPettersen at NAREX.com Wed Jun 13 14:10:16 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Wed, 13 Jun 2001 12:10:16 -0600 Subject: Inner classes Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D469@admin56.narex.com> > From: Mats Wichmann [mailto:xyzmats at laplaza.org] > > Java provides inner classes. They have some interesting properties, > but mostly smell to me like a hack to get around things being too > strongly typed in Java. Probably I'm missing some great point here. > > Nonetheless, I was challenged by someone to describe how it isn't a > shorcoming in Python that classes don't work this way and didn't > convince the guy so I'm looking for a more erudite comparison. But... Python does have inner classes... (although not anonymous ones) -- bjorn From fgeiger at datec.at Fri Jun 1 08:02:12 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Fri, 1 Jun 2001 14:02:12 +0200 Subject: Zope questions and comments (&Tkinter???) References: <3B158C50.887E3D59@earthlink.net> Message-ID: <9f808i$dsv$1@newsreaderm1.core.theplanet.net> I was in the same situation. I tried hard to become friends with Zope, because it's a great concept. But all those modules and documents scattered all over their site. I simply lost the forest for the trees. Then someone recommended Webware (webware.sourceforge.net). So I gave it a try. Give it a try too, you'll never regret. Regards Franz "Ron Stephens" wrote in message news:3B158C50.887E3D59 at earthlink.net... > I am interested in Zope and I have few questions. My interest is in > running a "simple" Zope based web server in order to have the ability > to run server side Python scripts; I might eventually be interested in > the object oriented database aspects of Zope, but it is not clear > whether I would be able to devote enough time and energy to actually be > able to do so. Someone recommended a Zope based hosting service named > hurrah.com and it looks good to me at first glance. I downloaded Zope > and fooled around a few weeks ago, it looked good but complex. My > questions: > > 1. Will Zope be too complex for me??? Specifically, if my primary > interest, in the short run, is to be able to run server side scripts > written in Python (or at least in a Python-like language) , will Zope > allow me to do this? Or will writing scripts in Zope be so complex that > it renders void my attraction for writing in Python because it is simple > and intuitive, i. e. , rather easy and enjoyable? > > 2. I have already discovered that the gui type input/output functions of > my scripts are the hardest part for me. I am only interested in simple > input and output by end users, but I want it to look good and be user > friendly. I do not need fancy graphics nor multimedia, just well > designed attractive forms and user input followed by outputed results in > verbal and numerical form. Will this kind of input/output be a big > problem using Zope? I almost don't dare ask, but I assume Tkinter will > not be supported by Zope? Will I really need to resort to other means, > such as JavaScript, to do such things ??? How straight forward is input > and output, in event driven programs, in server side scripting using > Zope??? > > 3. Would I be better served by using CGI, once I find a host that allows > me to do so? If CGI scripts written in Python are just as easy and > flexible as using Zope, maybe that's the way for me to go in the > beginning. I will still need to find a Python CGI friendly host company. > > 4. Any suggestions on host companies for Python and/or Zope? > > 5. I do have an always-on cable modem connection in my home. Should I > consider setting up a very simple web server on my own machine (rather > than finding a Zope Host?). If I could set up such a simple server, > allowing me to run server side Python scripts, or even CGI, I could link > to those pages from my other web site, on my non-Python non-CGI friendly > web host site. > > 6. Is Zope simply so complex that I will soon forget about why I enjoy > Python, i. e., intuitive, easy to use fun coding? > > > > General and unrelated comment, for no particular reason, but it comes to > mind in thinking about what I want to do in the project I have in > mind::: > > > It seems to me that Python offers straight forward, self consistent, > logical coding. I like that! But any kind of GUI coding, including > Tkinter, seems to me to be less intuitive, less consistent; involving > more memorization of lots of non-connected facts. Python allows me to > memorize principles and consistently and easily implement them. Most GUI > programming seems more like I recall Java or even JavaScript coding; > random, unconnected stuff that is no fun because it's detailed and > random > > > sorry for the rant. please disregard ;-))))) > > From kbk at shore.net Wed Jun 6 11:52:49 2001 From: kbk at shore.net (Kurt B. Kaiser) Date: Wed, 06 Jun 2001 15:52:49 GMT Subject: floating point in 2.0 References: Message-ID: <3B1E50C9.7D2509F4@shore.net> "Michael P. Soulier" wrote: > In Python 1.5.2, I could do this: > > good = (0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0) > > I could then get back exactly this when I output the value of "good". > However, with Python 2.0, I get this: > > >>> good > (0.0, 0.10000000000000001, 0.20000000000000001, 0.29999999999999999, > 0.40000000000000002, 0.5, 0.59999999999999998, 0.69999999999999996, > 0.80000000000000004, 0.90000000000000002, 1.0) from sys import displayhook def nogeekydisplay(x): print x sys.displayhook = nogeekydisplay Put that in your .pythonrc config file so it will load at startup. **************************************** "The current Python solution has worked for many users, and this should not break it. Therefore, in the default configuration,nothing will change in the REPL loop." - PEP 217 Final While displayhook is a good thing, IMHO Python's value as a beginner language is diminished by the new choice of default output format. It would be interesting to know what percentage of those who use Python "out of the box" really would choose the "more precise" default output which has to be rounded off in their heads.... And now we're pounding on people because they keep asking a simple question. Well, I'm afraid they're going to keep asking!! It-may-not-be-a-bug-but-it's-an-infelicity'ly yrs, KBK more keywords: floatingpoint floating-point bug From piet at cs.uu.nl Tue Jun 26 06:23:55 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 26 Jun 2001 12:23:55 +0200 Subject: File name from file descriptor? References: <3B335A1E.809B3FF7@snakefarm.org> Message-ID: >>>>> Carsten Gaebler (CG) writes: CG> Carlos Ribeiro wrote: >> functionality depend a lot on the OS being used. Could you please tell us >> why do you *need* to make it work using file descriptors? CG> The problem is this: I have a script that is called like CG> ./myscript.py < somefile CG> where somefile is a text file which may or may not be gzipped. To CG> determine whether or not the data is gzipped I read in one byte via the CG> gzip module. If that raises an exception I know the data is not gzipped. CG> But I'd miss the first byte if it is gzipped. Yes, I could store this byte CG> somewhere and then pass it around somehow, but ... you know? :-) So I'd CG> like to open a second 'instance' of the file for reading but I only have CG> sys.stdin's file descriptor. If you are sure that stdin will be a real file you can use: sys.stdin.seek(0,0) -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From heinlr at gmx.de Mon Jun 11 05:13:21 2001 From: heinlr at gmx.de (ssh) Date: Mon, 11 Jun 2001 11:13:21 +0200 Subject: What version of python is the right version? References: Message-ID: <9g21rb$31fu$1@wrath.news.nacamar.de> i think you should use 2.1 when you are now starting ; "Fredrik Steen" schrieb im Newsbeitrag news:slrn9i8vgn.1iv.nospamnntp at lisa.vegasys.se... > What version of python should I use for new projects? > 1.5.2, 2.0, 2.1? > > -- > .Fredrik Steen > http://www.stone.nu/ From sill at optonline.net Wed Jun 13 18:57:27 2001 From: sill at optonline.net (Rainy) Date: Wed, 13 Jun 2001 22:57:27 GMT Subject: base converter References: Message-ID: On Wed, 13 Jun 2001 22:01:08 GMT, Fredrik Lundh wrote: > Jeroen Wolff wrote: >> I looked on the net for a baseconverter written in python. Is there >> any? Something like: >> >> BaseConvert(20,2) --> "10100" > > def BaseConvert(x, b): > out = "" > while x: > x, d = divmod(x, b) > out = str(d) + out > return out > > (why has decimal to binary conversion suddenly turned into a > FAQ the last few months? it wasn't this way in the old days, > and I cannot remember ever having to output things as binary > numbers in a real-life project... can anyone explain?) > > Probably because many tutorials/books at least mention binary and ask you to try converting a few numbers to binary. Newbies read the book, try to convert, then try to confirm with python, hence the questions. > > -- Shine on you crazy diamond - Roger From qrczak at knm.org.pl Fri Jun 22 10:52:57 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 22 Jun 2001 14:52:57 GMT Subject: substitute for c/java's ?: References: Message-ID: 22 Jun 2001 13:10:21 +0200, piet at cs.uu.nl pisze: > MK> def aan(name): > MK> """Utility which returns 'a' or 'an' for a given noun. > MK> """ > MK> return if string.lower(name[0]) in 'aeiou' then 'an ' else 'a ' > > Which programming language is that? Hypothetical Python with if/then/else as an expression. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From aleaxit at yahoo.com Mon Jun 4 04:51:53 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 4 Jun 2001 10:51:53 +0200 Subject: random References: Message-ID: <9fflob32q4r@enews2.newsguy.com> "Nick Perkins" wrote in message news:V7xS6.126372$eK2.29676821 at news4.rdc1.on.home.com... ... > A: (P implies (not D)) > "Given a powerful army, I could not defeat Napolean" > > B: (not (P implies D)) > "Having a powerful army would not ensure that I could..." > > truth table: > P D A:(P implies (not D)) B:(not (P implies D)) > 0 0 1 0 > 0 1 1 0 > 1 0 1 1 > 1 1 0 0 > > The difference is that statement A is true if P is false, > whereas statement B can only be true if P is true. > Therefore, statement B implies that P is false. I think I'm getting confused. From the truth table above, AND for the immediately preceding statement, I would deduce the _opposite_ conclusion than yours, i.e., "B implies that P is _true_". How do you get the "implies that P is _false_" instead? Alex From eppstein at ics.uci.edu Fri Jun 29 12:16:15 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Fri, 29 Jun 2001 09:16:15 -0700 Subject: PEP 255: Simple Generators References: <8hgojtgi94l6ldiafvi06mhfd7cnlo1fbp@4ax.com> Message-ID: In article <8hgojtgi94l6ldiafvi06mhfd7cnlo1fbp at 4ax.com>, Toby Dickenson wrote: > David Eppstein wrote: > >So, back to the topic of PEP255: am I the only one bothered by the fact > >that the inorder example in the PEP is quadratic time, and that it seems > >difficult to use simple generators to yield a tree's nodes in inorder in > >linear time? ... > If that quadratic term is actually dominant for sensibly deep trees, > then I suspect it would not be too hard to optimise away this very > common case at C level: > > for x in : > yield x It is not always possible to completely optimize away the overhead of doing this loop. Proof (probably unconvincing to anyone but a theoretician): one could use simple generators to implement a union-find data structure (probably not the right way of actually implementing UF, but...) class disjointSet: __init__(self): self.parent = None self.generator = self.generate() generate(self): while not self.parent: yield self for x in self.parent.generator: yield x find(self): return self.generator.next() union(self,parent): if self.parent: raise ArgumentException self.parent = parent But there are known superlinear lower bounds on union-find. Note, this code assumes that it's ok to call next() on gen X at the same time as some other gen Y is suspended inside a for loop that's also looking at the elements of gen X; I don't see any reason why that shouldn't be allowed. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From akuchlin at mems-exchange.org Wed Jun 20 15:25:39 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 20 Jun 2001 15:25:39 -0400 Subject: Pythoin MUD (PyMUD?) References: <9gqq3t$hvs$1@brokaw.wa.com> Message-ID: <3dg0cvdkcs.fsf@ute.cnri.reston.va.us> Jonathan Gardner writes: > 1) Is there any existing python muds out there? See http://www.strout.net/info/coding/python/poo/index.html. Its author no longer works on it. (Didn't someone start a project to continue maintaining POO?) --amk From max at alcyone.com Wed Jun 27 15:09:59 2001 From: max at alcyone.com (Erik Max Francis) Date: Wed, 27 Jun 2001 12:09:59 -0700 Subject: Indexing Into A Tuple References: <3B3A0C32.EF179DAE@tundraware.com> Message-ID: <3B3A2F87.64521F2A@alcyone.com> Tim Daneliuk wrote: > for x, y in MyTuple: > print x, y > > Intuitively (and, obviously, incorrectly) it seems to me that the 1st > time through, the second example should return: > > x=("a", "b") and y=("c", "d") > > Instead, it returns x="a", and y="b" just like the first example. > > Why? It means the same thing as for z in MyTuple: x, y = z print x, y See it now? -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Bachelors have consciences, married men have wives. \__/ H.L. Mencken Alcyone Systems' Daily Planet / http://www.alcyone.com/planet.html A new, virtual planet, every day. From see at my.signature Tue Jun 19 23:54:25 2001 From: see at my.signature (Greg Ewing) Date: Wed, 20 Jun 2001 15:54:25 +1200 Subject: humans should use a power of 2 References: <9gjqh201q0o@drn.newsguy.com> <9gjshe02115@drn.newsguy.com> Message-ID: <3B301E71.BC0D575B@my.signature> thinkit wrote: > > In article <9gjqh201q0o at drn.newsguy.com>, thinkit says... > > > >please stop using decimal. most people already only use hexadecimal. "0x" is > >your friend...soon enough humans will be only using powers of 2 as general > >purpose bases. > > > > sigh...this troll has been posting this same drivel all over all kinds of > boards. plus trolling IRC with the same junk. just *plonk* this troll. Huh? thinkit is accusing *himself* (or herself?) of being a troll?!-) Some attribution or other seems to have gone astray here... -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From chrishbarker at home.net Thu Jun 21 14:28:54 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 21 Jun 2001 11:28:54 -0700 Subject: My PyGUI (Re: ANN: PythonCard mailing list) References: <3B31931E.D2F54D78@cosc.canterbury.ac.nz> Message-ID: <3B323CE6.1CB7A388@home.net> Greg Ewing wrote: > You might be interested in looking at a project I > started on a while ago to create an almost-pure-python > GUI library: > > http://www.cosc.canterbury.ac.nz/~greg/python_gui/ > > I haven't worked on it for a while, but there's This looks like a pretty nice start. Do you have any plans to continue the project? Have you posted to this newsgroup in the past to find out if there is enough interest to really get it moving? I'd love it if you would continue, Python really needs this! -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From andres at mail.mamey.com Fri Jun 1 15:47:54 2001 From: andres at mail.mamey.com (Andres Corrada-Emmanuel) Date: Fri, 1 Jun 2001 15:47:54 -0400 Subject: Sourceforge break-in and Python 2.1 security Message-ID: <200106011547.AA2156593690@mail.mamey.com> Hello, I've been reading the reports of the break-in into SourceForge with increasing alarm and I'm wondering if there is a security protocol in place that guarantees the integrity of the Python code being developed there. That is, should I worry that "Fluffy Bunny" claims that he broke into SourceForge 5 months ago and I downloaded Python 2.1 after that? -- ------------------------------------------------------ Dr. Andres Corrada email: andres at mamey.com Mamey - Internet Programming http://www.mamey.com ------------------------------------------------------ -- From loewis at informatik.hu-berlin.de Sat Jun 16 14:44:41 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 16 Jun 2001 20:44:41 +0200 Subject: ASCII decoding error with xml.dom.minidom References: Message-ID: gustafl at algonet.se (Gustaf Liljegren) writes: > Still got a problem with encoding/decoding errors when working with > xml.dom.minidom. I have run into something I didn't ask for. The DOM module > continues to output everything as Unicode strings, even if the file is a > typical 'plain text' XML file with an ISO 8859-1 encoding attribute in the > XML declaration! XML files are never plain text; all XML files are Unicode. See the XML recommendation for details. The file may be represented in some encoding; a DOM implementation is required to present the contents as Unicode. See the DOM recommendation for details. > The input data comes from two directions: one XML file, where the > input takes the form of Unicode strings as described above, and a > mailbox file, in Latin 1. Content from these two sources should be > mixed together in an XML output file. My guess is that you put byte strings into the DOM tree. You should not do that; instead, you should convert all strings to Unicode before putting them into the tree. You can get away with putting byte strings into the tree when they have all bytes <127. > Ideally, I'd like the output XML file in Latin 1. I wonder if there's an > easy way to decode everything in the DOM object to Latin 1, so that this > won't happen? No, that's not possible. Currently, toxml will return a Unicode string, it is then the caller's responsibility to convert this to UTF-8 (as toxml will not have put an encoding directive into the document). toxml should probably be extended to support various output encodings. Even if it does, the DOM tree still must contain Unicode strings only. Regards, Martin From bsb at winnegan.de Sat Jun 23 10:48:26 2001 From: bsb at winnegan.de (Siggy Brentrup) Date: 23 Jun 2001 16:48:26 +0200 Subject: emacs speedbar for python mode? In-Reply-To: <9h24tq$f7b$1@news1.xs4all.nl> References: <9h24tq$f7b$1@news1.xs4all.nl> Message-ID: <87bsnfxnet.fsf@winnegan.de> boud at rempt.xs4all.nl (Boudewijn Rempt) writes: > Amardeep Singh wrote: > > > try M-x speedbar > > Wonderful! Is there perhaps also a way to automatically > open the speedbar? Put the following into your .xemacs: (add-one-shot-hook 'python-mode-hook 'speedbar) There is a drawback though when you have file local-variables, no time to investigate further now. Regards Siggy -- Siggy Brentrup - bsb at winnegan.de - http://www.winnegan.de/ ****** ceterum censeo javascriptum esse restrictam ******* From daniel at dittmar.net Thu Jun 28 14:45:26 2001 From: daniel at dittmar.net (Daniel Dittmar) Date: Thu, 28 Jun 2001 20:45:26 +0200 Subject: Introspection References: <25b2e0d9.0106280923.31cadb06@posting.google.com> Message-ID: <3B3B7B46.CF46C4FE@dittmar.net> > Is there a good resource that gives comprehensive coverage of Python's > introspection capabilities all in one place? Download wxPython, start the demo and look at 'Cool Contribs/pyTree'. This uses inspection to drill down a module to functions and classes to members etc. Daniel From pih at oek.dk Mon Jun 4 07:55:03 2001 From: pih at oek.dk (Peter I. Hansen) Date: Mon, 04 Jun 2001 13:55:03 +0200 Subject: MySQL module Message-ID: <3B1B7717.7E53510F@oek.dk> Hi What is the recommended module for MySQL ? Is it the MySQL module or the MySQLdb module (which is in v. 0.35 !) ? Or is it something completely different ? /Peter From James_Althoff at i2.com Fri Jun 8 18:56:44 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Fri, 8 Jun 2001 15:56:44 -0700 Subject: ROGER SESSIONS DISQUALIFIES JYTHON AS "FREEWARE" Message-ID: Samuele Pedroni wrote: >About the current 2 devels : some more devels would be helpful, >not much for quality but for other obvious reasons . > >regards, Samuele Pedroni. A _HUGE_ thanks to Finn and Samuele who have done an amazing job on Jython! Jim From nperkins7 at home.com Sun Jun 10 04:33:00 2001 From: nperkins7 at home.com (Nick Perkins) Date: Sun, 10 Jun 2001 08:33:00 GMT Subject: floating point in 2.0 References: <9fiptc$m9d$1@panix2.panix.com> <3B1D154B.81016685@home.net> <9fj706$27u$1@panix3.panix.com> <3B1FCDF3.6DBFABF8@home.net> Message-ID: <0hGU6.182229$eK2.41756663@news4.rdc1.on.home.com> "Chris Barker" wrote: > 1 / 10 takes only one digit to represent accurately in base ten but > takes as many bits as you have to not precisly represent in binary. A > similar situation can be true in the reverse direction. decimal -> binary 0.1 0.0001010101010... or whatever it is.. but.. The reverse condition can not happen. Every n-digit binary float can be exactly represented by n decimal digits. binary -> decimal 0.1 0.5 0.01 0.25 0.001 0.125 0.0001 0.0625 0.00001 0.03125 0.000001 0.015625 ... ... Adding up any combination of these rows to produce any binary number, still produces a decimal number of the same length as the binary number. That is why decimal numbers are more powerful than binary, because for any given length, the set of numbers representable in decimal is a superset of those representable in binay. From akhar at videotron.ca Sat Jun 9 04:43:20 2001 From: akhar at videotron.ca (akhar) Date: Sat, 9 Jun 2001 01:43:20 -0700 Subject: is c faster? Message-ID: I have a script I wrote in python , I love the time it took me to devellop it faster than i could have done it in C. however after full review of my code I am not sure I can optimize it any more( it basicaly consist of importing an image and tranforming into a matrix to perform some for-looped operations on it) : I went from 20 seconds to 2. I can't seem to bring the execution time down :( . would C code be faster? by what factor? can I optimise my code more? how? Stephane NB: I have a dual-celeron 400mhz with 256Mo of ram and a 20 gig 7200rpm HDD Also anybody with a G4 with PIL and numpy install to test the speed of my code?(my friend has a 1GHz and it takes him .65 sec to execute I would like to know if an altivec enhanced computer would fair better) From mail at fredriks.org Thu Jun 28 10:35:54 2001 From: mail at fredriks.org (Fredrik Stenberg) Date: Thu, 28 Jun 2001 16:35:54 +0200 Subject: C extension problem (Solaris) In-Reply-To: <874rt0hkbi.fsf@elbereth.ccraig.org> References: <874rt0hkbi.fsf@elbereth.ccraig.org> Message-ID: On 28 Jun 2001, Christopher A. Craig wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Though I have used the C API before, this was my first attempt at > defining a new type with it, and I had a problem. It works fine on my > Linux/Intel box, but when I try to compile it on my Solaris 8 > UltraSPARC box it has an item in the module dictionary that contains a > non-working reference to the subtraction routine. > Found the error, you forgot to end static PyMethodDef with {NULL, NULL}. i.e, static PyMethodDef crat_methods[] = { {"_testgcd", crat_testgcd, METH_VARARGS, crat_testgcd_doc__}, {"rational", Rational_new, METH_VARARGS, crat_Rational_doc__} }; should be changed into, static PyMethodDef crat_methods[] = { {"_testgcd", crat_testgcd, METH_VARARGS, crat_testgcd_doc__}, {"rational", Rational_new, METH_VARARGS, crat_Rational_doc__}, {NULL,NULL} }; /princeps From BrianQ at ActiveState.com Tue Jun 12 17:13:02 2001 From: BrianQ at ActiveState.com (Brian Quinlan) Date: Tue, 12 Jun 2001 14:13:02 -0700 Subject: Reference Counts & Extensions.. In-Reply-To: <6fvV6.248430$Z2.2868464@nnrp1.uunet.ca> Message-ID: <003701c0f384$77b9c5b0$b503a8c0@activestate.ca> John wrote: > I'm writing an extension module and in my functions I > return something > like: > > return Py_BuildValue("i", 1); > > Will this cause a memory leak? Should I be doing this: > > PyObject *pyObj = PyBuildValue("i", 1); > Py_INCREF(pyObj); > return pyObj; > > Also, what if I make pyObj a global variable, can I then > use the first > method since the reference will be borrowed, like so: > > return pyObj; Py_BuildValue returns a new Python object with a reference count of one. The call to Py_INCREF is not required. But I don't understand why you were considering increase the reference count of pyObj to remove a potential memory leak; increasing the reference count makes the object persist for one more reference count decrement i.e. you were going the wrong way :-) If you make pyObj a global then you must increment the reference count every time you return it to Python. From nas at python.ca Sun Jun 24 19:08:38 2001 From: nas at python.ca (Neil Schemenauer) Date: Sun, 24 Jun 2001 16:08:38 -0700 Subject: PEP 255: Simple Generators In-Reply-To: ; from glyph@twistedmatrix.com on Sun, Jun 24, 2001 at 03:18:32PM -0500 References: <20010621134445.B20524@glacier.fnational.com> Message-ID: <20010624160838.B30403@glacier.fnational.com> Glyph Lefkowitz wrote: > New users should not be using generators -- it's an advanced control > structure with some interesting uses, [...] I strongly disagree with this point. New users SHOULD be using generators. I believe they are applicable in a surprising number of causes and are no harder for new users to learn than a number of other language features. They are certainly simpler than threads. Neil From willenpart at a1.net Mon Jun 4 14:58:37 2001 From: willenpart at a1.net (Michael Willenpart) Date: Mon, 4 Jun 2001 20:58:37 +0200 Subject: AW:Re: Zyclic updating of toplevel windows References: Message-ID: > > Now my question: > > Is is somehow possible to auto-update the toplevel-windows? e.g. to > > import time > while 1: > update_graphs() > time.sleep(600) # seconds > Thank you for the answer! The problem is: If I write this sleep statement within the function were the toplevel window with the graphic diargram is created, the functions of the main window are not accessable (it's not possible to push one of the buttons in the main window). Probably the program stucks in the while loop. Firstly, I don't know how to implement such a while loop within the mainloop() of my program. And secondly I also don't know how to update/access a toplevel window from my main program. From grante at visi.com Tue Jun 19 16:56:08 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 19 Jun 2001 20:56:08 GMT Subject: String encode() method error handling options? References: Message-ID: In article , M.-A. Lemburg wrote: >Grant Edwards wrote: >> >> The documentation for the encode() method mentions that the >> default action for an encoding error is to raise ValueError. >> The other options are 'ignore' and 'replace'. Can anybody >> point me to documentation on or examples of the ingore and >> replace options? > >The 'ignore' option will simply drop the character which cannot >be encoded (e.g. because there is no mapping for the Unicode >character in the chosen character set), the 'replace' option >will currently always write a '?' instead of the Unicode character >which caused the trouble. Thanks! Next time it happens I'll try using 'replace' and see what characters are causing the problem. >Latin-1 is not the same as the default Windows encoding which >typically is one of the cp125x encodings depending on your locale. >That could be the cause of the ValueErrors you are seeing. I'm sure you're right. Latin-1 seems to support enough of the local Windows encoding that I very rarely see the problem. -- Grant Edwards grante Yow! I decided to be JOHN at TRAVOLTA instead!! visi.com From opengeometry at yahoo.ca Sat Jun 23 17:45:38 2001 From: opengeometry at yahoo.ca (William Park) Date: Sat, 23 Jun 2001 17:45:38 -0400 Subject: VI In-Reply-To: <20010623121049.B21921@trufflehunter.hyperlinq.net>; from tjg@hyperlinq.net on Sat, Jun 23, 2001 at 12:10:49PM -0700 References: <9g9f1v$7oqr5$1@ID-11957.news.dfncis.de> <9gaul7$mth$2@brokaw.wa.com> <52e5ab5f.0106182325.4d1fe0d0@posting.google.com> <9h0kjj$h7f$1@brokaw.wa.com> <20010623121049.B21921@trufflehunter.hyperlinq.net> Message-ID: <20010623174538.B504@node0.opengeometry.ca> On Sat, Jun 23, 2001 at 12:10:49PM -0700, Timothy Grant wrote: > On Fri, Jun 22, 2001 at 04:33:49PM -0700, Jonathan Gardner wrote: > > If I could only figure out how to get it to indent the next line > > when I end a line with ":"... > > set cinwords=class,def,elif,else,except,finally,for,if,try,while > > might do what you are looking for. Also, don't forget set smartindent -- William Park, Open Geometry Consulting, 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From nperkins7 at home.com Sun Jun 3 17:25:19 2001 From: nperkins7 at home.com (Nick Perkins) Date: Sun, 03 Jun 2001 21:25:19 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> <9fcumq0215o@enews2.newsguy.com> Message-ID: <3XxS6.126499$eK2.29771284@news4.rdc1.on.home.com> "Alex Martelli" wrote in message news:9fcumq0215o at enews2.newsguy.com... > "Even given (a powerful army) I could not (defeat Napoleon)". > Do you read this as "having a powerful army IMPLIES I > cannot defeat Napoleon"? This doesn't sound right to me. > Surely it's "NOT (having a powerful army IMPLIES I can > defeat Napoleon)"? Funnily enough I have already posted (somehwhere near here), my exact interpretation of these two statements. However, I see what you are saying about the word 'Even'. In english, seems to say that both conditions: ( having a powerful army, and not having one), imply (not defeat N) I agree that that is a common english interpretation. I was taking the statements to be literal logical statements, and did not interpret the word 'even' as meaning that there are two implications: 1: (powerful army) -> (no defeat) 2: (not powerful army) -> (no defeat) Of course these two 'cancel out' to simply: (no defeat) Anyway, I am sure we both understand first order logic. (It is english that is open to interpretation!) From akuchlin at mems-exchange.org Thu Jun 28 17:49:35 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 28 Jun 2001 17:49:35 -0400 Subject: PEP scepticism References: Message-ID: <3dels41dhs.fsf@ute.cnri.reston.va.us> Roman Suzi writes: > I think improving Python itself is also improving what you've > just mentioned. No it isn't. Adding language features does not improve the confusing and incomplete MIME modules currently in the standard library. It does not remove the outdated demo programs from the distribution. It does not add more documentation. It does not bring us any closer to having a module catalog. It does not increase Python's visibility outside of the Python community. My point is that users are not currently saying "Gosh, Python doesn't have generators, so I won't use it." They're saying "Wow, there's a lot of useful libraries for Java; I'd better use it to be able to use them." --amk From aahz at panix.com Fri Jun 15 15:30:48 2001 From: aahz at panix.com (Aahz Maruch) Date: 15 Jun 2001 12:30:48 -0700 Subject: coroutines? References: Message-ID: <9gdnp8$80c$1@panix3.panix.com> In article , David Eppstein wrote: > >What I really want is coroutines. See PEP 255, posted just a couple of days ago. ;-) -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista I wasn't licking it, I was chewing it. From mwh at python.net Sun Jun 24 18:58:48 2001 From: mwh at python.net (Michael Hudson) Date: 24 Jun 2001 23:58:48 +0100 Subject: Why sys.ps2 after interactive #-line? References: <3b34d6cc.89984150@wa.news.verio.net> Message-ID: bokr at accessone.com (Bengt Richter) writes: > >>> > >>> # comment > ... # why ... at beginning of this line? > ... # and this, and the next? > ... > >>> > > Why not a fresh sys.ps1 prompt after each #-line ? Because That's The Way It Is. The heuristics the Python prompt uses to decide whether a statement typed interactively is finished are a bit hairy. They seem to work most of the time though. > Just curious :) Well, if you're *really* curious, you should probably read the source... Cheers, M. -- 41. Some programming languages manage to absorb change, but withstand progress. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From aleaxit at yahoo.com Sun Jun 3 16:09:59 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 3 Jun 2001 22:09:59 +0200 Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3B183CFF.A90213BA@san.rr.com> <9fa54s0fkb@enews2.newsguy.com> <3B1A7FEB.E466824E@san.rr.com> Message-ID: <9fe5q302hbg@enews2.newsguy.com> "Darren New" wrote in message news:3B1A7FEB.E466824E at san.rr.com... > Alex Martelli wrote: > > _Complete_ information about how the numbers are generated > > requires complete information about the state of their generator. > > Yep. The fun thing about quantum physics is that *complete* information > is available about the state of the generator, and you *still* don't Except it's not -- you can't be told position AND momentum of the particles (either, but not both). The information isn't (and presumably can't) be complete. > > Is your claim, then, that "randomness" MUST be used ONLY > > for systems which, at the level of observation under discussion, > > No. The point I'm discussing is that an algorithm cannot generate > randomness. Maybe it can't "generate" the randomness, but it can "unearth" it if it's hidden in the underlying "deep truth of mathematics". Which seems to be a way in which one can read C's thesis. Do the physical generators actually "generate" the randomness, or do they rely on underlying "deep randomness in the deep truth of physics", just unearthing some of it (e.g. by suitable amplification)? > No matter how much complexity you add to a mathematical > formula, it's still 100% predictable if you know what the formula is. So the _amount_ of randomness is constrained by 'program size'. Thus, it's finite for a finite-size program (program size being an upper bound, and it being, it seems, impossible to get a lower bound). > This is untrue of physical random number generators. I.e., a physical RNG cannot be finitely described? I think it can be, depending on its design -- and no doubt with the same as-close-to-1-as-desired-probability constraints we need to use on algorithms when we're running them on any physical piece of equipment. Deck-shuffling theory being an example, since a deck of cards that is shuffled has long been regarded as a typical "generator" of randomness. Dice that are massive enough may presumably be similarly finitized -- give me the initial state (position & momentum) accurately, and in principle I can apply classical mechanics and compute the positions at rest. Even if the dice are thus predictable-in-principle, it doesn't mean they aren't a RNG -- maybe not a 'perfect' one if you include the condition about being given ALL information (or all AVAILABLE information for a good-enough value of 'available':-). No doubt better-in-principle generators can be designed, taking advantage of the impossibility to have "complete enough" state information. I dunno, lava lamps, whatever. But that doesn't mean that suddenly card decks or dice "aren't random" any more (or that they never were). For all "finite-randomness generators", the interesting issue becomes "how much randomness". > > Chaotic effects may > > well ensure that the number of bits of information that would > > be needed to obtain prediction is higher than any practical > > measure. > > In an algorithm, it's never going to be bigger than your seed. Not sure what you mean by "seed" in the general case of any algorithm whatsoever. Even assuming the algorithm has to have an input and we must call the initial input value 'seed', what can you predict if all I tell you is that "the seed" is 32304823408349093? Nothing, it seems to me, unless the information you receive also includes the program that's going to much this "seed". So, why confuse things by putting "seeds" into the picture? Let's just say that amount of randomness (as measured in bits) can never be greater than the size of the program -- it's easier to account for any literal constants as part of the program's size than vice versa, isn't it? Well, Chaitin's approach boils down to defining amount of randomness as _minimal_ programsize to generate a sequence (which turns out to be undecidable in general, if I understand him correctly: any actual program that does the generation gives me an upper bound on the randomness of its output, but in general I have no way to prove a lower bound). > > So what is so special, that distinguishes a computer system > > from a deck of cards -- considering both systems at a > > macroscopic enough level that quantum effects can be > > ignored, which is easier for the deck of cards I think but > > is commonly done for well-designed computers too:-) -- > > so that I *could* get randomness from one and not the > > other? > > You don't get randomness from a deck of cards. You get randomness from > *shuffling* a deck of cards. The randomness comes from not knowing > exactly what the fingers were doing. Ah, from lack of information? The information is apparently not-available because nobody bothered to notice it?-) So is lack of information randomness?-) > If you shuffled the cards algorithmically (e.g., with a mechanical card > shuffler that very reliably put them in the same order) then they > wouldn't be random at all, *if* you knew exactly how the mechanical card > shuffler worked. That's the equivalent of using an algorithm to generate > pseudo-random numbers. And it turns out to be a good approximation of what happens when a human being shuffles cards in practice -- he or she tends to give a finite (and small) number of riffles that are rather predictable. Particularly when the original unsorted deck has 'structure', it's interesting to study to what extent that structure is broken up and to what extent a trace of it is preserved. For example, in classic rubber bridge, much of the deck before shuffling has been grouped in 'tricks' of 4 cards each which tend to be of the same suit, or 3 in a suit and 1 in another. If it was dealt without any shuffling, the 4 hands would tend to be rather "balanced" -- with similar number of cards in the various suits. Depending on the shuffling kind and amount used, this structure is gradually broken down until the probabilities approximate "theoretical" ones (those that would obtain if each hand of 13 cards were built by sampling without repetition from the deck). Measuring the _amount_ of randomness generated by various shuffling methods and amounts thus becomes quite interesting (for card-play theorists, at least -- maybe to some extent for players & others too). Saying that the resulting deck-order "isn't random at all if you knew" again seems to consider randomness totally congruent to lack of information. It isn't *perfectly* random, sure, but that's a long way from saying it isn't random *at all*. Measuring the _amount_ of randomness (maybe due to the exact amount of information you lack, if you want to frame it this way) is the interesting part. A shuffled deck of cards may be very far from your Platonic ideal of "a physical RNG", but it's pretty physical, has been used as a RNG for centuries, and (as any card-player can attest) generates or unearths or whatever SOME amount of randomness. Maybe those who shuffle card decks to get randomness are "in a state of sin" (those who call that deck "the Devil's Picture Book" would no doubt agree:-), but they do get (finite amounts of) randomness, not 'none at all'. > > It seems more fruitful to me to consider the amount > > of information, i.e., a quantitative assessment of randomness, > > rather than claim that only if that amount is 'infinite' can > > the word 'randomness' be properly used. > > It depends, again, on which meaning of "random" you want to use. For > some folks, "unpredictable" and "random" are two different things. And "random" means instead...? Didn't you also define it as such? > > Taking a set of states and deeming them equivalent can > > perfectly well be done -- who ever gets an "exact" number > > from physical measurement anyway?! It applies just as > > well to the finite definition of randomness. > > Is fine. If you want to call "unpredictable" and "random" the same > thing, power to you. I thought you were trying to understand the Von > Neuman quote, not to argue that he's using words you don't like. I have no objections to the words he's using -- at most I may have some to the meaning he might be attaching to them:-). I'm not particularly interested (in this thread) to understand JVN, I _am_ interested in applying the word "randomness" to the breaking of structure and *difficulty* of prediction that I can study in finite systems, rather than have it reserved for some kind of *impossibility* (infinite difficulty) of prediction. > > > I think "random" here means "unpredictable". Tossing dice will lead to > > > random/unpredictable results, even if you know everything there is to > > > know about the dice and the table. Generating numbers between 1 and 6 > > > will not be unpredictable if you know the seed and algorithm. > > > > If you have COMPLETE information about the dice &c (taking > > a HUGE number of bits, no doubt) you can predict their > > trajectories, bounces (if allowed), rolls, AND final results. > > No. Quantum effects will screw that up. Aren't dice (by far) massive enough to avoid that? > > Why should these macroscopic-physics effect be inherently > > unpredictable as you claim? > > If you start with a pooltable with perfect spheres for poolballs, > perfectly racked, you cannot sink all 15 balls with your eyes closed. > The probability cloud for the location of the last ball will be larger > than the pooltable. Interesting -- I can't refute this claim as I wouldn't know how to go about it. Is this result independent of the masses and diameters of the balls, temperature, &c, or does it specifically hold for the actual average sizes/temperatures/&c as used in pool? Unfortunately, pool is definitely not among my skills. > > If you have complete information about the algorithm and > > the relevant part of the state of the computer where it > > runs, again you have predictability. > > And that's why VN said calling it "random" is sinful. Aha, I knew it would get to attaching sinfulness to the way one uses words -- and, wouldn't you know it, exactly the word-use I care about in the context of this thread: what's now being directly attacked (by your interpretation of VN's words -- I do not know how demonstrable this interpretation is) is the attempt to measure the *amount* of randomness... the amount of information that would minimally afford prediction about the random phenomenon. If anything AT ALL predictable cannot "by definition" be random AT ALL, then "amount of randomness" becomes a meaningless, self-contradictory phrase. Which is exactly what I think is unsupportable... Alex From root at rainerdeyke.com Tue Jun 26 23:18:12 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 27 Jun 2001 03:18:12 GMT Subject: Should I use a dictionary? References: <9h93p9$4d8$1@panix2.panix.com> Message-ID: "phil hunt" wrote in message news:slrn9ji5aq.dqn.philh at comuno.freeserve.co.uk... > On 25 Jun 2001 21:41:13 -0700, Aahz Maruch wrote: > >In article , > >Greg Jorgensen wrote: > >> > >>When you want to sort the messages, use your own sort function to compare > >>the message date/time: > > > >That's a Bad Idea if there are a lot of messages; such comparison > >functions are expensive. > > How else do you do sorting, without comparisons? Counting sort or bucket sort, but I think he's really refering to the fact that this: l.sort() is much faster than this: l.sort(f) on the current implementation of Python, where 'l' is any long list and 'f' is any function or other callable object. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From edsinger at ai.mit.edu Mon Jun 25 09:56:43 2001 From: edsinger at ai.mit.edu (Aaron Edsinger) Date: Mon, 25 Jun 2001 13:56:43 GMT Subject: stdout and C extensions Message-ID: Hi, I found a bit of discussion on this in the archives, but no resolution. My c extension module uses printf() to write to stdout. Of course, this output doesn't show up when using IDLE, but does when using Python from the console. Has anyone come up with a clever way to get the stdout output to appear in the IDLE console window without having to change the actual C code? --aaron Aaron L. Edsinger Humanoid Robotics Group MIT Artificial Intelligence Lab 617.253.6532 | www.ai.mit.edu/people/edsinger/index.html From quango at watervalley.net Thu Jun 21 22:01:14 2001 From: quango at watervalley.net (Chris Lawrence) Date: Fri, 22 Jun 2001 02:01:14 GMT Subject: Python MUD (PyMUD?) References: <9gqq3t$hvs$1@brokaw.wa.com> Message-ID: <20010621.210107.1605908235.24783@watervalley.net> In article , "Remco Gerlich" wrote: > Jonathan Gardner wrote in comp.lang.python: >> 2) Is there any mud hackers out there with advice or ideas? This thing >> is as fresh as it gets, I want crazy and wacky ideas you've been >> mulling about in your mind for the past 25 years, and I want this mud >> to be truly unique. > > I'm interested. Years ago I was a mud addict, always lpmuds, been admin > on some. And I still think LPC is way cool. Moi aussi. I was a big LPmud guy. I'd look back and say I should have been paying more attention to my studies, but being a creator probably kept me from getting into worse trouble escaping from everyday life ;-) Indeed, one of the things that attracted me to Python was its similarity to LPC, at least in the sorts of things you could do with it and the facilities for mappings (dictionaries) and arrays. > I've been thinking a bit about a mud in Python, the problems come when > you run both the driver and code that was wrriten by wizards in the game > (their areas) in the same interpreter. You need to shield the driver > internals from the mud's objects. Although that's maybe possible with > rexec and similar, it's still easy to do a DOS attack - you need only > one drunken wizard to code an infinite loop, and your driver locks up. I > haven't found a solution yet, haven't thought about it enough. It's very > interesting :). My thought at the time (when I was trying to wrap my brain around it) was to set an alarm signal for +2 seconds; if the signal was raised, I raised a Python exception. Of course, there are still cases where the exception might not happen (while 1: pass). If I had the time and inclination again, I'd go back and hack on it some more, especially now that I have a machine that could actually host a MUD with a full-time T1 connection. Definitely would be fun to play with (did I just volunteer? ;-) Chris From tim.one at home.com Sat Jun 30 01:56:08 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 30 Jun 2001 01:56:08 -0400 Subject: PEP scepticism In-Reply-To: <9hhgbc$e50ak$2@ID-89274.news.dfncis.de> Message-ID: [Bernhard Reiter] >>> This might reduce the main advantage of Python to be clear and easy >>> and mostly have one good formulation on how to express what you want >>> to program in a structured way. [Tim] >> While I expect everyone would agree those are advantages of >> Python, I doubt there's consensus that those 4 advantages are "the >> main" advantage. Language design is more complex than that. [Bernhard Reiter] > Rethinking this I still think this are _the main_ advantages > compared to other languages. You're allowed to use Python for any reason that suits you . > What do you think the main advantages are? :) Python minimizes my unproductive programming time, and that's an *empirical* observation over years of using Python along with many other languages. I'm really not sure how it accomplishes it, but that's its main advantage to me (and, BTW, that's the core problem with Second System Syndrome too: I'm not sure Guido understands exactly how Python does it either). Part of it is expressivity coupled with lack of tricks; as a counter-example, APL is highly expressive provided you buy into the core trick that "everything's an array". Python lets (more, encourages) me to treat different things differently, yet is still highly expressive across many different kinds of things. Now when we get to: >>> Examples are: >>> - augmented Assigments >>> - Lists comprehensions >>> - Simple Generators my reaction to all is the same: they increase expressivity, each significantly reducing the gap between how I think of a problem and what I have to type to get the machine to think the same way I do. They *increase* "clear and easy" for me, so in that sense I'm a "clear and easy" fan too -- but people won't agree on what "clear and easy" mean. I've even been told that some people find Perl clear and easy . > ... > However not having augmented assignment made me think about it and > the clarity you gain when writing it more explicitly. We won't agree on that, so good thing for me that I think more like Guido here . I *think* "add y to x", or "bump x by y", not "add x and y and then replace x with the sum so obtained", so x += y is much clearer to me than x = x + y and I really mean "much". Faced with the latter, I always have to *deduce* "ah, OK, it's adding y to x", and that's a drag on my time. I hated that in Fortran and Pascal, and in Python too before augmented assignment was added. In Lisp it was easy to write macros, but then too easy to write so many macros that you can't make head or tail of the mess a few months later. Etc. Whenever Python changes to let me say what I intend more directly, I like it. I confess I don't care at all whether something is obvious at first glance. The ABC language tried that as far as humanly possible, and while it may have been great for teaching, it was a PITA for getting real work done. Part of Guido's genius was in extracting the pieces of ABC "that worked" on all levels (for both newbies and experts), tossing the parts that didn't, and incorporting new gimmicks akin to the parts of ABC that worked best. The acid test for me isn't whether a newcomer understands a gimmick at first sight, but whether (a) they can be taught it, and (b) whether, once learned, it's hard to *forget*. Picturing array indices as pointing *between* elements is the canonical example of that: it makes no sense at all to many newcomers, yet once learned it's compelling and endlessly fruitful. I'm all in favor of Python adding thousands of new gimmicks like that, but-- alas --the supply of comparably jewel-like ideas appears severely limited. >> Not even Scheme stayed *braindead* austere forever, you know . > That's why fresh, small languages are designed sometimes... And always will be. "Everything is an X" appeals to young language designers (you can't get "small" without that), and whether X is macros, strings, arrays, lists, classes, lambdas or combinators doesn't really matter: they get a spare but trick-laden language in the end, and expressivity sucks unless you share the delusion that everything's an X. Python's only nod in this direction was "everything's an object", but the semantics shared by all objects is so tiny (you can apply id() and repr() and str() and type() to anything) it doesn't get in the way. Part of the danger in PEPs 252-254 is in trying to expand this commonality. > ... > Maybe my subject of the original was suboptimal, but there is > some connection and I had to start expression what my concern is > somewhere. Here's something else to consider: as with the examples above, almost all changes to Python have been debated for years, and the backlog of old ideas with a strong constituency decreased rapidly over the last year (as old ideas finally got implemented or rejected). Changes that pop up out of thin air (i.e., without a long history) are much rarer, and rarely significant in the overall scheme of things. The strongest counter-example I can think of is the addition of Unicode strings, which popped out of nowhere (wrt the original language design and the initial year of "feature requests"), but were added in such a way that most American users still have no idea Python has them <0.7 wink>. So I expect the pace of language (but not library) change to slow, simply because we're running out of strong backed-up ideas for the core. but-then-most-debates-are-about-yesterday's-problems-ly y'rs - tim From JamesL at Lugoj.Com Fri Jun 29 17:02:34 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Fri, 29 Jun 2001 14:02:34 -0700 Subject: Augmented Assignement (was: Re: PEP scepticism) References: <6qn16r7i69.fsf@abnoba.intevation.de> <9hhu6701d5j@enews2.newsguy.com> <6qae2r71hd.fsf@abnoba.intevation.de> Message-ID: <3B3CECEA.5D02A66E@Lugoj.Com> Guido van Rossum wrote: > Sorry, I don't understand why people can seriously argue *against* > augmented assignment. And "!=" is augmented assignment for the "!" operator, which does what again? When you want to make a language look like it was designed by a committee, first thing you do is establish the committee. Well that part is done. > It just baffles me. And now for something completely different, we will baffle Guido, er, I mean a cat. By the way, just how did so many mathematical libraries come to be written in Fortran, which didn't have augmented assignments? (Just doing my baffling part.) > What kind of Spartan upbringing did you have? Scheme? Are those Spartans scheming again? Never look a gift horse in the mouth, or something like that. Never=cared=for=Scheme=and=can't=get=the=hang=of=these=hyphenated=endings=ollie. (So, is our language designer baffled enough yet?) From mikael at isy.liu.se Fri Jun 1 07:49:26 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 01 Jun 2001 13:49:26 +0200 (MET DST) Subject: who coined the term "real numbers" (was Re: Against PEP 240) In-Reply-To: <9f7m9i020v2@enews1.newsguy.com> Message-ID: On 01-Jun-2001 Alex Martelli wrote: > "Complex" is due to Gauss, 1831, specifically at first for numbers > of the form a+bi with a and b both integers -- "Tales numeros > vocabimus numeros integros complexos, ita quidem, ut reales > complexis non opponantur, sed tamquam species sub his contineri > censeatur". Earlier, they were called "imaginary". Today, numbers of the form a+bi with a and b both integers are called Gaussian integers. If you wish, you can say that the set is generated by i, which is normally written . This is also a square lattice in the complex field. If you instead use a hexagonal lattice in the complex field, you get the so called Eisenstein integers. This set is generated by a third root of unity, i.e. e**(2pi/3). yet-another-off-topic-science-thread-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: 01-Jun-2001 Time: 13:48:02 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From philh at comuno.freeserve.co.uk Sat Jun 30 07:13:02 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Sat, 30 Jun 2001 12:13:02 +0100 Subject: PEP scepticism References: Message-ID: On Sat, 30 Jun 2001 01:09:03 GMT, Rainer Deyke wrote: >"phil hunt" wrote in message >news:slrn9jq3rc.qg9.philh at comuno.freeserve.co.uk... >> On Fri, 29 Jun 2001 17:43:34 -0400, Tim Peters wrote: >> >Or the other existing method: >> > >> > # This is a multi-line comment. >> > # Although it sure looks like a sequence of >> > # single-line comments . >> >> This is truly bad, because it makes it harder to add new lines; >> you have to type "# " repeatedly when adding new comment text, which >> breaks the flow of thought -- at least it dores for me. > >Strange. In C++, I always use '//' for multiline comments in favor of >'/**/'. ('//' in C++ is equivalent to '#' in Python.) This makes the >comment more readable IMO. Why not just type the comment text first, and >add '#' marks later? That's what I do. I still find it an irritating hassle. I appreciate your point that beginning all comment lines with // makes for visibility. When I have long multi-line comment, I usually enclose them like this: /********* Start of long comment : : : end of long comment *********/ Which I find nice and visible. -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From mwh at python.net Wed Jun 13 09:40:59 2001 From: mwh at python.net (Michael Hudson) Date: 13 Jun 2001 14:40:59 +0100 Subject: How to tell if interpreter is in interactive mode References: Message-ID: "John Copella" writes: > I have some code in a module that I need to run only when the > interpreter is running interactively. Is there any way to test for > this at run time? There's a C global (Py_InteractiveFlag or somesuch), but I don't think it's exposed to Python. > I have looked at sys.stdin.isatty(), but this returns 1 when running > non-interactively as well (unless you do something odd like redirect > stdin to /dev/null). Well, yes, seeing as sys.stdin is still connected to a tty... Are you sure you want to do this? If the user's using idle or my pyrepl or something similar, then Python isn't running interactively from its point of view, but is from the user's. Cheers, M. -- FORD: Just pust the fish in your ear, come on, it's only a little one. ARTHUR: Uuuuuuuuggh! -- The Hitch-Hikers Guide to the Galaxy, Episode 1 From donod at home.com Sun Jun 17 21:53:04 2001 From: donod at home.com (Don O'Donnell) Date: Mon, 18 Jun 2001 01:53:04 GMT Subject: graceful version detection? References: <3B2D2F44.50007@red-bean.com> Message-ID: <3B2D5F78.B581DFF1@home.com> Ben Collins-Sussman wrote: > > Please excuse me if this is a common newbie question; I didn't find it > in the FAQ or tutorial. > > If I write a python script that uses 2.X features, and then run it with > a 1.X interpreter, I get a bunch of exceptions. Presumably this happens > during the initial byte-compilation. > > I'd like the script to instead gracefully print: > > "Sorry, this program requires Python 2.0 or higher." > > I tried writing some code to do this by parsing `sys.version' at the top > of my program; but as I said, the byte-compiler seems to choke first. > > What's the correct solution? > Ben, sys.version is a human readable string >>> import sys >>> sys.version '2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)]' This would require some fancy regular expression matching to extract the version number in the most general case. But, sys.version_info (new in ver 2.0) is a tuple which makes it easy to test the version number: >>> sys.version_info (2, 1, 0, 'final', 0) Since tuples are compared element by element, left to right, for (at most) the length of the shorter operand, here's what I do: if sys.version_info < (2, 1): print "Sorry, this program requires Python version 2.1 or higher." sys.exit(1) or if sys.version_info < (1, 5, 2): ... You can also use sys.hexversion, but trying to express the version numbers in hex and remembering how many hex digits are needed is more trouble than it's worth. Check the Library Reference for the sys module for these and a lot of other system goodies. Good luck, -Don From nperkins7 at home.com Sun Jun 3 02:52:52 2001 From: nperkins7 at home.com (Nick Perkins) Date: Sun, 03 Jun 2001 06:52:52 GMT Subject: Obsolesence of <> References: <3B17787F.266644CB@student.gu.edu.au> <3B1707A3.86AB1789@artenumerica.com> <3B17E8B3.F64581DE@artenumerica.com> <3B17FE8E.EFDF95F2@san.rr.com> <3B182360.1C6362FB@artenumerica.com> Message-ID: <89lS6.123310$eK2.28576139@news4.rdc1.on.home.com> In defense of Jose, i think he was trying to provide a 'total order relation' on the complex numbers, whereas the 'simple' method is a 'partial order relation'. The difference would be that in a total order relation, no two different complexes would map to the same real, so no two different complexes would compare as 'equal'. I am not sure is Jose succeeds, or if that is even possible. I seem to remember that it is possible,...i think... Personally, i would compare complex numbers by their distance to the origin ( in the 2D complex plane ). This could be optimized by directly comparing the sum of sqaures of the real and imag parts, without bothering to do the sqrt to find the actual distance to the origin. It would make it easier to program a Mandelbrot fractal! "Jose' Sebrosa" wrote in message news:3B182360.1C6362FB at artenumerica.com... > Darren New wrote: > > > > Jose' Sebrosa wrote: > > > > > Thats the only way I can figure to invent a comparison between two complexes, > > > and it seems preety absurd to me... > > > > If you're looking for a consistant but nonsense way of comparing tuples, > > you could compare them as tuples of floats. A < B if A.real < B.real || > > (A.real == B.real && A.imag < B.imag). > > Gosh! So simple! Of course you are right! > From nperkins7 at home.com Wed Jun 6 02:41:55 2001 From: nperkins7 at home.com (Nick Perkins) Date: Wed, 06 Jun 2001 06:41:55 GMT Subject: priority queue Message-ID: I need a priority queue, but I am not sure what kind I should use. I will be doing insertions that will likely fall somewhere in the middle, and will only be removing from the front of the queue. I expect insertions to out-number removals by about 2 or 3 to one. The easy way would be to just have a list, and .sort() it at each insertion. This, i am sure, would not be the fastest way. I think that a heap would best suit my needs. I could code one myself, but it must have been done before. I can't find one in the cookbook, or the vaults! (optional extra info).. I am re-coding into Python a C program that I wrote which finds the shortest solution to 'sokoban' puzzles. It uses an A* search. I think that the ease of implementing heuristics and algorithms in Python will allow me to write a 'smarter' program than the C version. In AI, smarter algorithms can give a performance boost of many orders of magnitude, which I hope will overwhelm any mere constant factor in speed penalty for going from C to Python. From aleaxit at yahoo.com Fri Jun 15 12:30:15 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 15 Jun 2001 18:30:15 +0200 Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> Message-ID: <9gdd710pl5@enews1.newsguy.com> "John Roth" wrote in message news:tik6mvpq92il0d at news.supernews.com... ... > The run-time issue (how to make it happen) could be fairly messy - I don't > know > of any mechanism currently in Python that will prevent a name from being > rebound to another object. __setattr__ of course. It only works for an instance, but that just means the 'module' called const (or alias, or whatever) has to be an instance -- easy, as I already showed. If as you say you're not hung on the syntax, either const.name or alias.name CAN easily be made unrebindable after an 'import const' or 'import alias'. Again, see my post of yesterday on this thread. Alex From sholden at holdenweb.com Wed Jun 6 09:49:56 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 6 Jun 2001 09:49:56 -0400 Subject: Jython book References: <3B18A928.E6E8B4C6@earthlink.net> Message-ID: "Ron Stephens" wrote in message news:3B18A928.E6E8B4C6 at earthlink.net... > It seems to me there is a huge opportunity for someone to come out with > the first good book on Jython. It is a good tool, but a really good book > would be of immense help. > > From what I have seen of the knowledge of some on this list, the > capability is there for someone to write a definitive masterpiece. > > I hope anyway. > > Maybe Alex Martelli??? > I understand New Riders have one in process right now. Publication date unknown. regards Steve From PoulsenL at capecon.com Fri Jun 8 14:08:06 2001 From: PoulsenL at capecon.com (PoulsenL at capecon.com) Date: Fri, 8 Jun 2001 14:08:06 -0400 Subject: More fun with Derivatives of Matrices Message-ID: The problem is that I do not have a single function for which I can take the derivative. I have broken the problem up into a series of subfunctions that are called and put together. So I used the Scientific package to "cheat" and save some time and avoid writing out the single monolithic matrix operation. This is extremely convenient for me because my first order condition can change slightly within any one of the subfunctions and it avoids me having to write several different cases in matrix notation. This was a perfect solution except for my inability to invert the matrix when it contained a DerivVar object. Also, I cannot use the formula for the derivative of a matrix, because it is only part of the larger equation that I am trying to avoid working out the analytical derivative of in the first place. Also I have broken up taking the first derivative in parts because there are over 300 parameters and I can't do it all at once. Again DerivVar work very well for this, but for the inversion problem. Thank you for your help so far, Loren From rpyron at alum.mit.edu Sat Jun 23 21:08:42 2001 From: rpyron at alum.mit.edu (Robert Pyron) Date: Sun, 24 Jun 2001 01:08:42 GMT Subject: win32all - which exception? Message-ID: I'm using win32 extensions to enumerate top-level windows. For each window, I call win32gui.GetParent(). If the window has no parent, the function raises an exception. So, I have two questions: 1. What exception is raised by this function? I'm using try:/except: to catch all exceptions, but I would like to be more specific. 2. In general, for other win32 functions, how can I tell which exception is being raised? From machin_john_888 at hotmail.com Wed Jun 6 11:28:34 2001 From: machin_john_888 at hotmail.com (John Machin) Date: 6 Jun 2001 08:28:34 -0700 Subject: why huge speed difference btwn 1.52 and 2.1? References: <9f8fgs$ooo$1@knot.queensu.ca> <9fdjsc$pn4$1@panix2.panix.com> <3b1bcf7a.12528354@news.ccs.queensu.ca> <9fj4tn$nr0$1@panix6.panix.com> Message-ID: <92ae279c.0106060728.1e60f49a@posting.google.com> aahz at panix.com (Aahz Maruch) wrote in message news:<9fj4tn$nr0$1 at panix6.panix.com>... > In article <3b1bcf7a.12528354 at news.ccs.queensu.ca>, > Robin Senior wrote: > > filename = string.replace(state, ' ', '_') > > g = open('states/'+filename+'/'+str(year)+'.TXT', "a") > > g.write(line) > > g.write("\n") > > g.close() > > f.close() > > In addition to the other comments you've received, you should probably > move the g.open() outside this loop. Presuming the number of lines of output data is big enough for you to care about how long it takes to run: any procedure that has a file open(), write(only_one_line) and close() inside its innermost loop needs serious reworking irrespective of the language used and the version thereof. If you are running an operating system that cares, you will be hit by multiple physical disk writes per output *line* as the close() flushes your file and its directory entry. If there are many more lines than one to be appended to each output file, you can do considerably better. So, if you have enough real memory, save your output data in an in-memory data structure -- for example, (a) dictionary where the key is (state_abbrev, year) and the value is a list of the relevant lines. Then for each dict entry: open(), write() once per list entry, close(). (b) list where each entry is (state, year, relevant_line). At end, sort the list then output it, opening each output file only once (when (state, year) changes). This will most likely take less memory and more time than the dictionary option --- but [pax Tim] don't believe me; write it both ways and benchmark it. If you don't have enough real memory [or your OS's memory allocator goes berserk when you create a large list by appending; see thread of about two weeks ago] either (a) buy more or (b) [very similar to option (b) above] write the output lines out to a single file, with state & year up the front of each line, sort the file using your OS's sort utility program, then read the sorted file back, opening each output file once only. HTH, John Machin From aleaxit at yahoo.com Wed Jun 13 17:30:29 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 13 Jun 2001 23:30:29 +0200 Subject: substitute for c/java's ?: References: <9g5fc4$m8u$01$1@news.t-online.com> <3B2671AF.B226FC54@accessforall.nl> <9g82qt$8ab$06$1@news.t-online.com> Message-ID: <9g8lth0la7@enews1.newsguy.com> "Jochen Riekhof" wrote in message news:9g82qt$8ab$06$1 at news.t-online.com... > Hi... > > > Instead I usually write: > > if option: result = value1 > > else: result = value2 > > just dropping the newlines. It's more verbose than > > result = option ? value1 : value2 > > but at least it's clean. > > Found a somewhat unclean solution that also has the drawback to process both > operands any way, but it is sometimes nice because short: > result (value1, value2)[not option] > > It assumes that the only booleans emerging from not x are 1 and 0, I hope > this is defind in the language. Yes, it is. But, as you noticed, it has drawbacks. http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/52310 has a survey of possibilities. Lloyd Goldwasser just added another neat one in a comment: (a and b, not a and c)[not a] this also relies on not a being 0 or 1 (which IS language-defined) and doesn't evaluate the (b or c) operand it doesn't need, just as the ((a and [b]) or [c])[0] Lloyd's idiom evaluates a three times (that's the downside) and is minutely longer than the classic one, but it has an interesting symmetry about it. Since interest in such pursuits is better kept at an aesthetic level, rather than being applied to production code, I think Lloyd's solution may in fact be deemed neater...:-). Alex From root at rainerdeyke.com Sat Jun 30 15:19:28 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Sat, 30 Jun 2001 19:19:28 GMT Subject: Augmented Assignement (was: Re: PEP scepticism) References: Message-ID: <4Dp%6.408588$oc7.55997471@news2.rdc2.tx.home.com> "Carlos Ribeiro" wrote in message news:mailman.993927046.4577.python-list at python.org... > As the current discussion about Augmented Assignment stands, I was > wondering if it was not better to make it invalid to use augmented > assignment on immutable types. Bad idea. If anything, I would go the other direction and make it illegal for mutable types. In my experience, the primary use of augmented assignment is for integers: a += 1 vs. a = a + 1 The augmented assignment version is clearly more maintainable since it contains less redundancy. On the other hand, augmented assignment is redundant for mutable types. If I want to extend a list in place, I'll use the 'extend' method since it more clearly communicates my intent. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From aleaxit at yahoo.com Sat Jun 16 05:18:35 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 16 Jun 2001 11:18:35 +0200 Subject: Any other Python flaws? References: <#72#QIT9AHA.262@cpmsnbbsa09> <3b2a7edd.586265184@wa.news.verio.net> Message-ID: <9gf89b1f5c@enews1.newsguy.com> "Bengt Richter" wrote in message news:3b2a7edd.586265184 at wa.news.verio.net... > On Thu, 14 Jun 2001 20:26:10 -0400, "Steve Holden" > wrote: > [...] > >Despite the fact that our Fearless Leader and BDFL has already revered > >himself once on this issue, I'd like to see strict syntactical equity > >between function definitions and class definitions, which is to say that a > >class with no superclasses should be declarable as: > > > > class myClass(): > > pass > > Why not the other way around? I.e., drop the mandatory "()" > for function defs with no args. A bare 'foo' could still > evaluate to and foo() would do > what it does now. IMHO that would be just as good. Best would (again IMHO) to have OPTIONAL parentheses at CREATION time only of both baseless classes and argless functions, but any solution that lets one use the same syntax in either case would be OK by me. Alex From piet at cs.uu.nl Fri Jun 22 07:10:21 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 22 Jun 2001 13:10:21 +0200 Subject: substitute for c/java's ?: References: Message-ID: >>>>> Marcin 'Qrczak' Kowalczyk (MK) writes: MK> def aan(name): MK> """Utility which returns 'a' or 'an' for a given noun. MK> """ MK> return if string.lower(name[0]) in 'aeiou' then 'an ' else 'a ' Which programming language is that? -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From paulp at ActiveState.com Fri Jun 29 21:16:25 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 29 Jun 2001 18:16:25 -0700 Subject: [Python-Dev] Support for "wide" Unicode characters References: <3B3BEF21.63411C4C@ActiveState.com> <3B3C95D8.518E5175@egenix.com> Message-ID: <3B3D2869.5C1DDCF1@ActiveState.com> "M.-A. Lemburg" wrote: > >... > > I'd suggest not to use the term character in this PEP at all; > this is also what Mark Davis recommends in his paper on Unicode. That's fine, but Python does have a concept of character and I'm going to use the term character for discussing these. > Also, a link to the Unicode glossary would be a good thing. Funny how these little PEPs grow... >... > Why not make the codec used by Python to convert Unicode > literals to Unicode strings an option just like the default > encoding ? > > That way we could have a version of the unicode-escape codec > which supports surrogates and one which doesn't. Adding more and more knobs to tweak just adds up to Python code being non-portable from one machine to another. > > ISSUE: Should Python allow the construction of characters > > that do not correspond to Unicode characters? > > Unassigned Unicode characters should obviously be legal > > (because they could be assigned at any time). But > > code points above TOPCHAR are guaranteed never to > > be used by Unicode. Should we allow access to them > > anyhow? > > I wouldn't count on that last point ;-) > > Please note that you are mixing terms: you don't construct > characters, you construct code points. Whether the concatenation > of these code points makes a valid Unicode character string > is an issue which applications and codecs have to decide. unichr() does not construct code points. It constructs 1-char Python Unicode strings...also known as Python Unicode characters. > ... Whether the concatenation > of these code points makes a valid Unicode character string > is an issue which applications and codecs have to decide. The concatenation of true code points would *always* make a valid Unicode string, right? It's code units that cannot be blindly concatenated. >... > We should provide a new module which provides a few handy > utilities though: functions which provide code point-, > character-, word- and line- based indexing into Unicode > strings. Okay, I'll add: It has been proposed that there should be a module for working with UTF-16 strings in narrow Python builds through some sort of abstraction that handles surrogates for you. If someone wants to implement that, it will be another PEP. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From erno-news at erno.iki.fi Sun Jun 3 08:40:54 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 03 Jun 2001 15:40:54 +0300 Subject: Looking up device major and minor numbers in Python References: <20010603.004420.1504569917.19294@elroy.house> Message-ID: In article <20010603.004420.1504569917.19294 at elroy.house>, "Harry Henry Gebel" writes: | Is there a way to find the device major and minor numbers of character | and block special device files using python? from looking at the sources, it looks like python does not return the st_rdev member of the stat structure that would have this information. you could kludge around it by parsing ls output or something. -- erno From chrishbarker at home.net Tue Jun 5 13:22:19 2001 From: chrishbarker at home.net (Chris Barker) Date: Tue, 05 Jun 2001 10:22:19 -0700 Subject: floating point in 2.0 References: <9fiptc$m9d$1@panix2.panix.com> Message-ID: <3B1D154B.81016685@home.net> Aahz Maruch wrote: > Actually, 2.0 *still* lies: > > >>> 0.1 > 0.10000000000000001 > >>> '%.55f' % 0.1 > '0.1000000000000000055511151231257827021181583404541015625' > > It just lies less than it used to. What the heck are all those digits at the end? Talk about lies, you can be sure all those digits aren't being stored (at least not in an IEEE 754 64bit double, which stores approx. 16 decimal digits. Approx. because it is really a given number of binary digits. I don't have the exact number off of the top of my head). interestingly enough, If you try to diplay more, you get: >>> '%.70f' % 0.1 '0.1000000000000000055511151231257827021181583404541015625000000000000000' now the extra is all zeros. Also, I get the same 55 digtits, so theya re not random garbage. Does anyone know what they are? Perhaps the Intel extra precision FPU bits? -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From johnroth at ameritech.net Fri Jun 29 19:44:19 2001 From: johnroth at ameritech.net (John Roth) Date: Fri, 29 Jun 2001 16:44:19 -0700 Subject: newbie with major "lambda" problem (perhaps a scope problem as well) References: <37hmjtk186jsm8k8j0tcq9rvae37mpjb3s@4ax.com> Message-ID: If I understand what you want to do, you want a scrolling panel at the top, and three command buttons below (or above) the panel, right? The issue here is that the buttons' action procedures need access to the class instance, so they should go inside the class. That means the buttons themselves should go inside the class. That means you need to build everything inside the class. In other words, you can't build the pmw.ScrollingFrame (or whatever) outside it, and then use the frame for the contents. You need to build it at the same level as the buttons and the data fields, which means inside the class. There's nothing wrong with building two (or more) levels of widget in the same class. You just need to insure that things nest neatly. John Roth One way of going about it is to "Joe Potter" wrote in message news:37hmjtk186jsm8k8j0tcq9rvae37mpjb3s at 4ax.com... > On Wed, 27 Jun 2001 07:21:38 -0700, "John Roth" wrote: > > > > >"Joe Potter" wrote in message > >news:gkkjjts1msjq3ps19qs1aobi6m06jtscpc at 4ax.com... > >> On Tue, 26 Jun 2001 22:00:52 -0700, "John Roth" > >wrote: > > > > > >> Thanks John, > >> > >> I think I see it. If I can get a look at the solution to the code example > >> that I used in my reply to Chris Barker --- I'll have it made. > >> > >> Perhaps you can take a look at that example also? > >> > >> Thanks again. > >> > >> Regards, Joe > > > >You don't need to create a frame at all - the classes I write just go right > >ahead and start loading widgets into the parent widget, which is passed in as a > >parameter. > > > > The code example came from Mark Lutz in his "Programming Python: 2nd Edition." > > Unfortunately for me, he loves to use classes in nearly all of his examples. I tried > to "de-class" the code but failed to preserve functionality with my results. > > > >Setting up your class as a frame is somewhat better for code reuse, but it > >really depends on what you want to do with it If it's a one-shot, a frame is > >redundant. If it's a group of controls you're likely to want to use > >somewhere else, then putting it in a frame makes it much more portable. > > > >The following snippet shows one I wrote recently: > > > >class ADataEntryUI: > > def __init__(self, parent, frame): > > self.ParentClass = parent > > self.DateType = "Gregorian" > > self._DateVar = StringVar() > > self._DateError = "" > > self.TimeType = "AM" > > self._TimeVar = StringVar() > > self._TimeError = "" > > > >As you can see, it doesn't subclass anything! > > > >John Roth > > > > > John, I want to use the following code as an interface to learning to use Gadfly SQL > in Python. It works (sort of) now if one does not mind the function buttons scrolling > out of sight on even a small database. > > What would really help --- is if you could advise me how in the world to put the > control buttons in the outer widget where they would not scroll ---- yet they would > still work. > > If the work involved takes too much time and you do not care to look at it, that is > fine. But, if you could look at it I would really appreciate it. > > In fact, if you could "de-class" the example it would be so much the better --- since > I would prefer to put off learning the mysteries of classes for a few more weeks. > > Regardless, you have been very helpful and I thank you. > > > Regards, Joe > > > > > > > > > ###################### code start (note will need a little txt file > ############################## > > import sys > from Tkinter import * > from tkMessageBox import askokcancel > import Pmw > > > class SumGrid(Frame): > def __init__(self, parent=None, numrow=5, numcol=5): > Frame.__init__(self, parent) > self.numrow = numrow # I am a frame container > self.numcol = numcol # caller packs or grids me > self.makeWidgets(numrow, numcol) # else only usable one way > > def makeWidgets(self, numrow, numcol): > self.rows = [] > for i in range(numrow): > cols = [] > for j in range(numcol): > e = Entry(self, relief=RIDGE) > e.grid(row=i+1, column=j, sticky=NSEW) > e.insert(END, 'xx') > cols.append(e) > self.rows.append(cols) > > > > Button(self, text='Print', command=self.onPrint).grid(row=0, column=0) > Button(self, text='Clear', command=self.onClear).grid(row=0, column=1) > Button(self, text='Load', command=self.onLoad).grid(row=0, column=2) > > > def onPrint(self): > for row in self.rows: > for col in row: > print col.get(), > print > print > > > def onClear(self): > for row in self.rows: > for col in row: > col.delete('0', END) > col.insert(END, '') > > def onLoad(self): > import string > #from tkFileDialog import * > #file = askopenfilename() > file = "joe.txt" > if file: > for r in self.rows: > for c in r: c.grid_forget() > > myfile = open(file, 'r') > filelines = myfile.readlines() > myfile.close() > self.numrow = len(filelines) > self.numcol = len(string.split(filelines[0])) > self.makeWidgets(self.numrow, self.numcol) > > row = 0 > for line in filelines: > fields = string.split(line) > for col in range(self.numcol): > self.rows[row][col].delete('0', END) > self.rows[row][col].insert(END, fields[col]) > row = row+1 > > > if __name__ == '__main__': > > root = Tk() > root.title('test a button') > > sf = Pmw.ScrolledFrame(root, > usehullsize = 1, > hull_width = 600, > hull_height = 300, > ) > > sf.pack(side = "top", padx = 10, pady = 6, fill = 'both', expand = 1) > > # can we move the button calls to here, and hence --- pur them in root???? > > > iframe = sf.interior() > SumGrid(iframe).pack() > mainloop() > > ######################## end code > ########################## > > You need a "joe.txt" file --- the below is as good as any > > ############## > > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > 1 2 3 4 5 6 7 8 > ######################## > ######################## From m.faassen at vet.uu.nl Wed Jun 6 17:58:29 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 6 Jun 2001 21:58:29 GMT Subject: GROUP TAKEOVER IN PROGRESS References: <69cl4tk6bitr0oi376ngtjp0m1bs7ucnk4@4ax.com> <902430AC4moondustapexnet@209.99.56.9> <93hn81$l4m$1@nnrp1.deja.com> <9025628F7moondustapexnet@209.99.56.9> <3a5c8520_1@news.foxinternet.com> <902581E21moondustapexnet@209.99.56.9> <3a5ce21b_1@news.foxinternet.com> <4A982771F09.psskvxvn@vluxxijwai.net> <3b1e5be3.95989595@news.telus.net> Message-ID: <9fm925$d92$2@newshost.accu.uu.nl> David - KLR250 G4 (Sherpa) wrote: > On 6 Jun 2001 04:17:29 GMT, Brent K Kohler wrote: >> >>ALL HAIL BRENT K KOHLER LORD AND HIGH MASTER OF USENET! > Oh dear. Someone didn't log out of his account when he walked away from > the computer... Probably a PSU plot, what do you think? There is the possibility that the PSU is really trying to From cmkleffner at gmx.de Mon Jun 18 11:32:18 2001 From: cmkleffner at gmx.de (cmkl) Date: 18 Jun 2001 08:32:18 -0700 Subject: statically linking the entire runtime (HPUX Python2.1) References: <3B2B18A3.E7CE525C@snakefarm.org> Message-ID: <3b091a1c.0106180732.5251e4b5@posting.google.com> Carsten Gaebler wrote in message news:<3B2B18A3.E7CE525C at snakefarm.org>... > Andrew MacIntyre wrote: > > > On Fri, 15 Jun 2001, Carsten Gaebler wrote: > > > > > I noticed that you can't build the curses module statically. The linker > > > then complains about duplicate definitions of 'tputs' in libncurses and > > > libtermcap. Is there a way to get around this? > > > > Do you really need to link in libtermcap?? I had been under the > > impression that libncurses contained all necessary functionality. > > You're right, the curses module does not need libtermcap. The problem > actually was that I put the following into Modules/Setup: > > readline readline.c /usr/lib/libreadline.a /usr/lib/libtermcap.a > _curses _cursesmodule.c /usr/lib/libncurses.a > > So I had a conflicting libtermcap from the readline module which does > not need libtermcap either. After deleting that and replacing > > LIBS= -lpthread -ldl -lutil > LIBM= -lm > > by > > LIBS= /usr/lib/libpthread.a /usr/lib/libdl.a /usr/lib/libutil.a > LIBM= /usr/lib/libm.a > > in the Makefile, I now have a 5.3 megs python interpreter that depends > on no more than ld.so and libc.so. :-) > Well, you could probably also say: > > LIBC=/usr/lib/libc.a > > but that would be like Monster Truck Madness ... ;-) > > > cg. Hi, I have now sucessfully build a static python2.1 version on HP-UX11 with cc: 1) edit configure and change: '-lpthread' to '/usr/lib/libpthread.a' if you want to have the pthread libary static. For HP-UX10 you may add '+Onolimit +DAportable' to the compiler switches. 2) change Modules/Setup to build all libraries there: my Setup contains the following modules: *static* posix posixmodule.c # posix (UNIX) system calls _sre _sre.c # Fredrik Lundh's new regular expressions array arraymodule.c # array objects cmath cmathmodule.c # -lm # complex math library functions math mathmodule.c # -lm # math library functions, e.g. sin() struct structmodule.c # binary structure packing/unpacking time timemodule.c # -lm # time operations and variables operator operator.c # operator.add() and similar goodies _weakref _weakref.c # basic weak reference support _codecs _codecsmodule.c # access to the builtin codecs and codec registry _testcapi _testcapimodule.c # Python C API test module _symtable symtablemodule.c strop stropmodule.c regex regexmodule.c regexpr.c pcre pcremodule.c pypcre.c unicodedata unicodedata.c # static Unicode character database _locale _localemodule.c # access to ISO C locale support fcntl fcntlmodule.c # fcntl(2) and ioctl(2) pwd pwdmodule.c # pwd(3) grp grpmodule.c # grp(3) errno errnomodule.c # posix (UNIX) errno values select selectmodule.c # select(2); not on ancient System V mmap mmapmodule.c xreadlines xreadlinesmodule.c _socket socketmodule.c crypt cryptmodule.c # -lcrypt # crypt(3); needs -lcrypt on some systems nis nismodule.c -lnsl # Sun yellow pages -- not everywhere termios termios.c # Steen Lumholt's termios module resource resource.c # Jeremy Hylton's rlimit interface audioop audioop.c # Operations on audio samples imageop imageop.c # Operations on images rgbimg rgbimgmodule.c # Read SGI RGB image files (but coded portably) md5 md5module.c md5c.c sha shamodule.c timing timingmodule.c rotor rotormodule.c # enigma-inspired encryption syslog syslogmodule.c # syslog daemon interface _curses _cursesmodule.c -lcur_colr -ltermcap new newmodule.c dbm dbmmodule.c # dbm(3) may require -lndbm or similar binascii binascii.c parser parsermodule.c cStringIO cStringIO.c cPickle cPickle.c fpectl fpectlmodule.c -lcl some patches are required in: _cursesmodule.c, termios.c, py_curses.h the curses module is linked against libcur_colr NOT libcurses ! py_curses.h has to include: #include _cursemodule.c has to include: #define STRICT_SYSV_CURSES I have no idea what to do with ncurses (I dont't have it) termios.c compiles if you exclude the relevant macros VREPRINT ... (see the error list) 3) ./configure --prefix=/somewhere --without-gcc 4) make, make test, make install python is linked against: (> chatr python ) dynamic /usr/lib/libnsl.1 dynamic /usr/lib/libdld.2 dynamic /usr/lib/libcur_colr.1 dynamic /usr/lib/libcl.2 (only needed by fpectl) dynamic /usr/lib/libm.2 dynamic /usr/lib/libc.2 these libraries should be available on other HPUX11 systems. python size is "only" 1.8 Mbyte A minimal 'freezed' python script is about 1.0 Mbyte (stripped) This is useful for my needs. comments ? Sincerly Carl From claird at starbase.neosoft.com Fri Jun 15 19:19:04 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 15 Jun 2001 18:19:04 -0500 Subject: Interfacing GUI applications..? References: <3B18032E.21AF631E@pfortin.com> Message-ID: In article <3B18032E.21AF631E at pfortin.com>, Pierre Fortin wrote: >Hi, > >I've been searching for a couple of days now and must resort asking for help... > >Does anyone know if it's possible to interface to a GUI application via a Python >script? I'm writing an application and would like to invoke Adobe's AcroRead >(on Linux) and feed data to a "fill-in" PDF file. > >The minimum requirement is to make AcroRead think it's coming from the >keyboard. Extra points for mouse events (or shortcuts, though not all menus >items have shortcuts). . . . Is this AcroRead operating under Windows? If so, I think it will be useful to sharpen your question to, "Does anyone know whether AcroRead is a COM server?" That question, incidentally, has nothing to do with Python, and little to do with GUIs; the folks in comp.text.pdf will more likely be of help with that. If you're operating under Windows (I speculate you are), and if AcroRead is a COM server (I anticipate that it is), then you're in luck; Python is a GREAT language for COM scripting. If not ... we'll try something else. Incidentally, ReportLab might interest you. 'Any- one out there have any user reports on ReportLab? I've cobbled together some of my own PDF manipula- tions, but I'll happily discard all of them for a well-done package. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From opengeometry at yahoo.ca Thu Jun 14 14:40:49 2001 From: opengeometry at yahoo.ca (William Park) Date: Thu, 14 Jun 2001 14:40:49 -0400 Subject: kmeans cluster analysis ? In-Reply-To: ; from thomas@cbs.dtu.dk on Wed, Jun 13, 2001 at 09:50:32PM +0200 References: Message-ID: <20010614144049.A1063@node0.opengeometry.ca> On Wed, Jun 13, 2001 at 09:50:32PM +0200, Thomas Sicheritz-Ponten wrote: > Before reinventing the wheel ... does anybody know of a python > implementation of the kmeans cluster analysis or (preferable) > bi-secting kmeans ? Need more detail (sigh!) -- William Park, Open Geometry Consulting, 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From ark at research.att.com Mon Jun 11 14:13:49 2001 From: ark at research.att.com (Andrew Koenig) Date: Mon, 11 Jun 2001 14:13:49 -0400 (EDT) Subject: Python and SML In-Reply-To: <6957F6A694B49A4096F7CFD0D900042F27D44B@admin56.narex.com> (BPettersen@NAREX.com) References: <6957F6A694B49A4096F7CFD0D900042F27D44B@admin56.narex.com> Message-ID: <200106111813.OAA10585@europa.research.att.com> >> From: Andrew Koenig [mailto:ark at research.att.com] >> Daniel> I am new to Python and was struck by the similarity to Daniel> a language I learned in a programming languages course, Daniel> SML/NJ. It, like Python, is an interpreted language... >> >> SML/NJ interpreted? How's that again? Bjorn> Both interpreted and compiled (even has an interactive shell :-) The implementations I've seen compile everything, even interactively typed statements. From edcjones at erols.com Thu Jun 14 15:46:40 2001 From: edcjones at erols.com (Edward C. Jones) Date: Thu, 14 Jun 2001 15:46:40 -0400 Subject: Any other Python flaws? References: Message-ID: <3B2914A0.6010902@erols.com> Andrew Kuchling wrote: > ... Are there any other flaws that should be added? It follows from some basic concepts of Python that "array = ([0] * 10) * 10" does not behave as usually intended. This is a well-known "dark corner" of Python; a place it is simply best to avoid. Is this fixable? I think dark corners like this should be documented carefully. Thanks for the wonderful language, Ed Jones From dsh8290 at rit.edu Fri Jun 15 10:40:01 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 15 Jun 2001 10:40:01 -0400 Subject: Integrating a Python GUI into a PowerBuilder App In-Reply-To: <49624b0b.0106150407.626295ca@posting.google.com>; from jurberg@my-deja.com on Fri, Jun 15, 2001 at 05:07:24AM -0700 References: <49624b0b.0106121135.61b6bd6c@posting.google.com> <49624b0b.0106140505.79851658@posting.google.com> <9gahru048k@enews1.newsguy.com> <49624b0b.0106150407.626295ca@posting.google.com> Message-ID: <20010615104001.B695@harmony.cs.rit.edu> On Fri, Jun 15, 2001 at 05:07:24AM -0700, John Urberg wrote: ... | Sorry if I was unclear in my previous post. I can use a Java or VB | GUI by making ActiveX controls from GUI panels done in those languages | and placing them on a blank PowerBuilder MDI child window. Since I | can't do that in Python, I have to find some other way (making a I find it hard to believe that you can't do that in Python. For one thing, Jython is an implementation of Python that runs on top of the JVM (as opposed to having its own VM implemented in C). Through the use of Jython, Python code can access anything that Java code can. Thus if you can use Java, you can use Jython to achieve the same result. I'm not familiar with ActiveX at all, but if it is related to COM, I know that CPython has good COM support. Maybe this will help, -D From sandorlevi at yahoo.com Sun Jun 17 20:30:45 2001 From: sandorlevi at yahoo.com (Levente Sandor) Date: 17 Jun 2001 17:30:45 -0700 Subject: COM method with pointer args Message-ID: <8b5e42a6.0106171630.43a3303a@posting.google.com> I need to automate some jobs in CorelDRAW, and there are a lot of methods which returns their results through pointers. Is there a possibility to use a COM method which requires pointer arguments? (From Python, of course :) Thanks, Levi From tim.one at home.com Tue Jun 19 19:28:54 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 19 Jun 2001 19:28:54 -0400 Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: [Nick Mathewson] > ... > My experience with generators comes from CLU's iterators, which also > had a distinct syntax for declaring them. While most of mine comes from Icon, which doesn't. While *every* expression in Icon "is a generator", the practical distinction between functions that generated multiple results and those that generated exactly one remained important -- but then so is whether a function returns an int or a list or deletes all files matching gen*.* . That is, I think people are making out generators to be a bigger deal than they are here: they're just a very nice way to implement an iterator, and there are many other ways to do that without using generators in 2.2. So why aren't people agitating for "iter" as an alternative to "def"? Because then it would sound silly . From gmcm at hypernet.com Wed Jun 20 08:41:49 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 20 Jun 2001 12:41:49 GMT Subject: calldll: given a longint (=pointer) - howdoi access the data? References: <3b30d4f2.21236779@news.muenster.de> Message-ID: <90C657DA0gmcmhypernetcom@199.171.54.155> [posted and mailed] Martin Bless wrote: [using calldll] >The dll calls the callback function with a pointer to a 860-byte data >structure. > >*** How do I turn this longint (being a pointer) into a Python data >structure (let's say string)? calldll.read_string(address, length) - Gordon From sandysj at asme.org Tue Jun 19 14:04:35 2001 From: sandysj at asme.org (Jeff Sandys) Date: Tue, 19 Jun 2001 18:04:35 GMT Subject: Teaching Pyhton on Wintel References: <1ev6xe3.15eskd91k2u1eaN%p.agapow@ic.ac.uk> Message-ID: <3B2F9433.D87925D7@asme.org> Paul-Michael Agapow wrote: > > I've decided to teach Python scientists. > 1. Any advice on which IDE etc. of Win Python to use? I like WinPython for development (better text editing) and IDLE for testing (better class browser). You get both with the distribution and it are no problems with using both. > 2. Anyone done a similar class? This class was used at CalTech for scientist: http://www.wag.caltech.edu/home/rpm/python_course/ This is a nice tutorial for math and science: http://starship.python.net/crew/hinsen/ I like: The Quick Python Book, by Daryl Harms and Kenneth McDonald, for learning, and: Python Essential Reference, by David Beazley, for programming. Let us know how your class goes. I believe that Python meets the goal of Computer Programming for Everyone (CP4E) better than any other language because it is one language that is open source with plenty of available utilities. (Though I still like Scheme and Logo for teaching) Thanks, Jeff Sandys From NoSpam at NoSpam.com Sun Jun 17 18:38:11 2001 From: NoSpam at NoSpam.com (Thomas) Date: Sun, 17 Jun 2001 22:38:11 GMT Subject: Using the Python license Message-ID: I want to use the Python license for my extension, so I have a few questions. Is it appropriate for C++ code, or just for Python? Is there a standard license file for me to include with my source? The one that ships with the Python source appears to be fairly Python specific. And, does anyone have a link to some comparative information about the different licenses? I'm interested in the main 'anything goes' licenses: Python, BSD, and the LGPL. Thanks, Tom. From Marc.Poinot at onera.fr Fri Jun 29 04:29:00 2001 From: Marc.Poinot at onera.fr (Marc Poinot) Date: Fri, 29 Jun 2001 10:29:00 +0200 Subject: LSM/European Python Meeting Final program Message-ID: <3B3C3C4C.18B6AF9F@onera.fr> The LSM/Topic19 (European Python Meeting) has now its final program. http://lsm.abul.org/program/topic19/topic19.php3 We have some changes, most presentations are now in the morning, and trainings/workshops are the afternoon. Our presentation place is Amphi B, and we have a dedicated room for all the LSM duration: classroom TD11 Marcvs [alias See you next week ;] From eppstein at ics.uci.edu Fri Jun 29 00:45:49 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Thu, 28 Jun 2001 21:45:49 -0700 Subject: PEP 255: Simple Generators References: Message-ID: In article , "Tim Peters" wrote: > Tail-recursion is pretty much insane for that in Python, as > processing list[0] then recursing on list[1:] turns a speedy task into a > quadratic-time mess. So, back to the topic of PEP255: am I the only one bothered by the fact that the inorder example in the PEP is quadratic time, and that it seems difficult to use simple generators to yield a tree's nodes in inorder in linear time? -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From m.faassen at vet.uu.nl Fri Jun 15 08:15:44 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 15 Jun 2001 12:15:44 GMT Subject: Any other Python flaws? References: Message-ID: <9gcu9g$gm4$1@newshost.accu.uu.nl> Mattias Engdeg?rd wrote: > In Andrew Kuchling writes: [snip] > (by the way, your page (Python Warts) claims that python uses > call-by-reference, which is a common misconception. Just like most other > sensible languages (but unlike C++, Fortran, Pascal) it uses call-by-value. > The values, however, are frequently references to objects, which is > probably the cause of the confusion. :-) When are the values *not* references to objects? They may be references to immutable objects, but they'll always be references. I agree that nobody agrees on whatever 'call-by-reference' means, or what 'call-by-value' means. I mean, I'm here confused why you'd say C++ doesn't support call-by-value while Python apparently does. :) Python uses references everywhere; you can't pass anything but references, assignment is reference rebinding, the only way you ever get to objects is through references. This is good and as it should be in Python. Let's not go into a discussion on whatever call-by-foo means, as nobody could agree last time around. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From olafb+usenet at pvv.org Mon Jun 25 08:28:59 2001 From: olafb+usenet at pvv.org (Olaf Trygve Berglihn) Date: 25 Jun 2001 14:28:59 +0200 Subject: Scripts (running once) References: <3B37271F.759B0236@usa.net> Message-ID: mixo writes: > How can one find out if there is a particular python script runnig, and > hence prevent > the same script from being run again? For instance, say I run a script > 'mytes.py' with > the following command: > > python mytes.py > > Now, the next time a user types the same command, a message saying the > script is > already running (or something of that sort) should be printed, as the > script has not > termintated. How about using a lock-file? This code removes the lock after the program has ended. Replace the finally-statements with a pass if you want the program to be executed only once. Note that the user must have write-permissons for the lockfile. #!/usr/bin/env python import os LOCKFILE="/tmp/myprog.lock" def main(): #your code here import time time.sleep(20) # pause for 20 sek. if __name__ == '__main__': if os.path.isfile(LOCKFILE): import sys sys.stdout.write("Already running myprog\n") sys.exit(1) else: fd = open(LOCKFILE, 'w') fd.close() try: main() finally: if os.path.isfile(LOCKFILE): os.remove(LOCKFILE) -- Olaf Trygve Berglihn From j.spies at hccnet.nl Wed Jun 27 18:55:54 2001 From: j.spies at hccnet.nl (Jaap Spies) Date: Thu, 28 Jun 2001 00:55:54 +0200 Subject: PEP 255: Simple Generators References: Message-ID: <3B3A647A.5020009@hccnet.nl> Carsten Geckeler wrote: > On Wed, 27 Jun 2001, Tim Peters wrote: > > >> [Carsten Geckeler] >> >> Griswold does. In the 3rd edtion of "The Icon Programming Language", the >> first two examples of generators are > > > As first examples it may be ok, but I'm sure Griswold is not explaining > the use and idea of generator by simple loops. Which Griswold? R.E or M.T? Jaap Spies 12 years ago I liked Icon, but now I'm in love with Python. From aleaxit at yahoo.com Tue Jun 19 17:33:35 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 19 Jun 2001 23:33:35 +0200 Subject: instance as fake module (Re: why is there no class (static) methods in Python ?) References: Message-ID: <9goge601q8u@enews2.newsguy.com> wrote in message news:mailman.992978370.21848.python-list at python.org... ... > But more to the point, I think that since in Python "everything is a > first-class object" -- which is great -- and since classes, therefore, are > first-class objects it would be nice (and powerful) if you could define > methods that you could invoke on such class objects. (And such methods > should support inheritance and override, of course.) Dictionaries, lists and functions are also first-class objects, by the same token. If what you say IS indeed the rationale for having 'methods that you could invoke' on class-objects, then by exactly the same rationale there must be the same ability on dictionaries, lists, and functions, right...? That "something is a first-class object" doesn't mean you have to be able to apply *EVERY* operation to it -- you can't "call" a list nor can you "slice" a function, for example. Rather, it means that operations *applicable to objects in general* can also be applied to that object: passing as function parameter, returning as function result, more generally binding to any generic kind of reference (item in a list or tuple, value in a dictionary) -- the ability of being the _key_ in a dictionary requires hashability (either immutability or not defining == as different from 'is', in practice:-). Therefore it seems that your sillogism is invalid -- "classes are 1st class objs", "all 1st class objs can have methods defined on them", therefore "classes must be able to have methods defined on them" -- alas, or hurrah, the second premise does not hold. Alex From grumble at usa.net Fri Jun 15 17:02:11 2001 From: grumble at usa.net (jcm) Date: 15 Jun 2001 21:02:11 GMT Subject: call-by-reference (was Re: Any other Python flaws?) References: <9gcu9g$gm4$1@newshost.accu.uu.nl> <9gd4tq$odb$1@news.mathworks.com> <9gdn37$61k$3@newshost.accu.uu.nl> Message-ID: <9gdt4j$b86$1@news.mathworks.com> Martijn Faassen wrote: > jcm wrote: >> In my experience, there's good agreement about what call-by-reference >> means just about everywhere but in newsgroups. Python supports only >> call-by-value -- you can't change the value of a variable in your >> caller's scope (globals aside). > Um, I wouldn't say it that way. Python supports changing the value a > name references just fine: > def foo(a): > a.append(42) > l = [1, 2, 3] > foo(l) Note I said you can't change the value of a _variable_ in your caller's scope. Changing the state of an object isn't the same. From philh at comuno.freeserve.co.uk Fri Jun 15 19:56:36 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Sat, 16 Jun 2001 00:56:36 +0100 Subject: Parrot-0.2.6 released References: <915a998f.0106151123.67a95e5d@posting.google.com> Message-ID: On 15 Jun 2001 12:23:28 -0700, Hamish Lawson wrote: >Jan Schaumann wrote: > >> http://use.perl.org/article.pl?sid=01/03/31/206248 >> >> Any connection or a coincidence? > >I'm guessing Parrot the GUI builder took its name from Monty Python's >"Parrot Sketch", Indeed yes. > though the software's documentation doesn't seem to >indicate the origin of the name. The "Parrot Sketch" is known to be >the source at a later date for the name of the Parrot language (the >spoof hybrid of Python and Perl that is the subject of the >use.perl.org article), Great minds think alike :-) > but I suspect without awareness of the >similarly named GUI builder. Which was started in August 1999, BTW. -- ## Philip Hunt ## ## philh at comuno.freeserve.co.uk ## From maybe at pdq.net Wed Jun 20 22:36:47 2001 From: maybe at pdq.net (mbraden) Date: Wed, 20 Jun 2001 21:36:47 -0500 Subject: DBX Files Message-ID: <001101c0f9fb$05a54a80$051990d1@computer> I recently had some e-mail in my Outlook express, inbox. With some very important data. I downloaded everything on my hard-drive, to a CD, because the computer had be restored. In doing so, when I copied everything back, the computer put in in Windows Explorer, and in a DBX file, which I can't read. Can you please help???????????????? Thanks, Mary -------------- next part -------------- An HTML attachment was scrubbed... URL: From xyzmats at laplaza.org Wed Jun 13 13:24:16 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Wed, 13 Jun 2001 17:24:16 GMT Subject: Inner classes Message-ID: <3b27a1aa.6747983@news.laplaza.org> Java provides inner classes. They have some interesting properties, but mostly smell to me like a hack to get around things being too strongly typed in Java. Probably I'm missing some great point here. Nonetheless, I was challenged by someone to describe how it isn't a shorcoming in Python that classes don't work this way and didn't convince the guy so I'm looking for a more erudite comparison. Mats Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From chrishbarker at home.net Mon Jun 18 15:55:59 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 18 Jun 2001 12:55:59 -0700 Subject: ftplib possible bug? Please help. References: <4b866f80.0106180908.31a3b6b5@posting.google.com> Message-ID: <3B2E5CCF.330BDC11@home.net> Marshall wrote: > I am using Python 2.0 on NT 4.0 > When I ftp a file from one NT server to another, using ftplib, it > changes the end of the line from CRLF to LF. It does this EVEN when > the transfer is Binary. > Passive mode or not passive does not make a difference either. > > Is this a known problem? and is there a fix? make sure you are opening your files as binary files, i.e.: file = open(filename, "rb") If you leave the "b" out, the CRLF will get translated to LF when Python reads the file. It will then get send by ftplib tot he server without any additional translation. I made this mistake, and it worked fine on Linux, and broke on the Mac, and it took me along time to find it. Duh! -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From fredrik at pythonware.com Wed Jun 13 15:02:04 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 13 Jun 2001 19:02:04 GMT Subject: binary file comparison with the md5 module References: <9g8ahr$s6t$1@bob.news.rcn.net> Message-ID: Christian Reyes wrote > I'm trying to write a script that takes two binary files and returns whether > or not their data is completely matching. > > One of my peers suggested that an efficient way to do this would be to run > the md5 algorithm on each file and then compare the resultant output. if you're comparing two binary files, that's not very efficient -- you really don't have to read the *entire* file to figure out if there's any differences... a better solution is to start by comparing the sizes (if they're different, the files cannot possible have the same content), and then read same- sized chunks from both files. as soon as two chunks differ, the files are different. the filecmp module implements this scheme: import filecmp if filecmp.cmp(file1, file2, shallow=0): print "same contents" (the shallow=0 flag makes sure that filecmp.cmp checks the contents even if the size and modification time attributes happens to match) > I tried opening the file with the built-in python open command, and then > reading the contents of the file into a buffer. But I think my problem is > that when I read the binary file into a buffer, the contents get tweaked > somehow. > > >>> x = open('d:\\binary.wav') if you double-check the docs (look for "open" under builtin functions in the library reference), you'll notice that Python opens files in text mode by default. to open a binary file, add "rb" as the second argument to open: > >>> x = open('d:/binary.wav', 'rb') hope this helps! From Randy.L.Kemp at motorola.com Wed Jun 27 18:00:46 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Wed, 27 Jun 2001 17:00:46 -0500 Subject: Developers needed Message-ID: I came across a new open source project from the jboss list. When I went to www.ofbiz.org, and especially the site at http://sourceforge.net/projects/ofbiz/, I noticed Python is being used. Perhaps some Python folks may take an interest. From m.faassen at vet.uu.nl Fri Jun 29 19:17:45 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 29 Jun 2001 23:17:45 GMT Subject: [TO]What's the big deal with EJB? [Re: PEP scepticism] References: <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> <3d8zib16g7.fsf@ute.cnri.reston.va.us> Message-ID: <9hj2ap$bdu$5@newshost.accu.uu.nl> Andrew Kuchling wrote: > Alex writes: >> What's EJB got going for it, anyway? > Buggered if I know. Perhaps they provide a frictionless method for > transferring a business's money to consultants. I was in a huge thread about those some weeks ago. The whole Java stuff offers: * standardized APIs. Makes it easier to learn systems, and easier to find programmers who know the system. This goes from a templating engine to persistence to relational/object integration. * help with scalability of the system (clustering for instance), if you use the APIs you're sort of assured you can scale it all up. Of course I'm skipping over a lot of stuff. Python (and many Python frameworks such as Zope) could do with a few more standardized APIs (and protocols/interfaces). I think Python actually has most of the pieces, though, but you have to worker harder to collect them together into an application. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From emile at fenx.com Thu Jun 21 13:39:18 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 21 Jun 2001 10:39:18 -0700 Subject: PEP 255: Simple Generators References: Message-ID: <9gtbnd$akdb0$1@ID-11957.news.dfncis.de> "Terry Reedy" wrote in message news:K_pY6.29983$Zt6.13980958 at news1.rdc2.pa.home.com... > Question: am I correct in thinking that separating iterator-generation from > iterator-first-use makes it possible to have multiple iterators from the > same generator in simultaneous use, as in > > sq10 = squares(10) > sq20 = squares(20) > ... > ? current cvs test shows this is possible -- Emile van Sebille emile at fenx.com --------- From tim.one at home.com Fri Jun 22 17:22:14 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 22 Jun 2001 17:22:14 -0400 Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: [Denys Duchier] > Think for example of a tree traversal algorithm that is parametrized > by a procedure to be applied to each node. My reading of the PEP does > not allow a procedure to be passed in that `yields' the node. The PEP gives two examples (one recursive, one not, but the distinction is internal implementation detail) of inorder node generators for a specific kind of binary tree. def generic_processor(traversable_thing, function_to_apply): for node in traversable_thing: function_to_apply(node) works fine, and isn't limited to trees -- traversable_thing can be any iterable object. Call via, e.g. (using the PEP example's names) generic_processor(t, some_leaf_function) where t is an instance of the PEP's Tree class. If you mean instead that you want to be able to pass a procedure to the tree traverser itself, fine, but then there's no real attraction to generators at all. > While possibly aberrant, let me suggest a higher-order programming > approach that would not even require a new keyword but merely a new > primitive which I'll call `generator'. This primitive takes a unary > procedure as argument and returns an iterator. The unary procedure > takes itself a `yield' procedure as argument. You do know that most calculus students drop out at "for every epsilon > 0 there exists a delta such that for every x where ..." . > Here is the fib example of the PEP written with my proposal: > > def fib(yield): > a, b = 0, 1 > while 1: > yield(b) > a, b = b, a+b > > g=generator(fib) I'm guessing at what all these pieces mean, but the final clue is missing: what do I do with g? Like, for example, for value in g: print value ? If so, how is Jython supposed to implement this? As the PEP says, "yield" is a keyword in large part because the Jython implementors can't alter the JVM, and they believe they need to know all potential suspension points at compile-time (implementing this stuff on top of Java threads instead is not a practical option). I would also miss the ability to pass arguments to generators in a natural way (I know I can fake it by mucking with lexical closures to make the function actually passed "look like" a one-argument function, but that's a strain in Python too). > It's straightforward (in an implementation) to check that the yield > procedure which is invoked actually corresponds to the generator that > is currently executing. If that's not the case, an exception should > be raised. > > This proposal has the advantage that the boundary of the generator is > fixed late, namely at the time the `generator' primitive is invoked. > It also support full compositionality. I'm not sure what you mean by that, but if it implies that you want, e.g., to be able to, within fib, pass yield on to a *called* function bif(yield), and also yield values from within bif, then we need the Stackless Python machinery to support that. PEP 255 is strictly a "one-frame gimmick": a 255 generator need only remember the state of a single frame, and can only yield to the generator's immediate invoker. Since the PVM is currently written in C using recursion, anything more general than that creates severe implementation difficulties. > ... > which I would write as follows: > > def zipgen(g,h): > def result(yield): > g(yield) > h(yield) > return result We can't support that, for reasons sketched in the preceding paragraph: when the guts of g decide to yield, we have a (recursive) C stack frame, inside the PVM, "stuck in the middle" between the invocation of "result" and the invocation of g. In order for "result"'s invoker to regain control, the C stack has to be popped. Icon (or at least one implementation I used for several years) manages to do this via platform-specific assembler to do cactus-stack-like context switches fooling the platform C implementation, and Stackless Python does it via eliminating C recursion from the PVM's eval loop (it supports full-blown continuations). The "Simple" in "Simple Generators" sidesteps all of that by supporting only generator->immediate_caller yields; but, as the recursive "inorder" PEP example shows, that's less a limitation than it may first appear (and Icon has the same limitation; the "cactus-stack-like" stuff is required only for Icon co-expressions, which are consequently not supported on all platforms). From paulp at ActiveState.com Thu Jun 28 17:39:46 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Thu, 28 Jun 2001 14:39:46 -0700 Subject: Augmented Assignment (was: Re: PEP scepticism) References: Message-ID: <3B3BA422.BF767FF7@ActiveState.com> Bruce Sass wrote: > > > ...what was a wart becomes a feature. That was a lot of effort to understand a typing shortcut. It's somewhat unpythonic to trade a long explanation for a bit less typing. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From machin_john_888 at hotmail.com Mon Jun 18 19:02:43 2001 From: machin_john_888 at hotmail.com (John Machin) Date: 18 Jun 2001 16:02:43 -0700 Subject: += overloading? References: <3b2e3554$0$331$8eec23a@newsreader.tycho.net> Message-ID: <92ae279c.0106181502.6f082c31@posting.google.com> "Neil Macneale" wrote in message news:<3b2e3554$0$331$8eec23a at newsreader.tycho.net>... > I am using a list as the data holding element, then appending to it in > the __iadd__ function. Then I use ''.join(list) to make a string > when the __str__ function is called. I am doing this to minimize the > number of string objects created, and figure that append runs in > constant time. Is join optomized though? It would defeat the purpose if > join worked by creating a new string to join the first two, then added > the third, etc. I am assumming that join is implemented in C, and runs > in 0(n) time, where n is the number of total characters. Am I assuming > incorrectly? I looked at string.py's join function, but that just called > another join method, and I don't know where that one is implemented. Either (1) don't assume; (a) download the source [doesn't take long] and look in stringobject.c and/or (b) search this newsgroup -- behaviour of append() and join() just might have been discussed before or (2) you might reason that join() has been around for a long time and any far-less-than-optimal algorithm implemented in an extremely rare moment of whatever by the gurus would have been pounced upon triumphantly and fixed by one of the many eager kibitzers. From glyph at twistedmatrix.com Sun Jun 10 18:19:11 2001 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: Sun, 10 Jun 2001 17:19:11 -0500 (CDT) Subject: py2exe how safe is my source ? In-Reply-To: <9g02if021ee@enews2.newsguy.com> Message-ID: On Sun, 10 Jun 2001, Alex Martelli wrote: > I don't know if anybody has bothered pattern-recognizing the output of > dis.dis back into Python source, but at least for one fixed Python > version it should be rather doable. Yep. There's a rather good program called "decompyle" which I've used more than once :). If you want your "source code" to be safe, don't give executables to your customers. You'd be surprised what a dedicated person with SoftICE can do with a week or two. ______ __ __ _____ _ _ | ____ | \_/ |_____] |_____| |_____| |_____ | | | | @ t w i s t e d m a t r i x . c o m http://twistedmatrix.com/users/glyph From thinkit8 at lycos.com Sun Jun 17 23:28:46 2001 From: thinkit8 at lycos.com (thinkit) Date: 17 Jun 2001 20:28:46 -0700 Subject: humans should use a power of 2 References: <9gjqh201q0o@drn.newsguy.com> Message-ID: <9gjshe02115@drn.newsguy.com> In article <9gjqh201q0o at drn.newsguy.com>, thinkit says... > >please stop using decimal. most people already only use hexadecimal. "0x" is >your friend...soon enough humans will be only using powers of 2 as general >purpose bases. > sigh...this troll has been posting this same drivel all over all kinds of boards. plus trolling IRC with the same junk. just *plonk* this troll. From tanzer at swing.co.at Fri Jun 1 02:49:29 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Fri, 01 Jun 2001 08:49:29 +0200 Subject: Obsolesence of <> (fwd) In-Reply-To: Your message of "Thu, 31 May 2001 22:57:41 EDT." Message-ID: mertz at gnosis.cx wrote: > Lulu of the Lotus-Eaters wrote: > >I'm not really sure I like the change Alex points to. It makes > >something like the below fail: > > > > l = [(1+1j),(2-2j),Klass(),Klass(),Klass,5,4,3,'c','b','a'] > > l.sort() > > > >Many of the comparisons have no particular meaning. But it is nice to have > >everything have some arbitrary inequality relation in order to create > >partial orderings on the subsets of things that really do have an order. > > aahz at panix.com (Aahz Maruch) wrote: > |Yup, this used to work. Then came Unicode.... > > Huh? What does Unicode have to do with anything? The below works fine, > for example: > > Python 2.0.42-S1.2.23 (#0, Apr 25 2001, 20:59:49) [GNU C/C++] on os2 > Type "copyright", "credits" or "license" for more information. > >>> x = u"spam" > >>> y = "spam" > >>> z = 1+1j > >>> w = u"eggs" > >>> x < y > 0 > >>> x < z > 0 > >>> x < w > 0 > > At least in my 2.0 version, unicode strings seem to compare fine to > other things (I didn't try *every* other thing... but the obvious few > are happy). Just try: >>> "??b" == u"abc" Traceback (most recent call last): File "", line 1, in ? UnicodeError: ASCII decoding error: ordinal not in range(128) :( Being able to sort lists no matter what elements they contained was very handy for some purposes... -- Christian Tanzer tanzer at swing.co.at Glasauergasse 32 Tel: +43 1 876 62 36 A-1130 Vienna, Austria Fax: +43 1 877 66 92 From sholden at holdenweb.com Thu Jun 28 21:55:45 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 28 Jun 2001 21:55:45 -0400 Subject: Augmented Assignment (was: Re: PEP scepticism) References: Message-ID: "Rainer Deyke" wrote in ... > "David Bolen" wrote ... > > I think that if the operation is phrased from the start as an action > > undertaken by the source object itself and that the source object's > > mutability can affect behavior, that it's not too big of a hurdle. > > This dual meaning of augmented assignment makes it dangerous: to get > reliable behavior, you need to be absolutely sure whether or not your object > is mutable before you attempt augmented assignment. I cringe in horror when > I think about people intentionally using the dual meaning of augmented > assignment. > You might, but when I cringed (in this newsgroup) it was pointed out in no uncertain terms (although perfectly politely, of course) that this had been a part of the master plan for quite a long time, and was something that many users wanted. At the time it seemed dangerous (in pedagogical terms) to have it be the case that var = var op exp gave different results from var op= exp Now, strangely enough, it's the *mutable* objects for which different results are obtained, because if the object can implement the operation by mutating then the value of other names also bound to the object changes under the covers. So I had no problems with augmented assignment on tuples, for example (which started this thread, IIRC). Nowadays, since it's a part of the language, I just use it and don't moan. But it does have to be taught... regards Steve -- http://www.holdenweb.com/ From spam at melkor.dnp.fmph.uniba.sk Tue Jun 5 04:06:24 2001 From: spam at melkor.dnp.fmph.uniba.sk (Radovan Garabik) Date: Tue, 5 Jun 2001 10:06:24 +0200 Subject: Reading email and newsgroups from Python? References: <3b1bd85b_2@news4.newsfeeds.com> Message-ID: <0u3if9.ftb.ln@127.0.0.1> Dry Ice wrote: : Just getting started with Python and : wxPython. I'm interested in receiving : and managing email and newsgroup posts : with these. : Will be doing this initially for Win98, : but will eventually be doing same for : Linux. (Using existing OS services : should make Linux easy, I suspect.) : Any code snippets you can suggest to : get me started? http://packages.debian.org/unstable/mail/pms.html -- ----------------------------------------------------------- | 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 twofingersalute at atl.mediaone.net Sat Jun 9 23:41:49 2001 From: twofingersalute at atl.mediaone.net (myself) Date: Sun, 10 Jun 2001 03:41:49 GMT Subject: Linux compile Q's Python 2.1 Message-ID: <20010609.234511.1943327684.1229@K7.atl.mediaone.net> Sorry to bother you guys so soon after my last post, but....... being unable to properly install from srpm, figured to just compile/install from source- did it a year or so ago for 1.5, shouldn't be a big whoop. Bzzzt. ./configure- ok made a few changes in Modules/Setup, "make", "make test": 17 tests skipped: test_al test_bsddb test_cd test_cl test_dbm test_dl test_gl test_imgfile test_largefile test_minidom test_nis test_pyexpat test_sax test_sunaudiodev test_sundry test_winreg test_winsound doesn't look tragic, seems like I had more skipped tests last time, but you guys be final arbiters.... "make altinstall libinstall"- well I'm a bit afraid latest Py will break something the system might need WRT Py 1.5.2, but only error of note (to my untrained eye) seems reasonable: I'll have to manually update sys.path. So now I'm looking at creating a script to start my shiny new IDLE (.08?)- but it *didn't* get installed- the sources are in my install directory, but nada in python2.1/site-packages (or anwhere else in /usr/local). What did I miss?? So: [root at K7 Python-2.1]# make uninstall make: *** No rule to make target `uninstall'. Stop. how rude :-( ! I really wanted to start fresh, partly 'cause I didn't realize that some/most/all of my mods to Setup are handled automagically by setup.py. Running Mandrake 7.2, gcc-2.95.2-12mdk, installing from Python-2.1.tgz from Pythonlabs. tcl/tk seemed to install fine. Clues? Please? (I've surely left out the imp't stuff, but if I knew what it was, probably wouldn't need to come a beggin' :-> ). PS- I don't have a PYTHONHOME set (noticed it was a prob. for others). TIA, y'all (yep, we _really_do_say_that_)..... From phd at phd.fep.ru Tue Jun 26 12:20:01 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Tue, 26 Jun 2001 20:20:01 +0400 (MSD) Subject: MSAccess databse from Linux box In-Reply-To: Message-ID: On Tue, 26 Jun 2001, michael montagne wrote: > In my effort to rebuild our intranet on a Linux box with Python I need to > retrieve information from several MSAccess databases. Is there a way to do > that with Python? Or Zope? ODBC via mxODBC (there are rumors mxODBC works on UNIX) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From MarkH at ActiveState.com Fri Jun 22 01:57:09 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Fri, 22 Jun 2001 15:57:09 +1000 Subject: Stop/Start Service in Win2k In-Reply-To: <006801c0face$1f6084c0$abcc4e18@cr582427a> Message-ID: > > A patch to win32serviceutil that tries to locate the short name given > > the long name would be gratefully accepted :) > > Here you go. And it was gratefully accepted :) A new win32serviceutil has been checked in incorporating this... Mark. From thinkit8 at lycos.com Wed Jun 13 08:03:58 2001 From: thinkit8 at lycos.com (thinkit) Date: 13 Jun 2001 05:03:58 -0700 Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> <3b266270$1_7@news5.uncensored-news.com> <9g68os0cd9@drn.newsguy.com> <3B26CD62.F89E5FA0@my.signature> Message-ID: <9g7kre020fq@drn.newsguy.com> In article <3B26CD62.F89E5FA0 at my.signature>, Greg says... > >thinkit wrote: >> >> we all need a general >>purpose base. decimal is that now, and hexadecimal would make a better choice. > >And if you use hands and feet, and exclude thumbs and >big toes, you can even do it on your appendages >if you really want. > >We need six more digit symbols, though. Borrowing >letters was okay as an interim measure, but we need >to move on. Any proposed designs? > >-- >Greg Ewing, Computer Science Dept, University of Canterbury, >Christchurch, New Zealand >To get my email address, please visit my web page: >http://www.cosc.canterbury.ac.nz/~greg wow...nice to hear a positive message for once--i've developed a flame proof suit as of late. yes, 6 more digit symbols would be ideal. not to mention a zero that doesn't look like a letter--but such is the ball and chain of tradition. the constructed language lojban already has 6 extra words for A-F...i'm not away of any other languages that do. this is one reason i've tried to like octal...but i still don't like that it uses three bits, which is an odd number. until then...i haven't had too many problems using hex in my own work. context as usual will make it clear whether you mean a number or meat (0xBEEF). From gregj at pobox.com Thu Jun 14 04:19:57 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Thu, 14 Jun 2001 08:19:57 GMT Subject: IP address to binary conversion References: Message-ID: "Jeroen Wolff" wrote in message news:tedfit8li6m4i5gknj0749v5iriau5fo6q at 4ax.com... > Hi, > > Can somebody help me (a newbee) to convert an ip address to is 32 bits > representation? Each of the four numbers in the dotted-quad IP address is the decimal version of a hex pair. It's already a 32-bit number, you just have to do a little bit of work. One way is to simply multiply the address out. For example, given the IP address 192.168.2.1, the 32-bit equivalent is: 192 * 256^3 + 186 * 256^2 + 2 * 256 + 1 = 3232236033 (0xC0A80201) Here's one Python solution. Note the long integers: Python's regular signed integers aren't big enough. >>> ip = "192.168.2.1" >>> q = ip.split(".") >>> n = reduce(lambda a,b: long(a)*256 + long(b), q) >>> n 3232236033L The reduce() is equivalent to: >>> n = long(q[0]) * 256**3 + long(q[1]) * 256**2 + long(q[2]) * 256 + long(q[3]) You can get a mask m bits long like this: >>> mask = (long(2)**m) - 1 Now you can simply AND these together to get the network and host portions of the address: >>> host = n & mask >>> net = n - host Use the %x (or %X) format conversion to see the result in hex: >>> print "net: %X host: %X" % (net, host) net: C0000000 host: A80201 Here's a trickier way to convert a decimal dotted-quad IP address to a hex string and then to a decimal integer: >>> # change each decimal portion of IP address to hex pair >>> hexn = ''.join(["%02X" % long(i) for i in ip.split('.')]) >>> long(hexn, 16) 3232236033L Enjoy. Greg Jorgensen PDXperts LLC Portland, Oregon USA gregj at pdxperts.com From tim.one at home.com Sat Jun 23 05:17:54 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 23 Jun 2001 05:17:54 -0400 Subject: PEP 255: Simple Generators, Revised Posting In-Reply-To: Message-ID: Major revision: more details about exceptions, return vs StopIteration, and interactions with try/except/finally; more Q&A; and a BDFL Pronouncement. The reference implementation appears solid and works as described here in all respects, so I expect this will be the last major revision (and so also last full posting) of this PEP. The output below is in ndiff format (see Tools/scripts/ndiff.py in your Python distribution). Just the new text can be seen in HTML form here: http://python.sf.net/peps/pep-0255.html "Feature discussions" should take place primarily on the Python Iterators list: mailto:python-iterators at lists.sourceforge.net Implementation discussions may wander in and out of Python-Dev too. PEP: 255 Title: Simple Generators - Version: $Revision: 1.3 $ ? ^ + Version: $Revision: 1.12 $ ? ^^ Author: nas at python.ca (Neil Schemenauer), tim.one at home.com (Tim Peters), magnus at hetland.org (Magnus Lie Hetland) Discussion-To: python-iterators at lists.sourceforge.net Status: Draft Type: Standards Track Requires: 234 Created: 18-May-2001 Python-Version: 2.2 - Post-History: 14-Jun-2001 + Post-History: 14-Jun-2001, 23-Jun-2001 ? +++++++++++++ Abstract This PEP introduces the concept of generators to Python, as well as a new statement used in conjunction with them, the "yield" statement. Motivation When a producer function has a hard enough job that it requires maintaining state between values produced, most programming languages offer no pleasant and efficient solution beyond adding a callback function to the producer's argument list, to be called with each value produced. For example, tokenize.py in the standard library takes this approach: the caller must pass a "tokeneater" function to tokenize(), called whenever tokenize() finds the next token. This allows tokenize to be coded in a natural way, but programs calling tokenize are typically convoluted by the need to remember between callbacks which token(s) were seen last. The tokeneater function in tabnanny.py is a good example of that, maintaining a state machine in global variables, to remember across callbacks what it has already seen and what it hopes to see next. This was difficult to get working correctly, and is still difficult for people to understand. Unfortunately, that's typical of this approach. An alternative would have been for tokenize to produce an entire parse of the Python program at once, in a large list. Then tokenize clients could be written in a natural way, using local variables and local control flow (such as loops and nested if statements) to keep track of their state. But this isn't practical: programs can be very large, so no a priori bound can be placed on the memory needed to materialize the whole parse; and some tokenize clients only want to see whether something specific appears early in the program (e.g., a future statement, or, as is done in IDLE, just the first indented statement), and then parsing the whole program first is a severe waste of time. Another alternative would be to make tokenize an iterator[1], delivering the next token whenever its .next() method is invoked. This is pleasant for the caller in the same way a large list of results would be, but without the memory and "what if I want to get out early?" drawbacks. However, this shifts the burden on tokenize to remember *its* state between .next() invocations, and the reader need only glance at tokenize.tokenize_loop() to realize what a horrid chore that would be. Or picture a recursive algorithm for producing the nodes of a general tree structure: to cast that into an iterator framework requires removing the recursion manually and maintaining the state of the traversal by hand. A fourth option is to run the producer and consumer in separate threads. This allows both to maintain their states in natural ways, and so is pleasant for both. Indeed, Demo/threads/Generator.py in the Python source distribution provides a usable synchronized-communication class for doing that in a general way. This doesn't work on platforms without threads, though, and is very slow on platforms that do (compared to what is achievable without threads). A final option is to use the Stackless[2][3] variant implementation of Python instead, which supports lightweight coroutines. This has much the same programmatic benefits as the thread option, but is much more efficient. However, Stackless is a controversial rethinking of the Python core, and it may not be possible for Jython to implement the same semantics. This PEP isn't the place to debate that, so suffice it to say here that generators provide a useful subset of Stackless functionality in a way that fits easily into the current CPython implementation, and is believed to be relatively straightforward for other Python implementations. That exhausts the current alternatives. Some other high-level languages provide pleasant solutions, notably iterators in Sather[4], which were inspired by iterators in CLU; and generators in Icon[5], a novel language where every expression "is a generator". There are differences among these, but the basic idea is the same: provide a kind of function that can return an intermediate result ("the next value") to its caller, but maintaining the function's local state so that the function can be resumed again right where it left off. A very simple example: def fib(): a, b = 0, 1 while 1: yield b a, b = b, a+b When fib() is first invoked, it sets a to 0 and b to 1, then yields b back to its caller. The caller sees 1. When fib is resumed, from its point of view the yield statement is really the same as, say, a print statement: fib continues after the yield with all local state intact. a and b then become 1 and 1, and fib loops back to the yield, yielding 1 to its invoker. And so on. From fib's point of view it's just delivering a sequence of results, as if via callback. But from its caller's point of view, the fib invocation is an iterable object that can be resumed at will. As in the thread approach, this allows both sides to be coded in the most natural ways; but unlike the thread approach, this can be done efficiently and on all platforms. Indeed, resuming a generator should be no more expensive than a function call. The same kind of approach applies to many producer/consumer functions. For example, tokenize.py could yield the next token instead of invoking a callback function with it as argument, and tokenize clients could iterate over the tokens in a natural way: a Python generator is a kind of Python iterator[1], but of an especially powerful kind. - Specification + Specification: Yield ? ++++++++ A new statement is introduced: yield_stmt: "yield" expression_list "yield" is a new keyword, so a future statement[8] is needed to phase - this in. [XXX spell this out] + this in. [XXX spell this out -- but new keywords have ripple effects + across tools too, and it's not clear this can be forced into the future + framework at all -- it's not even clear that Python's parser alone can + be taught to swing both ways based on a future stmt] The yield statement may only be used inside functions. A function that - contains a yield statement is called a generator function. + contains a yield statement is called a generator function. A generator ? +++++++++++++ + function is an ordinary function object in all respects, but has the + new CO_GENERATOR flag set in the code object's co_flags member. When a generator function is called, the actual arguments are bound to function-local formal argument names in the usual way, but no code in the body of the function is executed. Instead a generator-iterator object is returned; this conforms to the iterator protocol[6], so in particular can be used in for-loops in a natural way. Note that when the intent is clear from context, the unqualified name "generator" may be used to refer either to a generator-function or a generator- iterator. Each time the .next() method of a generator-iterator is invoked, the code in the body of the generator-function is executed until a yield or return statement (see below) is encountered, or until the end of the body is reached. If a yield statement is encountered, the state of the function is frozen, and the value of expression_list is returned to .next()'s caller. By "frozen" we mean that all local state is retained, including the current bindings of local variables, the instruction pointer, and the internal evaluation stack: enough information is saved so that the next time .next() is invoked, the function can proceed exactly as if the yield statement were just another external call. + Restriction: A yield statement is not allowed in the try clause of a + try/finally construct. The difficulty is that there's no guarantee + the generator will ever be resumed, hence no guarantee that the finally + block will ever get executed; that's too much a violation of finally's + purpose to bear. + + + Specification: Return + A generator function can also contain return statements of the form: "return" Note that an expression_list is not allowed on return statements in the body of a generator (although, of course, they may appear in the bodies of non-generator functions nested within the generator). - When a return statement is encountered, nothing is returned, but a + When a return statement is encountered, control proceeds as in any + function return, executing the appropriate finally clauses (if any - StopIteration exception is raised, signalling that the iterator is ? ------------ + exist). Then a StopIteration exception is raised, signalling that the ? ++++++++++++++++ - exhausted. The same is true if control flows off the end of the + iterator is exhausted. A StopIteration exception is also raised if + control flows off the end of the generator without an explict return. + - function. Note that return means "I'm done, and have nothing ? ----------- + Note that return means "I'm done, and have nothing interesting to ? +++++++++++++++ - interesting to return", for both generator functions and non-generator ? --------------- + return", for both generator functions and non-generator functions. ? +++++++++++ - functions. + + Note that return isn't always equivalent to raising StopIteration: the + difference lies in how enclosing try/except constructs are treated. + For example, + + >>> def f1(): + ... try: + ... return + ... except: + ... yield 1 + >>> print list(f1()) + [] + + because, as in any function, return simply exits, but + + >>> def f2(): + ... try: + ... raise StopIteration + ... except: + ... yield 42 + >>> print list(f2()) + [42] + + because StopIteration is captured by a bare "except", as is any + exception. + + + Specification: Generators and Exception Propagation + + If an unhandled exception-- including, but not limited to, + StopIteration --is raised by, or passes through, a generator function, + then the exception is passed on to the caller in the usual way, and + subsequent attempts to resume the generator function raise + StopIteration. In other words, an unhandled exception terminates a + generator's useful life. + + Example (not idiomatic but to illustrate the point): + + >>> def f(): + ... return 1/0 + >>> def g(): + ... yield f() # the zero division exception propagates + ... yield 42 # and we'll never get here + >>> k = g() + >>> k.next() + Traceback (most recent call last): + File "", line 1, in ? + File "", line 2, in g + File "", line 2, in f + ZeroDivisionError: integer division or modulo by zero + >>> k.next() # and the generator cannot be resumed + Traceback (most recent call last): + File "", line 1, in ? + StopIteration + >>> + + + Specification: Try/Except/Finally + + As noted earlier, yield is not allowed in the try clause of a try/ + finally construct. A consequence is that generators should allocate + critical resources with great care. There is no restriction on yield + otherwise appearing in finally clauses, except clauses, or in the try + clause of a try/except construct: + + >>> def f(): + ... try: + ... yield 1 + ... try: + ... yield 2 + ... 1/0 + ... yield 3 # never get here + ... except ZeroDivisionError: + ... yield 4 + ... yield 5 + ... raise + ... except: + ... yield 6 + ... yield 7 # the "raise" above stops this + ... except: + ... yield 8 + ... yield 9 + ... try: + ... x = 12 + ... finally: + ... yield 10 + ... yield 11 + >>> print list(f()) + [1, 2, 4, 5, 8, 9, 10, 11] + >>> Example # A binary tree class. class Tree: def __init__(self, label, left=None, right=None): self.label = label self.left = left self.right = right def __repr__(self, level=0, indent=" "): s = level*indent + `self.label` if self.left: s = s + "\n" + self.left.__repr__(level+1, indent) if self.right: s = s + "\n" + self.right.__repr__(level+1, indent) return s def __iter__(self): return inorder(self) # Create a Tree from a list. def tree(list): n = len(list) if n == 0: return [] i = n / 2 return Tree(list[i], tree(list[:i]), tree(list[i+1:])) # A recursive generator that generates Tree leaves in in-order. def inorder(t): if t: for x in inorder(t.left): yield x yield t.label for x in inorder(t.right): yield x # Show it off: create a tree. t = tree("ABCDEFGHIJKLMNOPQRSTUVWXYZ") # Print the nodes of the tree in in-order. for x in t: print x, print # A non-recursive generator. def inorder(node): stack = [] while node: while node.left: stack.append(node) node = node.left yield node.label while not node.right: try: node = stack.pop() except IndexError: return yield node.label node = node.right # Exercise the non-recursive generator. for x in t: print x, print + Both output blocks display: + + 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 + Q & A + Q. Why not a new keyword instead of reusing "def"? + + A. See BDFL Pronouncements section below. + - Q. Why a new keyword? Why not a builtin function instead? + Q. Why a new keyword for "yield"? Why not a builtin function instead? ? ++++++++++++ A. Control flow is much better expressed via keyword in Python, and yield is a control construct. It's also believed that efficient implementation in Jython requires that the compiler be able to determine potential suspension points at compile-time, and a new - keyword makes that easy. + keyword makes that easy. The CPython referrence implementation also + exploits it heavily, to detect which functions *are* generator- + functions (although a new keyword in place of "def" would solve that + for CPython -- but people asking the "why a new keyword?" question + don't want any new keyword). + + Q: Then why not some other special syntax without a new keyword? For + example, one of these instead of "yield 3": + + return 3 and continue + return and continue 3 + return generating 3 + continue return 3 + return >> , 3 + from generator return 3 + return >> 3 + return << 3 + >> 3 + << 3 + + A: Did I miss one ? Out of hundreds of messages, I counted two + suggesting such an alternative, and extracted the above from them. + It would be nice not to need a new keyword, but nicer to make yield + very clear -- I don't want to have to *deduce* that a yield is + occurring from making sense of a previously senseless sequence of + keywords or operators. Still, if this attracts enough interest, + proponents should settle on a single consensus suggestion, and Guido + will Pronounce on it. + + Q. Why allow "return" at all? Why not force termination to be spelled + "raise StopIteration"? + + A. The mechanics of StopIteration are low-level details, much like the + mechanics of IndexError in Python 2.1: the implementation needs to + do *something* well-defined under the covers, and Python exposes + these mechanisms for advanced users. That's not an argument for + forcing everyone to work at that level, though. "return" means "I'm + done" in any kind of function, and that's easy to explain and to use. + Note that "return" isn't always equivalent to "raise StopIteration" + in try/except construct, either (see the "Specification: Return" + section). + + Q. Then why not allow an expression on "return" too? + + A. Perhaps we will someday. In Icon, "return expr" means both "I'm + done", and "but I have one final useful value to return too, and + this is it". At the start, and in the absence of compelling uses + for "return expr", it's simply cleaner to use "yield" exclusively + for delivering values. + + + BDFL Pronouncements + + Issue: Introduce another new keyword (say, "gen" or "generator") in + place of "def", or otherwise alter the syntax, to distinguish + generator-functions from non-generator functions. + + Con: In practice (how you think about them), generators *are* + functions, but with the twist that they're resumable. The mechanics of + how they're set up is a comparatively minor technical issue, and + introducing a new keyword would unhelpfully overemphasize the + mechanics of how generators get started (a vital but tiny part of a + generator's life). + + Pro: In reality (how you think about them), generator-functions are + actually factory functions that produce generator-iterators as if by + magic. In this respect they're radically different from non-generator + functions, acting more like a constructor than a function, so reusing + "def" is at best confusing. A "yield" statement buried in the body is + not enough warning that the semantics are so different. + + BDFL: "def" it stays. No argument on either side is totally + convincing, so I have consulted my language designer's intuition. It + tells me that the syntax proposed in the PEP is exactly right - not too + hot, not too cold. But, like the Oracle at Delphi in Greek mythology, + it doesn't tell me why, so I don't have a rebuttal for the arguments + against the PEP syntax. The best I can come up with (apart from + agreeing with the rebuttals ... already made) is "FUD". If this had + been part of the language from day one, I very much doubt it would have + made Andrew Kuchling's "Python Warts" page. Reference Implementation - A preliminary patch against the CVS Python source is available[7]. + The current implementation, in a preliminary state (no docs and no + focused tests), is part of Python's CVS development tree[9]. + Using this requires that you build Python from source. + + This was derived from an earlier patch by Neil Schemenauer[7]. Footnotes and References [1] PEP 234, http://python.sf.net/peps/pep-0234.html [2] http://www.stackless.com/ [3] PEP 219, http://python.sf.net/peps/pep-0219.html [4] "Iteration Abstraction in Sather" Murer , Omohundro, Stoutamire and Szyperski http://www.icsi.berkeley.edu/~sather/Publications/toplas.html [5] http://www.cs.arizona.edu/icon/ [6] The concept of iterators is described in PEP 234 http://python.sf.net/peps/pep-0234.html [7] http://python.ca/nas/python/generator.diff [8] http://python.sf.net/peps/pep-0236.html + [9] To experiment with this implementation, check out Python from CVS + according to the instructions at + http://sf.net/cvs/?group_id=5470 Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil End: From castor at snafu.de Wed Jun 6 17:56:04 2001 From: castor at snafu.de (Wolfgang Lipp) Date: Wed, 06 Jun 2001 21:56:04 GMT Subject: Question re local bindings in nested scopes References: <8gdnht4as9mg09un8vu2ci2re80p2ujssq@4ax.com> Message-ID: <1104_991864564@ns.seowon.ac.kr> On Mon, 04 Jun 2001 09:55:41 -0700, Kirby Urner wrote: > > I don't get why the following two functions, each with internal > functions that take advantage of lexical scoping (new in 2.1), > behave so differently: > > from __future__ import nested_scopes > > def spam(a,b): > def bar(): > output = [] > print b > print a > output.append(a+1) > return output > return [x for x in bar()] > > def foo(a,b): > def bar(): > output = [] > print b > print a > a += 1 > output.append(a) > return output > return [x for x in bar()] > > >>> spam(1,10) > 10 > 1 > [2] > >>> foo(1,10) > 10 > Traceback (most recent call last): > File "", line 1, in ? > foo(1,10) > File "d:\program files\python21\ocn\test.py", line 38, in foo > return [x for x in bar()] > File "d:\program files\python21\ocn\test.py", line 34, in bar > print a > UnboundLocalError: local variable 'a' referenced before assignment > > I can fix foo() by assigning a to s and doing the increment on s: > > def foo(a,b): > def bar(): > output = [] > print b > print a > s = a # added this line > s += 1 # added this line > output.append(s) > return output > return [x for x in bar()] > > But should a=a+1 (or a += 1) really break the initial binding of a > to the outer scope? Is this intended? Given a and b initialize to > the outer scope values just fine in spam(), it seems odd to unbind > an already initialized variable at "compile time" just because we > add 1 to it. Seems too subtle for its own good. a=a+1 would seem > a runtime operation on a variable that is already initialized at > compile time thanks to lexical scoping. > > Kirby > > CC replies/insights to pdx4d at teleport.com and/or above address please > From akuchlin at mems-exchange.org Fri Jun 15 17:08:16 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 15 Jun 2001 17:08:16 -0400 Subject: Any other Python flaws? References: <3B2A530C.5F798823@bioreason.com> Message-ID: <3dvglxe9j3.fsf@ute.cnri.reston.va.us> Mitch Chapman writes: > I suspect from some of your follow-ups that "uncancellable threads" > does not fit the purpose of your design flaws page, and in any > case it's covered by a PEP (42?). Even so, since the problem > extends across all platforms I'll propose it. It's hard to see how you could implement cancellable threads with reasonable performance, though, unless the OS implements all the primitives and can therefore clean things up when a thread is cancelled. I lean more and more toward thinking that threads are a mistake, and if you think you need them, your OS simply has processes that are too heavyweight. --amk From new_name at mit.edu Thu Jun 7 12:12:12 2001 From: new_name at mit.edu (Alex) Date: 07 Jun 2001 12:12:12 -0400 Subject: getting current call stack References: Message-ID: Is there any way to determine the current call stack from a method/function? Use the traceback module. eg import traceback, pprint def where(): pprint.pprint(traceback.extract_stack()) if __name__ == '__main__': where() HTH Alex. From gustafl at algonet.se Thu Jun 21 15:54:47 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 21 Jun 2001 19:54:47 GMT Subject: Newbie xml.sax question References: Message-ID: Martin von Loewis wrote: >You shouldn't return a result from startElement; instead, you need to >store the value for until after parsing, e.g. Aha. Thank you, now it works. :-) Gustaf From barry at digicool.com Tue Jun 5 18:36:32 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Tue, 5 Jun 2001 18:36:32 -0400 Subject: multifile and mimetools to parse email folder References: <9fjeh0$7me$07$1@news.t-online.com> Message-ID: <15133.24304.352202.589432@anthem.wooz.org> >>>>> "JH" == J?rgen Hermann writes: JH> Did you spend any thoughts on adding header en-/decoding? The JH> stuff in mimify is broken. I've thought about it a little bit, but haven't had time to implement it. I think it might be a good idea to use unicode strings for encoded header values. -Barry From paulp at ActiveState.com Mon Jun 11 19:39:19 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Mon, 11 Jun 2001 16:39:19 -0700 Subject: Problem with UnicodeError and xml.dom.minidom References: Message-ID: <3B2556A7.9087A887@ActiveState.com> Gustaf Liljegren wrote: > >... > > Hope this is enough info for someone to solve it. Otherwise, I'd gladly > share the complete code if you need. But it may be too much for a > newsgroup. The easiest thing is to do the comparison as 8-bit strings rather than Unicode strings: if string.find(m.get('from'), e.encode("Latin-1")): or both as Unicode strings: if string.find(unicode(m.get('from'), "Latin-1"), e): Some of us have fought a losing war to make Python do that for you automatically but the opposition is fierce, well organized and well funded. ;) -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From claird at starbase.neosoft.com Fri Jun 8 22:55:44 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 8 Jun 2001 21:55:44 -0500 Subject: Generating WSDL for Python SOAP services References: <9f8tri$2g1$1@news.jump.net> Message-ID: <3A718620A8A31127.623E8D60A6ED7A56.B82E85271A2080D7@lp.airnews.net> In article <9f8tri$2g1$1 at news.jump.net>, Preston Landers wrote: >Hi all. > >My company (journyx.com) is planning to use SOAP to expose some methods of >our application server. The goal is to write a client that will ultimately >be embedded in an MS Office application and make calls to installations of >our software. > >We are using the actzero.com SOAP.py 0.9.5 module to implement the server >side, and the MS SOAP 2.0 toolkit on the client side. The MS toolkit "high >level API" requires that services have a WSDL (web services description >language) file that describes the methods that are availible and their >parameters. We are really hoping to use the "high level API" and thus avoid >writing our own handlers in Visual Basic, which is not our forte. (Python >is.) > >Therefore I am planning to write a WSDL generator that will examine our >exposed methods and write out a valid WSDL file. I realize you can compose . . . >I'm posting to the newsgroup to check if anyone else is already working >along these lines, or has any thoughts on the subject. . . . Yes. Others are working on this. I like to think that a complete solution will be public within a couple of weeks, in the natural course of events. If not, my bet is that a modest contracted incentive will produce as much PyWSDL functionality as you need, in a timely manner. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From rnd at onego.ru Thu Jun 7 15:09:19 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 7 Jun 2001 23:09:19 +0400 (MSD) Subject: UML <-> Python Message-ID: Hello, It occured to me that probably Python language has some abilities which couldn't be expressed in UML. For example: 0. How to express that object attributes can be added "on the fly"? 1. In Python it is possible to pass modules/packages as arguments. How to express this on static-model diagram? 2. Python's signature-based polymorphism is probably too "amorphic" to express with usual class boxes. But is it appropriate to use interfaces to describe this better? (interfaces aren't explicit in Python). 3. Some mighty features of Python coming from functional programming and used to organize conveyers of operations within containers couldn't (IMHO) adequately expressed by UML, because they are SIMD (single instruction, multiple data) things. It could be also interesting to hear the opposite: which UML diagrams (or their aspects) couldn't be directly applied in Python. For example, I have a feeling Python isn't very proficient in hiding details of threading. (Some modules are not thread-safe). Another point is that Python doesn't have language-level support for "private" and "protected" properties (not to mention types). OK, I am only started to learn UML and probably my questions are silly, but it seems UML is much more into C++/Java and imposes more constraints on design than Python. Has anybody out of pure curiosity to take UML description of some "serious" project (implemented in "serious" languages like C++ or Java) and try to implement most difficult parts in "named-after-the-comic-show" language ;-) What was the result? (I myself had pleasure to rewrite Perl programs in Python and once it even saved us from remote exploit. But that was not very serious scripts). Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Thursday, June 07, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Anything not nailed down is a cat toy." _/ From JamesL at Lugoj.Com Fri Jun 1 00:03:38 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Thu, 31 May 2001 21:03:38 -0700 Subject: Obsolesence of <> References: Message-ID: <3B17141A.11814668@Lugoj.Com> "Steven D. Majewski" wrote: > I thought =!= was reserver for one of the Orwell fuzzy comparators -- > > =!= the-same-but-different > > the others being: > > ==> equal-but-more-equal > <== equal-but-less-equal === equal-and-nothing-but-equal !!! not-even-in-the-same-universe <=> mostly-more-or-less-but-sometimes-the-same-or-maybe-darth-vader's-tie-fighter From az at cantanker.net.nospam Thu Jun 21 10:25:06 2001 From: az at cantanker.net.nospam (Cantanker) Date: Thu, 21 Jun 2001 14:25:06 GMT Subject: Pythoin MUD (PyMUD?) References: <9gqq3t$hvs$1@brokaw.wa.com> Message-ID: <6tnY6.149028$ff.1136120@news-server.bigpond.net.au> "Jonathan Gardner" wrote: > 1) Is there any existing python muds out there? I believe Eric Raymond recently wrote one, called 'make advent'. :) -- Cantanker / ---------/------------- / cantanker.net From qrczak at knm.org.pl Sat Jun 23 10:28:34 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 23 Jun 2001 14:28:34 GMT Subject: adding instance methods after instantiation References: <9h1vg2$14cc$1@node21.cwnet.roc.gblx.net> Message-ID: Sat, 23 Jun 2001 11:45:06 +0000 (UTC), Lee Harr pisze: > Is there some way to make m2 an instance method so that > it will automatically get passed c1 as its first > argument? You are putting it in a concrete instance. In this case you know the instance to pass: c1.m2 = lambda *args, **kwargs: m2(c1, *args, **kwargs) Note that it requires 'from __future__ import nested_scopes' if used inside a function. Without that feature m2 and c1 would have to be passed using the default argument trick and the function could not be fully general (these default arguments would not be available in kwargs). It creates a reference cycle. Newer Python versions garbage collect this, although not immediately; older don't. If the function is used only in one instance, you could as well refer to self as c1 in its body instead of through the argument, and the above would not be needed. If you put the method in a class instead of in the instance (i.e. c.m2 = m2), it will be passed the instance implicitly (and it will be available from all instances). -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From mcherm at destiny.com Tue Jun 5 15:06:03 2001 From: mcherm at destiny.com (Michael Chermside) Date: Tue, 05 Jun 2001 14:06:03 -0500 Subject: random Message-ID: <3B1D2D99.B2554934@destiny.com> David C. Ullrich wrote: > > > > [An lengthy and EXCELLENT detailed description of Omega, how it's > > defined, why it is/isn't "random", and how it all relates -- all > > expressed in terms a layperson can follow.] > > Well, it's certainly the case that you can still learn things on USENET. Thanks! -- Michael Chermside From ullrich at math.okstate.edu Mon Jun 4 11:52:37 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 04 Jun 2001 15:52:37 GMT Subject: random References: Message-ID: <3b1b9dd5.5603777@nntp.sprynet.com> On Sun, 3 Jun 2001 18:14:47 -0400, "Tim Peters" wrote: >[David C. Ullrich] >> ... >> Not that readers are likely to be reading carefully enough that it's >> going to matter, but just for the sake of telling no lies: I put >> my finger on what was bothering me about what I said here. >> It's not true that the sequence of bits of Omega is recursively >> enumerable. What's true (assuming that the N-th bit is 1 if the >> N-th program halts and 0 otherwise) is that the sequence of N >> for which the N-th bit is 1 is recursively enumerable. The >> set of N for which the N-th bit is 0 is _not_ recursively >> enumerable (and hence the sequence of bits of Omega is not >> recursively enumerable.) > >It's the "assuming that the N-th bit is 1 [iff] the N-th program halts" >that's off. Omega is the probability that "a random" program halts, and it >won't take long to figure out that "N'th-bit = halts(N-th program)" doesn't >work for that (e.g., if the 0'th program happens to halt, that would imply >the halting probability is >= 1/2 across all programs -- but the 0'th >program isn't generally that smart ). Um, actually I'm pretty sure that Omega _is_ what I said it is, and is also what you say it is. The first thing you need to note is that "probability that a random program halts" is _meaningless_ until we have specified how we are _choosing_ our "random program". Cf Bertand's Paradox: What's the probability that the length of a chord of a circle is larger than the radius? The answer is that this question has no answer until we specify how we choose that random chord. Any point inside the circle is the midpoint of a unique chord - if you choose a "random" point inside the circle and calculuate the probability that the length of the chord is longer than the radius you get one answer. But a chord is also determined by two points on the boundary - if you choose two points on the boundary "at random" and calculuate the probability that the chord is longer than the radius you get a different answer. Not an actual "paradox", simply shows that the meaning of "at random" is not well-defined. Technically, one needs to _specify_ a probability distribution on one's sample space before talking about the probability of anything. In some cases there is a "natural" distribution determined by symmetry. For example if someone says "random integer between 0 and 5 inclusive" it's reasonable to assume that the uniform distribution is intended, that is, we have X so that P(X=0) = P(X=1) = ... = P(X=5) = 1/6. (But in mathematics written by careful mathematicians one would not assume this was the default, one would specify the distribution. Never mind...) Now, what about a "random positive integer"? Is there a "natural" distribution to assume is meant there? No, when someone says "random positive integer" we cannot assume that the default uniform distribution is intended, because there _is_ no uniform distribution! Really. Suppose that I'm wrong, and saying "random positive integer" actually does specify something. Suppose that X is a random positive integer. Now what is P(X=1)? If we're talking about a "natural" distribution then P(X=1) = P(X=2) = P(X=3) = ... , by symmetry. But P(X=1) + P(X=2) + ... = 1. Now if all those numebers are equal then they're either positive or 0. If P(X=1) = 0 then it follows that 0 = 1. If P(X=1) > 0 then it follows that infinity = 1. So. There _is_ no "natural" default distribution on the positive integers - if you say something about a "random positive integer" you have not said anything unless you _specify_ a distribution. There are various different ways to specify a distribution on the positive integers, and they give different answers to questions about the properties of a "random positive integer." Ok. So Omega is the probability that a "random program" halts. This is one of those things I mentioned earlier: you read people talking about Chaitin's stuff and you say "what??", then you read what Chaitin actually wrote and you're relieved to see he included the details: Yesterday I looked at that link you provided and I saw Chaitin define Omega as the probability that a random program halts. My first reaction was that of course that's meaningless until you specify how you _select_ your "random program" (more precisely but less intuitively, until you specify what distribution on the space of all programs you are referring to.) But I read on: Chaitin is very well aware of everything I just said. Although he did not explain why he needed to do so, he _did_ "specify" what distribution he had in mind. Even though it was just a survey article - he knew I was going to be reading it someday. He says something like this (um, I may not get the details the same because I just skimmed it, I'm pretty sure he says something like this): There are countably many Turing machines. Enumerate them as T1, T2, ... . Now perform an experiment: Flip a coin. If it's heads then let T = T1. If it's tails flip again and if it's heads let T = T2. If it's tails flip again and if it's heads let T = T3. etc. With probability one we eventually get a head, so we have in fact chosen a random Turing machine T, with a well-defined distribution. Now Omega is the probability that T halts. The previous paragraph is a precise/rigorous specification of "Omega is the probability that a random program halts" (except it doesn't quite pin down what Omega _is_ since it does not specify exactly what order we put the Turing machines in at the start. To actually _define_ the sequence T1, T2,... we'd need to get into details of the syntax we were using to define TM's.) Now what _is_ the probability that T halts? We know that T is one of T1, T2, ... but we don't know which one. So P(T halts) = P(T = T1) * P(T1 halts) + P(T = T2) * P(T2 halts) + P(T = T3) * P(T3 halts) + ... But P(T = Tn) = 2**(-n). And there's nothing random about T1, it halts or it doesn't. If we say that Halts(T1) takes values 0 or 1 instead of True or False then we have exactly P(Tn halts) = Halts(Tn) for each n. Plug this and that into the previous equation and you get P(T halts) = 2^(-1) * Halts(T1) + 2^(-2) * Halts(T2) + 2^(-3) * Halts(T3) + ... And this exactly the sum of 2^(-n), where n ranges over all the values such that Tn halts. Which is a number with n-th bit = 1 iff Tn halts. **************** Ane there you are. The phrase "probability that a random program halts" _is_ meaningless mathematically until you specify a distribution on the space of all programs. Chaitin does specify a distribution. It's possible that I'm recalling the way he chooses a Turing machine by flipping coins incorrectly, but I don't think so. And in any case if you _do_ choose your program by flipping a coin as above that specifies a distribution, and with that distribution the probability that a random program halts _is_ a number with n-th bit = 1 if and only if the n-th TM halts. Yes, this does give us a lot of choice regarding what Omega should be. Um, "choice" is the wrong word. It does leave a lot of ambiguity regarding what the value of Omega actually is. In particular there exists an ordering T1, T2,... so that Omega = 1010101010101010... in binary. We can't _specify_ how to _define_ that ordering, but it exists (and when we start with an unspecified ordering we cannot know that it is _not_ one that gives Omega = .1010....) In particular if Omega is "the probability that a random program halts" and that's all we know about Omega then we cannot know that Omega is not 0.10101010..., which might seem to some as not the best choice for an RNG. (Exercise: Although we cannot know all of Omega, and so we cannot _specify_ an ordering of our Turing machines that will make Omega = 0.1010..., we _can_ __specify__ an _explicit_ ordering which will make Omega have the form 0.11?11?11?11?... .) (And in fact when I think about how to do that and I think about how one would "naturally" order the TM's it's not clear to me that such non-randomness does not creep into Omega defined using a "natural" ordering...) If I have the "definition" straight (and note that nothing I've said contradicts what you said about the definition!) then the bits of Omega are not going to be much use for an RNG. But it turns out that Omega _does_ solve a _different_ practical problem! What's the other pressing problem? Determining which reals have exact floating-point representations. Thm1. Omega does not have an exact representation in finite-but-unbounded-precision floating point. Thm2. Thm1 is all you can say about Omega, given the definition above: If x is any real (between 0 and 1) and x does not have an exact representation in finite-but-unbounded-precision floating point then there is an ordering T1, T2,... of our Turing machines that makes Omega = x. So: If you're wondering whether x can be represented exactly, simply first jiggle so 0 < x < 1, and then determine whether or not you can prove that x <> Omega. x can be represented exactly iff and only if it is possible to prove x <> Omega from the information about Omega above. I mention this for the benefit of those naive programmers we've been hearing about who want to know how to tell what can be represented exactly. HTH. >Not that the number you define >there isn't interesting in its own right! It's a classic example of a >non-computable real that can be approximated from below, and it shares that >much with Chaitin's Omega; but, IIRC, it doesn't meet the criteria for >randomness No it doesn't - this is exactly why I said to Alex just now that come to think of it I don't think we could use the bits of Omega for an RNG even if we could figure out what they were. I may have the definition of Omega wrong (but note again that what I'm taking for the "definition" is exactly consistent with what you say the definition is, I've just added more details). If I have the definition right then this really shows that the notion of "random" being used here is very different from other versions of the word. (Devil's advocate: But if Omega can be 0.10101010... then how can it be incompressible? You're not actually saying Chatin's wrong about that, are you? Ans: Have you read the _proof_ that it's incompressible? In particular can you say exactly what the hypotheses are? It may well be that if we start with a _definable_ ordering T1, T2, ... then we get an incompressible Omega. That's consistent with the above (the ordering giving .10101010... is _not_ definable, and while the ordering giving .11?11?11?... is definable I don't see why that sequence has to be compressible. Could well be that he simply didn't include the hypothesis about the ordering being definable in his survey paper. (Just like nobody _ever_ includes all the hypotheses in Godel's theorems when they're discussing them informally - people just assume that the axioms are recursive without mentioning it.) > (machine I can be related to machine I+1 in an exploitable way >s.t. halt(I) gives information about halt(I+1) -- for example, define the >encoding s.t. odd-numbered machines J merely prepend a no-op to the J-1 >machine, and then halt(J) == halt(J-1), so adjacent bits in the derived sum >are strongly correlated). > >Perhaps the easiest gimmick for programmers to grok is that the set of >rationals less than omega is recursively enumerable: Chaitin gives you a >generator object g such that the loop > > while 1: > r = g.next() > >eventually generates every rational number r less than omega. Then the >generated sequence of values r_0, r_1, .. approximates omega from below >(although only the biggest-so-far-seen are interesting), and for any real >epsilon greater than 0 there's *some* i s.t. omega - r_i < epsilon (since >every rational less than omega is eventually generated). So a subsequence >of the r_i converges to omega. Two results of the theory are that there's >no effective way to compute i as a function of epsilon ("you can't tell how >close you are"), yet there's no better way to compute omega than by running >that loop (you can study the implementation of g.next() all you like, but >there's no *fundamentally* better way to do it). Yup. Doesn't contradict the statement that the n-th bit is 1 if and only if the n-th program halts. > That last part eats at the >optimizers among us . > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From new_name at mit.edu Fri Jun 8 14:35:08 2001 From: new_name at mit.edu (Alex) Date: 08 Jun 2001 14:35:08 -0400 Subject: Passing back an array from an extension module? References: <9fqqqo$1p3e$1@newshost.nmt.edu> Message-ID: Yeah, numpy seems like a sensible choice for that. I have an example of how to do it in http://puffin.lcs.mit.edu:8080/align.tgz HTH. Alex. From billw at witherspoon-design.com Sun Jun 3 14:27:28 2001 From: billw at witherspoon-design.com (Bill Witherspoon) Date: Sun, 3 Jun 2001 14:27:28 -0400 Subject: Dynamically making lists? Message-ID: <000901c0ec5a$dac96f60$fd00a8c0@bill1> Hi all, If I have a list -> L = ['one', 'two', 'three',......,'one thousand'] and I want to split this into several lists with (say) two elements each -> m = ['one', 'two'] n = ['three', 'four'] o = ['five', 'six'} ...... zz = ['nine hundred ninety nine', 'one thousand'] How would I do this? I don't know how many elements are in L before I run the program. It seems like I have to generate variable names on the fly? Maybe there's something simple I'm missing here. Any pointers would be appreciated. TIA, Bill. From m.faassen at vet.uu.nl Fri Jun 1 17:58:44 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 1 Jun 2001 21:58:44 GMT Subject: Why isn't Python king of the hill? References: <9f7ai7$b4e$1@newshost.accu.uu.nl> <9f84rr$95m$1@panix2.panix.com> Message-ID: <9f936k$b2q$1@newshost.accu.uu.nl> Aahz Maruch wrote: > In article <9f7ai7$b4e$1 at newshost.accu.uu.nl>, > Martijn Faassen wrote: >> >>I believe there's a PEP about introducing decimal math into the Python >>core as the default behavior eventually; there's a thread elsewhere on >>the newsgroup. > Not quite. There's currently a PEP for making the default *rational* > arithmetic; I'm currently working on a module based on the ANSI standard > for decimal floating-point arithmetic. There's already Tim Peters's > FixedPoint for fixed-point decimal arithmetic. > I'm staying out of the politics on this one and leaving it to the > experts; I don't even really know enough to implement decimal > arithmetic, but I'm doing it anyway. ;-) You evidently know far more than I, however. So there's fixed-point, decimal floating-point and rational arithmetic.. And plain-old-confusing floats. :) They all involve numbers with points in them.. and when you do math with them, the answers may be different. That's about the extent of my knowledge. Perhaps I can use them in a 'voting system', like mission critical computers do (in the space shuttle and all). Use all four techniques and average the results. Or perhaps discard outlying values and then average, or use a sophisticated weighting system.. Hmm.. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From dsh8290 at rit.edu Wed Jun 27 13:35:45 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 27 Jun 2001 13:35:45 -0400 Subject: KDE and Windows In-Reply-To: <993660235.135465@seven.kulnet.kuleuven.ac.be>; from nightowl@uk2.net on Wed, Jun 27, 2001 at 06:43:10PM +0200 References: <993660235.135465@seven.kulnet.kuleuven.ac.be> Message-ID: <20010627133545.C17001@harmony.cs.rit.edu> On Wed, Jun 27, 2001 at 06:43:10PM +0200, NightOwl wrote: | Is it possible to develop a GUI which runs in Windows aswell as in KDE with | the same code ? I don't want to have to re-write all code just because I use | an other OS ... ? (Not using the COM-functions of Windows). Yes. Qt runs on both Unix and Windows. However Qt is not free for Windows (as-is). Just don't use any KDE/Linux specific features or any Windows specific features. -D From fcnpereira at home.com Sat Jun 16 23:35:01 2001 From: fcnpereira at home.com (Fernando Pereira) Date: Sun, 17 Jun 2001 03:35:01 GMT Subject: Why should i use python if i can use java References: Message-ID: <160620012334584600%fcnpereira@home.com> > Did guido use the time > machine to get a copy of the GoFBook before he started working on the > first version of Python, or are Patterns just a transparent attempt to > cover for chronically inexpressive languages like C++ and Java which can't > generally implement these mind-numbingly simple constructs in code? You just answered your own question, didn't you? -- F From db3l at fitlinxx.com Fri Jun 15 21:24:14 2001 From: db3l at fitlinxx.com (David Bolen) Date: 15 Jun 2001 21:24:14 -0400 Subject: str smarter than round? References: <9F852011A819CAA6.2C9141DBD4DB433F.3BFF2DB5D91E2E16@lp.airnews.net> Message-ID: claird at starbase.neosoft.com (Cameron Laird) writes: > In article , > Tim Peters wrote: > . > . > . > >Congratulations! You've elected yourself to be a guinea pig for reading > >this new Tutorial Appendix: > > > > http://python.sourceforge.net/devel-docs/tut/node14.html > > > >never-ask-a-question-unless-you-really-want-an-answer-ly y'rs - tim > > > > > > Is there or will there be a (more) persistent URL for this > Appendix? I assumer "node14" is likely to vary every few > weeks or so. You could just back up one level (to "tut") and then select Appendix B from the TOC :-) As it is, it's probably reasonably robust anyway since the nodes are numbered by major chapter, so a full new chapter (as opposed to sections or subsections, or other editing changes) would have to be added for that URL to change. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From no at spam.com Fri Jun 29 14:48:23 2001 From: no at spam.com (MDK) Date: Fri, 29 Jun 2001 14:48:23 -0400 Subject: Is this a true statement: Part II Message-ID: <9hiifr$sjs$1@taliesin.netcom.net.uk> Hello, Well, I was overwhelmed by the number of posts that resulted from the following statement: "Python can do everything C++ can do but just slower." Actually, it was not so much the quantity of the posts as it was the depth at which the discussions on principles, theories, and practices of computer science were explored. My purpose for this post was really not so esoteric; I did not have device drivers in mind when I posted. However, I did enjoy reading them. I am not sure after reading all the replies that I can say with confidence yes or no. I think that I can at least say this (if I understand most of what was said): 1. Excluding writing device drivers the answer is a clear yes. 2. Including writing device drivers, and depending upon ones definition of certain terms: a. Python can be used but perhaps not in the sense of 'pure' Python programming. b. On the other hand, Python can be used to program device drivers in so much as an hex editor can be used. Perhaps this is oversimplification and to some it's just wrong. But, what can I say? It got a little weird there. Anyway, of all the things that I'd learned from these readings the thing that surprised me the most were the statements regarding C++. My impression of C++ was that it was the end-all, be-all of languages and if you wanted to write a serious program you wrote it in C++. However, I'd seen in the posts at least once the word 'awful' to describe it. At least one person agreed and no one rebelled. So here is my second question - and explain it in such a way that I can explain it to my boss. Why is C++ awful; what's wrong with it? Best regards, Mark P.S. I know that this is off topic now but you don't expect me to post this question to the C++ forum, do you? From tdickenson at devmail.geminidataloggers.co.uk Tue Jun 19 04:52:14 2001 From: tdickenson at devmail.geminidataloggers.co.uk (Toby Dickenson) Date: Tue, 19 Jun 2001 09:52:14 +0100 Subject: PEP 255: Simple Generators References: <3B2EEF5A.8FF0DAFB@cosc.canterbury.ac.nz> Message-ID: Greg Ewing wrote: >Something is bothering me about this. In fact, >it's bothering me a LOT. In the following, will >f() work as a generator-function: > > def f(): > for i in range(5): > g(i) > > def g(i): > for j in range(10): > yield i,j > >If I understand PEP255 correctly, this will *not* >work. But it seems entirely reasonable to me that >it *should* work. It *has* to work, otherwise how >am I to write generators that are too complicated >to fit into a single function? > >Someone please tell me I'm wrong about this! def f(): for i in range(5): for pair in g(i): yield pair def g(i): for j in range(10): yield i,j Toby Dickenson tdickenson at geminidataloggers.com From mwh at python.net Thu Jun 21 19:20:48 2001 From: mwh at python.net (Michael Hudson) Date: Fri, 22 Jun 2001 00:20:48 +0100 (BST) Subject: python-dev summary 2001-06-07 - 2001-06-21 Message-ID: This is a summary of traffic on the python-dev mailing list between June 7 and June 21 (inclusive) 2001. It is intended to inform the wider Python community of ongoing developments. To comment, just post to python-list at python.org or comp.lang.python in the usual way. Give your posting a meaningful subject line, and if it's about a PEP, include the PEP number (e.g. Subject: PEP 201 - Lockstep iteration) All python-dev members are interested in seeing ideas discussed by the community, so don't hesitate to take a stance on a PEP if you have an opinion. This is the tenth summary written by Michael Hudson. Summaries are archived at: Posting distribution (with apologies to mbm) Number of articles in summary: 192 | [|] | [|] 30 | [|] | [|] | [|] | [|] | [|] | [|] [|] 20 | [|] [|] | [|] [|] [|] | [|] [|] [|] [|] | [|] [|] [|] [|] [|] | [|] [|] [|] [|] [|] | [|] [|] [|] [|] [|] [|] [|] 10 | [|] [|] [|] [|] [|] [|] [|] [|] | [|] [|] [|] [|] [|] [|] [|] [|] | [|] [|] [|] [|] [|] [|] [|] [|] [|] | [|] [|] [|] [|] [|] [|] [|] [|] [|] | [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] | [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] [|] 0 +-019-014-001-003-014-039-026-013-009-004-001-005-023-021 Thu 07| Sat 09| Mon 11| Wed 13| Fri 15| Sun 17| Tue 19| Fri 08 Sun 10 Tue 12 Thu 14 Sat 16 Mon 18 Wed 20 Quiet fortnight. * Adding .decode() method to Unicode * Marc-Andre Lemburg asked for opinions on adding a .decode method to unicode objects: He certainly got them; the responses ranged from neutral to negative, and there was a surprising amount of hostility in the air. The problem (as ever in these matters) seems to be that Python currently uses the same type for 8-bit strings and gobs of arbitrary data. Guido came to the rescue and calmed everyone down: since when discussion has vanished again. * Adding Asian codecs to the core * Marc-Andre Lemburg announced that Tamito KAJIYAMA has decided to relicense his Japanese codecs with a BSD-style license, enabling them to be included in the core: This is clearly a good thing; the only quibble is that the encodings are by their nature rather large, so they will probably go into a separate directory in CVS (probably python/dist/encodings/) and not go into the source tarball released on python.org. * Omit printing newline after newline * As readers of comp.lang.python will have noticed, Guido posted: and retracted: PEP 259, a proposal for changing the behaviour of the print statement. * sre "improvements" * Gustavo Niemeyer asked if anyone planned to add the "(?(1)blah)" re operators to Python: but Python is not perl and there wasn't much support for making regular expressions more baffling than they already are. * Generators * In a discussion that slobbered across comp.lang.python, python-dev and the python-iterators list at sf (and belongs on the latter!) there was much talk of PEP 255, Simple Generators. Most was positive; the main dissent was from people that thought it was too hard to tell a generator from a regular function (at the source level). However Guido listened to Tim's repeated claims that this is insignificant once you've actually used generators once or twice and Pronounced "'def' it is": and noticed that there are still some issues wrt try/finally blocks. However, clever people seem to be thinking about it, so I'm sure the problem's days are numbered :-) I should also note that the gen-branch has been checked into the trunk of CVS. Woohoo! Cheers, M. From greg at cosc.canterbury.ac.nz Wed Jun 27 01:41:46 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 27 Jun 2001 17:41:46 +1200 Subject: Help: Python 2.1: "Corrupt Installation Detected" Message-ID: <3B39721A.DED4E85A@cosc.canterbury.ac.nz> I'm trying to install Python-2.1 on Windows, and I keep getting "Corrupt Installation Detected" when I run the installer. >From other postings I've seen about this message, it means that the installer itself is corrupted somehow. But everything I can think of doing to test its integrity says that it's okay. I can open the installer with WinZip and "Test" it, and it passes. I ftp'ed it to another machine which has Python installed (in binary mode) and ran md5sum.py on it, and the result matches the checksum advertised on the web page. I also tried downloading Python-2.0.1.exe, but it says "Corrupt Installation Detected" as well. Does anyone have any idea what is going on here? -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From nospam at newsranger.com Sat Jun 30 16:44:51 2001 From: nospam at newsranger.com (Levente Sandor) Date: Sat, 30 Jun 2001 20:44:51 GMT Subject: Why Not Translate Perl to C References: Message-ID: <7Tq%6.2916$Kf3.27506@www.newsranger.com> In article , Oleg Broytmann says... > Yes, but you cannot write a compiler that will translate StringIO into >cStringIO. Python is too dynamic for this. If Python will ever get static >typing, things will become much better and we can return to the task of >building a compiler. Ok, this is true. We must sacrifice some speed for flexibility. I'm ready to do that -- and this is the real answer to the question. I just wanted to show the fault in the author's way of thinking. I can't see any reason to translate Python code to C. In most cases I'm satisfied with Python's speed and I use C when I absolutely need more performance. Levi From mwh at python.net Sat Jun 16 04:54:58 2001 From: mwh at python.net (Michael Hudson) Date: 16 Jun 2001 09:54:58 +0100 Subject: ihooks or imputil? References: <233dd1ac.0106160043.5e4bd1a5@posting.google.com> Message-ID: frank at opticode.co.za (Frank Conradie) writes: > Hi there > > I've searched the archives for everything on custom importers that I > could find, and there seems to be two ways to create them: ihooks or > imputils. > > Can anybody please tell me which is the "preferred" or "official" way > to create custom importers, imputil. > and where I can find *recent* example code or documentation? Err, if you can find any old examples for imputil, I think they should still more or less work. But I'm not aware of any comprehensive docs, sorry. It may be a "use the source, Luke" moment. Cheers, M. -- All programs evolve until they can send email. -- Richard Letts Except Microsoft Exchange. -- Art -- http://home.xnet.com/~raven/Sysadmin/ASR.Quotes.html From root at rainerdeyke.com Fri Jun 15 19:20:17 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 15 Jun 2001 23:20:17 GMT Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> <9gclvm02tte@enews1.newsguy.com> <9gdspv$324$0@216.39.170.247> Message-ID: "David LeBlanc" wrote in message news:9gdspv$324$0 at 216.39.170.247... > you mistake a simple example for how something would of necessity be > done. it could just as esasily be "alias true : not none and not 0" So what would the semantics of 'a == true' be? There are two option, both wrong (and I won't even mention the infinite number of other objects that test as 'false'). >>> true = not None and not 0 >>> 5 is true 0 >>> 5 is not None and not 0 1 >>> 0 is not None and not 0 1 -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From MarkH at ActiveState.com Wed Jun 20 22:54:23 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 21 Jun 2001 02:54:23 GMT Subject: WinCERAPI extension References: <728a73c6.0106201347.63e3f3c6@posting.google.com> Message-ID: <3B3161DB.5040507@ActiveState.com> Jeremy Silver wrote: > Hi, > > I was wondering if anyone could tell me how to get or build the > "wincerapi" extension for Python 2.1. I have all of the CE SDKs on my > machine, but I can't seem to figure out a way to get the wincerapi > extension. Any help would be greatly appreciated! The source code is part of the win32 extensions. Information on getting the source code can be found at starship.python.net/crew/mhammond/cvs.html Mark. From BPettersen at NAREX.com Fri Jun 1 19:46:17 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Fri, 1 Jun 2001 17:46:17 -0600 Subject: subclassing wxMenuBar... Message-ID: <6957F6A694B49A4096F7CFD0D900042F27DB6B@admin56.narex.com> I was stepping through the wxPython tutorial, and came across the part where they're creating the menus. It seemed like a good idea to put the menu definition in a datafile instead of specifying it programatically, so I though it would be a good chance to get some xml experience too... I have the following xml: (using the '_' instead of '&' to indicate shortcuts) and the following code: from xml.dom import minidom from wxPython.wx import * def filterText(nodelist): return [ x for x in nodelist if x.nodeType != x.TEXT_NODE ] class XMLMenuBar(wxMenuBar): def __init__(self, filename): menubar = minidom.parse(filename) for menu in menubar.childNodes: menuName = menu.attributes['name'].nodeValue.replace('_', '&') wxmenu = wxMenu() for menuItem in filterText(menu.childNodes): if menuItem.tagName == 'menuitem': attrs = menuItem.attributes idTag = int( attrs['id'].nodeValue ) name = attrs['name'].nodeValue.replace('_', '&') info = attrs['info'].nodeValue wxmenu.Append(idTag, name, info) elif menuItem.tagName == 'separator': wxmenu.AppendSeparator() self.Append(wxmenu, menuName) (I'm relatively new to dom programming, so any hints about that would be well received...) however, when I instantiate this class from my wxFrame subclass, I get the following traceback from the last line above: Traceback (most recent call last): File "wXMLMenu.py", line 65, in ? app = MyApp(0) File "d:\python21\wxPython\wx.py", line 1613, in __init__ _wxStart(self.OnInit) File "wXMLMenu.py", line 60, in OnInit frame = MyFrame(NULL, -1, "Hello from wxPython") File "wXMLMenu.py", line 38, in __init__ menu = XMLMenuBar('menu.xml') File "wXMLMenu.py", line 25, in __init__ self.Append(wxmenu, menuName) File "d:\python21\wxPython\windows.py", line 807, in Append val = apply(windowsc.wxMenuBar_Append,(self,) + _args, _kwargs) TypeError: Type error in argument 1 of wxMenuBar_Append. Expected _wxMenuBar_p. which I'm assuming means that the SWIGd code is expecting a wxMenuBar pointer to be the first argument to Append and can't deal with a subclass... Does anyone know a way around this? -- bjorn From JamesL at Lugoj.Com Mon Jun 11 20:48:36 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Mon, 11 Jun 2001 17:48:36 -0700 Subject: Global in multiple files References: <3B255CAC.E373C5B7@home.net> Message-ID: <3B2566E4.41695F50@Lugoj.Com> Chris Barker wrote: ... > Artur Skura wrote: ... > > (BTW I would like to thank other people for pointing out the > > possibility of having global.py module etc. ... > In fact, it may make sense to put accessor functions in your globals > module, like: > > globals.getUserList() ... Warning! Do not name such a module "globals.py" because "globals" is already a function in the global namespace. That is why I suggested "globalVars.py". The singular, "global" shouldn't collide with any existing names, but may be prone to confusion with the plural. You could always emulate Fortran and call it "common.py".... Just a word to the wise. From BigLar at LEONARDO.localhost Thu Jun 7 09:39:32 2001 From: BigLar at LEONARDO.localhost (Larry Ebbitt) Date: 7 Jun 2001 13:39:32 GMT Subject: GROUP TAKEOVER IN PROGRESS References: <3A29743F.CAA91142@my-Deja.com> <92dtj6$5dh$1@bob.news.rcn.net> <69cl4tk6bitr0oi376ngtjp0m1bs7ucnk4@4ax.com> <902430AC4moondustapexnet@209.99.56.9> <93hn81$l4m$1@nnrp1.deja.com> <9025628F7moondustapexnet@209.99.56.9> <3a5c8520_1@news.foxinternet.com> <902581E21moondustapexnet@209.99.56.9> <3a5ce21b_1@news.foxinternet.com> <4A982771F09.psskvxvn@vluxxijwai.net> <9fn1ac$9d3$2@216.39.170.247> Message-ID: On 7 Jun 2001 04:52:28 GMT, David LeBlanc wrote: > Don' you just hate it when they don't get their lithium? ROFL! -- Larry Ebbitt - Linux + OS/2 - Atlanta From ryanmorillo at hotmail.com Thu Jun 14 08:05:51 2001 From: ryanmorillo at hotmail.com (Ryan) Date: 14 Jun 2001 05:05:51 -0700 Subject: Pure Python mini-DB and NCurses References: <4a7fde99.0106140057.1e2fb285@posting.google.com> Message-ID: <4a7fde99.0106140405.61c0cc9f@posting.google.com> do you meen like the jed or joe (wierd linux editors) split screen? or an actual windows type popup windows type thing? sill at optonline.net (Rainy) wrote in message news:... > On 14 Jun 2001 01:57:03 -0700, Ryan wrote: > > I have been trying to figure out how to make a small database with the > > shelve module, but either the interface to update it is beyond me or > > I'm just not grocking some small attribute. I realize that a real DB > > would be more functional in most cases, but I just want to make a > > small contacts list program that I can run on the workstation and on a > > handheld, so I'm trying to make it so the db file can be imported from > > one to the other and updated. > > > > As for the ncurses I'm just trying to figure out why it would be used. > > If anyone has a reason other than novilty I would appreciate it as I > > can't understand what Guido was thinking when he put it in. > > I'm not sure I got your question right, but ncurses are useful for all kinds > of console applications where you need windows, such as irc clients, news > clients, mail clients, text editors and so on. From db3l at fitlinxx.com Mon Jun 18 22:49:11 2001 From: db3l at fitlinxx.com (David Bolen) Date: 18 Jun 2001 22:49:11 -0400 Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? References: <3B2B60AD.942719AE@earthlink.net> <9gkio3$9jcft$5@ID-89274.news.dfncis.de> <3B2D3975.31BF1984@earthlink.net> Message-ID: Ron Stephens writes: > Is there an extensive tutorial or good documentation of wxPython on the web > that one can learn from? The wxPython tutorial on the wxPython web site is > quite short and is insufficient for a klutz like me. (...) Others have pointed to the new Wiki work, but I just wanted to also highlight strongly the demo that comes with it. While it doesn't necessarily give you a top level tutorial, it's terrific for just interacting with the demo until you see an example of what you want and then looking at the source of that demo to see how it was accomplished. The demo also exercises a very large fraction of the components of wxPython, so it's a good show-n-tell to see how things might look. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From cfelling at iae.nl Mon Jun 18 15:55:57 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 18 Jun 2001 21:55:57 +0200 Subject: why is there no class (static) methods in Python ? References: <3B2D114E.7B39D954@intraware.com> <9gkg2i0278e@enews2.newsguy.com> Message-ID: <9glmcd$5qi$1@animus.fel.iae.nl> Alex Martelli wrote: > "Richard Gruet" wrote in message > news:3B2D114E.7B39D954 at intraware.com... ... >> class C: >> def staticFoo(x): print x >> >> C.staticFoo(1) > http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/52304 according to the faq there is an even shorter spelling of this idiom: class Callable: def __init__(self, callable): self.__call__ = callable this works as the magic method transformation only applies to class-functions, not to instance-functions. To me this spelling of the idiom is a tad more readable, besides it being more efficient as it saves one method call. Alex, would you prefer me to add a comment to your recipe entry, or would you rather change the recipe? -- groetjes, carel From ullrich at math.okstate.edu Wed Jun 6 11:19:36 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Wed, 06 Jun 2001 15:19:36 GMT Subject: random References: <3b1cf00f.5441109@nntp.sprynet.com> Message-ID: <3b1e4957.3040319@nntp.sprynet.com> On Tue, 05 Jun 2001 20:42:47 GMT, wtanksle at dolphin.openprojects.net (William Tanksley) wrote: >On Tue, 05 Jun 2001 15:09:25 GMT, David C. Ullrich wrote: >>But this question is not meant to be rhetorical: We have a syntax where >>the valid programs are exactly finite sequences of 0's terminated by a 1. >>Does this count as "self-delimiting"? > >Yes, but I don't think it counts as a UTM program. There are only >countably many possible programs for this machine, while a UTM can run >uncountably many. Um. Some of these "programs" have infinite length, then? If they all have finite length then there's only countably many - that's even if the length is unbounded. If a UTM actually runs programs of infinite length then fine, but I can't imagine what it means to run such a program. >>David C. Ullrich > >-- >-William "Billy" Tanksley David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From johnroth at ameritech.net Tue Jun 26 11:08:57 2001 From: johnroth at ameritech.net (John Roth) Date: Tue, 26 Jun 2001 08:08:57 -0700 Subject: Should I use a dictionary? References: Message-ID: "Remco Gerlich" wrote in message news:slrn9jgd4o.n2o.scarblac at pino.selwerd.nl... > Gustaf Liljegren wrote in comp.lang.python: > > I have an object type for e-mail messages based on the rfc822 module. After > > picking out some messages from several sources, I want to sort them in > > order of the date property of the message object (as far as I understand, > > everything in this process needs to be kept in memory). Anyway, the problem > > is that I need some hints about how to sort the messages, as they are not > > sorted in way I get them. > > > > One idea I came up with was to put the date property of the message object > > as a key in a dictionary, and let the rest of the message be the value! But > > even if it would work, I think it's ugly. If someone can convince me that > > it's not ugly, or give a better (i.e. faster) solution, I'd be happy. > > Although dictionaries are neat, I don't see how they would work here - you > can't sort a dictionary, and two messages may have the same date. You extract the keys into a list, sort them, and then use the sorted keys to reference the dictionary. As far as duplicates go, I find that using the sequence in which I added stuff is adequate - and it eliminates any questions about whether the sort is stable. It's very easy in Python - rather than keeping a counter, you can use len(dictionary) to get a usable number. John Roth > > Often, if you want to sort things on some field, you want the "decorate, > sort, undecorate" pattern (aka Schwartzian transform). In this case, if you > have a list of messages, you want to change it into a list of (date, > message) tuples, sort that, then change it back into a list of messages. As a previous poster said, using that could be quite expensive - it has to look at the actual message bodies to determine the order. > Something like > > messages = [...] > decorated = [ (get_date_in_seconds(message), message) for message in messages] > decorated.sort() > messages = [ part[1] for part in decorated ] > > -- > Remco Gerlich From liwen at eefind.com Mon Jun 25 01:34:36 2001 From: liwen at eefind.com (Iwan Cao) Date: Mon, 25 Jun 2001 13:34:36 +0800 Subject: CXX extension question. Message-ID: <9h6j9i$bi2$1@sunlight.pku.edu.cn> Greetings, I'm building a Python extension module using CXX. Everything looks just fine. This is my setup.py for my module PyHtmlText: import os, sys from distutils.core import setup, Extension support_dir = os.path.join(sys.prefix, "etc", "CXX") htmltext_dir= ".." platform= 'UNKNOWN' if sys.platform[:5]== 'win32': platform= 'WIN32' if sys.platform[:5]== 'linux': platform= 'LINUX' setup (name = "PyHtmlText", version = "0.1", maintainer = "Lilly Bai", maintainer_email = "baili at cn.ibm.com", description = "A wrapper for HTML page analyzer", url = "http://www.ibm.com.cn", packages = ['PyHtmlText'], package_dir = {'PyHtmlText': '.'}, ext_modules = [ Extension('PyHtmlText.pyhtmltext', define_macros= [(platform, None), ('HTMLANALYZER_DLL_API', '')], include_dirs= [(htmltext_dir)], sources = ['pyhtmltext.cpp', os.path.join(htmltext_dir, 'TextBlock.cpp'), os.path.join(htmltext_dir, 'HtmlAnalyzer.cpp'), os.path.join(htmltext_dir, 'HtmlExtractor.cpp'), os.path.join(htmltext_dir, 'PageData.cpp'), os.path.join(support_dir,'cxxsupport.cxx'), os.path.join(support_dir,'cxx_extensions.cxx'), os.path.join(support_dir,'cxxextensions.c'), ], ) ] ) I build the module on Linux and Windows2000, and it works on Windows2000. However, when I import the module on Linux, python report: ImportError: ./pyhtmltext.so: undefined symbol: what__C13runtime_error I guess it may because there is a statement in my code: try{ ... } catch(HtmlPageError &err){ std::cerr<< "HtmlAnalyzer Exception: "<< a_sFileName<< "\t"<< err.what()<< std::endl; throw RuntimeError(err.what()); } But when I comment out that code, there is still error. Any hint on that? Thanks in advance! BR Iwan From piet at cs.uu.nl Thu Jun 7 09:59:14 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 07 Jun 2001 15:59:14 +0200 Subject: Numeric Programming for Everybody References: Message-ID: >>>>> Don Dwiggins (DD) writes: DD> Here's a strawman proposal: the "default" number system for the language DD> will be like that of Unix "bc": fixed point (the user must declare how many DD> fractional places), no limit on size. Yes, of course it's inefficient, but DD> it's a good fit to the beginner's mental model. The introductory DD> documentation will describe this system, and mention the others available, DD> and why one might want to use them. That can't work as it uses a global variable (the number of fractional digits) and that gives problems with imported modules. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From Sir-XaoS at gmx.net Wed Jun 27 10:33:36 2001 From: Sir-XaoS at gmx.net (C. Koehler) Date: Wed, 27 Jun 2001 16:33:36 +0200 Subject: access to subfolders References: <3B39D4EA.A000782F@gmx.net> <3B39D560.77782F9A@gmx.net> Message-ID: <3B39EEC0.CC78F1BA@gmx.net> got the solution frrom zope mailing list... Try: getattr(container,id).manage_addProduct['OFSP'].manage_addFile(id+'.pdf',context.REQUEST['pdf']) From mac4-devnull at theory.org Tue Jun 5 12:40:56 2001 From: mac4-devnull at theory.org (Neil Macneale) Date: Tue, 05 Jun 2001 09:40:56 -0700 Subject: makepasswd References: <3B1B838B.BC9FD4CC@oek.dk> Message-ID: <3b1d0a27$0$331$8eec23a@newsreader.tycho.net> In article , "Edward S. Vinyard" wrote: >if 'executable' in dir(sys): > from whrandom import random > lowercase, uppercase, digits, punctuation >else: > import java.lang.Math > random = java.lang.Math.random # in [0.0, 1.0) > lowercase = "abcdefghijklmnopqrstuvwxyz" > uppercase = "ABCDEFGHIJKLMNOPQSTUVWXYZ" > digits = "0123456789" > punctuation = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~' Why no upper case R? Neil Macneale -- To reply to me via email, remove the '-devnull' from my address. From sholden at holdenweb.com Mon Jun 25 12:06:48 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 25 Jun 2001 12:06:48 -0400 Subject: DCOracle: platforms? Message-ID: <2hJZ6.16808$g4.471561@e420r-atl2.usenetserver.com> Cam anyone tell me if they have the DCOracle module working on Windows? The distribution's web page claims all platforms, but I don't see any Windows installation instructions, and haven't done enough C development in that environment to be confident of tackling this without assistance. regards STeve -- http://www.holdenweb.com/ From timr at probo.com Wed Jun 27 02:30:35 2001 From: timr at probo.com (Tim Roberts) Date: Tue, 26 Jun 2001 23:30:35 -0700 Subject: Is this a mimetools/rfc822 bug? References: <15159.41247.812177.613322@anthem.wooz.org> Message-ID: <00vijtcovmpqdvu0frqgijvob53m4gohsv@4ax.com> Sheila King wrote: > >But, according to the RFC's a header is required. A message body is not >required. > >According to RFCs I recall: Your message header must have at least one >of the following headers: To, Bcc, or CC. I believe that is the minimal >header: any one of the To-type fields. No other headers are required, >and no message body is required. Interesting. I was just about to disagree with you, but I decided to go back and read the RFC to make sure. I was wrong. Strict RFC822 compliance requires a "Date:" header, a "From:" header, and at least one recipient header. I find this interesting because sendmail, which I think of as the ultimate authority on RFC822, is perfectly willing to accept a message with no headers at all. I'm glad I looked before I shot my mouth off. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From pehr at alum.mit.edu Thu Jun 28 01:19:08 2001 From: pehr at alum.mit.edu (pehr anderson) Date: Thu, 28 Jun 2001 05:19:08 GMT Subject: curses webbrowser modules References: <3B32C29A.67E099F5@yahoo.com> Message-ID: <3B3ABE52.6AB12DE1@alum.mit.edu> Dear Alex, Here is a brute-force idea: Spawn or fork a new process which runs a small hunk of python code to execute your browser.open call in an output-redirected process environment. If you need to have back-and-forth rather than launch and forget, simply split your app into a client-server model at some protocol layer that makes sense for your application. Is there a more elegant way? You might be able to see something obvious by looking through the browser.open code. Perhaps you could make your own "inherited" version of the class that adds this key feature where you need it and leaves the rest of the class in-tact. -pehr Alex M wrote: > > Somewhere within my curses app I have this bit of code: > > session.myprofile.browser.open(session.url, 1) > > The above line of code works great but Netscape ruins my windows > when it decides to output some error message. eg error messages > with regards to fonts. Rewriting/refreshing the damaged windows doesn't > help. > I have worked around this problem by > modifying my .Xdefaults file, adding the following lines to it: > > .netscape*useStderrDialog:False > .netscape*useStdoutDialog:False > > But is there any other way of suppressing browser error messages so it > doesn't ruin my curses windows? > > Thanks. > > Alex Mercader > the_cpu_fan at yahoo.com From emile at fenx.com Wed Jun 27 17:33:11 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 27 Jun 2001 14:33:11 -0700 Subject: list of dictionaries References: <3B3A4B97.5F4EB1F1@cc.gatech.edu> Message-ID: <9hdjmt$dk0ki$1@ID-11957.news.dfncis.de> Note changes below -- Emile van Sebille emile at fenx.com --------- "George Thomas" wrote in message news:3B3A4B97.5F4EB1F1 at cc.gatech.edu... > Hi everyone, > As part of a project, I've ended up deciding to use a list of > dictionaries. However, I don't seem to be getting the "expected" results > of the append() operation on the list object. Here's some sample code to > illustrate the problem. > > import string > > dict_entry = { > 'a':'', > 'b':'', > 'c':'', > 'd':'' > } #This creates a single dict that gets appended each time #by creating a new dict for each entry as per below #you don't really need this anymore. > > a1 = "apples" > a2 = "oranges" > b1 = "bananas" > b2 = "peaches" > c1 = "coconuts" > c2 = "pears" > d1 = "dalmatians" > d2 = "pecans" > dict_entry = {} # create a new dict > sample_list = [] > dict_entry['a'] = a1 > dict_entry['b'] = b1 > dict_entry['c'] = c1 > dict_entry['d'] = d1 > sample_list.append(dict_entry) > dict_entry = {} # create a new dict > dict_entry['a'] = a2 > dict_entry['b'] = b2 > dict_entry['c'] = c2 > dict_entry['d'] = d2 > sample_list.append(dict_entry) > > It's something subtle or I'm making a stupid mistake somewhere. Either > ways, can someone see what's going on ? > ------------------------------------------------------------ > George Thomas > ------------------------------------------------------------ From koss at objectmentor.com Wed Jun 20 18:42:59 2001 From: koss at objectmentor.com (Bob Koss) Date: 20 Jun 2001 18:42:59 -0400 Subject: where to install on Red Hat 6.2 ? Message-ID: When I installed Python 2.1 last time, the tool 'netcfg' quit working due to Python conflicts. I had to diddle with paths whenever I wanted to use netcfg. I'm about to do another installation. Where should I install to keep everything that uses Python working? -- Robert Koss, Ph.D. | Training, Mentoring, Contract Development Senior Consultant | Object Oriented Design, C++, Java www.objectmentor.com | Extreme Programming -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From threeseas at earthlink.net Sun Jun 17 16:23:03 2001 From: threeseas at earthlink.net (Timothy Rue) Date: Sun, 17 Jun 2001 20:23:03 GMT Subject: Python version of IQ has been updates (IQ v0.34.python) References: <505.566T11T1243597threeseas@earthlink.net> <3B2A7F5E.MD-1.4.4.padf@ihug.com.nz> <3871.567T2214T9794928threeseas@earthlink.net> <87puc3ao42.fsf@pooh.honeypot> Message-ID: <2509.568T2823T9766233threeseas@earthlink.net> On 16-Jun-01 20:31:25 Kirk Strauser wrote: >At 2001-06-16T22:02:55Z, "Timothy Rue" writes: >> There was a recent article on slash dot about Python becomming GPL >> compatiable. It's open source and has a rich pattern matching module >> amoung many other note worthy things about it. >Tim, >Have you ever looked into Perl? We use it almost exclusively for >integrating large distributed systems, and its regular expression system is >second-to-none in my experience. Python's a good language (from what I hear >- I keep meaning to look into it), but Perl has a lot going for it also. It >isn't GPL (it's distributed under the Artistic License), but even RMS agrees >that it is Free in every sense of the word. >-- >Kirk Strauser Kirk, No I haven't looked into Perl. The RE pattern matching functions in Python are more than enough, more than I expected. Hey I can use white spaces in patterns now!!!. I forget what caused me to finally look into Python, maybe that third guy who was in the original MS team so many years ago and something he more recently said about python and the GPL or open source. But there were other things that in sum finally got me to look into Python. Alex Martelli said a few things regarding the RE pattern matching between Python and Perl and some other comparisons. Is Perl syntax as easy to read as python, for the beginner? Can perl be compiled into byte code for faster startup or put into a stand alone application? Or is Perl strickly an interpreted language? Ultimately things like compiled into bytecode or compiled into a exe are all a matter of translators, as is an interpreter or compiler or some translation stage in this process of ultimate conversion into machine understamndable language. So I guess the question is whether or not such translators are available to perl? Of course you can port IQ to Perl if you want, but in any case (perl, python, rebol, arexx) it'd be nice to incorporate into IQ, the ability to access files thru the internet in a way that is as simple as accessing a file on the system you are using IQ on. --- *3 S.E.A.S - Virtual Interaction Configuration (VIC) - VISION OF VISIONS!* *~ ~ ~ Advancing How we Perceive and Use the Tool of Computers!* Timothy Rue What's *DONE* in all we do? *AI PK OI IP OP SF IQ ID KE* Email @ mailto:timrue at mindspring.com >INPUT->(Processing)->OUTPUT>v Web @ http://www.mindspring.com/~timrue/ ^<--------<----9----<--------< From James_Althoff at i2.com Tue Jun 19 14:36:10 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Tue, 19 Jun 2001 11:36:10 -0700 Subject: why is there no class (static) methods in Python ? Message-ID: Thomas Heller wrote: > wrote in message >> My own metaclass experiments and posts have all tried to provide a >> mechanism for true class methods. But all metaclass mechanisms in Python >> that I'm familiar with are awkward, IMHO -- and probably don't and won't >> get used much (if at all). >I'm really satisfied with the following recipe (you will probably >remember): > >class ClassMeta: > class Instance: > def __init__(self, ...): > # initialize the new instance > .... > > def inst_method(self): > # an instance method > > def new(self, *args): > # a class method acting as a constructor > return self.Instance(arg1, arg2): > > def a_class_method(self, ...): > # another class method > .... > > >Class = ClassMeta() > >It is easy to understand and simulates 'real' class methods very well. >I will certainly use them. > >What's wrong with this pattern? I agree that the pattern above does a good job of "simulating 'real' class methods". The (slight) awkwardness here (for me) is that you have to keep in mind that "Class" refers to the metaclass instance and not to the "class of interest" ClassMeta.Instance. If you only had to deal with ClassMeta.Instance inside of the class methods (using self.Instance) there wouldn't be much of an issue. But if you want to subclass ClassMeta.Instance then you need a direct reference to it (the actual class) for use in the class statement and in all methods that require a call to a superclass method. So in the general case you probably want to expose ClassMeta.Instance via something like: "MyClass = Class.Instance" or "MyClass = ClassMeta.Instance" so you can say class MySubClass(MyClass)" instead of "class MySubClass(Class.Instance)" or "class MySubClass(MetaClass.Instance)" and "MyClass.instanceMethod(self)" instead of "Class.Instance.instanceMethod(self)" or "ClassMeta.Instance.instanceMethod(self)" Summarizing, the extra things you do in the above: o use an outer class for the metaclass definition o use an inner class for the actual class definition o manually create a singleton instance of the metaclass o expose the inner class via an assignment (I would think) o keep three names and objects in mind: * ClassMeta -- you need to know this to subclass the metaclass itself * Class -- you call class methods on this metaclass instance * MyClass -- you want this when subclassing and calling superclass methods That's not so bad all things considered. But it's enough extra stuff that it might prevent many/most from using it as the standard idiom for creating classes. I would like to see a standard idiom that you could use whenever you create *any* class so that you can start with no class methods and then later add one (or more) in easily without having to change the basic mechanism you used for creating the class to begin with. Despite these concerns, I agree that the pattern above is a good one. :-) Jim From qrczak at knm.org.pl Wed Jun 27 03:25:00 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 27 Jun 2001 07:25:00 GMT Subject: Newbie seeks help on case preserving substitutions References: <3B3767BB.A882F8@divalsim.it> <3B383B3A.F63FBA56@divalsim.it> Message-ID: Tue, 26 Jun 2001 09:35:22 +0200, Nicola Musatti pisze: > My strings have two parts: an initial two letter code and a > subsequent name. Those strings that are neither all uppercase > nor all lowercase always have an uppercase code and a capitalized > (i.e. first letter upper, all others lowercase) name. So there are only three case forms. You can perform three passes over each line, each pass being a case-sensitive replacement of constant strings prepared before the loop. This can be done without regexps, using .replace(old,new) method of strings (or string.replace(s,old,new) in Python < 2.0). Hej! -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From uioziaremwpl at spammotel.com Fri Jun 29 18:18:49 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Sat, 30 Jun 2001 00:18:49 +0200 (CEST) Subject: Augmented Assignement (was: Re: PEP scepticism) In-Reply-To: Message-ID: On 29 Jun 2001, David Bolen wrote: > Carsten Geckeler writes: > > > The problem which some people have with augmented assignment is not that > > they exist, but that they do not work as they expect (at least from the > > POV of some readers). I expect that > > ident op= expr > > works like > > ident = ident op expr > > > > At least that's what I'd have expectd comming from other programming > > languages. > > Of course, one interesting point is that while you may think the above > if coming from, say, C, what "ident = ident op expr" means in C is not > what "ident = ident op expr" means in Python. Yes, that's completely true. I can accept, that Python work differently in many cases. Actually I love Python's object stuff. That's something more natural that in many other languages. And I can accept, that objects (which are bound to different variable names) can be changed (like with l.extend). The point is not that Python differs from C (or other languages), but that the two statements above work differently. I can accept that, of course (well I have to, I thing ;) ). But, when I write the following three statements, l = l + [3, 4] l += [3, 4] l.extend([3,4]) it seems more logical to me, that the first two do the same than the last two. I know, of course, that the last two do the same. But anyway, the first two just _look_ more the same. > In C it has the result of changing data (in either case) that is > stored in a named location ident, in Python the long form just rebinds > the reference ident to a new object and doesn't touch the original > object. The short form can actually get closer to the C idiom if the > object is mutable. > > So I wonder if some of the confusion is people familiar with other > language's augmented assignment trying to extrapolate that into Python > and then running into the pre-existing differences in assignment > versus binding? No, that's at least no problem for me (see above). Cheers, Carsten -- Carsten Geckeler From jcollins at boulder.net Wed Jun 20 20:52:00 2001 From: jcollins at boulder.net (Jeffery D. Collins) Date: Wed, 20 Jun 2001 18:52:00 -0600 Subject: using os.system and ps2pdf In-Reply-To: ; from iddwb@imap1.asu.edu on Thu, Jun 21, 2001 at 12:19:49AM +0000 References: Message-ID: <20010620185200.F11141@boulder.net> On Thu, Jun 21, 2001 at 12:19:49AM +0000, iddwb wrote: > Problem. I need to read stdin, and convert it to pdf. Luckily, stdin > will give me postscript. So, I thought I simple script would work. > Invoking the ps2pdf program manually works fine to create the > pdf. Unfortunately, the following code doesn't allow ps2pdf to do its > work fully, It creates an empty pdf. Is there a better way to call an > external program than os.system? Alternatively, could reading stdin be > dropping something? > > any advice would be appreciated. > > > #!/usr/local/bin/python > > import os, sys, tempfile > > if __name__ == '__main__': > psf = tempfile.mktemp("psf") > pdf = tempfile.mktemp("pdf") > ps = open(psf, "w") > ps.write(sys.stdin.read()) > ps.close ps.close() > print "ps2pdf %s %s" % (psf, pdf) > os.system("ps2pdf %s %s" % (psf, pdf)) > > David Bear > College of Public Programs/ASU -- Jeffery Collins (http://www.boulder.net/~jcollins) From aleaxit at yahoo.com Fri Jun 15 08:08:18 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 15 Jun 2001 14:08:18 +0200 Subject: SMNP Interface(s)? References: Message-ID: <9gcts406ic@enews1.newsguy.com> "Benjamin Schollnick" wrote in message news:junkster-C7253B.20553314062001 at typhoon1-3.nyroc.rr.com... > > I just checked over at the Vaults & couldn't find any, does anyone know > of any SMNP modules for python? And of course, where to find them? Do you mean SNMP, as in http://sourceforge.net/projects/snmpy/, or is this some new 4-letter acronym I've not yet heard of...? Alex From claird at starbase.neosoft.com Mon Jun 18 17:12:49 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 18 Jun 2001 16:12:49 -0500 Subject: Two more questions, and a comment: Cross-Platform... References: <3B2B60AD.942719AE@earthlink.net> <3B2BF029.14AAF29E@earthlink.net> <170620012336202508%sburr@nospammac.com> Message-ID: In article <170620012336202508%sburr at nospammac.com>, Steven Burr wrote: >In article <3B2BF029.14AAF29E at earthlink.net>, Ron Stephens > wrote: > >> 1. Is Tkinter likely to be ported over to MacOS X soon? > >In a sense, it already has been. XFree86 has been ported to Darwin in >a form that runs side-by-side with Aqua. (You can switch to X Windows >by clicking a button and back to Aqua by typing cmd-opt-A.) Tcl/tk is >also available for Darwin. With XFree86, tcl/tk and the Darwin version >of Python, I've been able to run Python/Tkinter apps in X Windows on my >Mac. > >On the other hand, based on what I've read in the Mac-Python SIG and >elsewhere, nobody seems to be working on a port of tcl/tk to Carbon or >Cocoa. The Mac-Python SIG gives false impressions. Here's what Apple employee and recognized Tk expert Jim Ingham just told me: I am still working slowly on a Carbon port of Tk. I should be able to have something stable enough that others can hack on it in a month or two. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From gerhard.nospam at bigfoot.de Thu Jun 21 23:10:52 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Fri, 22 Jun 2001 05:10:52 +0200 Subject: [OT] MS EULA -- (will ActiveState become outlaws? ;-) References: Message-ID: On Thu, 21 Jun 2001 21:50:23 -0400 (EDT), Steven D. Majewski wrote: > > >Is this the next stage of Microsoft's war against Open Source ? > >Discussion of this on SlashDot : > >( Right before the article on the Monty Python Action Figures! ) > >If this spreads to all of Microsoft's EULA's, will this make >ActiveState illegal ? They don't specifically mention Python's >license, but they do mention Perl's ( and the "similar to any >of the following" clause would seem to include Python's. ) > >Does anyone know if this should be taken seriously ? Of course not. It was posted on Slashdot. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://highqualdev.com public key at homepage public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From dougfort at downright.com Sun Jun 10 07:58:27 2001 From: dougfort at downright.com (Doug Fort) Date: 10 Jun 2001 12:58:27 +0100 Subject: allow_reuse_address! duh! Message-ID: <3b2360e3$1_2@news5.uncensored-news.com> My coworkers have been complaining about a particuraly annoying feature of our agent infrastructure (http://pyagent.sourceforge.net): when you stop an agent, you have to wait for something like two minutes to restart, because the socket is busy. While poking around for something else, I stumbled over the allow_reuse_address class variable in SocketServer. Y'all may have known about this for years, but it's news to me. All you have to do is set it before initializing the TCPServer base class. SocketServer.TCPServer.allow_reuse_address = 1 SocketServer.TCPServer.__init__(self, host, RequestHandler) -- Doug Fort Senior Meat Manager Downright Software LLC http://www.downright.com ______________________________________________________________________ Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com With Seven Servers In California And Texas - The Worlds Uncensored News Source From m.faassen at vet.uu.nl Sat Jun 2 21:09:20 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 3 Jun 2001 01:09:20 GMT Subject: Why isn't Python king of the hill? References: Message-ID: <9fc2o0$52g$1@newshost.accu.uu.nl> Geoffrey Gerrietts wrote: >> Ah, a powerful query system, then. Difficult, too. Could you give >> a real life example of an actual arbitrary retrieval system? It's >> not full-text-search search, right? (the ZCatalog I believe already >> can do something like that, on multiple attributes). > Arbitrary and full-text are more or less identical. I can't speak > competently about ZCatalog. If it's got it, that's great -- but > I'm not sure what it is exactly, or how effective or efficient it > is to use that on a collection of large text. :) I'm not entirely sure if it can do full-text on all attributes at once (though that's relatively easy to fix, though the order of the result set may make not much sense), but it can do full-text on a single attribute. I haven't got much experience with it either, so I can't tell you much more. :) >> > I can't speak to how easy it is to move from one app server to >> > another. I /can/ speak for how much of the "hard work" is done >> > for you by some of these enterprise containers -- a whole lot! >> >> Could you go into some more detail on this? I've heard this >> more often, >> but I'm still not entirely clear on *what* work is done. :) > I think the meat of the response lies in answering this question. Good, as it's my main question. :) > I'm going to try to answer it first in regards to JSP and > servlets, and I'm going to mix in some of the J2EE stuff near the > end. I'm nowhere near as proficient with J2EE as I am with the > other two. Just a random note; I heard that WebWare for Python looks quite a bit like "that Java stuff", at least in inspiration, so it may be interesting for you to take a look at it. > Meanwhile, others will I'm sure jump in and correct me where I'm > wrong. Or I /hope/ they will, because I'm sure to be wrong. :) > First, one framing quote: >> I'm not interested in promoting a standard, I'm just interested in >> stealing ideas for Python-based APIs. I'm not interested in >> standardizing these APIs. :) > That frames my first issue. > I think that's a big part of what's great about these API's. > They're standard! [standardization can be good and helps you find people] Agreed; makes sense. It's just that I personally am more interested in the other stuff, not that fact that it's standard. I can't do much to make something a standard anyway, so I'll just look at stealing the ideas. The better the Python stuff gets, the more likely it is there are more people that know about it, too, of course. > ----- > REQUEST-CENTERED FRAMEWORK > ----- > When I'm developing under Zope, I start with a page and work > back from that. It's possible to determine from the request which > bit of content to serve up -- you either make a conditional page, > or you stick a bit of code at the top of the page that does > redirection based on the contents of the request object. Or you can do evil and cool stuff with AccessRules (the whole SiteRoot stuff). [snip] > I don't want a page-centered application; in fact, I would go so > far as to say that page centering breaks the MVC (model / view / > controller) paradigm that I aspire toward in my software designs. > The way Zope is set up, it seems to me that it encourages a > design that embeds controller elements in the view. What exactly do you mean by embedding controller elements in the view? I'm not entirely sure what you'd refer to as the controller here. [snip] > When you add servlets to the mix, though, you start eking your > way into deeper potential. Instead of requests being aimed at > your view components, requests are aimed at a servlet. The > servlet is invoked via routines that are designed to handle a > request. The objects associated with the request are a little > more "primitive" than the objects you pull out of Zope, but they > are handled in a fairly elegant fashion. > Having the servlet in charge of processing the request puts the > control into the controller, if you will. It makes it easy for > the app to center around the controller logic, without relying on > the view logic to hand over the reins. Hm, yes, I think this makes sense (though it could lead to horrible URLs). Of course you don't give the details here so I'm not entirely sure I get the entire picture right. [Model/View/Controller as JSP/Servlets/Beans] > ----- > JSP FEATURES > ----- > Like I said, JSP is much like DTML or PHP in appearance. JSP has > a few "directives" that you can use to apply general processing > rules to your page. Of particular interest: [JSP pages get compiled, not interpreted] We're not going to accomplish this in Python, though of course you could still write (possibly with C extensions) a fast interpreter for web pages in Python. Anyway, we're generally not using Python because insane speeds are the issue, so while this isn't a major bottleneck for me I'm not going to bother too much with this. > Your JSP pages have access to at least four levels of state > (there might be another I'm forgetting): application, session, > request, and page. The first three correspond to the same state > repositories managed by the servlet. The 'page' context is for > local objects. Right, in Zope you'd have 'acquired things', session object (if you have Core Session Tracking or something similar installed), REQUEST object and folder context, for these. I'm just trying to translate the concepts. > You can forward control to other servlets or JSP pages, and you > can also include pages. What do you mean by 'forwarding control'? Control of what? > I believe (though I'm not sure I've > tested this) that a page you forward to gets a fresh "page" > context, while an include uses the current page context. Also, > forward is terminal, while an include will return control after > processing the child. Not too revolutionary here, but the > features are present. Ah, I think I more or less understand. I'm not sure what the use of forward is compared to include, though. Why'd you ever want to forward control and never come back? Generate half a page with one JSP page, and the other with another? > You can embed Java. In fact, that's the way you do your > conditional display, and almost everything else interesting. This > can look kinda goofy in practice, but it does increase ease of > use. > You can associate a bean with an object, and map form properties > onto the bean's attributes. I think that this is most useful when > you're programming pure JSP, but it's pretty useful when you're > not. Right, Zope's REQUEST object does this automatically (the 'form' subobject). > You can create "custom tag libraries" for a more abstract and > less "page-centered" approach to reusable page content. Custom > tag libraries are more Java-centric than markup-centric. > ----- > SERVLET FEATURES > ----- > Most of what you get out of servlets is also available indirectly > in JSP if you jump through the right hoops. For pieces of the > application that don't need to display, though, there's not much > sense in hopping through the hoops -- it can be downright > annoying to need to. That's what makes servlets "natural" for the > controller component. Right, in Zope, you'd use Python Scripts (through the web), External Methods (not through the web) for this. You may want to bundle them into objects, and use ZClasses or program Python Zope products. A little bit of Python tends to go a long way, of course, and it helps to have high-level reusable components like ZSQL methods. > I've discussed session management before. Sounds like they're > doing some of that in newer Zope? That's good. It's a very hard > thing to do well. I would be concerned about ZEO and ZODB being > used in their unadulterated form to handle session management for > a high traffic site. It just seems like there'd be too much I/O > for ZODB/ZEO to handle it efficiently. They're working on various improvements to that too, of course. ZODB without undo for sessions for instance. ZODB layered on top of various stuff, like the berkely database. By default Core Session Tracking just keeps the sessions in RAM and they expire after a customizable time. > Servlet containers implement session management for you. The > servlet containers are presently not obliged to make these > sessions either persistent or distributable, but some of them do, > including at least one of the freely-available containers. > Persistent, distributable sessions provide good load balancing > and good failover. Right, the intention in Zope is to do this with ZEO and Core Session Tracking. > Servlets get a request and a response object passed to them. Like Zope's DTML pages, and of course you can pass those along to Python Scripts or other python code. > Generally you manipulate both. The request object has a list of > parameters and also a list of attributes. The former are > generally the form values while the latter is where you might > store state to pass it between servlets or between a servlet and > a JSP page. Something similar is done with REQUEST. REQUEST.set() can be used to store state for similar purposes. You can of course also directly call methods and pass parameters that way. ZPublisher makes some of that stuff work automatically. > Servlets can dispatch a request using either a forward or an > include, just like in JSP. > The container's handling of a servlet (or entire web app, which > is generally a bunch of servlets and lots of supporting pages) is > controlled by the "deployment descriptor", a file called web.xml. > This file has a standard, mandated format. It gives the developer > a great deal of control over how his or her servlet will be > instantiated, and how it will be managed once in memory. > Once written, a web application can be packed up into a .war file > (analogous to a .jar file) for easy deployment. The first time > the app is accessed, the .war file is unpacked. That makes > deployment remarkably (almost disgustingly) simple. Neat. With Zope exporting subfolders or simply copying Data.fs is relatively painless, but you need to copy over any external methods and special Python products manually, which isn't hard but an extra step. > ----- > ENTERPRISE JAVA BEANS > ----- [discussion of what 'enterprise' could mean] Enterprise is a typical buzzword. :) 'scalable' is a much better word to use if you want it to use in large evironments, and 'portable' works fine for diverse environments, I'd say. :) 'Has a lot of features for business use' fits the rest of the buzzword, I guess. > Adding EJB entails a few sacrifices and a few big gains. Sticking > your servlets into the J2EE "framework" means that you hafta put > your "application" level state into an EJB or a database (or at > least knowing that anything you stick into the application > storage can't be counted on to persist any longer than the > request). You really need to make anything you put into the > session area serializable (though there are a couple exceptions > to that rule). There are a couple other rules that go along with > that, I can't put fingers on them off the top of my head. All the > sacrifices are really pretty minimal. Okay, parts of this is a small problem with ZODB as well, of course. I suspect ZODB makes this even easier, as it exploits Python's flexibility. Integration with relational databases is another issue; it'd be nice if there was a nicer mapping to objects. I believe WebWare has something like that. (MiddleKit?) > The big gains: you get the distribution and persistence of > sessions. That's a hard thing to do well. Your servlets load > balance across all the servers that are running them. That's a > pretty big win, too -- that's also pretty hard to do in a > reliable fashion. And you get the EJB stuff, which means your > backend model objects pretty much distribute themselves with no > real additional design effort -- the binding mechanism is all > there, the publication mechanism, the lookup mechanism. It's all > there. Sort of like ZEO with Core Session Tracking. :) Of course this is still being heavily developed, but it seems to be getting near offering equivalent features. > The J2EE stuff makes deployment still one more step simpler, too. > It pushes parameters that might change during runtime out one > notch further, so that deployment configuration can be separated > from the details of servlet instantiation, URI mappings, and > other miscellany concerning the interaction of the app and the > app server. Hm, I'm not sure what this part means, exactly. I can't translate it to any Zope terms, which is how I tend to think about things, myself. [scaling from a small server to a large distributed system] This is definitely neat. One of the things that makes ZEO great too; it makes multiple distributed object database act like it's just one. I haven't had to use it either, yet, though. > ----- > JAVA DATA OBJECTS > ----- > JDO is still in development, so it's maybe not fair of me to talk > about it. But since a good proportion of the Python/Zope > technologies that we're trotting out for comparison are still in > development, I figure I might as well. Yes, I'm not trotting them out so much to do 'see, we have that too!', though there is a component in that, but to learn more about both by comparing the two, and to see if there are interesting directions which Zope is missing. I think Java's system works better for model/view/controller type situations right now; Zope's framework for that is currently still in design phases. Java also has clear (standardized) interfaces for it, something which Zope needs a lot more of. I don't know how to compare ZEO with the scalability features you sketched out. I would guess it's a question of tradeoffs; which is better probably depends on your requirements and development style. > Like I said once before, > maybe we can beat Java to the punch here. Python certainly has a lot of flexibility to work in its favor here, though I don't know if we have the development resources in the Python/Zope world to go fast on this. These discussions often seem to devolve into feature wishlists and pie-in-the-sky designing. That said, I think Digital Creations has got the message that integration with relational databases is deemed important by Zope users, and people are of course thinking about this. (in general, we don't seem to be missing many desired features, though we may not have most of them implemented yet. That is a good thing to know) [snip JDO is like EOF] > The EOF I've used, and the EOF I can comment on with a fair > amount of accuracy . The way EOF works, in its most potent > form, is thus: you develop a class with all its accessors and > mutators, plus all the business logic you might want to include. > You map some or all of its data fields to columns in your > database in what's called an entity description. You include > things like relationships to other entities -- does my Employee > entity have a one-to-one relationship with a Boss entity? Model it. > Does my Boss entity have a one-to-many relationship with Employee > entities? Model it. > Fetches can be performed by key, or by selector. Selectors can > pick out individual objects based on the properties of the > objects, or through elaborate path constructions that might trace > through a long series of relationships. An example: you might > fetch all Bosses who have an employee who has a spouse who has a > birthday this month. The selector might look something like: > employees.spouse.birthday.month == now.month Would this get translated into a query into a relational database? > When you fetch these objects from the database, the EOF puts > "Faults" in the place of relationships. When you first try to > read from a fault object, it runs off and fetches the object from > the database. A proxy pattern. > But that's not all! EOF also provides sophisticated caching and > data source controls. EOF also provides multiple 'editing > contexts' with undo capabilities and the ability to nest editing > contexts so that changes can be made within the context of other > changes, and committed incrementally, or abandoned en masse. Does this use relational database transaction features? (with subtransactions?) Note that the ZODB can already do transactions with subtransactions; the interesting bits here seem to be in the relationship modelling and querying, and the relational database integration. I believe ZPatterns may be able to do some of this, but I've never looked into them in detail. > EOF is a powerful tool for management of object graphs and > mapping the object graph onto the database. If even a fraction of > the power EOF offers developers comes through in JDO, that will > be a huge boon to anyone who works with a sophisticated dynamic > data model. Yes, sounds very interesting. I'll keep this in mind when I think about relational database integration in Zope. It's certainly been a fairly hot topic recently. Perhaps I should point some Zope folks to your post. :) [reiteration that standard APIs are important] *part* of the good effects you attribute to standard APIs can be dealt with by good API *documentation* instead. Another part deals with user interface; I do think Zope's web UI helps people who have little programming experience tremendously; I've seen this happen several time. A hot topic in the Zope world has to do with explicit interfaces, and clear documentation for them. This inspired PEP 245, currently under consideration for 2.2. While I don't agree with some of the details of that PEP, I do think the ability to have a form of explicit interfaces (run time checked if checked for at all! ability to lie about implementing an interface! this is Python :) is very important to the future health of Zope and similar large Python systems. http://python.sourceforge.net/peps/pep-0245.html > I will note, in closing, that recent days have been something of > a reawakening of faith in the darkened halls of my soul. Sunlight > has begun to break through the clouds as I consider Python all > over again. I have enjoyed this discussion a great deal, and > enjoyed most of all that it has stirred my humility some -- I > haven't seen all there is to see in the Python world, and much of > what I haven't seen is quite promising. > Thanks! :) And thank you for your extensive description! It must have been a lot of work writing it, but I certainly enjoyed reading about it. I have a much clearer idea of what Java's web application architecture is all about now, and how it maps to systems like Zope. For some time I've been very interested in making Zope's component model work better by having explicit interfaces and model/controller/view type abstractions. It's certainly been very interesting to hear how other systems have approached these issues. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From stevee at recombinant.demon.co.uk Tue Jun 5 15:15:00 2001 From: stevee at recombinant.demon.co.uk (Stephen D Evans) Date: Tue, 05 Jun 2001 20:15:00 +0100 Subject: PMW and Python 2.1 References: Message-ID: <3B1D2FB3.A56B9A61@recombinant.demon.co.uk> I have not encountered any problems with PMW. I have encountered a problem with Tkinter in someone's release of Python 2.1 for Microsoft Windows It the following Python script does not show radiobuttons then there is a problem with the tcl/tk build (causing problems with Tkinter and PMW): # There should be radiobuttons with this piece of code # from John E. Grayson's "Python and Tkinter Programming" chapter 4 # radiobutton.py example from Tkinter import * root = Tk() root.title('Radiobutton') fruit=[('Passion fruit', 1), ('Loganberries', 2), ('Mangoes in syrup', 3), ('Oranges', 4), ('Apples', 5), ('Grapefruit', 6)] var = IntVar() for text, value in fruit: Radiobutton(root, text=text, value=value, variable=var).pack(anchor=W) var.set(3) root.mainloop() ------------- Robert Hicks wrote: > Are there any problems running the latest PMW with Python 2.1? > > Bob From p.caven at ieee.org Tue Jun 19 22:04:33 2001 From: p.caven at ieee.org (Peter Caven) Date: Wed, 20 Jun 2001 02:04:33 GMT Subject: Properties in Python Message-ID: I'm sure that many people reading this newsgroup are aware that the C# (C-Sharp) language has a syntax for 'Properties' that allows a class implementor to hide the implementation of an instance's attribute behind a 'get'/'set' interface. In Python terms this would look like: class Demo: def __init__(self): self.attr1 = 1 self.attr2 = 2 def AMethod(self): pass and where: d = Demo() a1 = d.attr1 # would actually execute something like: d.attr1.get() d.attr2 = 3 # would actually execute something like: d.attr2.set(3) So, instead of allowing direct access to the instance attributes, C# actually executes 'get' and 'set' methods (if defined) for the attributes. This lets a programmer change the behavior of the attributes defined in the class (to have side-effects for example) without changing any code written by users of the class. Does anyone have any ideas on how to do this (elegantly) in Python? __getattr__ and __setattr__ don't seem to quite do it (ie. inheritance). Or, do the Python experts here think that this is not really such a good idea? -- Peter From johnroth at ameritech.net Sat Jun 2 10:22:02 2001 From: johnroth at ameritech.net (John Roth) Date: Sat, 2 Jun 2001 07:22:02 -0700 Subject: Tkinter: image handling: bug or feature? References: <3B170FD3.B98D5E51@artenumerica.com> Message-ID: I believe this behavior is documented - one of the references I've been inhaling recently stated that you **must** keep a reference to an image around, or the displayed version will vanish when the image is garbage collected. If I had to guess as to why, I'd think it was because Tkinter doesn't make a copy of the image anywhere - and once you get into Tk itself, you're playing by its rules on references and garbage collection, not Python's. If Tkinter kept its own reference, then other bad things might happen in oddball cases. John Roth "Jose' Sebrosa" wrote in message news:3B170FD3.B98D5E51 at artenumerica.com... > > Hi, > > I just figured out that this code > > from Tkinter import * > # > class NotSoFunny(Toplevel): > def __init__(self, master): > Toplevel.__init__(self, master = master) > # > #global my_img # <-- PAY ATENTION TO THIS LINE > # > my_img = PhotoImage(file = 'my_image.gif' ) > Label(self, image = my_img, bg = 'yellow').pack() > # > if __name__ == '__main__': (None).mainloop() > > does *not* display the image, but it does if i uncomment the highlighted line > (global statement). The problem seems to be that, at the time the mainloop() > is started, the reference to the image must be available to be displayed. > > Another way to ge the image displayed is to preserve them in the instance > namespace: > > from Tkinter import * > # > class Funny(Toplevel): > def __init__(self, master): > Toplevel.__init__(self, master = master) > # > # --> NOW I USE self.my_img INSTEAD OF my_img <-- > # > self.my_img = PhotoImage(file = 'my_image.gif' ) > Label(self, image = self.my_img, bg = 'yellow').pack() > # > if __name__ == '__main__': Funny(None).mainloop() > > As far as I see, this happens with images only. I like to use local names to > everything I can (so the names are not available when mainloop is called) and > the widgets are displayed with no problem... > > What's wrong with the images? > > I would (wildly) guess that the problem is somewhere in the python-tk > interaction layer... somehow, when we set the image option of a label, the > python does *not* make another reference to the image, so it is lost when the > name is local. Perhaps something in the > python -> command (string) for tk -> tk > sequence makes tk receive an instruction to display an image that it can't find > anymore... > > Or I'm simplly messing it all... > > Sebrosa From thefireinside at hotmail.com Fri Jun 22 18:12:09 2001 From: thefireinside at hotmail.com (Steve Keri) Date: 22 Jun 2001 15:12:09 -0700 Subject: Running an .exe file with python Message-ID: Is there a way i can run an .exe file and install a program using python? please help From mikael at isy.liu.se Fri Jun 8 02:39:30 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 08 Jun 2001 08:39:30 +0200 (MET DST) Subject: Decimal can be Binary Too (was decimal or rational) In-Reply-To: <3B183614.E299F31E@home.com> Message-ID: On 02-Jun-2001 Don O'Donnell wrote: > Scaling would require a multiply or divide by 10 every time the > exponent is incremented/decremented by one, not as fast as a > left or right bit shift; but it can be done pretty fast considering > that a multiply by 10 is equivalent to a left shift by 3 (*8) > followed by two adds (10*x == (8+2)*x == 8*x + 2*x == 8*x + x + x): > > >>> x = 42 > >>> (x<<3) + x + x # multiply by 10 without using * op > 420 Why not make that one left shift by 3, one left shift by 1, and one add? >>> x = 42 >>> (x<<3) + (x<<1) 420 What's more expensive here, add or shift? I'm more into hardware, and hardwired shifts are costless (disregarding overflow checks), while hardwired adds are not. > I'm not sure that this is any faster than x*10; in Python, probably > not, but in C it may be. (Haven't looked at any CPU timing charts > lately, so I may be all wet here; it used to be that mult & div were > very expensive.) (A quick timing check shows that > the above shift and add calculation takes about 3 times longer in > Python than a straight *10, as expected.) Neither am I. There's too much unknown here for me. /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: 08-Jun-2001 Time: 08:28:40 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From robin at jessikat.fsnet.co.uk Fri Jun 15 19:52:45 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sat, 16 Jun 2001 00:52:45 +0100 Subject: idle BUG References: Message-ID: In article , Tim Peters writes >[Robin Becker] >> I don't believe that blaming the other guy (Tcl) is the right way to go. .... >Fredrick reproduced the problem with a simple Python-free Tcl app. > ... well then that ought to be easier for the Tcl people to figure out. Is it available. I get this problem with really simple tkinter things. Pure Tcl should certainly be easier to check. -- Robin Becker From sheila at spamcop.net Sun Jun 10 11:01:09 2001 From: sheila at spamcop.net (Sheila King) Date: Sun, 10 Jun 2001 15:01:09 GMT Subject: New guy question References: Message-ID: <6o27its6v90qbc4mv1baeq25g8ssukpenf@4ax.com> On Sun, 10 Jun 2001 14:24:50 GMT, Sheila King wrote in comp.lang.python in article : :Reboot your machine and then try bringing up a DOS window and typing :python alook.py :at the DOS prompt. Hopefully it should work now. I just thought of something. Maybe Python is already in the PATH in your Autoexec.bat file, and the reason you are getting "Bad command or file name" is because you are not giving the full path to alook.py Maybe you don't need to do all the stuff I suggested with the msconfig and Autoexec.bat file. How about trying this instead: If alook.py is really c:\Python\Python20\alook.py (or whatever the full path is to that file on your machine) Try typing this in a DOS prompt window: python c:\Python\Python20\alook.py (Of course, modify the above to give the actual path to alook.py) Does this work for you??? -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From twofingersalute at atl.mediaone.net Fri Jun 8 21:37:10 2001 From: twofingersalute at atl.mediaone.net (myself) Date: Sat, 09 Jun 2001 01:37:10 GMT Subject: tummy compile Mandrake 7.2 Message-ID: <20010608.214013.1469262009.16325@K7.atl.mediaone.net> Greetings all! long time lurker here, trying to compile python2-2.1-4.src.rpm. Did a "rpm -- rebuild expat-1.1-3tummy.src.rpm", installed the rpm, no probs, then "rpm --rebuild python2-2.1-4.src.rpm" chugs along but exits w/ following: Processing files: python2-tools-2.1-4 Finding Provides: (using /usr/lib/rpm/find-provides)... Finding Requires: (using /usr/lib/rpm/find-requires)... line 246: Dependency tokens must begin with alpha-numeric, '_' or '/': %defattr(-, r oot, root) Failed to find Requires: Requires: python2 = 2.1-4 /bin/bash doesn't look like it's from spec file (lines 244-246): %{__prefix}/lib/python2.1/distutils %{__prefix}/lib/python2.1/encodings %dir %{__prefix}/lib/python2.1/lib-old I noticed this in spec file the aborted build left behind: BuildPrereq: expat-devel >= 1.1-3tummy BuildPrereq: db1-devel BuildPrereq: gdbm-devel already have gdbm-devel, got and installed db1 and db1-devel, no clue as to expat-devel as Mr. tummy doesn't seem to install it. tried again, fails again on same line, so doesn't look like it's referring to spec file, as lines 245-246 are now: %files -f tools.files tools %defattr(-, root, root) also, have following: rpm, rpm-build, rpm-devel v.3.0.5-27mdk. My goal here is to not only install Python2.1, but to learn a bit about installing from source rpms (1'st time on the latter, just in case you hadn't guessed). target is i686(Athlon). clues and/or nudges(wink, wink) in right direction appreciated......... From aahz at panix.com Wed Jun 20 14:55:08 2001 From: aahz at panix.com (Aahz Maruch) Date: 20 Jun 2001 11:55:08 -0700 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) References: <3B303FE5.735A5FDC@cosc.canterbury.ac.nz> <90C65699Dgmcmhypernetcom@199.171.54.194> Message-ID: <9gqric$kjd$1@panix3.panix.com> [posted to c.l.py with cc to Barry and Jeremy] In article , Paul Prescod wrote: > >We're discussing this issue on python-iterators. I think everyone >interested should head over there. I'd really like to discuss this but >I'm trying to follow the rules! While there's some logic here, it's not exactly convenient to subscribe to every mailing list under the sun each time a "critical" issue comes up. While I overall think Tim is right in removing python-dev from the list of venues for discussing PEP 255, I think that trying to place comp.lang.python (aka python-list) off-limits is a Bad Idea. I suggest that if PEP authors really wish to move discussion to separate mailing lists that the PEP guidelines should be modified to encourage inclusion of instructions for subscribing to the mailing list(s). Barry, Jeremy, any comments on the above idea? -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "It's not what you know, it's what you *think* you know." --Steve Martin From fdrake at cj42289-a.reston1.va.home.com Mon Jun 11 15:15:06 2001 From: fdrake at cj42289-a.reston1.va.home.com (Fred Drake) Date: Mon, 11 Jun 2001 15:15:06 -0400 (EDT) Subject: [development doc updates] Message-ID: <20010611191506.DC49F28923@cj42289-a.reston1.va.home.com> The development version of the documentation has been updated: http://python.sourceforge.net/devel-docs/ Substantial additional material on floating point arithmetic in the tutorial, written by Tim Peters to explain why FP can fail to reflect the decimal world presented to the user. Lots of additional updates and corrections. From sill at optonline.net Mon Jun 11 18:10:54 2001 From: sill at optonline.net (Rainy) Date: Mon, 11 Jun 2001 22:10:54 GMT Subject: Python grammar.. References: Message-ID: On Mon, 11 Jun 2001 17:27:18 -0400, John wrote: > Hi, > > I previously asked whether Python accepts function arguments without the > opening/closing brackets and commas, like so: foo(x,y) would become foo x > y. The answer to this was no. So, I am wondering if it would be easy to > modify the source and rebuild the interpretor to accept this format? I > tried modifying the Grammar file but that didn't seem to work... > > Thanks, > > John Out of curiosity, why would you want to do that, out of curiousity? > > -- The point of philosophy is to start with something so simple as not to seem worth stating, and to end with something so paradoxical that no one will believe it. From sholden at holdenweb.com Thu Jun 28 20:32:04 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 28 Jun 2001 20:32:04 -0400 Subject: Does mxTextTools work in Python 2.1? References: <3B3BCB69.C71F77C7@raqia.com> Message-ID: There are different distributions of the binary for different Python versions. You can pick up the appropriate file at http://www.lemburg.com/files/python/eGenix-mx-Extensions.html#Download-mxBAS E If you already have the source, it will need recompiling to run against 2.1. regards Steve -- http://www.holdenweb.com/ "David Lees" wrote in message news:3B3BCB69.C71F77C7 at raqia.com... > Subject line asks the question: Does mxTextTools work in Python 2.1 or > do I need to reinstall 2.0 to have it work? > > David Lees From emile at fenx.com Fri Jun 29 22:31:11 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 29 Jun 2001 19:31:11 -0700 Subject: [TO]What's the big deal with EJB? [Re: PEP scepticism] References: <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> <3d8zib16g7.fsf@ute.cnri.reston.va.us> Message-ID: <9hjdu1$e1h9l$1@ID-11957.news.dfncis.de> Kewl! -- Emile van Sebille emile at fenx.com --------- "Andrew Kuchling" wrote in message news:3d8zib16g7.fsf at ute.cnri.reston.va.us... > Alex writes: > > What's EJB got going for it, anyway? > > Buggered if I know. Perhaps they provide a frictionless method for > transferring a business's money to consultants. > > --amk > From aahz at panix.com Mon Jun 25 14:37:11 2001 From: aahz at panix.com (Aahz Maruch) Date: 25 Jun 2001 11:37:11 -0700 Subject: Can I start asynchronous threads in .pythonrc? References: Message-ID: <9h80cn$t3p$1@panix2.panix.com> In article , Alex wrote: > >I have some slightly time consuming administrative stuff that I'm doing >to my source tree each time I start python. I'm running it in my >.pythonrc file, which means there's a delay of a few seconds before I >get the python prompt. Is there any way to get stuff in my .pythonrc to >run in the background? Why not just create a cron job? There's no intrinsic reason you couldn't use threads, but I'm not sure this is a good use. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Those who do not remember the past are condemned to repeat it." From careye at spamcop.net Thu Jun 28 06:33:35 2001 From: careye at spamcop.net (Carey Evans) Date: 28 Jun 2001 22:33:35 +1200 Subject: strftime: %Z, timezone, and all that References: Message-ID: <878zicdhc0.fsf@psyche.dnsalias.org> Les Schaffer writes: > i tried adding a date header to an email as per the python docs, like so: ... > return strftime("%a, %d %b %Y %H:%M:%S %Z", localtime()) ... > Date: Tue, 26 Jun 2001 23:40:46 Eastern Daylight Time ... > seems like %Z in strftime should either return a +0500 or an EDT, no? -0500, actually. I think the Python documentation is incorrect in this case. K&R only describes %Z as "time zone name, if any", and the Single UNIX Spec is just as vague: http://www.opengroup.org/onlinepubs/7908799/xsh/strftime.html In any case, my time zone is one of "New Zealand Standard Time", "Pacific/Auckland" or "NZST", none of which is listed in section 5.1 of RFC 822. RFC 822 has been superseded by RFC 2822 now as well, and the latter deprecates the named time zones. Here's a function to return the correct numeric time zone for RFC 2822: def zone2822(timetuple): dst = timetuple[8] offs = (time.timezone, time.timezone, time.altzone)[1 + dst] return '%+.2d%.2d' % (offs / -3600, abs(offs / 60) % 60) -- Carey Evans http://home.clear.net.nz/pages/c.evans/ "Quiet, you'll miss the humorous conclusion." From philh at comuno.freeserve.co.uk Wed Jun 20 09:44:04 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Wed, 20 Jun 2001 14:44:04 +0100 Subject: ANN: Introducing PLY-1.0 (Python Lex-Yacc) References: <3B306425.1BA938BE@lemburg.com> Message-ID: On Wed, 20 Jun 2001 07:57:32 -0500 (CDT), David Beazley wrote: >M.-A. Lemburg writes: > > > > Just a suggestion: PLY seems to use the same logic for attaching > > grammar snippets to functions as SPARK does. IMHO, this is bad > > design since doc-strings should really only be used for documentation > > and not include vital information for the program logic. > >Actually, I thought the doc string hack was one of the neatest >programming tricks I've ever seen (which is exactly why I copied it >from SPARK). Why would I write a different documentation string for a >grammar rule anyways? The grammar rule in the docstring not only >tells the parser generator what to do, but it precisely documents what >the function does at the same time. I don't know what inspired John >to take this approach in SPARK, but it's pure genius if you ask me :-). Yeah, it certainly wouldn't have occurred to me (a happy SPARK user). -- ## Philip Hunt ## ## philh at comuno.freeserve.co.uk ## From blaster_boy at hotmail.com Sun Jun 17 17:07:06 2001 From: blaster_boy at hotmail.com (Blaster_boy) Date: Sun, 17 Jun 2001 21:07:06 GMT Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? References: <3B2B60AD.942719AE@earthlink.net> Message-ID: <_Z8X6.41946$mR5.5658440@afrodite.telenet-ops.be> Hello Ron, I am not a very good python programmer, still learning the basics, but it's the language I've decided to learn after looking at a lot of other languages. Perhaps this is not for you, but have you thought about using Zope ? In it's own way, that too is an event-driven user interface. True, you need to learn yet another language (DTML), but you can easely integrate it with python scripts (at least, that's what I am reading in the Zope book...). My plan is, since our intranet phonebook falls over all the time (just when you absolutely need that phone number) to write a python script that read in the csv file, and link that with Zope to provide my own phonebook. Regards, and I'ld be interested as well in other comments... A What about using ZOPE as "Ron Stephens" wrote in message news:3B2B60AD.942719AE at earthlink.net... > I have not been successful heretonow in gui or event driven programming > . Learning and using Tkinter is much harder for me that procedural > Python. I am doing fine on classes and object oriented Python also, but > not event driven programing. Some of the options available to me that I > am aware of are: (I am programming on a Windows 98 machine). > > 1. Tkinter and wxPython. I have not been too successful with Tkinter, > but I do not rule it out. I have just begun to look at wxPython. Does > anyone think wxPython is easier to learn and use than Tkinter, or about > the same? > > 2. Boa Constructor and wxPython. I have downloaded Boa and it looks > complicated, but I like the idea of a VisualBasic like gui designer. Is > Boa far enough along to be used? Any comments on Boa? > > 3. PythonWorks. I just downloaded the evaluation copy. OK, it costs > $395, a lot of money to pay for a hobbyist. However, if it were the > answer to my prayers and far better, as a gui painter, than any other > alternative, I guess I would consider it. Does anyone have experience > with Pythonware and could you comment? I am really mainly interested in > the gui painter. > > 4. theKompany's BlackAdder. Same as above. For some reason, I seem more > favorably inclined towards Pythonware, btu I don't know why ;-)) Anyone > have any experience with BlackAdder and can you comment? > > 5. I am vaguely aware of other alternatives such as qt toolkits, gtk > toolkits, etc. > > 6. Java based solutions. I am successful in getting my scripts to run > under Jython. I am a little, just a little, familiar with Java and the > JVM's. It occurs to me that there may be Java based gui painters that I > could use as a front end to connect to jython based programs? A few > years ago I used a Sun product called Java Studio that fell in this > category; I like Java Studio, but Sun discontinued it. Are there any > open source or even commercial products I should consider? > > 7. Someone on the list mentioned they use Jbuilder from Borland as a gui > painter for their Python programs. Hmmm, Jbuilder has a boxed package > for sale much cheaper than even Pythonworks ;-))) Any comments pro or > con???? I doubt that this would fit my definition of "easy" to learn and > to use, but who knows??? > > I would appreciate any comments. Python's ease of learning and ease of > use opens new doors for "low IQ" programmers like myself. But much that > one might wish to do involves event-driven programming, and Python does > not yet, it seems to me, offer the same ease of use in this arena. But I > keep searching and hoping. Event driven programming is awful important > and it would be nice if Python's core advantages could somehow extend > into this area. > > I would prefer to stick to a solution that is as much Python-like as > possible, but a jython-Java GUI solution is also of interest. Maybe I > will try one of each. > > I think this whole topic of discussions of interest to many newbie's and > programming hobbyists, not just to myself. A successful address to this > "problem" could seriously propel Python even further as an educational > and first-learning language. I would really enjoy a discussion of pros > and cons and possible directions to explore, both now and also in the > future, if anyone can predict future directions of even-driven GUI > programming and Python. ;-)))) > > Ron Stephens > > > From john.thai at dspfactory.com Wed Jun 13 13:33:20 2001 From: john.thai at dspfactory.com (John) Date: Wed, 13 Jun 2001 13:33:20 -0400 Subject: PyArg_ParseTuple part 2 Message-ID: Hi, In an extended python c function, I use PyArg_ParseTuple to extract a list object from python. I then use PyList_AsTuple to get a tuple version of the list. I'm expecting an list of 2 integers, so I use PyArg_ParseTuple again, passing in this new derived tuple, and specifying "ii". Should this not work? First, after I call PyList_AsTuple, I get NULL back instead of a PyObject. Second, lets say I pass variable x (from python) = [1,2] into my function, right after making this function call foo(x), no matter what I type, either x, or just enter, I get the following msg: SystemError: C:\Code\python\dist\src\Objects\listobject.c:1317: bad argument to internal function Anyone know what's going on? Related questions: Is there a fast way of extracting elements from a list, other than using PyList_GetItem, then converting the PyObject into the type you are looking for? And why isn't there a PyInt_FromInt(int) function? Thanks, John From rod_weston at yahoo.com Thu Jun 7 19:25:46 2001 From: rod_weston at yahoo.com (Rod Weston) Date: 7 Jun 2001 16:25:46 -0700 Subject: Learning OOP... References: <9fm8ti$d92$1@newshost.accu.uu.nl> Message-ID: The reasons I feel a need to learn OOP languages are as follows: 1. I feel that OOP offers the best conceptual fit for my programming projects which are primarily business oriented. 2. Career choices - any programmer in today's market needs to be OOP conversant and productive, preferably with a language that will be recognized and used 'a lot', thereby generating profitable opportunities. 3. I want to reuse code as much as possible. 4. I want to reduce errors and take advantage of advanced debugging tools. 5. I want strong and flexible data typing - I know it sounds like an oxymoron. I want the typing to be especially powerful (restrictive) but I want to be able to define the constraints of the types myself. 6. I want something relatively easy to use and to learn. 7. I want reduced development times and enhanced maintenance tools. 8. I want portability and scalability. 9. I want a lot of open source code available. 10. I want source code that is easily read. 11. I want good quality but free or inexpensive tools - especially a validated compiler to properly optimize my code for the task at hand and catch as many errors as possible at compile time. Not all the objectives relate to OOP, but most do. From what I've seen so far, Ada best meets my criteria but I have not done enough research yet to be willing to gamble my future on it. From Administrator at crescere.co.uk Mon Jun 11 04:22:33 2001 From: Administrator at crescere.co.uk (Administrator at crescere.co.uk) Date: Mon, 11 Jun 2001 09:22:33 +0100 (BST) Subject: Rejected Message Message-ID: <200106110822.f5B8MXm18346@sulphur.cix.co.uk> The attached mail message has been rejected for the following reason: Body contained word(s)/phrase(s): fuck, shit Additional Information: -------------- next part -------------- An embedded message was scrubbed... From: python-list-request at python.org Subject: Python-list digest, Vol 1 #6324 - 11 msgs Date: Sat, 09 Jun 2001 00:17:00 -0400 Size: 40043 URL: From robin at jessikat.fsnet.co.uk Fri Jun 15 04:00:41 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 15 Jun 2001 09:00:41 +0100 Subject: idle BUG References: Message-ID: In article , Tim Peters writes .... >> It's clearly some kind of race between python and Tcl/Tk. > >Fredrik Lundh has provoked the same problems with pure Tcl/Tk apps run from >a wish shell -- no Python components involved. That is, there's no reason >to believe Tkinter or Python have anything to do with this. ... I don't believe that blaming the other guy (Tcl) is the right way to go. I too can make Tk Apps go wrong, but in every case that this happened I eventually traced the problem to a programming error in my tcl coding. This is especially true in later Tcl's as they've found and fixed some of the earlier problems and also introduced multithreading. There were also some problems caused by win32 Tk apps interfering with each other because of Tk's attempts at determining all existing Tk apps (to allow the send command to work), but I think that is disabled in 8.3. I run complex Tcl code every day on the same box and it never locks up. The reason for wanting to run Tkinter apps from a dos/cmd box is to see the print outputs for debugging etc. -- Robin Becker From sandysj at asme.org Mon Jun 25 19:26:47 2001 From: sandysj at asme.org (Jeff Sandys) Date: Mon, 25 Jun 2001 23:26:47 GMT Subject: 'with' statement in python ? References: Message-ID: <3B37C8B7.CA513385@asme.org> Gerhard H?ring wrote: > asgard wrote: > > writing self before every object's method really drives me crazy. > > self.a = 1 > > You can use any name instead of self, some people use simply "s", for example. self drives me nuts too, but I learned to use it after trying "my" and "_". I kind of liked underscore, the blank, insert name here idea, but it is hard to verbally communicate. self is easy to communicate and well understood. my.a = 1 _.a = 1 Thanks, Jeff Sandys From James_Althoff at i2.com Fri Jun 1 16:56:53 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Fri, 1 Jun 2001 13:56:53 -0700 Subject: Returning 'None' on Instantiation ? Message-ID: Alex Martelli wrote: >Factory is perfectly-robust. The only Python specific >part is the possibility to "reuse the names", but it's >debatable whether that adds anything to actual use, and >it sure doesn't add anything to _robustness_:-). > >Alex I agree with Alex on the main point of using the factory design pattern. I would suggest, though, that "rebinding the class name" is probably not a good idea in many cases because you might need a reference to the class itself anyway: to create a subclass, to access class fields, etc. Distinguishing a factory function from the class is probably a good thing to do for extensibility. So picking a nice name (not the class name) for the factory function is probably a better way to go most of the time. Jim From scarblac at pino.selwerd.nl Mon Jun 11 08:26:52 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 11 Jun 2001 12:26:52 GMT Subject: What version of python is the right version? References: Message-ID: Fredrik Steen wrote in comp.lang.python: > What version of python should I use for new projects? > 1.5.2, 2.0, 2.1? Unless there is some good reason not to, always use the latest. -- Remco Gerlich From darked at my-deja.com Sun Jun 17 23:03:45 2001 From: darked at my-deja.com (Darek Kedra) Date: 17 Jun 2001 20:03:45 -0700 Subject: MySQLdb-0.3.5 build problem SOLUTION :-) References: Message-ID: After getting and installing zlib1-devel-1.1.3-15mdk.i586.rpm the module MySQLdb-0.3.5 builds and installs with no problems. Darek From m.faassen at vet.uu.nl Tue Jun 12 19:01:45 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 12 Jun 2001 23:01:45 GMT Subject: What "Tim Peters" really looks like References: Message-ID: <9g670p$i4s$1@newshost.accu.uu.nl> Jarno J Virtanen wrote: [snip] > Shortly after the incident I was captured and send to the > XXXXXXXXXXX star system near the XXXXXXXXXXX star. I managed to > send the above mentioned picture and this message by stealing some > bytes from the stream they're sending from here to Earth. > They seem to have some horrible and evil plan for Okay, the PSU cut you off there, it seems. If you can give us some info on where in the galaxy you are (and which galaxy), we can use a timemachine driven faster than light drive to get you back. Then when we talk in person in a properly shielded room, and you can disclose their evil plan. I suspect I already know what it is about. Since the PSU will likely cut me off I will try to get the message across by dropping some key words: floating point rounding errors siphon dollars From loewis at informatik.hu-berlin.de Thu Jun 7 07:08:46 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 07 Jun 2001 13:08:46 +0200 Subject: Trouble with Parsing XML References: Message-ID: Benjamin Schollnick writes: > EXPAT does give me a few of the objects data back, but not all of them. Not sure what you mean. All entites that you have in the document are reported, as far as I can tell. Which ones are missing in your output? For reference, I get XML.Parsers.Expat ------------------------------------------ Start : multistatus attrs: {} Start : response attrs: {} Start : href attrs: {} Start : propstat attrs: {} Start : prop attrs: {} Start : displayname attrs: {} Start : summary attrs: {} Start : entityowner attrs: {} Start : dsref attrs: {u'handle': u'User-2'} Start : displayname attrs: {} Start : username attrs: {} Start : parents attrs: {} Start : dsref attrs: {u'handle': u'Collection-10'} xml.sax ------------------------------------------ > Can anyone verify that EXPAT is operating properly? Since I don't know what your script does on your installation, I cannot verify this. > I'm assuming this is a Programmer (my) error, but I'm not familiar > enough with EXPAT to decide on what is the problem. It might be neither-nor - I cannot see any problem. Regards, Martin From skip at pobox.com Thu Jun 21 12:44:41 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 21 Jun 2001 11:44:41 -0500 Subject: How to convert an object ref to string and the reverse In-Reply-To: <9dab6033.0106210725.935e7c4@posting.google.com> References: <9dab6033.0106210725.935e7c4@posting.google.com> Message-ID: <15154.9337.875910.914107@beluga.mojam.com> Ivan> how is it possible to convert an instance Ivan> to string and how to do the reverse - convert the Ivan> resulting string in a valid object reference. Take a look at the pickle and cPickle modules: >>> import pickle >>> class foo: ... def __init__(self): ... self.a = 1 ... >>> i = foo() >>> i <__main__.foo instance at 0x82d1444> >>> pickle.dumps(i) "(i__main__\nfoo\np0\n(dp1\nS'a'\np2\nI1\nsb." >>> j = pickle.loads(pickle.dumps(i)) >>> j <__main__.foo instance at 0x823fb24> -- Skip Montanaro (skip at pobox.com) (847)971-7098 From thecalm at NOSPAM.btinternet.com Tue Jun 26 19:13:22 2001 From: thecalm at NOSPAM.btinternet.com (G. Willoughby) Date: Wed, 27 Jun 2001 00:13:22 +0100 Subject: Im running Macmilan Inc's standalone.py and im having a few difficulties finding modules it requires Message-ID: <9hb4st$j5l$1@neptunium.btinternet.com> Im running Macmilan Inc's standalone.py and im having a few difficulties finding modules it requires, any idea where these modules can be found? dos mac nt.stat os2 posix strop.lowercase strop.maketrans strop.uppercase strop.whitespace ce pwd MACFS macfs MacOs thanks, Gaz. From skip at pobox.com Sat Jun 9 00:31:23 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 8 Jun 2001 23:31:23 -0500 Subject: printing Python stack info from gdb Message-ID: <15137.42651.137370.490871@beluga.mojam.com> >From time to time I've wanted to be able to print the Python stack from gdb. Today I broke down and spent some time actually implementing something. set $__trimpath = 1 define ppystack set $__fr = 0 select-frame $__fr while !($pc > Py_Main && $pc < Py_GetArgcArgv) if $pc > eval_code2 && $pc < set_exc_info set $__fn = PyString_AsString(co->co_filename) set $__n = PyString_AsString(co->co_name) if $__n[0] == '?' set $__n = "" end if $__trimpath set $__f = strrchr($__fn, '/') if $__f set $__fn = $__f + 1 end end printf "%s (%d): %s\n", $__fn, f->f_lineno, $__n end set $__fr = $__fr + 1 select-frame $__fr end select-frame 0 end Output looks like this (and dribbles out *quite slowly*): Text_Editor.py (147): apply_tag Text_Editor.py (152): apply_tag_by_name Script_GUI.py (302): push_help Script_GUI.py (113): put_help Script_GUI.py (119): focus_enter Signal.py (34): handle_signal Script_GUI.py (324): main Script_GUI.py (338): If you don't want to trim the paths from the filenames, set $__trimpath to 0. Warning: I've only tried this with a very recent CVS version of Python on a PIII-based Linux system with an interpreter compiled using gcc. I rely on the ordering of functions within the while loop to detect when to exit the loop and when the frame I'm examining is an eval_code2 frame. I'm sure there are plenty of people out there with more gdb experience than me. I welcome any feedback on ways to improve this little bit of code. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From gerhard.nospam at bigfoot.de Sat Jun 16 21:18:22 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sun, 17 Jun 2001 03:18:22 +0200 Subject: qt or gtk? References: <9ggof8$gmd$1@brokaw.wa.com> Message-ID: <3B2C055E.DF07B0D1@bigfoot.de> Courageous wrote: > > ?Now I feel stupid. I thought Qt was free to use if your software is free, > ?but costs money if you plan to sell it. There are two versions - commercial > ?and free software, and you have to buy a license if you want to use the > ?commercial version. I assumed the difference between the two is only in > ?name and license, and the source is the same, however. > > Actually, I believe that what you said is correct for the Linux platform, > but I'm not sure. What I am sure of is that Qt is not free for Windows, > irrespective of how you intend to use it. Qt/X11 is available under the GPL. Alternative commercial licensing for Qt/X11 is also available. Qt/Windows is only available under a commercial license. Of course, you can use a X server on Windows and try to compile Qt/X11 with Cygwin ... The licensing is not tied to the operating system, but Qt/X11 and Qt/win32, Qt/Mac have a different codebase. Only the X11 version is available under the GPL. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://highqualdev.com public key at homepage public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From aleaxit at yahoo.com Tue Jun 5 10:35:35 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 5 Jun 2001 16:35:35 +0200 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3b1cdf94.55bd@bolder.com.co.za> Message-ID: <9fiqno016ig@enews1.newsguy.com> "goose" wrote in message news:3b1cdf94.55bd at bolder.com.co.za... ... > > Due to the fact that they have been designed for > > university (friendly) environment. > > serious multi-user environments, unlike windows which evolved from a single-user > single-tasking os with no security at all ... Windows/95 did (and its direct successors, /98 and /ME). Windows/NT didn't -- it's a completely different system, and its chief architect was the same guy who had chief-architected VMS for DEC. In fact I find in it many of the things I disliked in VMS, although at least it's simpler:-). But, like VMS (and Unix of all sorts, and the IBM OS's, ...), it IS a real operating system. /2000 uses NT technology, too. *In theory* the coming Windows/XP is going to rely on /NT-/2000 technologies too, finally putting to rest forever the last traces of the Quick & Dirty OS (QDOS), which Gates bought & relabeled "DOS 1.0" in 1984 because he had to have something to sell to IBM _fast_ and MS had zero skill or experience in doing operating system software (QDOS, if I get it right, was in turn basically a disassembly-hack a bit-reassembly of CP/M to move it from 8080 to 8086 -- sorry, I just LOVE rambling about such irrelevant stuff:-). > i'm sorry - openbsd is probably *THE* most secure os on the planet ... > go to the website and read up about it (not too sure what it is, but should be http://www.openbsd.org/ > easy to find, considering it's popularity) ... be prepared to be impressed ... I love their approach to security, yes. If I ever were responsible for choosing or suggesting a top-security OS, with security being the overriding concern, I don't think I would look further than OpenBSD. Alex From paulp at ActiveState.com Mon Jun 4 08:45:05 2001 From: paulp at ActiveState.com (Paul Prescod) Date: 4 Jun 2001 07:45:05 -0500 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Jun 4) Message-ID: <39E4770BB90353A4.F5B0F67B7F841C19.51D1EEF69D817244@lp.airnews.net> The DISLIN data plotting library has reached the ripe old age of 7.5. DISLIN isn't only usable from Python but what other language would you choose? http://www.dislin.de/ It seems DISLIN is the topic of the week. Eric Hagemann covers it in his onging series on numerical programming in Python: http://www.oreillynet.com/pub/a/network/2000/06/02/magazine/numerically.html Maybe the topic of the week is more general than DISLIN. How about graphics? Michael Wallace describes how to generate graphics with Piddle: http://www.onlamp.com/pub/a/python/2001/05/31/piddle.html You'll need a user interface to go with all of those pretty pictures. PYUI is a user interface library written in 100% Python using PyGame! http://pyui.sourceforge.net/ Games based on PyGame just keep popping up. Pygris is a falling blocks game written in Python. Next I predict, PyKombat, PyMario and PyQuake! http://www21.brinkster.com/coonsta/pygris/ How do you do serial IO in Python? Usual answer: It depends on your operating system. New answer: not anymore! XIO is a new cross-platform serial port driver for win32 and Unix. http://groups.google.com/groups?ic=1&th=dae9fa4438b9bc9a,3 Python is great as a first programming language. Point your newbie friends at this article by Cameron Laird to convince them to stick their toes in the programming pool in the shallow end. http://www.oreillynet.com/pub/a/network/2000/06/02/magazine/python_first_language.html If Cameron didn't convince them, how about a review from an expert. Ron Stephens describes a newbie's love affair with Python: http://groups.google.com/groups?ic=1&th=b5d4dd1f55a71d62,3 PyChecker 0.5 has been released. PyChecker helps you find common bugs in python source code. http://pychecker.sourceforge.net/ Chapter 5 of "Dive Into Python" is available. This chapter discusses Unit Testing. http://diveintopython.org/roman_divein.html Python is great at talking COM, CORBA, SOAP and now cross platform COM(XPCOM)! XPCOM is the component system developed in the Mozilla project. Uche Ogbuji tells all: http://www-106.ibm.com/developerworks/components/library/co-pyxp1.html A variety of threads this week dived into arcana relating to numbers. First there is recurring discussion of whether Python should adopt rationals, or decimal floating point and if so with what syntax: http://groups.google.com/groups?th=893850c4619119ea,109&ic=1 Then there was an interesting debate on the nature of randomness. Bill Bell summarizes it well: "What is it about random numbers that provokes so much discourse". The thread starts here: http://groups.google.com/groups?th=3afeb4752bc8482a,62&ic=1 Stephen Figgens takes a look at structured grep and its relationship to Python. http://www.onlamp.com/pub/a/python/2001/05/23/pythonnews.html Frank Willison challenges the Python community to contribute to the Python cookbook: http://www.oreilly.com/frank/ ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the daily python url http://www.pythonware.com/daily comp.lang.python.announce announces new Python software. Be sure to scan this newly-revitalized newsgroup at least weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Michael Hudson continues Andrew Kuchling's marvelous tradition of summarizing action on the python-dev mailing list once every other week. http://starship.python.net/crew/mwh/summaries/ http://www.amk.ca/python/dev The Vaults of Parnassus ambitiously collect Python resources http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ The Python Software Foundation has replaced the Python Consortium as an independent nexus of activity http://www.python.org/psf/ Cetus does much of the same http://www.cetus-links.de/oo_python.html Python FAQTS http://python.faqts.com/ 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 tricks of the trade: http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python&num=100 http://groups.google.com/groups?meta=site%3Dgroups%26group%3Dcomp.lang.python.* Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://groups.google.com/groups?oi=djq&as_q=+Python-URL!&as_ugroup=comp.lang.python Suggestions/corrections for next week's posting are always welcome. [http://www.egroups.com/list/python-url-leads/ is hibernating. Just e-mail us ideas directly.] To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From sdm7g at Virginia.EDU Thu Jun 21 22:19:28 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Thu, 21 Jun 2001 22:19:28 -0400 (EDT) Subject: Another Wart! string.find() [ was: namespace issue? ] In-Reply-To: <112e9d13.0106211743.39215b91@posting.google.com> Message-ID: On 21 Jun 2001, Chuck Esterbrook wrote: > "Steven D. Majewski" wrote in message news:... > [snip] > > > > I'ld love to see it fixed, however, I suspect that in this case, > > many lines of installed code trumps Computer Programming for Everybody! > > > > So is it a flaw, relative to CP4E, that sequences start at index 0 > instead of 1? An 'everybody' kind of person would think of the "first" > element as e[1]. Only someone familiar with pointer arithmetic from C > or assembly would think that "first" is 0. No -- that's not a "flaw" , it's an "engineering tradeoff" -- i.e. you can't please everyone all the time! Zero is natural whenever you are thinking in terms of offsets: every ruler starts with an implied 0 inches (or cm. or other). Zero based indexing makes slice indexing much easier to figure -- one-based indexing would make that more confusing to everyone. Lots of other technical fields besides programming use zero based indexing -- where do you think C got it ? Probably from mathematics or engineering. Most high-school grads should be familiar with the notation. Yeah -- there are arguments for 1 over 0, but whatever you choose is going to be 'wrong' for somebody, some of the time. And not surprising C programmers does have *some* value. ( But I can't really think of a good reason for string.find to return -1 *except* that it wouldn't surprise a C programmer. ) -- Steve Majewski From dalke at acm.org Thu Jun 21 22:56:44 2001 From: dalke at acm.org (Andrew Dalke) Date: Thu, 21 Jun 2001 20:56:44 -0600 Subject: Another Wart! string.find() [ was: namespace issue? ] References: Message-ID: <9gucf9$ruc$1@slb3.atl.mindspring.net> Steven D. Majewski wrote: > It probably *ought* to return None for not found: > "string"[None] yields an exception: > "TypeError: sequence index must be integer" > while "string"[-1] returns "g" > so a coding error is likely to slip thru without an exception. ... > I'ld love to see it fixed, however, I suspect that in this case, > many lines of installed code trumps Computer Programming for Everybody! >>> print string.find.__doc__ find(s, sub [,start [,end]]) -> in Return the lowest index in s where substring sub is found, such that sub is contained within s[start,end]. Optional arguments start and end are interpreted as in slice notation. Return -1 on failure. >>> print string.index.__doc__ index(s, sub [,start [,end]]) -> int Return the lowest index in s where substring sub is found, such that sub is contained within s[start,end]. Optional arguments start and end are interpreted as in slice notation. Raise ValueError if not found. >>> Only difference is what to do when the substring isn't found; return -1 or raise a ValueError. Andrew dalke at acm.org From jtorborg at fnal.gov Wed Jun 6 17:51:39 2001 From: jtorborg at fnal.gov (Julie Torborg) Date: Wed, 6 Jun 2001 16:51:39 -0500 Subject: Generating Multiple Class Instances In-Reply-To: <3B1E9A20.A9647C06@ActiveState.com> Message-ID: On Wed, 6 Jun 2001, Paul Prescod wrote: > > There's something funny there. How does each Quark know what its color > and mass is? What is the definition of getcolor and getmass? where getcolor and getflavor are already defined, and you're right, I can get this part working fine... > > flavor=['up', 'down', 'strange', 'charm', 'top', 'bottom'] > > for each in flavor: > > each=Quark() > > You aren't changing the list. You're just reading from it, never writing > to it. Here's a straightforward way to do it: I don't want to change the list, I want to do the same thing as typing i_top=Quark(top) i_bottom=Quark(bottom) > flavornames = ['up', 'down', 'strange', 'charm', 'top', 'bottom'] > flavors = [] > for each in flavornames: > flavors.append(Quark()) > > for each in flavors: > print each.color This just creates a new ordered array. If I want to access the mass of top, I still have to know where in the array the top instance lives. What I want to do, is starting with my original list, is to make another list (which is composed of a simple variation on the original list, like adding the i_ above). Then if I want to know the mass of charm, I just type moc=i_charm.mass and I don't have to know where anything lives. Eventually, all of this will be going into a GUI, and access to all these parameters will be very non-linear. The big idea here is to keep all the "attributes" associated with their "objects." It seems to be so well described by the OOP jargon I can't believe I'm having trouble. What I visualize is this: You've got a whole bunch of balloons (the class) filled with different gases (the instance). Each has a different color (the "name"), a string hanging from it and a sticker stuck to it (the attributes). On the sticker and the string are written words. Now, I set all these balloons bouncing around. How do I find what's written on the sticker of the balloon with helium in it? Well, I have to know what color that balloon is, then I can say, "Get the orange balloon." When the orange balloon comes to me, I look at the sticker and say "Eureka." Now if all the balloons are the same color, I have to go through all the balloons, or I have to find another way of "naming" them, like putting them in order on a line (the ordered list you suggest). The problem with that is that not only do I have to know what gas is in what balloon, I have to keep them in order or I lose that information. But, to be fair, the solution you've provided here is better than what I've come up with. Maybe there's a way to automatically build a dictionary that will associate a "name" with each instance. That still seems like a lot of keystrokes, not to mention CPU load during lookup (like I said, there are hundreds of list items, I fictionalized this one for simplicity), especially when I have a gut feeling that with a little finesse, there's a much more elegant solution. Or there should be. From jochen at riekhof.de Thu Jun 14 11:38:33 2001 From: jochen at riekhof.de (Jochen Riekhof) Date: Thu, 14 Jun 2001 17:38:33 +0200 Subject: substitute for c/java's ?: References: <9g5fc4$m8u$01$1@news.t-online.com> Message-ID: <9galoe$8m6$06$2@news.t-online.com> > result=iif(option,value1,value2) oh, this is visual basic (should I have said this? ;-). Good idea, drawback is it has the same disadvantage as the tuple method in that it does evaluate both values first (btw exactly what VB does, too). Ciao ...Jochen From SBrunning at trisystems.co.uk Tue Jun 5 04:33:05 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Tue, 5 Jun 2001 09:33:05 +0100 Subject: Running an AS/400 CL program via ODBC Message-ID: <31575A892FF6D1118F5800600846864D78BCCE@intrepid> > From: Aaron Fransen [SMTP:aaronf at nospam.telusplanet.net] > I have a problem executing an AS/400 CL program from the SQL/ODBC > interface > in Python. I know the interface on the AS/400 works because I actually > wrote > the code to do it originally in VB, which has been live on our web site > for > months. I'm getting sick of the Really Big Visual Basic Corporation > though, > and am in the process of converting the site to Python, which seemed to me > to be about the best/easiest/really cool tools out there. > > I can run any SQL query via the ODBC 2 interface (Python 2.1) using the > following code: > > dbc=odbc.odbc("datasourcename/as400username/password") > cursor=dbc.cursor() > cursor.execute("Select * from MYTABLE") > result=cursor.fetchall() > > Works perfectly. However, if I try something like this: > > cursor.execute("{{Call > LIB.PROGNAME(?,?,?,?,?,?)}}",['PARM1','TWO','THREE','1','','']) > > it bakes with "SQL0204 - PROGNAME in LIB type *N not found. in EXEC". > > Thoughts? Is the user ID that you are using authorised to the program? Are there any exit programs on your system which could be blocking access? Have you tried the LIB/PGM naming convention? Anything else in the job log? Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From pedroni at inf.ethz.ch Fri Jun 15 14:59:13 2001 From: pedroni at inf.ethz.ch (Samuele Pedroni) Date: Fri, 15 Jun 2001 20:59:13 +0200 Subject: Inner classes References: <3b27a1aa.6747983@news.laplaza.org> <3B2A34EE.FEF14DBC@enabledventures.com> Message-ID: <3B2A5B01.1B60057A@inf.ethz.ch> I hope you know that you can do the following in jython: class StupidExample: def butAAction(self,e): .... def butBAction(sel,e): ... def __init__(self): self.butA = JButton("A",actionPerformed=self.butAAction); self.butB = JButton("B",actionPerformed=self.butBAction); or even lambdas instead of bounded methods if your code is short enough Samuele Pedroni. Glen Starchman wrote: > Paul Prescod wrote: > > In Java all of the code would have to be in a class and _onclick would > > have to be defined in *another* class (because you can't pass references > > to functions/methods). Thus you need inner classes. > > One of the most difficult (well, maybe not *difficult*, but > definitely time-consuming) things in converting Java classes to > Jython (or Python) classes is that bastard of all Java features: the > anonymous inner class. Given code that looks like: > > class StupidExample > { > StupidExample() > { > JButton button = new JButton("Dumb Button"); > button.addActionListener(new ActionListener() > { > actionPerformed(event e) > { > doSomething(); > ... > } > } > } > } > > What happens if you decide to add another button that has similar > functionality? In this case, you end up writing yet another > anonymous inner class. Icky. > > So, in Jython, what I do is either implement ActionListener in the > parent class, and write a multi-purpose handler, or write a second > class for the handler: > > class StupidExample(ActionListener): > def __init__(self): > self.button = JButton("Dumb Button") > self.button.addActionListener(self) > > def actionPerformed(e): > if e.getSource==self.button: > doSomething() > ... > > Now, after typing all of that I have forgotten my point... oh, > yeah... Inner Classes (and *especially* Anonymous Inner Classes) > suck. > > > > > In some languages without first-class classes, you hack classes through > > function "closures". In languages without first-class functions, you > > hack functions through "one-method classes". Python has both and you > > don't have to hack! > > Hurray for Python! > > > -- > > Take a recipe. Leave a recipe. > > Python Cookbook! http://www.ActiveState.com/pythoncookbook From rob at ZOOstation.cc Thu Jun 7 04:32:06 2001 From: rob at ZOOstation.cc (Rob Brown-Bayliss) Date: 07 Jun 2001 20:32:06 +1200 Subject: HTML Widget Message-ID: <991902727.28037.1.camel@ZOOstation.cc> Hi I am looking for a workable html widget for Python useing Pygtk. I have tried pygme (for embeding mozilla) and this did work, but after upgrading to mozilla 0.9 it has died. I spent several hours downgrading mozilla to 0.81, but now it just segfaults. Is ther a binding for gtkhtml? -- Rob Brown-Bayliss ---======o======--- www.ZOOstation.cc From m.faassen at vet.uu.nl Fri Jun 1 01:52:07 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 1 Jun 2001 05:52:07 GMT Subject: Why isn't Python king of the hill? References: Message-ID: <9f7ai7$b4e$1@newshost.accu.uu.nl> Geoffrey Gerrietts wrote: > I've spent a lot of time trying to come up with a response to > Martijn's comments and questions. I didn't realize just a few of my curious questions would have this effect. I'm interested in scalability issues, as I hope to be running into them eventually. (yeah, I meant that; if I run into them that means business is going well :). > It's taken me more time than I > thought it would. My first cut was approaching a novel in length. > I'm going to try to restrain myself to the salient points this > time. (Still didn't do all that good a job, did I?) Read with interest. > Martijn writes: >> [ deletia ] >> How does Zope's ZEO fit in this picture? I would think it'd >> help scale a Python app across a lot of boxes, right? Zope of >> course has a persistence toolkit; the ZODB. RPC mechanisms >> exist for Zope as well; for instance XML-RPC. How were these >> not satisfactory? > We use ZEO to centralize our actual Zope objects. Business > objects, the core of our dynamic model, are managed outside Zope. > In Zope, we have images and DTML content, with a few wrapper > objects around external entities. We use an authentication scheme > that uses Zope's ACL mechanisms but stores user records in a SQL > database. How does Zope interact with the business objects? Through external methods? > I've looked at ZODB and ZEO some for my personal edification. If > I'm not mistaken, they provide a great mechanism for object > persistence with key-based retrieval. My evaluation suggested > that ZODB and ZEO were not very good at handling arbitrary > retrieval, or even retrieval at the level of a SQL select > statement. What do you mean with 'arbitrary retrieval'? I agree SQL select-like retrieval still isn't doable very well with the ZODB; the relational paradigm does well here, and accomplishing this kind of thing with the ZODB seems to be difficult. The ZCatalog can help here, and the underlying BTree implementation has been rewritten to decrease some bottlenecks recently, but my experience with it is extremely limited; I can't 'think' Catalog yet when I think about my problems. > I don't think we should expect them to do that, but > that's a very real requirement for much or most business data. Agreed; the ZODB isn't good at lots of writes either, and its paradigm is so different from the relational one a relational style application shouldn't be written in it. There may be other approaches with the ZODB to accomplish the same things, but I rather like the data being in a relational database, and don't feel up to too much experimenting with critical data. Eventually the ZODB may get there and I'll be watching it. Also interesting is recent thought going into improved integration of Zope with relational databases. > I don't know a whole lot about Zope and XML-RPC. I've read bits > and pieces on one site or another. It looks pretty easy to use > when Zope is your XML-RPC server, and it looks pretty easy to use > when you're on the client end of an XML-RPC call. I've played with this a bit and it's pretty trivial; almost the same as calling into the ZODB directly, though with some important limitations (I believe XML-RPC can't do very much with objects, such as object parameters). SOAP will also be interesting in this area, but I don't think Zope speaks this yet and I haven't played with it. > Developing a > server seems only slightly more complicated, and looks to be > something that could be automated or abstracted fairly readily. > We use ILU in the place where XML-RPC would be. I honestly can't > give you a compare-contrast as to how the two crack up against > one another, or why we picked ILU. I suspect that we use ILU > because it was available and mature when the site was being > pulled together. Maybe one of the original architects had some > good reusable code generation tools to use with ILU. > I think our deployment benefits from ILU's directory-based > approach. An ILU server publishes where it's running so that > clients can connect to it; that adds a little fault-tolerance and > scalability to the design. On the other hand, ILU's pretty rigid > about a lot of things, so in a few specific spots in our > application, we've sacrificed some of the freedoms that generally > come with programming in Python. I suppose this could be somewhat comparable with running CORBA servers, right? I don't have much experience in this area, though I'm very curious to hear more about how you integrate Zope with this. > Now I've answered the questions (I think fairly), but I'd like to > take a step back and re-frame my comments. > I like Python and I like programming in Python. I took this job > because I would get to program in Python. Some of my peers don't > share my enthusiasm, which is a shame, but I think they're > learning to appreciate it. > When I think about designing a webapp, though, I don't think > about an app like the one I'm working on now. I think about an > app I worked on a couple years back, one that really deserved to > be a webapp but wasn't. > That app ran out of an office of a half-dozen fairly tech-savvy > librarians. They knew web stuff, but did not know programming. > They had to hire consultants to develop for them, and hire > consultants to do system administration for them. > When I think about designing a webapp, this is the webapp I think > about -- the one I never got to write. For the last year or year > and a half, that mental design has been done in Java. In moments > of weakness, I think that I could get away with using Jython, but > in the end I come back to straight Java. The Java toolkit won't > make development any faster, but it does have other compelling > features. > Some of the features are either lacking or hidden to my limited > vision in Python, notably decimal math and PDF generation. Python has reportlab for PDF, which seems to work pretty well: http://www.reportlab.com I believe there's a PEP about introducing decimal math into the Python core as the default behavior eventually; there's a thread elsewhere on the newsgroup. I'm not very familiar with these issues, though. Do you need decimal math to avoid the subtle rounding errors and such inherent in floats, when doing currency calculations and such? > There's a certain draw to being able to take a single webapp and > deploy it on any of a dozen different app servers that know how > to handle the content, though it's small. What do you mean by this, exactly? Are you referring to the whole Enterprise JavaBeans framework (sorry if I confuse any of the terminology here) that's been implemented by various vendors? I've always been skeptical about how well that actually works, but here I'm skeptical without any actual real knowledge. :) > But the biggest draw is > that someone who's proficient with Java is not too hard to find. Are you sure about this? I mean, sure, lots of people are being cranked out that can use Java to a certain extent, but is it really true that it's not hard to find someone *good* at it? > Someone who's proficient with Python is considerably harder to > lay hands on. But I'd think that anyone who's actually good at Java would be retrainable to use Python in a matter of days. I was okay with C++ and various other languages at the time, and picked it up in no time, and from what I've read here over the years I'm sure my story isn't the only one. I'll grant you the use of Zope may be different. :) Then again, I may be too skeptical about this; I've seen a non-programmer but web-savvy person go from absolutely no Zope *or* Python *or* SQL knowledge last october to maintaining and extending a web app I wrote back then, right now. He's fiddling with the DTML, adding stuff here and there. He's added a bit of SQL too, and knows how to exploit acquisition. He's now moving into bits of Python. There's a lot he doesn't understand yet, but he sure is effective. I wonder if that's a purely isolated case or if this happens more often. I've seen something similar happen with a few others though (though they did have more programming experience), so Zope may not be as confounding as think. :) > Furthermore, while performance isn't a huge deal to those folks, > their app did show signs of growing to cover a lot more terrain. > It's conceivable that once the app was turned loose, it really > would need to worry about the kind of massive load that starts to > show off Python's seams. Are Java's seams that much tighter? I know it's faster, on average, though it does seem to consume oodles of memory. And then there's the question about closing the seams; it would seem to me that this would be easier to do in Python in many situations, because it's just a lot more flexible. > I think that part of the issue here is that when I think about a > webapp, I don't think about an app that will be written and won't > change. I don't think about working on the same app for the rest > of my life, or even for more than a couple years. And I think > about something that's continually growing, and I plan as if it > will be as cool to the rest of the world as I think it is. Any larger app will have to grow and change over time, so I consider this as well for my Zope/Python/relational database apps, which is why I'm interested in your ideas about what makes Java more suitable for these purposes. Not so I can go and use Java, but for stealing some ideas. :) > For more modest ambitions, the factors that weigh heavy on me may > seem irrelevant or even overweening. :) Many people are using Python for rather less modest ambitions, however. I'm certainly planning to. :) > Meanwhile, I'll build all > my administration tools, glue apps, and prototypes in Python. :) Good! Thanks for the interesting posting, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From chrishbarker at home.net Mon Jun 11 20:05:00 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 11 Jun 2001 17:05:00 -0700 Subject: Global in multiple files References: Message-ID: <3B255CAC.E373C5B7@home.net> > (Ruby seems elegant, also I spare some finger-gimnastics when > I have to change indentation of a whole function only because I > added one condition etc.) get yourself an editor that is Python-aware (Emacs, PythonWin, Scite, etc.). It will let you increase or decrease the indentation of a block of code easily. Then you will be spared the finger gymnastics of typing all those darn braces and semicolons! > (BTW I would like to thank other people for pointing out the > possibility of having global.py module etc. Yes, it solves my > problem for now, but maybe I should really redesign it as Roman > suggest to eliminate the need. No, I still don't know how :)) Maybe, but the idea of a module as a storage place for an assortment of data that you want to access from lots of places is a good one. Those FORTRAN common blocks were good for something, you know! Just be careful about over-using it. I tend to reserve it for things that are only set once, and then only read by various other modules later, if a piece of data is being changed by a lot of different modules, it may not belong there. As far a OO design is concerned, a module used in this way is very much like a class with only one instance. It's just a little less code. IN fact, it may make sense to put accessor functions in your globals module, like: globals.getUserList() rather than explicity accessing the global value itself. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From emile at fenx.com Sun Jun 10 10:20:52 2001 From: emile at fenx.com (Emile van Sebille) Date: Sun, 10 Jun 2001 07:20:52 -0700 Subject: New guy question References: Message-ID: <9g000o$6g7e9$1@ID-11957.news.dfncis.de> Well, try this then: Get into Idle - from the File dropdown menu select new window. In the new window type in: print "Hello World! In the new window, from the File dropdown menu select Save As then enter the file name as test.py. With the new window (now renamed test.py) selected, hit the F5 key - this runs the script and in the Python Shell window you should see the words: Hello World! You'll still need to learn how to either navigate to python.exe's home directory, add to your environment's path, or otherwise register .py scripts, but at least you'll be able to see python do something and save your experiments. HTH, -- Emile van Sebille emile at fenx.com --------- "Glen Mettler" wrote in message news:PjKU6.130094$I5.33796922 at news1.rdc1.tn.home.com... > I forgot to ask - what is the purpose of the Python window and the Python > Shell window? > > Can I NOT run a series of scripts from these windows? Must I go to the DOS > window to check my program? > > Glen > > "Glen Mettler" wrote in message > news:TiyU6.127784$I5.32725119 at news1.rdc1.tn.home.com... > > I have a small script I entered from a Python book that works when I run > it > > using F5. > > However, when I go to the console and enter python alook.py, I get an > error > > message: > > > > >>> python alook.py > > SyntaxError: invalid syntax > > > > I am too new to this to know why. > > > > Glen > > > > > > From tyler at tylereaves.com Thu Jun 21 07:25:48 2001 From: tyler at tylereaves.com (Tyler Eaves) Date: Thu, 21 Jun 2001 11:25:48 GMT Subject: String --> int References: <9gsl08$gsl$1@wanadoo.fr> Message-ID: On Thu, 21 Jun 2001 13:17:55 +0200, "Romain Guy" wrote: > Assuming fsock is a File objet, when I do: >var = fsock.read(4) >I get a String. I'd like to convert it into an integer. I haven't found any >method for this so I built this one: > >def _buildInteger(bytes): > if len(bytes) != 4: > return -1 > else: > return ord(bytes[0]) | ord(bytes[1]) << 8 | ord(bytes[2]) << 16 | >ord(bytes[3]) << 24 > >It works perfectly but I'd like to use one internal to Python if possible... I hare to tell ya this, but try int(strg) From grante at visi.com Mon Jun 11 14:01:47 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 11 Jun 2001 18:01:47 GMT Subject: 1.5.2, COM, Unicode Message-ID: I recently moved my MAPI mail-fetcher from Win95/Python-1.5.2 to Win2K/Python-2.1. After the move, I noticed that I had problems when I received e-mails with extended characters (?, ?, ? and so on). Adding .encode('latin-1') in a couple places fixed it. I'm pretty sure I got e-mails like that before, and I was wondering what the COM support library did with them in 1.5.2. Were all of the Unicode strings in COM objects automagically converted in to latin-1 encoding? -- Grant Edwards grante Yow! Everywhere I look at I see NEGATIVITY and visi.com ASPHALT... From chapman at bioreason.com Fri Jun 8 11:22:40 2001 From: chapman at bioreason.com (Mitch Chapman) Date: Fri, 08 Jun 2001 09:22:40 -0600 Subject: Python output for Glade References: <9fdprb$3hpec$2@ID-91520.news.dfncis.de> Message-ID: <3B20EDC0.D328DE1E@bioreason.com> Rajarshi Guha wrote: > > Hi, > does anybody know of patches etc that can give me Python source for a > Glade project. I tried using glade.py but it gives a number of errors and > suggests I use libglade. Is there any docs/webpages available showing how to > use libglade? [Shameless self-promotion] The July 2001 issue of Linux Journal will have an article on using Glade/libglade with Python. You can also find a tutorial at http://www.bioreason.com/~brian/GladeBase.html I know Russell Nelson also has a tutorial on the subject, but don't know the URL. He posted it recently, so a search at www.deja.com should turn it up. -- Mitch Chapman Mitch.Chapman at bioreason.com From davygrvy at pobox.com Fri Jun 1 18:47:52 2001 From: davygrvy at pobox.com (David Gravereaux) Date: Fri, 01 Jun 2001 15:47:52 -0700 Subject: crossing boundaries into Tcl References: Message-ID: "Pete Shinners" wrote: > >"David Gravereaux" wrote >> % $i eval {_} >> python0: Traceback (most recent call last): >> File "", line 1, in ? >> NameError: name '_' is not defined > >hey david. welcome to python. the problem here is that the magic >"_" underscore variable is not part of the actual python language, >it is just a little shortcut the interactive interpreter adds >to represent the last result. > >unfortunately i know not enough about python in tcl to know >how to handle the situation, good luck Thanks, I'm trying. I tried calling PyRun_String() with Py_single_input for the start token, and it looked like it was working at first, but the result was printed to stdout rather than returned as the return value. The PyObject* in the return always say 'None', which I think means "no errors"... Is there a start token that can return the value of the last operation? There must be somewhere. The result of an eval is such a central concept to Tcl that I find it strange that it's missing in other interpreted languages. Tcl_Interp *interp; interp = Tcl_CreateInterp(); Tcl_Init(interp); Tcl_Eval(interp, "pwd"); printf("Your current working directory is %s", interp->result); What's the same concept when using python embedded? How do you get the result of an operation as a char*? -- David Gravereaux From aleaxit at yahoo.com Thu Jun 14 15:57:05 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 21:57:05 +0200 Subject: Python, Unicode, l8n and i18n References: <9gajd9$8ft$3@216.39.170.247> Message-ID: <9gb4vh0t22@enews1.newsguy.com> "David LeBlanc" wrote in message news:9gajd9$8ft$3 at 216.39.170.247... ... > Has anyone taken a look at using the International Components for Unicode > with/as part of Python: As ICU uses C++ (albeit minimally) I don't think it can become a part of Python (Python being firmly wedded to C). *Using* it is another matter -- as I understand, it *does* have a C-callable interface (have not looked at it in detail, yet) -- and anyway it could no doubt be wrapped e.g. with Boost Python, CXX, or maybe even Swig. It DOES appear VERY interesting if one has difficult internationalization needs (collation, calendar, currency, ...)! Alex From mal at lemburg.com Tue Jun 19 15:45:34 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 19 Jun 2001 21:45:34 +0200 Subject: Comprehensive Python Archive Network References: <87n1762ddv.fsf@penguin.aktivist.ru> <87iths2zjg.fsf@penguin.aktivist.ru> Message-ID: <3B2FABDE.B8DE326B@lemburg.com> Wartan Hachaturow wrote: > > >>>>> "mal" == mal writes: > > mal> AFAIK, ActiveState will contribute its PPM tools back to Python, so > mal> those may become what we all have been dreaming of the last few years > mal> ;-) > > BTW, I've got one crazy idea.. What if we would come in contact > with CPAN people, and would just adopt current CPAN to store python > modules? > We would at least have Web-interface ready, and we would have to > only write modules to download modules and install modules. Don't know whether the Perl people would like this... but yes, this idea would of course go a loooong way. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From MarkH at ActiveState.com Sat Jun 23 23:22:12 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sun, 24 Jun 2001 03:22:12 GMT Subject: win32 extension installation problem References: Message-ID: <3B355CE8.8060605@ActiveState.com> zihonglu wrote: > We are building a product with python and the win32 extension, in win32 > environment. I have a problem in shipping the product with win32 extension. > > What I really want is to have the python interpreter and the win32 extension > installed inside our product's directory, say c:\MySoftware\Python, and in > the registry, set python's keys under HKLM\Software\MySoftware\Python, > instead of the typical HKLM\Software\Python, to avoid conflict with > customer's possible existing python installation or possible future python > installation change. I can achieve that by change python's source code to > look for the new registry key. The best solution is to change Python's view of the core registry key. The default Python registry key is HKLM\Software\Python\PythonCore\{version-id} This {version-id} is loaded from the Python.dll string resource table. You can open Python.dll in MSVC (ie, the pre-built version - no need to rebuild anything) and locate the one-and-only string resource. This will say, eg, "2.1". Hence the registry used for 2.1 is: HKLM\Software\Python\PythonCore\2.1 You can change this to any value you like (numeric or otherwise). This will change the registry key used by that DLL. FYI, this value is reflected into Python as sys.winver - however, you can not simply change it at runtime, as the value has already been used by the time you get your first opportunity to change it. So, although you can not simply change the "root" of the registry, changing this version string will give you your own playground that will not affect pre-installed versions. > However, since I am also using the win32 > extension, it looks HKLM/Software/Python for its installation and execution, > not my new keys. I also use PythonService.exe, which checks for its key > under HKLM/Software/Python for registering the service, not the one I set > under my new keys. You probably don't want to use the win32all installer - simply install these extensions along with your software into the appropriate directories. At runtime, there is nothing hard-coded to use the version number. pythonservice.exe and all other code that needs the registry at runtime uses sys.winver to determine where to put it. Hence, pythonservice.exe running with a patched python.dll should magically do the right thing. This mechanism was added specifically for this situation, so you may as well use it. > To solve these problems, how many places I need to change the win32 > extension source code, if I can find them? Is there a better way? Where do > I get the source code? You get the source code via http://starship.python.net/crew/mhammond/cvs.html Mark. From nospam at newsranger.com Thu Jun 21 14:44:13 2001 From: nospam at newsranger.com (Norman Shelley) Date: Thu, 21 Jun 2001 18:44:13 GMT Subject: Subject: ?Numpy: number of elements in an array? Message-ID: <1grY6.4168$yp1.152397@www.newsranger.com> In Numpy how does one get the number of elements in an array? This seems to do it reduce(mul, a.shape, 1) but shouldn't there be a straight forward, function/method to do it? Norman Shelley rrdn60 at email.sps.mot.com From skip at pobox.com Tue Jun 12 11:32:11 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 12 Jun 2001 10:32:11 -0500 Subject: metaclasses -- aka Don Beaudry hook/hack In-Reply-To: References: Message-ID: <15142.13819.477491.993419@beluga.mojam.com> James> Before I head too deeply into Zope dependencies, I would be James> interested in knowing whether or not "type(MyClass) == James> types.ClassType" and "isinstance(myInstance,MyClass)" work for James> classes derived from ExtensionClass. Straight from the horse's mouth: >>> type(gtk.GtkButton) >>> type(gtk.GtkButton) == types.ClassType 0 >>> isinstance(gtk.GtkButton(), gtk.GtkButton) 1 James> (And if so, why do these work for C extension classes using the James> Don Beaudry hook but not for Python classes using the same hook?) You'll have to ask someone with more subject knowledge. (Don would probably be a good start. ;-) I've cc'd python-dev because the experts in this area are all there. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From JamesL at Lugoj.Com Thu Jun 28 12:22:50 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Thu, 28 Jun 2001 09:22:50 -0700 Subject: PEP scepticism References: <9hfg1n$du33c$1@ID-89274.news.dfncis.de> Message-ID: <3B3B59DA.35F6B71D@Lugoj.Com> Bernhard Reiter wrote: > > This a general warning against the second system syndrom in Python. [ Elided. ] Thank you, Bernhard. I agree with your unease. From thys at netsys.co.za Wed Jun 20 04:31:25 2001 From: thys at netsys.co.za (Thys Meintjes) Date: Wed, 20 Jun 2001 10:31:25 +0200 Subject: Text Widget toolkit In-Reply-To: <20010616111538.A1585@proxy.dsf> References: <20010616111538.A1585@proxy.dsf> Message-ID: <01062010312501.07399@klip.boereplaas> curses >>> from curses import * >>> dir() ['ALL_MOUSE_EVENTS', 'A_ALTCHARSET', 'A_ATTRIBUTES', 'A_BLINK', 'A_BOLD', etc. If you've worked with curses/ncurses before you should be on your way. The python src's /demo dir has a few curses examples. On Sat 16 Jun 01 07:45, proxy wrote: > Hi! > > I am looking at a text widget toolkit for use in console applications. > I took a look at the anaconda sources which revealed that they were using > snack as their toolkit. Snack as I am told is a wrapper around Newt. Now > Newt had been considered an "unstable" interface by some folks. > > My question is : What are the various python text based toolkits available? > > TIA, > Sandip From philh at comuno.freeserve.co.uk Mon Jun 4 06:32:15 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Mon, 4 Jun 2001 11:32:15 +0100 Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> Message-ID: On Mon, 04 Jun 2001 03:07:30 GMT, Brett g Porter wrote: > >"Harald Hanche-Olsen" wrote in message >news:pcolmn9y349.fsf at thoth.home... >> + Tim Churches : >> >> | No experience (I am in a similar situation to you wrt UML), just >> | some advice: don't buy the O'Reilly book 'UML in a Nutshell' - it is >> | the only O'Reilly title I have encountered which is truly woeful >> | (most are quite good). >> >> Hmm. Has it occured to you that this might be a reflection on UML >> rather than on the book per se? > >Don't know about that -- I bought it (unseen) a week or so ago since I've >never had bad luck with a book from O'Reilly. Until now. > >Now, I enjoy reading dense prose. But this is one of those books where I >know less after reading a page than I did beforehand. It's about as clear as >postmodern literary criticism. > >This is not a book for reading, this is a book for lying down and avoiding. I agree with these comments. The O'Reilly UML book isn't good. -- ## Philip Hunt ## ## philh at comuno.freeserve.co.uk ## From Achim.Gaedk at zpr.uni-koeln.de Sat Jun 16 10:01:14 2001 From: Achim.Gaedk at zpr.uni-koeln.de (Achim Gaedke) Date: Sat, 16 Jun 2001 16:01:14 +0200 Subject: Bug in expatreader... References: Message-ID: <3B2B66AA.1357872C@zpr.uni-koeln.de> (I like responding myself much...) Here is a workaround for the missing functionality of parser.setContentHandler(handler): parser._parser.CharacterDataHandler=handler.characters This line is taken from xml.sax.expatreader.ExpatReader.reset() This does work after parser.reset() or after parser.parse(...) is called once (because parse() calls reset()). I think this error should be corrected somewhere else, but I don't know where. From m.faassen at vet.uu.nl Wed Jun 6 17:56:02 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 6 Jun 2001 21:56:02 GMT Subject: Learning OOP... References: Message-ID: <9fm8ti$d92$1@newshost.accu.uu.nl> Rod Weston wrote: > Trying to decide which language to learn first. I have programming > experience in PICKBASIC and now want to learn OOP.At this point, I am > leaning toward learning Ada and then Python. Any ideas on why I > should or should not use these languages in this sequence? Why do you want to learn these languages? What problems are you looking to solve and why do you think those languages would be most suitable? If your interest is mostly to learn more about programming (among other things OO), then you may be best starting out with Python. Python is probably an easier language for beginners than Ada is. I would also think Python's support for OO is better than Ada's. Python's dynamicity may make you familiar with OO concepts faster than a statically typed language like Ada could, as it leaves more room to experiment and you need to spend less time working to please the language in order to do what you want to do. That said, Ada will also help you learn some new concepts (like static typing, for one. I don't know if PICKBASIC has such a thing). I'm not overly familiar with Ada except the broad classication the language fits in, so I can't help you more there. Good luck, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From Brianmce at bigfoot.com Tue Jun 26 06:40:02 2001 From: Brianmce at bigfoot.com (Brian McErlean) Date: Tue, 26 Jun 2001 10:40:02 GMT Subject: Is this a true statement? References: <8NuZ6.362378$oc7.42924874@news2.rdc2.tx.home.com> <3B3788A2.3BD1D672@tundraware.com> <9qMZ6.368197$oc7.44797813@news2.rdc2.tx.home.com> <3B37A15D.DF05A331@tundraware.com> Message-ID: <3b386603.106141042@news> On 25 Jun 2001 20:40:02 GMT, Tim Daneliuk wrote: >Rainer Deyke wrote: >> > > >> > I still do not understand/agree with this line of reasoning entirely. >> >> Your reasoning is flawed. > >Perhaps, but thus far, I've only seen assertion to that effect, not proof. > > >> >> Interaction with the outside world is, by definition, *not* algorithmic. > > >Nope. All computational activity is algorithmic. The thing >that *causes* the input to be what it is may- or may not be >guided by algorithm but insofar as a program sees input, it is >algorithmic by nature. "Input" can be subtle. It can be >a numeric value, a keystroke, the closing of a switch in a >mechanical device, or simply a measure of time, but all these >are meaningless (in our context) without algorithmic processing. Output is not the same as computational ability. The interfaces with which a program can output and interact with its environment have no effect on its computational power. Postscript is turing complete, but can't even access files. Java is turing complete, and remains so when you limit what it can access through its security model. > >> Consider this diagram of a typical computer program: >> >> Input -> Computation -> Output >> >> Only the "computation" part is algorithmic, and those who use the term >> "Turing complete" generally only concern themselves with the computation > >Nope. Formally, an "algorithm" is something which when presented with >a given set of inputs will always produce the same output. (This, BTW, >is why Genetic Algorithms are a contentious case because given a particular >input, a GA will NOT give the same results repeatably.) So, by the >very definition of what an algorithm is and does, it embraces the notion >of both input and output. No - the input to the genetic algorithm is the entire input since the start of the program. That its performance has changed after some input is irrelevant - if you go back to the same initial state and give it the same input, it will act exactly the same (It can't do anything else - after all it is running on a deterministic finite state machine.) >> All computer programs are deterministic. Any computer program that > >Nope. Not even close to true. The entire family of NP-Complete algorithms >(Traveling Salesman, Knapsack Packing, et al) are NON-deterministic (that's >what the 'N' stands for. This is incorrect. There is no such thing as an NP-Complete algorithm, you mean NPC _problems_. This simply means that there is no (currently known) deterministic algorithm that can solve the problem in polynomial time. The non-deterministic part refers to the fact that it _is_ possible to check whether a proposed solution is in fact correct, and so if you have a non-deterministic step that 'guesses' a solution, or you check all possible solutions in paralell, then you can potentially solve it in polynomial time. The checking algorithm is still deterministic. The NP part only refers to the time complexity of the problem, not the algorithm. The problems are completely solvable with normal algorithms - they just take a long time. >> > 2) Have Python write out a set of machine code bits which >> > are understood by the underlying implementation and >> > hardware to be the correct handling of an interrupt. Actually, I don't think this is a valid solution to the problem. If you define "writing a device driver in python" as equivalent to "writing a program in python that writes a device driver", then you violate the "purely in python" bit, because you're also writing it in C ( because the python interpreter is written in C, and it wrote/interprets a program (with your python program as input) that wrote the program that generated the device driver ;-) >> >> Only if the system has a writeable disk with sufficient empty space. This >> is not a given. > >Well no it's not, but this is irrelevant to the discussion. Clearly, some >implementations of any algorithm are more time/space efficient - Bubble >Sorts run in O(n^2) but Heap Sorts run in O(n log n) yet both are still >just sorting. The limitations of disk, memory, and CPU merely define >how big a problem we can solve, or how fast we can solve it, not *how many* >different kinds of problems we can solve, which is the debate here. This is really a nitpick, but limitations of memory etc do define what type of problems we can solve. You can't do anything on a machine with no memory. The reason is that computers aren't really turing machines, they are finite state machines. For a reasonable amount of memory they do approximate turing completeness for most problems. > >For example, a machine with limited disk space can solve the same *set* of >problems as a machine with Terabytes of disk, just much slower and less >efficiently. The minimums necessary to compute everything which is >computable were defined initially by Turing and later by Bohm and >Jacopini and in no case was disk space, memory space, or CPU speed >a foundational condition. As I said, these real-world constraints >speak to how fast or how efficiently we can run a given algorithm, >not how many *different* kinds of algorithms we can do. Turing does state that a certain amount of memory is needed to compute anything. A turing machine has to have infinite memory in some form (eg. the standard infinite tape.) There are some problems that can't be solved with a mere finite number of states. > >> >> > 3) Add a native interrupt object to the language. >> > >> > 1) clearly takes us out of "pure Python" and is thus of no further >> > interest (unless you actually want to *solve* this problem in the >> > real world, in which case this is probably the best solution ;))) >> > >> > 2) Works just fine, but is kind of clumsy and unnatural to use. >> > Note, however, that it is 2) that gives us the ability to do *anything* >> > in Python which we can "do" in any other Turing-Complete language. >> > >> > 3) is where the rocks start to get thrown. If I do 3), have I "extended" >> > the language to do something it could not previously? NO! I have >> > implemented what I could already do with 2) in a more programmer-friendly >> > manner, but I have not changed the net computational power of the >> language. But I don't think you can define the language as "anything it might do at some future point in time, after I've added something." If I add the complete possible C interfaces to postscript, I don't think I can call it postscript anymore, (unless I want a lawsuit whenever someone views a document that formats his hard drive). If by "Python" you are referring to all possible future implementations of the language, then this is true, but you can still say "There are things possible in implementation of C, that are not possible with the standard distribution of python 2.1" >> >> "Net computational power" is irrelevant in this context. > >If you say so. I thought this was the exact point of the debate: Can C++ >and Python "do" the same things. i.e., Do they possess equivalent abilities >to compute the same set of problems - Computational Power. > They do posess equivalent computational power, but they can't do the same things, because C defines certain interfaces that python doesn't. -- Brian McErlean From carlf at panix.com Tue Jun 19 22:47:16 2001 From: carlf at panix.com (Carl Fink) Date: 20 Jun 2001 02:47:16 GMT Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: <3B2EACF5.1D10252D@earthlink.net> Message-ID: In article <3B2EACF5.1D10252D at earthlink.net>, Ron Stephens wrote: > Anyway, by my count 7 people have expressed some sort of interest in a > HyperCard-like gui creator, since it was first mentioned yesterday by Roman I'm a fairly experienced Asymetrix ToolBook developer. TB's scripting language is OpenScript, which seems to be HyperCard on steroids. I'm very interested. If I ever learn enough Python, I would certainly contribute. I see it as having a *development environment* similar to ToolBook -- that is, the running interpreter loads and dynamically runs the components of the program being worked on. There's also an "immediate window" in which code snippets can be directly typed and executed. A really good help system would be a must (and might be where I could make a direct contribution, if only *because* I'm a Python tyro and can see it from a beginner's viewpoint). The scripting language should definitely be Python. Event handling should be HyperCard/ToolBook-like. Each object (in the sense of something you draw in the GUI painter) should have its own event handlers, scripted in a property of that object. For instance, a button would have a script property "on buttonClick" script defining what to do when a single-first-mouse-button-click event is received. The runtime should be Python itself, not some special library. There should be the ability to package up any addons, though. -- Carl Fink carlf at dm.net I-Con's Science and Technology Programming From scarblac at pino.selwerd.nl Fri Jun 1 01:26:37 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 1 Jun 2001 05:26:37 GMT Subject: 2.1 strangness References: <9f5s61$t89$1@slb5.atl.mindspring.net> Message-ID: Andreas Jung wrote in comp.lang.python: > > "Robin Becker" schrieb im Newsbeitrag > news:lCoIXKAB3mF7Ew5A at jessikat.demon.co.uk... > > This is a condensation of some weirds I'm seeing with M2Crypto which I > > downloaded today; I'm running SF 2.1 for win32 > > > > ################################## > > #file ttt.py > > from httplib import * > > > > class Bongo(HTTPConnection): > > pass > > ################################## > > > > when I attempt to run this > > > > C:\Python\devel\m2crypto-0.06-snap5-win32\demo\ssl>python \tmp\ttt.py > > Traceback (most recent call last): > > File "\tmp\ttt.py", line 3, in ? > > class Bongo(HTTPConnection): > > NameError: name 'HTTPConnection' is not defined > > > > but certainly httplib has a class HTTPConnection > > > > is this the famous blow up in your face from the future concerning > > shadowed globals? It seems rather nasty to me, but then I objected to > > the original static scoping stuff. This seems entirely module level so > > what gives? > > Your "from httplib import *" is the problem. Since Python 2.1 (?) only > elements definied in module.__all__ will be imported by 'import *'. If module.__all__ is defined. If it's not, you get the old behaviour (just clarifying). > httplib.__all__ is ['HTTP']. If you look at the library reference, all the module does is define the HTTP class anyway. The rest is implementation detail that may change, apparently. On the other hand, it's irritating that things that used to be imported with a 'from import *' aren't anymore. The old mechanism was that names that shouldn't be imported had prefix _; there are a few of those in httplib. Why does it suddenly have an __all__ that contains only HTTP? -- Remco Gerlich From aahz at panix.com Mon Jun 4 11:20:03 2001 From: aahz at panix.com (Aahz Maruch) Date: 4 Jun 2001 08:20:03 -0700 Subject: Python as REXX replacement? References: Message-ID: <9fg8v3$bn9$1@panix3.panix.com> In article , Scherer, Bill wrote: > >IBM has ported Python v1.4. see: >http://www-1.ibm.com/servers/eserver/zseries/zos/unix/python.html That doesn't appear to be particularly helpful. While programs written under Python 1.4 will be mostly forward-compatible, there have been a lot of changes that are *not* backward-compatible. More than that, this runs under the IBM "Unix services", not under VM or MVS. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 I surf faster than you do, monkey boy. (My take on Netscape vs. Lynx) From schorsch at schorsch.com Thu Jun 7 12:13:02 2001 From: schorsch at schorsch.com (Georg Mischler) Date: Thu, 7 Jun 2001 18:13:02 +0200 Subject: Numeric Programming for Everybody References: Message-ID: <9fo98s$bui$03$1@news.t-online.com> Don Dwiggins wrote: > Where speed and/or size is an issue, the more sophisticated programmer > will move to integer, rational, or floating point, as appropriate (and of > course, the documentation will include -- or point to -- descriptions of > the consequences of the choice). Maybe, maybe not... I just noticed the following on an invoice I have to pay: stuff 30,00 more stuff 30,00 --------- 59,99 + 16,00 % VAT 9,60 --------- 69,59 Obviously, some programmer decided on granting me a rebate of one german Pfennig. This is from a publishing company, which probably bills tens of thousands of seperate customers for the entry lines in trade fair catalogs each year. Guess that programmer will have to skip a few coffe breaks to make up for the losses summing up that way... Have fun! -schorsch -- Georg Mischler -- simulations developer -- schorsch at schorsch.com +schorsch.com+ -- Lighting Design Tools -- http://www.schorsch.com/ From tom at peresys.co.za Thu Jun 14 10:38:47 2001 From: tom at peresys.co.za (Tomasz Stochmal) Date: 14 Jun 2001 07:38:47 -0700 Subject: substitute for c/java's ?: References: <9g5fc4$m8u$01$1@news.t-online.com> Message-ID: > 1. (most important) > I am missing something like the c/Java ?: operator. This is so convenient in > many places and saves a lot of typing. > It works like > result = option ? value1 : value2; > which is equivalent to > if option: > result = value1 > else: > resultl = value2 > > Is there anything I overlooked? I use this function I wrote: def iif(Condition,ValueTrue,ValueFalse): if Condition: return ValueTrue else: return ValueFalse Example on in-line if: result=iif(option,value1,value2) From jcollins at boulder.net Thu Jun 21 21:24:56 2001 From: jcollins at boulder.net (Jeffery D. Collins) Date: Thu, 21 Jun 2001 19:24:56 -0600 Subject: Anyone used Pippy? In-Reply-To: <5.0.2.1.0.20010620223911.026d64a0@mail.inet.com.br>; from cribeiro@mail.inet.com.br on Wed, Jun 20, 2001 at 10:41:52PM -0300 References: <5.0.2.1.0.20010620223911.026d64a0@mail.inet.com.br> Message-ID: <20010621192456.B1084@boulder.net> The pippy web site has been updated. The latest release contains mostly speed and memory usage improvements, and there is now an experimental module for importing modules from the memo pad. On Wed, Jun 20, 2001 at 10:41:52PM -0300, Carlos Ribeiro wrote: > I've installed Pippy on my Palm IIIxe some time ago. I found it to be a > nice toy, just that, mainly because of how difficult is to download Python > scripts into the Palm. As of now you have to build Pippy with the scripts > you want to run, and this is not exactly easy to do. As someone else > pointed out on the list today (on another topic), we're just too lazy - > there must be a convenient way to make it. If I only had time... > > > Carlos Ribeiro -- Jeffery Collins (http://www.boulder.net/~jcollins) From mal at egenix.com Sat Jun 30 07:52:38 2001 From: mal at egenix.com (M.-A. Lemburg) Date: Sat, 30 Jun 2001 13:52:38 +0200 Subject: [Python-Dev] Support for "wide" Unicode characters References: <3B3BEF21.63411C4C@ActiveState.com> <3B3C95D8.518E5175@egenix.com> <3B3D2869.5C1DDCF1@ActiveState.com> Message-ID: <3B3DBD86.81F80D06@egenix.com> Paul Prescod wrote: > > "M.-A. Lemburg" wrote: > > > >... > > > > I'd suggest not to use the term character in this PEP at all; > > this is also what Mark Davis recommends in his paper on Unicode. > > That's fine, but Python does have a concept of character and I'm going > to use the term character for discussing these. The term "character" in Python should really only be used for the 8-bit strings. In Unicode a "character" can mean any of: """ Unfortunately the term character is vastly overloaded. At various times people can use it to mean any of these things: - An image on paper (glyph) - What an end-user thinks of as a character (grapheme) - What a character encoding standard encodes (code point) - A memory storage unit in a character encoding (code unit) Because of this, ironically, it is best to avoid the use of the term character entirely when discussing character encodings, and stick to the term code point. """ Taken from Mark Davis' paper: http://www-106.ibm.com/developerworks/unicode/library/utfencodingforms/ > > Also, a link to the Unicode glossary would be a good thing. > > Funny how these little PEPs grow... Is that a problem ? The Unicode glossary is very useful in providing a common base for understanding the different terms and tries very hard to avoid ambiguity in meaning. This discussion is partly caused by exactly these different understanding of the terms used in the PEP. I will update the Unicode PEP to the Unicode terminology too. > >... > > Why not make the codec used by Python to convert Unicode > > literals to Unicode strings an option just like the default > > encoding ? > > > > That way we could have a version of the unicode-escape codec > > which supports surrogates and one which doesn't. > > Adding more and more knobs to tweak just adds up to Python code being > non-portable from one machine to another. Not necessarily so; I'll write a more precise spec next week. The idea is to put the codec information into the Python source code, so that it is bound to the literals that way with the result of the Python source code being portable across platforms. Currently this is just an idea and still have to check how far this can go... > > > ISSUE: Should Python allow the construction of characters > > > that do not correspond to Unicode characters? > > > Unassigned Unicode characters should obviously be legal > > > (because they could be assigned at any time). But > > > code points above TOPCHAR are guaranteed never to > > > be used by Unicode. Should we allow access to them > > > anyhow? > > > > I wouldn't count on that last point ;-) > > > > Please note that you are mixing terms: you don't construct > > characters, you construct code points. Whether the concatenation > > of these code points makes a valid Unicode character string > > is an issue which applications and codecs have to decide. > > unichr() does not construct code points. It constructs 1-char Python > Unicode strings...also known as Python Unicode characters. > > > ... Whether the concatenation > > of these code points makes a valid Unicode character string > > is an issue which applications and codecs have to decide. > > The concatenation of true code points would *always* make a valid > Unicode string, right? It's code units that cannot be blindly > concatenated. Both wrong :-) U+D800 is a valid Unicode code point and can occur as code unit in both narrow and wide builds. Concatenating this with e.g. U+0020 will still make it a valid Unicode code point sequence (aka Unicode object), but not a valid Unicode character string (since the U+D800 is not a character). The same is true for e.g. U+FFFF. Note that the Unicode type should happily store these values, while the codecs complain. As a result and like I said above, dealing with these problems is left to the applications which use these Unicode objects. > >... > > We should provide a new module which provides a few handy > > utilities though: functions which provide code point-, > > character-, word- and line- based indexing into Unicode > > strings. > > Okay, I'll add: > > It has been proposed that there should be a module for working > with UTF-16 strings in narrow Python builds through some sort of > abstraction that handles surrogates for you. If someone wants > to implement that, it will be another PEP. Uhm, narrow builds don't support UTF-16... it's UCS-2 which is supported (basically: store everything in range(0x10000)); the codecs can map code points to surrogates, but it is solely their responsibility and the responsibility of the application using them to take care of dealing with surrogates. Also, the module will be useful for both narrow and wide builds, since the notion of an encoded character can involve multiple code points. In that sense Unicode is always a variable length encoding for characters and that's the application field of this module. Here's the adjusted text: It has been proposed that there should be a module for working with Unicode objects using character-, word- and line- based indexing. The details of the implementation is left to another PEP. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From daniel.dittmar at sap.com Fri Jun 22 08:50:20 2001 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Fri, 22 Jun 2001 14:50:20 +0200 Subject: Is this a true statement? References: <9gvb8q$ssl$1@taliesin.netcom.net.uk> Message-ID: <9gveua$9e5$1@news1.wdf.sap-ag.de> > Python can do everything C++ can do No, there are some things Python can't do (unless you count writing extensions) > but just slower. Assuming you have the time to implement all the features in C++ and it doesn't have to work reliable (you time the benchmark only once), this is true. Daniel From robin at jessikat.fsnet.co.uk Sat Jun 9 14:18:03 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sat, 9 Jun 2001 19:18:03 +0100 Subject: spell method chaining? References: <19l8IVAAgJI7EwAk@jessikat.demon.co.uk> <3B2111FF.D998EEE4@letterror.com> <3B21D830.E823D70F@letterror.com> <$6JOJKAxteI7EwQC@jessikat.fsnet.co.uk> <3B225433.11E13251@letterror.com> Message-ID: In article <3B225433.11E13251 at letterror.com>, Just van Rossum writes >Robin Becker wrote: .... > >I can't deduct from this code what on earth it's supposed to be _doing_: it's >way too >convoluted for me to parse. But I'm wondering: is subclassing really the best >solution >for the problem? Instead of painfully trying to dynamically create classes, why >don't >you use containment and delegation? As in: > >class Wrapper: > > def __init__(self, object): > self.__object = object > def __getattr__(self, name): > # this is enough for retrieving attrs, if attrs are set-able, you > # also need to need a corresponding __setattr__ and __delattr__ > return getattr(self.__object, name) > def __getitem__(self, index): > return Wrapper(self.__object[index]) # whatever > >Just well the idea is that if P is a property holding class so that p=P() p.a and p.b exist x=TPC(P) is an instance of P that also allows indexing so x[0].a and x[1].b are equivalent to x.a and x.b we can assign to indexed properties x[0].a = 3 x[1].b = 4 then x[0].a isn't identical to x.a assigning to x.a changes the 'default' value for all indexed values etc. all the code works except that there's this nasty bit of chaining of possible __getattr__ methods that could go wrong. -- Robin Becker From atodd at spam.free.email.com Tue Jun 19 21:57:12 2001 From: atodd at spam.free.email.com (Andy Todd) Date: Wed, 20 Jun 2001 01:57:12 GMT Subject: list 2 dictionary newcomer question References: Message-ID: t_messmer at yahoo.com (Tom Messmer) wrote in : >Lets say I have a list of arbitrary, but definitely even length, and I >want to convert it to a dictionary. List might look like ['/', '15', >'/proc', '100'](I'm parsing the output of df) I'd simply like to pair >'em up like {'/':'15', '/proc':'100'} I have a feeling I'm going to be >embarrassed at how easy this is, but I cant seem to figure it out. >I've seen examples on doing this with lists of lists, but not flat >lists. Any takers? >Tom My two cents, barring an automatic coercion (which I haven't looked for in the documentation - sorry) is; >>> list=['a', 1, 'b', 2, 'c', 3] >>> dict={} >>> x=len(list)-1 >>> for i in range(0,x): ... if i%2==0: ... dict[list[i]]=list[i+1] ... >>> dict {'b', 2, 'c', 3, 'a', 1} Hope that helps, Andy -- Content free posts a speciality From db3l at fitlinxx.com Wed Jun 13 22:42:34 2001 From: db3l at fitlinxx.com (David Bolen) Date: 13 Jun 2001 22:42:34 -0400 Subject: msvcrt.getch() overly receptive in idle? References: <9g5m7k$gu8$1@nntp6.u.washington.edu> <9g93c9$8ft$1@216.39.170.247> Message-ID: David LeBlanc writes: > One could certainly put in an "any key" event at the bottom of the list > of other interesting keys (or all keys and no other key events and > dispatch manually for "interesting" keystrokes and pass on the ones not > interesting to this level of the app (ctrl-c for example)). The default > action would be to pass the event on down the event chain. Alternatively, > the event is enabled and "interesting" keys are processed. Sounds right > about like a key-configurable editor would do it... This could be added > to Idle's or Pythonw's event loop easily enough, although the pythonw > route would have to be approved for inclusion by the snake wranglers > imho. It's not quite that simple. Pythonw itself doesn't have an event loop, it's just a standard interpreter compiled with options so that no console gets created upon execution. Idle does have events, for example, via Tk, but aside from translating keyboard events into actions for the UI, there's no general keypress queue ever seen as far up as an executing script (which executes in a simulated interpreter). So the event loop in question would be part of the Tk stuff in Idle (or the win32ui stuff in Pythonwin), and I'm not sure how flexible they are in terms of translating single key events into queued input to the executing Python script. Remember also that Python itself doesn't really have any single character interface for I/O ... getch() is in an MS specific wrapper module, so there aren't really any hooks in the Python interpreter loop (which things like Idle/Pythonwin use) to queue up individual keypresses from GUI events. I'm sure you could queue up characters to be seen as part of the next readline() or raw_input(), but that's not the same single-character-wait functionality. Of course, one could replace the msvcrt wrapper under the IDE environments, and for the getch() call wait around for an internal character event appropriate to the GUI in use, but its probably overkill, and re-investigating what the getch() is being used for in the first place is likely the most sensible thing to do. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From djc at object-craft.com.au Sun Jun 17 09:33:11 2001 From: djc at object-craft.com.au (Dave Cole) Date: 17 Jun 2001 23:33:11 +1000 Subject: csv-0.3 released Message-ID: I have just started fiddling around with building modules on NT so decided to convert my csv module to distutils. It seems to be working. So for all of you NT heads who were just hanging out for a fast CSV parser in Python - here it is: http://www.object-craft.com.au/projects/csv/ For people who do not have a C compiler I have put the binary up here: http://www.object-craft.com.au/projects/csv/csv.pyd - Dave -- http://www.object-craft.com.au From cmkleffner at gmx.de Thu Jun 14 11:36:09 2001 From: cmkleffner at gmx.de (cmkl) Date: 14 Jun 2001 08:36:09 -0700 Subject: statically linking the entire runtime (HPUX Python2.1) References: Message-ID: <3b091a1c.0106140736.29d55695@posting.google.com> hi, freeze.py is your friend! It lives in the source-code distribution directory: ./Tools/freeze 1) You need the python sources, you need a C compiler 2) You have to build, test and install python from source 3) Somewhere in your install directory is the static python runtime library libpythonxxx.a 4) copy the freeze directory somewhere python freeye.py -h gives some help on necessary options 5) python /whateverdir/freeze.py -o mydir -e /somedir/informixdb test.py will copy a lot of files in mydir/ - type 'make' there and you will get your pythenabled binary /somedir/informixdb in this example is a directory with additional objectfiles for C-modules (informixdb int his case) 6) If you are not happy with the Makefile, change ./lib/python2.0/config/Makefile Unfortunately python2.1 comes with 'setup.py', which will install alot of C-modules as shared library. Carl GADGIL PRASAD /INFRA/INFOTECH wrote in message news:... > hello, > > forgive me for ignorance, but I didnt know of creating a standalone exe from > a > python prog on unix, I went all the way to rewrite a python code to C prog > cause, > I needed to have a binary only. I guess, FAQ doesn't mention this. Utils I > guess > do something similar for win platforms like py2exe which I use. > > Can a easy to follow procedure be posted by the knowledgable for those not > very > proficient in handling C source compilations inolving make and whatnot. > > /prasad > > -----Original Message----- > From: Andrew MacIntyre [mailto:andymac at bullseye.apana.org.au] > Sent: Wednesday, June 13, 2001 5:30 PM > To: python-list at python.org > Subject: Re: statically linking the entire runtime (HPUX Python2.1) > > > On 12 Jun 2001, cmkl wrote: > > > On HP-UX I'm trying to build python2.1 without building the C-modules > found > > in Modules/ as shared libraries. With the Version 2.0 this was the > default. > > I played around with configure, setup.py and Modules/Setup but I always > > end up with a binary depending on various shared libraries. > > I need this, bacause I want to freeze my pythons scripts as a single > binary. > > Distribution is much easier this way. > > What is the trick to do that? > > I don't know specifically about HP-UX, but in general: > 1: uncomment the modules you want in Modules/Setup > 2: comment any "*shared*" terms in Modules/Setup > 3: don't bother with setup.py, as its only for dynload modules > > -- > Andrew I MacIntyre "These thoughts are mine alone..." > E-mail: andrew.macintyre at aba.gov.au (work) | Snail: PO Box 370 > andymac at bullseye.apana.org.au (play) | Belconnen ACT 2616 > andymac at pcug.org.au (play2) | Australia From tjenkins at devis.com Tue Jun 5 09:27:57 2001 From: tjenkins at devis.com (Tom Jenkins) Date: 5 Jun 2001 06:27:57 -0700 Subject: subclassing wxMenuBar... References: <6957F6A694B49A4096F7CFD0D900042F27DB6B@admin56.narex.com> Message-ID: <946c5a14.0106050527.4e941892@posting.google.com> Tom Jenkins wrote in message news:... > Bjorn Pettersen wrote: > > > I was stepping through the wxPython tutorial, and came across the part > > where they're creating the menus. It seemed like a good idea to put the > > menu definition in a datafile instead of specifying it programatically, > > so I though it would be a good chance to get some xml experience too... > > [snip] > > Well I wouldn't subclass wxMenuBar; instead I'd create a helper class > that would handle reading the xml and loading it into the wxMenuBar. I > took your code and changed it to work as a helper. Along the way I > added some functionality. [snip] Err... well it looks like the mailing list -> newsgroup bridge stripped out the attachment that contained the code for the helper class. So let me follow up by putting it directly in the message #---------------------------------- ''' XMLMenuLoader: Class to handle loading a wxMenuBar with menu items defined in XML author: Tom Jenkins based on code by Bjorn Pettersen #*TODO*: refactor load into base class that handles loading the menu in another way so we can have ListMenuLoader, StreamMenuLoader, etc... ''' from xml.dom import minidom from wxPython.wx import * def filterText(nodelist): return [ x for x in nodelist if x.nodeType != x.TEXT_NODE ] class XMLMenuLoader: def __init__(self, filename, wxMenuBar = None): '''Save the filename and menubar to use''' self._filename = filename self.setMenuBar(wxMenuBar) def setMenuBar(self, wxMenuBar = None): ''' set the menubar property to the given menubar wxMenuBar -> the root menubar of the frame''' self._wxMenuBar = wxMenuBar def menuBar(self): '''Return the stored menubar''' return self._wxMenuBar def load(self, wxMenuBar = None, controller = None): '''Load the menubar with the menu items stored in XML format in the instance's filename property wxMenuBar -> the root menubar of the frame; if given will become the instances new menubar property controller -> the class instance that will receive any callbacks stored in the menu items' callback attribute ''' if wxMenuBar != None: self.setMenuBar(wxMenuBar) menubar = minidom.parse(self._filename) # loop over and process all of the menu elements in the menubar for menu in menubar.getElementsByTagName('menu'): menuName = menu.attributes['name'].nodeValue.replace('_', '&') wxmenu = wxMenu() for menuItem in filterText(menu.childNodes): if menuItem.tagName == 'menuitem': attrs = menuItem.attributes idTag = int( attrs['id'].nodeValue ) name = attrs['name'].nodeValue.replace('_', '&') info = attrs['info'].nodeValue wxmenu.Append(idTag, name, info) # only load the callbacks if there is a controller if controller: try: callback = attrs['callback'].nodeValue handler = getattr(controller, callback, None) if handler: EVT_MENU(controller, idTag, handler) except KeyError, ex: # didn't have a callback attribute - skip #*TODO*: check if there is a better way; maybe a has_key test? pass elif menuItem.tagName == 'separator': wxmenu.AppendSeparator() self.menuBar().Append(wxmenu, menuName) #---------------------------------- > > Thanks for the initial post Bjorn, I had fun working on this... Didn't-have-fun-getting-the-code-out-to-you-though-ly, yours Tom From m.faassen at vet.uu.nl Fri Jun 15 15:19:03 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 15 Jun 2001 19:19:03 GMT Subject: call-by-reference (was Re: Any other Python flaws?) References: <9gcu9g$gm4$1@newshost.accu.uu.nl> <9gd4tq$odb$1@news.mathworks.com> Message-ID: <9gdn37$61k$3@newshost.accu.uu.nl> jcm wrote: > Martijn Faassen wrote: >> I agree that nobody agrees on whatever 'call-by-reference' means, or what >> 'call-by-value' means. I mean, I'm here confused why you'd say C++ doesn't >> support call-by-value while Python apparently does. :) > In my experience, there's good agreement about what call-by-reference > means just about everywhere but in newsgroups. Python supports only > call-by-value -- you can't change the value of a variable in your > caller's scope (globals aside). Um, I wouldn't say it that way. Python supports changing the value a name references just fine: def foo(a): a.append(42) l = [1, 2, 3] foo(l) Though of course the value of immutable values can't be changed. Python doesn't support the changing of the *reference* of the name in the caller's scope (awful hacks aside). Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From jkn at nicorp.f9.co.uk Mon Jun 25 05:41:02 2001 From: jkn at nicorp.f9.co.uk (Jon Nicoll) Date: 25 Jun 2001 02:41:02 -0700 Subject: [OT]: resolution of PerformanceCounter under NT Message-ID: <8351bb33.0106250141.7b7aa3d@posting.google.com> Hello there Further to my recent posting about using calldll to call the Win32 API functions QuesryPerformanceCounter()/QueryPerformanceFrequency(): :: begin import calldll import struct m = calldll.load_library('kernel32') f = calldll.get_proc_address(m, 'QueryPerformanceFrequency') p = calldll.membuf(4) px = p.address() if calldll.call_foreign_function(f, 'l', 'l', (px,)): res = p.read(0, 4) print struct.unpack('l', res)[0] :: end I find that I get a return value, on my Dell Precision 410 running NT4/SP5, of: >>> 448630000 ie 448e06, which looks to me rather like the Performance counter is using the Timestamp Register (via the RDTSC instruction, presumably) running at the CPU's clock frequency (?). This surprised me, as I'm used to seeing a resolution of 873nSec or so. Anyone know if this is generally true under NT, or under what circumstances I'm likely to get the different resolutions of the Performance Counter? Thanks for any pointers Regards jon Nicoll From adjih at crepuscule.com Tue Jun 26 12:36:38 2001 From: adjih at crepuscule.com (Cedric Adjih) Date: 26 Jun 2001 16:36:38 GMT Subject: Python scripting [was: Re: emacs speedbar for python mode?] References: <9h24tq$f7b$1@news1.xs4all.nl> <9h2bo2$335$1@news1.xs4all.nl> Message-ID: <9hadmm$4qk$1@ites.inria.fr> Fran?ois Pinard wrote: > [Boudewijn Rempt] >> Thank! I've only just bit the bullet and started to use emacs - after >> I found out there really isn't an alternative for writing docbook. >> I do wish I hadn't put it off for so long, though. I've used vi and >> nedit for more than half a decade... > If I could only script Emacs with Python! Emacs LISP is not so bad, it > has a lot of virtues, yet writing Scheme or Python is more pleasurable to me. > Of course, I'm a bit aware of the Guile project. Why not Python, then? Here is a proof of concept of a related idea: -- Cedric From akuchlin at mems-exchange.org Tue Jun 19 11:02:55 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 19 Jun 2001 11:02:55 -0400 Subject: Python version of IQ has been updates (IQ v0.34.python) References: <505.566T11T1243597threeseas@earthlink.net> <3B2A7F5E.MD-1.4.4.padf@ihug.com.nz> <3871.567T2214T9794928threeseas@earthlink.net> <87puc3ao42.fsf@pooh.honeypot> <2509.568T2823T9766233threeseas@earthlink.net> <9gkftm026v9@enews2.newsguy.com> <87k829ai6y.fsf@pooh.honeypot> <9gnkp00o7f@enews2.newsguy.com> Message-ID: <3dofrkecm8.fsf@ute.cnri.reston.va.us> "Alex Martelli" writes: > And where would that "elsewhere" be? Once upon a time, you could > perhaps count on "a real programmer" having a lot of experience > with vi and/or emacs, lexx, grep, egrep, sed, awk -- today, while > still widespread and flourishing, these tools are not mainstream. A vestigial trace of this era shows up right at the beginning of the Python tutorial, which starts "If you ever wrote a large shell script, you probably know this feeling: you'd love to add yet another feature, but it's already so slow, and so big, and so complicated; ..." Today I'm sure most people start with a general scripting language, and don't bother with trying a shell script first. > It's interesting that the two P-languages arrive at roughly > similar power by such widely divergent paths. Python's way If you're familiar with Python's internals, it's also instructive to look at http://gisle.aas.no/perl/illguts/, a description of Perl's implementation. You can see a likeness between the two implementations, though Perl adds lots of specialized flags to objects in an effort to squeeze out a cycle here or there, while Python just says to hell with it and leaves the code straightforward and simple. It's my understanding that part of the motivation of the Perl6 rewrite is to drop a lot of the flags and special-casing, because on modern processors the clever tricks don't actually help much, so Perl's implementation will likely become more like Python's in this respect. --amk From aleaxit at yahoo.com Thu Jun 7 16:19:06 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 7 Jun 2001 22:19:06 +0200 Subject: getch() of Turbo C in Python? References: Message-ID: <9fongm01ic6@enews1.newsguy.com> "Anurag Ved" wrote in message news:fa4233c9.0106071108.7b1c4ed8 at posting.google.com... ... > Is there something similar to the getch() function of Turbo C which > reads just one key from and returns immediately? Yes, it's called getch() and is exported from module msvcrt (in Windows versions of Python). Alex From newwave at ACMEmail.MeNoLikeSpam.net Fri Jun 8 21:52:28 2001 From: newwave at ACMEmail.MeNoLikeSpam.net (Austin) Date: Sat, 09 Jun 2001 01:52:28 GMT Subject: File Headers Message-ID: Hello All, I would like to be able to have a user specify a document and have the program return the files type. This cannot be determined via extension, however it only needs to be able to distinguish between a MP3 or a Zip file. If it's neither, then it should return something along those lines. Please e-mail me directly at newwave@@@acmemail.net (remove the extra @ signs) as I have limited access to newsgroups. Thanks!!! Cheers- Austin From mcherm at destiny.com Sun Jun 17 14:10:36 2001 From: mcherm at destiny.com (Michael Chermside) Date: Sun, 17 Jun 2001 13:10:36 -0500 Subject: list.sort() Message-ID: <3B2CF29C.7B6871B5@destiny.com> > I know the sort-method on lists changes the list in-place and doesn't > return anything, but I'm still confused. > > Take these examples: > > >>> l = [4,3,2] > >>> l = l > >>> l > [4, 3, 2] > > The list is unchanged, even after assigning it to itself. But: > > >>> l = l.sort() > >>> l > >>> print l > None > > If we split the problem into parts, "l.sort()" sorts l and it becomes > [2,3,4]. I expected it to be [2,3,4] after assigning it to itself (after > it got sorted), but the list seem to got deleted instead. I don't like > this behaviour, at all. Okay, I think I can answer this one. Suppose that you did the following: >>> l = [4,3,2] >>> l = l.getLength() >>> print l Well, first of all, you'd get an error because there's no method of Lists called "getLength()", but if there WERE, you'd probably expect this to change l from the list [4,3,2] to the number 3. The idiom "l = l.func()" changes l to whatever l.func() returns, REGARDLESS of whether or not calling .func() has side-effects like modifying the list. So consider your code: >>> l = [4,3,2] >>> l = l.sort() >>> print l What does "l.sort()" return? Why, like all functions that don't really have a meaningful "return value" it returns "None". And so l gets set to None (it is NOT deleted... just set to None). What you really wanted is this: >>> l = [4,3,2] >>> l.sort() >>> print l [2, 3, 4] > Why does Python behave like this? Why does sort() change lists > _in-place_, instead of returning a list? Now THAT is a really excellent question. Because there are two reasonable ways that Guido COULD have done it. The correct idiom could (sensibly) be either: >>> l.sort() # Idiom 1: correct idiom or >>> l = l.sort() # Idiom 2: incorrect idiom The second idiom, which Guido DIDN'T chose has certain advantages. The biggest advantage is that it doesn't modify the original list. This is particularly useful in functional style programming, and you can see how it would work in the follow [hypothetical] snippet: NOT_REAL>>> list = [4,3,2] NOT_REAL>>> newlist = list.sort() NOT_REAL>>> newlist [2, 3, 4] NOT_REAL>>> list [4, 3, 2] Well... that's a cool feature! So why on earth did Guido pick idiom 1? Well, the very feature that we're lauding here is the source of the problem. Because idiom 2 would require the that the original list not be changed, a whole new list would have to be created. This would wind up taking 2x as much memory! The decision was made that requiring the use of 2x as much memory each time a list was sorted was just too much overhead to impose on everyone. But never fear! If this is how you WANT to work, then it only requires 4 extra lines of code!!! The following demonstrates a simple function to return a sorted version of a list without modifying the original: >>> def sortlist(list): newlist = list[:] newlist.sort() return newlist >>> l = [4,3,2] >>> l = sortlist(l) >>> l [2, 3, 4] Have fun! -- Michael Chermside From shredwheat at mediaone.net Tue Jun 12 12:44:07 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Tue, 12 Jun 2001 16:44:07 GMT Subject: BIG problem if readline strips newlines Message-ID: i've seen frequent mention of an option for readline() to strip out newlines as each string is read. this sounds like a great idea, but i realized its gonna be very difficult to loop through a text file. the standard python idioms will no longer work... for line in file.readlines(chomp=1): pass while 1: line = file.readline(chomp=1) if not line: break pass neither of these constructs will work because the loop will break once there is a blank line with only a linefeed ("\n"). i can't quite imagine what a basic loop through a file would look like if the blank lines had no linefeeds? while 1: line = file.readline(chomp=1) if line == None: break pass i suppose thats not too bad, but would there be a better way all around? From m.faassen at vet.uu.nl Tue Jun 12 19:24:39 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 12 Jun 2001 23:24:39 GMT Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: Message-ID: <9g68bn$i4s$3@newshost.accu.uu.nl> Glyph Lefkowitz wrote: > I'm for it. In fact, we should do things like this more often -- if the > semantics of "print" change once per release, everyone will stop using it, > the keyword/bytecode will vanish, and people will use a function for > writing to standard out, as it should have been all along! :) Okay, if this is the explicit *reason* for adopting this PEP, I could be convinced to be for it, otherwise against. :) Is this PEP written just to test whether we're still awake and sane on comp.lang.python? First we get >>, seemingly to encourage 'print' is for serious stuff as well (though it has too much magic for that kind of stuff really), and then we get this to add more magic, breaking lots of the serious stuff... I'll ask it twice today: what is it with print that encourages this confusion? Is it really the case that the little magic 'print' has is slowly leading to more and more magic to patch up for the previous magic? Anyway, if we're adapting this PEP to point out why print is evil so it can be eventually removed, why not just get over with the incompatibility issue right away and get rid of print entirely? :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From loewis at informatik.hu-berlin.de Mon Jun 18 07:19:03 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 18 Jun 2001 13:19:03 +0200 Subject: why is there no class (static) methods in Python ? References: <3B2D114E.7B39D954@intraware.com> <3B2D6669.7DEFD13F@intraware.com> Message-ID: Richard Gruet writes: > But the reason to choose to define a function as a class method > rather than a mere (static) function is -obviously- when this > function is closely related to the class itself, not to one of its > instances. Depending on how exactly it is related, provinding a module function might *still* be the better solution - even if class methods were available. > In fact, constructors (and destructors) are class methods, not > instance methods, but they are handled specially in the language so > they appear as instance methods.. No, constructors (at least as available in Python, C++, and Java), are really initialization methods, and thus instance methods. This is easily seen as they get an object as implicit argument. > Typical examples of class methods: > loadInstanceFromStream(aStream) # Create an instance from its persistent That is a factory function, something that should be separate from the class itself. > getInstanceCount() # returns the number of instances > getInstanceList() # returns the list of > getClassName() or getAnyInfoOntheClass() ...... These ought to be globl functions, taking the class as an argument. Some of these are really easy to implement in Python: def get_class_name(x):return x.__name__ Regards, Martin From roy at panix.com Sun Jun 24 09:53:07 2001 From: roy at panix.com (Roy Smith) Date: 24 Jun 2001 09:53:07 -0400 Subject: Is this a true statement? (fwd) References: <3b35eec8.1798329@nntp.sprynet.com> Message-ID: <9h4rc3$mfk$1@panix6.panix.com> David C. Ullrich wrote: >For example, I've seen it stated several times that if >you're writing Windows programs you have to be writing >C or C++ because the API is written in C. This is simply >not true, you can write Windows programs in any language >you like, and with no silliness involved. Much the same statement can be said about the Macintosh. The API is written in Pascal, or at least using Pascal-style constructs like counted (instead of null-terminated) strings. Yet, the overwhelmingly vast majority of Mac applications are written in C or C++ these days. All it takes is the right glue, and you can use any language you want. From guido at python.org Fri Jun 29 08:42:30 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 29 Jun 2001 12:42:30 GMT Subject: Augmented Assignment (was: Re: PEP scepticism) References: Message-ID: Paul Prescod writes: > That was a lot of effort to understand a typing shortcut. It's somewhat > unpythonic to trade a long explanation for a bit less typing. I think you're looking it the wrong way. You shouldn't think "+= is confusing because sometimes it modifies an object and sometimes it does". Gee, there are lots of places where something that's *spelled* the same has a different effect depending on the object types involved. The right way to think about this is "list objects are mutable and tuples are not". So if you want to give a library function a sequence object of yours but you don't want it to be changed, pass it a tuple. If you want it to be changed (or don't care) pass it a list. --Guido van Rossum (home page: http://www.python.org/~guido/) From philipp at salomon.at Fri Jun 8 03:25:36 2001 From: philipp at salomon.at (Philipp Jocham) Date: 8 Jun 2001 07:25:36 GMT Subject: Compiling Python2.1 under HP-UX with threads ? References: Message-ID: On Thu, 07 Jun 2001 20:08:00 +0200, M.-A. Lemburg wrote: >I am having trouble compiling Python 2.1 under HP-UX 11.00 >with threads. > >Even though the compile runs fine (ok, termios and _curses fail >to compile, but I don't need those), the test suite fails to >pass all tests which try to use threads. The error I get is: > > ThreadError: can't start new thread > >Does anyone have hints what I could try to debug this ? Does the configure process detect __pthread_create_system in -lpthread ? I've compiled it with gcc-2.95.2 and it works out of the box (besides termios and _curses). Philipp -- Philipp Jocham SALOMON AUTOMATION GmbH mailto: philipp.jocham at salomon.at A-8114 Friesach bei Graz From gwyoder at hotmail.com Wed Jun 13 07:28:55 2001 From: gwyoder at hotmail.com (Pilgrim) Date: Wed, 13 Jun 2001 11:28:55 GMT Subject: VI Message-ID: Can someone tell me what "vi" is for a text editor to work with python? Where can I get this? From erwin at andreasen.com Sun Jun 24 11:29:08 2001 From: erwin at andreasen.com (Erwin S. Andreasen) Date: 24 Jun 2001 17:29:08 +0200 Subject: Pythoin MUD (PyMUD?) References: <9gqq3t$hvs$1@brokaw.wa.com> Message-ID: <66dl28xn.fsf@andreasen.org> Here's one other MUD that wasn't mentioned -- Aedon: http://initd.org/Software/aedon It has some very interesting things such as modeling of object properties. I've listed it (and the two other Python projects mentioned) at this page: http://www.andreasen.org/newmud/ Naturally, I am also working on a Python MUD -- our plan is to first achieve a level of functionality that makes the MUD comparable to some of the popular Diku-based code bases, so a more pragmatic approach rather than theoretical research. No URL at the moment, but one of the more interesting things about it is automatic persistence of everything. Oliver Jowett who wrote the code has also released it separately here: http://www.randomly.org/projects/cog/ Oh yeah, a year ago I ran a competition about writing a MUD in 16k source code. 5 out of 24 entries were written in Python. You can get the code here: http://www.andreasen.org/16k.shtml scarblac at pino.selwerd.nl (Remco Gerlich) writes: > Always a big lack of free time. I'd like to see a mailing list though :-) I started a python-mud list on egroups a while back when I began working on my Python MUD; it never gained enough momentum. If you want to subscribe and save it from death by inactivity, it's here: http://groups.yahoo.com/group/python-mud/ It was meant as a place for generic Python-related MUD discussion. I didn't manage to do much work on my Python MUD since starting the list, so there hasn't been any discussion in ages. It's also so much easier just to DO things in Python rather than talk about them ;) PS: If one of you would rather join an existing project rather than to start your own (and you have substantial experience with programming both Python and coding/design other MUD bases), feel free to email me and I can tell you more about my Python MUD project which I've mentioned above. There are some 8k lines of code now, and you can find it running at abandoned.org port 4300. -- =============================================================== Herlev, Denmark Software Designer <*> Eicon Networks Research =============================================================== From Attila.Feher at lmf.ericsson.se Tue Jun 5 10:36:15 2001 From: Attila.Feher at lmf.ericsson.se (Attila Feher) Date: Tue, 05 Jun 2001 17:36:15 +0300 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3B1B1825.8109BA83@lmf.ericsson.se> <3b1ce1f7.5642@bolder.com.co.za> <3B1CE4D3.18F99168@lmf.ericsson.se> <3b1ce9a2.57e7@bolder.com.co.za> Message-ID: <3B1CEE5F.68CB655E@lmf.ericsson.se> goose wrote: [SNIP] > sorry ... temporary brain-fade induced by getting into an argument concerning > "everybody uses windows, so u should only develop for microsoft" ... > terribly sorry > :-) :-))) A From osu-nntp at portzer0.virtualave.=NOSPAM!!!=net Tue Jun 5 15:52:10 2001 From: osu-nntp at portzer0.virtualave.=NOSPAM!!!=net (Locke) Date: Tue, 5 Jun 2001 15:52:10 -0400 Subject: integers Message-ID: <9fjd8q$qb6$1@charm.magnus.acs.ohio-state.edu> is there such thing as someint++ or someint-- or someint += 2 in python?? it is a pain in the butt writing someint = someint + 1 Thanks! From johnroth at ameritech.net Fri Jun 15 10:24:17 2001 From: johnroth at ameritech.net (John Roth) Date: Fri, 15 Jun 2001 07:24:17 -0700 Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> Message-ID: "Nick Perkins" wrote in message news:nQeW6.237411$eK2.50576177 at news4.rdc1.on.home.com... > > "David LeBlanc" wrote in message > news:9gbsdv$8ft$9 at 216.39.170.247... > > > alias true: 1 > ... > >...read so nicely to be able to say "if something is true" > > it's even easier than that: > > if something: > ... > > ..which can 'read' just as well, if you choose your names accordingly. > > ..but on a more general note, am i to understand that you are suggesting > C-style macros, where code is 'physically substituted', before being run? > That would be a Bad Thing, i think. C was a nice little language before it > turned into a giant mess of macro substitutions. I didn't understand David's proposal as macro preprocessing. I understood it as a request for a one-time assignment (i.e., one that guaranteed that the name couldn't be reassigned (or rebound to a different object, for language purists)). As far as I'm concerned, that's the essence of the proposal: whatever object is bound to the name will not change (at least, until the code is edited!) This means that it really only makes sense for immutable objects. I also don't really care about the syntax - there are people working on Python who are much more knowledagable about what would fit cleanly. I prefer "const", but I could live quite happily with "alias." Likewise, I prefer "=", since my vision is that it really is a (one-time) assignment, but I could live with ":". The run-time issue (how to make it happen) could be fairly messy - I don't know of any mechanism currently in Python that will prevent a name from being rebound to another object. The problems with the C language #define statement are outside of the scope of this discussion, other than as a horrible example of how to add a layer of obfustication to a program. John Roth > > > > From bokr at accessone.com Fri Jun 15 00:01:49 2001 From: bokr at accessone.com (Bengt Richter) Date: Fri, 15 Jun 2001 04:01:49 GMT Subject: Any other Python flaws? References: Message-ID: <3b296534.514160393@wa.news.verio.net> On Thu, 14 Jun 2001 14:27:59 -0400, Andrew Kuchling wrote: >I was updating my page of possible Python design flaws >(http://www.amk.ca/python/writing/warts.html) last night to take 2.1 >into account. 2.1's nested scoping fixes one major wart, and the >other major one, the type/class dichotomy, might get fixed in 2.2 if >the descr-branch in CVS turns out well. (It's neat that the two >largest ones may both get fixed before 2001 is out.) > >That leaves the remaining warts as minor wibbling about 'do' >statements, print >>, and the like. Are there any other flaws that >should be added? Virtualized file system access with mounting of real-system files and trees at any desired mount points? The guiding star would be having a platform-independent abstract hierarchical name space to virtualize access to various containers and sources and destinations of stuff. Mapping access to a particular platform's file systems would be one use. Mapping to unix could be pretty transparent as far as usage is concerned. One benefit would be that Python could have its _own_ standard hierarchical file-and-such-entities-as-my-be-desired name space independent of platform, or at least more independent. The unix model of a '/' root and everything branching from there seems like a good one to adopt, but let's think about the virtual aspect. For one thing, you would have the opportunity to define access controls, e.g., by mounting real file trees read-only and restricting chdir by not allowing access to anything not mounted. The (OTTOMH ;-) concept is to have an ordinary python directory as the root, e.g., pyVFS={} and then populate it by initializing and 'mounting' various things. One initial thing might be a virtual 'python' subdirectory which could contain the mount points for various standard parts of a typical python installation, e.g. docs,libs,etc., e.g., pyVFS['python']={} Thus mounting doc on my win32 system might be equivalent to pyVFS['python']['doc']= \ PathAccess('drwxr-xr-x','d:\\Python21\\Doc') whereas on my slackware linux system it might be pyVFS['python']['doc']= \ PathAccess('drwxr-xr-x','/usr/doc/python-1.5.2') And thus open('/python/doc/index.html') could be platform independent, assuming the pyVFS tree was designed to a standard. This could also eliminate much of the need to use sys.path searches. I don't know how efficient using nested python dictionaries would be, but that's an optimization detail, and only unusual programs would care. The idea of "PathAccess" is to have a reference to an instance of an access class initialized with whatever is needed to define the access. This would have to be at least partly platform dependent depending on what it was interfacing to. Compatible classes would have to have standard methods for accepting path tails to chase, etc., so that it would fit in with simply chasing nested python dictionaries within which they may be encountered. If the system looked in a directory and found that 'doc' was not an access object, but another virtual subdirectory, it would act accordingly, and chase the path through it as opposed to names gotten from a mounted directory via the access object. This could allow installation of file filters and/or network goodies and/or even 'files' with funny side effects, like converting data to plots and storing it to a destination .png file, etc., or piping it to an X display, or ... The thing is, you'd have a private python world to play with, mapping to platform things as necessary and/or possible/desirable, while being able to sythesize totally new virtual things to access. I'd love to spend more time on this, but that's my newbie USD0.02 for now. Got a long evening ahead. From alankarmisra at hotmail.com Thu Jun 7 15:46:39 2001 From: alankarmisra at hotmail.com (gods1child) Date: 7 Jun 2001 12:46:39 -0700 Subject: I used to like Python but... Message-ID: <25b2e0d9.0106071146.565bf774@posting.google.com> Now I think I'm just plain in love. I wuz reading this book on OOP concepts which used a classic problem of chess (described below) to illustrate the power of 'thinking OOP'. It gave a 'pseudocode' for a possible solution to the problem. Converting the pseudocode to Python was like typing the darn pseudocode! Man i love this language. Here's the problem and the code for your amusement and one more reason to pray for Python becoming king of the hill: The problem is to place 8 queens on a chess board such that no queen can attack another. The solution given below takes an 'OOP' approach where each queen queries its immediate neighbor (the one that came before) as to where it can place itself in a specific cell. If the neighbor accepts, it in turn politely asks its neighbor if this new entrant should be allowed to stand in that cell until someone says 'this means war!' and the poor new entrant starts looking for a new home. This way the queens find the acceptable solution by talking to each other instead of Mr Garry Kasparov looking over the chess board making decisions on behalf of each queen. BTW, i'm not a science grad so i apologize if this is like the oldest problem in the world # 8 queens # The problem is to place 8 queens on a # chess board such that no queen can attack # another class Queen: def __init__(self, column, queen): self.row = 1 self.column = column self.neighbor = queen def findSolution(self): while (self.neighbor and \ self.neighbor.canAttack(self.row, self.column)): if(not self.advance()): return 0 return 1 def advance(self): if(self.row < 8): self.row += 1 return self.findSolution() if(self.neighbor and not self.neighbor.advance()): return 0 self.row = 1 return self.findSolution() def canAttack(self, testRow, testColumn): if self.row == testRow: return 1 columnDifference = testColumn - self.column if ((self.row + columnDifference) == testRow) or \ ((self.row - columnDifference) == testRow): return 1 if self.neighbor: return self.neighbor.canAttack(testRow, testColumn) return 0 def getPosition(self, cells): if self.neighbor != None: self.neighbor.getPosition(cells) cells[self.row-1][self.column-1] = 'X' lastQueen = None for i in range(1,9): lastQueen = Queen(i, lastQueen) lastQueen.findSolution() cells = [] for i in range(0,8): cells.append(list('O'* 8)) lastQueen.getPosition(cells) print '\n\n' for i in range(0,8): for j in range(0,8): print cells[i][j], print From jparlar at home.com Fri Jun 29 16:17:23 2001 From: jparlar at home.com (Jay Parlar) Date: Fri, 29 Jun 2001 16:17:23 -0400 Subject: Python WWW::Search? Message-ID: <20010629201814.ILOR2955.femail2.rdc1.on.home.com@jparlar> Has anyone heard of or seen anything simliar to Perl's WWW::Search collection, but implemented for the most wonderful language I've ever used? I need to be able to pull search results from various search engines, and while I have hacked together a few pieces of code that do the job for some engines, I'd really like a more robust solution. In case you have no idea what I'm talking about (Who'd want to really know anything about Perl anyway? ;-) ), this site http://www.isi.edu/lsam/tools/WWW_SEARCH/index.html describes what WWW::Search is. Hopefully someone's seen something equivalent for Python. This would make myself, and my colleague very happy if something did exist (Hi Bill!). Thanks in advance, Jay Parlar From tim.one at home.com Thu Jun 21 23:36:27 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 21 Jun 2001 23:36:27 -0400 Subject: [OT] MS EULA -- (will ActiveState become outlaws? ;-) In-Reply-To: Message-ID: [Steven D. Majewski] > Sent: Thursday, June 21, 2001 9:50 PM > Is this the next stage of Microsoft's war against Open Source ? > > Discussion of this on SlashDot : > > ( Right before the article on the Monty Python Action Figures! ) > > If this spreads to all of Microsoft's EULA's, will this make > ActiveState illegal ? They don't specifically mention Python's > license, but they do mention Perl's ( and the "similar to any > of the following" clause would seem to include Python's. ) I don't think so. All the licenses mentioned (including Perl's Artistic License) obligate (under most circumstances) the licensee to provide source for any changes they may make; no version of the Python license requires that. But I'm neither a lawyer nor Bill Gates, so cutting open a chicken and looking for patterns in its entrails is better legal advice. > Does anyone know if this should be taken seriously ? I'm sure it already is, and by many people. Whether *you* should make it your life's work isn't really a question c.l.py can answer . From greg at cosc.canterbury.ac.nz Mon Jun 25 02:46:58 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Mon, 25 Jun 2001 18:46:58 +1200 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) References: <200106201855.OAA21119@panix3.panix.com> <15153.15434.385992.754443@beluga.mojam.com> Message-ID: <3B36DE62.7DDD28E0@cosc.canterbury.ac.nz> "Barry A. Warsaw" wrote: > > But once > there's a serious move to include the code into CVS in a > non-experimental way (as I gather is the case with the generators > feature), I really think it the discussions have to be moved to > python-dev at the very least. Not only that, but a decent amount of time needs to be allowed for discussion by people who haven't been following all the in-camera proceedings before Guido makes a Pronouncement. Two days is not enough! -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From danielk at aracnet.com Tue Jun 5 11:13:55 2001 From: danielk at aracnet.com (Daniel Klein) Date: Tue, 05 Jun 2001 08:13:55 -0700 Subject: formatting numbers References: Message-ID: On Mon, 04 Jun 2001 20:21:30 GMT, "michael montagne" wrote: >Simple question. I am accessing a database of job numbers that take the >form of "00049" and "01049". These values are integers. When I return the >value from the database it reads "49". I need to add the leading digits if >they are there so this number would read "00049". In MSAccess I used >Format(num,"00000"). How can I do that with Python? >>> print '%05d' % 49 00049 HTH, Dan From boud at rempt.xs4all.nl Sat Jun 23 03:37:51 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 23 Jun 2001 07:37:51 GMT Subject: emacs speedbar for python mode? Message-ID: <9h1h0f$9kh$1@news1.xs4all.nl> I've learnt to use XEmacs for Python programming - mostly because I had to use it to write docbook source for my book on PyQt. However, when editing Java with Xemacs I have a handy speedbar - file and class browser in one. Is there something comparable for the Python mode? -- Boudewijn Rempt | http://www.valdyas.org From joonas at olen.to Tue Jun 12 01:43:44 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Tue, 12 Jun 2001 08:43:44 +0300 Subject: EXECing multiple lines. References: <3B2518B9.5C5CE56B@olen.to> <9g36sn$8mp$1@news.mathworks.com> Message-ID: <3B25AC10.9AA7899E@olen.to> Joshua Marshall wrote: > > Joonas Paalasmaa wrote: > > What might be wrong when I get the following error? > > >>>> exec """for x in range(5): > > print x""" > > Traceback (innermost last): > > File "", line 1, in ? > > exec """for x in range(5): > > File "", line 2 > > print x > > ^ > > SyntaxError: invalid syntax > >>>> > > It works if you put a newline at the end. I don't know if it's a bug > that it doesn't work without the newline. Strange. But now it works. From mcc at TO.GD-ES.COM Wed Jun 27 02:54:40 2001 From: mcc at TO.GD-ES.COM (Merton Campbell Crockett) Date: Tue, 26 Jun 2001 23:54:40 -0700 (PDT) Subject: HTML Content Rewriting Message-ID: Several years ago, I developed a system for a customer that allowed their employees and customers to securely access web content on servers inside their firewall. Basically, I used Apache's mod_rewrite module to implement what might be called a "dual reverse proxy". Unfortunately, times have changed. Several of the customer's organizations have started playing with various web development tools that create dynamic content. Several of these embed information from the HTTP requests in the documents that are generated. At a minimum this embedded information results in warnings about protocol changes, i.e. hard-coded links that specify an http: method when the remote users are using the https: method. At worse, there are references to internal names and IP addresses that are not accessible from the Internet. Both PHP and Python seem to provide capabilities that would allow "fix ups" to be applied to the content as it is delivered to the remote user. Python looks like it might have a few more tools for manipulating HTML content. What I would like to do is dynamically add a BASE tag to the document and convert all absolute to relative references if they involve the current web site. For references to other web servers accessible through this facility, I would like to ensure that the references are in the external form and to disable the links to web servers that are not accessible by remote users. What I would like from this group is some guidance. Can this be done with Python? Are there existing Python tools that might perform some of the functions that I would like performed? What pitfalls and "gotchas" should one be aware? Merton Campbell Crockett From sdm7g at Virginia.EDU Fri Jun 22 12:47:23 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Fri, 22 Jun 2001 12:47:23 -0400 (EDT) Subject: Is this a true statement? In-Reply-To: <3B3362C6.5F2781EB@raqia.com> Message-ID: On Fri, 22 Jun 2001, David Lees wrote: > Not necessarily. It might go faster if you were comparing a Python > built-in operation (coded in C) with something inefficiently coded in > C++. But the statement that "Python can do everything C++" is true, but > a tautology. You can substitute nearly any language; Basic, C, Algol, > Lisp,... and it is still a true statement. > > david lees > > > MDK wrote: > > > > Python can do everything C++ can do but just slower. Wrong, David. Turing completeness means that anything you can *COMPUTE* in one language you can computer in another. Python, Lisp, C++, etc. are all equivalent in that sense. But you can't *DO* all of the same things in all languages -- for example: you can write a device driver in a language if you can't specify interrupt vectors or hardware address pointers. -- Steve Majewski From robin at jessikat.fsnet.co.uk Mon Jun 18 19:03:49 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Tue, 19 Jun 2001 00:03:49 +0100 Subject: idle BUG References: <3b2e552f.2621005@nntp.ix.netcom.com> Message-ID: <2MTskUAVjoL7Ewqc@jessikat.fsnet.co.uk> In article <3b2e552f.2621005 at nntp.ix.netcom.com>, Mike Clarkson writes .... >Robin, try this (you'll have to fix the tk.eval lines back up to be >all one line). In Tkinter.py, change quit() to > > def quit(self): > """Quit the Tcl interpreter. All widgets will be destroyed.""" > self.tk.eval('foreach w [winfo child .] {wm protocol $w >WM_DELETE_WINDOW {}; catch {destroy $w}}') > self.tk.eval('catch {set w .; wm protocol $w WM_DELETE_WINDOW >{}; destroy $w}') > self.tk.quit() > >If it works for you, I'll explain why it's required under Tkinter, but >not Tk. > >This makes self.quit() do what it's documented to do, and leaves >self.tk.quit (which is _tkinter.quit) to do what it does now, namely >signals the mainloop to end but destroys no widgets. > ... sorry my app hangs as before. have you got other changes in place? >Mike. -- Robin Becker From mcfletch at home.com Tue Jun 26 02:47:57 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Tue, 26 Jun 2001 02:47:57 -0400 Subject: Win32 extensions using the .NET SDK and the Win32 Platform SDK Message-ID: <000801c0fe0b$efd59060$a9807018@cr706570a> Last month I did some preliminary tests to see if these two free packages could be used for making Python extensions on Win32. It seems to work fine (see previous thread referenced below), save for one error. I've just hacked around that, and am looking for a knowledgeable person to assure me that my hack isn't redefining truth or anything, and potentially to ask if an IFDEF could be added to config.h . The problem is at line 385 (in the Python 2.0 distribution): #if defined(MS_WINDOWS) && !defined(MS_WIN64) typedef long intptr_t; typedef unsigned long uintptr_t; #endif In the free tools, the definitions are: 8<___ net sdk\include\stdarg.h # 48 ______ #ifndef _UINTPTR_T_DEFINED #ifdef _WIN64 typedef unsigned __int64 uintptr_t; #else typedef _W64 unsigned int uintptr_t; #endif #define _UINTPTR_T_DEFINED #endif 8<___ net sdk\include\io.h # 48 ______ #ifndef _INTPTR_T_DEFINED #ifdef _WIN64 typedef __int64 intptr_t; #else typedef _W64 int intptr_t; #endif #define _INTPTR_T_DEFINED #endif My hack was to change the following in the above... typedef _W64 int intptr_t; to typedef _W64 long intptr_t; and typedef _W64 unsigned int uintptr_t; to typedef _W64 unsigned long uintptr_t; Now, I can compile PyOpenGL and run all the demos and tests for both Python 2.0 and 2.1, but I have _no_ idea what I'm doing here, so I'd ask if anyone with a clue could hold me and whisper that everything'll be all right :) . References: http://groups.google.com/groups?ic=1&th=dc85d5decb14f5ca,5 Hold me, Mike From samschul at pacbell.net Mon Jun 18 02:05:58 2001 From: samschul at pacbell.net (Samuel Schulenburg) Date: 17 Jun 2001 23:05:58 -0700 Subject: Any other Python flaws? References: Message-ID: Paul; I received your e-mail on this problem, and just wanted to post back to the group,your response. Thanks for the quick turn around on my post. The response from Paul: ====================================================================== I think it is more to do with line length. Anyhow, it is fixed in the latest ActivePython and will be fixed in the next win32all release. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook ======================================================================= Samuel Schulenburg Paul Prescod wrote in message news:... > Samuel Schulenburg wrote: > > > > I see a problem that only occurs in the IDLE, or > > Winpython environment. > > I am not having any luck reproducing this problem in pythonwin. Are you > sure that it doesn't matter *what* file you open? Maybe it only happens > for large files. Or binary files. From James_Althoff at i2.com Wed Jun 20 15:19:50 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Wed, 20 Jun 2001 12:19:50 -0700 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) Message-ID: Aahz Maruch wrote: >While there's some logic here, it's not exactly convenient to subscribe >to every mailing list under the sun each time a "critical" issue comes >up. I agree completely! Jim From jh at web.de Fri Jun 8 15:28:46 2001 From: jh at web.de (Jürgen Hermann) Date: Fri, 8 Jun 2001 21:28:46 +0200 Subject: return from finally clause Message-ID: <9fr8u3$gj9$01$1@news.t-online.com> Consider this script: def spam(ret): try: print 1 try: print 2 raise RuntimeError finally: print 3 if ret: return finally: print 4 print 5 spam(1) spam(0) and its output 1 2 3 4 1 2 3 4 Traceback (most recent call last): File "exp.py", line 15, in ? spam(0) File "exp.py", line 6, in spam raise RuntimeError RuntimeError That means that if you (accidently?) return within a finally clause, you effectively eat the exception. This should be documented, or fixed. From kosh at aesaeion.com Fri Jun 22 03:53:29 2001 From: kosh at aesaeion.com (kosh) Date: Fri, 22 Jun 2001 01:53:29 -0600 Subject: Zope and PHP Nuke References: <9guphk$5in$1@news.netpower.no> Message-ID: <9guthp$aa9$1@apollo.csd.net> David Brown wrote: > I have been looking around some websites, and have come across Zope and > PHP > Nuke. As far as I can see, both systems provide a basis for a complex > website including discussion forums and the like. Would it be fair to say > they cover similar uses, or are there major differences? My impression is > that Zope is more demanding on the system, and on configuration and > maintainance, but has better facilities for letting people remotely add > articles to the site. I know that Zope is Python-based, while PHP Nuke is > (oddly enough) PHP-based, and I am at least basically familiar with both > languages. > > What I am interested in doing is setting up a relatively simple discussion > forum system for our company. The aim is mainly to provide a common point > were we can hold information and comments regarding changes, bugs, or > ideas > for our products. Initially, this is only for internal use, but later it > should be accessible externally too. There will not be any really > sensitive data on the site, so we don't need high security (other than the > firewall and filtering for the web server itself), but we need at least to > be able to > restrict access to areas based on user names and passwords. As far as I > undertand it, both Zope and PHP Nuke would be suitable for this. > > It is important that the system can run on both Linux and NT - we > currently run a small Apache + PHP system on NT at the moment, but will > later move to > Linux. How easy is it to migrate data from one system to the other when > we switch over? > > For the backend, am I correct in thinking that both systems support MySQL > and postgreSQL ? Is there any particular reason for choosing one over the > other here? (Speed is not vital as this will be a low load, and I think > MySQL's more limited data integrity protection will be perfectly > sufficient.) Are there binaries for postgreSQL available for NT anywhere? > > Do Zope and PHP Nuke support different languages for different users? > English is fine for me, but many people here (in Norway) would prefer the > texts to be in Norwegian, even if the posts themselves are in English. > > There are plenty of sites describing Zope and PHP Nuke, and I have read > some > of the introductionary stuff. But there doesn't seem to be much comparing > the two, which would be helpful for people like me who are trying to > choose. Any comments or links would be very useful, as would suggestions > for alternative systems. > > Thanks, > > David Brown > Norway > > > > With zope there is a very simple solution for you. Look into squishdot. It is a simple product to add to create a discussion forum like slashdot. It also requires no outside database. Zope is a persistant object database. This makes it easy to work with and backup. The whole site can be backup and moved with a single file the Data.fs file. That is where all the data is stored for the site. If you want a discussion forum different then slashdot there are items for that also. On the whole I have really liked workting with it as a persistent object environment. From aahz at panix.com Mon Jun 4 14:10:32 2001 From: aahz at panix.com (Aahz Maruch) Date: 4 Jun 2001 11:10:32 -0700 Subject: Python Threading (win32) References: <3B1BCBA6.638F14D7@telocity.com> Message-ID: <9fgiuo$rgg$1@panix3.panix.com> In article <3B1BCBA6.638F14D7 at telocity.com>, Adonis wrote: > >ive looked over the Python documentation about threading, but its all >hebrew to me, anyone care to shed the light on how to thread? just a >simple start/stop thread example, ill get it after that. http://starship.python.net/crew/aahz/ -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 I surf faster than you do, monkey boy. (My take on Netscape vs. Lynx) From bawolk at ucdavis.edu Fri Jun 1 18:20:10 2001 From: bawolk at ucdavis.edu (Bruce Wolk) Date: Fri, 01 Jun 2001 15:20:10 -0700 Subject: Python 2.1 dependencies Message-ID: <3B18151A.E95C4E4B@ucdavis.edu> On an RH 7.1 system I rebuilt the source RPMs for Python 2.1. But when I tried to install expat-1.1-3tummy.i386.rpm, I got the following error error: failed dependencies: libexpat.so.0 is needed by abiword-0.7.13-2 This is odd, since /usr/lib/libexpat.so.0 is present on my system, but also what does Python have to do with abiword? Bruce From tim.one at home.com Fri Jun 29 01:09:37 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 29 Jun 2001 01:09:37 -0400 Subject: PEP scepticism In-Reply-To: <3dhex01n1m.fsf@ute.cnri.reston.va.us> Message-ID: [Andrew Kuchling] > ... > But would I rather have had list comprehensions or a catalog of all > Python extensions similar to CPAN? I'd have much preferred the latter, > because it would make a greater improvement in my programming life > than, say, list comprehensions do. This doesn't imply that list > comprehensions don't improve my life at all (they do) ... So what do you do about the curious disconnect between supply and demand in Open Source projects? You got list comprehensions because Greg Ewing (and later Thomas Wouters) generously volunteered to supply them, not because, e.g., Guido *decided* they were more important at the time than was a CPAN workalike. The Python distribution is the sum of what Python users have contributed. That's why, e.g., why we ship tabnanny.py instead of a GUI builder. But note that "instead of" is dead wrong, and so possibly misleading: nothing I ever worked on took away from the time I would have spent on a GUI builder instead, because I never would have worked on the latter regardless (it's not my thing -- no interest, and no competence). A similar dynamic holds in case after case. Even if *everyone* wants some gimmick X, it won't happen unless volunteers work on X. Speaking of which, we really need a web app to match up Python projects with potential volunteers . things-will-be-different-when-microsoft-owns-python-ly y'rs - clipitimbot From Attila.Feher at lmf.ericsson.se Wed Jun 6 11:48:49 2001 From: Attila.Feher at lmf.ericsson.se (Attila Feher) Date: Wed, 06 Jun 2001 18:48:49 +0300 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3b1cdc84.5514@bolder.com.co.za> <9fleid$3rp$1@oslo-nntp.eunet.no> <3B1E4951.7F36D4E4@alcyone.com> Message-ID: <3B1E50E1.35AE59C@lmf.ericsson.se> Erik Max Francis wrote: [SNIP] > Either that or you like playing games. Competent computers users and > programmers play games too, you know. If they have time and no headache :-((( BTW some competents I know play games... really... although I have never seen an original box of any game they play :-))) So OK they do play. But do they buy? A From fdrake at acm.org Fri Jun 29 15:24:00 2001 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Fri, 29 Jun 2001 15:24:00 -0400 (EDT) Subject: Python 2.1 docs in GNU info format Message-ID: <15164.54736.838888.800048@cj42289-a.reston1.va.home.com> Milan Zamazal has contributed Python 2.1 documentation in GNU info format. It is available on python.org: ftp://ftp.python.org/pub/python/doc/2.1/ and on SourceForge: http://sourceforge.net/project/showfiles.php?group_id=5470&release_id=41415 Thanks, Milan! -Fred -- Fred L. Drake, Jr. PythonLabs at Digital Creations From samschul at pacbell.net Sat Jun 2 21:06:04 2001 From: samschul at pacbell.net (Samuel Schulenburg) Date: 2 Jun 2001 18:06:04 -0700 Subject: Embedded 'C' problem? References: Message-ID: "Pete Shinners" wrote in message news:... > "Samuel Schulenburg" wrote > > File "", line 1 > > print """EB70:|30 E8 8A 17 00 00 66 89 04 9F 83 C4 08 43 3B 5C > > 0.....f......C;\""" > > > > ^ > > SyntaxError: invalid token > > > > The problem is final "\" in the origional string is interfering with > > the final tripple quote forming a \""" which is interprited as an > > escape sequence. > > for this problem, just use a double backslash at the end. you > could also place an r at the front of the string, which will > treat it as a raw string, giving backslash no special meaning. > > > r"""5c 0......f.....C:\""" The problem is that I have no control over the charactors that make up ucMsgStr. These characters are the ASCII conversion of the previous 16 hex values. i.e. a hex memory dump routine. EB70:|30 E8 8A 17 00 00 66 89 04 9F 83 C4 08 43 3B 5C 0.....f......C;\ From clpy at snakefarm.org Fri Jun 22 08:03:11 2001 From: clpy at snakefarm.org (Carsten Gaebler) Date: Fri, 22 Jun 2001 14:03:11 +0200 Subject: File name from file descriptor? Message-ID: <3B3333FF.BB019208@snakefarm.org> Hi there! How can I determine a file's name if I only have the file descriptor? os.fdopen(fd).name just returns '(fdopen)'. Regards Carsten. From rdindir at contactsystems.com Thu Jun 21 07:47:03 2001 From: rdindir at contactsystems.com (Riza Dindir) Date: Thu, 21 Jun 2001 07:47:03 -0400 Subject: Aargh! Function takes exactly x arguments, y given.. Message-ID: <01BE72461A01D5118F8900A0C99D65C305D733@ENGSRV> Hi there, The function 'def MyMethod( x, y ):' is a member function of a class. So if you call 'foo.MyMethod(1, 2)' you are also passing the foo object implicitly. You have to define the function as 'def MyMethod( self, x, y ):'. 'foo' is the third parameter, passed in as self, when used as 'foo.MyMethod( 1, 2 )'. Regards, -----Original Message----- From: Chris Tavares [mailto:ctavares at develop.com] Sent: Wednesday, June 20, 2001 11:11 PM To: python-list at python.org Subject: Re: Aargh! Function takes exactly x arguments, y given.. "David C. Ullrich" wrote in message news:3b2f3759.467766 at nntp.sprynet.com... > On Mon, 18 Jun 2001 08:19:30 -0700, Erik Max Francis > wrote: > > >Anders And wrote: > > > >> I am a happy pythoneer using a combination of C++ and Python for my > >> everyday > >> work. > >> Usually, debugging is easy but every now and then, I get the "function > >> takes > >> exactly x arguments, y given" error message, clearly due to some other > >> problem than what Python thinks. Does anybody have any experience with > >> this > >> particular error message? I don't know what triggers it and thinking > >> back, I > >> think I have solved most of my problems with this message with a major > >> code > >> rewrite. > > > >The error means just what it says: You are calling a function with too > >many or too few arguments. Why you're doing that exactly is something > >we couldn't tell you without code examples that actually give you the > >error. > > > >Only thing I can think of is that you've got a confusion with bound and > >unbound methods; if you call an unbound method (C.f where C is a class > >and f is a method), then you need to provide an instance of C as the > >first method (the implicit self method becomes explicit). > > Or he's not calling the function that he thinks he is, possibly > because of an "import *". > > (I refrained from guessing at first cuz I didn't want to leave > anything out. Is there a natural third possibility?) > The problem I still hit quite often is this: class Foo: def MyMethod( x, y ): pass foo = Foo() foo.MyMethod(1, 2) Boom! Called with three args, expected two. -Chris -- http://mail.python.org/mailman/listinfo/python-list From whisper at oz.nospamnet Thu Jun 14 11:29:17 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 14 Jun 2001 15:29:17 GMT Subject: WHY is python slow? References: <9g5j3p$ird$3@216.39.170.247> Message-ID: <9gal8d$8ft$5@216.39.170.247> In article , phrxy at csv.warwick.ac.uk says... > On 12 Jun 2001, David LeBlanc wrote: > > > In article , > > tim.one at home.com says... > > > > > C++ adds nothing to C that can't be done just as well with > > > preprocessor macros, > > > > > there's-no-accounting-for-mass-delusion-ly y'rs - tim > [...] > > Aside from massive code bloat and agonizingly slow compiles, there are > > just some things in C++ that cannot be expressed using the C > > preprocesser. > > I think you missed the flashing 'sarcasm' sign. > > > John > > Ooops-duh! :-) At least my other post in this thread had the irrelevant and irreverent bits set :-) I thought it was quite witty and nobody said a word about *that* one . Dave LeBlanc From m.bless at gmx.de Wed Jun 6 13:21:53 2001 From: m.bless at gmx.de (Martin Bless) Date: Wed, 06 Jun 2001 17:21:53 GMT Subject: Bios calls in Python? References: Message-ID: <3b1e6611.6945219@news.muenster.de> What about DOS calls? I know the DOS interrupt "get truename of a file" still exists, and that's exactly what I'm looking for. (In case of substituted drives). But I don't know how to call from Python. Martin [Bill Walker]: >Is it possible to make BIOS calls in Python (Windows version)? In >particular, I would like to plot graphic points in EGA resolution to the >console screen. > > From whisper at oz.nospamnet Sat Jun 2 13:20:31 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 2 Jun 2001 17:20:31 GMT Subject: I had a thought ... (I know, call the newspapers). References: <9f5nhn02816@enews2.newsguy.com> Message-ID: <9fb78v$qf5$1@216.39.170.247> In article <9f5nhn02816 at enews2.newsguy.com>, aleaxit at yahoo.com says... > What if it's FASTER too, as MS is these days claiming > for their Currency, see above? I believe the claim is > unfounded, but that's another issue. It still seems > to be little used even by the kind of people who take > any MS claim as gospel:-). Even if it's not faster, it would simplify the language for computer language newbies. Currency might be a comfortable metaphor for people, especially accounting types who probably think a number is naked without a currency symbol. > We can easily supply a Money or Currency or whatever > type today, *APART* from convenience of literals. Maybe > for experimental purposes we can supply that with a > "preprocessor" at import time, ala PyHTML... (I'd use > $ though, much as I love the Euro -- requiring Unicode > source would not endear the concept to most users:-). Rather then stick to a particular character to denote that something is currency, this would be an ideal opportunity to internationalize. Further, by saving the unicode representation of the symbol used ($, Euro, Pound, Franc, Lire, Yen etc.) one has the potential for doing currency conversion with some to be specified __InfixOperator__. FWIW... Dave LeBlanc From efj at mintec.com Tue Jun 19 14:00:51 2001 From: efj at mintec.com (Erik Johnson) Date: 19 Jun 2001 11:00:51 -0700 Subject: Refrence Counting Message-ID: I am unclear about my responsibilities in refrence counting. I am trying to use Python as an extension language. In the code snip below I wish to return an "associative array"/"dictionary" of information. Upon looking through the newsgroup I got a bit paranoid about memory leaks due to incorrect reference counting. Do I need to decrement the reference count for the second dictionary below (grades)? When I use PyStringFromString() it creates the object with a reference count of one, then it is added to my dictionary with PyDict_SetItem() does this increment it again? Should I create it in a seperate step then use PyDict_SetItem() and then decrement it? Thanks in advance for any help. Erik Johnson int _PY_GetCutData(PyObject *self, PyObject *args) { int i, numg; PyObject *ret = NULL, *grades = NULL; do { ret = PyDict_New(); if(!ret) break; if(!PyDict_SetItem(ret, PyString_FromString("Area"), PyString_FromString(cr->area))) break; if(!PyDict_SetItem(ret, PyString_FromString("TotalTons"), PyFloat_FromDouble(_GetTotalCutTons(cr)))) break; grades = PyDict_New(); if(!grades) break; if(!PyDict_SetItem(ret, PyString_FromString("AvgGrade"), grades)) break; for(i = 0 ; i < numg ; ++i) { if(!PyDict_SetItem(ret, PyInt_FromLong(i), PyFloat_FromDouble(_GetAvgCutGrade(cr, i)))) break; } if(i != numg) break; return ret; }while(FALSE); Py_XDECREF(ret); Py_XDECREF(grades); return 0; } From pfortin at pfortin.com Mon Jun 25 14:38:08 2001 From: pfortin at pfortin.com (Pierre Fortin) Date: Mon, 25 Jun 2001 14:38:08 -0400 Subject: creating a matrix in python? References: <3B350DC7.748C3903@telocity.com> Message-ID: <3B378510.7C4459BE@pfortin.com> Adonis wrote: > > how do i go about this? > > i have looked into the tutorial 100+ times and cant get anything on > matrices out of it? > only thing i came up with was some thing like: > blah = ['buh', 'blah', 'wassah'] > blah[1][0] > 'buh' > > ??? ^^^ Right... I get this: >>> blah = ['buh', 'blah', 'wassah'] >>> blah[1][0] 'b' ^^^ Formatted for clarity: >>> m = [[1,2,3], [4,5,6], [7,8,9]] >>> m[1][1] 5 >>> m3 = [[[1,2,3], [4,5,6], [7,8,9] ], [[11,12,13],[14,15,16],[17,18,19]], [[21,22,23],[24,25,26],[27,28,29]]] >>> m3[1][1][1] 15 Pierre > any help would greatly be appreciated. > > Adonis -- Support Linux development: http://www.linux-mandrake.com/donations/ Last reboot reason: 06/22/01: added 512M memory From agavrilov at home.com Thu Jun 7 13:21:29 2001 From: agavrilov at home.com (Alexander Gavrilov) Date: Thu, 07 Jun 2001 17:21:29 GMT Subject: Problem with embedding AND extending with BOOST References: Message-ID: Your error message makes me think that you have to enable Run-Time Type Information. Go to Project -> Settings... -> C/C++ -> C++ Language and check "Enable Run-Time Type Information (RTTI)" checkbox. Hopefully it'll help. -- Alexander Gavrilov Brainbench MVP for C++ http://www.brainbench.com "Emmanuel Astier" wrote in message news:c700d3a2.0106070742.6e225819 at posting.google.com... > Hi, > > I'm quite new to python, and try to extend/embed it (under > Windows/VC6) > > To extend it, I'm using the BOOST python library. > > But I have a problem whenever I want to import a class and use it. > > Here's my code : > > ---------------------------------------------- > main.c : > ---------------------------------------------- > namespace hello { > > class world > { > public: > world(int) {} > ~world() {} > int get() const { return 5; } > }; > > > size_t length(const int& x) { return x;} > } > > #include > > // Python requires an exported function called init in > every > // extension module. This is where we build the module contents. > extern "C" > #ifdef _WIN32 > __declspec(dllexport) > #endif > void inithello() > { > try > { > // create an object representing this extension module > boost::python::module_builder hello("hello"); > > // Create the Python type object for our extension class > boost::python::class_builder world_class(hello, > "world"); > > // Add the __init__ function > world_class.def(boost::python::constructor()); > // Add a regular member function > world_class.def(&hello::world::get, "get"); > > // Add a regular function to the module > hello.def(hello::length, "length"); > } > catch(...) > { > boost::python::handle_exception(); // Deal with the exception for > Python > } > } > > > > void main() > { > PyObject* modname, * mod, *func, *mdict; > long Answer; > > Py_Initialize(); > inithello(); > modname = PyString_FromString("Totohello"); > mod = PyImport_Import(modname); > // Initialisation et verification de Python : > if (mod) > { > Answer = 1; > mdict = PyModule_GetDict(mod); > func = PyDict_GetItemString(mdict, "MyFunction"); > if ( func ) > { > Answer = 2; > if ( PyCallable_Check(func) ) > { > PyObject* rslt; > rslt = PyObject_CallFunction(func, "i", 5); > if (rslt) > { > Answer = PyInt_AsLong(rslt); > Py_XDECREF(rslt); > } > else > { > PyErr_Print(); > Answer = 3; > } > } > } > } > printf("Answer : %i", Answer ); > Py_XDECREF ( mod ); > Py_XDECREF(modname); > Py_Finalize(); > } > > ---------------------------------------------- > Totohello.py : > ---------------------------------------------- > def ChangeFov(a): > from hello import * > MyInst = world(2) > #print MyInst.get() <- Crash when uncommented ! > val = length(5) > return 14 + val > > > > The linker report 2 errors, one of those is : > :\dev\boost\boost_1_22_0\boost\python\detail\extension_class.hpp(225) > : warning C4541: 'dynamic_cast' used on polymorphic type 'class > boost::python::detail::instance_holder_base' with /GR-; unpredictable > behavior may result > d:\dev\boost\boost_1_22_0\boost\python\detail\extension_class.hpp(218) > : while compiling class-template member function 'class hello::world > *__cdecl boost::python::python_extension_class_converters hello::world,class boost::python::det > ail::held_instance >::non_null_from_python(struct > _object *,struct boost::python::type)' > > and effectively, it crashes in the "non_null_from_python" function... > > > As someone suceeded in extended AND embedding python using BOOST ? > > Thanks for any help, > > Emmanuel From ocschwar at mit.edu Sun Jun 3 21:00:24 2001 From: ocschwar at mit.edu (Omri Schwarz) Date: 03 Jun 2001 21:00:24 -0400 Subject: (WIBNI) Grail, the Python web browser. References: <9fe7lj$qf5$2@216.39.170.247> Message-ID: David LeBlanc writes: > In article , ocschwar at mit.edu says... > > I see that the Sourceforge project Grail > > comes with the disclaimer "we don't have time > > to work on it anymore, so knock yourselves out, guys) > > (basically). > > > > But it seems like a nice piece of work. > > Would any Pythonist be interested in restarting the > > project? > > > > -- > > Omri Schwarz --- > > Timeless wisdom of biomedical engineering: "Noise is principally > > due to the presence of the patient." -- R.F. Farr > > > > > It looks like Grail @ sourceforge.net was a victim of the recent > sourceforge trashing. The sourceforge page now claims that this project > has not released any files, but AFAIK it used to offer up at least a > couple of different versions. The CVS repository seems to be intact. > > I wonder if the HTML widget now in WxPython, which inlcudes some tables > etc. wouldn't be a better place to start? I'm thinking of writing something starting with Grail and switching the GUI library to WxPython. I have no time for this at the moment, plus I'm a Python newbie. Maybe in a few months. -- -- Omri Schwarz --- Timeless wisdom of biomedical engineering: "Noise is principally due to the presence of the patient." -- R.F. Farr From LLewin at oreilly.com Thu Jun 7 06:26:02 2001 From: LLewin at oreilly.com (Laura Lewin) Date: 7 Jun 2001 03:26:02 -0700 Subject: Jython book References: <3B18A902.92912FCF@earthlink.net> Message-ID: Hi, I have an eye on Jython as well for a book, and am talking to a few people. Nothing is set in stone yet, so if anyone has any additional ideas or suggestions on the topic, please feel free to email me. (Alex Martelli is quite busy with Nutshell at the moment, but it was a good thought!) Laura LLewin at oreilly.com Ron Stephens wrote in message news:<3B18A902.92912FCF at earthlink.net>... > It seesm to me there is a huge opportunity fro someone to coem out with > the first good book on Jython. It is a good tool, but a really good book > would be of immense help. > > From what I have seen of the knowledge of some on this list, the > capability is theree for someone to write a definitive masterpiece. > > I hope anyway. > > Maybe Alex Martelli??? From sill at optonline.net Tue Jun 19 05:28:53 2001 From: sill at optonline.net (Rainy) Date: Tue, 19 Jun 2001 09:28:53 GMT Subject: Newbie seeking warm bodies References: Message-ID: On Mon, 18 Jun 2001 23:35:42 -0400, Neal Weissman wrote: > would anyone in the long island or nyc area consider having an annoying > newbie user (a newbie asking a lot of annoying questions) dwelling amongst > them? > > i am reading the official python documentation, by Guido van Rossum and > Fred L. Drake, and have just hit a brick wall. > > please respond directly to my email. thanks. > > > /s/ neal weissman > You should try alan gauld's tutorial or 'how to think like a computer scientist' one (google for 'em). The official tutorial is for people who had some coding experience. Also, there are several good books for new to coding, look at the bookshelf at python.org. -- Lucifer Sam Siam cat Always sitting by your side Always by your side That cat's something I can't explain - Syd From michael at stroeder.com Mon Jun 25 11:27:37 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Mon, 25 Jun 2001 17:27:37 +0200 Subject: DistUtils and optimized compile Message-ID: <3B375869.E417C833@stroeder.com> HI! I'd like to use DistUtils for a pure Python module package. Everything seems to be ok so far but when doing python setup.py install only the .pyc byte-code is compiled and installed. I'm missing the .pyo files with the optimized compiled byte-code. Any help's appreciated. Ciao, Michael. From m.faassen at vet.uu.nl Mon Jun 4 13:50:52 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 4 Jun 2001 17:50:52 GMT Subject: I NEED to TEACH you something, QUICK! References: Message-ID: <9fghps$av0$1@newshost.accu.uu.nl> Itamar Shtull-Trauring wrote: > Rainer Deyke wrote: >> Did you actually write all that, or was it algorithmically generated? > Really... can't you recognize a simple Usenet posting on the subject of > "'Usenet discussions about war' as a metaphor for refactoring" when you see > one? Perhaps the confusion is caused by the apparent lack of context/attribution. She seems to be quoting someone in some post that I don't know about. Did you see the original she was replying to, if it existed? Perhaps it's a newsreader configuration problem. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From qrczak at knm.org.pl Mon Jun 25 15:14:05 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 25 Jun 2001 19:14:05 GMT Subject: Newbie seeks help on case preserving substitutions References: <3B3767BB.A882F8@divalsim.it> Message-ID: Mon, 25 Jun 2001 18:32:59 +0200, Nicola Musatti pisze: > I have a number of files which contain different variations of the > same string, e.g. > > ECBASE > ECBase > ecbase > > Which I want to substitute with a different string, while preserving > the original case, e.g. > > OWTEST > OWTest > owtest What should it do if strings have different lengths? E.g. substitute NIcoLA with properly cased Musatti - how to define the problem then? -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From ajm at enteract.com Thu Jun 21 13:35:40 2001 From: ajm at enteract.com (Alan Miller) Date: Thu, 21 Jun 2001 12:35:40 -0500 Subject: launching a file with its associated application on windows References: <9gr70q$bac$1@bob.news.rcn.net> Message-ID: Christian Reyes (christian at rocketnetwork.com) wrote: >Is there a method that takes a file as an argument and then opens that file >with the its associated viewer? Use the Windows "Start" command. import os os.system("start d:\\sample.txt") From emile at fenx.com Wed Jun 27 10:47:34 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 27 Jun 2001 07:47:34 -0700 Subject: regex scanner question References: Message-ID: <9hcrub$ckcs2$1@ID-11957.news.dfncis.de> "Roman Suzi" wrote in message news:mailman.993584693.4336.python-list at python.org... > Is it standard Python feature I could safely use or will it be dropped > soon as it happened to xrange as a sequence type? > Did I miss something? xrange is still in the 2.2a docs http://python.sourceforge.net/devel-docs/lib/built-in-funcs.html#built-in-fu ncs without warning type comments. -- Emile van Sebille emile at fenx.com --------- From gregj at pobox.com Tue Jun 12 05:30:09 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Tue, 12 Jun 2001 09:30:09 GMT Subject: Help for Python newbie References: Message-ID: You can use the join function from the string module like this: >>> import string >>> mylist = ['1', '2', '3'] >>> mystring = string.join(mylist, '\t') >>> mystring '1\t2\t3' Or you can use the string type's join method. The trick is to remember that join is a method of the string, not of the list: >>> mystring = '\t'.join(mylist) >>> mystring '1\t2\t3' This may be clearer: >>> delim = '\t' >>> mystring = delim.join(mylist) Greg Jorgensen PDXperts LLC Portland, Oregon, USA gregj at pdxperts.com ----- Original Message ----- From: "Bob Hibberdine" Newsgroups: comp.lang.python Sent: Tuesday, June 12, 2001 2:01 AM Subject: Help for Python newbie > Hi, > > Any help with the following much appreciated. > > I want to convert a list of items into a tab separated string. According the > Python manuals I can use join: > > I quote from the manual: > > join (words[, sep]) > Concatenate a list or tuple of words with intervening occurrences of > sep. The default value of sep is a single space character...... > > here's the output from the interpreter: > > PythonWin 2.0 (#8, Mar 7 2001, 16:04:37) [MSC 32 bit (Intel)] on win32. > Portions Copyright 1994-2001 Mark Hammond (MarkH at ActiveState.com) - see > 'Help/About PythonWin' for further copyright information. > >>> > >>> import string > >>> mylist = ['1','2','3'] > >>> mystring = '' > >>> mystring = mystring.join(mylist) > >>> print mystring > 123 > > note there is no space between the items. > > Now, I try to use join as I want, I get: > > >>> mystring = mystring.join(mylist,'\t') > Traceback (innermost last): > File "", line 1, in ? > TypeError: join requires exactly 1 argument; 2 given > >>> > > I got my python form ActiveState and am working on Win98. > > Thanks in advance. > Bob Hibberdine From db3l at fitlinxx.com Mon Jun 11 18:06:04 2001 From: db3l at fitlinxx.com (David Bolen) Date: 11 Jun 2001 18:06:04 -0400 Subject: return from finally clause References: <9fr8u3$gj9$01$1@news.t-online.com> Message-ID: "J?rgen Hermann" writes: > That means that if you (accidently?) return within a finally clause, you > effectively eat the exception. This should be documented, or fixed. It is documented - see section 7.4 in the language reference (penultimate paragraph in my 1.5.2 version). It's true if the finally statement raises another execution or uses return, break or continue, and is apparently due to the fact that the finally statement doesn't have access to the exception information while executing. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From loewis at informatik.hu-berlin.de Thu Jun 21 14:05:42 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 21 Jun 2001 20:05:42 +0200 Subject: Codeobjects of Modules? References: Message-ID: gbgbgb at gmx.de writes: > Now I want to run entire pyc-Files and/or modules. How do I get the > bytecode from modules and what is the format of the pyc-files. I could > not find any documentation. Please have a look at the py_compile module. Essentially, it has the magic, a time stamp, and the marshalled code object of the module. > After finishing the PVM in Python I want to port it to - please do not > kill me - JAVASCRIPT. I think this could be interesting to be able to > execute python-byte-code on NS and IE without JAVA. You can already do that, without either Java or JavaScript, using a Python plug-in. For IE, PythonWin supports ActiveScripting out of the box. Regards, Martin From gardner at cardomain.com Sat Jun 9 23:55:25 2001 From: gardner at cardomain.com (Jonathan Gardner) Date: Sat, 9 Jun 2001 20:55:25 -0700 Subject: PYML, Python, Perl and Zope References: Message-ID: <9fuqu9$rep$2@brokaw.wa.com> John Abbe wrote: > PYML looks very neat for web delivery (Python embedded in HTML). > > http://www.pyml.org/ > > With Python 2.1 does it still need the SGML thing? > > Is there anything like it for Perl? > Take a look at HTML::Mason (for Perl). I don't think it can get much better than that. Very fast development time. From piet at cs.uu.nl Mon Jun 18 09:46:22 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 18 Jun 2001 15:46:22 +0200 Subject: Loading select queries into objects References: Message-ID: >>>>> "Graham Ashton" (GA) writes: GA> Hi. I've just started playing with database access from Python and have GA> stumbled across yet another hole in my knowledge of Python idioms. GA> I've got a class that has an attribute for each column in a database GA> table, and an accessor method that sets the value of each attribute. I GA> then populate the attributes with the result of a database query. GA> Here's an example: GA> query = """ GA> SELECT column1, column2, some_column GA> FROM a_table GA> """ GA> cursor = self.db.cursor() GA> cursor.execute(query) GA> tup = cursor.fetchone() GA> self.column1(tup[0]) # this could be better! GA> self.column2(tup[1]) GA> self.some_column(tup[2]) GA> What I'm wondering is; is there an idiomatic way of applying the values GA> in a tuple to a list of functions? In Perl I'd use map(), but I'm not GA> sure if there's a "cleaner" way in Python. If you can use map in Perl, you can use map in Python. But I don't think this problem can be solved easily with map, because map applies a single function to a sequence, not a list of functions to a sequence. That is, if I understand how you want to do it: The list of functions is [f0, f1, f2] and you want: f0(tup[0]) f1(tup[1]) f2(tup[2]) You could do something like: funlist = (self.column1, self.column2, self.some_column) for i in range (len(funlist)): apply(funlist[i],(tup[i],)) or use zip. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From bruce.g.stewart at worldnet.att.net Sun Jun 3 10:46:42 2001 From: bruce.g.stewart at worldnet.att.net (Bruce G. Stewart) Date: Sun, 03 Jun 2001 14:46:42 GMT Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> Message-ID: <3B1A4DC3.4B6EBCE@worldnet.att.net> TGOS wrote: > > On Sat, 2 Jun 2001 22:31:50 +0200, "Polterguy" > wrote: > > > [...snip...] > > I agree totally, but fact is 99.99999% of the commersial world uses win32. > > Are you sure you understand the term "commercial"? > Windows is mainly used by private users and not even there 99% of them use it. Polterguy is unduly pessimistic about the hegemony of Windows, but your reply is also unrealistic. > Do you think a nuclear power plant runs with Windows? Or maybe the software of > an airport tower? If that's the case, how many people do you think would die > during a blue screen error? Most computer systems, even in the nuclear power and air transport industries, are not in life critical applications. > Do you think the majority of worldwide banks use Windows? An easy to hack, > insecure and not very stable operating system? A blue screen would mean loosing > millions of dollars a minute and a single hack would make every hacker a rich > man. Yet most do use it. Not exclusively, but for desktop client machines, it's very pervasive throughout the financial industry. > At my university are over 2,000 PCs and not a single one runs with Windows. You are perhaps fortunate, but not typical. One might wonder why this is. Surely some individuals or departments could benefit from some commercial software that is only available for Windows. Are your systems implemented in some proprietary, non-cross-platform way? > On which planet are you living? > You probably think that 99% of all CPUs currently in use are x86 CPUs, right? > Well, that's damn wrong. Not even 40% of all CPUs are x86 compatible ones. > (Source: Market Research of '99...not quite up-to-date, but there hasn't > changed that much in the last 1 and half years) > And with what OS do you think run the other 60%? Certainly not with Windows. A large percentage of CPUs aren't in personal computers. Many toil away in microwave ovens, cd players, electric toothbrushes, etc. These aren't particularly relevent to questions about 3D graphic maniplulation over the www. [...] The main point of your post is well taken. A cross-platform interface standard is preferable to a platform specific one, other things being equal. But there's not much point in answering hyperbole with hyperbole. From slobin at ice.ru Tue Jun 12 23:34:45 2001 From: slobin at ice.ru (Cyril Slobin) Date: 12 Jun 2001 20:34:45 -0700 Subject: Python for MS-DOS (was: Re: RS232 support for DOS on 486?) References: Message-ID: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) wrote in message news:... > I tried downloading file: > > ftp://ftp.ice.ru/pub/slobin/python/pythonx.zip > > which may only be read by user 1010, is not downloable by anonymous FTP. > Could this be adjusted? Sorry, fixed. From rnd at onego.ru Wed Jun 20 01:42:11 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 20 Jun 2001 09:42:11 +0400 (MSD) Subject: Re. PythonCard - was Re: Event-driven GUIs ... In-Reply-To: <3B2EC98E.FE0F1B6E@earthlink.net> Message-ID: On Wed, 20 Jun 2001, Ron Stephens wrote: > One could only suggest Roman Suzi and Neil Hodgson since they were the > first two to mention HyperCard. (and it sounds like they know what > they're talking about) > > Of course one would hope that some of the followers could actually > produce good code...;-))))) Wow! I sleeped alittle and the idea of PythonCard growed to the extent separate maillist were created and I am almost appointed leader ;-) Well, if you want to look at my failed project, please do: http://cvs.seul.org/~rnd/index.html It's a tool for quizzes, stalled at design stage... :-( Of course, I have some design ideas for the PythonCard, but I can't lead at this time. BTW, about leading in Open Source projects, please, read a thoughtful article at: http://www.seul.org/edu/oss.project.leadership.html Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From hgg9140 at cola.ca.boeing.com Mon Jun 25 14:42:07 2001 From: hgg9140 at cola.ca.boeing.com (Harry George) Date: Mon, 25 Jun 2001 18:42:07 GMT Subject: creating a matrix in python? References: <3B350DC7.748C3903@telocity.com> Message-ID: Do you mean matrices as in linear algebra? If you have installed the Numeric package, the process is, e.g.: mat=zeros((4,4),Float64) Adonis writes: > how do i go about this? > > i have looked into the tutorial 100+ times and cant get anything on > matrices out of it? > only thing i came up with was some thing like: > blah = ['buh', 'blah', 'wassah'] > blah[1][0] > 'buh' > > ??? > > any help would greatly be appreciated. > > Adonis > -- Harry George E-mail: harry.g.george at boeing.com The Boeing Company Renton: (425) 237-6915 P. O. Box 3707 02-CA Everett: (425) 266-3868 Seattle, WA 98124-2207 Page: (425) 631-8803 From jwolff at ision.nl Fri Jun 15 02:31:18 2001 From: jwolff at ision.nl (Jeroen Wolff) Date: Fri, 15 Jun 2001 08:31:18 +0200 Subject: IP address to binary conversion References: Message-ID: > >>>> host = n & mask >>>> net = n - host >>>> print "net: %X host: %X" % (net, host) >net: C0000000 host: A80201 > Is there a way back to present the calculated results in a doted decimal notation? Jeroen From rajarshi at presidency.com Fri Jun 8 14:38:23 2001 From: rajarshi at presidency.com (Rajarshi Guha) Date: Sat, 9 Jun 2001 00:08:23 +0530 Subject: Just a small quine References: <3b1fa942.11180453@news.t-online.de> Message-ID: <9fru2m$5n2f8$1@ID-91520.news.dfncis.de> Gerson Kurz wrote in message news:3b1fa942.11180453 at news.t-online.de... > > import sys > > z,x,y= "}{|}A|k{|kA|}=BE1)|BF}))|$}:~pI~/;@Go{H%{&A?|if }:~pJ"\ > "IJ-1~#>=0:GoAG at HG;o{G;%-I&{?|m,kJ,j=C?;/@~o{~D:Gl[c]("\ > ")?","G$p:%~;%~;el!]':p%break~;![':p%# "%if c=='%while o%\n%m[k]%+=1%\t%if not %c=j[o]%-=1%sy"\ > "s.std%[0]*64000,0,0,u%if l.has"\ > "_key(c)%in.read(%out.write(chr(%=1%,o".split('%'),"HG"\ > "&%/~!#?}{;$@ABCDEFIJ" What *is* a quine? How do you work out the code you wrote? -- ------------------------------------------------------------- Rajarshi Guha email: rajarshi at presidency.com web: http:/www.psynet.net/jijog From michael+gnus at trollope.org Fri Jun 22 10:27:52 2001 From: michael+gnus at trollope.org (Michael Powe) Date: 22 Jun 2001 07:27:52 -0700 Subject: Another Wart! string.find() [ was: namespace issue? ] References: Message-ID: >>>>> "Steven" == Steven D Majewski writes: Steven> ( But I can't really think of a good reason for Steven> string.find to return -1 *except* that it wouldn't Steven> surprise a C programmer. ) Well, if we had boolean values, it could just return false! I wonder what percentage of the time string.find() is used just as I was using it, to check for the existence of a substring rather than actually doing something with it when found. Maybe, we just need the python equivalent of strchr() in C (returns a pointer or NULL, i.e., true or false). mp From fredrik at pythonware.com Thu Jun 14 15:40:51 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 14 Jun 2001 19:40:51 GMT Subject: PEP 259: Revise to remove context-driven magic from print References: <486de2.0106131406.5c0cbef9@posting.google.com> <9gamor$8ft$6@216.39.170.247> Message-ID: <7r8W6.5407$G4.842350@newsc.telia.net> David LeBlanc wrote: > I don't see why you consider this a joke, nor do I see the > ignorance and arrogance which you seem to. you forgot to mention how many years you've been programming. From chris.gonnerman at newcenturycomputers.net Wed Jun 13 01:14:44 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Wed, 13 Jun 2001 00:14:44 -0500 Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: <9g5486016t4@enews2.newsguy.com> Message-ID: <004701c0f3c7$c4a59000$0101010a@local> ----- Original Message ----- From: "Alex Martelli" Newsgroups: comp.lang.python To: Sent: Tuesday, June 12, 2001 8:08 AM Subject: Re: [Python-Dev] PEP 259: Omit printing newline after newline > "Chris Gonnerman" wrote in message > news:mailman.992346739.24842.python-list at python.org... > > From: "Roman Suzi" > > > No, no! Do not take print away! It help to migrate from Basic! ;-) > > > > This is the best single reason I can see OTHER than not breaking existing > > scripts. > > Not just BASIC, but Perl, and SO MANY other languages have a print > > statement. > > Ah, yes. Perl compatibility is definitely a must, isn't it...? > > Not VB, because that has no "print statement" -- is has a > "print #" statement, and the #filenumber part is mandatory; > it writes to a disk file. > > Not C, which uses a printf *FUNCTION*. Not C++ (which uses > the << operator). Not Java. If compatibility or migration > help from other languages is "the best reason" (apart from > not breaking working code) for print's existence as a > statement, then it seems the reasons in print's favour > are even weaker than I thought. Trust Alex to beat me over the head with the facts... :^) Note that tcl has a puts statement which fundamentally works like Python's print... just with a different name. Languages with a print statement fundamentally similar to Python/Perl: BASIC bc ksh Languages with a very similar statement with a different name: *nix sh/csh echo REXX say > Meanwhile, there ARE people out there (beginners, but not > idiots:-) who might like > print > to PRINT -- yet when they use it, their printer doesn't do > anything... stuff gets displayed on-screen, NOT printed. Point. > Those guys and gals have never seen a 'printing terminal', > and this idiomatic usage of a verb which DOES have an > obvious, different, and perfectly current meaning in > 'computerese' is hardly a good idea in a CP4E setting. Point. > > IMHO Alex's output() function is not really necessary. If you hate print, > > use fileobj.write(), and leave us print-users alone. > > Several built-in functions "are not really necessary". > Why have dir(x) when vars(x).keys() is equivalent, for > example? Speed, convenience, solidity. > > If an output function were defined, it could play the > same role wrt the print statement as __import__ plays > wrt the import and from statements. The statement > would remain (of course: breaking a vast majority of > all scripts would be silly), *AND* it would be > defined and documented to internally invoke the function. Well why didn't you say so? THAT sounds like a FINE idea! > So the programmer gets a chance to "override" the > function and get a global effect even when another > module used the statement instead. Perhaps, in this > spirit, the function should be named __print__, then. I agree here... __print__ is to print as __import__ is to import. > > Aesthetics alone are not a good enough reason for such a fundamental and > > painful change. > > Absolute agreement here! Aesthetics are shifty, and a > frail reed indeed. Hardly good reason for ANY change > (for doing things right in the first place, maybe, but > not even Guido can get 100% right -- yet he has a far > better track record in taking right design decisions > than anybody else I've ever met or heard about:-). Glad I didn't totally bomb... > But the statement/function distinction is NOT chiefly > about "aesthetics". It IS chiefly about functionality. > > print has no real reason to exist as a statement, but, > OK, it get grandfathered in (note that this would argue > for leaving the default to respect-all-newlines, rather > than Guido's new idea of removing SOME newlines). EXACTLY. As I so often ask customers, "what does this buy you?" > Having > print as a statement gives no real advantage, but it does > give some disadvantages _unless_ the underlying functionality > can be tweaked. You can do MANY tweaks by using a wrapped > file-like-object as stdout, but NOT all -- the file-object > is not "told" about how many print statements are being > processed, so it can't do such tweaks as the one that is > now being proposed by Guido. A __print__ underlying > function would solve that. Having a friendly name such > as output is nice but secondary. I'll happily agree to an "undercover" change to print which does not break all my existing CGI scripts. Explicit is better than implicit, right? So given that I read the manual and know that print adds a newline, and I add a newline, any errors are my own fault. Have it start taking them out and BOOM. Changing print to call __builtins__.__print__ (and allowing that function to be overridden) would give the changemongers something to use and leave us old-fashioned types safe. From grante at visi.com Sat Jun 2 00:08:40 2001 From: grante at visi.com (Grant Edwards) Date: Sat, 02 Jun 2001 04:08:40 GMT Subject: Why isn't Python king of the hill? References: Message-ID: On Fri, 1 Jun 2001 16:35:03 -0700, Geoffrey Gerrietts wrote: >The big problem with binary FP is that most people (myself >included) don't know when to expect approximation rather than >an exact result. Always expect an approximation. Surprise is one of the 3 main weapons of floating point... The secret to using binary floating point successfully is to _never_ expect an exact result and not to use binary floating point if you require an exact result. You may thing that 1.0 + 2.0 == 3.0 ought to be true, but you should always treat floating point operations as if there are small random numbers being thrown in at every step. So you should check for fabs((1.0 + 2.0) - 3.0) < [a small number] Choosing the value for [a small number] is left as an exercise for the reader. -- Grant Edwards grante Yow! Did you find a at DIGITAL WATCH in YOUR box visi.com of VELVEETA?? From aleaxit at yahoo.com Thu Jun 14 10:31:21 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 16:31:21 +0200 Subject: Integrating a Python GUI into a PowerBuilder App References: <49624b0b.0106121135.61b6bd6c@posting.google.com> <49624b0b.0106140505.79851658@posting.google.com> Message-ID: <9gahru048k@enews1.newsguy.com> "John Urberg" wrote in message news:49624b0b.0106140505.79851658 at posting.google.com... ... > > application. I'd really like to push Python as the new language, but > > I need to find a way to seemlessly integrate a Python GUI into the > > PowerBuilder app (i.e. as child windows of the MDI). I would expect ... > Should I assume from the lack of response to this and other tries that > integrating a Python GUI into a PowerBuilder app is an impossible > task? Time to give in and settle for Java or VB? If a "Java GUI" can be "a child window of the MDI", I'm astonished (I would have thought it impossible!) -- but if you can do it in Java you can do it in Python (Jython, to be precise, since it can use ANY GUI class that Java can use). If a "VB GUI" can be "a child window of the MDI", I'm astonished (I would have thought it impossible!) -- but if you can do it in VB you can do it in Python (Python on Win32 has excellent COM support, and so it can control any "VB GUI", since VB exposes things in COM terms). So, no need to settle for either Java or VB. Once you've found how to use their GUI's "as child windows of the MDI", let us know, and, albeit bereft of any PowerBuilder knowledge whatever, it will be reasonably easy for us to show how to use Python. Alex From ej at ee.duke.edu Thu Jun 7 01:38:03 2001 From: ej at ee.duke.edu (eric jones) Date: Thu, 07 Jun 2001 05:38:03 GMT Subject: Recursive algorithms anyone? References: <1f0uhtgmhb0vlud6pof6i4mctqjdq8l2eu@4ax.com> Message-ID: <%qET6.7830$ru2.2769757@typhoon.southeast.rr.com> Here is an alternative approach: def add_item(val,lst): new_lst = [] for item in lst: if type(item) is type([]): new_lst.append(add_item(val,item)) else: new_lst.append(item + val) return new_lst print add_item(1,[1,2,[3,4,[5,6]],7]) [2, 3, [4, 5, [6, 7]], 8] "Kirby Urner" wrote in message news:1f0uhtgmhb0vlud6pof6i4mctqjdq8l2eu at 4ax.com... > > > How to implement in Python the classic thing of > adding k to every item in a list. Except a list > may contain other lists to arbitary depth? > > I say classic because it's the kind of thing you > do in computer science 101. > > E.g. >>> additem(1,[1,2,[3,4,[5,6]],7]) > [2,3,[4,5,[6,7]],8] > > Here's the Scheme solution: > > (define (additem items k) > (cond ((null? items) null) > ((not (pair? items)) (+ items k)) > (else (cons (additem (car items) k) > (additem (cdr items) k))))) > > > My best Python attempt so far: > > >>> def additem(items, k): > if not type(items) == type([]): return items + k > if len(items)==0: return [] > return [additem(items[0],k)] + additem(items[1:],k) > > >>> additem([[9,8],1,2,3,4,[1,2, [5,6]]],1) > [[10, 9], 2, 3, 4, 5, [2, 3, [6, 7]]] > > But maybe there's a better solution? > > Kirby > > CC pdx4d at teleport.com por favor > From rnd at onego.ru Sun Jun 17 01:45:35 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 17 Jun 2001 09:45:35 +0400 (MSD) Subject: in statement and namespace type ideas In-Reply-To: <3B2BD14A.1545DA9F@alcyone.com> Message-ID: On Sat, 16 Jun 2001, Erik Max Francis wrote: >Roman Suzi wrote: > >> I also thought about absent "with" operator and how it could be used >> in Python. Maybe it is beneficial to have "with" syntax like in the >> followin example: > >This gets suggested about once a month or so. Check Google Groups for >reaseons why it's not a very good idea for Python. Maybe its because "with" could not be find in archives ;-) Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, June 17, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Tis better to have loved a short than to never have loved a tall." _/ From akuchlin at mems-exchange.org Mon Jun 18 11:59:23 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 18 Jun 2001 11:59:23 -0400 Subject: Using the Python license References: Message-ID: <3dsngxeq3o.fsf@ute.cnri.reston.va.us> "Thomas" writes: > And, does anyone have a link to some comparative information about the > different licenses? I'm interested in the main 'anything goes' licenses: > Python, BSD, and the LGPL. The differences between the Python and BSD/X11 licenses stem from CNRI's legal counsel not believing that the BSD license is actually valid, for various incomprehensible and/or unconvincing reasons. This is why the Python 2.0 license is a page long and the BSD license is three paragraphs. You can use the Python license if you like, but why not just use the X11 license? (The X11 license was also the Python 1.5.2 license) --amk From Denys.Duchier at ps.uni-sb.de Wed Jun 20 14:13:00 2001 From: Denys.Duchier at ps.uni-sb.de (Denys Duchier) Date: 20 Jun 2001 20:13:00 +0200 Subject: PEP 255: Simple Generators References: Message-ID: Denys Duchier writes: > > def zipgen(g, h): > > giter = g() > > hiter = h() > > while 1: > > yield giter.next() > > yield hiter.next() > > which I would write as follows: > > def zipgen(g,h): > def result(yield): > g(yield) > h(yield) > return result That last part of my message flowed from my fingers into the keyboard without being appreciably slowed down by the mush between my ears :-) Tim was describing interleaving and I implemented concatenation which Tim might have written as: def concgen(g,h): for x in g(): yield x for x in h(): yield x Cheers, -- Dr. Denys Duchier Denys.Duchier at ps.uni-sb.de Forschungsbereich Programmiersysteme (Programming Systems Lab) Universitaet des Saarlandes, Geb. 45 http://www.ps.uni-sb.de/~duchier Postfach 15 11 50 Phone: +49 681 302 5618 66041 Saarbruecken, Germany Fax: +49 681 302 5615 From luthi at vaw.baug.pleasedontspamme.ethz.ch Thu Jun 7 15:57:29 2001 From: luthi at vaw.baug.pleasedontspamme.ethz.ch (luthi at vaw.baug.pleasedontspamme.ethz.ch) Date: 07 Jun 2001 21:57:29 +0200 Subject: RS232 support for DOS on 486? Message-ID: I wonder if someone has managed to use the serial port (RS232) with Python on a 486 with MS-DOS. I have to use a (old, rugged) 486 for data recording of a TEK-Scope and would like to customize the communication. I am grateful for any advice Martin L?thi From MCStoufer at lbl.gov Tue Jun 19 14:06:41 2001 From: MCStoufer at lbl.gov (Martin Stoufer) Date: Tue, 19 Jun 2001 11:06:41 -0700 Subject: Explicit ConfigParser.options() call? Message-ID: <3B2F94B1.235E48FE@lbl.gov> Is there any intelligent way to get *just* the options in a specific subsection in a .cfg file? The call returns all the stuff in [DEFAULT] as well. Is this worthy of an addition to the module? -MArtin -- perl -le '$_="6110>374086;2064208213:90<307;55";tr[0->][ LEOR\!AUBGNSTY];print' From avv at quasar.ipa.nw.ru Thu Jun 7 15:50:18 2001 From: avv at quasar.ipa.nw.ru (Alexander V. Voinov) Date: Thu, 07 Jun 2001 12:50:18 -0700 Subject: WHY is python slow? References: <4.3.2.7.2.20010607144657.042f8328@bdg.centrin.net.id> Message-ID: <3B1FDAF9.1CCCE7D1@quasar.ipa.nw.ru> Hi Thomas Wouters wrote: > I don't know that Ruby is faster than Python, .... You may visit the below site under the terms and conditions of the following license: I HAVE READ ALL AVAILABLE LITERATURE AND DISCUSSIONS ABOUT LANGUAGE COMPARISONS BASED ON BENCHMARKS AND FULLY UNDERSTAND THE LIMITATIONS OF THE LATTER. If you are NOT agree with this statement as applicable to you, you must NOT follow this link: http://www.bagley.org/~doug/shootout/ Alexander From sill at optonline.net Sat Jun 9 16:28:50 2001 From: sill at optonline.net (Rainy) Date: Sat, 09 Jun 2001 20:28:50 GMT Subject: create backup script in python References: <7b515e0f.0106011730.6b1aa82d@posting.google.com> Message-ID: On 9 Jun 2001 11:26:21 GMT, Fredrik Steen wrote: > On Sat, 02 Jun 2001 15:22:44 GMT, Rainy wrote: >> On 1 Jun 2001 18:30:48 -0700, eric_brake wrote: >>> What is the easiest way to write a file copy script in python? I want >>> to use the script as a way to backup any file I choose on my hard >>> drive. Binary mode is best while handling this range of file types, >>> Correct? >>> >>> thank you >> >> Backup to where? I made a little script that backs up my home directory >> to a cdrw disk, it uses mkisofs and cdrecord (unix programs). >> >> > > Would you share your script? > Sure.. I think I appended it to original message but then someone snipped it. Anyhoo, here it goes: #!/usr/bin/env python #----------------------------------------------------------------------- # # # Send bug reports, comments to Andrei Kulakov # Last Updated: Fri Aug 11 22:03:27 EST 2000 # Copyright (C) 2000 Andrei Kulakov #----------------------------------------------------------------------- import os, sys homedir = os.path.expanduser('~sill/') # cdrw device (cdrecord argument) dev = '0,0,0' def print_help(): print 'backup.py script' print 'Usage: backup.py ' sys.exit() try: image_file = sys.argv[1] except IndexError: print '*** Error: need one argument.' print_help() os.system('cp -r /etc ' + homedir) os.system('mkisofs -R -o ' + image_file + ' ' + homedir) os.system('cdrecord -v -blank=fast -speed=2 -dev=' + dev) os.system('cdrecord -v -dev=' + dev + ' -speed=2 -fs=8m ' + image_file) answer = raw_input('Erase image file? [Y/n]') if answer == 'Y' or answer == '': os.remove(image_file) os.remove(homedir + '/etc') -- Don't be so humble -- you are not that great - Golda Meir From sholden at holdenweb.com Thu Jun 28 21:47:59 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 28 Jun 2001 21:47:59 -0400 Subject: Terminating a local process COM server Message-ID: For efficiency reasons I am implementing a credit-card checking algorithm as a COM LocalServer object. For debugging purposes I would like to be able to terminate the current instantiation (i.e. process), so I can start another one with revised Python code. It would also be nice, in production, to have some way to terminate the LocalServer process so that the next instantiation of the COM object restarts the server in a new process. I'm aware that this would invalidate references to any objects created by the process, but for testing it *would* be "comvenient" not to have to kill the COM server process manually. Anyone help? Or at least explain where I'm mistaken if this isn't a sensible goal... regards Steve -- http://www.holdenweb.com/ From root at rainerdeyke.com Fri Jun 22 18:54:12 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 22 Jun 2001 22:54:12 GMT Subject: PEP 255: Simple Generators References: <9h0crt$rq6$1@slb1.atl.mindspring.net> Message-ID: "Andrew Dalke" wrote in message news:9h0crt$rq6$1 at slb1.atl.mindspring.net... > There isn't quite enough information to distinguish between at > least some class definitions and function definitions without the > use of a keyword. Consider > > >>> class SuperTest: > ... pass > ... > >>> def Test(SuperTest): > ... def __init__(self, spam): > ... self.spam = spam > ... def __str__(self): > ... return str(self.spam) > >>> t = Test("eggs") > >>> str(t) > 'None' > >>> How about a new rule that requires the 'return' statement in a function? # Class: def c(): def __init__(self, spam): self.spam = spam # Function: def f(): def __init__(self, spam): self.spam = spam return # Null generator: def g(): def __init__(self, spam): self.spam = spam return yield None -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From tim.one at home.com Wed Jun 27 14:34:50 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 27 Jun 2001 14:34:50 -0400 Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: [Carsten Geckeler] > ... > Do you really mean that? I would not start teaching Icon generators in > the context of simple looping like in > > every i:= 1 to 10 > do write(i) Griswold does. In the 3rd edtion of "The Icon Programming Language", the first two examples of generators are every i := find(s1, s2) do write(i) and every i := 1 to limit do write(i^2) immediately contracted to every write((1 to limit)^2) >> except that Icon also has many other kinds of "special context" >> shere generators act reasonably. > This other "special context" of expressions failing and fallback is > acutally the core idea of Icon. Alternation and conjunction are also explicit generative control structures, distinct from the "every" and "suspend" generative control structures; I assume you lump them in with "expressions", but it's really subtler than that. In a similar way, "and" and "or" are really more control structures in Python than operators. Expression evaluation in Icon also invokes conjunction implicitly all over the place, but not across statements, or across the X and Y in "every X do Y", etc. > Probably most of the readers of this list are not really familiar > with Icon, so some examples may be useful. That's fine, but I'm going to skip it as the relationship to the PEP is getting too thin: PEP 255 isn't aiming at goal-directed evaluation, just at generators. From zen at shangri-la.dropbear.id.au Tue Jun 19 20:38:36 2001 From: zen at shangri-la.dropbear.id.au (Zen) Date: 20 Jun 2001 11:38:36 +1100 Subject: PEP 255: Simple Generators References: <9glhg7$dlk$1@nntp6.u.washington.edu> Message-ID: <3b2ffe9c$1@mercury.its.rmit.edu.au> "Russell E. Owen" writes: >Several proposals come to mind. They are all compatible with each other: >1) Have users explicitly say "raise StopIter" when they mean it. This is >2) Add a keyword, such as "stop". It could always raise StopIter, or >3) Have "return" mean exactly what it means now, but also have a 4) Have 'yield' with no arguments raise a StopIter. Having 'yield' and 'return' in the same function could then become a syntax error. Alternativly, it could be used to save a few lines for things-that-generate-infinitly. def mygen(): for i in range(1,10): yield i return 10 may be identical to def mygen(): while 1: for i in range(1,11): yield i This would also makes the following a valid generator: def void(): return None From rsiebler at ibeam.com Thu Jun 21 15:26:15 2001 From: rsiebler at ibeam.com (Robin Siebler) Date: Thu, 21 Jun 2001 19:26:15 GMT Subject: How to stop/start/check a service. Message-ID: I'm new to Python and I have ActivePython installed. Could someone give me an example of how to start/stop/check a service? Thanks! From mal at lemburg.com Fri Jun 15 16:28:00 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 15 Jun 2001 22:28:00 +0200 Subject: Office's Access XP ODBC DBI from PythonWin References: <9ga6cd02m44@enews1.newsguy.com> <9gctnb06cu@enews1.newsguy.com> Message-ID: <3B2A6FD0.4EAA1ECE@lemburg.com> Alex Martelli wrote: > > > I believe that the mxODBC license is very liberal > > compared to other commercial software (usage is free for private > > use, you get the complete source code, etc.) and certainly not > > too expensive for a company to license. > > Absolute agreement. But the issue I have in mind is: Fred Smith > is all fired up about using his newfound Python skills to make > a little utility for company internal use, which needs to access > various corporate and departmental databases. He tries doing it > with the free odbc, but that one keeps crashing -- forget it. So > he faces a choice: > a. doing it with ADO, using the freely downloadable win32all > extensions and freely downloadable MSDAC > b. convincing the boss to pay for an mxODBC license > Advantage of [b] is getting sourcecode AND being able to run the > resulting utility on Linux boxes. Advantage of [a] is, Fred can > get right down to programming and avoid the boss-convincing step. > > If Fred is REALLY REALLY *VERY* KEEN to have sourcecode to all > he uses, he may try [b] -- and may be or not be able to convince > the boss. Most Freds in this world, I fear, will go for the > easier choice of [a] instead. Most bosses are Windows-heads > anyway and, for an utility that's not going to be a revenue > generator for the company anyway, will instantly pick [a], too. > > If the free odbc didn't crash quite SO much, maybe it could be > kept as a viable c. choice -- and help in a tiny way to make > Linux boxes (and maybe free BSD variants too:-) more viable... If Fred doesn't need maintained and supported software, then he could stick with mxODBC 1.1.1 which still is around. That's free for commercial inhouse usage too, but the setup is somewhat more difficult (no distutils support) and the version is no longer being actively maintained. > > > I don't mind that, I can understand where he was coming from... But > > > win32's ODBC code seems to work fine for our purposes, and should still > > > be developed....or maintained... > > > > > > MxODBC can't be the only ODBC code out there..... > > > > ODBC is *very* complicated and maintaining an interface for it > > to make the user experience a painless one *very* time consuming. > > You are surely right on this (which underscores Microsoft's > wisdom in not-so-opaquely divorcing themselves from ODBC in > a gradual way and pushing for their Ole/DB-ADO approach...). They are not having much fun with their new standards either -- just look at how often they have switched technologies and interfaces in the last few years. ODBC, OTOH, is getting better and faster and the old prejudice of ODBC being slow is no longer true. In fact, many DB vendors have switched to ODBC as their native C level API. IBM with DB2 is a prominent example. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From sill at optonline.net Thu Jun 14 16:41:26 2001 From: sill at optonline.net (Rainy) Date: Thu, 14 Jun 2001 20:41:26 GMT Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> <9g8q7t0uib@drn.newsguy.com> <9ga811013r@drn.newsguy.com> Message-ID: On 14 Jun 2001 04:43:29 -0700, thinkit wrote: > In article , "Steve says... >> >>"thinkit" wrote in message >>news:9g8q7t0uib at drn.newsguy.com... >>> In article , >>> Tom_Good1 at excite.com says... >>> > >>> >thinkit wrote in message >>> >news:<9g5d3p0f0p at drn.newsguy.com>... >>> >> humans should use a power of 2 as a base. this is more logical because >>it >>> >>synchs with binary, which is at the very heart of logic--true and false. >>it is >>> >> more natural perhaps, to use decimal--but logic should, and will, win >>out. >>> > >>> >I'm amused by the idea that "humans should [do something] because . . >>> >. it is more logical." Ah yes, we humans are so extremely logical. >>> >That's why advertisers -- whose livelihood depends on getting us to do >>> >things -- inevitably appeal to our highly refined sense of logic, and >>> >never play to our emotions or baser instincts ;-) >>> >>> some of us are...and those that are will easily dominate or destroy the >>rest. >>> >>If you're bent on world domination, perhaps you should apply for a job at >>Microsoft? >> >>regards >> Steve >>239 (decimal) > > microsoft caters to the dumb in the worst kind of ways. i know bill's a smart > guy, so maybe he's building up money to unleash the forces...but i doubt it. > To unleash the awesome powers of hexadecimal upon the world? Yeah, I somehow doubt that also ;-). -- Jupiter and Saturn Oberon Miranda And Titania Neptune Titan Stars can frighten - Syd From emile at fenx.com Sat Jun 2 20:20:48 2001 From: emile at fenx.com (Emile van Sebille) Date: Sat, 2 Jun 2001 17:20:48 -0700 Subject: Copying files to multiple comp's on a lan References: <9f8k3v$1i04$1@news.cybercity.dk> <9fbmbk$2acl$1@news.cybercity.dk> Message-ID: <9fc04d$3cmch$1@ID-11957.news.dfncis.de> Attached below is a script I put together that runs on a win2k box and backs up the windows shares of other systems in the local network. Perhaps there's some ideas you can use. HTH, -- Emile van Sebille emile at fenx.com #!python ## netBackup.py import os import string from win32pipe import popen3 from time import time, localtime def targetSystems(): "return list of active systems on the network" retval = [] systemsList = popen3("net view")[1].readlines() for line in systemsList: i = string.split(line) if i: i = i[0] isServer = string.find(i,'\\\\') + 1 if isServer: retval.append(i) return retval def backupFolderList(targetSystem): " return list of shares on target system that should be backed up" retval = [] cmd = "net view %s" % targetSystem shares = popen3(cmd)[1].readlines() for share in shares: shareInfo = string.split(share) try: shareName = string.join(shareInfo[0:shareInfo.index('Disk')],' ') if len(shareName) != 1: retval.append(shareName) except: pass return retval def setBackupDestination(): today = localtime(time()) thisMonth = today[1] dayOfMonth = today[2] dayOfWeek = today[6] # 0(Monday) - 6(Sunday) dayOfYear = today[7] if dayOfMonth == 5: backUpDrive = 'HI'[thisMonth % 2] backupDestinationFolder = 'Monthly' elif dayOfWeek == 6: #It's Sunday backupDrive = 'HI'[dayOfYear % 2] backupDestinationFolder = 'Sunday' else: backupDrive = 'HI'[dayOfWeek % 2] backupDestinationFolder = ['MWF','TTS'][dayOfWeek % 2] return r'%s:\Backups\%s' % (backupDrive, backupDestinationFolder) def backupFolder(target, folder, backupDestination, trace=1): "backup contents of folder on target" cmd = r'xcopy "%s\%s\*.*" "%s\%s\%s" /D /E /C /I /K /X /Y' % (target, folder, backupDestination, string.split(target,"\\")[-1],folder) rslt = popen3(cmd)[1].readlines() if trace: print rslt def excludeSystems(): return [r'\\spam', r'\\parrot'] def backup(): backupDestination = setBackupDestination() for target in targetSystems(): if target not in excludeSystems(): sysName = string.split(target,r"\\")[-1] print "\n\nBacking up %s " % target folders = backupFolderList(target) if folders: if not os.path.isdir(r'%s\%s' % (backupDestination, sysName)): os.mkdir(r'%s\%s' % (backupDestination, sysName)) open(r'%s\%s\%s' % (backupDestination, sysName, 'BackupStart'),'w').write('Backup Start Time') for folder in folders: print " ", folder backupFolder(target, folder, backupDestination) open(r'%s\%s\%s' % (backupDestination, sysName, 'BackupCompleted'),'w').write(string.join(folders, '\r\n')) if __name__ == '__main__': backup() From whisper at oz.nospamnet Sat Jun 16 00:20:05 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 16 Jun 2001 04:20:05 GMT Subject: PEP 259: Revise to remove context-driven magic from print References: <486de2.0106131406.5c0cbef9@posting.google.com> <9gamor$8ft$6@216.39.170.247> <9gbess$gla$3@newshost.accu.uu.nl> Message-ID: <9gempl$324$5@216.39.170.247> In article <9gbess$gla$3 at newshost.accu.uu.nl>, m.faassen at vet.uu.nl says... > David LeBlanc wrote: > > [effbot negative response] > > > I don't see why you consider this a joke, nor do I see the > > ignorance and arrogance which you seem to. I think it's kind of > > unfortunate that an influential person in the python world, such as > > yourself, would swat down someone's idea without even saying why! Quite a > > way to discourage people from having new ideas whether right or wrong. > > > > Well, Fredrik did quote some relevant bits from the original proposal > that he considered arrogant. > > It's just the way the effbot works; a Perl regex is sometimes clogging > up its neural net. See here for more information on the effbot: > > http://www.twistedmatrix.com/users/jh.twistd/python/moin.cgi/PythonRolePlayingGame > > No offense to anyone; some additional consideration on all sides might've > helped, but then again everyone's inconsiderate at times, and a strong > reply isn't always awful. I wasn't nice to Guido a few posts back, > myself. Sorry Guido. :) > > Regards, > > Martijn > I am new to the ways of the effbot :-) Thanks for being a mediating influence :-) Regards, Dave LeBlanc From Sir-XaoS at gmx.net Sat Jun 23 11:20:45 2001 From: Sir-XaoS at gmx.net (Sir XaoS) Date: Sat, 23 Jun 2001 17:20:45 +0200 Subject: ?automatical user authentification? Message-ID: <3B34B3CD.7ED2B21A@gmx.net> Salve, How do I use already existing accounts for a session with python, actually Zope? e.g. something like a unix account, because it's nasty remembering too many passwords, isn't it, and I only need this usermanagement behind a Firewall and the user authentification will only be used for distiguishing between the users. The [password] security is only pro forma. I just need something to bind in a website which distinguishes the users from itself, not by interacting with the user again. I know that in PHP exist some functions which can deal with unix accounts, etc.- So: how do I handle them in Python? a better documentation, like found on www.python.org, would help me, too. thanks, already. Christian From see at my.signature Wed Jun 20 00:02:07 2001 From: see at my.signature (Greg Ewing) Date: Wed, 20 Jun 2001 16:02:07 +1200 Subject: locking dictionaries (was Re: New statement proposal for Python) References: <9gl1rg$p45$1@panix2.panix.com> Message-ID: <3B30203F.B158D356@my.signature> Aahz Maruch wrote: > > OTOH, there's been some discussion of locking dicts during certain > operations to prevent some ugly bugs and crashes. I'm given to understand that, in the case of lists, this is achieved by temporarily changing the type pointer. If a similar thing were done for dicts, presumably it wouldn't have any effect on the performance of non-locked dicts. > would it maybe make > sense to add an external interface to the locking mechanism? Hmmm... wild thought: after type/class healing, every object will have a __class__ attribute... if it were changeable... d = {'spam':42} d.__class__ = MyLockedDictClass No, probably far too dangerous... x = [] x.__class__ = 3.__class__ print x <<>> -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From romain.guy at jext.org Wed Jun 20 14:47:07 2001 From: romain.guy at jext.org (Romain Guy) Date: Wed, 20 Jun 2001 20:47:07 +0200 Subject: OOP in Python References: <4e2ddb70.0106200954.11faa218@posting.google.com> Message-ID: <9gqquh$jfv$1@wanadoo.fr> "static" variables (or class attributes) are defined like this: class MyClass: myStaticVar = 1 myStaticList = [1, 2, 3] # ... Instance attributes are define like this: class MyClass: #... def __init__(self): self.myInstanceAttrInt = 2 self.myInstanceAttrList = [2, 3, 4] -- Romain "Java Swinguer !" Guy romain.guy at jext.org www.jext.org "Now, don't you worry. The saucers are up there. The graveyard is out there. But I'll be locked up safely in there." - Paula Trent, Plan 9 From Outer Space "Jonas Bengtsson" a ?crit dans le message news: 4e2ddb70.0106200954.11faa218 at posting.google.com... > Ok I admit - I am a Python-newbie! > > What about local variables and class variables when dealing with > classes? > With local vars I mean temporaryly used variables in a function. Will > they be treated as 'normal' instance attributes? Do I have to delete > them by myself when I'm leaving a function? > With class vars I mean if many class instances of a class may share a > variable. In C++ this is accomplished by a static variable. How do I > do in Python? > > Thanks in advance, > Jonas B From uioziaremwpl at spammotel.com Wed Jun 27 15:01:03 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Wed, 27 Jun 2001 21:01:03 +0200 (CEST) Subject: Windows-Qt free for non-commercial use (Re: KDE and Windows) In-Reply-To: <20010627133545.C17001@harmony.cs.rit.edu> Message-ID: On Wed, 27 Jun 2001, D-Man wrote: > On Wed, Jun 27, 2001 at 06:43:10PM +0200, NightOwl wrote: > | Is it possible to develop a GUI which runs in Windows aswell as in KDE with > | the same code ? I don't want to have to re-write all code just because I use > | an other OS ... ? (Not using the COM-functions of Windows). > > Yes. Qt runs on both Unix and Windows. However Qt is not free for > Windows (as-is). Just don't use any KDE/Linux specific features or > any Windows specific features. I've just received a newsticker message, that there will be a "Qt Non Commercial Edition for Microsoft Windows" available under the condition that the source code of the program using Qt is made available. Cheers, Carsten -- Carsten Geckeler From sapsi at bigfoot.com Fri Jun 29 08:10:24 2001 From: sapsi at bigfoot.com (Drop Anchor!!) Date: Fri, 29 Jun 2001 17:40:24 +0530 Subject: Setitimer Message-ID: <9hhr0k$e0k9m$1@ID-91520.news.dfncis.de> Hi How do i use calls like setitimer in Python? i.e how would i set a timer without using alarm which works only for seconds, say i want for milliseconds? Thanks please reply to email also sapsi at bigfoot.com From Glen.Mettler at home.com Sat Jun 9 22:59:17 2001 From: Glen.Mettler at home.com (Glen Mettler) Date: Sun, 10 Jun 2001 02:59:17 GMT Subject: New guy question References: Message-ID: <9oBU6.128578$I5.32912060@news1.rdc1.tn.home.com> > Based on the '>>>' prefix It looks like you're entering this into the > python interpreter. In that context, to get the same behaviour, you > would probably want to do something like "execfile('alook.py')" Try > running "python alook.py" from the shell/dos command prompt, instead. > It might be helpful to work through a tutorial. The one at > www.python.org/doc/tut is pretty good, imo. > > Alex. Actually, I am working thru a tutorial right now. I don't recall it saying anything about the differences between the DOS window and the IDLE window. In any case, I went to the DOS window and this is what I get: >>> python alook.py File "", line 1 python alook.py ^ SyntaxError: invalid syntax >>> Glen From nperkins7 at home.com Thu Jun 14 22:31:16 2001 From: nperkins7 at home.com (Nick Perkins) Date: Fri, 15 Jun 2001 02:31:16 GMT Subject: profile.run won't run! Message-ID: I can't get profile.run to work.. def solve_problem(): ...blahblahblah solve_problem() # works exec("solve_problem()") # also works but.. profile.run("solve_problem()") ... File "c:\python21\lib\profile.py", line 356, in run return self.runctx(cmd, dict, dict) File "c:\python21\lib\profile.py", line 362, in runctx exec cmd in globals, locals File "", line 1, in ? NameError: name 'solve_problem' is not defined I have verified that "solve_problem" is in globals() when I am doing this. In another IDE I get an Unbound Local error in the first function that comes up. Am I missing something? From daniel.dittmar at sap.com Mon Jun 18 11:52:45 2001 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Mon, 18 Jun 2001 17:52:45 +0200 Subject: Function lookup using a directory. References: <29pX6.14682$cF.320097@news1.nokia.com> Message-ID: <9gl84e$s7f$1@news1.wdf.sap-ag.de> > Can I do this, I.E. have a class as a value in a dictionary > and if so, what would the correct declaration be. Put the command table after the class declarations and put the classes into the dictionary, not the names. command_table = {'0': Help0, '1': Help1, '2': Help2, '3': Help3 } Daniel From Randy.L.Kemp at motorola.com Mon Jun 11 16:12:55 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Mon, 11 Jun 2001 15:12:55 -0500 Subject: Newbie Message-ID: Try the tutorials at www.python.org. -----Original Message----- From: justsurfn2004 at aol.com [mailto:justsurfn2004 at aol.com] Sent: Monday, June 11, 2001 2:19 PM To: python-list at python.org Subject: Newbie Hello, im a newbie to all this programming stuff and i just downloaded python and i want to know how to use it. Can anyone reccommend any websites for me to go to on how to use it? My email address is pcgamesrule at hotmail.com Thanks From msoulier at storm.ca Wed Jun 6 22:43:45 2001 From: msoulier at storm.ca (Michael P. Soulier) Date: Thu, 07 Jun 2001 02:43:45 GMT Subject: Interesting speed benchmark References: Message-ID: On Thu, 7 Jun 2001 10:40:04 +1000, Delaney, Timothy wrote: > > 1. You know *when* the object will be destroyed (in a program a trivial as > this). > > 2. Since you only ever have 2 ObjectTest instances at any time, it's highly > likely that the memory for them will be reused for the two instances, > meaning you don't have to continually allocate more memory. This means thr > program is more likely to run in a smaller memory footprint - always a Good > Thing (TM). Tim Delaney This makes sense, but if Python is doing less allocation, that should also be a time saver, no? Or did the performance increase in lazy GC just so far outweight the benefits of less malloc() calls that it didn't matter here? Mike -- Michael P. Soulier "With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead." -- RFC 1925 From andy.pevy at nokia.com Tue Jun 19 03:15:55 2001 From: andy.pevy at nokia.com (andy.pevy at nokia.com) Date: Tue, 19 Jun 2001 07:15:55 GMT Subject: Function lookup using a directory. References: <29pX6.14682$cF.320097@news1.nokia.com> <3B2E4CA6.AF9C5D84@accessforall.nl> Message-ID: Hi Ype Ype Kingma wrote: > Andy, > In addition to the earlier replies: > Your run() method seems to be checking for > presence of arguments, so you might > consider defining it with an extra '*' as: > class Help0: > def run(self, *which): > if len(which) == 1: > print 'Help no args' > else: > print 'Help args' > This will give you a tuple with the passed arguments, > in your case an empty tuple. The argument passed to thee run method is a list, so does this still necessary ??. > Have fun, > Ype > andy.pevy at nokia.com wrote: >> >> Hi Guys >> >> I am having trouble with the directory data type. What I want to >> do is to set up a directory that I can use to parse a command entered by >> the user, and have a directory return the name of a class to handle the >> command. Like this :- >> >> command_table = {'0': 'Help0', >> '1': 'Help1', >> '2': 'Help2', >> '3': 'Help3' } >> >> class Help0: >> >> def run(self,which): >> if len(which) == 1: >> print 'Help no args' >> else: >> print 'Help args' >> > [snip] >> >> if __name__ == '__main__': >> >> command = user_input() >> >> try: >> h = command_table[command[0]] >> except: >> print command[0]+' not found' >> >> h.run() # Call the run method of the selected class. >> > -- > email at xs4all.nl -- We were always told that a million monkeys typing for a million years would eventually produce the works of Shakespeare. Now, thanks to the Internet, we know this is not true. From aahz at panix.com Fri Jun 1 15:03:09 2001 From: aahz at panix.com (Aahz Maruch) Date: 1 Jun 2001 12:03:09 -0700 Subject: Python + threads + wxWindows = segfault, help! References: <9f8f7j$k5c$1@panix6.panix.com> Message-ID: <9f8otd$1v7$1@panix3.panix.com> In article , Greg Copeland wrote: > >Arg! In my hurry to get this posted it seems that I left some >important information out. I'm running Python 2.1 with wxPython >2.2.5 and wxWindows 2.2.7, though I get the same results with >2.2.5 as well. > >The application design is using the parent for the GUI and >threads for communication. Data is passed back and forth via >Python's Queue class. > >Most of the segs that I get seemingly have to do with threads. >I think I'm the only SMP user on the project and oddly enough, >I think I'm the only user seeing issues like this. Are you calling any extensions other than wxPython? It sounds like some thread is calling into Python when it doesn't have the Global Interpreter Lock. Are you sure that threads other than main *don't* make any wxPython calls? What OS is this on? (I'm assuming SGI, but....) -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Characters exist to suffer, you know. An author needs a little sadism in her makeup." --Brenda Clough From noselasd at frisurf.no Fri Jun 29 07:09:43 2001 From: noselasd at frisurf.no (Nils O. Selåsdal) Date: Fri, 29 Jun 2001 13:09:43 +0200 Subject: python2.1 and RedHat7.1 References: Message-ID: "Michael Ackerman" wrote in message news:mailman.993580729.681.python-list at python.org... > Hello. > I tried to install the python2.1 rpm for RedHat7.0 on my 7.1 system but > got a > "failed dependency" message saying that it wants: > libcrypto.so.0.9.6, libssl.so.0.9.6 > But these files are present, in /usr/lib. So what's going on? > Any help will be appreciated. And the version (0.9.6) asked for is the same as in your directory? Then the libraries havent been installed with RPM, rpm dont check the filesystem only its database. do: rpm -ivh python* --nodeps From nas at python.ca Tue Jun 19 18:21:28 2001 From: nas at python.ca (Neil Schemenauer) Date: Tue, 19 Jun 2001 15:21:28 -0700 Subject: PEP 255: Simple Generators In-Reply-To: ; from Denys.Duchier@ps.uni-sb.de on Tue, Jun 19, 2001 at 11:55:26PM +0200 References: Message-ID: <20010619152128.B15126@glacier.fnational.com> Denys Duchier wrote: > Unless I misread the PEP, the entire generation logic must be > defined in a single function (because the `yield' keyword must > statically occur within the body of the generator function). That's right. These are "Simple Generations". Implementating continuations is much harder since you have to deal with the C stack. Look at Stackless Python if your interested. I'm still hoping that Python will get continuations (microthreads and coroutines if you think continuations is a dirty word). Its not going to be easy though and I feel pretty safe predicting that they won't be in Python 2.2. PEP 255, on the other hand, stands a good chance of making it. Neil From donod at home.com Sun Jun 17 02:40:22 2001 From: donod at home.com (Don O'Donnell) Date: Sun, 17 Jun 2001 06:40:22 GMT Subject: += overloading? References: <3b2c2cbb$0$324$8eec23a@newsreader.tycho.net> Message-ID: <3B2C5151.30234EF@home.com> Neil Macneale wrote: > > I am creating a colored stringbuffer class, and I want to append words to > the buffer with the '+=' operator. Ex: > > >>>csb = CSB("INIT STRING") > >>>csb += "Hello" > >>>print csb > INIT STRINGHello > > would be the desired effect. I can't seem to find anything in the lib > docs about overloading that operator though. Am I looking in the wrong > place? It is also important that a new object is NOT created every time > the operator is used, because that would be a waste. > > Suggestions? Thanks for any tips! > > Neil Macneale > > -- > To reply to me via email, remove the '-devnull' from my address. It's in the Reference Manual, section 3.3.6 in Release 2.1, not the Lib docs, since it's an operator defined by the language, not the library. The method you're looking for is called augmented addition, and it is defined as: def __iadd__(self, other): ... return self In general, the augmented arithmetic operators should update self in place where possible. In the case where self is immutable, as yours may be since it's string based, you'll have to create a new concatenated string and rebind self to it. These methods must also return self, since just rebinding the local copy of the self ref will never be seen by the caller. Good luck. -Don From rnd at onego.ru Thu Jun 21 12:24:33 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 21 Jun 2001 20:24:33 +0400 (MSD) Subject: critic this please In-Reply-To: Message-ID: On Thu, 21 Jun 2001, NJM wrote: >I've just wrote this small program that calculates the length of a rafter >for you(I'm a carpenter), but I didn't write it "properly". I can't seem to >wrap my head around using classes. Does anyone have any input. (I must admit that being a son of architect, I can't distinguish a rafter from other wood objects up there, so probably I have no moral right to critisize.) For a program it is easy and simple and it solves what you want. (though I can't think in inches/feet, m/cm/mm please) But if it was a programmers' program, it' would be much shorter: programmers are too lazy to write much! Instead of plane(rafter1, 1) plane(rafter1, 2) ... plane(rafterN, M) (I am too lazy to even write it properly...) they will most certainly write something like: for reafter in rafters: # for each rafter for i in range(M): # M times plane(rafter, i) # plane that rafter I think, you've got an idea. Instead of 8*x + 8*y + 8*z it is possible to write: 8*(x+y+z) Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Thursday, June 21, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Useless Invention: Motorcycle seat-belts." _/ From tim.one at home.com Tue Jun 26 20:32:26 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 26 Jun 2001 20:32:26 -0400 Subject: PEP 260: simplify xrange() In-Reply-To: <3B39237F.1A7EF3F2@Lugoj.Com> Message-ID: [James Logajan] > Are there still known bugs that will take some effort to repair? Is > xrange constantly touched when changes are made elsewhere? If no to > both, then I suggest don't fix what ain't broken; life is too short. > (Unless it is annoying you to distraction, then do the deed and get > it over with.) I think it's more the latter. I partly provoked this by bitterly pointing out that there's more code in the CVS tree devoted to supporting the single xrange() gimmick than Neil Schemenauer added to support the get-out-of-town more powerful new generators. Masses of crufty code nobody benefits from are a burden on the soul. although-it-would-be-impolite-to-ask-we-why-still-ship-a-directory- full-of-crufty-old-irix5-demos-in-the-std-library-ly y'rs - tim From grante at visi.com Sat Jun 2 11:49:06 2001 From: grante at visi.com (Grant Edwards) Date: Sat, 02 Jun 2001 15:49:06 GMT Subject: Why isn't Python king of the hill? References: <9fa5fi0fru@enews2.newsguy.com> Message-ID: On Sat, 2 Jun 2001 09:42:34 +0200, Alex Martelli wrote: >> _never_ expect an exact result and not to use binary floating >> point if you require an exact result. >> >> You may thing that 1.0 + 2.0 == 3.0 ought to be true, but you > >And it is (on any FP system respecting IEEE 754 -- and any >other FP system I've ever heard about). I know that it is. But when you start depending on that fact, you're doomed. >> should always treat floating point operations as if there are >> small random numbers being thrown in at every step. So you > >I think this is exactly what Kahan describes as one of the >widespread (and false) myths about floating point. Of course it is not true. But if you pretend it is, you've got a much better chance of producing working code. -- Grant Edwards grante Yow! And furthermore, at my bowling average is visi.com unimpeachable!!! From rnd at onego.ru Tue Jun 12 02:00:15 2001 From: rnd at onego.ru (Roman Suzi) Date: Tue, 12 Jun 2001 10:00:15 +0400 (MSD) Subject: [Python-Dev] PEP 259: Omit printing newline after newline In-Reply-To: Message-ID: On Mon, 11 Jun 2001, Glyph Lefkowitz wrote: >I'm for it. In fact, we should do things like this more often -- if the >semantics of "print" change once per release, everyone will stop using it, >the keyword/bytecode will vanish, and people will use a function for >writing to standard out, as it should have been all along! :) Why do you insist on using function instead of print statement? Maybe, we can also eliminate del statement because there is no "new" cunterpart of it? print is nice as it is. Please, leave it along. >On Mon, 11 Jun 2001, Chris Gonnerman wrote: > >> I have to say, I'm strongly against this PEP... does anyone else agree with >> me? > > > ______ __ __ _____ _ _ > | ____ | \_/ |_____] |_____| > |_____| |_____ | | | | > @ t w i s t e d m a t r i x . c o m > http://twistedmatrix.com/users/glyph > > > > Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Tuesday, June 12, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "My cat likes to play Hide-And-Go-Poop." _/ From nperkins7 at home.com Wed Jun 13 18:29:41 2001 From: nperkins7 at home.com (Nick Perkins) Date: Wed, 13 Jun 2001 22:29:41 GMT Subject: Global Variables + Threads References: <3B26796A.C3FAF2E3@telocity.com> <9g7v2n$6l2$1@panix6.panix.com> Message-ID: >"Aahz Maruch" wrote: >... >Pass around a class instance. If you pass a class instance to your Tkinter code, which contains the information that you want to be 'global', then you can then modify the information contained in that class from 'outside'. If you simply pass in the 'global' variables, then they will not stay 'connected' to the original variables. ..passing a variable directly is like making a copy.. ( actually, it makes another name which is bound to the same object, but if you modify the variable, it simply binds to another object, it does not actually change the object that it referred to ..(usually). ) >>> class thing: ... def __init__(self,x): self.x = x ... def print_x(self): print self.x ... >>> x = 'something' >>> t = thing(x) >>> t.print_x() something >>> x = 'something else' # change value from 'outside' >>> t.print_x() something ...but if you pass in a reference to a class, it will 'point to' the same object, and you can then read or modify any 'parts' of that object, without losing your reference to the original object. >>> class globals: pass ... >>> g=globals() >>> >>> class thing: ... def __init__(self,globals): self.globals = globals ... def print_x(self): print self.globals.x ... >>> t = thing(g) >>> g.x = 'something' >>> t.print_x() something >>> g.x = 'something else' # change value from 'outside' >>> t.print_x() something else This has nothing to do with threads, it is just a matter of scoping and binding. Variables that are global are only really global to the module in which they are defined. Any other modules need to be explicity given access to them. Another option, I suppose, is have variables that you want to be global...er, i mean, accessible from many scopes,... declared all in a separate module, which can be imported by the other modules. It all comes down to switching from thinking about 'variables and values', to thinking about 'names and objects', and remembering that names can be re-bound to different objects when you think that you are 'modifying a variable'. I'm not sure if this is exactly the original problem, but I had fun thinking about it. From philh at comuno.freeserve.co.uk Thu Jun 14 20:18:16 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 15 Jun 2001 01:18:16 +0100 Subject: Parrot-0.2.6 released Message-ID: I have just released Parrot version 0.2.6. Parrot is a text-based GUI builder. It is intended to be used by programmers writing GUI applications. Parrot is written in Python. To use Parrot, you write a text file descriping your application's GUI. Then you invoke the Parrot program, which reads your file and produces output code implementing the GUI. At the moment, Parrot can produce two sorts of output: * HTML containing the GUI * a Python program which when run will implement the GUI using Python's Tkinter interface to Tk. The current release contains modifications contributed by Ludger Humbert () to get radio buttons working correctly. Parrot is currently pre-alpha code, so don't expect to do much useful work with it yet. Parrot is available from: http://www.vision25.demon.co.uk/oss/parrot/intro.html Parrot is licenced under the GNU GPL. -- ## Philip Hunt ## ## philh at comuno.freeserve.co.uk ## From tim.one at home.com Fri Jun 1 21:30:40 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 1 Jun 2001 21:30:40 -0400 Subject: Decimal can be Binary Too (was decimal or rational) In-Reply-To: <3B183614.E299F31E@home.com> Message-ID: [Don O'Donnell] > ... > If by "floating-point-decimal" you mean internal representation of > both the mantissa and the exponent by some sort of a binary-coded > decimal, let me point out that it is not necessary to go to full > decimal in order to to achieve the `7.35` == "7.35" goal.> > By letting the exponent represent powers of 10 rather than 2, the > base (or mantissa) and exponent can both be represented in binary > as an int or long. Thus, the internal calculations can use the > fast integer hardware instructions, rather than decimal arithmetic > which would have to be done by software. > ... See for a fixed-point version of that. For "typical" commercial use, the problem is that converting between base-2 (internal) and base-10 (string) is very expensive relative to the one or two arithmetic operations typically performed on each input. For example, hook up to a database with a million sales records, and report on the sum. The database probably delivers the sale amounts as strings, like "25017.18". Even adding them into the total *as* strings would be cheaper than converting them to a binary format first. In addition, once you're outside the range of a native platform integer, you're doing multiprecision operations by hand anyway. Python's longs use "digits" in base 2**15 internally, but *could* use, say, base 10**4 instead. The code would be almost the same, except for using different low-level tricks to find twodigits/base and twodigits%base efficiently. From aleaxit at yahoo.com Mon Jun 18 12:09:53 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 18 Jun 2001 18:09:53 +0200 Subject: Function lookup using a directory. References: <29pX6.14682$cF.320097@news1.nokia.com> Message-ID: <9gl94i0a91@enews2.newsguy.com> wrote in message news:29pX6.14682$cF.320097 at news1.nokia.com... > Hi Guys > > I am having trouble with the directory data type. What I want to You appear to mean the _dictionary_ data type. > do is to set up a directory that I can use to parse a command entered by > the user, and have a directory return the name of a class to handle the > command. Like this :- > > command_table = {'0': 'Help0', > '1': 'Help1', > '2': 'Help2', > '3': 'Help3' } Rather than holding the NAMES, which would require further work to find the class corresponding to a name, hold the CLASS directly -- move this definition AFTER that of the classes and change it to: command_table = {'0': Help0, '1': Help1, '2': Help2, '3': Help3, } > Can I do this, I.E. have a class as a value in a dictionary Sure! > and if so, what would the correct declaration be. No 'declaration', as you see -- the dictionary-display expression you used is correct -- just have it hold the classobjects directly (you'll need to define command_table after the classes are created) rather than their names. Alex From bkc at Murkworks.com Thu Jun 7 08:16:05 2001 From: bkc at Murkworks.com (Brad Clements) Date: Thu, 7 Jun 2001 08:16:05 -0400 Subject: McMillan Installer 4 error ImportError: No module named posixpath References: <3b1ea684$1_4@127.0.0.1> Message-ID: <3b1f6fbe_2@127.0.0.1> Thanks, but I did remove posixpath from the excludes in the .cfg file, and rebuilt using Builder.py The Builder.log shows (I think) that posixpath gets included. -- Brad Clements, DevNet Sysop 5 Developer Network Sysop Team "David Bolen" wrote in message news:uy9r5ta7h.fsf at ctwd0143.fitlinxx.com... > "Brad Clements" writes: > > > I have a very simple python 1.5.2 script on w2k that I want to distribute. > > > > I've tried beta 4 of the installer to create either a standalone or simple > > distribution, but when I run it (either one), I get the same error. Trace > > attached below. > > > > I tried explicitely importing posixpath, but that doesn't matter. tried with > > and without the -win32 option. > > I believe the default configuration files built by the installer top > level scripts (like standalone) automatically exclude some path > modules (including posixpath) as part of constructing the archive (the > APPZLIB clause in the default setup). I think that's similar to why > pywintypes/win32api is always excluded - there's a reference to them > in the standard libraries but it's on a conditional path, so you'd > always get them even when not needed. > > In this case, it sounds like you do actually need it, so try removing > posixpath from the excludes line once you've built your config file. > > Also, in cases like this, builder.log is your friend, since it'll show > the sequence of identifying the need for posixpath, and then excluding > it if instructed to do so from the config. > > -- > -- David > -- > /-----------------------------------------------------------------------\ > \ David Bolen \ E-mail: db3l at fitlinxx.com / > | FitLinxx, Inc. \ Phone: (203) 708-5192 | > / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ > \-----------------------------------------------------------------------/ -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From Gareth.McCaughan at pobox.com Sat Jun 30 16:11:25 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Sat, 30 Jun 2001 21:11:25 +0100 Subject: functional programming and default parameters References: Message-ID: Tim Peters wrote: > [Ralf Muschall] > > ... > > Unfortunately, in Python writing > > > > for i in range(3): > > j=i > > fns[i]()=lambda:j > > > > fails, and even this fails too: > > > > for i in range(3): > > j=i+10 > > a[i]=lambda:j > > > > map(x:x(),fns) gives [12,12,12]. ... > No, Python does no optimizations at all: WYSIWYG. But you're carrying a > scope model over from Lisp that doesn't apply in Python. In general, the > only way to get a Lispish new scope in Python is via nesting a def. I'm not sure Lisp experience is the culprit here. (mapcar #'funcall (loop for i upfrom 1 to 5 collecting (lambda () i))) ==> (6 6 6 6 6) An equivalent with DOTIMES is just the same, by the way. I don't remember reading Ralf's original article, so if that proves that his expectation *is* derived from Lisp then what I'm not sure of is that Ralf has correctly understood Lisp. :-) -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From gbreed at cix.compulink.co.uk Mon Jun 25 07:28:32 2001 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: 25 Jun 2001 11:28:32 GMT Subject: any idea how i could test if a variable is a floating point number? References: <9h76io$ht3$1@neptunium.btinternet.com> Message-ID: <9h7790$l0e$1@plutonium.compulink.co.uk> > any idea how i could test if a variable is a floating point number? type(variable)==type(1.0) From sholden at holdenweb.com Thu Jun 28 15:28:39 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 28 Jun 2001 15:28:39 -0400 Subject: Can I pass a cursor to a function? References: Message-ID: wrote ... > I am trying to figure out whether or not Python will let me pass a > cursor variable to a function so that I don't have to create another > connection instance to Oracle. Here's the chunk of code: > You're looking at a non-existent problem ... see below. > try: > dbc = odbc.odbc(conn_str) > crsr = dbc.cursor() > except: > raise database_error > > while 1: > sql = "SELECT DATA, ROWID FROM ;" > crsr.execute(sql) > records = crsr.fetchall() > for record in records: > pid = `record`[2:4] > rowid = `record`[129:-2] > row_flag = 'TRUE' > > if row_flag == 'TRUE': > if pid == 'RE': > receipt_flag = 'TRUE' > receipt_mod.receipt(crsr,record) > else: > time.sleep(5) > > I set data up so that both if statements evaluate to true, the flag > is set, and the receipt function is invoked. I get this error if I > try to pass dbc or crsr: > > Traceback (most recent call last): > File "C:\proc_mgr.py", line 33, in ? > receipt_mod.receipt(crsr,record) > AttributeError: receipt > The problem here seems to be with your receipt_mod. Python is telling you that (module? class? whatever...) does not have a "receipt" attribute - in other words, you are referring to a non-existent name. I'd be *very* surprised if this worked with only the second argument. > If I just pass the record variable, things work fine. Is there a way > that I can pass crsr that I am not seeing or can I make it global and > use it in the function that way? Any help or suggestions will be > appreciated. Thanks. > You can pass cursors just like anything else as an argument. For example, here's a "cursor prettyprinter" function I wrote to give me a legible output from random database queries. def cpp(cursor, t = None): """Return the result of the last operation on a cursor, retrieving unless it is provided as an argument.""" print d = cursor.description if not d: return "\n#### NO RESULTS ###\n" if not t: try: t = cursor.fetchall() except: # XXX should specify exception type return """\n###EXCEPTION ON FETCHING RESULTS###\nException data:\n%s\n(%s)"""\ % (sys.exc_type, sys.exc_value) names = [] lengths = [] rules = [] col = 0 for dd in d: l = dd[1] if not l: l = 12 l = max([l, len(dd[0])] + [len(str(t[i][col])) for i in range(len(t))]) names.append(str(dd[0])) lengths.append("%%%ss" % l) rules.append("-"*l) col += 1 format = " ".join(lengths)+"\n" result = "\n" + format % tuple(names) result += format % tuple(rules) for row in t: result += format % row return result regards Steve -- http://www.holdenweb.com/ From chrishbarker at home.net Thu Jun 7 20:03:46 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 07 Jun 2001 17:03:46 -0700 Subject: Mutable class attributes are shared among all instances, is it normal ? References: <27vvht4uslv2ibq2q8ee4tovg86e7qempb@4ax.com> Message-ID: <3B201662.6DB35744@home.net> Alain TESIO wrote: > > Hi, sometimes class attributes added just after > "class ...:" outside a functions interfere among > instances, more precisely mutable objects are > linked to the same object as if it were a static > attribute. > > See the test case below. > > If I delete the line "val=[None]" in class > Y and add "self.val=[None]" in its __init__ > it works as class X. > > Is it a bug or did I miss something ? Nope, that's exactly as it is supposed to work. All the variables in a class definition are members of the definition itself. You want this, because you wouldn't want to make a copy of all the methods and all defined in the class. Remember that all variable in Python are just a reference to something. There is only one copy of all the stuff in a class definition. When you create an instance a reference to that instance is passed in as the first parameter to __init__. by convention, it is called self. Anything to want to be unique to that instance need to be put in self. When self is passed in, it comes with references to all the class variables, including all the methods defined, adn in your case, "val". Now, the reason you have your confusion is that since everything in Python is a reference, the distiction that matters is whether it is mutable or not. A mutable object (a list) can be changed in place. An immutable object can not. If you assign a new value to a name that references an object, the name then gets assigned to your new object, and the old one is de-refereced (it will be garbage collected if there is nothing else pointing to it. Whe you alter a mutable object, however (list[index] = something) you have not changed the reference, but you have changed the object it is pointing to. So in your example: > class X: > > val=None # val no is a attribute of "X" > > def __init__(self): # self is an instance of class "X", so it has a reference to val > for i in range(3): > self.val=random.random() # you have now changed what self.val refernces, a new random number. X.val is still referencing "None" for each instance, "self" is a new copy, so self.val is a new variable. > > def __repr__(self): > return str(self.val) > > class Y: > > val=[None] > > def __init__(self): # same as above so far. > self.val[0]=random.random() # self.val still references the list that X.val references, but you have now changed the contents of that list. For each instance, you get another reference to the SAME list, so each time it is changed, it looks different to every variable that references it. > > def __repr__(self): > return str(self.val) > ============ end of file 'cl.py' Try this: >>> import cl >>> print cl.X.val None >>> x1=cl.X() >>> print cl.X.val # note: it hasn't changed. None >>> print cl.Y.val [0.54460536751587463] >>> y1=cl.Y() >>> print cl.Y.val # note it has changed [0.092879566011803139] >>> This can be a handy feature if you want a set of data to be available to all the instances of a class, and you want to be able to change that dataset, making all the changes available to all instances. If you want each instance to have it's own version of the data, put it in "self". Try this: >>> reload(cl) # it needs to be reloaded to get a clean copy of Y >>> >>> print cl.X.val None >>> x1=cl.X() >>> print cl.X.val # note: it hasn't changed. None >>> print cl.Y.val [None] >>> y1=cl.Y() >>> print cl.Y.val # note it has changed [0.91001740255497787] >>> Note that this is just a more convoluted of the simple demo of mutable objects. >>> a = [1,2,3,4] >>> b = a >>> # A and b reference the same list >>> a[:] = [5,6,7,8] >>> # a[:] assigns to the CONTENTS of the list >>> a [5, 6, 7, 8] >>> b [5, 6, 7, 8] >>> # since there is only one list, a and b are both changed >>> a = (1,2,3,4) >>> b = a >>> # a and b point to the same tuple >>> a[:] = (5,6,7,8) Traceback (most recent call last): File "", line 1, in ? TypeError: object doesn't support slice assignment >>> # oops! tuples are imutable, you can't change their contents >>> a = (4,5,6,7) >>> # a now points to a new tuple, b still points to the old one >>> a (4, 5, 6, 7) >>> b (1, 2, 3, 4) >>> # there are now two tuples, a references one and b refernces the other -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From eppstein at ics.uci.edu Wed Jun 20 19:49:33 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Wed, 20 Jun 2001 16:49:33 -0700 Subject: PEP 255: Simple Generators References: <3B303FE5.735A5FDC@cosc.canterbury.ac.nz> <90C65699Dgmcmhypernetcom@199.171.54.194> <16074dce.0106201512.5459e720@posting.google.com> Message-ID: I wrote: > > I'm wondering if it wouldn't make sense to allow a non-empty return > > statement in a generator, with the semantics that the object being returned > > is itself some kind of iterator that is used to continue the sequence. > > > > i.e. > > def integers(i): > > yield i > > return integers(i+1) In article <16074dce.0106201512.5459e720 at posting.google.com>, jeff at ccvcorp.com (Jeff Shannon) replied: > It seems to me that this would be better written as > > def integers(i): > while 1: > yield i > i += 1 > > but I confess that I don't see offhand how either case generalizes to a > less-contrived example. It doesn't *seem* to me that your proposal adds > significant functionality... but I'm not so familiar with functional > programming, so I'm likely missing something. :) Ok, another mathematical one: def collatz(i): yield i if i % 2 == 0: return collatz(i/2) else: return collatz(3*i+1) Yes, of course, you could do it with a loop. You can do anything with a loop, so what need is there for recursion or any other such programming language feature? But I think the functional point of view is more clearly expressed here than with a loop. Second example, more data-structural: since list comparison is lexicographic, max(x,y) where x and y are two lists should be well-defined. What about when x and y are not lists but some other kind of iterator? def maxgen(x,y): for pair in zip(x,y): yield max(pair[0],pair[1]) if pair[0] > pair[1]: return x elif pair[1] > pair[0]: return y (Note this is proof of concept rather than a good implementation, zip is only supposed to work for lists and this code doesn't deal with the issue of what happens if you get to the end of one iterator before deciding who wins.) Again, you could do this by replacing each of the return stmts with a loop, but I think this is clearer. Finally, some earlier messages in this thread requested a way to use the return statement to yield one last item and then stop. That is, to abbreviate the idiom yield x return Here's a way to do it with this definition of a nonempty generator return: return (x,) -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From MarkH at ActiveState.com Thu Jun 21 20:56:26 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Fri, 22 Jun 2001 00:56:26 GMT Subject: Pythonwin embedded in another program... References: <13bf971.0106211242.d94cf0f@posting.google.com> Message-ID: <3B3297B9.5010505@ActiveState.com> Chris wrote: > After building elapsedTimer_d.pyd and sio_d.pyd I manually made > reference to them in the registry where the other module references > are. Upon trying to import from the interactive prompt in our monitor > I get the following error. This wont work. You need to run _everything_ as debug versions, and then there is no reason to modify the registry at all. In general, you simply embed against "win32ui_d.pyd" instead of "win32ui.pyd". This will magically bring in "pythonxx_d.dll" and force _all_ .pyd imports to locate an _d version. If this is too intrusive, you could consider sticking with the "release" build, but modify the build process temporarily to disable optimizations and enable symbolic debug info. This will then let you debug just those .pyd files, but not the ones you are not building manually. Also, later versions of the win32 extensions have serial port support in the win32file module. This may be a better long term approach than the serial module. Mark. From aahz at panix.com Wed Jun 13 16:36:48 2001 From: aahz at panix.com (Aahz Maruch) Date: 13 Jun 2001 13:36:48 -0700 Subject: Need help with threads References: <_nOV6.9330$ki5.130125@vixen.cso.uiuc.edu> Message-ID: <9g8it0$9gt$1@panix3.panix.com> In article <_nOV6.9330$ki5.130125 at vixen.cso.uiuc.edu>, Damian Menscher wrote: > >I'm trying to use threads to run various processes that require some >I/O. http://starship.python.net/crew/aahz/ -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Just because I'm selling you into slavery doesn't mean we can't be friends." B-movie cliche Hall of Fame (_Bounty Hunter: 2002_) From jamwt at jamwt.com Wed Jun 13 20:49:05 2001 From: jamwt at jamwt.com (James Turner) Date: Thu, 14 Jun 2001 00:49:05 GMT Subject: Embedding: Problem with CallObject Message-ID: <20010613.174914.1793282088.6934@bender.nowhere.non> Hello. I'm just starting to play with embedding Python in C, and I'm getting a huge headache from trying to figure out what's wrong with my code here: --test.c-- #include int main(int argc, char** argv) { PyObject *str,*mod,*flist,*func,*args; Py_Initialize(); str = PyString_FromString("anything"); /*Import mod */ mod = PyImport_Import(PyString_FromString("one") ); flist = PyModule_GetDict(mod); func = PyDict_GetItemString(flist,PyString_FromString("out")); args = PyTuple_New(1); PyTuple_SetItem(args, 0,str); /* FAILS HERE!! */ PyObject_CallObject(func,args); Py_XDECREF(flist); Py_XDECREF(func); Py_XDECREF(args); Py_XDECREF(mod); Py_XDECREF(str); Py_Finalize(); return 0; } --one.py-- def out(str): print "C says: %s" % str --end code-- And, right where I've commented FAILS HERE!! in the C code, I get the lovely: Segmentation fault (core dumped) I one.py is in the current directory, so I run it $env PYTHONPATH=. ./test It imports the module fine, and I can successfully run out(str) if I change it to out() and pass it NULL from C. (Meaning call the func w/no arguments and just print "Hello World" or something.) After testing this with: if (PyErr_Occurred())PyErr_Print(); all over the C code, I'm pretty sure this is why it's failing: I'm doing something wrong with the way I'm passing it that tuple from C. Hopefully someone more skilled can lend a hand! Thanks, James (PS) -- I am aware of CallMethod with the formatted string... I'm looking for a solution that enables one.py to modify my C-made PyObjects. My code is based on learning from http://www.mcmillan-inc.com/embed.html and referring to the official Python/C Api @ www.python.org. From jurberg at my-deja.com Wed Jun 13 08:33:58 2001 From: jurberg at my-deja.com (John Urberg) Date: 13 Jun 2001 05:33:58 -0700 Subject: Integrating a Python GUI into a PowerBuilder App References: <49624b0b.0106121135.61b6bd6c@posting.google.com> Message-ID: <49624b0b.0106130433.3d20b1ac@posting.google.com> "Brad Bollenbach" wrote: > The problem I can see though is coming up for an alternative to datawindow > controls/objects. If you try to do OO development, the datawindow becomes useless since all the data is yanked from the database directly into the user interface. So I don't see a problem there. It's probably a good thing since it will force our developers to work out a design for their code instead of just painting a datawindow and coding a retrieve and update. From micronospampad at nospam.yahoo.com Wed Jun 6 20:00:48 2001 From: micronospampad at nospam.yahoo.com (Mahesh Padmanabhan) Date: Wed, 06 Jun 2001 18:00:48 -0600 Subject: Interesting speed benchmark References: <3B1D6FED.4070506@nospam.yahoo.com> Message-ID: <3B1EC430.9020201@nospam.yahoo.com> As one poster suggested, Python's reference counting might be the culprit, so I modified the Java test as follows (probably not the correct way to do it): public class ObjectTest { public ObjectTest next; public static void main(String[] args) { for (int i = 0; i < 1000; i++) { ObjectTest root = new ObjectTest(); for (int j = 0; j < 10000; j++) { root.next=new ObjectTest(); root=root.next; System.gc(); // <-----------Force garbage collection } } } } The program did not even complete in 7 minutes at which point I became impatient and killed it. Did I modify the program correctly ? I then modified the program to move System.gc() to the outer loop. public class ObjectTest { public ObjectTest next; public static void main(String[] args) { for (int i = 0; i < 1000; i++) { ObjectTest root = new ObjectTest(); for (int j = 0; j < 10000; j++) { root.next=new ObjectTest(); root=root.next; } System.gc(); // <-------- Outer loop } } } This time the program did complete with the following time: real 0m33.165s user 0m32.980s sys 0m0.250s Approximately a 1500% increase. Seems like that poster was correct in pointing out that the memory management scheme of Java vs Python makes a difference. Mahesh Mahesh Padmanabhan wrote: > Hello, > > To email me remove "nospam" from the email address. > > I came across this web site: > http://www.twistedmatrix.com/~glyph/rant/python-vs-java.html > > in which the author does some (by his own admission) subjective > benchmarks between java and python. While most of it is usual stuff, the > one test that stood out was the following: > > (I am using a Debian woody system with Python 2.1 and JDK 1.3 from > blackdown on an Intel system) > > Python program: > --------------- > > class ObjectTest: > pass > > for i in xrange(1000): > root=ObjectTest() > for j in xrange(10000): > root.next=ObjectTest() > root=root.next > > Time: > > real 1m23.326s > user 1m23.290s > sys 0m0.060s > > > Java program: > ------------- > > public class ObjectTest { > public ObjectTest next; > public static void main(String[] args) { > for (int i = 0; i < 1000; i++) { > ObjectTest root = new ObjectTest(); > for (int j = 0; j < 10000; j++) { > root.next=new ObjectTest(); > root=root.next; > } > } > } > } > > Time: > > real 0m2.428s > user 0m2.190s > sys 0m0.220s > > There is a huge difference in performance. In fact I tried this under > Windows NT 4 SP5 with Python 2.1 and jdk1.3 from SUN and got similar > results. > > I am very curious to know why Python takes so much time. > > Thanks > > Mahesh > From aahz at panix.com Wed Jun 6 14:16:33 2001 From: aahz at panix.com (Aahz Maruch) Date: 6 Jun 2001 11:16:33 -0700 Subject: floating point in 2.0 References: <3B1E50C9.7D2509F4@shore.net> <9flkoi$ofu$1@panix2.panix.com> <3B1E6A67.2B33C197@shore.net> Message-ID: <9fls21$h0f$1@panix2.panix.com> In article <3B1E6A67.2B33C197 at shore.net>, Kurt B. Kaiser wrote: >Aahz Maruch wrote: >> >> Quite the contrary! The sooner people realize that floating point is >> broken, the better off they are! > >What we're talking about is the unformatted output representation. Until >Python computes (with reasonable speed) in BCD or some such, I think >most people would want good old "print". What people want isn't necessarily what's good for them. more-channeling-of-uncle-timmy-ly y'rs -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "NRE is a lot like cocaine. Feels great while you're on it, makes you feel very special and talented, and you become highly annoying to those who aren't on it." --Stef From mcherm at destiny.com Fri Jun 29 14:43:24 2001 From: mcherm at destiny.com (mcherm at destiny.com) Date: Fri, 29 Jun 2001 13:43:24 -0500 Subject: PEP scepticism Message-ID: <37533bb8.3bb83753@destiny.com> > This a general warning against the second system syndrom in Python. > > Maybe I am a hypocritical sceptic, but I have the impression that > some feeping creatureism is introduced into Python. > This might reduce the main advantage of Python to be clear and easy > and mostly have one good formulation on how to express what you want > to program in a structured way. > > Examples are: > - augmented Assigments > - Lists comprehensions > - Simple Generators > > To me it looks like these contructs do not add capabilities to > python which were missing. [....] > Please to not respond giving me the very good reasons on why these > features I have given as examples have been added or will be added > to python. [....] > On the other hand this is excatly the danger I want to warn you about. > It is a social reason for being careful: > > Participation in the PEP debates about Python-enchancements > requires a certain level of knowledge and interest > about computer language design. > > It is most likely that the participants > do understand complicated language constructs easily and > are python wizards. They might just not see how the addition > of syntatic sugar will lead to a higher learning curve for the masses. [....] > Mainly as a python user I urge you to take this into consideration. First of all, thank you Bernhard, for raising an important point. I completely agree with you: one of the strengths of Python is its simplicity, and I would never want to see it go the way of Perl or C++. And you are (IMHO) RIGHT that those who discuss PEPs are probably more savy than the typical Python user, and they need to keep that in mind. On the other hand, I find your list of examples sorely lacking. Without trying to convince you, let me just state that in MY opinion: Augmented Assignment -- perhaps not a good idea, but I guess we got tired of being laughed at by people coming from C and java. It's awefully convenient anyhow. List Comprehensions -- one of my new arguments for why Python is so much BETTER than other languages. Their elegence and simplicity (for a task which is incredibly common) makes the language SIMPLER to read, and the syntax is so "obvious" that beginners can pick it up after seeing 2 or 3 examples. Simple Generators -- this, too, is elegant and simple to understand. If you use them in wierd ways you might be able to create confusion (eg: add methods to a generator-iterator), but used straightforwardly, I think these will be powerful in some very common situations, and fairly easy to explain. So I guess what I'm saying here is that I *agree* strongly with your point, and we *must* keep this in mind as we consider new language additions, but IMHO, we've already been doing a good job of this. The features we're adding (except for print>>) are well-chosen and not excessive. If we keep your advice in mind, maybe we can continue that record. -- Michael Chermside From shalehperry at home.com Sat Jun 30 18:40:41 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Sat, 30 Jun 2001 15:40:41 -0700 (PDT) Subject: ImportError: No module named colormap In-Reply-To: <3B3E4DF0.3430571F@pool.informatik.rwth-aachen.de> Message-ID: > I cant get through this error message: > > morten at debian:~$ python mandelbrot2.py > Traceback (innermost last): > File "mandelbrot2.py", line 7, in ? > from colormap import * > ImportError: No module named colormap > > > How can I solve this Problem unter Debian and FreeBSD ? > # apt-get install auto-apt # auto-apt update # long pause $ auto-apt search I find no file called colormap.py, Colormap.py, etc. In fact: one:~$ auto-apt search colormap.py one:~$ auto-apt search Colormap.py one:~$ auto-apt search colormap usr/include/qt/qglcolormap.h devel/libqt3-dev usr/X11R6/include/X11/pixmaps/colormap.xpm x11/fvwm-common usr/bin/colormap devel/liballegro3.9.36-dev-common one:~$ auto-apt search Colormap one:~$ auto-apt search tkcolormap one:~$ auto-apt search tkcolormap From montagne at boora.com Mon Jun 4 19:00:10 2001 From: montagne at boora.com (michael montagne) Date: Mon, 04 Jun 2001 23:00:10 GMT Subject: formatting numbers References: Message-ID: <_pUS6.72862$FS3.620413@sjc-read.news.verio.net> Thank you all. I knew there was a simple way. -mjm "Ken Seehof" wrote in message news:mailman.991688947.28483.python-list at python.org... >>> num = 49 >>> print "%05d" % num 00049 The % operator is popular for C/C++ programmers like me, who are used to the standard library C function "printf". Otherwise you may prefer a somewhat more pythonic approach: >>> print ("0000" + `num`)[-5:] # works for num >= 0 00049 ----- Original Message ----- From: "michael montagne" Newsgroups: comp.lang.python To: Sent: Monday, June 04, 2001 1:21 PM Subject: formatting numbers > Simple question. I am accessing a database of job numbers that take the > form of "00049" and "01049". These values are integers. When I return the > value from the database it reads "49". I need to add the leading digits if > they are there so this number would read "00049". In MSAccess I used > Format(num,"00000"). How can I do that with Python? > > -mjm > > > > -- > http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From mwh at python.net Wed Jun 13 14:38:37 2001 From: mwh at python.net (Michael Hudson) Date: 13 Jun 2001 19:38:37 +0100 Subject: PyArg_ParseTuple part 2 References: Message-ID: "John" writes: > Hi, > > In an extended python c function, I use PyArg_ParseTuple to extract a > list object from python. I then use PyList_AsTuple to get a tuple version > of the list. I'm expecting an list of 2 integers, so I use PyArg_ParseTuple > again, passing in this new derived tuple, and specifying "ii". Should this > not work? First, after I call PyList_AsTuple, I get NULL back instead of a > PyObject. Second, lets say I pass variable x (from python) = [1,2] into my > function, right after making this function call foo(x), no matter what I > type, either x, or just enter, I get the following msg: > > SystemError: C:\Code\python\dist\src\Objects\listobject.c:1317: bad argument > to > internal function > > Anyone know what's going on? Err, you are specifying your function as METH_VARARGS, right? (Just a guess). Otherwise, how about showing us some code - I can't really follow your description above. > Related questions: Is there a fast way of extracting elements from a list, > other than using PyList_GetItem, then converting the PyObject into the type > you are looking for? Well, there's PyList_GET_ITEM, but no, not really. Lists store PyObject*s - what were you expecting? > And why isn't there a PyInt_FromInt(int) function? There's PyInt_FromLong - is that what you're after? Cheers, M. -- Presumably pronging in the wrong place zogs it. -- Aldabra Stoddart, ucam.chat From XQ.Xia at ccsr.cam.ac.uk Tue Jun 5 10:25:51 2001 From: XQ.Xia at ccsr.cam.ac.uk (XiaoQin Xia) Date: Tue, 05 Jun 2001 15:25:51 +0100 Subject: How to save the Graph on Tkinter.canvas? Message-ID: <3B1CEBEF.C178EA22@ccsr.cam.ac.uk> An HTML attachment was scrubbed... URL: From nperkins7 at home.com Wed Jun 20 01:36:21 2001 From: nperkins7 at home.com (Nick Perkins) Date: Wed, 20 Jun 2001 05:36:21 GMT Subject: Partially evaluated functions References: Message-ID: "Rainer Deyke" wrote: > ... > class curry: > def __init__(*args, **kwargs): > self = args[0] > self.function = args[1] > self.args = args[2:] > self.kwargs = kwargs > def __call__(*args, **kwargs): > kwargs.update(self.kwargs) > return self.function(self.args + args, kwargs) > ... This is pretty close to the cookbook version: http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/52549 class curry: def __init__(self, fun, *args, **kwargs): self.fun = fun self.pending = args[:] self.kwargs = kwargs.copy() def __call__(self, *args, **kwargs): if kwargs and self.kwargs: kw = self.kwargs.copy() kw.update(kwargs) else: kw = kwargs or self.kwargs return self.fun(*(self.pending + args), **kw) I notice that that the cookbook version makes a copy of the kwargs dictionary. I suppose this prevents kwargs from being modified after being supplied to curry. Also the actual call to the function uses the * and ** operators to 'expand' the arguments. I have been using this version, and it works perfectly. I was especially pleased to see how well it handles a mixture of positional and keyword arguments, any comination of which can be specified at both creation-time and at call-time. The only requirement is that positional args specified at creation-time must be the left-most positional arguments. Positional arguments supplied at call-time are inserted to the right of those specified at creation-time. For functions whose arguments are all keyword arguments, any comination of arguments can be supplied at both create-time and call-time. You can curry all of the arguments to a function, creating a callback. You can curry a class to create a sort of 'lightweight subclass', actually, more like a factory function, which creates instances, passing certain arguments to the class's __init__ Curried functions are popular among 'functional language' users, and should be more popular among Python users. Python works pretty well with 'functional' idioms, and already borrows things like map(), zip() and reduce(), which are known to be powerful functions. Another good one is compose...(also in the cookbook), which creates a single function from two other functions. From akuchlin at mems-exchange.org Wed Jun 13 14:40:07 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 13 Jun 2001 14:40:07 -0400 Subject: Inner classes References: <3b27a1aa.6747983@news.laplaza.org> Message-ID: <3dae3cfcl4.fsf@ute.cnri.reston.va.us> xyzmats at laplaza.org (Mats Wichmann) writes: > Nonetheless, I was challenged by someone to describe how it isn't a > shorcoming in Python that classes don't work this way and didn't > convince the guy so I'm looking for a more erudite comparison. Work *what* way? It's perfectly legal to do this: class C: class inner: ... stuff for inner class ... stuff for class C --amk From beechd at gatsby.tafe.tas.edu.au Wed Jun 13 08:28:04 2001 From: beechd at gatsby.tafe.tas.edu.au (David) Date: 13 Jun 2001 05:28:04 -0700 Subject: Working with paths with spaces in NT References: <9fol5s$9d3$3@216.39.170.247> Message-ID: I got a different problem on my Win2K box (Python2.0) File "G:\ses\oddstuff\dirlist.py", line 7, in getDirs os.chdir(path) OSError: [Errno 22] Invalid argument: 'wordpfct.wpg' which was due to the original line: os.chdir(path) At the end of the recursion I hit a file, hence the change below: import os import dircache import re def getDirs(path, tabs): dirlist = [] if os.path.isdir(path): os.chdir(path) for dir in dircache.listdir("."): if os.path.isdir(dir): dirlist.append(dir) print dirlist for dir in dirlist: print dir getDirs(dir, tabs + 1) getDirs("e:/Documents and Settings/", 1) Otherwise appeared to handle paths with spaces OK David David LeBlanc wrote in message news:<9fol5s$9d3$3 at 216.39.170.247>... > In article , > tim.one at home.com says... > > [David LeBlanc] > > > import os > > > import dircache > > > import re > > > > > > def getDirs(path, tabs): > > > dirlist = [] > > > os.chdir(path) > > > for dir in dircache.listdir("."): > > > if os.path.isdir(dir): > > > dirlist.append(dir) > > > print dirlist > > > for dir in dirlist: > > > print dir > > > getDirs(dir, tabs + 1) > > > > > > getDirs("L:/languages/python", 1) From gbreed at cix.compulink.co.uk Thu Jun 14 09:33:35 2001 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: 14 Jun 2001 13:33:35 GMT Subject: a newbie question about gadfly References: Message-ID: <9gaeff$1c7$1@plutonium.compulink.co.uk> In article , jm7potter at hotmail.com () wrote: > Now, if you have the time and inclination --- could you explain why > your first code > failed and the second worked? (I hate magic) > > And further, could you explain to a newbie why *my* code failed? It looks like this was answered to your satisfaction overnight. > >Oh, you have that? I think the example right at the bottom of > >p.257 should do what you want. In your case > > > >insertstat = "insert into students (name, grade) values (?, ?)" > >cursor.execute(insertstat, (namex, gradex)) > > > > This does not work. I tried it before asking here on this ng. > > In fact, your suggestion is the very code I tried. I am at a loss as to > why it does > not work in Python. It shows that I am missing some big deal in my > understanding of > the language. Some major flaw in my understanding. Are you sure you tried it exactly as written? It may be a Gadfly bug, I doubt it's a language issue. > Yes, I see how this would work --- I did not even need to try it. > > But, this is not what was used on page 257. This is how you'd do it that way, exactly as it worked for me except I used a multiline string to correct for wordwrap: >>> from gadfly import gadfly >>> connection = gadfly('test','dbtest') >>> cursor = connection.cursor() >>> insertstat = "insert into Frequents" \ "(perweek, bar, drinker) values(?,?,?)" >>> perweek=35 >>> bar='guidos' >>> drinker='tim' >>> cursor.execute(insertstat, (perweek, bar, drinker)) >>> cursor.execute('select * from Frequents') >>> print cursor.pp() PERWEEK | BAR | DRINKER ============================ 1 | lolas | adam 3 | cheers | woody 5 | cheers | sam 3 | cheers | norm 2 | joes | wilt 1 | joes | norm 6 | lolas | lola 2 | lolas | norm 3 | lolas | woody 0 | frankies | pierre 1 | pans | peter 35 | guidos | tim > I learned C about 15 years ago. I learned to use the language with very > simple i/o > --- and later explained to more sophisticated GUI interfaces. > > Some of us old guys may need to do the same with Python. Hmm, it must be over 15 years ago I learned Basic. Funnily enough, I've never used raw_input that I can remember, over the year or so I've been playing with Python. I use the interpreter interactively for that very simple I/O. It's one of the things I really like about Python. Graham From Tom_Good1 at excite.com Tue Jun 19 15:37:16 2001 From: Tom_Good1 at excite.com (Tom Good) Date: 19 Jun 2001 12:37:16 -0700 Subject: Simple example that won't work! References: Message-ID: Jay Parlar wrote in message news:... > > def download(url = 'http://www.opera.com:3600',process = firstlast): > print url > retval= urlretrieve(url)[0] Well, for me that URL is a problem. Here is my test: PythonWin 2.1 (#15, Jun 15 2001, 14:13:47) [MSC 32 bit (Intel)] on win32. Portions Copyright 1994-2001 Mark Hammond (MarkH at ActiveState.com) - see 'Help/About PythonWin' for further copyright information. >>> from urllib import urlretrieve >>> x = urlretrieve('http://www.opera.com:3600') Traceback (most recent call last): File "", line 1, in ? File "c:\python21\lib\urllib.py", line 78, in urlretrieve return _urlopener.retrieve(url, filename, reporthook, data) File "c:\python21\lib\urllib.py", line 208, in retrieve fp = self.open(url, data) File "c:\python21\lib\urllib.py", line 176, in open return getattr(self, name)(url) File "c:\python21\lib\urllib.py", line 283, in open_http h.putrequest('GET', selector) File "c:\python21\lib\httplib.py", line 432, in putrequest self.send(str) File "c:\python21\lib\httplib.py", line 374, in send self.connect() File "c:\python21\lib\httplib.py", line 358, in connect self.sock.connect((self.host, self.port)) File "", line 1, in connect IOError: [Errno socket error] (10061, 'Connection refused') >>> From hinsen at cnrs-orleans.fr Fri Jun 29 09:08:29 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 29 Jun 2001 15:08:29 +0200 Subject: the center of the world (was Re: Check out O'Reilly's Open Source Convention Highlights) References: <3B3AA82D.1A0FE860@seebelow.org> <3B3B2DED.5303198A@seebelow.org> <9hhri7019jd@enews2.newsguy.com> Message-ID: "Alex Martelli" writes: > to 'population centers'. Of course I could get different > centers by choosing different weighing factors (country GNP > rather than country population, for example). Or by Python expertise ;-) > Hmmm, if the coordinates were on a plane, finding the weighed center > would be trivial, but offhand I can't think of how to do it on a > sphere's surface -- I guess there must be some way more suitable > than just solving a generalized extremization problem -- can anybody > suggest one...? What's so bad about it? Searching for a global minimum in two variables is not so difficult. All the more within finite coordinate intervals. Of course there might be no global minimum at all. Konrad. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From tim.one at home.com Fri Jun 22 13:48:06 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 22 Jun 2001 13:48:06 -0400 Subject: Another Wart! string.find() [ was: namespace issue? ] In-Reply-To: <3B337D2B.35F2FD47@home.net> Message-ID: [Chris Barker] > Returning -1 was an unfortunate choice for two reasons: > > it is not a false value > > it is a valid index into a string Historical note: at the time these functions were designed, negative indices were not allowed: sequence[negative_int] raised an exception. Allowing the latter was a later addition to the language, and was a mixed blessing (for this and other reasons; but I think it was a net win). > This is all kind of useless discussion however as string.find is > in far too much code as it is. Yup: learn to love it, or be killed . > Besides, it really isn't all that bad anyway. Indeed, *most* endless threads are about things that don't matter . From uioziaremwpl at spammotel.com Mon Jun 25 14:55:02 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Mon, 25 Jun 2001 20:55:02 +0200 (CEST) Subject: creating a matrix in python? In-Reply-To: <3B350DC7.748C3903@telocity.com> Message-ID: On Sat, 23 Jun 2001, Adonis wrote: > how do i go about this? > > i have looked into the tutorial 100+ times and cant get anything on > matrices out of it? > only thing i came up with was some thing like: > blah = ['buh', 'blah', 'wassah'] > blah[1][0] > 'buh' bla[1][0] should return 'b'. bla[1] is the second item in the list, i.e. 'blah', and 'blah'[0] returns the first item of 'blah'. > any help would greatly be appreciated. You are probably interested in numeric matrices which can be expressed as lists of lists. Let's have a look a the following interactive session. >>> mat = [[1,2,3], [4,5,6], [7,8,9]] >>> mat [[1, 2, 3], [4, 5, 6], [7, 8, 9]] >>> mat[0] [1, 2, 3] >>> mat[1] [4, 5, 6] >>> mat[1][2] 6 >>> mat[2][1] = 999 >>> mat[0][2] = -999 >>> mat [[1, 2, -999], [4, 5, 6], [7, 999, 9]] Building such matrices in pograms may be a little bit more complicated as you can't assign values directly into a non-existing matrix (like in Perl). >>> newmatrix[2][0] = 4 Traceback (most recent call last): File "", line 1, in ? NameError: There is no variable named 'newmatrix' As one solution you may build an empty matrix (filled with 0 or None) and enter the elements later, like here: >>> mat2 = [] >>> for i in range(3): ... mat2.append([0]*3) ... >>> mat2 [[0, 0, 0], [0, 0, 0], [0, 0, 0]] >>> mat2[2][0] = 999 >>> mat2 [[0, 0, 0], [0, 0, 0], [999, 0, 0]] There are surely better ways of doing the above, but I think you get an impression how lists of lists work. Cheers, Carsten -- Carsten Geckeler From loewis at informatik.hu-berlin.de Thu Jun 7 04:54:40 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 07 Jun 2001 10:54:40 +0200 Subject: ExtensionClasses for Python 2.1? References: <6564c76c.0106060233.100516da@posting.google.com> Message-ID: paragate at gmx.net (Wolfgang Lipp) writes: > Does anyone know whether Jim Fulton of Zope's ;-) > ExtensionClass module is available for Python 2.1 > (preferrably compiled for w95, actually...)? > > AFAIK, the current version should be at least 1.2; > also, ExtensionClasses seemed to have worked at least > upto Python 2.0. To my knowledge, the version of ExtensionClass that is included in the most recent Zope release works fine with Python 2.1. The only issue I'm aware of is that ExtensionClass instances do not participate in garbage collection, but the disciples of acquisition will tell you that you don't need garbage collection with acquisition, anyway. Regards, Martin From mlh at idi.ntnu.no Sun Jun 17 14:40:50 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Sun, 17 Jun 2001 20:40:50 +0200 Subject: list.sort() References: <3B2CEBF1.CCF5377D@hack.org> Message-ID: <9gitji$ns2$1@tyfon.itea.ntnu.no> "Rikard Bosnjakovic" wrote in message news:3B2CEBF1.CCF5377D at hack.org... > I know the sort-method on lists changes the list in-place and doesn't > return anything, but I'm still confused. > > Take these examples: > > >>> l = [4,3,2] > >>> l = l > >>> l > [4, 3, 2] > > The list is unchanged, even after assigning it to itself. But: > > >>> l = l.sort() > >>> l > >>> print l > None Naturally. As you yourself said, sort doesn't return anything, i.e. l.sort() evaluates to None. When assigning None to l, l becomes None. Simple :) > If we split the problem into parts, "l.sort()" sorts l and it becomes > [2,3,4]. Yes, l becomes [2,3,4] and l.sort() returns None. > I expected it to be [2,3,4] after assigning it to itself (after > it got sorted), That's not what you did. You would have to do this: >>> l.sort() >>> l = l > but the list seem to got deleted instead. I don't like > this behaviour, at all. Well, what is usually said in these situations is - "write yourself a function": def sort(some_list): result = some_list[:] result.sort() return result Perhaps not very nice, but... -- Magnus Lie Hetland http://www.hetland.org "Reality is that which, when you stop believing in it, doesn't go away." -- Philip K. Dick From greg at cosc.canterbury.ac.nz Thu Jun 21 01:10:41 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 21 Jun 2001 17:10:41 +1200 Subject: PEP 255: Simple Generators References: <3B303FE5.735A5FDC@cosc.canterbury.ac.nz> <90C65699Dgmcmhypernetcom@199.171.54.194> <16074dce.0106201512.5459e720@posting.google.com> Message-ID: <3B3181D1.BFB73057@cosc.canterbury.ac.nz> David Eppstein wrote: > > Ok, another mathematical one: > > def collatz(i): > yield i > if i % 2 == 0: > return collatz(i/2) > else: > return collatz(3*i+1) Your proposal might work in the case where the recursion involved is tail-recursion, but using tail-recursion in place of iteration is a functional idiom that doesn't fit very well in Python, IMO. The cases where you would really want to use recursive generators in Python are the non-tail-recursive ones, and I don't think your proposal would help much there. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From dougfort at downright.com Thu Jun 14 21:02:29 2001 From: dougfort at downright.com (Doug Fort) Date: 15 Jun 2001 02:02:29 +0100 Subject: [Somewhat Off] Monty Python and the Holy Grail Returns to U.S. Theaters Message-ID: <3b295ea5$1_6@news5.uncensored-news.com> >From SlashDot: check out http://www.montypython.net/graildates.php Apologies to residents of other countries, but this is big news in this wasteland. -- Doug Fort Senior Meat Manager Downright Software LLC http://www.downright.com ______________________________________________________________________ Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com With Seven Servers In California And Texas - The Worlds Uncensored News Source From fdrake at acm.org Mon Jun 11 11:24:53 2001 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Mon, 11 Jun 2001 11:24:53 -0400 (EDT) Subject: spawning unix command processes which run in parallel and simultaneously In-Reply-To: <007601c0f1a3$37ab2460$1301010a@personal.net> References: <9fvhqj$57m$1@news.hk.linkage.net> <007601c0f1a3$37ab2460$1301010a@personal.net> Message-ID: <15140.58053.173289.29049@cj42289-a.reston1.va.home.com> Bufu writes: > The documentation seems to have the wrong argument order for popen2, popen3, > and popen4, where the optional bufsize and more arguments are swapped > (should read "popen2 (cmd[, mode [, bufsize]])"). > > The documentation is in the os module under "6.1.2 File Object Creation" > presumably because it creates file like objects. I would have expected it > to be in "6.1.5 Process Management", or at least a cross-reference there. Thanks for pointing this out; I've made the appropriate corrections and additions to the Library Reference. The updates will be part of the manuals for Python 2.1.1 and 2.2. And please don't hesitate to CC: additional suggestions to be me at python-docs at python.org, or submit them via the Python bug tracker at SourceForge: http://sourceforge.net/tracker/?atid=105470&group_id=5470 -Fred -- Fred L. Drake, Jr. PythonLabs at Digital Creations From foo at ix.netcom.com Sun Jun 10 23:07:41 2001 From: foo at ix.netcom.com (Matt Butler) Date: 10 Jun 2001 20:07:41 -0700 Subject: Win32 Installer on 2.1? References: <50be6f7c.0105220115.612c9912@posting.google.com> <50be6f7c.0106062352.a6f2670@posting.google.com> <50be6f7c.0106071259.13fcbfc3@posting.google.com> <90BA710B4gmcmhypernetcom@199.171.54.154> Message-ID: <50be6f7c.0106101907.169d0e07@posting.google.com> All- After Gordon's last note I went ahead and took the jump to 2.1. Using Installer 4a1, everything went smooth. Meaning that I had no new issues. My app has issues, because it's still in development. It's a small (~3000 line) app. Which makes extensive use of Tkinter. From marcora at colorado.edu Thu Jun 7 11:27:08 2001 From: marcora at colorado.edu (Edoardo ''Dado'' Marcora) Date: Thu, 7 Jun 2001 09:27:08 -0600 Subject: How can I extend raw_input to provide user w/ default input string? References: <9fmgli$43f$1@peabody.colorado.edu> <3B1F0D82.DB10E008@yahoo.com> Message-ID: <9fo6g6$36v$1@peabody.colorado.edu> Thanx Paul for your helpful suggestion. However, I was thinking about presenting the user with a default input and give him/her the ability to edit it. Maybe I should think about using Tkinter if this is impossible to do using a console interface. "Paul Winkler" wrote in message news:3B1F0D82.DB10E008 at yahoo.com... > Edoardo ''Dado'' Marcora wrote: > > > > I am wondering if it is possible to provide the user with a default input > > string using raw_input or similar function. > > If you just want to show the default, that could be done like this: > > import sys > > def raw_input_with_default(prompt, default="yes"): > sys.stdout.write(prompt + " [%s] " % default) > result = sys.stdin.readline().strip() > result = result or default > return result > > > So if they don't type any non-whitespace characters before hitting return, > default will be used. > > If you want them to be able to *edit* the printed default string... I have no > idea. > > HTH, > > PW From emarkp at CSUA.Berkeley.EDU Sat Jun 2 12:49:58 2001 From: emarkp at CSUA.Berkeley.EDU (E. Mark Ping) Date: Sat, 2 Jun 2001 16:49:58 +0000 (UTC) Subject: Why isn't Python king of the hill? References: <9fa5fi0fru@enews2.newsguy.com> Message-ID: <9fb5fl$26kf$1@agate.berkeley.edu> In article , Grant Edwards wrote: >On Sat, 2 Jun 2001 09:42:34 +0200, Alex Martelli wrote: >>And it is (on any FP system respecting IEEE 754 -- and any >>other FP system I've ever heard about). > >I know that it is. But when you start depending on that fact, >you're doomed. That's silly and just plain wrong. You should depend on understanding how FP works. And in this case, 1.0 + 2.0 == 3.0 every time on every platform that I've run into--I don't know that because I just happened to try it out, but rather I know how the FP works on those platforms and know that it is correct. >>> should always treat floating point operations as if there are >>> small random numbers being thrown in at every step. So you >> >>I think this is exactly what Kahan describes as one of the >>widespread (and false) myths about floating point. > >Of course it is not true. But if you pretend it is, you've got >a much better chance of producing working code. You should definitely read Pete Becker's articles in the June, July and October 2000 issues of The C/C++ Users Journal. He explains why you're statement is insufficient and incorrect. For instance, two very large numbers might really be the same, but be off by a bit. Checking the difference of the values will yield another large number, and a method like "IsCloseTo" will incorrectly fail. Really, floating point arithmetic has well-defined semantics; guessing and treating them as if they have random components is the lazy and error-prone way to use them. -- Mark Ping emarkp at soda.CSUA.Berkeley.EDU From gmcm at hypernet.com Wed Jun 20 16:23:50 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 20 Jun 2001 20:23:50 GMT Subject: calldll: given a longint (=pointer) - howdoi access the data? References: <3b30d4f2.21236779@news.muenster.de> <90C657DA0gmcmhypernetcom@199.171.54.155> <3b30ec78.26180817@news.muenster.de> Message-ID: <90C6A5F4Cgmcmhypernetcom@199.171.54.154> Martin Bless wrote: >It's a pity there's so little documentation about the 'calldll' and >'npstruct' stuff. What I really mean is: I didn't find ANY doc at all >- not counting the c-source itself which I do not understand (yet). Let's just say that if there were someone with the brains, patience and inclination to follow Sam Rushing around and finish all that he starts, the world would be a *very* different place. - Gordon From phd at phd.fep.ru Wed Jun 27 04:02:09 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Wed, 27 Jun 2001 12:02:09 +0400 (MSD) Subject: threadpool In-Reply-To: Message-ID: On Tue, 26 Jun 2001, Yirong Shen wrote: > Can anyone suggest a good threadpool implementation for Python? May be you'll find http://txobject.sourceforge.net/ useful? Features (C++/Python): ... Object-Oriented Threads ... Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From jkraska1 at san.rr.com Mon Jun 11 18:35:43 2001 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 11 Jun 2001 22:35:43 GMT Subject: Learning OOP... References: <3b25059c.5089017@news.laplaza.org> <9g36ej02ah6@enews1.newsguy.com> Message-ID: >Given that those Python objects, 'under the hood', are implemented >in C (which doesn't offer inheritance), it would be truly amusing >if Python had managed to use inheritance anyway...:-) Well, the X library uses "inheritance," except, of course, the rest of the world calls it "composition". :-) It's-all-just-games-of-nomenclature-ly-yrs C// From DARK_SNIPA at NTLWORLD.COM Mon Jun 11 23:17:04 2001 From: DARK_SNIPA at NTLWORLD.COM (CEREBRAL ASSASSIN) Date: Tue, 12 Jun 2001 03:17:04 GMT Subject: EXCELLENT NEW WEB BOARD!! CHECK IT OUT :) Message-ID: From boyd at insultant.net Wed Jun 6 06:44:07 2001 From: boyd at insultant.net (Boyd Roberts) Date: Wed, 6 Jun 2001 12:44:07 +0200 Subject: best language for 3D manipulation over web ? References: Message-ID: <9fl1k2$avh$1@neon.noos.net> "Amardeep Singh" a ?crit dans le message news: mailman.991760892.19711.python-list at python.org... > > > On Tue, 5 Jun 2001, Attila Feher wrote: > > > > > Creating a perfectly secured Unix system is equally extremely hard. > > not if you know what you are doing no, it isn't. been there, done that. openbsd seems to be the choice. i've ignored the 'perfectly' because that is not possible. no usable system can offer perfect security. the problem with windows is that the original model was totally flawed and it has inhereted that right down the line. NT is a ghastly mess. it's security is laughably complex, therefore unusable. someone should teach those kids at redmond how to do virtual memory and someone should teach dave cutler that VMS sucked. here is a gem that was fixed by microsoft a while back, but it demonstrates their basic lack of understanding: http://www.planete.net/~boyd/fnt.html From d_krause at pixelpark.com Thu Jun 28 05:56:35 2001 From: d_krause at pixelpark.com (DirkK) Date: Thu, 28 Jun 2001 11:56:35 +0200 Subject: AW: How to grab HTML files behind authentification Message-ID: <704219C33D36D5119319000102053E500A8F76@marvin.bitlab.de> To be honest, I didn't try this (though it's obvious). But on the other hand, the other approach is a bit more transparent, because you control the header yourself. Do you have another easy solution for cookies (this would have been the next thing I need)? Dirk -----Ursprungliche Nachricht----- Von: Oleg Broytmann [mailto:phd at phd.fep.ru] Gesendet: Donnerstag, 28. Juni 2001 11:51 An: Dirk Krause Cc: python-list at python.org Betreff: Re: How to grab HTML files behind authentification Thank you. But do you know urllib can do the same even simpler? urllib.urlretrieve("myName:myPassword at http://www.something.com/secret/index. html") On 28 Jun 2001, Dirk Krause wrote: > I've put together some code the python community might find useful. > You can use this script to automatically spider web pages beyond the > www-authenticate Dialog Box. > > ---snip--- > import httplib, string, base64 > > # How to grab HTML files behind authentification > # author: Dirk Krause, 06/28/2001 > # change these entries below!! > > base = 'http://www.something.com' > path = '/secret/index.html' > > u_name = 'myName' > u_pwd = 'myPassword' > > > # ok, here goes > > hlink = httplib.HTTP(base) > hlink.putrequest('GET', path+' HTTP/1.0') > hlink.putheader('Host', base) > > hlink.putheader('Accept', 'text/html') > hlink.putheader('Accept', 'text/plain') > > temp = "%s:%s" % (u_name,u_pwd) > temp = base64.encodestring(temp) > temp = "Basic %s" % string.strip(temp) > hlink.putheader("Authorization",temp) > > hlink.endheaders() > > errcode, errmsg, header = hlink.getreply() > content = hlink.getfile().read() > > print content > print errcode, header Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. -------------- next part -------------- An HTML attachment was scrubbed... URL: From Paul.Casteels at ua.ac.be Thu Jun 28 10:35:12 2001 From: Paul.Casteels at ua.ac.be (Paul.Casteels at ua.ac.be) Date: 28 Jun 2001 16:35:12 +0200 Subject: qt or gtk? References: <9gk8he$8gl$1@brokaw.wa.com> <16074dce.0106181045.139d80a5@posting.google.com> Message-ID: <3b3b40a0@news.uia.ac.be> Jeff Shannon wrote: : elf at halcyon.com (Elf Sternberg) wrote in message news:<9gk8he$8gl$1 at brokaw.wa.com>... :> In article :> sill at optonline.net (Rainy) writes: :> :> >> Qt is distributed under the GNU Public License and TrollTech's :> >> Commercial License. What this means is that if you write a program :> >> using Qt, you have two choices: you can distribute your program in the :> >> whole, source code and all, or your can pay TrollTech's licensing :> >> contract and keep your source code secret. :> :> >Is this true for both qt for X and qt for windows or only for X qt? :> :> The GNU Public License does not specify what operating systems :> it applies to. If you can build or modify the GPL version of QT to work :> with the Windows operating system, then you can build GPL programs for :> Windows with QT. :> :> Elf : But if (as was stated before) only the X11 codebase is available under : GPL, then the fact that the license doesn't specify an OS is a technical : detail. In order to run the GPL version under Windows, you would essentially : be emulating Unix on Windows (cygwin + X-server), with all the little : gotchas that tend to come with emulation. Of course, if the X11 : source is GPL, then you could, in theory, port that to Win32 yourself.... The licensing for non-commercial applications for Qt/Win32 was changed very recently. Have a look here : http://www.trolltech.com/company/announce/noncommercial.html -- Paul Casteels Paul.Casteels at ua.ac.be Tel: +32.3.8202455 Fax: +32.3.8202470 University of Antwerp Dpt.Physics Universiteitsplein 1 B-2610 Wilrijk Belgium From salvatore.didio at wanadoo.fr Wed Jun 6 17:13:23 2001 From: salvatore.didio at wanadoo.fr (Salvatore DI DIO) Date: Wed, 6 Jun 2001 23:13:23 +0200 Subject: Vaults of parnassus not accepting new submissions? References: Message-ID: <9fm5un$nvc$1@wanadoo.fr> Hello, I've submitted a site and they gave me a positive response within a few days. Salvatore From sill at optonline.net Mon Jun 4 16:38:25 2001 From: sill at optonline.net (Rainy) Date: Mon, 04 Jun 2001 20:38:25 GMT Subject: Help a newbie pls! References: Message-ID: On Mon, 4 Jun 2001 20:52:58 +0100, David A. wrote: > Hi to all, > > I am a newbie to python and I was writing a very simple script taht takes > the content of one file and then re-writes it in the H4x0r style (i know, I > know, it's completly stupid and useless, and, no I am no of them, it is just > a toy program...) the problem is it doesn't work, could anyone look at the > few lines and explain me why? > > in the source code I say you where it stops to work. > > thanks for any help in advance! > > > There you go (I explain everything in comments): #!/usr/bin/env python #31172 H4x0R # # or # # Fancy writing! import tempfile import sys import string def main(): print "hello" try:file=open('FAQ.txt') except IOError: print "Unable to open file", file sys.exit(4) #try: temp_file=open('res.txt','w') #tempfile.mktemp() #except IOError, msg: # print "Unable to create temp file!" # print msg # sys.exit(2) x=0 # that's the correct (and accepted) way to write it # it's not as clean, so 2.2 will have a cleaner version, # and 2.1 already has a better version using .xreadlines() # but I don't know which version you're using.. # in 2.1 i think it's while line in file.xreadline(): or something similar while 1: line = hx0(file.readline()) if not line: break temp_file.write(line) x = x+1 print x sys.exit(0) def hx0(line): new_line=[] for letter in line: if letter=='i':letter='1' if letter=='a':letter='4' if letter=='o':letter='0' if letter=='x':letter='X' new_line.append(letter) # otherwise, join inserts a space between joined elements return string.join(new_line,'') # print new_line main() -- I'll give you anything, everything if you want things - Syd From see at my.signature Tue Jun 19 23:31:32 2001 From: see at my.signature (Greg Ewing) Date: Wed, 20 Jun 2001 15:31:32 +1200 Subject: Two minor syntactic proposals References: <9gkcsn0229c@enews2.newsguy.com> Message-ID: <3B301914.7B60E6F7@my.signature> Alex Martelli wrote: > > I just hope it doesn't have to be > as narrowly-worded as "allowing def x.y iff x is specifically > a bare identifier that is bound to a class-object and is > also the class's classname"...:-). I like this idea too! The way I'd describe it is as allowing a general l-value (i.e. anything that can appear on the lhs of an assignment) in place of the current identifier-being-bound in def, class and import statements. By the way, here's another possible use -- creating a dict-of-funcs for simulating a case-statement: table = {} def table['spam'](): ... def table['eggs'](): ... (On the downside -- I like the def self.foo() idea too, and this is in direct conflict with it! Sigh, can't have everything, I suppose, and I think I'd rather have this than def self.foo() if it came down to a choice.) -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From amardeep at tct.hut.fi Sat Jun 16 09:54:37 2001 From: amardeep at tct.hut.fi (Amardeep Singh) Date: Sat, 16 Jun 2001 16:54:37 +0300 (EET DST) Subject: qt or gtk? In-Reply-To: <3B2B609B.285DCB06@web.de> Message-ID: On Sat, 16 Jun 2001, Dominic wrote: > > > Rainy wrote: > > > I want to learn python gui programming in linux. I think tk looks too ugly, so > > I narrowed down the choice to two main contenders, qt and gtk. Which of these > > has more complete and up-to-date python bindings? Are there other reasons > > to prefer one of these over another for python gui work? > > > > The QT toolkit is technically better (quality of code). ^^^^^^^^^^^ ^^^^^^ care to explain why? So some time > has passed since I had compared them. But I do not know how good > or bad the bindings are. I suggest you should use the tk toolkit > it seems to have a good binding and comes with the standard > python distribution. And the TCL/TK toolkit has a high quality. > So TK would be best in my humble opinion, and QT second. > (QT is not completely free but that doesn't make it bad, actually > it's the best X- Toolkit for C++ programming.) > > Ciao, > Dominic > > > > > > > -- > > "Your password must be at least 18770 characters and cannot repeat any of your > > previous 30689 passwords. Please type a different password. Type a password > > that meets these requirements in both text boxes." > > (Error message from Microsoft Windows 2000 SP1) > > From qrczak at knm.org.pl Wed Jun 6 02:35:16 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 6 Jun 2001 06:35:16 GMT Subject: integers References: <9fjd8q$qb6$1@charm.magnus.acs.ohio-state.edu> <9fjgqf$rp0$2@brokaw.wa.com> <9fjj16$4in$1@news.mathworks.com> Message-ID: 5 Jun 2001 21:30:14 GMT, Joshua Marshall pisze: > I like how Python keeps side-affecting language constructs in the > realm of statements. Well, function invocations can have side effects. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From s713221 at student.gu.edu.au Mon Jun 4 05:12:47 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Mon, 04 Jun 2001 19:12:47 +1000 Subject: Lego Mindstorms robotics control via Python? References: Message-ID: <3B1B510F.5866FAC5@student.gu.edu.au> Sean 'Shaleh' Perry wrote: > > On 01-Jun-2001 Kevin Altis wrote: > > I would like to control a robot via Python on Windows (specifically Windows > > 2000). The Lego Mindstorms product is relatively inexpensive and easy to > > find and supports an infrared transmitter, so that seems like a good choice > > to program around. Does anyone know if there is a already a Python wrapper > > for issuing RCX ("yellow brick") commands? If not, how about a COM-enabled > > app that I could control or a C library/source that I could wrap in Python? > > Any other suggestions, reading material, or URLs for further info would be > > appreciated. I would be interested in controlling other robotic devices, but > > only if they are commercially available and relatively inexpensive. > > > > There is a project called LegOS. You should track it down. Makes mindstorm > programming useful again. There's also a python extension for LegOS at http://www.hare.demon.co.uk/lego/pylnp.html. Was curious so I search-engined it. adding-yet-another-module-to-his-machine-that-he-will-probably-never-use-ly yours, Joal Heagney/AncientHart From new_name at mit.edu Tue Jun 26 09:18:11 2001 From: new_name at mit.edu (Alex) Date: 26 Jun 2001 09:18:11 -0400 Subject: urllib: geturl with max filesize? References: <9ha08v$n0s$02$1@news.t-online.com> Message-ID: I don't know about other security issues. It may depend on what you plan to do with the content the user points you at. But you can limit the download size fairly easily: import urllib f = urllib.urlopen(url) data = [] while len(data) < 1024: block = f.read(1024) if block == '': break data.append(block) f.close() write(''.join(data)) ...will restrict the download to 1M, I guess. HTH Alex. From andersh at nextramobile.com Tue Jun 5 06:12:55 2001 From: andersh at nextramobile.com (Anders Hanssen) Date: Tue, 5 Jun 2001 12:12:55 +0200 Subject: PYML, Python, Perl and Zope References: Message-ID: <6g2T6.5360$vu4.530477@news3.oke.nextra.no> "John Abbe" wrote: > Zope uses DHTML, right? Is anyone using it with PYML? Zope use DTML: http://www.zope.org/Documentation/Guides/DTML-HTML/ -- \anders From boud at rempt.xs4all.nl Sat Jun 30 02:28:42 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 30 Jun 2001 06:28:42 GMT Subject: noncommercial Python+QT on Windows? (was Re: qt or gtk?) References: <9gk8he$8gl$1@brokaw.wa.com> <16074dce.0106181045.139d80a5@posting.google.com> <3b3b40a0@news.uia.ac.be> <9hfjho05to@enews1.newsguy.com> Message-ID: <9hjriq$pc8$1@news1.xs4all.nl> John J. Lee wrote: > Hasn't been released yet, and will only be available for MacOS X. I don't > think Trolltech has stated what the license options will be. Matthias Ettrich from Trolltech has stated on Linuxtoday that there will also be a non-commercial license for OS X. -- Boudewijn Rempt | http://www.valdyas.org From chrishbarker at home.net Thu Jun 7 15:52:37 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 07 Jun 2001 12:52:37 -0700 Subject: floating point in 2.0 References: <9fiptc$m9d$1@panix2.panix.com> <3B1D154B.81016685@home.net> <3B1DC3AE.6EA1F09D@accessone.com> <3B1FCBD8.C43504C1@home.net> <9fokct$o6q$1@hadron.noos.net> Message-ID: <3B1FDB85.E2A7D53A@home.net> Boyd Roberts wrote: > it's simple: > > floating point represented in finite binary is not precise > for all values. > > learn to live with it. it's one of the first things they teach you > in comp sci. unless you really know what you're doing it is not a > subject that you re-invent as a weekend project, not unless you're > a fan of dire, unforeseen consequences. Unfortunately, if you know no more than the fact that some amount of error can be introduced, you are doomed to your "dire, unforeseen consequences". Either than or not using floating point at all. Some operations produce no or little error, and some produce a great deal of error. If you have no idea which is which, than you are stuck. Many of us can get away with ignoring floating point error (especially when using doubles), but the more you know , the better off you are, and it is difficult stuff, but not unknowable. By the way, one of my collegues introduced a bug with floating ppoint round off in a way that I di not forsee, and it took us a long time to find it. We need to store a LOT of values in a file, and so as not to waste space, we used the array module, and stored them as single precision floats. Whe we used them after reading the file, they got typcast to s Python Float (C double). As it happens, these values were angles, with none greater than 2*pi. later, when we checked the values, we found that when you round a double representation of pi to a float, and then back to a double, you get a bigger number, which we didn't expect. Here is an example: >>> from array import array >>> from math import pi >>> pi2 = array('f',[pi]) >>> a = array('f',[pi]) >>> pi2 = a[0] >>> pi2 > pi1 1 This took a while to find! -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From senux at senux.com.NOSPAM Fri Jun 15 01:17:14 2001 From: senux at senux.com.NOSPAM (Brian Lee) Date: Fri, 15 Jun 2001 05:17:14 GMT Subject: crypt module on win32? Message-ID: <3B299A96.C42FC98C@senux.com.NOSPAM> Hi, I want to use some Python code on MS-Windows. The code use crypt module but there is no such module on Python for MS-Windows. Any other modules which works like crypt module? Or... any ideas? - Brian,. From roedy at mindprod.com Mon Jun 4 18:38:33 2001 From: roedy at mindprod.com (Roedy Green) Date: Mon, 04 Jun 2001 22:38:33 GMT Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> Message-ID: On Sat, 2 Jun 2001 18:30:47 -0400, "Bart Kowalski" wrote or quoted : >mbedded processors (watches, cell-phones, calculators, >etc), Last time I looked there were more microprocessors in cars than on desktops. For that sort of application, coding cost is spread over more units, and it not going to change. You have to get it right first time, and you have to squeeze it into the cheapest possible hardware. It quite different from writing code to handle business logic where ease of maintenance is paramount. For more detail, please look up the key words mentioned in this post in the Java Glossary at: http://mindprod.com/gloss.html If you don't see what you were looking for, complain! or send your contribution for the glossary. -- Roedy Green, Canadian Mind Products Custom computer programming since 1963. Ready to take on new work. From tim.one at home.com Thu Jun 14 22:24:47 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 14 Jun 2001 22:24:47 -0400 Subject: idle BUG In-Reply-To: Message-ID: [Robin Becker] > I think this must be a bug in Tkinter, but since no one ever responds I > thought I'd whine about idle instead. See http://sf.net/tracker/?group_id=5470&atid=105470&func=detail&aid=216289 > I run python2.1 Win95 OSR2. > Start a command window > run python idle.py > > Kill the idle window using the mouse (click on the x). In some unknown > percentage of cases (like 50%) the process hangs and doesn't return to > the command window. > > The hung process is very destructive and makes it impossible to reboot > the machine properly. This bug has been present for a very long time > and I'm fed up with it. Use pythonw instead. Then it doesn't hang. Nobody knows how to fix it, or even what causes it (follow the link). > It's clearly some kind of race between python and Tcl/Tk. Fredrik Lundh has provoked the same problems with pure Tcl/Tk apps run from a wish shell -- no Python components involved. That is, there's no reason to believe Tkinter or Python have anything to do with this. > The problem doesn't occur on win2k so I guess there's some > difference between the run times that helps. Win9x suffers many flaky behaviors related to consoles and processes. pythonw appears to avoid the hangup problems simply by getting the console window out of the equation. Without MS's source code at hand, I doubt we'll ever get a deeper understanding than that. From thomas at xs4all.net Thu Jun 28 16:00:53 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 28 Jun 2001 22:00:53 +0200 Subject: Problems with ./configure options (Python-2.1) on HPUX11 for 64bit ELF format In-Reply-To: <3b091a1c.0106280908.2b997f95@posting.google.com> Message-ID: <20010628220053.Z8098@xs4all.nl> On Thu, Jun 28, 2001 at 10:08:03AM -0700, cmkl wrote: > The problem is, that configure is not able to estimate some > options correctly: i.e. SIZEOF_LONG and SIZEOF_VOID_P is set to 4 > instead of 8. > OPT=+DD64 ./configure --whatever or 'CC=cc +DD64' ./configure --whatever > do not have en effect on the estimation of the SIZEOF constants. > At least SIZEOF_FPOS_T also has set to 8. This is just a wild guess, but did you remember to throw away 'config.cache' before running configure with those options ? And if you type 'make' after the configure, do you see make execute 'cc +DD64' like you want it to ? OPT won't work, because it isn't used in the SIZEOF tests, but CFLAGS should, and setting CC should also work. Perhaps HP's 64-bit support is of the kind where you need to use special datatypes for it to work ? -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From robin at stop.spam.alldunn.com Wed Jun 20 00:12:16 2001 From: robin at stop.spam.alldunn.com (Robin Dunn) Date: Wed, 20 Jun 2001 04:12:16 GMT Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: <73PX6.317$zE1.418988@news.uswest.net> <3B2FE2BD.F210FA8A@home.net> Message-ID: > > What I imagine is this: > > A GUI library that is built for Python, that interacts well with the > Python library and all the native type. This library would, for > instance, expect to get a Python list whne is needed a list of items. It > would be written in C++ (or maybe C). It would be platform independent. > The strength in this approach is that the core library could just as > easily be extended in either Python or C/C++. This way, the community > could develop nice higher-level widgets and really expand the toolbox. > It could be used from either C/C++ or Python. This way, one could > develop a C/C++ app with an embedded python interpreter, and GUI code > could be run from either language, the transition would be easy. > > Many of these features now exist in wxPython. I'd say nearly all, but that's just my slightly biased opinion... > That is why I am using it. > However, wxPython is a thin wrapper around a C++ class library. This is > a good thing because it allows common documentation and the wrappers can > be produced with SWIG. But arguably not a *Good Thing*. Mainly it just reduces complexity enough that one single ordinary human can develop, enahance, maintain, and find/fix bugs in the package and still have time for a real job and a bit of a life. SWIG doesn't generate the best code, but it means that there is around a quarter of a million lines of code that I don't have to maintain and debug by hand! > It is a bad thing because you end up writing > Python code that is not natural (pythonic), and a whole lot more verbose > and complex than it needs to be. Since I have a strong C++ background I look at the world with an intermixed C++/Python view, so I often have a hard time seeing the "non-pythonic" issues with wxPython but I know they are there. I've addressed many of them at the SWIG layer and there have been a few contributions for the wxPython.lib package for some more pythonic things at the Python layer. I'll accept all contributed code that makes things easier. > It also suffers some from performance > issues do to translating from Python lists to wxLists, generating > wrappers around C++ objects, etc. I've recently had some ideas and added items to my todo list that will probably help out in this area, so I think this will become less of an issue over time. On the other hand, for a large majority of things wxPython is used for it is fast enough already. > I don't understand the details, but > the issues are there. wxWindows and Python also share a lot of duplicate > functionality: sockets, database access, process control, file system > manipulations, etc. etc. Much of which can be turned off when compiling wxWindows, but there probably will always be some overlap with the current architecture. -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! From guido at digicool.com Fri Jun 22 13:12:20 2001 From: guido at digicool.com (Guido van Rossum) Date: Fri, 22 Jun 2001 13:12:20 -0400 Subject: Python 2.0.1 released! Message-ID: <200106221712.f5MHCLF07192@odiug.digicool.com> I'm happy to announce Python 2.0.1 -- the final release of the first Python version in a long time whose license is fully compatible with the GPL: http://www.python.org/2.0.1/ I thank Moshe Zadka who did almost all of the work to make this a useful bugfix release, and then went incommunicado for several weeks. (I hope you're OK, Moshe!) Compared to the release candidate, we've fixed a few typos in the license, tweaked the documentation a bit, and fixed an indentation error in statcache.py; other than that, the release candidate was perfect. :-) Python 2.0 users should be able to replace their 2.0 installation with the 2.0.1 release without any ill effects; apart from the license change, we've only fixed bugs that didn't require us to make feature changes. The SRE package (regular expression matching, used by the "re" module) was brought in line with the version distributed with Python 2.1; this is stable feature-wise but much improved bug-wise. For the full scoop, see the release notes on SourceForge: http://sourceforge.net/project/shownotes.php?release_id=40616 Python 2.1 users can ignore this release, unless they have an urgent need for a GPL-compatible Python version and are willing to downgrade. Rest assured that we're planning a bugfix release there too: I expect that Python 2.1.1 will be released within a month, with the same GPL-compatible license. (Right, Thomas?) We don't intend to build RPMs for 2.0.1. If someone else is interested in doing so, we can link to them. --Guido van Rossum (home page: http://www.python.org/~guido/) From jeff at ccvcorp.com Wed Jun 27 13:07:01 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 27 Jun 2001 10:07:01 -0700 Subject: the indentaion for grouping thing References: <3b34de9a$1_2@anonymous> <9h2qpa$6bg$1@slb0.atl.mindspring.net> <3b38f4a5_1@anonymous> Message-ID: <3B3A12B5.BBEC3A4D@ccvcorp.com> Anonymous wrote: > "Andrew Dalke" wrote in message > news:9h2qpa$6bg$1 at slb0.atl.mindspring.net... > > Use tabnanny, or run Python with the '-t' or '-tt' > > options. If you're worried, force your version > > control system to run a validation on the code > > before checking it in. > > Like I said, all answers like "well, just use product x" don't fly because > it's not just me that has to use the script. I want my scripts to be > maintainable by people I don't necessarily know of. I consider it a design > flaw to have the language dependent upon artificial solutions that are > external to the language in order to have it be maintainable. Well, if you run Tabnanny on every file that you edit, and on every file that ends up having a problem, then... maintenance becomes trivial. And if you (or the other developers) are using any sort of IDE or decent editor, then the whole tab/spaces issue will never come up to begin with--and even if some pathological case arises where this *is* a problem, that tabnanny check will fix it in minutes (or less). > Anyway, nothing will change, so is there a product like I asked about that > validates and parsers python with paired delimiters added? Not pindent, and > not comments, because the script has to be unparseable by python without the > pre-processor. Tabnanny fits all of the *real* requirements here--it doesn't enforce your hypothetical delimiters, but it *does* validate code and enforce valid code blocking. It is not Python's fault if you insist on using language constructions that are foreign to it, and it is under no obligation to enforce some other language's rules. If you are really so obsessed about delimiters, then maybe you shouldn't use Python. There are plenty of other languages that use delimiters. Jeff Shannon Technician/Programmer Credit International From pj at sgi.com Tue Jun 26 23:28:59 2001 From: pj at sgi.com (Paul Jackson) Date: 27 Jun 2001 03:28:59 GMT Subject: PEP 260: simplify xrange() References: <3B39480C.F4808C1F@Lugoj.Com> Message-ID: <9hbjtr$jnvjl$1@fido.engr.sgi.com> James quipped: |> > although-it-would-be-impolite-to-ask-we-why-still-ship-a-directory- |> > full-of-crufty-old-irix5-demos-in-the-std-library-ly |> |> Perhaps because the Irix community would be quite Irate if they were I can't speak for the Irix community, but I am confident that the Irix vendor wouldn't mind. Looks to me like Irix 5 is about 7 years old, from the perspective of the RCS source tree dates. -- I won't rest till it's the best ... Manager, Linux Scalability Paul Jackson 1.650.933.1373 From hbn at imada.sdu.dk Sat Jun 2 17:38:12 2001 From: hbn at imada.sdu.dk (Henrik Berg Nielsen) Date: Sat, 2 Jun 2001 23:38:12 +0200 Subject: Copying files to multiple comp's on a lan References: <9f8k3v$1i04$1@news.cybercity.dk> Message-ID: <9fbmbk$2acl$1@news.cybercity.dk> Hi again all, Thx for all the replys, it was really more than I expected! I've been reading over all your suggestions and I can see that I should have provided a bit more information about the machines involved. So here goes: All machines, including the host which should distribute the files, run Win2k. I have write access to all machines, and all machines have a share called "temp" on the C drive. Likewise all machines have the same login and password. I've been fiddling a bit around with the various suggestions you guys made and I can't really seem to get it to work my way. I'd prefer the Python approach (as it seems doable and I have absolutely 0 experience on shell programming). So far I haven't been able to access file on the remote machines via the open() method. What should I write if I wanted to access the file called "foo.txt" located in the "temp" folder on the C drive of the machine named "Orion"? I like the approach more where I let os.system() do the copying for me, but it really doesn't work all that good if I can't assemble the proper network paths. On a side note; what does os.sytem() do specifically? I thank you all alot for all the fine responses, but could you next time please be a bit more specific as I'm a rather newbie to all this stuff... :) Also I tried "import win32api, win32file, win32net" and it can't find neither of them, should I install these seperately or what? (plz don't laugh :)) Thanks again, Henrik Berg Nielsen "Henrik Berg Nielsen" wrote in message news:9f8k3v$1i04$1 at news.cybercity.dk... > Hi all, > > I'm rather new to Python, and this is my first post in this NG (as you can > probably tell). I hope that you guys can get the meaning of my writings as > english is not my native language, so I apology beforehand for any > spelling/grammatical errors. > > I need to make a small script thats capable of copying a file from the > machine that its being run on to all the other machines on the lan. The > target path on all the other machines should be the same. The script should > take the path of the source file and the remote path to the shared folder(s) > as arguments. I'll define all the machines the file is to be copied to > elsewhere. > > Where do I start when making such a script? What kind of builtins should I > know of and which functions will be useful in my work? What do I need to > investigate closer (I've never tried network programming before)? > > I used to do this filecopying for each machine seperately with the Windows > Explorer, and seeing as its something that I do rather often, I'm beginning > to get a little bugged by this tedious method, and have decided that now its > time to make it a little more automated. > If you know of an already existing program that can accomplish this task for > me any pointers would be greatly appreciated. > > Thanks in advance, > > Henrik Berg Nielsen > > From MarkH at ActiveState.com Thu Jun 21 21:00:49 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Fri, 22 Jun 2001 01:00:49 GMT Subject: Installation problem with Win32Comm References: <3B32883E.29DA9AB4@raqia.com> Message-ID: <3B3298C0.2080805@ActiveState.com> David Lees wrote: > I must be doing something incorrect with the setup of Win32Comm. I > unzipped it and am trying to run the test demo: commtest.py and get the > following stack traceback. I am running under NT, with active state > Build 210 Python I have no idea, but consider using the COM port facilities already in ActivePython. See win32\Demos\win32comport_demo.py for an example. Mark. From python_binto at yahoo.com Wed Jun 27 07:16:56 2001 From: python_binto at yahoo.com (binto bient) Date: Wed, 27 Jun 2001 04:16:56 -0700 (PDT) Subject: Welcome to the "Python-list" mailing list In-Reply-To: Message-ID: <20010627111656.20262.qmail@web14801.mail.yahoo.com> tes __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ From Pekka.Pessi at nokia.com Sat Jun 2 18:04:39 2001 From: Pekka.Pessi at nokia.com (Pekka Pessi) Date: Sat, 02 Jun 2001 22:04:39 GMT Subject: Sockets References: <3B193770.30999EAC@telocity.com> Message-ID: In message <3B193770.30999EAC at telocity.com> Adonis writes: >how can i check for errors when using the socket module? >errors like: unable to connect; insufficient memory etc. Usually, you get an exception indicating the error. If you are using sockets in nonblocking mode, you can also check errors explicitly with getsockopt() method, e.g., error = s.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR) BR, Pekka Pessi From GADGILP at INFOTECH.ICICI.com Thu Jun 14 03:02:32 2001 From: GADGILP at INFOTECH.ICICI.com (GADGIL PRASAD /INFRA/INFOTECH) Date: Thu, 14 Jun 2001 12:32:32 +0530 Subject: statically linking the entire runtime (HPUX Python2.1) Message-ID: <718A0962DFC2D4119FF80008C7289E47016FD95E@ICICIBACK3> hello, forgive me for ignorance, but I didnt know of creating a standalone exe from a python prog on unix, I went all the way to rewrite a python code to C prog cause, I needed to have a binary only. I guess, FAQ doesn't mention this. Utils I guess do something similar for win platforms like py2exe which I use. Can a easy to follow procedure be posted by the knowledgable for those not very proficient in handling C source compilations inolving make and whatnot. /prasad -----Original Message----- From: Andrew MacIntyre [mailto:andymac at bullseye.apana.org.au] Sent: Wednesday, June 13, 2001 5:30 PM To: python-list at python.org Subject: Re: statically linking the entire runtime (HPUX Python2.1) On 12 Jun 2001, cmkl wrote: > On HP-UX I'm trying to build python2.1 without building the C-modules found > in Modules/ as shared libraries. With the Version 2.0 this was the default. > I played around with configure, setup.py and Modules/Setup but I always > end up with a binary depending on various shared libraries. > I need this, bacause I want to freeze my pythons scripts as a single binary. > Distribution is much easier this way. > What is the trick to do that? I don't know specifically about HP-UX, but in general: 1: uncomment the modules you want in Modules/Setup 2: comment any "*shared*" terms in Modules/Setup 3: don't bother with setup.py, as its only for dynload modules -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andrew.macintyre at aba.gov.au (work) | Snail: PO Box 370 andymac at bullseye.apana.org.au (play) | Belconnen ACT 2616 andymac at pcug.org.au (play2) | Australia -- http://mail.python.org/mailman/listinfo/python-list . -------------- next part -------------- An HTML attachment was scrubbed... URL: From gardner at cardomain.com Sat Jun 9 23:52:34 2001 From: gardner at cardomain.com (Jonathan Gardner) Date: Sat, 9 Jun 2001 20:52:34 -0700 Subject: Why no 'elif' in try/except? References: <3B1A06EE.F484930A@snakefarm.org> Message-ID: <9fuqou$rep$1@brokaw.wa.com> Carsten Gaebler wrote: > Hi there! > > How about adding an 'elif' to try/except? I.e.: > > try: > res = dosomethingnasty() > except: > complain() > elif res == 1: > behappy() > > instead of > > try: > res = dosomethingnasty() > except: > complain() > else: > if res == 1: > behappy() > > Any opinions? > Wouldn't an 'eltry' (= "else: try:" ) make more sense? try: something except: error on something eltry: something else except: error on something else else: everything working great Which is the same as: try: something except: error on something else: try: something else except: error on something else else: everything working great The first just looks better. Thinking-around-the-else-ly yours, Jonathan From ajm at enteract.com Fri Jun 29 13:41:58 2001 From: ajm at enteract.com (Alan Miller) Date: Fri, 29 Jun 2001 12:41:58 -0500 Subject: Terminating a local process COM server References: Message-ID: Steve Holden (sholden at holdenweb.com) wrote: >Hmmm. It's not as simple as I at first believed. I thought running a service >might be a good way to go, but of course this begs the question of how to >communicate with the service! There are all sorts of options for interprocess communication on Windows, but since you're considering using a service it seems likely that you're running on NT or 2000. If that's the case, I believe named pipes should be a decent option. ajm From m.faassen at vet.uu.nl Fri Jun 29 19:11:42 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 29 Jun 2001 23:11:42 GMT Subject: PEP scepticism References: <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> Message-ID: <9hj1ve$bdu$4@newshost.accu.uu.nl> Andrew Kuchling wrote: > I don't think improving Python the language will win new converts at > this point; improving the standard library, development environments, > or the documentation is more likely to bear fruit. Ah, very much like the point I was making in a post I just made. What do you think about formalizing this, and restricting some releases of Python to be focused on bugfixes and library development, avoiding syntax changes (which frequently entail relatively large changes in semantics)? Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From sdm7g at Virginia.EDU Thu Jun 21 21:50:23 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Thu, 21 Jun 2001 21:50:23 -0400 (EDT) Subject: [OT] MS EULA -- (will ActiveState become outlaws? ;-) Message-ID: Is this the next stage of Microsoft's war against Open Source ? Discussion of this on SlashDot : ( Right before the article on the Monty Python Action Figures! ) If this spreads to all of Microsoft's EULA's, will this make ActiveState illegal ? They don't specifically mention Python's license, but they do mention Perl's ( and the "similar to any of the following" clause would seem to include Python's. ) Does anyone know if this should be taken seriously ? -- Steve Majewski (c) Open Source. Recipients license rights to the Software are conditioned upon Recipient (i) not distributing such Software, in whole or in part, in conjunction with Potentially Viral Software (as defined below); and (ii) not using Potentially Viral Software (e.g. tools) to develop Recipient software which includes the Software, in whole or in part. For purposes of the foregoing, Potentially Viral Software means software which is licensed pursuant to terms that: (x) create, or purport to create, obligations for Microsoft with respect to the Software or (y) grant, or purport to grant, to any third party any rights to or immunities under Microsofts intellectual property or proprietary rights in the Software. By way of example but not limitation of the foregoing, Recipient shall not distribute the Software, in whole or in part, in conjunction with any Publicly Available Software. Publicly Available Software means each of (i) any software that contains, or is derived in any manner (in whole or in part) from, any software that is distributed as free software, open source software (e.g. Linux) or similar licensing or distribution models; and (ii) any software that requires as a condition of use, modification and/or distribution of such software that other software distributed with such software (A) be disclosed or distributed in source code form; (B) be licensed for the purpose of making derivative works; or (C) be redistributable at no charge. Publicly Available Software includes, without limitation, software licensed or distributed under any of the following licenses or distribution models, or licenses or distribution models similar to any of the following: (A) GNUs General Public License (GPL) or Lesser/Library GPL (LGPL), (B) The Artistic License (e.g., PERL), (C) the Mozilla Public License, (D) the Netscape Public License, (E) the Sun Community Source License (SCSL), and (F) the Sun Industry Standards License (SISL). From dnew at san.rr.com Fri Jun 1 16:43:58 2001 From: dnew at san.rr.com (Darren New) Date: Fri, 01 Jun 2001 20:43:58 GMT Subject: Obsolesence of <> References: <3B17787F.266644CB@student.gu.edu.au> <3B1707A3.86AB1789@artenumerica.com> <3B17E8B3.F64581DE@artenumerica.com> Message-ID: <3B17FE8E.EFDF95F2@san.rr.com> Jose' Sebrosa wrote: > The problem with complexes is to arrange them in a unidimentional structure. As > we can map R to C (and vice-versa), it is possible: [...] > Thats the only way I can figure to invent a comparison between two complexes, > and it seems preety absurd to me... If you're looking for a consistant but nonsense way of comparing tuples, you could compare them as tuples of floats. A < B if A.real < B.real || (A.real == B.real && A.imag < B.imag). Not very good mathematics, but then mathematicians don't try to do that. :-) It certainly doesn't make any *less* sense than "foo" < 27. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. This is top-quality raw fish, the Rolls-Rice of Sushi! From alan.gauld at bt.com Tue Jun 12 09:06:06 2001 From: alan.gauld at bt.com (Alan Gauld) Date: Tue, 12 Jun 2001 14:06:06 +0100 Subject: Help for Python newbie References: Message-ID: <3B2613BE.2C5854F3@bt.com> Bob Hibberdine wrote: > I quote from the manual: > > join (words[, sep]) >>> import string >>> print string.join.__doc__ join(list [,sep]) -> string Return a string composed of the words in list, with intervening occurrences of sep. The default separator is a single space. (joinfields and join are synonymous) >>> print mystring.join.__doc__ S.join(sequence) -> string Return a string which is the concatenation of the strings in the sequence. The separator between elements is S. >>> In other words you looked at the docs for the join function within the string module but used the join method of the string class. They are not the same. Other posters showed how to do what you want with string methods. Here is how to use the string module: >>> import string # if you haven't already! >>> mylist = ['1','2','3'] >>> mystring = '' >>> mystring = string.join(mylist,'\t') >>> print mystring 1 2 3 >>> HTH, Alan G. From scarblac at pino.selwerd.nl Thu Jun 14 07:03:22 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 14 Jun 2001 11:03:22 GMT Subject: base converter References: Message-ID: Jeroen Wolff wrote in comp.lang.python: > On Wed, 13 Jun 2001 22:01:08 GMT, "Fredrik Lundh" > wrote: > > >(why has decimal to binary conversion suddenly turned into a > >FAQ the last few months? it wasn't this way in the old days, > >and I cannot remember ever having to output things as binary > >numbers in a real-life project... can anyone explain?) > > > > > > > Me it is to convert an ip addresses like (192.168.2.1/24) into a 32 > bits integer. Also the mask i wil convert to a 32 bit interger. Via > converting the 4 octets into its binary representation. Put all the 32 > bits in a string and convert it to a interger. After that i can do an > AND between these two integers and calucate the network part of it. socket.inet_aton gives the 32 bit network representation of an IP address. It gives it as a string of 4 bytes though. Then you could use struct.unpack to put it into an integer. >>> struct.unpack(">i", socket.inet_aton("127.0.0.1"))[0] 2130706433 And use & to and them. Then pack, etc. -- Remco Gerlich From tgos at spamcop.net Sun Jun 3 13:44:03 2001 From: tgos at spamcop.net (TGOS) Date: 3 Jun 2001 12:44:03 -0500 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3B1A47EA.AFBD45E8@lmf.ericsson.se> Message-ID: On Sun, 03 Jun 2001 17:21:30 +0300, Attila Feher wrote: > Just to inform you: the worlds easiest to hack and crack systems are the > UNIX systems. That's absolutely incorrect. It's easily provable by having a look at "how" hackers were entering a Unix system. Whenever a new hack is made public somewhere on the Internet, I first have a look at "how it was done" because that's most interesting to me (more interesting than "who was hacking the system" and "for what reason"). And usually I'll read the following: "This hack was possible because of a security hole in XYZ, that got fixed in version 1.234, which was released ". But that's all only valid for maybe 5% of all hacks, 95% of all hacks are only possible because the hired system admin wasn't qualified for this job. Come on, if you leave your UNIX server widely open to the public, it's no wonder if you get hacked. IOW most UNIX hacks only result of poor administration and hacking a perfectly secured UNIX system is extremely hard. In most cases it's harder than hacking Windows, because only a "root-hack" is really useful on UNIX systems, whereby on Windows systems it's enough to be an ordinary user in many cases. Despite that, more people will be able to see UNIX source code before it gets released than are actually working for Micro$oft as whole, so the chance that they find hidden bugs in network code (for example) is a lot higher than in case of Windows. But leaving this all aside for a second: *Where* in my post did I say that Unix is extremely secure and hard to hack? All I said is that Windows isn't secure. PLEASE, don't put words into my mouth that I never used! I suggest you read my post a second time. > Serious users (security, incl. but > not limited to NATO, banks etc.) use VMS. Some smaller banks use(d) > OS/2. Same situation as above. I never said that those use UNIX, did I? (if you disagree, please post the line!) All I said was that those don't use Windows. Are you sure you have read my post? And speaking about cross-platform development: OS/2 is a very good Java platform. I don't know anything about VMS, but it's certainly not impossible to port a Java Virtual Machine for this system as well. > But what is sure: Linux (UNIX) with sources is ony used (at > serious places) as firewall (where the actuall OS is inspected and > corrected line by line) and as a Web Server with no online connection to > the real internal network. Again, I never said that UNIX is used in all the places you described above. I get the feeling that you are replying to the wrong post here. > So don't take UNIX to any higher level than it is. I never did that, you are currently doing that because you assume ... well, I have no idea what you are assuming. > And about Windows being a shit: Just try to look around and find a > portable async gethostbyname or a standard gethostbyname_r for > Unices... Good luck. BTW you can find numerous workarounds which fail > in numerous environments. And the fact that this function (which I personally have never needed up to now) doesn't exist on UNIX is the proof that Windows isn't shit? Funny, but that makes no sense to me. > Windows is not better than UNIX and UNIX is not better than Windows and > none of those are neither secure nor realtime O/Ss. 1) I never said that UNIX is better than Windows (correct me if you can!), I only said that Windows is unstable, insecure and not very well thought out. 2) I never said that UNIX is secure, neither in my last post nor in this post. 3) There actually is a realtime version of Linux ... just thought I should mention that. > Don't make a religious war about this. It rather looks like /you/ are making a religious war out of that. I nowhere said "UNIX is better" and that all people shall use UNIX PC instead of Windows PCs. I use Windows myself (not as only OS, but still more often). I was only pointing out that not 99.9999% of all PCs run with Win32 (the reality is not even close to that) and that cross-platform development has no disadvantages. > BTW 1 addition: there are numerous Internet SW which run only on Windows > (some only on win9x series) and they do survive. I never said they can't survive, did I? I only said that all the BIG companies support multiple platforms, that was all. Hell, to which post are you really replying here? Certainly not to mine. > Like online casino SW. Would they survive with a Linux only solution? I don't know and I don't care. I'm a supporter of cross-platform solutions and a Linux only solution is no cross-platform solution. You seem to misunderstands my motives. Saying how shitty Windows is and only developing Linux software from this day on isn't making the situation any better. You exchange one "platform dependent solution" with another "platform dependent solution". Cross-platform development meaning to not develop for any specific platform. It means developing a base version that can run everywhere and then only fine-tune this base version for different systems. That's cross-platform development. To get back to your question: Would the casino SW developers also survive when creating software that can run on Windows, Linux, Solaris, Irix and OS/2? Certainly! Maybe even better than they are doing right now. > So there is a huge market for Windows apps. Just like there's a huge market for other OSes, so why not supplying software for more than a single market? Because you could gain more customers and earn more money? Yeah, that would certainly be a big disadvantage. If you are developing a online application that people shall be able to use within their browser (and that's what this whole thread is all about...but I assume you don't know that because you haven't read anything within this thread up to now, including my post to that you are replying), where is the advantage of limiting it to a single platform? I don't see any. The cross-platform solution is there, all you need to do is using it! -- TGOS From quango at watervalley.net Fri Jun 29 05:03:34 2001 From: quango at watervalley.net (Chris Lawrence) Date: Fri, 29 Jun 2001 09:03:34 GMT Subject: HTTP 1.1 support in BaseHTTPServer [patch 430706] Message-ID: <20010629.040327.1473442062.911@watervalley.net> I've submitted a patch to SourceForge that implements optional persistent connection support in BaseHTTPServer (#430706). Your feedback would be appreciated; I've tested it on an experimental HTTP proxy server and it seems to work well, but it would benefit from greater and wider testing. The persistence is not enabled by default, since it would break servers that don't send Content-Length headers. To enable persistent connections, set self.protocol_version to "HTTP/1.1". It will fallback nicely for HTTP/0.9 and HTTP/1.0 clients, however. http://sourceforge.net/tracker/?func=detail&aid=430706&group_id=5470&atid=305470 Chris From davygrvy at pobox.com Fri Jun 1 21:50:44 2001 From: davygrvy at pobox.com (David Gravereaux) Date: Fri, 01 Jun 2001 18:50:44 -0700 Subject: crossing boundaries into Tcl References: Message-ID: <5ahghtgilidt63v0d6tvvgsj2ljgqvks7j@4ax.com> David Gravereaux wrote: >Is there a start token that can return the value of the last operation? There >must be somewhere. The result of an eval is such a central concept to Tcl that >I find it strange that it's missing in other interpreted languages. > >Tcl_Interp *interp; > >interp = Tcl_CreateInterp(); >Tcl_Init(interp); >Tcl_Eval(interp, "pwd"); >printf("Your current working directory is %s", interp->result); > > >What's the same concept when using python embedded? How do you get the result >of an operation as a char*? Actually, the more complete code would be: Tcl_Interp *interp; int code; interp = Tcl_CreateInterp(); code = Tcl_Eval(interp, "proc foo {} {}; expr {rand()}"); if (code == TCL_OK) { printf("the random number is %s", interp->result); } else { printf("We bombed with %s", interp->result); } If all that PyRun_String() returns is "exception or not", where/how is it possible to get the last result of the operation? Is it true that POP_TOP in eval_code2() of ceval.c discards the object before returning? How can I not pop the top, and grab the result then Py_DECREF it after I'm done? -- David Gravereaux From philh at comuno.freeserve.co.uk Fri Jun 29 17:47:58 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 29 Jun 2001 22:47:58 +0100 Subject: [TO]What's the big deal with EJB? [Re: PEP scepticism] References: <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> <3d8zib16g7.fsf@ute.cnri.reston.va.us> Message-ID: On 29 Jun 2001 14:34:00 -0400, Andrew Kuchling wrote: >Alex writes: >> What's EJB got going for it, anyway? > >Buggered if I know. Perhaps they provide a frictionless method for >transferring a business's money to consultants. Ther's probably some truth in that... :-) -- ## Philip Hunt ## philh at comuno.freeserve.co.uk ## From chrishbarker at home.net Fri Jun 8 14:59:59 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 08 Jun 2001 11:59:59 -0700 Subject: floating point in 2.0 References: Message-ID: <3B2120AF.9306D1E3@home.net> You know, after reading all this (I do find it interesting), I wonder why I have never seen a language include an easy way to get/compare a floating point number in a given precision. One of the first things we all learn is that you should rarely use: if fp1 == fp2 sometimes it is easy to use if fp1 <= fp2, but other times what you really want is: if fp1 == fp2 (in the first 5 decimal digits.) it's fairly easy to do: if fp1 < fps+eps and fp1 > fps-eps But then you need to know the order of magnitude of the numbers, leaving you with: if fp1 < 1.000001*fp2 and fp1 > 0.999999*fp2 which I suppose would work, but you are now doing two multiplies and a compare, and I think it's ugly. Since this is a very common need, I wonder why it isn't build into languages, or even better, built into hardware. What I would like to see are a RoundToNPlaces function, and maybe a CompareToNPlaces function (with better names) Does anyone have any nifty algorithms that they use for this that they would like to share? I'd at least like to put them into my own toolbox. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From donn at u.washington.edu Fri Jun 15 19:55:05 2001 From: donn at u.washington.edu (Donn Cave) Date: 15 Jun 2001 23:55:05 GMT Subject: call-by-reference (was Re: Any other Python flaws?) References: <9gcu9g$gm4$1@newshost.accu.uu.nl> <9gd4tq$odb$1@news.mathworks.com> <9gdn37$61k$3@newshost.accu.uu.nl> <9gdt4j$b86$1@news.mathworks.com> Message-ID: <9ge78p$pn4$1@nntp6.u.washington.edu> Quoth jcm : | Martijn Faassen wrote: |> jcm wrote: |>> In my experience, there's good agreement about what call-by-reference |>> means just about everywhere but in newsgroups. Python supports only |>> call-by-value -- you can't change the value of a variable in your |>> caller's scope (globals aside). | |> Um, I wouldn't say it that way. Python supports changing the value a |> name references just fine: | |> def foo(a): |> a.append(42) | |> l = [1, 2, 3] |> foo(l) | | Note I said you can't change the value of a _variable_ in your | caller's scope. Changing the state of an object isn't the same. Aside from the semantics of whether the state of an object has anything to do with its value, etc., it's questionable whether "you can't change the value of a variable" is the way to identify "call by value". It may be, but then it just illustrates why "call by value" isn't relevant to Python. Call by value in a language like C is a copy operation. Your function receives a copy of the variable. So of course it can change the value of the copy, but the original is unaffected. If you say Python calls by value, then Martijn's example shows that it doesn't make this copy, so there's some confusion. You can say Python calls by value but not the same way that C does, but that begs the question, what good does it do to say call by value, if it doesn't mean something reasonably consistent? If we give up on call by value and decide Python must therefore call by reference, then you can drag out your examples and show how it can't be doing that. Python has "call by the one right way". Donn Cave, donn at u.washington.edu -- call by value C example. struct Z { int a, b; }; int bfol(struct Z z) { z.a = 0; } -- Python (un)equivalent def bfol(z): z.a = 0 From bart.lateur at skynet.be Wed Jun 6 09:20:21 2001 From: bart.lateur at skynet.be (Bart Lateur) Date: Wed, 06 Jun 2001 13:20:21 GMT Subject: GROUP TAKEOVER IN PROGRESS References: <69cl4tk6bitr0oi376ngtjp0m1bs7ucnk4@4ax.com> <902430AC4moondustapexnet@209.99.56.9> <93hn81$l4m$1@nnrp1.deja.com> <9025628F7moondustapexnet@209.99.56.9> <3a5c8520_1@news.foxinternet.com> <902581E21moondustapexnet@209.99.56.9> <3a5ce21b_1@news.foxinternet.com> <4A982771F09.psskvxvn@vluxxijwai.net> Message-ID: Brent K Kohler wrote: >My first royal order to all of you peons is that from this time >foward you will add the following signature to all of your posts! I won't. Nyehnyehnyeh. -- Bart. From DavidL at raqia.com Thu Jun 14 20:18:17 2001 From: DavidL at raqia.com (David Lees) Date: Thu, 14 Jun 2001 20:18:17 -0400 Subject: Simple example of BaseHTTPServer use References: <3B2928F0.A467C8B6@raqia.com> <3b293b80_1@news5.uncensored-news.com> Message-ID: <3B295449.9850C023@raqia.com> Doug, A little light just went on and maybe I get it. If I want to have a 'Content-length: 572' in the header, do I need to issue a 'send_header('Content-length: 572') ? Assuming that is correct, then I am responsible for computing the content length. There is only one thing I still don't get. When I send stuff back to the client using wfile.write('foo') when do things get sent? As soon as I issue the command or do I need to do a flush or close or something like that? Thanks, david lees Doug Fort wrote: > > David Lees wrote: > > > I would like to use the BaseHTTPServer class to handle a PUT and send > > back some http. I am sending the headers back correctly I think, but no > > data appears to be going back. I am probably using the wfile instance > > variable incorrectly. Here is sample code I am working on. > > > > def do_PUT(self): > > self.send_response(200,'\n') > > self.send_header("Content-type", "text/html") > > self.wfile.write('junker goes\nout here\n') > > self.end_headers() > > > > > > > > Thanks in advance. > > > > David Lees > > > I believe you need to call end_headers() before attempting to send any > data. end_headers() writes a blank line which is followed by the data. I > recommend Frederik Lundh's book "Python Standard Library" from O'Reilly, it > has good clear examples and list lists at US$29.95 unlike the bloated $50 > books that line the shelves. > > -- > Doug Fort > Senior Meat Manager > Downright Software LLC > http://www.downright.com > > ______________________________________________________________________ > Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com > With Seven Servers In California And Texas - The Worlds Uncensored News Source > From djc at object-craft.com.au Tue Jun 26 06:36:16 2001 From: djc at object-craft.com.au (Dave Cole) Date: 26 Jun 2001 20:36:16 +1000 Subject: Sybase module 0.27 released Message-ID: What is it: The Sybase module provides a Python interface to the Sybase relational database system. The Sybase package supports almost all of the Python Database API, version 2.0 with extensions. The module works with Python versions 1.5.2 and later and Sybase versions 11.0.3 and later. It is based on the Sybase Client Library (ct_* API), and the Bulk-Library Client (blk_* API) interfaces. The 0.20 and later releases are a re-implementation of the module using a thin C wrapper on the Sybase-CT API, and a Python module to provide the DB-API functionality. It is still a work in progress, but should be good enough for most purposes. Changes for this release: - Sybase.py module no longer imports exceptions module. - Optional auto_commit argument has been added to Sybase.connect(). The default value is 0. - Optional delay_connect argument has been added to Sybase.connect(). The default value is 0. This allows you to manipulate the Sybase connection before connecting to the server. >>> import Sybase >>> db = Sybase.connect(server, user, passwd, delay_connect = 1) >>> db.set_property(Sybase.CS_HOSTNAME, 'secret') >>> db.connect() - Removed redundant argument from sybasect.ct_data_info() - Added pickle capability to NumericType - I somehow forgot to copy this over from the old 0.13 module. - Re-arranged sybasect.h to make it easier to follow - I hope. - Documentation updates. - Dave -- http://www.object-craft.com.au From maxm at normik.dk Fri Jun 1 05:20:02 2001 From: maxm at normik.dk (=?iso-8859-1?Q?Max_M=F8ller_Rasmussen?=) Date: Fri, 1 Jun 2001 11:20:02 +0200 Subject: Trouble with Python in ASP development Message-ID: <7BD10B680501D411B9DF009027E06F32197D2D@exchange> > From: Thomas Weholt [mailto:thomas at cintra.no] > Is there any way to get more info from ISS or find out what > goes wrong? > Passing the same parameters to a Kunde-object in the python > interpreter > works just fine. In ASP it just won't work. I would put some debug code into the Kunde object and see what happens in there. Or better yet, write some unittest to the kunde object. Then print the errormessages to a file. btw. a small optimisation of your code. Sorry couldn't help it. def getParams(params): "Helper function" paramDict = {} for param in params: paramDict[param] = str(Request(param)) return paramDict k = Kunde(**getParams(['firmanavn', 'adresse', 'postadresse'])) Hav en god dag Max M From tim.one at home.com Mon Jun 25 03:42:13 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 25 Jun 2001 03:42:13 -0400 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) In-Reply-To: <3B36DE62.7DDD28E0@cosc.canterbury.ac.nz> Message-ID: [Barry A. Warsaw] > But once there's a serious move to include the code into CVS in a > non-experimental way (as I gather is the case with the generators > feature), I really think it the discussions have to be moved to > python-dev at the very least. [Greg Ewing] > Not only that, but a decent amount of time needs to be > allowed for discussion by people who haven't been following > all the in-camera proceedings before Guido makes a Pronouncement. > Two days is not enough! Two days between what and what? The PEP was posted widely on the 14th (to all of c.l.py, c.l.py.a, the Iterators list, and Python-Dev); the Pronouncement was on the 21st; Python generators have been discussed off and on for 10 years; and all the arguments I ever saw had already been made on the Iterators list before the PEP was first posted. For that matter, they were old in the early 90's already, at least to Guido. "Two days" doesn't match any of that, although I won't exaggerate to "two decades" in return . We may be wonderful Python People, but this is still Usenet dynamics: virtually all interesting points are brought out very quickly, and then there's an eternity of repetition. Luckily, since we *are* wonderful Python People, we get to skip the flame-war part of it. From James_Althoff at i2.com Mon Jun 18 15:21:53 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Mon, 18 Jun 2001 12:21:53 -0700 Subject: why is there no class (static) methods in Python ? Message-ID: In response to Richard Gruet's inquiry concerning the lack of class methods in Python, Michael Lunnay wrote: >why do you need it as part of the class, if it is related to the class just >have it in the same module so you can do: > >import foo > >x = foo.foo() >print foo.staticfunction() > >Michael In discussions of class methods in Python (or the lack thereof) the question of "What's wrong with just using a module function instead?" inevitably comes up. Often, a module method works just fine. However, it is NOT the case that module functions are equivalent to (true) class methods (a la Smalltalk). A module function -- acting as a "poor man's substitute" for a class method -- has the same limitation that a function has vis a vis an instance method. Namely, it does not provide support for a "virtual" mechanism/framework. As an example, suppose we have yourModule.yourFunction1 -- acting as a class method substitute for the class yourModule.YourClass. And suppose the implementation of yourModule.yourFunction1 makes a call to yourModule.yourFunction2. Now suppose I create myModule.MyClass. MyModule.MyClass is a subclass of yourModule.YourClass so I can reuse all of the instance methods defined for yourModule.YourClass (and its superclasses). I can override and change any instance methods I inherit from yourModule.yourClass and I can add any more that I need. This is great; I reuse instead of reinventing! Now suppose I want to reuse the (pseudo) class methods for yourModule.YourClass. In particular I notice that yourModule.yourFunction1 is exactly what I want, but I need to override yourModule.yourFunction2 in order to adapt it for myModule.MyClass. How can I do this (preferably WITHOUT resorting to "black magic" and whilst preserving "thread-safeness")? I am stuck -- because module functions are NOT methods (in the sense that they are not associated with an instance) and hence do not participate in a "method lookup/override" mechanism. So if I define my own myModule.yourFunction2, it doesn't help. And I can't reuse yourModule.yourFunction1. I have to reimplement the exact same code. This is not nice. So true class methods -- methods invoked on class objects with inheritance and override (a la Smalltalk) -- are good -- and far better than module functions acting as a poor man's substitute therein -- mainly if you consider code extensibility and reuse a good thing. Jim From pfenn at mmm.com Thu Jun 14 09:17:48 2001 From: pfenn at mmm.com (pfenn at mmm.com) Date: Thu, 14 Jun 2001 08:17:48 -0500 Subject: humans and logic Message-ID: Decimal vs hex vs octal vs binary? It's just different representations of the same number. This obsession with form over substance is not logical. Anyway, computers don't deal with 1's and 0's. They deal with high and low voltages. Rather than reform the elementary school curriculum by switching to binary arithmetic, I'd rather introduce electrical engineering. Analog electrical engineering, because all those stray capacitances matter when your chips run at 1 GHz. somebody-will-probably-take-this-post-seriously-ly, Tom From andym at ActiveState.com Thu Jun 21 23:47:50 2001 From: andym at ActiveState.com (Andy McKay) Date: Thu, 21 Jun 2001 20:47:50 -0700 Subject: Stop/Start Service in Win2k Message-ID: <006801c0face$1f6084c0$abcc4e18@cr582427a> > A patch to win32serviceutil that tries to locate the short name given > the long name would be gratefully accepted :) Here you go. -- Andy -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: GetShortName.py URL: From Pieter_Claerhout at CreoScitex.com Tue Jun 26 07:43:10 2001 From: Pieter_Claerhout at CreoScitex.com (Pieter Claerhout) Date: Tue, 26 Jun 2001 13:43:10 +0200 Subject: Sybase module 0.27 released Message-ID: <2B1262E83448D211AE4B00A0C9D61B0301DDDFBA@msgeuro1.ste.scitex.com> Does anyone know if this will work for MS SQL Server as well? It's a rip-off of Sybase anyway, as far as I remember. Pieter -----Original Message----- From: Dave Cole [mailto:djc at object-craft.com.au] Sent: Tuesday, June 26, 2001 12:36 PM To: python-list at python.org Subject: Sybase module 0.27 released What is it: The Sybase module provides a Python interface to the Sybase relational database system. The Sybase package supports almost all of the Python Database API, version 2.0 with extensions. The module works with Python versions 1.5.2 and later and Sybase versions 11.0.3 and later. It is based on the Sybase Client Library (ct_* API), and the Bulk-Library Client (blk_* API) interfaces. The 0.20 and later releases are a re-implementation of the module using a thin C wrapper on the Sybase-CT API, and a Python module to provide the DB-API functionality. It is still a work in progress, but should be good enough for most purposes. Changes for this release: - Sybase.py module no longer imports exceptions module. - Optional auto_commit argument has been added to Sybase.connect(). The default value is 0. - Optional delay_connect argument has been added to Sybase.connect(). The default value is 0. This allows you to manipulate the Sybase connection before connecting to the server. >>> import Sybase >>> db = Sybase.connect(server, user, passwd, delay_connect = 1) >>> db.set_property(Sybase.CS_HOSTNAME, 'secret') >>> db.connect() - Removed redundant argument from sybasect.ct_data_info() - Added pickle capability to NumericType - I somehow forgot to copy this over from the old 0.13 module. - Re-arranged sybasect.h to make it easier to follow - I hope. - Documentation updates. - Dave -- http://www.object-craft.com.au -- http://mail.python.org/mailman/listinfo/python-list From guido at python.org Thu Jun 21 09:13:39 2001 From: guido at python.org (Guido van Rossum) Date: Thu, 21 Jun 2001 13:13:39 GMT Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) References: <200106201855.OAA21119@panix3.panix.com> <15153.15434.385992.754443@beluga.mojam.com> Message-ID: barry at digicool.com (Barry A. Warsaw) writes: > In general I think that it's fine to continue to discuss PEPs on > alternative forums until they are pretty well fleshed out. But once > there's a serious move to include the code into CVS in a > non-experimental way (as I gather is the case with the generators > feature), I really think it the discussions have to be moved to > python-dev at the very least. > > Unless there's heated objections, I'll update the PEP 1 procedures to > describe this workflow. > > -Barry Sounds about right to me. --Guido van Rossum (home page: http://www.python.org/~guido/) From junkster at rochester.rr.com Mon Jun 11 19:33:44 2001 From: junkster at rochester.rr.com (Benjamin Schollnick) Date: Mon, 11 Jun 2001 23:33:44 GMT Subject: XML Problem/Confusion? Message-ID: I'm attempting to finish a pseudo webdav interface class... The only problem is that the XML results I'm receiving aren't being handled correctly.... This test application seems to be ignoring several of the entries from the captured stream. The XML looks AOK to me, but I haven't written XML before, and I'm not sure if I'm reading this correctly. Could anyone chime up, and point out any errors that I may have caused? - Benjamin ------------------------ Cut here test_data = """ http://xww.psg-techservices.world.xerox.com/docushare/Collection-22 TSA - Material in Transit TSA - Material in Transit (Temporary Files) Benjamin Schollnick admin HTTP/1.1 200 OK""" #from xml.dom.minidom import parse, parseString #dom = parseString (test_data) #print dom.getElementsByTagName ("parents") #print dom.getElementsByTagName ("handle") import xml.parsers.expat def start_element(name, attrs): print "Start :",name, "\t\tattrs: ",attrs def end_element(name): print "End :",name pass def char_data (data): print "Character : ", repr(data) pass parser = xml.parsers.expat.ParserCreate() parser.EndElementHandler = end_element parser.StartElementHandler = start_element print "XML.Parsers.Expat \n------------------------------------------" parser.Parse (test_data) #print "xml.sax \n------------------------------------------" #import xml.sax #dparser2 = xml.sax.make_parser() #print xml.sax.parseString(test_data, dparser2) From emile at fenx.com Fri Jun 1 12:42:23 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 1 Jun 2001 09:42:23 -0700 Subject: screenscraping References: <991411356.20275.0.nnrp-10.c1c3e154@news.demon.co.uk> Message-ID: <9f8gsm$2srlq$1@ID-11957.news.dfncis.de> I've almost completed a project that does this. I needed to control a non-standard windows app, parts of which were only accessible through mouse-clicks. I'm using Macro Scheduler http://www.mjtnet.com/index.mv?msched6.html which allows me to create macros using python that can be fed to Macro Scheduler. HTH, -- Emile van Sebille emile at fenx.com --------- "Paul Brian" wrote in message news:991411356.20275.0.nnrp-10.c1c3e154 at news.demon.co.uk... > all, > > I may be scraping the bottom of the barrel as well a screen, but I would > like to know if it is possible to (using python) activate a windows > application that takes input from a GUI, and enter in data through the GUI > programmatically. > For example, bring up the address page, "tab" over to Surname and enter in > "foo" > I am prevented from using any kind of API or direct interface to real work. > > Thank you > > > P Brian > > From ark at research.att.com Mon Jun 11 13:37:43 2001 From: ark at research.att.com (Andrew Koenig) Date: Mon, 11 Jun 2001 17:37:43 GMT Subject: Python and SML References: Message-ID: Daniel> I am new to Python and was struck by the similarity to Daniel> a language I learned in a programming languages course, Daniel> SML/NJ. It, like Python, is an interpreted language... SML/NJ interpreted? How's that again? -- Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark From tim.one at home.com Fri Jun 15 16:26:07 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 15 Jun 2001 16:26:07 -0400 Subject: idle BUG In-Reply-To: Message-ID: http://sf.net/tracker/?group_id=5470&atid=105470&func=detail&aid=216289 [John Roth] > Pythonw is OK for the shipping version of an app, but I need the console > window while I'm debugging. If the problem is strictly associated with > the close button in the upper right corner, ... It is not. As the referenced bug report says, I provoked the same problems closing IDLE via Ctrl+Q. It doesn't appear to matter how IDLE is told to shut down. From jtorborg at fnal.gov Wed Jun 6 16:28:33 2001 From: jtorborg at fnal.gov (Julie Torborg) Date: Wed, 06 Jun 2001 15:28:33 -0500 Subject: Generating Multiple Class Instances Message-ID: <3B1E9271.B05CC4E3@fnal.gov> I'm no wiz at OOP, but I have the following problem: I have a list of some hundreds of items, each of which has several attributes,What I want to do is peg each of the values to the list item and move it around my program. This seems like the perfect opportunity to take advantage of the OOP aspect of Python by setting up a class, but I can't create or use instances without hard-wiring it for every list item. What I want to do is: class Quark: def __init__(self): self.color=getcolor() self.mass=getmass() flavor=['up', 'down', 'strange', 'charm', 'top', 'bottom'] for each in flavor: each=Quark() ###Then later: for each in flavor: print each.color ###What I'm relegated to doing is: up=Quark() down=Quark() strange=Quark()... print up.color print down.color print strange.color... Which works, but with hundreds of list items, gets messy in a hurry. I've also tried messing around with using something that looks more like quark=Quark() several times, but then all the info stored in the previous instance gets obliterated. I've also tried using lists and dictionaries, but they're bulky and what's the point of using an OOP language if there's no additional functionality or elegance? From chrishbarker at home.net Thu Jun 21 15:16:31 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 21 Jun 2001 12:16:31 -0700 Subject: JSP vs Python any takers References: <5agY6.517092$166.10724721@news1.rdc1.bc.home.com> Message-ID: <3B32480F.A8646CBF@home.net> "Nils O. Sel?sdal" wrote: > > 2) On a linux apache box is there a python add-in that allows phython > script > > to be used to create > > dynamic pages like you can when you use python script on an M$ IIS > web > > server > ok... > You dont need the embedded python module/interpreter to to that, you > can use CGI. There is also mod-snake for Apache, to give you better performance. http://modsnake.sourceforge.net/ > > why would I use python over JSP Because Python is a wonderful language, and a joy to work with! -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From senux at senux.com.NOSPAM Sat Jun 30 13:34:37 2001 From: senux at senux.com.NOSPAM (Brian Lee) Date: Sun, 01 Jul 2001 02:34:37 +0900 Subject: How to create Python executable References: <3b3d73cd.48834029@news-server.bigpond.net.au> Message-ID: <3B3E0DAD.2080800@senux.com.NOSPAM> Try py2exe and freeze. py2exe homepage is http://py2exe.sourceforge.net/ and freeze is in Python source tarball. I've ever test to build exe file from a Python source with wxPython and some other my own modules and it works pretty well. Visit their homepage for more. - Brian,. sorular wrote: > A simple question I should've learnt long ago! > > How to make an executable from a python program? > > The code is made up from several python scripts and files in a > directory. It requires ActiveState to run but I want to run it on any > machine as an executable (*.exe) that don't necessarily have python. > > thanks > > ~sor From sholden at holdenweb.com Mon Jun 18 09:19:05 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 18 Jun 2001 09:19:05 -0400 Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? References: <3B2B60AD.942719AE@earthlink.net> <9gkdbb022u4@enews2.newsguy.com> Message-ID: Oh. You mean ".NET" isn't Microsoft marketing-speak for "Not Yet"? tongue-in-cheek-ly y'rs - steve -- http://www.holdenweb.com/ "Alex Martelli" wrote in message news:9gkdbb022u4 at enews2.newsguy.com... > "Paul Prescod" wrote in message > news:mailman.992841807.926.python-list at python.org... > [mostly snipped excellent explanation] > > Visual Python is an IDE plug-in for Visual Studio.NET. Visual Studio.NET > > is an IDE from Microsoft that has the four letters .NET at the end to > > convince you that it is sufficiently different from Visual Studio 7 that > > I think you mean 6 where you wrote 7 here...? > > > you should buy it. You can develop .NET applications with Visual Studio > > .NET but you can also develop old fashioned Windows applications or raw > > I find it incredible that MS mktg doesn't understand the deep (and > justified on the burned-once principle) *CONSERVATISM* of many, many > development organizations. Those "four letters at the end", as you > so well put it, ARE convincing many that the IDE "is sufficiently > different from VS6" that they *WON'T* buy it -- or, at least, not yet. > > If they've made the strategic decision not to develop for the .NET > platform YET (quite a reasonable one for many development orgs at > this point -- experimentation is one thing, but production SW on > which big money depends needs to proceed very cautiously), and the > 'brilliant' folks at MS mktg manage to convince them that VS.NET > *IS* about .NET, then it follows that development will remain on > good old VS6 -- period. *sigh*. What a mktg *GOOF*...!-( > > > Alex > > > From bos at hack.org Wed Jun 13 20:01:14 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Thu, 14 Jun 2001 02:01:14 +0200 Subject: IP address to binary conversion References: <3B27FE3A.D7F9879E@hack.org> Message-ID: <3B27FECA.FD9A7A74@hack.org> Here's a solution for the reverse: >>> socket.inet_ntoa(struct.pack("!I", long(1074015239))) '64.4.44.7' -- Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From dgoodger at bigfoot.com Wed Jun 13 22:57:25 2001 From: dgoodger at bigfoot.com (David Goodger) Date: Wed, 13 Jun 2001 22:57:25 -0400 Subject: PEP 257: Docstring Conventions In-Reply-To: Message-ID: on 2001-06-13 2:17 AM, Roman Suzi (rnd at onego.ru) wrote: > 1. Are the existing docstrings in Python standard modules > example of good docstrings according to this PEP? Some are, some aren't. Not everybody has read Guido's Python Style Guide (the source of 98% of the PEP), and not everybody who *has* read it applies it. Part of the motivation for making this into PEP was to standardize docstrings so that tools can extract useful information. > Does it mean that docstring must describe interface, not > implementation? Yes. Implementations frequently change. > That is, docstring has nothing to do with internals of the > function? Typically, yes. Docstrings are how a module/class/method/function advertises its services to the Python world. "This is how to call me, this is what I'll do for you, this is what I'll give back." -- David Goodger dgoodger at bigfoot.com Open-source projects: - Python Docstring Processing System: http://docstring.sf.net - reStructuredText: http://structuredtext.sf.net - The Go Tools Project: http://gotools.sf.net From tim.one at home.com Tue Jun 12 03:17:44 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 12 Jun 2001 03:17:44 -0400 Subject: Future floating point directions? [was Re: floating point in 2.0] In-Reply-To: <9g181j$pao$1@agate.berkeley.edu> Message-ID: [Tim] >> Python has no 754 story -- it doesn't try. [Edward Jason Riedy] > Which is really astonishing for a language aiming at ease of use > and teaching. Astonishing? Don't know about that. ABC (Python's closest predecessor) and DrScheme are definitely in the teaching biz, and they take e.g. 6.02e23 as meaning exact rational (301/(5*10L**24)). That's more astonishing to me, but it's a position reached by more than one serious newbie-friendly language project. > Yes, I know, it's someone else's fault. Not really. Who would that be? Trying to tease precise x-platform sense out of 754 HW given the current state of C environments is a major project, unless we give up on using C's facilities and do it all in software instead. Which is why I expect Python will sooner grow an 854 story, indeed doing decimal fp entirely in software. > (Not that I've been jumping up and down with code. sigh... C++ sucks > my will to code, but I don't know any more flexible language that > compiles on both a T3E and an SP.) Python is written in straight C (of the C89 flavor; BTW, it wasn't until about a year ago that Python finally required an ANSI C compiler; new stds are adopted slowly, which is why you shouldn't be so timid about requiring what you really want in the end -- c.f. 754 punting on correct decimal<->binary rounding for fear of rocking a boat that sank anyway a few years later). >> [on whether C99 is likely to be implemented in full] > I can think of three companies with test vectors being developed, > so I assume there's something to test. Of course, all three also > sell hardware with these features. gcc's coming along, but with > much more finely stretched resources. gcc is important, but before Python can rely on a thing literally dozens of compilers have to support it, and correctly. OTOH, the more Platforms from Mars Python lands on, the more I'm inclined to say "oh, screw it -- if we can bash it into shape under gcc and WinTel, that's 90% of the benefit". Guido doesn't listen to me, though . >> [RS 6000 fused mul-add] > Nope. They happened to have a chunk of space left, someone > suggested fma for correctly rounding an iterative division, and > an engineer did it over a weekend, fitting it into the add, mul, > and extra space. Can't remember his name, but I can dig through > my notebook if necessary. Story from Dr. Kahan, who was there. > Go fig. > ... > > Actually, it was for getting a division without a divider. But > your point's mostly valid. The primary push was on getting some > extra speed (software-ish, thus pipelined, divide), This is a spicier story than I read in the IBM Journal at the time (thanks!), but can't say it's fundamentally different: they wanted faster division and didn't have the real estate for a monster divider. That's just pragmatic. I expect they got at least as much market benefit from the math library improvements as from pipelining division, too. > but the group also wanted to compete on reliability features. Thus > the extra breakdown of the invalid flag. > > Most of the features we want to add will address reliability / > debugability in some way. Things like trapping methods that > don't require precise interrupts, etc. All Good Things! [about "goodness of their hearts" motivations] > Yes, but he's not the only one at Sun. They're mostly ex-students > of Dr. Kahan's, though. > > And I could have drawn an example from HP, and that wouldn't be > because of a Kahan student. Surprising, but true. ;) It happens. Had KSR survived, you could have picked me as an example too -- they spent several hundred thousand dollars grafting better 754 support into the hardware at my obnoxious urging (not to mention sweat, blood and ultimately tears), but all it bought them in the end was financial disgrace and bankruptcy. That's 754's fault, because if we had rotten addition they could have blamed the accounting discrepancies on the hardware . [on directed roudning modes] >> Virtually all HW FPUs support them, and because they're required. > And because rounding modes are nigh impossible to implement in > software. The paying market for these modes isn't worth the bother. What saved them is that they're (a) easy to implement in HW, and (b) required. Either one makes a decent case, but the combination is compelling. Worrying about how hard it would be to do in SW instead is a legitimate concern for a stds committee, but cuts no ice with the people who pay for chip design -- not unless legions of customers, or key internal developers, insist they need it. If they insist they need it and it turns out they don't use it, they don't get to play that game again. > I do wish software had access to the three extra bits necessary to > round correctly. So mandate them <0.7 wink>. >> Without that C99 wouldn't have even considered it (part of X3J11's >> mandate is not to require things that can't be done w/ reasonable >> efficiency, so w/o near-universal HW support already in place, they >> would have punted on this too). > Um, fma is required in C99. I'm glad of that, too, but it's unique among C99 features in being bundled with inquiry macros that say whether or not the implementation "is fast". So they didn't ignore efficiency there, and the existence of the macros is (unfortunately) a red flag that will scare non-experts away. > It certainly lacks near-universal hardware support... And portability > pressures have a way of making optional features required. Look at > how many vendors have Linux syscall translation layers. The scientific market-- unlike the Linux market --is a shrinking piece of the overall pie, though. I'd say binary fp is perceived by the bulk of the market as a necessary evil for now, but I'm not sure that will last either. >> Tossing "recommended" out the window is the best tool a std has. > Considering the groups being targetted have completely ignored > REQUIRED pieces, I don't know if it matters. Which modern chips do you have in mind that punt on required 754 pieces? I know you view 754 as "a systems standard", but most of the world doesn't: if the bulk of it isn't in HW, most language committees aren't going to agree to fill the gaps. The long struggle with C alone should be evidence enough of that. >> You said you're introducing a quad format, and I assume that's >> "the usual" 15-bit exponent + 113-bit mantissa one, so stop at >> required correct rounding to and from no more than 36 decimal >> digits, and everyone will be happy (this can be done with code >> much simpler than Gay's, and also without bigint arithmetic). > Well, if the only defined destinations are single, double, and > quad, then you only have to support conversions to those > destinations. The standard only defines things in the standard. I could repeat that paragraph (and did ), but don't know how to make it clearer. Correct rounding to+from no more than 36 decimal digits can be done economically and with relative ease, and covers formats up through and including the quad format I guessed at there (which is the IEEE-like quad format Sun and KSR both implemented in the early 90's, so I assume it's still in favor). > Binary to decimal is constrained so that binary -> decimal -> binary > produces the same number if both binary numbers are in the same > precision. >> Users want that, but IIRC 754 already requires it. > Not quite. It's required for a smaller range than is now > possible. I believe you're talking about the range over which 754 requires correct rounding. I'm not -- just about binary -> decimal -> binary identity. They're different (albeit related) issues in 754. From section 5.6 (apparently after the point you stopped reading ): When rounding to nearest, conversion from binary to decimal and back to binary shall be the identity as long as the decimal string is carred to the maximum precision specified in Table 2, namely, 9 digits for single and 17 digits for double. There are no weasel words restricting that to the range where correct rounding is required; correct rounding is sufficient for identity (given enough precision in the decimal string), but not necessary. > Ok. Calculate in double precision with single precision inputs > and output. There's not enough precision in a single to enter some programmers' salaries without catastrophic loss of information <0.9 wink>. It's simply too small for general use. > You'll get _much_ more reliable answers. But unfortunately, Python > doesn't make that easy. A calculator with that feature (the HP 12C) > does use extra precision in the calculation. HP should get Major Awards for usable numerics! I'm sure the 12C offered at least 10 decimal digits of displayed precision, though, which is a whale of a lot more practical than 754 single's "7 -- kinda, it's hard to explain". >> Single is a storage-efficiency gimmick for big problems with >> low-precision data. > Nonsense. Not in my world. In 15 years at Cray and KSR, neither company built a box with HW support for any fp format other than 64 bit. There wasn't sufficient interest to justify the development cost, and both businesses lived and died on fp arithmetic. Some specific market segments wanted it, such as weather forecasting and the oil industry; what they had in common was truly massive quantities of low-precision data, for which single sufficed and saved half their tape, disk and in-memory storage costs. Math libraries could be a little cheaper for single too; that's it. > Single precision is for limiting the effects of rounding. Why do I need a distinct storage format for that? I'd rather compute in double extended all the time, and explicitly round back to exactly the # of bits I want when I explicitly want to cut back. > Single precision without double precision is incredibly silly (although > some DSPs seem to survive). Some DSPs get by with 16-bit integer "block fp" -- but they know what they're doing, and are designed with specific algorithms in mind. >> "Number-like types" include things like Dates and Times in Python; >> there is no widest numeric type, and the set of numeric types isn't >> even known at compile-time (users can add new ones on the fly). > At the very worst, you can find the widest common type of all > floating-point numbers in a given statement. Consider a > statement containing arithmetic-looking operations. The > interpreter can evaluate all the methods appearing in the > statement first. Then it can examine the objects involved > and find anything that's a floating-point type. Dates and > times aren't floating-point types. All the floating-point > types can be coersed up once. This does require that the > floating-point types be comparable, but that's reasonable. I look forward to the PEP . Seriously, I don't know how to implement this in Python. You at least need to invent and enforce a new protocol by means of which an object can be queried as to whether or not "it's fp", and if so what its precision and dynamic range is. The only PEP even vaguely related (and it's vaguely at strongest) on the table now is Paul Dubois's for Fortran-like Kinds: http://python.sourceforge.net/peps/pep-0242.html Sounds like you need first to define a few new methods in the std tp_as_number type slot. > Yes, this does change the semantics slightly. Anyone relying > on both the order and results of subexpression evaluation to > pass information silently between objects should be shot, so I > don't think it's a big loss. I'm sure someone will, but until it's fleshed out a real debate won't begin. > It also changes the implementation a great deal, which is why > there are no patches attached. ;) Whew! I was afraid my mail client lost them . > I'm trying to find a sensible extension outside of statement- > level, but it might be hopeless. It may also be more promising. For example, a new kind of block, with fp_context=double_extended: all intermediates in the block use double extended IBM's Standard Decimal Arithmetic Proposal requires user-settable precision (akin to, e.g., x86's "precision control" fpu bits) as part of numeric context, and it's also a puzzle how to work that into Python smoothly. In the Java version it looks like a context argument is explicitly passed to every operation -- brrrrrr. > It certainly can't be perfect, as there is no way to assume that > the types involved are at all related to the types of the inputs, but > there may be a reasonable compromise for 90% of the code. A run- > time type inferencer? Think that could be useful well beyond > floating-point expressions. Ya, people have been saying that for a decade, but I'm afraid I lost their patches too . > (IMHO, static and dynamic typing is simply a matter of time > scale. Everything is statically typed when it is actually > executed (run through the processor) and dynamically typed > during development.) I like that view; it has merit. >> Even restricted to floating types, at least two Python GMP >> wrappers exist now, at least one of which exposes GMP's >> unbounded (but dynamically specified) precision binary fp type. > This should _not_ be mixable with typical floating-point numbers > without the programmer saying it's ok. The semantics are entirely > different. If you want them mixed, you should be promoting > everything they touch to the arbitrary length types. They're not arbitrary-length, they're fixed-length, but of user-settable length (fall back on your own view of static vs dynamic here!). "Entirely different" seems a stretch, as they're as much "as if to infinite precision with one final rounding" as 754 semantics. As to mixing them at all, I'm much less a fan of silent coercions than most, but I usually get out-voted on such things. If you do write a PEP, it's something to argue for there. > Think of the user whose problem is actually in the decimal->binary > conversion. Or a case like z = a + b + c, where a is a gmp type. > Is it [(a + b) :: gmp-type + c] :: gmp-type, or [a + (b + c) :: > Python float] :: gmp-type? Yes, _I_ know it's left-to-right, but > must everyone be a language lawyer? If they want to use a language w/o surprises, yes. Left-to-right is a Sacred Rule in Python, and I don't know of any language other than Icon that makes expression evaluation so easy to predict. > What if a user of a routine had input c as a gmp-type, intending > for the internals to use arbitrary precision? The routine would > have silently used fixed precision intermediates. That depends on the internal implementation of the routine, and the rules you're hypothesizing for your version of Python. Presumably under "widest available", the routine would adjust to the precision of its inputs. > ... > Consider too interval arithmetic. For intervals to be really > useful, even the decimal->binary conversions touching an interval > need to return intervals. Otherwise, you've violated the > properties guaranteeing that the answer lies within the result > interval. Requiring explicit casts to intervals doesn't mesh > well with a dynamically typed language like Python. That makes > the code much less reusable. I don't see a reason "in theory" that intervals couldn't be contagious too. But this is all so far from current Python it's too unreal to get picky about. > Actually, with a widest-feasible evaluation strategy, you _can_ > mix these pretty well. You'll get the most expected results. > I'm still not comfortable with mixing random-length floats with > fixed-length floats, especially when division, square root, and > elementary functions are involved, but intervals and further > fixed-length floats work beautifully. I'm happy to hypothesize arbitrary-precision math libraries too. They're doable (from Macsyma to Emacs calc), and quite handy. > On the flip side, complex really shouldn't be silently mixed > with real at all. Since the way to spell a complex literal in Python does mix them (like 3+4*j: that's an honest-to-god + and * there, not a lexical gimmick), that's a hard rule to adopt . > Imagine a beginner trying Cholesky factorizaion in Python. I can't. I can picture a beginner using a bad algorithm for computing std deviation, though, and then Python does stop them from trying to take the sqrt of their negative real variance (newbies generally don't find about cmath.sqrt for a long time). > It'll seem to run just fine. Any solve with the factors will give > only real numbers from real numbers. But some results are completely, > SILENTLY wrong. Why? The matrix wasn't positive definite. It should > have choked, but entries silently went imaginary. Solves will still > produce real numbers. Is this special case important enough to stop mountains of code that mix real and complex without incident? > Now imagine debugging a program that has a symmetric solve > somewhere. Would you spend much time looking at one of the best- > understood portions? Or would you end up blowing a huge amount > of time checking input, data structure conversions, etc.? Most > programmers would assume it's a ``problem with floating-point > arithmetic.'' > > There are similar problems with many textbook formulas and > complex arithmetic. Perhaps people should know better, but how > often do they? Wouldn't it be better for Python to help them > learn? Guido's view of matrix algebra, and complex numbers, be they in combination or isolation, is that they're not on a newbie's radar. "Don't ask, don't tell." This is something to take up with the NumPy folks. > It somewhat does by separating math and cmath. This one isn't > something that can be handled with a `widest' evaluation scheme; > silently mixing these types in any way can lead to horrible bugs. In the background Guido is reworking Python's type and class model. It should be possible after that's done to subclass from the builtin types. If so, then you should be able to subclass the complex type and override its coercion policies. Any change to Python's core binary fp numerics would likely require near-universal consensus -- and I just don't see that happening. I'm afraid there's no behavior that doesn't have a vocal constituency when threatened, and when the primary users of a thing can't reach agreement the status quo wins by default. life-in-the-same-old-same-old-lane-ly y'rs - tim From mread at cableinet.co.uk Sun Jun 3 18:44:30 2001 From: mread at cableinet.co.uk (Mike Read) Date: Sun, 03 Jun 2001 22:44:30 GMT Subject: Windows editor? References: <3af2c38f.341431824@News.CIS.DFN.DE> Message-ID: "Ken Seehof" wrote in message news:mailman.989002929.16775.python-list at python.org... > dsavitsk wrote: > > wrote in message > > news:3af2c38f.341431824 at News.CIS.DFN.DE... > > > On Fri, 04 May 2001 01:21:48 GMT, "Brandon J. Van Every" > > > wrote: > > > > > > >What's a good Python editor for programming under Windows, specifically > > > >Windows 2000? According to Google archives it seems this question > hasn't > > > >been asked in awhile. > > > > > > > > > > > >-- > > > >Cheers, www.3DProgrammer.com > > > >Brandon Van Every Seattle, WA > > > > > > > > > Best one for Windows is PythonWin. > > > > I thought this was the *only* answer ... > > > > > Sadly, there are no plans to update it. > > > > is this true? i'm not going to get stuck using some sort of Python .Net > crap > > am i? > > > > doug > > There's another alternative: Komodo by ActiveState. It looks promising > although I haven't gotten it to work yet. Komodo is the reason PythonWin > is not likely to continue it's evolution. > > Don't confuse Komodo with the Python.Net stuff that ActiveState is also > doing. Komodo is a separate product. > > - Ken I've played with it a little and its seems quite good - quite good for perl too actually (hush my foul mouth). Regards, Mike From pmartel at ne.mediaone.net Sat Jun 2 20:15:43 2001 From: pmartel at ne.mediaone.net (Phil Martel) Date: Sun, 03 Jun 2001 00:15:43 GMT Subject: Why isn't Python king of the hill? References: Message-ID: Geoffrey Gerrietts wrote in message news:mailman.991438863.26627.python-list at python.org... > Martijn writes: > > So there's fixed-point, decimal floating-point and rational > > arithmetic.. > > And plain-old-confusing floats. :) > > > > They all involve numbers with points in them.. and when you do math > > with them, the answers may be different. That's about the extent > > of my knowledge. > > > Here's a five minute explanation, and maybe I can dig up a link to a quick > tutorial on FP in general. (Ok, maybe it's more like a fifteen-minute > explanation. Somebody stop me!) Someone who knows better ought to correct me > if I'm talking out my butt. > > ===== > Unbounded rationals > ===== > > Unbounded rationals would basically give the language the power to express > any rational number accurately. I confess that I'm not sure how it would go > about doing that exactly. I THINK it would do so by maintaining an internal > representation of the operation that gives rise to an infinitely-repeating > decimal, and use that expression in conjunction with known mathematical > properties to join in expressions with other values. > > This is pretty complicated to do, and, according to several people, has some > real problems when common repeating decimals get into your calculations -- > like .333 for instance. Your performance is highly variable depending on how > hard it is to keep track of the numbers you're using. > I'm not a Python expert, but the general idea is to have a class with two variables, "Numerator" and "Denominator". For unbounded rationals, they should be long integers. Arithmetic operations are done like fractional arithmetic. Using the notation N/D to represent the unbpunded rational with Mumerator = N and Denominator = D, Addition: A/B + C/D = (A * D + B * C)/(B * D) Multiplication: A/B * C/D = (A * C)/(B * D) Division: A/B / C/D = A/B * D/C = (A * D)/(B * C) It is traditional, though not absolutely necessary, to remove any common factors from the Numerator and Denominator, thus: 1/6 + 1/4 = (1 * 4 + 6 * 1 )/(6 * 4 ) = 10/24 which would reduce to 5/12 If you use rational arithmetic, you avoid repeating decimals. 0.333333 is an approximation for 1/3 Best wishes, --Phil Martel > > Thanks, > --G. > > --- > Geoff Gerrietts > Software Engineer, HomeGain.com > 510-655-0800 x4320 > From altis at semi-retired.com Tue Jun 19 22:08:35 2001 From: altis at semi-retired.com (Kevin Altis) Date: Tue, 19 Jun 2001 19:08:35 -0700 Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: <3B2EADB0.9DBC6FC8@earthlink.net> Message-ID: I think it is at least worth discussing in more depth and organizing the various ideas, goals, what people do and don't want, etc. If someone that is already familiar with setting up a project on sourceforge or another space could go ahead and do so that would be great. If that won't give us a mail list or some other form of threaded discussion forum, then we could just create a Yahoo groups list, set up a manilasite, etc. Given what people have said so far I think we have at least two if not three different goals in mind. ka "Ron Stephens" wrote in message news:3B2EADB0.9DBC6FC8 at earthlink.net... > Of course, each person undoubtedly has a different set of concepts in mind > when he thinks of "PythonCard"..still, an intriguing amount of interest in 24 > hours... > From james at daa.com.au Thu Jun 7 22:44:48 2001 From: james at daa.com.au (James Henstridge) Date: Fri, 8 Jun 2001 10:44:48 +0800 (WST) Subject: [pygtk] HTML Widget In-Reply-To: <991967480.4503.0.camel@ZOOstation.cc> Message-ID: On 8 Jun 2001, Rob Brown-Bayliss wrote: > > > Did you get a new version of pygme or recompile the existing copy of pygme > > when upgrading mozilla? The mozilla embedding API is not stable, and > > changes occasionally (the binary API breaks more often than source API). > > Yeah, I tried recompiling. The soucre for pygme (in the gnome cvs) has > not changed since october though. > > The best I can get is a grey window in the component. The output in the > shell suggests it is working, but not displaying... In that case, you might want to try emailing the pygme author about it. > > > > Is ther a binding for gtkhtml? > > > > There is a gtkhtml binding included with gnome-python. It is not built by > > default though. Pass the --enable-gtkhtml switch to configure to build > > it. > > Is there any reason for not building by default? for example stability? It would probably be a good idea build it by default now. gtkhtml used to change incompatibly more often than gnome-python releases, which made building it by default a bit of a problem. It has settled down since then though. James. From phrxy at csv.warwick.ac.uk Fri Jun 8 17:42:02 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Fri, 8 Jun 2001 22:42:02 +0100 Subject: WHY is python slow? In-Reply-To: References: Message-ID: On Thu, 7 Jun 2001, Tim Peters wrote: > [Steven Haryanto] > > Although it is generally accepted that Python is slower than > > Java/Perl/Ruby, a layman like me would be curious to know why > > exactly this is so. > > Me too, although philosophers and historians have been puzzling for > centuries over how it can be that generally accepted beliefs are often > divorced from reality. I guess it's for the same reasons that Python has > significant whitespace just like Fortran's, Lisp is slower than Visual > Basic, C++ adds nothing to C that can't be done just as well with > preprocessor macros, functional languages can't be used for real work, and > that at least one of {Linux, NT} is a great operating system . [...] :) *Are* there any good (as opposed to 'good enough') operating systems in existence? Completely off-topic, I know: just ignore me... John From tim.one at home.com Mon Jun 18 19:31:44 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 18 Jun 2001 19:31:44 -0400 Subject: PEP 255: Simple Generators In-Reply-To: <9glhg7$dlk$1@nntp6.u.washington.edu> Message-ID: [Russell E. Owen] > This sounds like an interesting and really useful proposal. However,a > few details are worrisome to me: You should catch up with the discussion on the Python-Iterators list (as mentioned in the PEP announcement), where these have already been discussed several times. I'll only give brief summaries here. > * A generator looks like a function until you find the "yield" statement > inside. I think this will make the code much harder to read. One keyword > buried anywhere in a function totally changes its behavior. If a > generator acted like a function until it hit "yield", this wouldn't be > so bad, but it sounds as if generators have enough significant > differences (such as restrictions on and a changed meaning for return) > that they are very different beasts. > > I'd much rather see a declaration up front that this is going to be a > generator. E.g. add a new keyword such as "generator". Who would this help? Seriously. There's nothing special about a generator to a caller, except that it returns an object that implements the iterator interface. While the latter is important to know, there are many ways to construct iterators in 2.2 without using generators at all. This is better communicated via documentation (e.g., make the first line of the docstring "Generate ..." instead of "Return ..."). On the other end, someone modifying the generator isn't going to miss that it *is* a generator: all the control flow will focus on feeding intermediate results to yield statements. IOW, you worry too much . > * The unusual use of "return" and the associated restriction of no > expression list. What "return" means in a generator is "raise StopIter", > not return. I personally really dislike using a keyword for multiple > vaguely similar purposes. Look at "static" in C++ for an example of > where this can lead. "return" means "I'm done" in any kind of function, generator or not. You can raise StopIteration instead if you feel you must, but then you're focusing on an implementation detail, and that's not helping anyone. Guido appears to feel quite strongly about this one, so if you want to push it I suggest finding a better analogy than C++'s (over)use of static. I'll note that in Icon, "yield" is spelled "suspend", and "return expression" is allowed, meaning "I'm done, but I have one last useful value to suspend with". It's possible Python may grow that meaning too, but it was thought better to keep it more restrictive at first. From jedi at ccrypt.net Wed Jun 20 14:31:29 2001 From: jedi at ccrypt.net (jedi) Date: Wed, 20 Jun 2001 11:31:29 -0700 (PDT) Subject: raw_input In-Reply-To: <_x5Y6.18111$9r1.1628947@e3500-atl1.usenetserver.com> Message-ID: Should look more like this: >>> name = raw_input("Enter your name:") Enter your name: jedi >>> print name jedi >>> you needed to assign the raw_input to a variable to print it out. another way you could have dones is: >>> print raw_input("Enter your name:") Enter your name:jedi jedi >>> but I'm not sure if looks better. On Wed, 20 Jun 2001, Brendhan Horne wrote: > >>> raw_input ("Enter your name:") > Enter your name:Brendhan > 'Brendhan' > >>> print name > Traceback (innermost last): > File "", line 1, in ? > print name > NameError: There is no variable named 'name' > > Okay What did I do wrong it should have printed my name after the print name > command. > > -- > Thanks, > Brendhan > -----BEGIN GEEK CODE BLOCK----- > Version: 3.1 > GE d- s: a C++ U(++) P(++) L+(++) E- W+ N+ o+ K- w+ > O+ M V? PS+ Y PGP(++) t++ 5++ X- R+++ tv++ b+++ DI++ > D G(++) e+(++) h-- r++ y++* > ------END GEEK CODE BLOCK------ > > > > -- > http://mail.python.org/mailman/listinfo/python-list > From scarblac at pino.selwerd.nl Fri Jun 22 05:14:07 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 22 Jun 2001 09:14:07 GMT Subject: namespace issue? References: <87k825ljrz.fsf@elbereth.ccraig.org> <3B32707A.F03344D5@pfortin.com> Message-ID: Pierre Fortin wrote in comp.lang.python: > Michael Powe wrote: > > So now the question is, 'why'? Am I misusing the string.find() > > function? Okay, string.find() returns -1 when the string is not found, > > which would seem to be what I expected, a false result. Maybe python > > doesn't treat -1 as false? Well, I'll try being explicit and testing > > for -1 return. I probably have just confused myself hopelessly. > > Sometimes -1 is used for failure; BUT -1 is NOT false... in those cases, you > can simply add 1 to the return to force a failure to return 0 (false)... Eek, how unobvious. I like if s.find("bla") != -1: a lot better than if s.find("bla")+1: The second one takes two steps to understand, in my mind. -- Remco Gerlich From tflagg2001 at yahoo.com Tue Jun 26 16:54:05 2001 From: tflagg2001 at yahoo.com (tflagg2001 at yahoo.com) Date: 26 Jun 2001 13:54:05 -0700 Subject: Building python 2.1 on Solaris 7 with gcc Message-ID: I'm having the same problem a number of people had which seem to relate to the -shared/-fPIC/-G flags. I'm trying to build the Python-2.1 version on Solaris 7 on SPARC with gcc 2.95.3. Everything is fine until: PYTHONPATH= ./python ./setup.py build running build running build_ext building 'struct' extension creating build creating build/temp.solaris-2.7-sun4m-2.1 gcc -I. -I/export/Python-2.1/./Include -I/usr/local/include -IInclude/ -c /export/Python-2.1/Modules/structmodule.c -o build/temp.solaris-2.7-sun4m-2.1/structmodule.o creating build/lib.solaris-2.7-sun4m-2.1 gcc -shared build/temp.solaris-2.7-sun4m-2.1/structmodule.o -L/usr/local/lib -o build/lib.solaris-2.7-sun4m-2.1/struct.so Text relocation remains referenced against symbol offset in file 0x2098 build/temp.solaris-2.7-sun4m-2.1/structmodule.o ... 0x20ac build/temp.solaris-2.7-sun4m-2.1/structmodule.o ld: fatal: relocations remain against allocatable but non-writable sections collect2: ld returned 1 exit status WARNING: building of extension "struct" failed: command 'gcc' failed with exit status 1 building 'regex' extension .... [same errors for regex, and lots of others from here on...] The configure.in file DOES have this: 633 if test -z "$CCSHARED" 634 then 635 case $ac_sys_system/$ac_sys_release in 636 SunOS*) if test "$GCC" = yes; 637 then CCSHARED="-fPIC"; 638 fi;; However, the "-fPIC" doesn't seem to propagate up to the "gcc" command. I've tried various other things, including adding -fPIC into the python distutils, or adding '-G', with various other problems... This has happened on 2 different SPARC Solaris 7 systems. Any help would be appreciated! Tim From loewis at informatik.hu-berlin.de Sat Jun 16 13:54:43 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 16 Jun 2001 19:54:43 +0200 Subject: Python equivalent of CPAN Library modules References: Message-ID: davehurt at flash.net (David Hurt) writes: > I would appreciate any feedback on the practicality/usefulness/etc. of this > effort. I think it will be a huge effort, and it might be that the outcome is not all that useful, e.g. you might find that the most often requested CPAN modules have already good Python equivalents. I'm not sure what you'd do when the Python module offers the same functionality, but with a totally different API. That said, if you volunteer to do the work, I'm sure many people would be interested to see what the result is. Regards, Martin From syver at NOSPAMcyberwatcher.com Thu Jun 21 20:47:54 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Fri, 22 Jun 2001 02:47:54 +0200 Subject: NT Service and COM References: Message-ID: <9gu4nf$553$1@troll.powertech.no> "Andr?" wrote in message news:fed2e489.0106211103.3c894ab3 at posting.google.com... > Hi. I found this example in Python Programming on Win32, page 349. > I have not tested it. Am typing in a hurry, beware of tpyos: Yes, but that ain't doesn't expose no COM server. If you ever find out Duncan I'd be really pleased to hear what you've figured out. I've only come so far as to look at the .py file that implements local servers for python. Take a look at win32com.server.localserver.py to see how vanilla pythoncom objects are exposed like a localserver. From cliechti at nospam.mails.ch Thu Jun 28 19:47:55 2001 From: cliechti at nospam.mails.ch (chris liechti) Date: 29 Jun 2001 01:47:55 +0200 Subject: WIN32: How to control another windows application (AppActivate not found) References: <3B3B45C3.59825716@gdp-group.com> <9hfimv050c@enews1.newsguy.com> Message-ID: ---snip-- > It's a very fragile approach (you're *WAY* better off using the > Automation interface of the other application -- just about every > application on Windows exposes some object model via Automation), > but if you have some legacy app and absolutely must control it > that way, see for example: > > http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/65107 --- i am interested in this too and i tried the recipe from the url above, but... the calculator shows up and then i get the folowing error: --- Traceback (most recent call last): File "sendkeys.py", line 6, in ? shell.AppActivate("Calculator") File "d:\python21\win32com\client\dynamic.py", line 437, in __getattr__ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: WScript.Shell.AppActivate --- there is no 'AppActivate' nor a 'SendKeys' method available! i'am using ActivePython 2.1 build 210 on Win98 any ideas what this could be? --- shortened piece of source - look at the link above for the full one!: import win32api import win32com.client shell = win32com.client.Dispatch("WScript.Shell") shell.Run("calc") shell.AppActivate("Calculator") shell.SendKeys("1{+}") --- TIA chris -- import re email = 'cliechti at nospam.mails.ch' print re.sub('nospam\.','',email) From mcherm at destiny.com Fri Jun 15 14:36:21 2001 From: mcherm at destiny.com (Michael Chermside) Date: Fri, 15 Jun 2001 13:36:21 -0500 Subject: str smarter than round? Message-ID: <3B2A55A5.A2BF0D8C@destiny.com> Attention Tim: I looked over the new appendix and have one tiny edit to suggest. Original paragraph: Note that this is in the very nature of binary floating-point: this is not a bug in Python, it is not a bug in your code either, and you'll see the same kind of thing in all languages that support your hardware's floating-point arithmetic. My proposed modification: Note that this is in the very nature of binary floating-point: this is not a bug in Python, it is not a bug in your code either, and you'll see the same kind of thing in all languages that support your hardware's floating-point arithmetic, although some languages may not display the difference. Reason for proposed modification: Nieve readers are likely to read this and say, "hey... I've worked with , before and never saw 0.1 == 0.10000000000000001. This manual obviously doesn't know about ." It is useful to explain that the difference between Python and is not that Python can only approximate floating point numbers, but that Python is HONEST about it. Possible alternative wording: ...languages that support your hardware's floating-point arithmetic. Unlike Python, some languages round the value off before displaying it, but the actual value is still a binary approximation. I prefer the first wording, but pick your favorite and go with it. And I have to say, this is a very good job of addressing a perennial point of confusion. -- Michael Chermside From phd at phd.fep.ru Mon Jun 25 11:49:01 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Mon, 25 Jun 2001 19:49:01 +0400 (MSD) Subject: DistUtils and optimized compile In-Reply-To: <3B375869.E417C833@stroeder.com> Message-ID: On Mon, 25 Jun 2001, Michael [iso-8859-1] Str?der wrote: > I'd like to use DistUtils for a pure Python module package. > Everything seems to be ok so far but when doing python setup.py > install only the .pyc byte-code is compiled and installed. I'm > missing the .pyo files with the optimized compiled byte-code. python -O /usr/local/lib/python2.1/compileall.py /usr/local/lib/python2.1/site-packages Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From stevencooper at isomedia.com Fri Jun 29 18:17:26 2001 From: stevencooper at isomedia.com (stevencooper at isomedia.com) Date: Fri, 29 Jun 2001 15:17:26 -0700 Subject: Augmented Assignement (was: Re: PEP scepticism) In-Reply-To: ; from philh@comuno.freeserve.co.uk on Fri, Jun 29, 2001 at 07:22:19PM +0100 References: <6qn16r7i69.fsf@abnoba.intevation.de> <9hhu6701d5j@enews2.newsguy.com> <6qae2r71hd.fsf@abnoba.intevation.de> Message-ID: <20010629151726.A2076@isomedia.com> On Fri, Jun 29, 2001 at 07:22:19PM +0100, phil hunt wrote: > On Fri, 29 Jun 2001 16:13:29 GMT, Guido van Rossum wrote: > >Bernhard Herzog writes: > > > >> Augmented assignment doesn't actually offer anything that couldn't have > >> been done with explicit method calls, at least as far as in-place > >> modification is concerned, because under the covers it actually is a > >> method call. Explicit is better than implicit. > > > >Sorry, I don't understand why people can seriously argue *against* > >augmented assignment. It just baffles me. What kind of Spartan > >upbringing did you have? Scheme? Really, I just don't get it. This > >was by far the most asked-for feature ever! And that quote "explicit > >is better than implicit" quote is pretty tired by now. It can be used > >against a whole lot of Python features. > > Indeed, the reductio ad absurdum of it is that all coding should > be done in assembler, or at least, nothing more high-level than C. Sorry, Lisp/Scheme is a much better comparison than assembler. It is certainly a high level language, but possesses the fewest possible number of constructs. I think it has its merits. The power comes from an ability to layer and combine, not from the quantity of supported operators. I doubt experienced Lisp programmers are any less productive than experienced Ada programmers, despite the obvious imbalance in the size of their feature sets. I've been programming in C++ for many years. Believe me I'd cheer if they eliminated "+=" and all the other redundancies that merely save keystrokes. Frankly I don't think there's anything wrong with Python stagnating if it is or becomes good enough. I personally love Python because it is minimalist and elegant. I'll be disappointed if it changes. Regards, Steve -- \_O< \_O< \_O< ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Steve Cooper Redmond, WA From geoff at homegain.com Tue Jun 12 21:33:32 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Tue, 12 Jun 2001 18:33:32 -0700 Subject: memory profiling Message-ID: <393D961EA4FCD311B03F00D0B746D65803275E94@HQSXCH01> I'm sure this question has been asked and answered a few times now, but I can't seem to find an answer for it, either in the FAQ or in the newsgroup archives. How do people do memory profiling in python? I'd like to compare, for instance, the memory consumed by a dictionary-based approach versus a list or tuple based approach. I've seen the tool in mxTools, sizeof, which is nice, but that doesn't seem to address the big "random" factor, the empty pointers in the dictionary. Does a tool exist that will let me measure this in some reasonably straightforward way? Are other people doing any kind of memory profiling, or do folks just "eyeball it"? Am I missing something blatantly and plainly obvious that I should be embarassed for not seeing? Thanks in advance, --G. --- Geoff Gerrietts Software Engineer, HomeGain.com 510-655-0800 x4320 From support at internetdiscovery.com Sat Jun 23 01:56:32 2001 From: support at internetdiscovery.com (Mike Clarkson) Date: Sat, 23 Jun 2001 05:56:32 GMT Subject: idle BUG - hung Python processes References: <3b2fba2f.1443851@24.0.228.33> <3B3063B8.3070206@ActiveState.com> Message-ID: <3b342bf7.4732228@24.0.228.33> On Wed, 20 Jun 2001 08:50:00 GMT, Mark Hammond wrote: >Mike Clarkson wrote: > >> I know you're not-a-gui-guy, but can you help with python.exe compile >> and link flags? Has anyone build Tkinter with Cygwin, and if so, does >> the same problem show up there? > > >What help specifically? > >python.c is compiled with: > >/nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /D "WIN32" /D >"NDEBUG" /D "_CONSOLE" /D "_MBCS" >/Fp"x86-temp-release\python/python.pch" /YX >/Fo"x86-temp-release\python/" /Fd"x86-temp-release\python/" /FD /c > >python.exe is linked with: > >odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib >comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib >/nologo /subsystem:console /incremental:no /pdb:"./python.pdb" /debug >/machine:I386 /out:"./python.exe" Thanks for the reply Mark. I'll build a clean Tcl 8.4 from scratch and post the flags it uses. I was just wondering if there was any possible subtlety on the /D_CONSOLE or /subsystem flags. I know compiler and linker flags are a long shot, but Python is the only program I've seen that generates unkillable processes under Win98, and it looks like it happens to frozenTkinter apps as well (see PS below). Here's a minimum Python program that illustrates the problem: import Tkinter from Tkconstants import * root = Tkinter.Tk() root.wm_protocol('WM_DELETE_WINDOW', root.tk.quit) root.mainloop() Call this hang.py and run it in a DOS window under Win98: python hang.py Click on the X in the corner of the Tk window. You generate an unkillable hung Python that inhibits Windows shutdown. So the first, and most important question is how can Python ever be unkillable. The only place to look I could think of was the compile/link flags. Maybe another might be how sys.exit treats the Tcl thread in Python. Now if you change the WM_DELETE_WINDOW to use the patched Tkinter root.quit that I suggested to Robin, root.wm_protocol('WM_DELETE_WINDOW', root.quit) then my patch to Tkinter solves the problem for me under Win98. (Robin said it didn't for him under Win95, but I couldn't get him to check that he was using the patched call in all places i.e. wm_protocol.) self.tk.quit() is the _tkinter quit, which just says bail out of the self.tk.mainloop(). It doesn't destroy any windows, delete any Tk intepreter or even delete any of the tcl commands declared in Python as callbacks. In Tkinter.py, I patched quit() to: (you may have to fix the tk.eval lines back up to be all one line). def quit(self): """Quit the Tcl interpreter. All widgets will be destroyed.""" # Use raw Tcl to ensure the foreach is atomic self.tk.eval('''foreach w [winfo child .] { wm protocol $w WM_DELETE_WINDOW {}; catch {destroy $w} }''') self.tk.eval('''catch {wm protocol . WM_DELETE_WINDOW {}; destroy .}''') self.tk.quit() My patched root.quit() makes sure all windows all destroyed. My theory is that the undestroyed windows might be stopping Python from unloading the Tk and exiting cleanly. Probably my quit(self) method could also have added at the end self.destroy() which is an internal Tkinter function that deletes the Python callback functions. It should probably be renamed to _deletetclcallbacks. The self.destroy() in Idle.PyShell at the end of main() after the root.mainloop() should then probably be then changed to: root.quit() which I think should solve Robin's original problem (I don't have a Win95 box here to test it on.) I'll submit the patch for Tkinter anyway, because I think it's correct, even if it doesn't explain why Python can be unkillable. I think it's *very* important that Python never be unkillable. On a related but different problem, Tk's event loop does not respond to WM_QUERYENDSESSION or WM_ENDSESSION events, so there is no way to gracefully shut down a Tkinter application when the user initiates a shutdown. The Tk event loop can be patched to do this, but I was wondering if there was any graceful way of doing this in Python? Would it have to be in a seperate thread? Many thanks, Mike. PS: freeze.py with -s windows links with this: link -out:ifindpy.exe *.obj "shell32.lib" "comdlg32.lib" "wsock32.lib" "user32.lib" "oleaut32.lib" "j:\ActivePython-2.1. 0-210/pcbuild/python21.lib" Note no /subsystem. From opengeometry at yahoo.ca Fri Jun 8 17:22:24 2001 From: opengeometry at yahoo.ca (William Park) Date: Fri, 8 Jun 2001 17:22:24 -0400 Subject: How do I serve an image from a Python Script? In-Reply-To: <3B2134A2.EFE1736F@yahoo.com>; from haaserd@yahoo.com on Fri, Jun 08, 2001 at 01:25:06PM -0700 References: <3B2134A2.EFE1736F@yahoo.com> Message-ID: <20010608172224.A1599@node0.opengeometry.ca> On Fri, Jun 08, 2001 at 01:25:06PM -0700, haaserd wrote: > Hi, > > I am trying to serve an image from a Python script using Apache under > Windows. My simple HTML statement: > > a picture > > ...and my simple script: > > #!c:/Python20/python.exe > import sys > > def pix(): > n = 'c:/My Pictures/Sample.jpg' > p = open(n,'rb') > apix = p.read() > p.close() > sys.stdout.write("content-type: image/jpeg\n\n") > sys.stdout.write(apix) > sys.stdout.flush() > > if __name__ == '__main__': > pix() > > As you can see I am ignoring the CGI fields for the moment and am just > trying to serve up an image. Through debugging statements that I have > removed, I know the program crashes on the statement > sys.stdout.write(apix) > if the picture is over 200,000 bytes. > > On small images (10k), the script runs to completion, but no image > appears. What am I doing wrong? Download a JPEG image that works. Then, take a look at what kind of headers you get. For example, my Apache gives me HTTP/1.1 200 OK Date: Fri, 08 Jun 2001 21:12:06 GMT Server: Apache/1.3.14 (Unix) Last-Modified: Wed, 03 Jul 1996 06:18:15 GMT ETag: "18621-916-31da10a7" Accept-Ranges: bytes Content-Length: 2326 Connection: close Content-Type: image/gif -- William Park, Open Geometry Consulting, 8 CPU cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From cce at clarkevans.com Sat Jun 2 16:29:37 2001 From: cce at clarkevans.com (Clark C . Evans) Date: Sat, 2 Jun 2001 15:29:37 -0500 Subject: I had a thought ... (I know, call the newspapers). In-Reply-To: <3B172894.9B64F46F@my.signature>; from see@my.signature on Fri, Jun 01, 2001 at 05:31:00PM +1200 References: <3B172894.9B64F46F@my.signature> Message-ID: <20010602152937.B3335@doublegemini.com> On Fri, Jun 01, 2001 at 05:31:00PM +1200, Greg Ewing wrote: | Roman Suzi wrote: | > | > my = 0.02$ | | No, no... for consistency with other numeric | literals, it should be | | my = 0$0.02 Why not... my = USD$0.02 my = EUR$0.0235877 my = JPY$2.38420 ;) Clark From timr at probo.com Sun Jun 3 00:21:28 2001 From: timr at probo.com (Tim Roberts) Date: Sat, 02 Jun 2001 21:21:28 -0700 Subject: need code to gen all bit possibilities for 64 bits References: <9f4ipd$reu@freepress.concentric.net> Message-ID: grante at visi.com (Grant Edwards) wrote: >In article , Tim Roberts wrote: > >> >>The easiest way to generate all possible 64-bit patterns is to count: >> >>i = 0L >>while i < (2L ** 64L): print i >> >>Printing 18 quintillion numbers is going to take a very, very, VERY long >>time. At one per microsecond, I get about 500,000 years. > >I think the while loop above is going to run longer than >500,000 years. :) Whoops. I started out using xrange, but I wasn't convinced it would handle longs. That's what I get for being a smart aleck. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From gem at hsv.crc.com Fri Jun 8 14:53:25 2001 From: gem at hsv.crc.com (Glen Mettler) Date: Fri, 8 Jun 2001 13:53:25 -0500 Subject: Newby question - Trimming spaces from a string References: Message-ID: I found it! It is String.Strip() Interestingly enough, neither of the two books I have ("Learning Python" and "Programming Python" discuss this. I had to download "Lib.pdf" from the web to find all the object model properties for "String" Glen "Glen Mettler" wrote in message news:newscache$qu5meg$we5$1 at news.crc.com... > I have a string " abcd " and I need to trim the leading and trailing > spaces so that I get "abcd" > How do I do that? > > Glen > > From johnroth at ameritech.net Wed Jun 13 00:01:42 2001 From: johnroth at ameritech.net (John Roth) Date: Tue, 12 Jun 2001 21:01:42 -0700 Subject: Python grammar.. References: Message-ID: "John" wrote in message news:YIaV6.248191$Z2.2856970 at nnrp1.uunet.ca... > Hi, > > I previously asked whether Python accepts function arguments without the > opening/closing brackets and commas, like so: foo(x,y) would become foo x > y. The answer to this was no. So, I am wondering if it would be easy to > modify the source and rebuild the interpretor to accept this format? I > tried modifying the Grammar file but that didn't seem to work... > > Thanks, > > John So what you're saying is that if I have a function "Spam(eggs, ham) and a function scramble(, size = small), then I'd have to write Spam(scramble(eggs), ham) as Spam scramble eggs ham. How do I tell that "ham" is an operand of Spam, and not the second operand of scramble? The only way this could possibly work is if the parser could tell, at compile time, exactly how many operands each function had. There are languages where this is possible, but Python isn't one of them. John Roth > > From om at nikocity.de Thu Jun 14 17:26:18 2001 From: om at nikocity.de (Omni Permeable) Date: 14 Jun 2001 14:26:18 -0700 Subject: base converter References: <9ga0q902gl7@enews1.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:<9ga0q902gl7 at enews1.newsguy.com>... > "Greg Jorgensen" wrote in message > news:GE_V6.166783$p33.3516294 at news1.sttls1.wa.home.com... > > > > "Fredrik Lundh" wrote: > > > > > def BaseConvert(x, b): > > > out = "" > > > while x: > > > x, d = divmod(x, b) > > > out = str(d) + out > > > return out > > > > > > > Slightly modified to work with bases > 10: > > > > def BaseConvert(x, b): > > "convert decimal number x to base b" > > digits = "0123456789ABCDEF" > > out = "" > > if b <= len(digits): > > while x: > > x, d = divmod(x, b) > > out = digits[d] + out > > return out > > In general, I think it's better to avoid building a > string by a loop concatenating single characters. It > may not matter much in this case, but... > > def BaseConvert(x, b): > import string > digits = string.digits + string.uppercase > if b>len(digits): > raise ValueError, "base %s too large"%b > if x == 0: > return '0' > elif x<0: > negative = 1 > x = -x > else: > negative = 0 > result = [] > while x: > x, d = divmod(x, b) > result.append(digits[d]) > if negative: > result.append('-') > result.reverse() > return ''.join(result) > > I've also tried to fix the bug which (I believe) > would make this loop endlessly for x<0, &c. tracking down bug#2 : b==1 iterates forever! because : divmod (5,1) == (5,0) any more elegant solution than this one : elif b==1: return '0'*x unfortunately this throws an exception if x is very large (at least on my machine) From root at rainerdeyke.com Mon Jun 25 17:34:20 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 25 Jun 2001 21:34:20 GMT Subject: Is this a true statement? References: <8NuZ6.362378$oc7.42924874@news2.rdc2.tx.home.com> <3B3788A2.3BD1D672@tundraware.com> <9qMZ6.368197$oc7.44797813@news2.rdc2.tx.home.com> <3B37A15D.DF05A331@tundraware.com> Message-ID: "Tim Daneliuk" wrote in message news:3B37A15D.DF05A331 at tundraware.com... > Rainer Deyke wrote: > > Consider this diagram of a typical computer program: > > > > Input -> Computation -> Output > > > > Only the "computation" part is algorithmic, and those who use the term > > "Turing complete" generally only concern themselves with the computation > > Nope. Formally, an "algorithm" is something which when presented with > a given set of inputs will always produce the same output. (This, BTW, > is why Genetic Algorithms are a contentious case because given a particular > input, a GA will NOT give the same results repeatably.) So, by the > very definition of what an algorithm is and does, it embraces the notion > of both input and output. "Input" and "output" are physical actions. A computer program cannot necessarily manipulate the physical world, and "programming language A can manipulate the physical world" does not imply "programming language B can manipulate the physical world", even if both are Turing complete. > Nope. *All* computation (including graphics generation) is reducable to a > Turing Machine. Which part of the Turing machine can emmit light? > In your example, the machine that turns things into > graphics is itself a TM (if it is a digital computer) or it is the end > analog device which is irrelevant to this entire discussion. The end analog device is the entire point of the discussion. Most implementations of C++ can control it directly; Python cannot. > > All computer programs are deterministic. Any computer program that > > Nope. Not even close to true. The entire family of NP-Complete algorithms > (Traveling Salesman, Knapsack Packing, et al) are NON-deterministic (that's > what the 'N' stands for. I challenge you to write a single computer program which, given the same input, can produce more than one possible output. Variances in operating environment are part of the input. > > > generates output O from input I will always generate output O from input I. > > > > This is true for all things which are formally "algorithms". But this > is not the same thing exactly as "deterministic". It is the same thing. "Deterministic" = "Given this input, there can only be one output". Perhaps you are refering to the fact that the program is designed to produce any one correct solution among many? This is a human interpretation. The program doesn't know the problem it is trying to solve, it only know the procedure by which it is trying to solve it, and the procedure only has one possible result. > > Only if the system has a writeable disk with sufficient empty space. This > > is not a given. > > Well no it's not, but this is irrelevant to the discussion. Clearly, some > implementations of any algorithm are more time/space efficient - Bubble > Sorts run in O(n^2) but Heap Sorts run in O(n log n) yet both are still > just sorting. The limitations of disk, memory, and CPU merely define > how big a problem we can solve, or how fast we can solve it, not *how many* > different kinds of problems we can solve, which is the debate here. > > For example, a machine with limited disk space can solve the same *set* of > problems as a machine with Terabytes of disk, just much slower and less > efficiently. The minimums necessary to compute everything which is > computable were defined initially by Turing and later by Bohm and > Jacopini and in no case was disk space, memory space, or CPU speed > a foundational condition. As I said, these real-world constraints > speak to how fast or how efficiently we can run a given algorithm, > not how many *different* kinds of algorithms we can do. Forget about the amount of disk space. A device driver in C++ can run on a system with *no* writable disk. This is not true in Python. > > "Net computational power" is irrelevant in this context. > > If you say so. I thought this was the exact point of the debate: Can C++ > and Python "do" the same things. i.e., Do they possess equivalent abilities > to compute the same set of problems - Computational Power. "Doing" != "computing". Get it now? -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From tim.one at home.com Sun Jun 3 22:06:05 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 3 Jun 2001 22:06:05 -0400 Subject: I had a thought ... (I know, call the newspapers). In-Reply-To: Message-ID: [Alex Martelli] > I don't think anybody's really using it, though. I could > be wrong, it's hard to get precise statistics, but for > what I can judge from typical VB snippets seen around > they seem to be using the convenient notation (which, I > think, maps to floating-point) anyway. [Don Dwiggins] > See http://support.microsoft.com/support/kb/articles/Q172/3/38.ASP for > one use of Currency having nothing to do with money. Cute! In an earlier, unrelated thread, we learned that the Currency type is really a 64-bit int, conceptually scaled by a factor of 10000. The performance counter API uses 64-bit ints directly. So they're the same thing, except that the VB code at the link has to fiddle around multiplying the Frequency value by a magic 10000 to get VB to *treat* the value like a real 64-bit int. OTOH, in (Ctr2 - Ctr1) / Freq, the 10000's cancel out so they dare not play with magic multipliers in *that* context. Oh ya -- I bet all the VB programmers understand this in sufficient detail to bet the business on . From ssthapa at classes.cs.uchicago.edu Mon Jun 18 11:53:16 2001 From: ssthapa at classes.cs.uchicago.edu (Suchandra Thapa) Date: Mon, 18 Jun 2001 15:53:16 GMT Subject: Redhat 7.1 and Python 2.1 References: <20010524235013.K690@xs4all.nl> Message-ID: Chad Everett wrote: > >And the reason they don't ship with both Python 1.5.2 and Python 2.1 is? The powertools cd has python2.0 on it. -- ---------------------------------------------------------------------------- | Suchandra Thapa | "There are only two kinds of math . s-thapa-11 at NOSPAMalumni.uchicago.edu | books. Those you cannot read beyond | the first sentence, and those you | can not read beyond the first page." | -C.N. Yang ---------------------------------------------------------------------------- From SBrunning at trisystems.co.uk Wed Jun 20 10:05:43 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Wed, 20 Jun 2001 15:05:43 +0100 Subject: sendmail Message-ID: <31575A892FF6D1118F5800600846864D78BD70@intrepid> > From: Nik Goodey [SMTP:splat_360 at flashmail.com] > I am trying to get a form on my page email me some info. I can;t figure > out how to get sendmail to get the form info and email it. I'll tell you how *I've* done it. But I must warn you - I have been told that this method is exposed to misuse. Stay tuned to c.l.py for more info on this problem... Anyway, my form looks like so:
Your name:
Your e-mail address:
Subject:

Your message or question:

and the script to process it looks like this: import sys, cgi, smtplib, traceback, StringIO failHTML = '''Whatever HTML you want here''' sentHTML = '''Whatever HTML you want here''' mailtemplate = '''From: %(email)s To: youraddress Subject: %(subject)s Email from %(name)s %(comments)s''' sent = None print "Content-type: text/html\n" try: form = cgi.FieldStorage() formstrings = {} for formfield in form.keys(): formstrings[formfield] = form[formfield].value mailtext = mailtemplate % formstrings mailserver = smtplib.SMTP('yourSMTPserver') failure = mailserver.sendmail( 'youraddress', 'youraddress', mailtext) sent = not failure except: foo = StringIO.StringIO() traceback.print_exc(file=foo) failure = foo.getvalue() if sent: print sentHTML else: print failHTML # print failure # Enable this if you are having problems... I'm not using sendmail here - smtplib seemed easier. BTW, any suggestions for improving this, my first CGI script, would be warmly recieved... Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From pedrogarrett at mediaone.net Thu Jun 21 20:30:24 2001 From: pedrogarrett at mediaone.net (Pedro Garrett) Date: Fri, 22 Jun 2001 00:30:24 GMT Subject: Memory usage per object Message-ID: <20010621.173023.1529195746.23741@theforestal.localhost> I have a web traffic analyzer that loads large amounts of data from log files. The data structures that I keep are all dictionaries and lists and all of the data items (and keys) are strings, ints, or long ints. At the end of a run, I recurse all my structures to add up the total memory size and get about 11MB, though Linux reports the script taking up 80MB. I'd like to find out where all the extra memory is going. Does anybody know exactly what the memory overhead of creating a dictionary/list is, and what the overhead of each entry is so that I can more accurately tally how much memory my data structures are taking up? Or alternatively, a module or function that will do this for me, or perhaps a memory profiler. I've used the gc module and it doesn't report any garbage, so I figure my data structures are just much larger than I thought. I'm only loading data (I never delete any) so I don't think the problem is undeleted refererences. I'm using Python 2.1 on a pretty-much-stock Redhat-7.0 linux i386 system. Thanks in advance for any help, --Pedro From dougfort at downright.com Mon Jun 25 07:03:40 2001 From: dougfort at downright.com (Doug Fort) Date: 25 Jun 2001 12:03:40 +0100 Subject: installing MySQLdb with Python 2.1 References: <3b36a319.369414049@news1.on.sympatico.ca> Message-ID: <3b371a8c$1_4@news5.uncensored-news.com> Ken wrote: > Hi, > > I'm trying to install MySQLdb for use with Python 2.1, on a RH 7.1 > system. Unfortunately, I succeeded using the RPM, and it embedded it > into the Python 1.5.2 release (and not the 2.1). How would I get this > to work with 2.1? (ie. when I type "import MySQLdb" in python2, there > is an error...). > > Thanks! > > kc > I'm using the following, if you can paste the URI. It works well with Python 2.1. I had to make a few code changes: cursors are packaged differently and return tuples instead of lists. http://rpmfind.net/linux/RPM/sourceforge/mysql-python/MySQL-python-0.9.0c2-1.py21.i386.html -- Doug Fort Senior Meat Manager Downright Software LLC http://www.downright.com ______________________________________________________________________ Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com With Seven Servers In California And Texas - The Worlds Uncensored News Source From gustafl at algonet.se Mon Jun 11 15:27:42 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 11 Jun 2001 19:27:42 GMT Subject: Lost between urllib and httplib References: Message-ID: "Bill Bell" wrote: For some reason, my newsserver appears to have lost Dougs article (could it be the attachment?), but I found it on groups.google.com (without attachment of course). Thanks a lot for the info anyway. It's a great relief to know that I can still use httplib. I only need some more knowledge in HTTP. Nevertheless, I'd appreciate very much to see how to handle 301 and 302 redirections too. Regards, Gustaf Liljegren From SBrunning at trisystems.co.uk Fri Jun 22 03:26:28 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Fri, 22 Jun 2001 08:26:28 +0100 Subject: ANNOUNCE: The Neophyte Pythoneers List Message-ID: <31575A892FF6D1118F5800600846864D78BD87@intrepid> > From: Jesse W [SMTP:jessw at loop.com] > I have just now created a mailing list via Yahoo for the sharing, > joint debugging and general discussion of Python programs. The > list is intended to be primarily for those who have not yet reached > expert level in Python programming, but experts are also very > welcome. > Splitter! Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From ullrich at math.okstate.edu Tue Jun 5 10:26:01 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Tue, 05 Jun 2001 14:26:01 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> <3b19393d.703539923@news.okstate.edu> <9fgkci0gdu@enews2.newsguy.com> Message-ID: <3b1ce391.2243151@nntp.sprynet.com> On Mon, 4 Jun 2001 12:16:13 +0200, "Alex Martelli" wrote: >"David C. Ullrich" wrote in message >news:3b19393d.703539923 at news.okstate.edu... > ... [...] > > >Perhaps this subpart is about communication too: [a] >> about.) People don't usually try to prove things >> by saying it's probably in a book somewhere... > >Right, but you didn't ask for a PROOF, the way I read >your question, just: [b] >> Could you give us a hint regarding exactly what work >> of Chaitin's shows we can get "truly random" numbers from > >..."shows". I understand "show" and "prove" can >be used as synonymous in some contexts, and maybe >that is how you were using 'show' here -- I had not >read it as such. Anyway, you were only asking for >a _hint_ about exactly what work of Chaitin was the >relevant one, not the proof itself -- and why isn't it >correct to 'hint' that his recent book titled "Exploring >Randomness" looks like the right one? I couldn't and >can't be positive, not having received and studied it >yet, but it seemed a potentially useful pointer to supply >in response to a request for just a "hint"! Um, actually (i) when I ask for a hint regarding what work of Chaitin's shows that JVN was wrong, where _I_ come from it's clear that what I actually want is a hint regarding _how_ Chaitin shows it's wrong - saying it's probably in a book somewhere doesn't really say anything about that. But you're right, when I said [a] I had forgotten exactly how I'd phrased [b]. (ii) My attitude towards a few things had changed somewhat between the time I said [b] and the time I said [a]; had to do with some people seeming to be engaged in some sort of holy crusade, complete with loyalty oaths... never mind. >> I hope I've clarified the contradiction you mention >> in this post - while I don't think it was actually a >> contradiction, I do agree that seeing it as >> contradictory is not all that unreasonable, I >> would have stated things much more carefully >> if I'd known there was going to be a quiz. > >Same here. I have used sloppy, approximate and >perhaps misleading wording. There are enough real >disagreements without artificially constructing more. > >Neither of us was 'all that unreasonable' in taking >some of the other's words in pretty bad ways >(including contradictory, ridiculous, offensive, &c), >and maybe, as we didn't know there was going to >be a quiz, it was also not totally unreasonable to >spend 'just' hours rather than entire days in crafting >our statements. The overall result _was_ rather >unreasonable though:-). That seems like a reasonable way to put it. >> First, I don't think that it makes >> sense to talk about a perfectly >> random _sequence_, any more than >> it makes sense to talk about a random >> number. Someone wanted to know >> how random 6 was. > >If you take away the sting of 'perfectly', it >seems to me that talking about 'how random >is a number [sequence of bits]' does make >sense. The word "random" means many many different things. I did not say that talking about a prefectly random sequence did not make any sense. How can I say I didn't say that in the face of a _quote_ that shows that I said exactly that? Context. I was replying to your question about what I meant by "perfect randomness" or similar constructions. Yes, there are certainly senses in which one sequence can be regarded as more random than another. Those senses are irrelevant to the question I was trying to answer - when we say one sequence is more random than another that simply is not the "random" I was talking about. > 6, aka 110, is not very random because >it can be output by a tiny program indeed in >any given UTM. 00000000000000000000 is >several bits, but not very random, as, again, >the program to output them can be made small. >000001010011100101110111's structure is >not quite as evident, but clearly there as soon >as you cut the string up 3 bits at a time -- again >a small program is possible. It starts getting >harder with 0011101000100001011000100101 >(a string I just input 'at random':-) -- the fact >I don't see its structure doesn't mean it have >one (and apparently I have no way in general >to prove a given long bitstring _doesn't_ have >"structure" -- to find a lower bound on the >amount of bits needed to encode it). > >But this is close to the way a 'man in the street' >would use the word 'random' about a sequence >of bits -- including the possibility that one seems >random (I haven't noticed its structure == I >only so far have a program to emit it that is >large) but really isn't (it does have structure, >there _is_ a small program generating it). If >we can give a useful technical meaning to a >word that well matches its common-or-garden >use, why not? I never said we should not. Although usiing different words for different things would be preferable it doesn't always work out that way. >But I do agree that JVN was likely not thinking >of this meaning of 'random' as it was (AFAIK) >not used in his time. > [c] >> A perfect RNG is one with this property: >> If you use it to generate N bits then each >> sequence of N bits appears with probability >> 1/2^N. It has this property for _every_ N. > >So the computation of Omega is a perfect RNG -- No, in the sense that I'm using the words in [c] the computation of the bits of Omega is _not_ a perfect RNG. Even ignoring the question of whether we can call it a "computation". The first bit of Omega _is_ either 0 or 1. To be a perfect RNG in the sense in which the words were intenbded in [c] the first bit would have to be random, equal to 1 with probability 1/2 and 0 with probabilty 1/2. Since it _is_ a _specific_ well-defined number it simply is not at all clear what it can possibly mean to talk about the "probaility" that the first bit is 1. >and isn't there an old proof about pi having >this property too? (dim memories here...) The property you're talking about is that all sequences of N bits appear in the sequence with frequency 2^(-N) (asymptoticaly). This is not the same as [c]. The word is "normal". It may well be that Omega is a normal number. It is _not_ known that pi is normal. It seems pretty likely because most numbers are normal (like if you choose a real "at random" you get a normal number with probability 1) but nobody has a clue how to prove that pi actually is normal. >> (Hence an algorithm, as the word is usually >> defined, cannot be a perfect RNG. Because >> it has only finitely many states - it must repeat >> after a while, and hence for large enough >> values of N it is not true that all sequences >> of length N are equally likely.) > >Sorry, but I must be missing something. Can't >I write an algorithm to compute as many bits >of pi as I want? Sure, the amount of state it >will have to save when it has computed K bits >of pi, in order to compute the next N (the next >'run'), will grow with K, having no upper bound. > >But isn't that the reason we have Turing machines, >their infinite tape?-) Um, you're absolutely right about this. I guess I was assuming a bounded amount of storage in that "proof", and I certainly didn't mean to assume that; if there's a bound on the storage space then everything's different. I still suspect it's true that given anything which I would call an arithmetic RNG there exists a "randomness test" that the RNG will fail, which a "perfectly random" RNG would pass. But the proof above is nonsense, because I do mean to allow unbounded storage (otherwise things are boring). > Isn't a Turing-machine >program (even one exploiting the fact that the >tape is unbounded) "an algorithm", at least when >it can be proved to run to completion in finite >time at each run? Any given run will only use a >finite portion of the tape, but we don't have to >know how much in advance, do we? At each >successive (finite) run, more and more of the >tape could be used -- we ain't gonna run out. > >In other words, are you saying there cannot >exist an algorithm that is able to compute any >arbitrary amount of bits of pi on request, and (having >computed the first K of them and kept whatever >other auxiliary state it needs to on the Turing >machine tape) can at any time be asked for >"and now the next N please" for any N? Why >would this Turing-machine program not be an >algorithm, by the definition you want to use? >It seems to me to meet any definition of >algorithm I have ever encountered, but maybe >I have not encountered enough? > >If you concede such an algorithm is possible, >then how does it "have only finitely many >states", and why must it "repeat after a while"? >Surely it's proven that pi's bits (or digits in >any integer base of your choice) _don't_ repeat >after a while -- that's why pi is *irrational*, no? I've conceded your points in the last three paragraphs, but: >Now if my dim memories are correct, wouldn't >this algorithm be a "perfect RNG" by your >definition as here given? No. First, note that we do not know that pi _is_ normal. But supposing for the sake of argument that it is normal (it's not hard to give an algorithm that _does_ generate the bits of a normal number - let's call that number pi): It's not a perfect RNG because there's nothing random about it. The first digit after the decimal _is_ 1, and the second digit _is_ 4. There's nothing at all unpredictable or incompressible about it - anyone who knows how to calculuate the digits of pi can "predict" what the digits are. To put it another way: Consider the number 0.0123456789101112131415161718192021222324... consisting of all the natural numbers written one after the other (took decimal to make the pattern more clear). This _is_ a normal number, which is to say that the digits of this number _are_ "random" in the sense that we're assuming the digits of pi are random. It doesn't really look like a "random" number, does it? Seems kind of easy to predict the next digit. > Or was this definition >meant to be incomplete, with clauses to be >added progressively as needed to eliminate >otherwise uncomfortable algorithms from the >"perfect RNG" class?-) The definition I gave _was_ _very_ incomplete, but nobody's mentioned why. It certainly was not meant to be incomplete in the sense you ask about here - if someone pointed out the actual incompleteness I'd reply that that's just the way it is... >Alex > > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From jkraska1 at san.rr.com Wed Jun 6 20:48:57 2001 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 07 Jun 2001 00:48:57 GMT Subject: priority queue References: Message-ID: On Wed, 06 Jun 2001 06:41:55 GMT, "Nick Perkins" wrote: >I need a priority queue, but I am not sure what kind I should use. I will >be doing insertions that will likely fall somewhere in the middle, and will >only be removing from the front of the queue. I expect insertions to >out-number removals by about 2 or 3 to one. Use a standard binary heap. It will do absolutely fine in all general cases. Your other alternative is a fibonacci heap, which is optimized for insert. I have the binary heap at: http://www.sourceforge.net/projects/pythonic Checkout the "pythonic" module. The adt submodule is what you want. It also has a circular dequeue and a specialized python list which supports O(1) head-push and tail-append. The priority queue interface should be obvious. See test_pqueue.py in the same directory. C// From jkraska1 at san.rr.com Thu Jun 7 17:11:40 2001 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 07 Jun 2001 21:11:40 GMT Subject: WHY is python slow? References: Message-ID: On Thu, 07 Jun 2001 14:52:36 +0700, Steven Haryanto wrote: > Python is slower ... a layman like me would be curious to know why >exactly this is so. Dispatch overhead, much of it. >My first guess would be the ubiquitous use of dictionaries? Not per se, but it's related. IIRC, a typical run of the python interpreter reveals that dictionaries are a major contributor to CPU time in the Python runtime, but this is still < 20% (and sometimes quite a bit less). There are many things going on. C// From aleaxit at yahoo.com Mon Jun 4 06:16:13 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 4 Jun 2001 12:16:13 +0200 Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> <3b19393d.703539923@news.okstate.edu> Message-ID: <9fgkci0gdu@enews2.newsguy.com> "David C. Ullrich" wrote in message news:3b19393d.703539923 at news.okstate.edu... ... > probably I should not have said what I did the > way I did, because my impression is that there > is really no such thing as complete information > about a physical system. Sorry for making such a production of it, but that was exactly the crux of this part of the argument (and the contradiction that kept grating on me). I apologize if I wasn't effective in communicating this aspect. *Most* (not all) of this fracas seems to be about such miscommunications in one or the other direction, such as: > >> >> can have complete information regarding the state > >> >> of an _arithmetic_ _algorithm_. > >> > > >> >I assume that is your definition of "an algorithm"? > >> > >> It's not the _definition_, (and to the extent that > >> it is part of a definition it's not _my_ definition). ... > Good heavens, of course the state of an algorithm > can be finitely described. I didn't say otherwise. > > When I said "not _my_ definition" I meant it was > not a definition due to me, not that it was not > a definition that I was using. When I said that > it was not the definition I meant _exactly_ that: > "one can have complete information regarding > the state" is not the definition of "arithmetic > algorithm". Heh, OK, "PART of the definition" is correct, and I totally misread what you meant by "not _my_ definition" when you correctly inserted that 'part of'. Had I more carefully phrased my question as "is part of the definition of 'algorithm' that you are using" we might have been spared a fraction of these exchanges, just as we might have, had your phrasing re 'given complete information' up above been as you now wish it had. Different use of technical terms is also part of it, it seems. When I say "algorithm" (and this seems to be widespread usage) I don't necessarily imply an algorithm that is guaranteed to stop within a finite amount of time nor one that is guaranteed to have the exact answer when it does stop -- I say 'deterministic' algorithm when I need to imply that, 'probabilistic' algorithm when I need to imply the contrary, and just 'algorithm' without adjectives when talking about both sorts. 50 years ago usage was surely different (presumably back then a phrase like 'probabilistic algorithm' would either seem an oxymoron or be taken as a strange way to name an algorithm about some aspect of probability theory), so I might have taken that into account. Perhaps this subpart is about communication too: > about.) People don't usually try to prove things > by saying it's probably in a book somewhere... Right, but you didn't ask for a PROOF, the way I read your question, just: > Could you give us a hint regarding exactly what work > of Chaitin's shows we can get "truly random" numbers from ..."shows". I understand "show" and "prove" can be used as synonymous in some contexts, and maybe that is how you were using 'show' here -- I had not read it as such. Anyway, you were only asking for a _hint_ about exactly what work of Chaitin was the relevant one, not the proof itself -- and why isn't it correct to 'hint' that his recent book titled "Exploring Randomness" looks like the right one? I couldn't and can't be positive, not having received and studied it yet, but it seemed a potentially useful pointer to supply in response to a request for just a "hint"! > I hope I've clarified the contradiction you mention > in this post - while I don't think it was actually a > contradiction, I do agree that seeing it as > contradictory is not all that unreasonable, I > would have stated things much more carefully > if I'd known there was going to be a quiz. Same here. I have used sloppy, approximate and perhaps misleading wording. There are enough real disagreements without artificially constructing more. Neither of us was 'all that unreasonable' in taking some of the other's words in pretty bad ways (including contradictory, ridiculous, offensive, &c), and maybe, as we didn't know there was going to be a quiz, it was also not totally unreasonable to spend 'just' hours rather than entire days in crafting our statements. The overall result _was_ rather unreasonable though:-). > First, I don't think that it makes > sense to talk about a perfectly > random _sequence_, any more than > it makes sense to talk about a random > number. Someone wanted to know > how random 6 was. If you take away the sting of 'perfectly', it seems to me that talking about 'how random is a number [sequence of bits]' does make sense. 6, aka 110, is not very random because it can be output by a tiny program indeed in any given UTM. 00000000000000000000 is several bits, but not very random, as, again, the program to output them can be made small. 000001010011100101110111's structure is not quite as evident, but clearly there as soon as you cut the string up 3 bits at a time -- again a small program is possible. It starts getting harder with 0011101000100001011000100101 (a string I just input 'at random':-) -- the fact I don't see its structure doesn't mean it have one (and apparently I have no way in general to prove a given long bitstring _doesn't_ have "structure" -- to find a lower bound on the amount of bits needed to encode it). But this is close to the way a 'man in the street' would use the word 'random' about a sequence of bits -- including the possibility that one seems random (I haven't noticed its structure == I only so far have a program to emit it that is large) but really isn't (it does have structure, there _is_ a small program generating it). If we can give a useful technical meaning to a word that well matches its common-or-garden use, why not? But I do agree that JVN was likely not thinking of this meaning of 'random' as it was (AFAIK) not used in his time. > A perfect RNG is one with this property: > If you use it to generate N bits then each > sequence of N bits appears with probability > 1/2^N. It has this property for _every_ N. So the computation of Omega is a perfect RNG -- and isn't there an old proof about pi having this property too? (dim memories here...) > (Hence an algorithm, as the word is usually > defined, cannot be a perfect RNG. Because > it has only finitely many states - it must repeat > after a while, and hence for large enough > values of N it is not true that all sequences > of length N are equally likely.) Sorry, but I must be missing something. Can't I write an algorithm to compute as many bits of pi as I want? Sure, the amount of state it will have to save when it has computed K bits of pi, in order to compute the next N (the next 'run'), will grow with K, having no upper bound. But isn't that the reason we have Turing machines, their infinite tape?-) Isn't a Turing-machine program (even one exploiting the fact that the tape is unbounded) "an algorithm", at least when it can be proved to run to completion in finite time at each run? Any given run will only use a finite portion of the tape, but we don't have to know how much in advance, do we? At each successive (finite) run, more and more of the tape could be used -- we ain't gonna run out. In other words, are you saying there cannot exist an algorithm that is able to compute any arbitrary amount of bits of pi on request, and (having computed the first K of them and kept whatever other auxiliary state it needs to on the Turing machine tape) can at any time be asked for "and now the next N please" for any N? Why would this Turing-machine program not be an algorithm, by the definition you want to use? It seems to me to meet any definition of algorithm I have ever encountered, but maybe I have not encountered enough? If you concede such an algorithm is possible, then how does it "have only finitely many states", and why must it "repeat after a while"? Surely it's proven that pi's bits (or digits in any integer base of your choice) _don't_ repeat after a while -- that's why pi is *irrational*, no? Now if my dim memories are correct, wouldn't this algorithm be a "perfect RNG" by your definition as here given? Or was this definition meant to be incomplete, with clauses to be added progressively as needed to eliminate otherwise uncomfortable algorithms from the "perfect RNG" class?-) Alex From robin at jessikat.fsnet.co.uk Wed Jun 27 04:04:05 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 27 Jun 2001 09:04:05 +0100 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) References: <3B3950ED.8002AF8@cosc.canterbury.ac.nz> Message-ID: In article , Tim Peters writes >[Tim] >> We didn't *have* to expose Python's generator-iterator object >> either > >[Greg Ewing] >> Out of curiosity, what would a Python generator implementation >> look like that didn't expose generator-iterators? What would >> happen if you called a generator outside of a for-loop >> context? > >The implementation would probably be almost exactly the same, but the >*visible* behavior would probably look like either Icon or, less likely, >CLU. ... it would have been so much nicer and easier if these generator functions could be generalised to be resumable then all the nonsense about where and when they could be used would vanish. This seems to be too late now. -- Robin Becker From sholden at holdenweb.com Fri Jun 8 17:53:06 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 8 Jun 2001 17:53:06 -0400 Subject: Keyword argument parsing in error in 2.0? Message-ID: I'm working on a SQL abstraction layer, using methods to generate SQL appropriate to a particular database back-end. This has involved using keyword arguments to many of the methods. As a catchall (to avoid having to handle too much SQL syntax) many methods have a REST keyword argument, which is appended to the generated statement. The 2.0 compiler is complaining about the following statement: c.UNION(c.SELECT(["l.beer", "l.drinker", ["count(distinct s.bar)", "nbars"]], FROM=[["likes", "l"], ["serves", "s"]], WHERE="l.beer=s.beer", REST="group by l.beer, l.drinker"), c.SELECT("distinct beer, drinker, 0 as nbars", FROM="likes", WHERE="beer not in (%s)" % c.SELECT("beer", FROM="serves")), REST="order by 3 desc") This validates fine in PythonWin, but when the module containing it is executed I get: Traceback (most recent call last): File "alltest.py", line 396, in ? REST="order by 3 desc"), TypeError: keyword parameter redefined: REST The implication is clearly that the system is seeing two definitions of the same keyword argument, but I have tried to analyze the statement carefully and it seems to me that the different REST arguments are being provided to different calls. Just to check, I tried running the following program: def a(x, y, z, REST="NothingA"): return "%s %s %s %s" % (x, y, z, REST) def b(x, y, z, REST="NothingB"): return "%s %s %s %s" % (x, y, z, REST) print "STARTING" print a("a", b("m", "n", "o", REST="Ignore1"), a("s", "t", "u", REST="Ignore2"), REST="Ignore3") This runs fine, printing STARTING a m n o Ignore1 s t u Ignore2 Ignore3 Is this a bug, or can I simply not see my error for looking too hard? regards Steve From gustafl at algonet.se Thu Jun 21 10:41:34 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 21 Jun 2001 14:41:34 GMT Subject: Newbie xml.sax question Message-ID: I have made a config file in XML, with elements carrying attributes with names and values to store parameters. The idea is to be able to retrieve the parameters in a single way, like: # Set up parser etc... c = ConfigFile() # Retrieve value value = c.getValue(element, attribute) I thought SAX would be the right tool for retrieving the parameter values, but this is the first time I use it. I started out with a class with a method that shall return an attribute (parameter) value, based on a search for the first right element with the right attribute: from xml.sax import saxutils class Parameters(saxutils.DefaultHandler): def __init__(self, element, attribute): self.element = element self.attribute = attribute def startElement(self, name, attrs): if name == self.element: return attrs.getValue(self.attribute) I invoke it according to the XML howto: from xml.sax import make_parser parser = make_parser() dh = Parameters('limits', 'max-depth') parser.setContentHandler(dh) print parser.parse('e:/test/config.xml') Now what? There's no error, but I can't figure out how to acctually retrieve the value that the startElement method returns. The output from the last line is None. Regards, Gustaf Liljegren From tim.one at home.com Sun Jun 10 01:31:25 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 10 Jun 2001 01:31:25 -0400 Subject: floating point in 2.0 In-Reply-To: Message-ID: [Tim] > HW is key, because without near-universal HW support for a > thing that thing will never become widely accepted. HW vendors used > to punt on denorms because of the expense, but despite the expense > everyone plays along with denorms now, and not because of user demand > but simply because it's required. [Stuart L. Anderson] > None of the SGI boxes I've seen support denorms. Also, the IBM > mainframes and the Classic Crays don't use IEEE 754 in any form. And > then, there are the Alpha boxes running in VAX mode. Had you drawn up a listing 10 years ago (when Python's numerics were being designed), the list would have been very much longer. For example, I worked at Kendall Square Research then, and we punted on denorms too -- but 754 conformance hadn't worked its way into govt contracts by then either. For the love of God, Stuart, Cray even came out with the world's lamest *Ada* compiler, just to check off that box . There are a lot fewer companies designing FPUs now, but conformance to the letter of 754 is near-universal among new designs. still-python-wants-to-run-on-everything-ly y'rs - tim From dsh8290 at rit.edu Sun Jun 24 13:29:24 2001 From: dsh8290 at rit.edu (D-Man) Date: Sun, 24 Jun 2001 13:29:24 -0400 Subject: Is this a true statement? In-Reply-To: <3b360fba.10233292@nntp.sprynet.com>; from ullrich@math.okstate.edu on Sun, Jun 24, 2001 at 04:12:49PM +0000 References: <3b34939b.410758@nntp.sprynet.com> <3b35ed3b.1401529@nntp.sprynet.com> <3b360fba.10233292@nntp.sprynet.com> Message-ID: <20010624132924.D13478@harmony.cs.rit.edu> On Sun, Jun 24, 2001 at 04:12:49PM +0000, David C. Ullrich wrote: [snipped long discussion] When I read the original question I got the impression that "write a device driver in Python" meant "A person sits down at a console with a text editor, writes some Python code that implements the device's spec in terms of the driver API specified by the kernel". David Ullrich is taking "write a device driver in Python" to mean "output the bytes that comprised the finished driver to a file that the kernel can load and execute". In the former meaning, no a device driver can't be written in Python. In the latter, then yes, python has the ability to write binary data to a file. It also goes, then, to say that one could write the driver using only a hex editor (or the "front panel", for Steve :-)). I think that most people thought the first interpretation of the original question was obivous and thus did a poor job of answering David's questions. At the pratical level, (as David also says) a device driver can't be written in Python. At a more theoretical level, David is correct, almost. A device driver isn't a file, but a sequence of bytes in memory in the kernel's address space :-). I hope the original poster now understands the answer to his question and not too many people have been upset by the miscommunication in the discussion. -D From dnew at san.rr.com Sun Jun 3 14:51:05 2001 From: dnew at san.rr.com (Darren New) Date: Sun, 03 Jun 2001 18:51:05 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> <9fbbds01pk0@enews2.newsguy.com> Message-ID: <3B1A870D.42C89933@san.rr.com> Alex Martelli wrote: > > "Mark 'Kamikaze' Hughes" wrote in message > news:slrn9hi99k.9ns.kamikaze at kuoi.asui.uidaho.edu... > ... > > A true random number generator is not one that requires an infinite > > amount of information to predict, it is one that is *impossible* to > > predict, regardless of how much information you have. > > OK, that's your definition. Do you agree with Ullrich's > apparent thesis that _any_ physical system is such a 'true random > number generator' because of inevitable quantum effect _no > matter at how macroscopic a level you look at the system_, No. Systems that are designed to not show quantum effects (like computers) are very easy to predict reliably. Not 100%, but 99.99999999999999999% or better. Hence, they're not random, because I can almost always predict them. But since they're quantum systems, I cannot 100% predict them. > and secondarily that 'true randomness' (he calls it 'perfect') > only exists at all _because_ of quantum effects? I think it's more that 'true randomness' doesn't exist where there isn't any physical system involved, such as in a mathematical formalism. > If this is NOT what you mean, then let's find out what you > DO mean by "impossible to predict" if it's not some quantum > sophistry:-). "Impossible to predict with >50% likelyhood of success." Of course, it's *always* possible to predict what number will come up on the dice. Just go to Vegas and watch people do it. The trick is being *correct* with better-than-expected probability. > Are all of these a "true random > number generator" by your definition? Generally. > Couldn't I for example > in principle predict the outcome of dice being rolled, if I did > have a sufficient but finite amount of information on the > state of the dice? No. > There only seem to be macroscopic phenomena > involved This is incorrect. The dice bounce because of interactions between atoms in the dice and atoms in the table. Ensuring that there is sufficient such interactions is one of the rules of craps. > > > Meanwhile I still see nothing 'sinful' in dealing with > > > randomness finitely, > > > > It's simple. If you have a pseudo-random number generator, you will > > eventually repeat, > > If the 'eventually repeat' is sufficiently longer than the > time to the expected heat death of the Universe, for > example, is that a real problem? Any more than it is Let's put it this way. I'll run a Keno game with ping-pong balls bouncing arund in a cage. I'll let anyone who wants to examine the balls as much as they like, and the machine, and etc. You run a Keno game using a computer to generate the random numbers. You let anyone who wants examine your programs, OS, hardware, etc. Lets see who makes money and who loses money. (This actually happened in Atlantic City. Someone one several times over the course of 6 months, because the computer was starting over with the same sequence of games every time the casino lost power. I think it's safe to say this isn't random.) > before it's any use. Now, what difference does it make whether > the bits in the pad are generated by using a system that is > _impossible_ to predict (sufficient amplification of some > tastefully chosen quantum effect, say -- assuming quantum > effects ARE indeed intrinsically unpredictable), or one that > WOULD be possible to predict EXCEPT for the little detail of > needing *a sufficiently large amount* of information that is > just not there? N coin-flips, for example, to generate N bits. Needing a sufficiently large amount of information that isn't availble and never has been and never will be means that it's impossible to predict, yes? > Each flip is presumably predictable (with a probability as > close to 1 as one wishes) GIVEN information about initial > coin state and forces applied, Well, no. This is the assumption you keep making that's incorrect. This is exactly 100% precisely what quantum physics says. The flip is *not* predictable with a probability as close to 1 no matter how much informaiton about the initial coin state and forces applied. Really. It just isn't. Besides, this gets into another problem. The one-time pad is *not* random. If it were random, you wouldn't be able to decrypt the message. The one time pad was *randomly generated*, but once it's generated, it's not random any more. I can with 100% accuracy predict exactly what sequence of bits I generated for the one time pad. > Now what, if anything, is different about using some program > implementing a given algorithm to generate the pad? What > else except the amount of bits of information that are needed > for the prediction? I.e., the amount of randomness. The fact that one can look at the output of your algorithm (if it's not a very good one) and deduce what the algorithm is and all the starting points. If, for example, your algorithm is to feed a counter into DES with a fixed key and use the output as your random number sequence, then I have only 2^56 different keys to try to figure out what key you used. The reason? Because I know when I got it right. If I can tell when I have the *right* answer, then the sequence isn't random. > If high > enough, if a large-enough number M of bits of information is > needed to predict the N bits on the pad, then the system is > as secure as with N coin-flips. This is incorrect. If you need (say) 256 bits of key material, I'll have a difficult time brute-forcing the key before the universe dies. However, if I *do* happen to *guess* the right key, I'll know it. *Even* if you generated 256 coin flips, and then used them with an algorithm to generate 100K of pseudo-random data with an algorithm I know. Now, the likelyhood of me guessing is very tiny, but it's not zero. The likelyhood of me guessing your OTP is very tiny, but it's not zero. The difference is that if I do guess you're OTP, I won't know that I did. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. This is top-quality raw fish, the Rolls-Rice of Sushi! From tjreedy at home.com Mon Jun 4 14:45:08 2001 From: tjreedy at home.com (Terry Reedy) Date: Mon, 04 Jun 2001 18:45:08 GMT Subject: Zyclic updating of toplevel windows References: Message-ID: > Now my question: > Is is somehow possible to auto-update the toplevel-windows? e.g. to import time while 1: update_graphs() time.sleep(600) # seconds From sholden at holdenweb.com Thu Jun 28 15:07:08 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 28 Jun 2001 15:07:08 -0400 Subject: Is this a true statement? References: <8NuZ6.362378$oc7.42924874@news2.rdc2.tx.home.com> <3B3788A2.3BD1D672@tundraware.com> Message-ID: <3dL_6.5896$Gf4.193265@e420r-atl1.usenetserver.com> "Jarno J Virtanen" wrote ... > 25 Jun 2001 18:54:02 GMT Tim Daneliuk wrote: > > I still do not understand/agree with this line of reasoning entirely. > > As I mentioned in a previous post, one has to define what we mean by > > "do" or "program". It is a fundamental truth of Computer Science that > > all Turing-Complete languages have *exactly* the same computational > > abilities - i.e., They all handle the exact same set of algorithms - > > in particular, those algorithms which are Turing Computable (which > > excludes things like the Halting Problem). This *includes* all > > "interactions with the outside world" because such interaction > > is, by definition, algorithmic. > > I think it is still the fundamental _hypothesis_, although it has > strong evidental support. :-) > > > (Fine Point: There is a debatable point here about whether adaptive > > algorithms like those found in Genetic Programming are really formally > > "algorithms" at all because they do not behave consistently when faced with > > he same input conditions, but that's way outside the scope of this discussion.) > > I remember reading from a book titled "Mathematics: 2001 and beyond" (or > something like that), that in theory a networked group of computers > which all evolve independently is not restricted to "turing-completeness", > but I honestly didn't grasp all the details. ;-) > Since a Tuirng-complete computer can compute any computable function, the implication of such an assertion would be that a networked group of comupters can compute non-computable functions. This seems unlikely to me. looking-forward-to-machine-gestalt-intelligence-ly y'rs - steve From arturs at iidea.pl Sun Jun 10 10:58:53 2001 From: arturs at iidea.pl (Artur Skura) Date: 10 Jun 2001 14:58:53 GMT Subject: Global in multiple files References: Message-ID: On Sun, 10 Jun 2001 17:21:18 +0400 (MSD), Roman Suzi wrote: >>So, I thought I might be smarter than it. I would pass this >>variable to where I need it, but... it stil obstinately refuses to >>work. But then, my ex-global is a list of instances of a class, >>and methods in instances of another class won't accept it as >>an argument. > >Why do you need global variable in the OOP design anyway? I knew you would say that! ;) The source code is at http://arturs.iidea.pl/server.py and you can get 'live demo' by $ telnet arturs.iidea.pl 2211 It's based on simple chat code. I just want to keep this one little global, userlist, in order not to do some strange acrobatics later. It's clean, simple, keeps the number of arguments to pass to ther functions small etc. >I blame myself each time I maintain code with global variables: >the code can't be easily reconfigured, creates other problems. >Globals are allright only in short scripts which has no chance >to grow larger. In this case it fits perfectly. I need to acces userlist from any place, any moment. OK, suppose I want to do away with global userlist. I want to pass it to TS_Command instance. Will it work? No. Why? I have no idea... You see, I don't want to stick fanatically to my global, any solution is fine, provided that I can split my code and see it working as before, when it was all in one file. This 'userlist' is my last obstacle. Regards, Artur -- http://www.wolneprogramy.org "Jakos nie kusi mnie perspektywa zostania wsiowym glupkiem znajacym sie tylko na komputerach i zarabiajacym mnostwo kasy" -- lcamtuf From sean.mcgrath at propylon.com Mon Jun 11 14:55:09 2001 From: sean.mcgrath at propylon.com (sean.mcgrath at propylon.com) Date: Mon, 11 Jun 2001 19:55:09 +0100 Subject: XML examples needed References: <3b1aa296.13311941@news.laplaza.org> Message-ID: <8o4ait8jqbmpf9lt9sfrodi7fdjgtq4ahj@4ax.com> Mats, I'd suggest you at least give the Pixie library a try (http://www.pyxie.org). You don't need my book in order to make use of the library. regards, Sean >Books...there's McGrath's XML Processing with Python, but besides my >not having any book budget at the moment, the book seems to have come >in for quite a bit of criticism so I'm pretty doubful in any case. > From dwig at advancedmp.net Thu Jun 7 18:36:19 2001 From: dwig at advancedmp.net (Don Dwiggins) Date: 07 Jun 2001 15:36:19 -0700 Subject: Why should i use python if i can use java In-Reply-To: "Alex Martelli"'s message of "Thu, 7 Jun 2001 21:56:36 +0200" References: <9fngvl011jg@enews2.newsguy.com> <006d01c0ef8c$01af4ee0$0300a8c0@arthur> Message-ID: Alex Martelli writes: > I've posted very extensively about it, and how I prefer 'lightweight > proxies' instead -- instances that have no state (but rather delegate > all state, and possibly all behavior, to a singly-instanced object not > exposed directly to client code) but are freely instantiable at need -- and > specifically what different advantages this brings in different contexts, > such as Python, COM, and so on. Of all the issues, the key one is that > LWP is more change-proof than SDP in my experience -- "there must > be only one" is, out of all design constraints, one of those that most > tend to change in an iteration. Refactoring LWP's is trivial, refactoring > SDP typically isn't. Sorry, I guess I missed those posts. From the above, it sounds like you still start with an SDP-style singleton for the proxies to "point at", then add the LWP class for users to instantiate; this is essentially a Bridge, which fits your description of the advantages -- you allow the "state package" to be changed while not affecting the clients and, as you also describe, you can evolve the LWP separately (e.g., subclassing). It looks to me as though, rather than replacing one pattern with another, you've created a nice composition of two patterns. Of course, your LWPs, being Featherweights, could be used in other ways as well. -- Don Dwiggins "Solvitur Ambulando" Advanced MP Technology dwig at advancedmp.net From thomas at cintra.no Mon Jun 4 13:58:34 2001 From: thomas at cintra.no (Thomas Weholt) Date: Mon, 4 Jun 2001 19:58:34 +0200 Subject: Programming ASP with ActivePython [also a general Web question] References: <87lmn8fdmi.fsf@penguin.aktivist.ru> Message-ID: Hi, Had the same problem, but before Mark Hammond ( I believe ) posted the fix also referenced to here, I installed Apache and mod_python. Both available on Win and *nix. Works perfect. The old-fashion-way of mixing code and content ( ASP, JSP, PHP, PSP etc. ) is terrible to work with in larger projects. Using mod_python I've built a set of templates, actual HTML-code with %(id)s in them I load to build-pages with. 100% seperation of coding and design. Much easier to work with and maintain. I'm thinking of writing an article about the project as soon as it's finished. Thomas "Wartan Hachaturow" wrote in message news:87lmn8fdmi.fsf at penguin.aktivist.ru... > > Hello. > > I've got one trouble with ASPs on Python -- they doesn't work ;) > In fact, I did run pyscript.py, and it said that it has successfully > registered python as a scripting engine. > When I try to execute server-side scripts, they fail (saying 500 Server > Error). > In fact, client-side scripts does work in IE (even Calculator :) > Since it's the first time I try to do anything on IIS/ASP, I can't even > find the error logs (bye, bye /var/log/apache/error.log). > Did anyone faced the same problem? > I did included my try.asp in this message, just in case I'm wrong in the > script: > > -- > > > <%@ LANGUAGE=Python %> > > <% > for i in range(3,8): > Response.Write("Hello World!!
" % i) > %> > > > > -- > > P.S. Can anyone advise me some nice Python web programming environment > based on *nix? I've checked mod_python -- but it doesn't support sessions > and persistent db connections, and I am too lazy to write them by myself. > Zope seems to be too heavy and bloated (IMHO). > In fact I'd like to have something really working in the production already > (for example, WebWare doesn't seem to me being in that state), fast, and > easy to write for (e.g. also supporting features such as mentioned > sessions, persistent database connections). > Maybe I didn't searched too long, but right now it seems to me (poor man I > am) that ASP on Windows is the only solution. > > P.P.S. I am running IIS 5.0 on Win2k Advanced Server SP2, with ActivePython > 2.1.0.210 > > -- > Regards, Wartan. > echo "Your stdio isn't very std." > -- Larry Wall in Configure from the perl distribution From sholden at holdenweb.com Mon Jun 18 14:21:22 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 18 Jun 2001 14:21:22 -0400 Subject: Two minor syntactic proposals References: <9gkcsn0229c@enews2.newsguy.com> Message-ID: Of course, a possible solution to the original problem is to create a new class, whose __init__() method creates an instance variable containing a member of the original class, and to delegate non-implemented methods to that instance. I'm aware such delegation takes a little more CPU time, but it keeps the interface clean and guarantees that if the original class is redefined later the revised interface is made available. Probably preaching to the choir here, though. regards Steve -- http://www.holdenweb.com/ "Alex Martelli" wrote in message news:9gkcsn0229c at enews2.newsguy.com... > "Barry A. Warsaw" wrote in message > news:mailman.992844567.4921.python-list at python.org... > ... > > def Thing.new_method(self, x): > ... > > It never caught on, but this was in the (way) pre-PEP days. If > > there's interest, I could write up a PEP on this. > > FWIW, I'd *LOVE* it if there was some relaxation of the > current constraint that binding-statements (except assignment, > and package-related import) can only affect 'bare' (unqualified) > identifiers. It *IS* (from my POV) a wart (albeit a minor one) > that, to rebind anything BUT a bare identifier by class/def/import/ > from I must do a three-step -- first use the statement to bind a > 'temporary' bare-identifier, then assign the bare-identifier > to what I *really* want to bind, finally del the temp id. > > I understand that packages mean "import x.y" has very special > meaning, of course -- but "import x as y.z", "from x import > y as z.t", "def x.y", and "class x.y" all seem so natural to > me, so typically Pythonic, that I do not really understand > why they are currently forbidden in favour of, e.g.: > from x import y as temporaryname > z.t = temporaryname > del temporaryname > and the like. Where's the added-value in this restriction...? > > So, yes, I'd *LOVE* it if a PEP could remove at least SOME > of these constraints -- I just hope it doesn't have to be > as narrowly-worded as "allowing def x.y iff x is specifically > a bare identifier that is bound to a class-object and is > also the class's classname"...:-). That may be the TYPICAL > use, of course, but hopefully it need not be so tightly > restricted again...? > > > Alex > > > From edcjones at erols.com Thu Jun 14 12:36:10 2001 From: edcjones at erols.com (Edward C. Jones) Date: Thu, 14 Jun 2001 12:36:10 -0400 Subject: Utility for searching Python documentation Message-ID: <3B28E7FA.9080600@erols.com> I wrote a simple Python program that uses grep to search the Python documentation. Should such a utility be put in the Python distribution? Thanks, Ed Jones From dnew at san.rr.com Fri Jun 1 21:10:25 2001 From: dnew at san.rr.com (Darren New) Date: Sat, 02 Jun 2001 01:10:25 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> Message-ID: <3B183CFF.A90213BA@san.rr.com> > The quote above contains the premise "even given _complete_ > information". Except you snipped the end of the sentence, which is "complete information about how they're being generated." I can have complete information about exactly how many atoms of uranium I have in my sample, and still not be able to predict when the next atom will pop. I have complete information about how the numbers are being generated (watching a radioactive sample) without any information about what the next number will be. > I assume that is your definition of "an algorithm"? That > its state be finite? That's generally what it means. :-) That it's finite and deterministic. > While you are absolutely certain that > NO physical system can be described in finite terms, > EVER? That's what quantum physics says, and it's pretty much the best supported physical theory we have. > > >A physical system that is macroscopic enough to escape > > >Heisenbergian conumdrums > > > > There is no such system. > > In this case, no physical computer is predictable, and all > we study about algorithms are abstractions -- since a > computer system IS a physical system, then ALL bits > coming out from it must be random in your sense of > the word. Nope. Because you have an infinite number of possible states, and you collapse some of those into a 0 bit and some into a 1 bit. It's because you're *classifying* states in your brain as 1 or 0, ignoring the reality that there's an infinite number of voltages that represent 0. > If, on the other hand, you maintain that the output > from a physical system CAN be predictable if that > system is a computer running your program, then > what makes you SO certain that NO other physical > systems can also be predictable in the same sense?-) Again, you're talking two diferent things. In the first, you're talking about "the output will be somewhere between 4.5v and 5.5v on this wire." The other you're talking about an exact number. > A couple centuries ago all scientists were certain of > one thing, now they're all becoming certain of another, > and I won't be around in a couple more centuries to > laugh at the likely-different certainties they'll have > then. Meanwhile, mathematics is far from exempt > from paradigm shifts, of course, but those never do > 'contradict' the previous certainties (META-maths is > different that way of course -- cfr. Russel's well > known demolition of Frege's lifework:-), rather > extend and generalize on them. This is generally true of physics, too. > quote talks generically about "random", without using > the word "perfect" you now insert, and without any > specification of infiniteness as a prerequisite, and, as > such and without the needed qualifications, it is not > correct. _with_ the qualifications you want to place, > it seems to become tautological ("I define X as being > something that requires infinities: no finite system can > reach X, it can only approach it") and therefore sterile > and uninteresting, unless there are hidden layers of > exoteric meaning nesting in it, I guess. I think "random" here means "unpredictable". Tossing dice will lead to random/unpredictable results, even if you know everything there is to know about the dice and the table. Generating numbers between 1 and 6 will not be unpredictable if you know the seed and algorithm. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. This is top-quality raw fish, the Rolls-Rice of Sushi! From rob at jam.rr.com Fri Jun 8 21:16:27 2001 From: rob at jam.rr.com (Rob Andrews) Date: Sat, 09 Jun 2001 01:16:27 GMT Subject: Problems with Vaults of Parnassus References: <1108_991869141@ns.seowon.ac.kr> Message-ID: <3B217810.870ED5FC@jam.rr.com> Rainy wrote: > > On Wed, 06 Jun 2001 23:12:21 GMT, Wolfgang Lipp wrote: > > > > readers, > > > > I am having a few problems with the vaults of parnassus > > recently. the vaults are undisputedly *the* one-stop station > > whenever you look for a python module. however, there > > are three problems i can see: > > > > the current categorization is somehow less than > > satisfying. i do not want to delve into an analysis > > here; if nobody feels this way, ignore the point. > > if someone agrees, perhaps this can be made > > more concrete. > > > > more seriously, the search engine does not work > > correctly. i have experienced this several times, > > and i am sure it is not a mistake i make, it is a > > malfunction. please go try for yourselves: on > > http://www.vex.net/parnassus/apyllo.py/751771926.353274583 > > you'll find jim fulton's extension classes (with > > a sadly broken link, but that's more of dc's > > problem). the author's name is in the field > > titled 'owner'. now go to the search form below > > and try to find 'jim', 'fulton', 'jim fulton', lowercase, > > uppercase. restrict the search to 'any text', 'owners', > > do what you will -- "No Parnassus records matching > > your search criteria were found." is the sole answer. > > then, try 'extensionclass' -- same, no results. only > > thing that does yield results is 'extension class' (13 > > records) and 'extension class' (87 records). it must > > be admitted that 'extensionclass' is not in the text > > of the page, but it's in the url. be that as it may, > > the name of the owner does appear and is not > > found. > > > > next, you say ok, those extensionclasses must be > > somewhere, so you follow the download link to > > fetch > > http://www.vex.net/parnassus/download/Parnassus-Condensed-by-Category.html > > which is sadly way behind time, and there, indeed! > > you find a lot of hits for 'extension' (using the browser's > > find-on-page function) plus one for 'extensionclass' (this > > time, the url is, of course, found because it is included in > > the listing). however, names of owners/authers do *not* > > appear in the listing. > > > > in all, if i was asked 'please find out whether a guy named jim > > fulton, who works for digital creations, has made available > > a module called extensionclass', and i go searching, i sure > > would have to answer in the negative, which is not correct. > > obviously, we have a few problems that intertwine here, > > and some of them are not within the vault's responsibility > > (although it may be hard to communicate to executives > > why links are not checked for validity and listings are not > > updated nightly). > > > > does anyone have similar experiences? where is the > > problem? > > > > > > -wolf > > > > > > In addition, submissions and updates (reportedly) take up to > more than a week to get posted. > > -- > Jupiter and Saturn Oberon Miranda > And Titania Neptune Titan > Stars can frighten > - Syd I've always liked the Vaults, and see myself continuing to do so for some time to come. If anyone is interested in submitting source code, links to source on your site, a link to your home page, etc., or if you are looking for some interesting code, programming contest problems/solutions, or just some challenges to stimulate your creativity, may I shamelessly plug Useless Python? (The Vaults of Parnassus was one of our first links!) So far, we've been able to post people's code within minutes or hours of submission in nearly every case. Site maintenance is all done manually at the moment while I work on automating the whole business with Python Power! Rob -- Useless Python! Kinda like the AOL of the Open Source Community 3;-> http://www.lowerstandard.com/python/index.html From francis.meyvis at sonycom.com Mon Jun 11 09:07:00 2001 From: francis.meyvis at sonycom.com (Francis Meyvis) Date: Mon, 11 Jun 2001 13:07:00 GMT Subject: spawning unix command processes which run in parallel and simultaneously References: <9fvhqj$57m$1@news.hk.linkage.net> Message-ID: Hoi, Windows Win32 (NT version only) uses named pipe whose file names must look like //./pipe/YOUR_FILE_NAME_HERE in order to be recognized correct (note that I did not try it) -- --- Kind regards, best wishes, francis meyvis Bufu wrote in message news:mailman.992215593.31286.python-list at python.org... > Yes, os.popen and friends are what you want. > > I recommend trying stuff in the interpreter; it's more fun that reading > documentation, and usually more instructive, and more accurate. > > The documentation seems to have the wrong argument order for popen2, popen3, > and popen4, where the optional bufsize and more arguments are swapped > (should read "popen2 (cmd[, mode [, bufsize]])"). > > The documentation is in the os module under "6.1.2 File Object Creation" > presumably because it creates file like objects. I would have expected it > to be in "6.1.5 Process Management", or at least a cross-reference there. > > By the way, it seems to act strangely in PythonWin: > > >>> f =os.popen(r'C:\junk\test.exe') > Traceback (innermost last): > File "", line 1, in ? > WindowsError: [Errno 2] The system cannot find the file specified > > The same happens for any command line string, but it works fine in the > console version of python. > > ----- Original Message ----- > From: "Alan Tsang" > Newsgroups: comp.lang.python > To: > Sent: Sunday, June 10, 2001 3:23 AM > Subject: spawning unix command processes which run in parallel and > simultaneously > > > > > > HI, I am learning to code with Python and I encounter a technical problem. > > > > I want to spawn a few unix command processes from a python script so that > I > > can get the output from the unix command processes and use them in python. > > > > But I don't want to wait for the completion of one process at a time and > > then start another. I want the python script to start the processes > > simultaneously and monitor whether anyone of them have finished and if so, > > get the output from the finished one. > > > > It seems to me that the os and popen2 module is useful in this respect but > > I am not sure how to do it. > > > > Is it possible to do it in python? would be grateful if anyone can give > me > > a reference to any documentation. > > > > Thanks > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > From jarrett at ydyn.com Thu Jun 21 14:37:20 2001 From: jarrett at ydyn.com (W. Jarrett Campbell) Date: Thu, 21 Jun 2001 13:37:20 -0500 Subject: Python Job Posting: Austin, TX Message-ID: Company: Yield Dynamics, Inc. Position: Software / Senior Software Engineer Location: Austin, TX Yield Dynamics, Inc. is a fast growing software company supplying Yield Management and Advanced Process Control software to the semiconductor manufacturing industry. We are looking for an experienced Python developer to work in our Austin research and development center. The job will involve close work with our Advanced Process Control engineers to quickly prototype new products and applications and deliver those prototypes to our productization team in Santa Clara. Python skills that we are seeking include XML parsing, C/C++ extension interfacing, embedding python in other applications, GUI development under Python, and database interfacing with Oracle and MySQL. Working knowledge of SOAP, XML, HTTP, Apache, Java, CORBA, and Tcl/Tk is desirable but not required. Additionally, experience in the semiconductor industry is a plus! The job will involve limited travel, typically to our Santa Clara, CA location. For more information on Yield Dynamics, please visit our website at http://www.ydyn.com. Interested parties should submit their resume via email to: W. Jarrett Campbell Member of Technical Staff Yield Dynamics, Inc. jarrett at ydyn.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From sarah_dahler at yahoo.com Fri Jun 1 17:20:20 2001 From: sarah_dahler at yahoo.com (sarah_dahler at yahoo.com) Date: Fri, 1 Jun 2001 14:20:20 -0700 (PDT) Subject: Yahoo! Auto Response Message-ID: <20010601212020.51194.qmail@mta309.mail.yahoo.com> sarah_dahler at yahoo.com -------------------- Original Message: Received: from ch.egroups.com (208.50.99.226) by mta310.mail.yahoo.com with SMTP; 01 Jun 2001 14:20:19 -0700 (PDT) X-eGroups-Return: sentto-1214101-2447-991429885-sarah_dahler=yahoo.com at returns.onelist.com Received: from [10.1.4.55] by ch.egroups.com with NNFMP; 01 Jun 2001 21:11:26 -0000 MIME-Version: 1.0 Message-ID: <991429885.636.65831.l9 at yahoogroups.com> Mailing-List: list python-list at yahoogroups.com; contact python-list-owner at yahoogroups.com Delivered-To: mailing list python-list at yahoogroups.com Precedence: bulk List-Unsubscribe: Date: 1 Jun 2001 21:11:25 -0000 From: python-list at yahoogroups.com Reply-To: python-list at cwi.nl To: python-list at yahoogroups.com Subject: Digest Number 2447 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable There are 25 messages in this issue. Topics in this digest: 1. Sourceforge break-in and Python 2.1 security From: "Andres Corrada-Emmanuel" _________________________________________________________ DO YOU YAHOO!? Get your free @yahoo.com address at http://mail.yahoo.com From mwh at python.net Mon Jun 4 14:23:02 2001 From: mwh at python.net (Michael Hudson) Date: 04 Jun 2001 19:23:02 +0100 Subject: How to get the size of an object? References: Message-ID: stain at prigioniero.it (Nicola S.) writes: > Is there a way to get the size of an object in Python? > I mean something like 'sizeof' C operator... TIA Roughly speaking, no. Why do you want such a thing? Cheers, M. -- The only problem with Microsoft is they just have no taste. -- Steve Jobs, (From _Triumph of the Nerds_ PBS special) and quoted by Aahz Maruch on comp.lang.python From m.faassen at vet.uu.nl Wed Jun 13 19:15:03 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 13 Jun 2001 23:15:03 GMT Subject: Distutils error on a VPS References: Message-ID: <9g8s5n$gv8$1@newshost.accu.uu.nl> tracy s. ruggles wrote: > Has anyone out there had experience installing new packages on a VPS > (virtual private server)? I've posted a few question about trying to > install MySQLdb and haven't received any response... > Are there any tricks to installing on a VPS? I don't know anything about Virtual Private Servers, I'm afraid, so anything I'll tell you here may be useless information. I'm just going from my knowledge of C compilers. > All of the code in distutils/sysconfig.py spits out wrong directory paths > for the include and header directories. I've tried altering that code but > to no avail... I still get this error: > building '_mysql' extension > gcc -g -O2 -Wall -Wstrict-prototypes -fPIC > -I~/usr/local/mysql-3.23.38/include/mysql > -I/usr/home/ol0401/usr/local/Python-2.1/Lib -c _mysql.c -o > build/temp.solaris-2.6-sun4u-2.1/_mysql.o > _mysql.c:31: Python.h: No such file or directory > _mysql.c:40: structmember.h: No such file or directory > _mysql.c:41: mysql.h: No such file or directory > _mysql.c:42: mysqld_error.h: No such file or directory > _mysql.c:43: errmsg.h: No such file or directory > error: command 'gcc' failed with exit status 1 > Does anyone know what's going? 'gcc' appears to fail because it can't find the appropriate header files; it doesn't seem to be finding Python.h and structmember.h (also part of the Python include files), and can't find several MySQL header files either. On my system, Python.h is in /usr/include/python2.0 (for Python version 2.0), which is where Debian put it. Your own -I directive seems to a custom install from source, but its Lib directory is not where it keeps the Python C header files (which the MySQL needs to compile). Try its Include directory instead, which indeed contains Python.h. As for mysql, you do seem to be pointing to an include directory there. Verify whether that directory is indeed: ~/usr/local/mysql-3.23.38/include/mysql It should contain mysql.h, mysqld_error.h and such. (try an absolute path too instead of ~/usr.. that doesn't look right but perhaps it's a VPS thing?). It's unfortunate the distutils seem to do the wrong thing here. Perhaps you should discuss this on the distutils-sig so this can be diagnosed properly and improved. More information on this sig is here; if my help is useless be sure to try there (on the mailing list): http://www.python.org/sigs/distutils-sig/ Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From joe.gaffey at gradient.ie Wed Jun 27 12:30:31 2001 From: joe.gaffey at gradient.ie (joe) Date: 27 Jun 2001 09:30:31 -0700 Subject: viewing newsgroups with Zope Message-ID: <7241dd96.0106270830.7e60162a@posting.google.com> Hi, I am trying to use a web front end to view already existing newsgroups on an nntp server. I want to use Zope and was wondering if there are any zope products out there that will do this for me. I do not need it to act as a mail server or anything like this. I had a quick look at zopeGUM but this seems to be saying that it *will* provide something that may do this for me. Any help/suggestions would be appreciated. PS - is this the correct/best place to ask this question? Thanks, Joe. From dsh8290 at rit.edu Fri Jun 1 14:07:25 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 1 Jun 2001 14:07:25 -0400 Subject: spaces and arguements.. In-Reply-To: <3UPR6.243439$Z2.2750797@nnrp1.uunet.ca>; from john.thai@dspfactory.com on Fri, Jun 01, 2001 at 01:02:14PM -0400 References: <3UPR6.243439$Z2.2750797@nnrp1.uunet.ca> Message-ID: <20010601140725.A7707@harmony.cs.rit.edu> On Fri, Jun 01, 2001 at 01:02:14PM -0400, John wrote: | Hi, | | Am I mistaken or is there a way to invoke a method with arguements that | are separated by spaces instead of in brackets? Much like print x, y ? | So if I had a method foo(x) can I call foo x ? 'print' is a statement, thus is doesn't use parenthesis. If you put them there, you are not calling a function, but rather (possibly) adjusting order of operations while creating a sub expression. When calling a function, the parenthesis tell the compiler that you want to call it. Function calls always need parens. This is consistency, not perl . -D From root at rainerdeyke.com Wed Jun 27 11:08:01 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 27 Jun 2001 15:08:01 GMT Subject: Creating a _light_ python dll References: <3b39df15.103692562@news.iway.fr> Message-ID: "Emmanuel Astier" wrote in message news:3b39df15.103692562 at news.iway.fr... > I would like to use Python as a script for internet games. > The game will be avalaible by download only, so size really matters. > > What are the modules that I can remove from the standard python ? > I thought of : > complex, > long object, These two are part of the language itself on the syntax level, so removing them might prove difficult. > AudioOp, > imageOp, > md5, > md5module, > rgbimgmodule, > rotormodule, > shamodule, > signalmodule, > soundex, > yuvconvert > > Are any of these necessary for python ? > Are there any other module I could take back ? > Is thread and threadmodule necessary, if I want to make a single > thread application ? If it's a module, it's probably safe to get rid of it (with some obvious exceptions). In general, if you can remove it, recompile, and still run your game on it, then it was safe to remove. Otherwise put it back in. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From hgg9140 at fred.local Mon Jun 4 19:06:17 2001 From: hgg9140 at fred.local (Harry George) Date: 04 Jun 2001 16:06:17 -0700 Subject: Python and databases References: <991557251.316332@seven.kulnet.kuleuven.ac.be> <9fcv2j021uk@enews2.newsguy.com> Message-ID: It is only a "problem" if you need every nuance of DBI 2.0. You can get a whole lot of work done using what is available in, e.g., psycopg (for Postgresql) and MySQl-python (for MySQL). "Alex Martelli" writes: > "Pieter Laeremans" wrote in message > news:991557251.316332 at seven.kulnet.kuleuven.ac.be... > > Hi, > > > > Does python has something like perl 's DBI? > > I can 't find any documentation about it in the python docs. > > http://www.python.org/topics/database/ > > The problem may be finding complete implementations of > the current (release 2.0) DB-API spec, but that depends on > a lot of factors: are you going to make commercial use of > it, and in that case do you have funding -- for non-commercial > use, OR for pay in the case of commercial use, you can get > Lemburg's excellent mxODBC implementation (if ODBC is > what you want to use). You can also get implementations > for quite a few specific database engines. > > > Alex From nperkins7 at home.com Sun Jun 17 15:22:31 2001 From: nperkins7 at home.com (Nick Perkins) Date: Sun, 17 Jun 2001 19:22:31 GMT Subject: list.sort() References: <3B2CEBF1.CCF5377D@hack.org> Message-ID: "Rikard Bosnjakovic" wrote in message ... > >>> l = l ... I am pretty sure that l = l will never have any effect, whatsoever. Assignment never creates a copy of the data, it just 'points' to the same data. ( or "refers to the same object" ) This just makes l point to whatever it already points to. No effect. ..however.. I do find it a bit strange that list.sort() returns None, but I am sure there is a good reason for that. It is also strange that you can legally do: [3,2,5].sort() ..but you can not recover the sorted list. eg. a = [3,2,5].sort() assert a == None I presume that the list actually gets sorted, but since no referece is maintained to the list, it immediately becomes 'garbage', and is lost forever. ..the same goes for list.reverse()... If they both returned references to themselves, you could do: a = [3,2,5].sort().reverse() assert a == [5,3,2] From boyd at insultant.net Mon Jun 4 10:42:44 2001 From: boyd at insultant.net (Boyd Roberts) Date: Mon, 4 Jun 2001 16:42:44 +0200 Subject: Python as REXX replacement? References: <9fg5l3$deo$1@news.rchland.ibm.com> Message-ID: <9fg6qj$2cu$1@neon.noos.net> "Larry Whitley" a ?crit dans le message news: 9fg5l3$deo$1 at news.rchland.ibm.com... > A friend in Poughkeepsie currently uses REXX as his scripting language but > is becoming increasingly interested in Python. He asked if there is a > version that runs on the IBM 390 systems under VM or MVS? Does a port to > 390 (also known as zSeries) exist? someone's bound to have ported perl -- gag ... From ullrich at math.okstate.edu Mon Jun 25 10:06:33 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 25 Jun 2001 14:06:33 GMT Subject: Is this a true statement? References: <3b34939b.410758@nntp.sprynet.com> <9h2nuc$g6g$0@216.39.170.247> <3b35e8fa.311691@nntp.sprynet.com> Message-ID: <3b3744fc.2024805@nntp.sprynet.com> On Mon, 25 Jun 2001 00:38:46 GMT, grante at visi.com (Grant Edwards) wrote: >On Sun, 24 Jun 2001 13:22:46 GMT, David C. Ullrich wrote: >>On 23 Jun 2001 18:42:20 GMT, David LeBlanc >>wrote: >> >>>In article <3b34939b.410758 at nntp.sprynet.com>, ullrich at math.okstate.edu >>>says... >>>> On Fri, 22 Jun 2001 12:47:23 -0400 (EDT), "Steven D. Majewski" >>>> wrote: >>>> >>[...] >>>> >>>The reason why you can't write a device driver in pure Python >>>is simple: a device driver requires the ability to read to and >>>write from specific pre-determined locations in the processor's >>>memory and/or I/O space. >> >>Yes, a device driver has to do this. But I don't see why a >>program that _writes_ a device driver has to do these things. > >Nobody is arging that you can't write a Python program that >generates a sequence of bytes in a file that can be used as a >device driver by some particular OS. You don't seriously think >that anybody is interested in doing this do you? Of course not. The question at the top of the thread was whether it is true or false that Python can do anything that C can do, just slower. Do _you_ seriously think that anyone is interested in using Python as a _universal_ replacement for C? Presumably not. So what does the thread have to do with what people are actually interested in doing? >Grant Edwards grante Yow! PARDON me, am I > at speaking ENGLISH? > visi.com David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From davygrvy at pobox.com Tue Jun 5 06:40:55 2001 From: davygrvy at pobox.com (David Gravereaux) Date: Tue, 05 Jun 2001 03:40:55 -0700 Subject: Is PyRun_String() broken? References: Message-ID: Martin von Loewis wrote: >David Gravereaux writes: > >> I've tried using Py_single_input for the start token, but the result of the >> operation is sent to stdout. How is it possible to eval code and get the result >> back? As far as I've able to RTFM and "use the source luke" is to determine >> that eval_code2() when coming back out of the eval falls into the POP_TOP case >> and does Py_DECREF(v) on the result to destroy it. >> >> I WANT IT! WHERE'D IT GO? > >If you want the result of some computation, that computation better be >an expression; statements don't have a result. Then I'll take an empty one. That's fine. > So you should use Py_eval_input. I tried Py_eval_input, but I can't send it arbitrary code, such as "import sys". I get this for doing it: D:\itcl_exp>tclsh84 % load tclpython20.dll % set i [python::interp new] python0 % $i eval {3+4} 7 % $i eval {def f: pass} python0: File "", line 1 def f: pass ^ SyntaxError: invalid syntax % $i eval {eval("3+4")} 7 % $i eval {eval("def f: pass")} python0: Traceback (most recent call last): File "", line 0, in ? File "", line 1 def f: pass ^ SyntaxError: invalid syntax % $i eval {import sys} python0: File "", line 1 import sys ^ SyntaxError: invalid syntax % If I use Py_file_input, PyRun_String accepts the code, but no return value is used. Just some string that say 'None'. I'll assume that means "no exception generated". D:\itcl_exp>tclsh84 % load tclpython20.dll % set i [python::interp new] python0 % $i eval {import sys} None % $i eval {sys.version} None % $i eval {3+4} None % I'm at a loss for how to get python to accept arbitrary code, and give me a result. I can understand 'import sys' having an empty return, but I can not accept nothing in return for 'sys.version'. Does my problem make sense? >> If all that PyRun_String() returns is "exception or not", where/how is it >> possible to get the last result of the operation? Is it true that POP_TOP in >> eval_code2() of ceval.c discards the object before returning? How can I not pop >> the top, and grab the result then Py_DECREF it after I'm done? > >You cannot. If you have a Py_file_input that has "computes some >value", that file input should either assign to some variable, or be a >function that you can call so that it returns a result. It looks I'll have to dig inside the node compiler or do something very dirty to achieve what I need. That last TOP_POP has to be stripped from the node, and I must have it drop out of eval_code2() at that point so I can pop the top myself and get the result. So if I have to know the difference between a statement and an expression when using PyRun_String to get a return value, can I assume that the evaluation of arbitrary code for a result is a concept python doesn't support? I doubt it. There's a way to do this somehow and I haven't found it yet. >Why do you want the result of the last expression statement, anyway? I want the same concept that Perl and Tcl have for doing an eval. It seems python doesn't have the concept of returning values for an eval of arbitrary code using PyRun_String. Is there another function that I could try instead? -- David Gravereaux From adjih at crepuscule.com Tue Jun 5 02:52:11 2001 From: adjih at crepuscule.com (Cedric Adjih) Date: Mon, 4 Jun 2001 23:52:11 -0700 Subject: I NEED to TEACH you something, QUICK! References: Message-ID: "Laura Creighton" wrote in message news:mailman.991627986.11067.python-list at python.org... > > [...after some refactoring...] > > Note that sometimes when you try this, wonderful things happen: > > >War is bad. > > Huh? That's the whole point. That is exactly what Tolstoy was trying to > say when he wrote that scene ... > > ***************** > > Notice, again, how we have avoided spending all our time drowning in > dog statistics that we really don't have any immediate need for. > This reminds me this chess anecdote after Tal-Botvinnik: Tal: "After the game I demonstrated some very interesting (at least, I thought they were interesting) variations. Mikhail Moiseyevitch, I think only out of politeness, listened to me and then said: "This is all very well, but - at first I was afraid of the piece sacrifice, but later I decided that I should exchange the Rooks, keeping the Queens on the board." I was surprised by these words. This assessment of the position seemed too abstract. But when we began analysing the position, I realised that Botvinnik was absolutely right. If I had exchanged the Queens, White's Pawns would have been stronger than Black's Knight. Provided Black's Queen had remained on the board, however, White's King would have been in real danger. "Of course, such an abstract approach to evaluating chess positions should not be regarded as a universal remedy; on the other had, in the course of the game one should not rely only on calculation of concrete variations." (BTW, chess books are full of "design" patterns) From kbk at float.ne.mediaone.com Mon Jun 11 15:46:06 2001 From: kbk at float.ne.mediaone.com (Kurt B. Kaiser) Date: Mon, 11 Jun 2001 19:46:06 GMT Subject: Newbie References: <20010611151900.11318.00004174@ng-mp1.aol.com> Message-ID: www.python.org : check out "Top Documentation Links", especially the tutorials. Then, Book: David Beazley, "Python Essential Reference" Newsgroup: comp.lang.python From see at my.signature Tue Jun 19 02:21:14 2001 From: see at my.signature (Greg Ewing) Date: Tue, 19 Jun 2001 18:21:14 +1200 Subject: PEP 255: Simple Generators References: Message-ID: <3B2EEF5A.8FF0DAFB@cosc.canterbury.ac.nz> Something is bothering me about this. In fact, it's bothering me a LOT. In the following, will f() work as a generator-function: def f(): for i in range(5): g(i) def g(i): for j in range(10): yield i,j If I understand PEP255 correctly, this will *not* work. But it seems entirely reasonable to me that it *should* work. It *has* to work, otherwise how am I to write generators that are too complicated to fit into a single function? Someone please tell me I'm wrong about this! -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From matt at mondoinfo.com Sat Jun 9 13:40:10 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Sat, 09 Jun 2001 17:40:10 GMT Subject: Tkinter Qs References: <3B2257B6.D4390F7D@telocity.com> Message-ID: On Sat, 09 Jun 2001 13:07:03 -0400, Adonis wrote: >what form of measurement does Tkinter use? Pixels or DIB? Sometimes it uses pixels, sometimes it uses lines, and sometimes it uses characters. b=Button(root,text="Test",width=10) # 10 characters wide t=Text(root,width=20,height=2) # 20 characters wide, 2 lines high f=Frame(root,width=25,height=35,bg="green") # 25 by 35 dots This is often maddening. Fredrik Lundh mentions a way of working around this odd use of multiple units of measure at (wrapped for line length): http://www.pythonware.com/library/tkinter/ introduction/x1309-patterns.htm That's from his excellent An Introduction to Tkinter. I recommend it highly. >why doesnt this work? (text not being colored) >t = Text(frame, width=50, height=15) >t.pack() >t.tag_config("test", foreground="red") >t.insert(END, "test") The first argument to tag_config() is a user-defined tag name. The tag needs to be added to specific characters or character ranges: t=Text(root, width=50, height=15) t.pack() t.tag_config("mytag", foreground="red") t.insert(END, "test") t.tag_add("mytag","1.0","1.4") You can also specify the tag name when you're inserting text: >>> t.insert(END,"wibble","mytag") Regards, Matt From alan.gauld at bt.com Mon Jun 4 13:30:06 2001 From: alan.gauld at bt.com (Alan Gauld) Date: Mon, 04 Jun 2001 18:30:06 +0100 Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> <991574786.733151@nntp01.uskonet.com> Message-ID: <3B1BC59D.E73096D2@bt.com> Frank Millman wrote: > Having said that, can anyone suggest an appropriate news > group for this kind of question. comp.software-eng is probably the best one. comp.object will accept it too tho'. And you do seem to have gotten a reasonable response here - Pythoneers are pretty good that way :-) Alan G. From nperkins7 at home.com Sat Jun 2 23:22:08 2001 From: nperkins7 at home.com (Nick Perkins) Date: Sun, 03 Jun 2001 03:22:08 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:9fb0ju01a8a at enews2.newsguy.com... > "David C. Ullrich" wrote in message > news:3b18ea18.332276 at nntp.sprynet.com... > ... > > I said you cannot have complete information about > > a physical system. You can't. An algorithm is not > > Let's take your original sentence again, snipless: > > """ > A physical RNG can have the property that one cannot make > any prediction about the value of the next bit even given > _complete_ information about how the numbers are being > generated. > """ > > This says "GIVEN _complete_ information". Now you say > you CANNOT "have complete information". The two > statements are in contradiction. If you cannot have it, > how can it be given? I don't see why you keep denying > this obvious contradiction. This is not a contradiction. if we define predicates: I : have complete information P : can make prediction then the first statement is: I implies (not P) and the second is: (not I) The conjuction of these axioms implies that I is false, but says nothing about P. Both of these statements can be true regardless of whether P is true or false. The second statement renders the first irrelevant, but does NOT contradict it. From see at my.signature Wed Jun 20 01:54:29 2001 From: see at my.signature (Greg Ewing) Date: Wed, 20 Jun 2001 17:54:29 +1200 Subject: Suggested amendment to PEP 255 References: Message-ID: <3B303A95.367357C9@my.signature> Tim Peters wrote: > > Who would this help? Seriously. There's nothing special about a generator > to a caller, except that it returns an object that implements the iterator > interface. What matters to the caller is irrelevant here. We're talking about what matters to someone writing or reading the implementation. To those people, there is a VERY big difference between a regular function and a generator-function -- about as big as the difference between a class and a function! In fact, a generator-function is in many ways much more like a class than a function. Calling a generator-function doesn't execute any of the code in its body; instead, it creates an instance of the generator, much like calling a class creates an instance of the class. Calling them "generator classes" and "generator instances" would perhaps be more appropriate, and more suggestive of the way they actually behave. The more I think about this, the more I agree with those who say that overloading the function-definition syntax for defining generators is a bad idea. It seems to make about as much sense as saying that there shouldn't be any special syntax for defining a class -- the header of a class definition should look exactly like a function definition, and to tell the difference you have to look for some subtle clue further down. I suggest dropping the "def" altogether and using: generator foo(args): ... yield x ... Right from the word go, this says loudly and clearly that this thing is *not* a function, it's something else. If you haven't come across generators before, you go and look in the manual to find out what it means. There you're told something like Executing a generator statement creates a special callable object called a generator. Calling a generator creates a generator-instance, which is an iterator object... [...stuff about the "yield" statement...] I think this is going to be easier to document and lead to much less confusion than trying to explain the magic going on when you call something that looks for all the world like a function and it doesn't execute any of the code in it. Explicit is better than implicit! -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From spam_kill.guse at hobbiton.org Wed Jun 6 12:10:41 2001 From: spam_kill.guse at hobbiton.org (goose) Date: Wed, 06 Jun 2001 16:10:41 GMT Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3b1cdc84.5514@bolder.com.co.za> <9fleid$3rp$1@oslo-nntp.eunet.no> <3B1E4951.7F36D4E4@alcyone.com> <3B1E50E1.35AE59C@lmf.ericsson.se> <3B1E52DA.BBC9FC32@alcyone.com> Message-ID: <3b1e5601.3970@bolder.com.co.za> Erik Max Francis merely scratched his head and went: > Attila Feher wrote: > >> BTW some competents I know play games... really... although I have >> never >> seen an original box of any game they play :-))) So OK they do play. >> But do they buy? > > That competent computer users play games but never buy them is also > ridiculous. > *REAL* computer users don't buy games ... they write their own -- goose ----- " as a matter of fact, I don't find it very funny that this guy has posted the same joke twice in 2 days...... it's bad enough when other people steal jokes off each other but when you rip off your own jokes there's something wrong with you " --atj, cillian on about BretMS From aleaxit at yahoo.com Fri Jun 15 06:33:50 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 15 Jun 2001 12:33:50 +0200 Subject: sorting values in dict References: <3b292d23.1831931958@localhost> Message-ID: <9gcob001ca@enews1.newsguy.com> "Victor Muslin" wrote in message news:3b292d23.1831931958 at localhost... > This may not be the shortest or most efficient, but it does the trick: > > a={'a':9,'b':8,'c':7} > l=[] > for k,v in a.items(): > l.append((v,k)) > l.sort() > for v,k in l: > print v,k I think it's pretty close, except that, to build l, l = [(v,k) for k,v in a.items()] may be (very slightly) shorter and more efficient. Alex From carlf at panix.com Sun Jun 24 10:18:22 2001 From: carlf at panix.com (Carl Fink) Date: 24 Jun 2001 14:18:22 GMT Subject: Is this a true statement? References: <3b34939b.410758@nntp.sprynet.com> <3b35ed3b.1401529@nntp.sprynet.com> Message-ID: In article <3b35ed3b.1401529 at nntp.sprynet.com>, David C. Ullrich wrote: Are you trolling or just having trouble with English? > I may well be misunderstanding something, but it's not deliberate. > What _is_ the distinction between "write to a file" and > "create a new program"? (I'm assuming that the "program" > in question is the device driver. _Is_ that something other > than a file? And if not then what does a C program that > writes device drivers do, other than write a file?) But "writing a device driver" isn't something the *program* does at all. It's something a *programmer* does. The programmer, working in Python, could technically write a device driver, but for practical purposes wouldn't be "using" Python to create the driver. He/she would be writing the device driver in pure machine language and the only use of Python would be to perform a file write operation. "Writing a device driver", I repeat, is what the *programmer* does, not what the *program that writes the actual file* does. -- Carl Fink carlf at dm.net From habibcs at hotmail.com Mon Jun 11 10:39:03 2001 From: habibcs at hotmail.com (Habib Ahmed) Date: 11 Jun 2001 07:39:03 -0700 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> Message-ID: AOA n hi ALL (also some silly guy like me, but dont mind) u want 3d manipulation lang, the best support is been provided by the OpenGL, it's the industry standard, also it is available 4 many platforms, as it is actually depends, on the hardware graphics card/accelerator present on the client PC(that supports opengl). well i also used DirectX 7, its great, but 4 Windows XX platform, about 50-60 % of ppl use windows, and in WFC, com.ms.* there is a pakage 4 the implementation of all kinds of win32s win64...... Directx activex com+..... u can use that, While as far as java3D is concerned, i have known it uses the OpenGL engine, so get relaxed, its tooooo boooosting, great. Use it without hasitaion.., Basic optimization in 3d manipulation(3d-game or any type of 3d App) depends on the coding tech implemented... Also C the Anfy Java (search on google.com for Anfy java), i c that and cant beleive that it can run fast this much, there r various 3d demos... all in java, they r nearly running/rendering at the speed that my Direct3D, game showed.... So go on Using Java 3D, it best, Also java in itself is so much optimizing, that if C++ go on fulfilling the promise of java it could'nt be that much optimized, (i say this coz basically i am a low-level developer Assembly). Use it , have a great time, And also plz inform me about ur app. feel free 2 contact (any body): habibcs at hotmail.com and habib1146 at yahoo.com CU waiting 4 ur reply....... From smarsh at hotmail.com Tue Jun 26 20:30:47 2001 From: smarsh at hotmail.com (scott) Date: Wed, 27 Jun 2001 00:30:47 GMT Subject: [OT] Is there any tutorial for those who learn Java after Python ;-) References: Message-ID: <3B3928F3.CCAA71CA@hotmail.com> D-Man wrote: > > On Tue, Jun 26, 2001 at 09:23:20PM +0400, Roman Suzi wrote: > | > | I want to learn Java (Not that I am dissatisfied with Python, > | but this seem to be "the must" to find a job ;-) > > I would recommend using Jython to start -- you can do useful stuff > using your Python knowledge and use the Java libraries. It is really > cool. > > | And some simple things makes me wonder: > | > | public class JavaRules { > | public static void main(String args[]) { > | System.out.println(2+2+"a"); > > This line is a type error. > > | System.out.println("a"+2+2); > > Here is a little bit of Java's magic -- the java.lang.String being > first, it's '+' operator converts the other objects to a string, then > concatenates them. > You'd better stick to Python advice for the time being. Output will be: 4a a22 From dsh8290 at rit.edu Fri Jun 1 15:55:31 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 1 Jun 2001 15:55:31 -0400 Subject: Why isn't Python king of the hill? In-Reply-To: <9f7ai7$b4e$1@newshost.accu.uu.nl>; from m.faassen@vet.uu.nl on Fri, Jun 01, 2001 at 05:52:07AM +0000 References: <9f7ai7$b4e$1@newshost.accu.uu.nl> Message-ID: <20010601155530.C7896@harmony.cs.rit.edu> On Fri, Jun 01, 2001 at 05:52:07AM +0000, Martijn Faassen wrote: | Geoffrey Gerrietts wrote: ... | > Now I've answered the questions (I think fairly), but I'd like to | > take a step back and re-frame my comments. ... | > When I think about designing a webapp, this is the webapp I think | > about -- the one I never got to write. For the last year or year | > and a half, that mental design has been done in Java. In moments | > of weakness, I think that I could get away with using Jython, but | > in the end I come back to straight Java. The Java toolkit won't | > make development any faster, but it does have other compelling | > features. ... | > There's a certain draw to being able to take a single webapp and | > deploy it on any of a dozen different app servers that know how | > to handle the content, though it's small. | | What do you mean by this, exactly? Are you referring to the whole | Enterprise JavaBeans framework (sorry if I confuse any of the | terminology here) that's been implemented by various vendors? I've | always been skeptical about how well that actually works, but here | I'm skeptical without any actual real knowledge. :) I don't have any experience with J2EE either, but I hear the term a lot in discussions regarding the direction of our products in this Java shop. My question for you is : What about J2EE makes it so great? What are the features that you really need/want? Why not start an "Enterprise Python" spec, or something, to provide those features in Python? If J2EE is the main reason to use Java (excluding the reason in your next section), then let's take all the good ideas from it and make them part of Python too. If Python had "PyEE" then it might be easier to sell to management . | > But the biggest draw is that someone who's proficient with Java is | > not too hard to find. Someone who's proficient with Python is | > considerably harder to lay hands on. Given the ease of learning Python and the flexibility it offers, I don't think this a real issue. As Martijn's examples show, any Java programmer can learn Python quite easily. I've also heard many comments on this list indicating that most of the people who know python and java like python a lot better than java (myself included). | > Furthermore, while performance isn't a huge deal to those folks, | > their app did show signs of growing to cover a lot more terrain. | > It's conceivable that once the app was turned loose, it really | > would need to worry about the kind of massive load that starts to | > show off Python's seams. | | Are Java's seams that much tighter? I know it's faster, on average, | though it does seem to consume oodles of memory. And then there's the | question about closing the seams; it would seem to me that this would | be easier to do in Python in many situations, because it's just a lot | more flexible. Finn Bock recently posted on Jython-users some numbers someone else gave him regarding CPython vs. Jython on JDK 1.4 beta. http://www.geocrawler.com/archives/3/7017/2001/5/0/5834964/ Using PyStone it showed Jython to be quite a bit faster than CPython. I was surprised, but using Python and Java together might be more feasible in the near future. | > I think that part of the issue here is that when I think about a | > webapp, I don't think about an app that will be written and won't | > change. I don't think about working on the same app for the rest | > of my life, or even for more than a couple years. And I think | > about something that's continually growing, and I plan as if it | > will be as cool to the rest of the world as I think it is. | | Any larger app will have to grow and change over time, so I consider | this as well for my Zope/Python/relational database apps, which is | why I'm interested in your ideas about what makes Java more suitable | for these purposes. Not so I can go and use Java, but for stealing | some ideas. :) :-) (see above questions regardig J2EE) | > Meanwhile, I'll build all | > my administration tools, glue apps, and prototypes in Python. :) | | Good! | | Thanks for the interesting posting, I found it interesting too. -D From andy.pevy at nokia.com Mon Jun 18 11:31:10 2001 From: andy.pevy at nokia.com (andy.pevy at nokia.com) Date: Mon, 18 Jun 2001 15:31:10 GMT Subject: Function lookup using a directory. Message-ID: <29pX6.14682$cF.320097@news1.nokia.com> Hi Guys I am having trouble with the directory data type. What I want to do is to set up a directory that I can use to parse a command entered by the user, and have a directory return the name of a class to handle the command. Like this :- command_table = {'0': 'Help0', '1': 'Help1', '2': 'Help2', '3': 'Help3' } class Help0: def run(self,which): if len(which) == 1: print 'Help no args' else: print 'Help args' class Help1: def run(self,which): if len(which) == 1: print 'Help1 no args' else: print 'Help1 args' class Help2: def run(self,which): if len(which) == 1: print 'Help2 no args' else: print 'Help2 args' class Help3: def run(self,which): if len(which) == 1: print 'Help3 no args' else: print 'Help3 args' if __name__ == '__main__': command = user_input() try: h = command_table[command[0]] except: print command[0]+' not found' h.run() # Call the run method of the selected class. So, a couple of questions please..... Can I do this, I.E. have a class as a value in a dictionary and if so, what would the correct declaration be. Thanks. Andy Pevy A Very Beginner Pythoneer. -- We were always told that a million monkeys typing for a million years would eventually produce the works of Shakespeare. Now, thanks to the Internet, we know this is not true. From crj003 at yahoo.com Fri Jun 22 12:35:05 2001 From: crj003 at yahoo.com (Rich J) Date: 22 Jun 2001 09:35:05 -0700 Subject: Bitwise 'AND' error? References: Message-ID: <5c8ecb0b.0106220835.133bfa58@posting.google.com> "Tim Peters" wrote in message news:... > [Rich J] > > Could someone please explain to me why this is giving these results. > > This is taken directly from the python interpreter. > > > > >>> long = 0x2964619C7L > > >>> mask = 0xFFFFFFFF > > >>> ling = long & mask > > >>> print 'new number = %#x' % ling > new number = 0x2964619c7 > > >>> ling > 11111111111L > > >>> long > 11111111111L > > >>> > > > > Why would 'anding' with this mask give back the same number? It should > > have given back 0x964619C7, right? Or am I losing my mind? > > No, you're running on a 32-bit machine and mixing unbounded ints with 32-bit > ints. Mask is -1, and in "long & mask" mask has to be converted to long > first; long(-1) == -1L, i.e. mask is coerced to a (conceptually) infinite > string of 1 bits. Do > > mask = 0xFFFFFFFFL > ^ > instead. Thanks, alot! I thought I was losing it! From smigowsky at dspace.de Mon Jun 11 03:53:34 2001 From: smigowsky at dspace.de (Stefan Migowsky) Date: Mon, 11 Jun 2001 08:53:34 +0100 Subject: AW: Error connecting to COMServer Message-ID: <84257D042AA7D411B3F700D0B7DB9B7C13AB2D@newsintern.dspace.de> As you see from the makepy code the ProgId you must use is "Adder.AddingMachine.1.0". The developer of the COM server seems not to give a version independent Prog ID. So you should use : >>>from win32com.client import Dispatch >>>a = Dispatch("Adder.AddingMachine.1.0") Stefan > > > Mark Hammond wrote in message > news:<3B21C08F.8080905 at ActiveState.com>... > thanks for your answer > > Mike M?ller wrote: > > > > > > > > Dim Adder As New AddingMachine > > > > > > > > > It appears the ProgID of the object is simply "AddingMachine" > > The wizard that took me through the creation process says > Adder.AddingMachine is the ProgID > and > AddingMachine is the short name. > > > > > > >>>>from win32com.client import Dispatch > > >>>>a = Dispatch("Adder.AddingMachine") > > > > > > Try just using "AddingMachine". > > This results in: > > >>> from win32com.client import Dispatch > >>> Dispatch("AddingMachine") > Traceback (innermost last): > File "", line 1, in ? > File "c:\code\python20\win32com\client\__init__.py", line 94, in > Dispatch > dispatch, userName = > dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) > File "c:\code\python20\win32com\client\dynamic.py", line 80, in > _GetGoodDispatchAndUserName > return (_GetGoodDispatch(IDispatch, clsctx), userName) > File "c:\code\python20\win32com\client\dynamic.py", line 71, in > _GetGoodDispatch > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, > pythoncom.IID_IDispatch) > com_error: (-2147221005, 'Ung\374ltige Klassenzeichenfolge', None, > None) > > According to MSDN ... passing an invalid object name ... > > > > > Can I conclude anything if I look into at the file > generated by COM > > > Makepy? > > > > > > Why not open it and see :) You should find some generated comments > > telling you the correct Prog ID to use for all the objects > in the library. > > from the generated file: > # This CoClass is known by the name 'Adder.AddingMachine.1.0' > > But this gives the same result as without the 1.0 > > # The following 3 lines may need tweaking for the particular server > # Candidates are pythoncom.Missing and pythoncom.Empty > defaultNamedOptArg=pythoncom.Empty > defaultNamedNotOptArg=pythoncom.Empty > defaultUnnamedArg=pythoncom.Empty > > Empty and Missing give the same error messages (Adder.AddingMachine or > just AddingMachine as ProgID). > > Since the file is not long I just appended it (see below). > > Mike > > > > # Created by makepy.py version 0.3.6 > # By python version 2.0 (#8, Oct 19 2000, 11:30:05) [MSC 32 bit > (Intel)] > # From type library '1' > # On Fri Jun 08 23:15:41 2001 > """AddingMachine 1.0 Type Library""" > makepy_version = '0.3.6' > python_version = 0x20000f1 > > import win32com.client.CLSIDToClass, pythoncom > > # The following 3 lines may need tweaking for the particular server > # Candidates are pythoncom.Missing and pythoncom.Empty > defaultNamedOptArg=pythoncom.Missing > defaultNamedNotOptArg=pythoncom.Missing > defaultUnnamedArg=pythoncom.Missing > > CLSID = pythoncom.MakeIID('{904245FB-DD6D-11D3-9835-0000F875E193}') > MajorVersion = 1 > MinorVersion = 0 > LibraryFlags = 8 > LCID = 0x0 > > class CoClassBaseClass: > def __init__(self, oobj=None): > if oobj is None: oobj = pythoncom.new(self.CLSID) > self.__dict__["_dispobj_"] = > self.default_interface(oobj) > def __repr__(self): > return "" % (__doc__, > self.__class__.__name__) > > def __getattr__(self, attr): > d=self.__dict__["_dispobj_"] > if d is not None: return getattr(d, attr) > raise AttributeError, attr > def __setattr__(self, attr, value): > if self.__dict__.has_key(attr): > self.__dict__[attr] = value; return > try: > d=self.__dict__["_dispobj_"] > if d is not None: > d.__setattr__(attr, value) > return > except AttributeError: > pass > self.__dict__[attr] = value > > # This CoClass is known by the name 'Adder.AddingMachine.1.0' > class AddingMachine(CoClassBaseClass): # A CoClass > CLSID = > pythoncom.MakeIID("{904245FC-DD6D-11D3-9835-0000F875E193}") > coclass_sources = [ > ] > coclass_interfaces = [ > ] > > RecordMap = { > } > > CLSIDToClassMap = { > '{904245FC-DD6D-11D3-9835-0000F875E193}' : AddingMachine, > } > CLSIDToPackageMap = {} > > win32com.client.CLSIDToClass.RegisterCLSIDsFromDict( CLSIDToClassMap ) > -- > http://mail.python.org/mailman/listinfo/python-list > From sholden at holdenweb.com Sat Jun 30 21:13:44 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sat, 30 Jun 2001 21:13:44 -0400 Subject: 'with' statement in python ? References: Message-ID: "D-Man" wrote in message news:mailman.993920867.31303.python-list at python.org... > On Thu, Jun 28, 2001 at 10:13:40PM -0400, Steve Holden wrote: > | The reappearance of the FAQ wizard allowed me to enter: > | > | 6.31. Why doesn't Python have a "with" statement like Delphi's Object > | Pascal? > > I just found out that JavaScript has a "with" statement (spelled > "with" too). Might want to add that. > 6.31. Why doesn't Python have a "with" statement like some other languages? regards Steve From jbellprj at iinet.net.au Thu Jun 7 09:02:28 2001 From: jbellprj at iinet.net.au (John Bell) Date: Thu, 07 Jun 2001 21:02:28 +0800 Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> <3B1BC755.65510E63@bt.com> Message-ID: <3B1F7B64.44C76411@iinet.net.au> After replying to the original query on this thread (and being in a similar situation to the original poster inasmuch as I am in the beginning stages of using UML as a diagraming method - as per my initial post I don't see UML as anything like a development methodology) and trying out ArgoUML, dia, MetaEdit+ remodelling a completed Python project and several semi-developed tools, I would follow the implicit advice of the following poster and go with dia if programming in Python. The simplicity of the python class model (cf. eg C++ eg methods look like attributes, no member privacy hierarchy, lack of reference parameters etc) is better suited to dia than the other tools which are designed for more complex syntactic models. Despite a couple of annoying bugs which will presumably be fixed, dia has the advantage of being very easy to use and has one of the great advantages of Python itself: Speed of development. John Harry George wrote: > I've done "software engineering" data and process modeling in big > death march projects and in small XP efforts. In every case, the > problem is to use models/diagrams where/when they are needed, not just > "because they told us to". And the only way they seem to be > maintained is if there is no printed documentation -- everything is > live on the web. Edit and publish in a 3 second cycle time. > > Under these circumstances, UML models (specifically Dia) make sense > for conceptual modeling, logical data modeling, a dash of DFD's, and > the occassional state diagram. The idea is to bring the community of > players into a high0-level mindmeld as ASAP, not to lock down every > nuance of the implementation. Then do design and code reviews on the > implementation, which conveniently is in an easy-to-read langauge, > like...python > > grante at visi.com (Grant Edwards) writes: > > > In article <3B1BC755.65510E63 at bt.com>, Alan Gauld wrote: > > > > > >> I took a 3 day class on UML once. My impression: yet another > > >> "silver bullet" that doesn't work in real life. > > > > > >Like any design notation UML is there to communicate. If > > >the peer group is small enough the advantages are marginal. > > > > Agreed. All of the projects I've worked on have been small (1-2 > > people typically, 4-5 max). Resources are always scarce and > > when schedule and budget gets tight, maintining the system and > > design description always seems to be the first thing to fall > > off the bottom of the priority list. > > > > "Just get the fix released to production, and we'll worry > > about updating the documents later..." > > > > >If you are working in a distributed group of 20 or more > > >programmers something likev UML is near essential. Most > > >of my projects involve several hundreds of programmers > > >(250 on the current one) and there we simply couldn't > > >operate without UML. > > > > One of the problems I've run into consistently over the past 10 > > years is when management insists on using "big project" > > methodologies on tiny projects. Their reasoning seems to go > > something along the lines of: If one person can do a project > > like this in nine months using the "seat of the pants" method, > > then if we make him use Flowcharts/SASD/UML/whatever, then it > > should only take half as long! > > > > >> thought it was marginally useful, but like any other form of > > >> documentation, if it's not maintained (and it never is, AFAICT) > > >> it becomes worse than useless. > > > > > >It depends on the level that you work at. Architectures don't > > >vary that much and are useful for maintainers. But code varies > > >a lot so if you try to use UML for documenting code without > > >tool support for reverse engineering changes then I agree it > > >quickly becomes out of date. > > > > > >But How else do we communicate design to a new start - it takes > > >a long time to read a million lines of code.... UML and similar > > >tools cut that time down by an order of magnitude. > > > > I agree that you certainly need something for documenting large > > systems. The fashion in what that "something" is has varied > > over the years, and UML seemed as good as anything (certainly > > better than some). > > > > -- > > Grant Edwards grante Yow! -- In 1962, you could > > at buy a pair of SHARKSKIN > > visi.com SLACKS, with a "Continental > > Belt," for $10.99!! -- Regards, John Bell From chrishbarker at home.net Thu Jun 14 19:43:22 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 14 Jun 2001 16:43:22 -0700 Subject: sorting values in dict References: Message-ID: <3B294C1A.1AEE9CE1@home.net> Jeroen Wolff wrote: > I want to display a dict sorted by value. This brings up what I think is a serious limitation of the list sort() method: It doesn't return any information about how the items have been rearranged, so that you could use it to sort another list the same way. Nor, for that matter does it allow you to pass in a new sorting order. Here is what I have come up with instead: def sort_by_other_list(list_to_sort,list_to_sort_by,sortable = 0): """ sort_by_other_list(list_to_sort,list_to_sort_by, sortable = 0): returns a list of the elements of "list_to_sort", sorted by the elements of "list_to_sort_by". Example: >>> sort_by_other_list(['a,','b','c','d'],[4,1,3,2]) ['b', 'd', 'c', 'a,'] the list that is being sorted does not have to be sortable If the list being sorted is sortable, than you can use the "sortable" flag and a more efficient method will be used. """ if sortable: return map(lambda i: i[1], zip(list_to_sort_by,list_to_sort)) else: pairs = map(None, list_to_sort_by,range(len(list_to_sort_by))) pairs.sort() out_list = [] for i in map(lambda x: x[1],pairs): out_list.append(list_to_sort[i]) return out_list # for your case: dict = {'a':9,'b':7,'c':8,'d':4,'e':6} keys = sort_by_other_list(dict.keys(),dict.values(),sortable = 1) for key in keys: print key, dict[key] # If you want to use idea directly (are keys guaranteed to be sortable?), # it can a little cleaner: stuff = zip(dict.values(),dict.keys()) stuff.sort() print for value,key in stuff: print key,value NOTE: is there a way to avoid the "map" to extract the first list again? -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From jochen at riekhof.de Tue Jun 12 12:18:47 2001 From: jochen at riekhof.de (Jochen Riekhof) Date: Tue, 12 Jun 2001 18:18:47 +0200 Subject: substitute for c/java's ?: Message-ID: <9g5fc4$m8u$01$1@news.t-online.com> Hi... as a newcomer to python (like it a lot!) I found almost everything great except two things: 1. (most important) I am missing something like the c/Java ?: operator. This is so convenient in many places and saves a lot of typing. It works like result = option ? value1 : value2; which is equivalent to if option: result = value1 else: resultl = value2 Is there anything I overlooked? 2. switch (not important) if elif else is not a proper substitute for switches, as the variable in question has to be retyped in each if/elif clause. One can shorten the code by assigning to a temporary variable, but I consider switch more elegant. The ability to specify limits like 0 <=x <=10 is cool, however. Otherwise, one of the coolest languages I learned so far!! Ciao ...Jochen Jochen Riekhof jochen at riekhof.de Independent Software Developer From bernhard at intevation.de Thu Jun 28 10:47:19 2001 From: bernhard at intevation.de (Bernhard Reiter) Date: 28 Jun 2001 14:47:19 GMT Subject: PEP scepticism Message-ID: <9hfg1n$du33c$1@ID-89274.news.dfncis.de> This a general warning against the second system syndrom in Python. Maybe I am a hypocritical sceptic, but I have the impression that some feeping creatureism is introduced into Python. This might reduce the main advantage of Python to be clear and easy and mostly have one good formulation on how to express what you want to program in a structured way. Examples are: - augmented Assigments - Lists comprehensions - Simple Generators To me it looks like these contructs do not add capabilities to python which were missing. They seems to be rare cases in which I prefer that the programmer got to have the overview anyway and should use a longer version which is more explicit and explains more about what is actually being done. The new syntatic additions still require that the programmer has a full understanding about what is going on. On the other the sum of language constructs is growing and harder to understand as a complete system. Please to not respond giving me the very good reasons on why these features I have given as examples have been added or will be added to python. I know that the reasons are well worked out and make sense. You can easily convince me as I have to admit that I do not have the time to follow all the arguments and work out my opinion. On the other hand this is excatly the danger I want to warn you about. It is a social reason for being careful: Participation in the PEP debates about Python-enchancements requires a certain level of knowledge and interest about computer language design. It is most likely that the participants do understand complicated language constructs easily and are python wizards. They might just not see how the addition of syntatic sugar will lead to a higher learning curve for the masses. (And we are missing the ability to make usability tests for these kind of features because it is very hard to show and would require tests with many programmers over long test periods.) Mainly as a python user I urge you to take this into consideration. Bernhard ps.: I have similiar thoughts about some recent strategic development ideas for Zope. Python and Zope both have 2.x version number, please fight the 2nd system syndrom. :) -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) FSF Europe (fsfeurope.org) From root at rainerdeyke.com Sun Jun 17 12:42:29 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Sun, 17 Jun 2001 16:42:29 GMT Subject: Data Structure Question References: <20010617.090337.1987231011.7258@behemoth.miketec.com> Message-ID: "Mike Johnson" wrote in message news:20010617.090337.1987231011.7258 at behemoth.miketec.com... > I was hoping to do something like: > > diction['thekey']=value > > in a loop. The key and the value are not always unique, so 'diction' ends > up dropping some information. > > On thing that did work was to embed a nested dictionary into a list. > > list=[] > diction={} > > diction['key']='somedata' > list.append(diction) > diction={} > (repeat) > > But... This makes it a terrible pain to search and count keys.... Try the other way around, i.e. a dictonary of lists: key_value_pairs = [('key1', 'value1'), ('key2', 'value2'), ('key2', 'value3')] dict = {} for key, value in key_value_pairs: dict.setdefault(key, []).append(value) -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From root at rainerdeyke.com Wed Jun 20 15:08:53 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 20 Jun 2001 19:08:53 GMT Subject: Partially evaluated functions References: Message-ID: <9x6Y6.327563$oc7.32009573@news2.rdc2.tx.home.com> "Nick Perkins" wrote in message news:VL5Y6.296349$eK2.60381920 at news4.rdc1.on.home.com... > > "Rainer Deyke" wrote... > > > ... > > My version is superior in that it doesn't use named arguments. Consider: > > > > def f(self): > > print self > > > > curry(self = 5) # This will fail with the cookbook version. > > > > ..Of course, you mean: > > curry(f, self=5) Yes. > .. which works fine with the cookbook version. > ( why wouldn't it? ) Have you tested it? In Python 2.0: >>> def f(self, **kwargs): ... print self, kwargs ... >>> f(f, self=5) Traceback (most recent call last): File "", line 1, in ? TypeError: keyword parameter redefined: self >>> -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From aleaxit at yahoo.com Tue Jun 5 09:22:11 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 5 Jun 2001 15:22:11 +0200 Subject: Python and databases References: <991557251.316332@seven.kulnet.kuleuven.ac.be> <9fcv2j021uk@enews2.newsguy.com> Message-ID: <9fime501137@enews1.newsguy.com> "Harry George" wrote in message news:m3elszg80m.fsf at fred.local... responding to my note (which he only quotes afterwards): > > http://www.python.org/topics/database/ > > > > The problem may be finding complete implementations of > > the current (release 2.0) DB-API spec, but that depends on says: > It is only a "problem" if you need every nuance of DBI 2.0. You can > get a whole lot of work done using what is available in, e.g., psycopg > (for Postgresql) and MySQl-python (for MySQL). ...or a zillion other Python almost-DBI-perhaps-2.0 implementations, sure. But I think that is *IS* a problem to have a standard that is not implemented although it's been around for quite a while. If it has too many 'nuances', perhaps we should have a BASE level, which everybody can easily implement and Python newbies can be taught, and one or more advanced/optional/wizard-only levels for the hard stuff. BTW, Gadfly used to be one example I gave of almost-DBI-2 (though the lack of NULL hurt -- didactically first of all), but now, with 2.1, the warnings about it using regex rather than re make it not a very good newbie-intro any more. Has anybody looked into changing Gadfly to use re (and maybe innocuously accept NOT NULL constraints on columns since it IS going to want them NOT NULL anyway?-)...? Alex From BrianQ at ActiveState.com Fri Jun 22 21:15:17 2001 From: BrianQ at ActiveState.com (Brian Quinlan) Date: Fri, 22 Jun 2001 18:15:17 -0700 Subject: cmdline.py not working in ActiveState Python 2.1 In-Reply-To: <3B339168.9D7A9094@raqia.com> Message-ID: <000001c0fb81$f75acd50$b503a8c0@activestate.ca> > However, using > the same build (ActiveState) under windows NT, the command line option > is not recognized and 'b' has value zero. > > Any idea what is going on here? I think this command line parser used > to work on older windows Python distributions. Are you actually running the script from the command line or running it from PythonWin and entering the command line arguments in the RunScript dialog? The later won't work with cmdline.py because it grabs the command line arguments upon import, and PythonWin will only import it once i.e. your commandline arguments will be as they were for the first run. If this is not the case, please let me know because I am using ActivePython and cmdline.py without any problems. -- Brian Quinlan Python and XSLT Developer BrianQ at ActiveState.com ASPN - ActiveState Programmer Network Essential programming tools and information http://www.ActiveState.com/ASPN From akuchlin at mems-exchange.org Sat Jun 2 13:12:50 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 02 Jun 2001 13:12:50 -0400 Subject: QuickCam and python? References: <3dae3r3uzc.fsf@ute.cnri.reston.va.us> Message-ID: <3dk82upzzh.fsf@ute.cnri.reston.va.us> "akhar" writes: > SANE in PIL? I haven't seen that mentionned on their web site? Does it do > realtime or picture by picture? It's definitely in there; I contributed the module originally. I don't understand your second question. It takes single frames, but it can do so pretty quickly; using the Polaroid DMC driver in SANE, a Python server can readily take 20 frames per second, JPEG-encode them, and pump them out via TCP/IP on a middling Pentium (450 MHz). That's not doing any very complicated processing on each frame, though. --amk From donod at home.com Mon Jun 4 11:56:49 2001 From: donod at home.com (Don O'Donnell) Date: Mon, 04 Jun 2001 15:56:49 GMT Subject: Decimal can be Binary Too (was decimal or rational) References: Message-ID: <3B1BB007.966C2746@home.com> Tim Peters wrote: > > [Don O'Donnell] > > ... > > If by "floating-point-decimal" you mean internal representation of > > both the mantissa and the exponent by some sort of a binary-coded > > decimal, let me point out that it is not necessary to go to full > > decimal in order to to achieve the `7.35` == "7.35" goal.> > > By letting the exponent represent powers of 10 rather than 2, the > > base (or mantissa) and exponent can both be represented in binary > > as an int or long. Thus, the internal calculations can use the > > fast integer hardware instructions, rather than decimal arithmetic > > which would have to be done by software. > > ... > > See > > nt.py> > > for a fixed-point version of that. For "typical" commercial use, the > problem is that converting between base-2 (internal) and base-10 (string) is > very expensive relative to the one or two arithmetic operations typically > performed on each input. For example, hook up to a database with a million > sales records, and report on the sum. The database probably delivers the > sale amounts as strings, like "25017.18". Even adding them into the total > *as* strings would be cheaper than converting them to a binary format first. > > In addition, once you're outside the range of a native platform integer, > you're doing multiprecision operations by hand anyway. Python's longs use > "digits" in base 2**15 internally, but *could* use, say, base 10**4 instead. > The code would be almost the same, except for using different low-level > tricks to find twodigits/base and twodigits%base efficiently. Thanks for your comments, Tim. I agree that in most commercial environments, input, moving, formatting and output of numbers exceeds the amount of actual calculations that are done with them. Hence the early business oriented computers did all their calculations in some form of decimal format, to save the costly dec-bin-dec conversion steps. The "revolutionary" IBM 360 of the '60s was the first to have both floating-point hardware for scientific processing as well as fixed-point "packed-decimal" hardware for business use. With today's fast processors however, the radix conversion steps are hardly noticeable. I've done a lot of COBOL (yuck) programming on Univac/Unisys mainframes, which, lacking hardware decimal instructions, did all their fixed-point processing in binary. I never encountered any performance problems. Quite the contrary, they were incredibly fast machines for commercial work. I took a look at your FixedPoint.py module. Very nice work, thanks. As it turns out I already had downloaded ver 0.0.3, but had forgotten about it. Thanks for the update. I notice that you are also using a long integer internally to store the base number and an int to store a power of 10, as I suggested in my original posting. I was thinking more along the lines of a floating-point type rather than your fixed-point. I.E., with your FixedPoint class: 5.12 * 4.22 == 21.61 (it's rounded to two decimal places) With my dfloat class: 5.12 * 4.22 == 21.6064 (result is exact) I think there is a real need for both types of numbers. Especially in view of the fact that with Python's built in types, what we get today is: >>> 5.12 * 4.22 21.606400000000001 Do you think it would be possible or desirable to extend/generalize your FixedPoint class to handle the "floating decimal" as an option? Or would it be better to make it a separate class or subclass? Any opinions? still-learning-from-reading-your-code-ly y'rs -Don From xyzmats at laplaza.org Fri Jun 15 17:40:46 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Fri, 15 Jun 2001 21:40:46 GMT Subject: Solaris 8/x86: Build problems Message-ID: <3b2a7fc2.5552674@news.laplaza.org> Wondering if anyone has seen this. I just cleared the decks enough to get Solaris x86 loaded up, along with gcc. To be ultra-specific, it's the 1000 release of Solaris 8, and it's gcc 2.95.2. The configure and build of the Python binary itself was completely clean, but as soon as the modules and distutils come into play, it blows up completely. I built Python 2.0 some months ago and didn't see this, but at that point distutils weren't involved, right? I'm suspecting the autoconfigure somehow is not giving the right magic incantation to distutils. Here's a snapshot of the build log showing the last thing that worked, and the first that didn't: ranlib libpython2.1.a gcc -o python \ Modules/python.o \ libpython2.1.a -lpthread -lsocket -lnsl -ldl -lthread -lm PYTHONPATH= ./python ./setup.py build Text relocation remains referenced against symbol offset in file 0xe6 build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0xeb build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x1cf build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x224 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x24e build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2cf build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2dd build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x3c3 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x418 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x445 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x4ca build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x510 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x51e build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x696 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x804 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x814 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0xaa4 build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0xaa9 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0xb10 build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0xb15 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0xb6c build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0xb71 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0xbe8 build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0xbed build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0xc58 build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0xc5d build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0xd85 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0xda4 build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0xda9 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0xdfd build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0xe1c build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0xe21 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0xe9e build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0xea3 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x10f5 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x1114 build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0x1119 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x1171 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x1190 build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0x1195 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x1405 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x1424 build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0x1429 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x1485 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x14a4 build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0x14a9 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x150d build/temp.solaris-2.8-i86pc-2.1/structmodule.o lilendian_table 0x1515 build/temp.solaris-2.8-i86pc-2.1/structmodule.o bigendian_table 0x151d build/temp.solaris-2.8-i86pc-2.1/structmodule.o lilendian_table 0x153a build/temp.solaris-2.8-i86pc-2.1/structmodule.o bigendian_table 0x1545 build/temp.solaris-2.8-i86pc-2.1/structmodule.o native_table 0x1552 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x1590 build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0x1595 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x16ae build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0x16b3 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x1768 build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0x176d build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x17a6 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x1850 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x188a build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x1a74 build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0x1a79 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x1ace build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0x1ad3 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x1b8d build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0x1b92 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x1c88 build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0x1c8d build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x1ceb build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x1d54 build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0x1d59 build/temp.solaris-2.8-i86pc-2.1/structmodule.o struct__doc__ 0x204d build/temp.solaris-2.8-i86pc-2.1/structmodule.o struct_methods 0x2052 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2057 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2084 build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0x2093 build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0x2099 build/temp.solaris-2.8-i86pc-2.1/structmodule.o StructError 0x20a8 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x20ae build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x270 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x274 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x278 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x27c build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x280 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x284 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x288 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x28c build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x290 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x294 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x298 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x29c build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2a0 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2a4 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2a8 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2ac build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2b0 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2b4 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2b8 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2bc build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2c0 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2c4 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2c8 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2cc build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2d0 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2d4 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2d8 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2dc build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2e0 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2e4 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2e8 build/temp.solaris-2.8-i86pc-2.1/structmodule.o 0x2ec build/temp.solaris-2.8-i86pc-2.1/structmodule.o _xstat 0x14 build/temp.solaris-2.8-i86pc-2.1/structmodule.o _lxstat 0x3c build/temp.solaris-2.8-i86pc-2.1/structmodule.o _fxstat 0x64 build/temp.solaris-2.8-i86pc-2.1/structmodule.o _xmknod 0x8d build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyInt_AsLong 0xae build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_Occurred 0xc1 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_Occurred 0x13d build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_Occurred 0xd96 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_Occurred 0xe0e build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_Occurred 0xe79 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_Occurred 0x1106 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_Occurred 0x1182 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_Occurred 0x1416 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_Occurred 0x1496 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyExc_TypeError 0xcf build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyExc_TypeError 0xe87 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyExc_TypeError 0x1855 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_ExceptionMatches 0xd5 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_ExceptionMatches 0xe8d build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0xf1 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0x22f build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0x259 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0x423 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0x450 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0xaaf build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0xb1b build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0xb77 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0xbf3 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0xc63 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0xdaf build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0xe27 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0xea9 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0x111f build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0x119b build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0x142f build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0x14af build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0x159b build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0x16b9 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0x1773 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0x185b build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0x1a7f build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0x1ad9 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0x1b98 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0x1c93 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_SetString 0x1d5f build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyLong_Type 0x11c build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyLong_AsUnsignedLong 0x12a build/temp.solaris-2.8-i86pc-2.1/structmodule.o frexp 0x1c0 build/temp.solaris-2.8-i86pc-2.1/structmodule.o frexp 0x3b4 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyExc_SystemError 0x229 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyExc_SystemError 0x41d build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyExc_OverflowError 0x253 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyExc_OverflowError 0x44a build/temp.solaris-2.8-i86pc-2.1/structmodule.o ldexp 0x28c build/temp.solaris-2.8-i86pc-2.1/structmodule.o ldexp 0x483 build/temp.solaris-2.8-i86pc-2.1/structmodule.o ldexp 0x6cf build/temp.solaris-2.8-i86pc-2.1/structmodule.o ldexp 0x84e build/temp.solaris-2.8-i86pc-2.1/structmodule.o floor 0x2ed build/temp.solaris-2.8-i86pc-2.1/structmodule.o floor 0x4e0 build/temp.solaris-2.8-i86pc-2.1/structmodule.o floor 0x52e build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyFloat_FromDouble 0x6f4 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyFloat_FromDouble 0x873 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyFloat_FromDouble 0x9f4 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyFloat_FromDouble 0xa30 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyString_FromStringAndSize 0x894 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyString_FromStringAndSize 0x18ee build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyString_FromStringAndSize 0x1eba build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyString_FromStringAndSize 0x1f13 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyInt_FromLong 0x8b9 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyInt_FromLong 0x8dd build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyInt_FromLong 0x901 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyInt_FromLong 0x925 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyInt_FromLong 0x948 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyInt_FromLong 0x994 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyInt_FromLong 0xf44 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyInt_FromLong 0xfc4 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyInt_FromLong 0x124c build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyInt_FromLong 0x12cc build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyInt_FromLong 0x1800 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyLong_FromUnsignedLong 0x972 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyLong_FromUnsignedLong 0x9b8 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyLong_FromUnsignedLong 0xfad build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyLong_FromUnsignedLong 0x12b5 build/temp.solaris-2.8-i86pc-2.1/structmodule.o memcpy 0x9e0 build/temp.solaris-2.8-i86pc-2.1/structmodule.o memcpy 0xa1c build/temp.solaris-2.8-i86pc-2.1/structmodule.o memcpy 0xdce build/temp.solaris-2.8-i86pc-2.1/structmodule.o memcpy 0xe46 build/temp.solaris-2.8-i86pc-2.1/structmodule.o memcpy 0x1b2e build/temp.solaris-2.8-i86pc-2.1/structmodule.o memcpy 0x1bef build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyLong_FromVoidPtr 0xa54 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyString_Type 0xb48 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyString_Type 0x1ac4 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyString_Type 0x1b83 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyString_Size 0xb56 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyString_Size 0x1af0 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyString_Size 0x1bb0 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyString_AsString 0xb90 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyString_AsString 0x191d build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyString_AsString 0x1b1f build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyString_AsString 0x1bdf build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyFloat_AsDouble 0xd76 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyFloat_AsDouble 0xdee build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyFloat_AsDouble 0x10e6 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyFloat_AsDouble 0x1162 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyFloat_AsDouble 0x13f6 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyFloat_AsDouble 0x1476 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyLong_AsVoidPtr 0xe66 build/temp.solaris-2.8-i86pc-2.1/structmodule.o __ctype 0x1622 build/temp.solaris-2.8-i86pc-2.1/structmodule.o __ctype 0x194e build/temp.solaris-2.8-i86pc-2.1/structmodule.o __ctype 0x1dba build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyArg_ParseTuple 0x17af build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyArg_ParseTuple 0x1cf4 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyTuple_Type 0x1827 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyTuple_Size 0x1835 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyTuple_GetItem 0x1876 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyTuple_GetItem 0x1a9b build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyArg_Parse 0x1893 build/temp.solaris-2.8-i86pc-2.1/structmodule.o memset 0x1a54 build/temp.solaris-2.8-i86pc-2.1/structmodule.o memset 0x1b55 build/temp.solaris-2.8-i86pc-2.1/structmodule.o memset 0x1c17 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyList_New 0x1d76 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyList_Append 0x1f7f build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyList_AsTuple 0x1fd8 build/temp.solaris-2.8-i86pc-2.1/structmodule.o Py_InitModule4 0x205c build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyModule_GetDict 0x2070 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyErr_NewException 0x2089 build/temp.solaris-2.8-i86pc-2.1/structmodule.o PyDict_SetItemString 0x20b7 build/temp.solaris-2.8-i86pc-2.1/structmodule.o ld: fatal: relocations remain against allocatable but non-writable sections collect2: ld returned 1 exit status Text relocation remains referenced against symbol offset in file filler.18 0x235 build/temp.solaris-2.8-i86pc-2.1/regexmodule.o Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From mwh at python.net Fri Jun 8 07:40:23 2001 From: mwh at python.net (Michael Hudson) Date: 08 Jun 2001 12:40:23 +0100 Subject: How can I extend raw_input to provide user w/ default input string? References: <9fmgli$43f$1@peabody.colorado.edu> <3B1F0D82.DB10E008@yahoo.com> <9fo6g6$36v$1@peabody.colorado.edu> Message-ID: Skip Montanaro writes: > >> However, I was thinking about presenting the user with a default > >> input and give him/her the ability to edit it. Maybe I should think > >> about using Tkinter if this is impossible to do using a console > >> interface. > > Alex> You might want to check out the readline module. > > I don't think that works. I asked about it a few months ago and got a > negatory response from Guido. (Not that it wouldn't be useful, just that > the readline module doesn't support it.) > > There have been a couple packages announced here in the past month or so > that are readline replacements. One of them could probably be coerced into > providing default values for console inputs. Mine[1] certainly can. But it's unixoid only at the moment, and while porting to windows would be possible, it would be non-trivial and hasn't been done. I was under the impression that the OP was on Windows. Might have been wrong though. Cheers, M. [1] Pyrepl: http://starship.python.net/crew/mwh/hacks/pyrepl.html -- BUGS Never use this function. This function modifies its first argument. The identity of the delimiting character is lost. This function cannot be used on constant strings. -- the glibc manpage for strtok(3) From ullrich at math.okstate.edu Thu Jun 7 10:36:14 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Thu, 07 Jun 2001 14:36:14 GMT Subject: random References: <3b1cf00f.5441109@nntp.sprynet.com> <3b1e43f4.1661099@nntp.sprynet.com> <9flldm01o6s@enews2.newsguy.com> Message-ID: <3b1f8e08.2031514@nntp.sprynet.com> On Wed, 6 Jun 2001 18:23:17 +0200, "Alex Martelli" wrote: >"David C. Ullrich" wrote in message >news:3b1e43f4.1661099 at nntp.sprynet.com... > ... >> I didn't bother mentioning the semantics before getting straight >> whether the syntax counted as "self-delimiting". It is very >> easy to design a Turing-complete programming language where >> the syntactically valid programs are exactly the bitstrings >> consisting of all 0's terminated by a 1. Assunming that > >If so, then the set of Turing-machine program must be >enumerable (alpha-0). But is it? > >> "arbitrary binary data" means only finitely much binary >> data that's no problem. > >I think there is the rub. > >What I find in the "Stanford Encyclopedia of Philosophy", e.g: > >""" >A Turing machine is an abstract representation of a computing >device. It consists of a read/write head that scans a (possibly >infinite) two-dimensional tape divided into squares, each of >which is inscribed with a 0 or 1. Computation begins with the >machine, in a given "state", scanning a square. It erases what >it finds there, prints a 0 or 1, moves to an adjacent square, >and goes into a new state. This behavior is completely determined >by three parameters: (1) the state the machine is in, (2) the number >on the square it is scanning, and (3) a table of instructions. The >table of instructions specifies, for each state and binary input, >what the machine should write, which direction it should move in, >and which state it should go into. (E.g., "If in State 1 scanning >a 0: print 1, move left, and go into State 3".) The table can list >only finitely many states, each of which becomes implicitly defined >by the role it plays in the table of instructions. These states are >often referred to as the "functional states" of the machine. >""" > >Finite-state machine at the 'core', infinite tape (sorry I >used more than two tape symbols in my previous post and >assumed an 'output' that was not to the tape itself, but >I believe it's easily proved that you can map any finite >number of tapesymbols to two, and use [e.g] even squares >of the tape as 'input' aka 'program' and odd ones for >'output', etc, etc). This is the TM (not yet necessarily >Universal, all depends on that FSM at the core) as I >recalled it, after lo these many years... Whether there are countably many Turing machines or uncountably many depends on whether the tape itself is considered part of the TM. I've seen plenty of definitions that appear to say that the tape is part of the TM. I've also seen it said in plenty of places that there are only countably many Turing machines. Could be that this means that people use the word "TM" inconsistently. It would be a big surprise if that were the one word in the language that _is_ used consistently. I have no interest in debating whether it's correct or not to include the tape as part of the machine or to regard the tape as something external to the machine that the machine manipulates. _In_ the sense in which I was using the words, the TM is the finite-state machine and the tape is something that the TM manipulates. Regarding the question of which usage is really the usage that's been intended in all of this discussion: Does there or does there not exist a TM which will calculuate all the bits of Chaitin's Omega? You start it running and the bits appear one by one, continuing until you pull the plug. (The standard answer is "no". If the tape is part of the machine then the answer is "yes": You just consider the TM that starts with Omega on the tape, and which does nothing but echo its input. I'll let you decide whether this means that "TM" really has referred to the finite-state machine or whether when people say there is no TM to calculate Omega they should really say there is no TM-with-initially-blank-tape. But if you insist on calling the tape part of the "program" (this is still in the non-UTM context), as in >and use [e.g] even squares >of the tape as 'input' aka 'program') then there _is_ a "program" to calculate the bits of Omega. It seems to me that this indicates that the usual meaning of the word "program" is not what you're taking it to be. Don't know whether it indicates anything like that to you.) >[E.g. to treat even and odd squares differently you "just" >have to split the core FSM appropriately, so it 'remembers' >whether it's on an odd or even square of the tape -- that >is just one bit so at most it doubles the FSM's states -- >doing it all with 0 and 1 is unwieldy but you can move >to any finite number of symbols by using N squares with >0 and 1 to represent up to 2**N distinct symbols and >complicating the FSM accordingly -- etc, etc... but of >course it's possible to slip in one of these "etc"s:-)] > > >Alex > > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From thomas at cintra.no Sat Jun 16 14:20:24 2001 From: thomas at cintra.no (Thomas Weholt) Date: Sat, 16 Jun 2001 18:20:24 GMT Subject: Slightly Off Topic : restrictions on the response part in a SOAP-response Message-ID: Hi, Just wondering if I could put whatever XML I want into the response-part of a SOAP-response. Like : ... HUGE amount of XML-data ... The examples I've seen so far is more like calling a function that adds to numbers and returns the sum. In real life I'd like to return a bit more info in each request. Thomas From ng at fnmail.com Thu Jun 14 17:24:52 2001 From: ng at fnmail.com (Enrico Ng) Date: Thu, 14 Jun 2001 16:24:52 -0500 Subject: wrapping a C++ class Message-ID: <9gba7n$8jj$1@info1.fnal.gov> I am trying to wrap a simple C++ class like this: class mymath { int x, y; public: void set_values(int a, int b) {x=a;y=b;} int add(void) {return (x+y);}}; The thing is, I'm not sure how to wrap this. I am assuming the self is the pointer for the class that gets passed. But I dont think I am casting it correctly here. Here is my wrapper code: #include "Python.h" #include "test.cpp" extern "C" { static PyObject *wrap_add(PyObject *self, PyObject *args) { PyObject *Pyresult; mymath *arg0 = (mymath*) self; if (!PyArg_ParseTuple(args, ":add")) return NULL; Pyresult = PyInt_FromLong((long)arg0->add()); return Pyresult; } static PyObject *wrap_set_values(PyObject *self, PyObject *args) { mymath *arg0 = (mymath*) self; int arg1; file://var for argument int arg2; file://var for argument if (!PyArg_ParseTuple(args, "ii:set_values",&arg1,&arg2)) return NULL; arg0->set_values(arg1,arg2); Py_INCREF(Py_None); return Py_None; } static PyMethodDef testMethods[] = { { "add", wrap_add, METH_VARARGS }, { "set_values", wrap_set_values, METH_VARARGS }, { NULL, NULL } }; void inittest() {Py_InitModule("test", testMethods);} } -- Enrico Ng Fermilab - WH 13X From m.hadfield at niwa.cri.nz Thu Jun 7 18:48:56 2001 From: m.hadfield at niwa.cri.nz (Mark Hadfield) Date: Thu, 7 Jun 2001 22:48:56 +0000 (UTC) Subject: ActivePython and WSH problem References: Message-ID: <004201c0efa4$040c3dc0$d938a8c0@Hadfield> From: "JohnB" > I installed ActivePython under NT and believe that the following .wsf file > should work: > ... > However, on running it, the following error is displayed "...pytest.wsf(6, > 14) Windows > Script Host: The value for the attribute is not valid : language". Open this file in Internet Explorer ...\Python21\win32comext\axscript\demos\client\ie\demo_check.htm and it will probably tell you your Python scripting engine is not registered. There's a reference there to a .py file you should run to register it --- Mark Hadfield m.hadfield at niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield National Institute for Water and Atmospheric Research -- Posted from clam.niwa.cri.nz [202.36.29.1] via Mailgate.ORG Server - http://www.Mailgate.ORG From Richard.Suchenwirth at kst.siemens.de Wed Jun 20 09:35:03 2001 From: Richard.Suchenwirth at kst.siemens.de (Richard.Suchenwirth) Date: Wed, 20 Jun 2001 15:35:03 +0200 Subject: How to change codepage (encoding) in Tcl/Tk References: <44da3708.0106192258.623311a7@posting.google.com> Message-ID: <3B30A687.197D30E9@kst.siemens.de> Peteris Martinsons wrote: > > I have a UI form, written in BeOpen Python 2.1 with Tcl/Tk that has 4 > text boxes. > I want 2 of them to display text in English and 2 in Russian. Is this > possible? If Yes, how do I do this? Which is the property to alter? In Tcl/Tk, all strings are internally represented as Unicode/UTF-8. This extends to text in Tk widgets as well - if you just have at least one font that "implements" a certain Unicode, Tk widgets will happily display it without any need for configuration. So, to put some Russian into a text widget in Tcl, just say .t insert end \u0413\u0414\u041F Other encodings will however come into play when doing file I/O (including stdin/out). Want to read a Russian text file in koi-8 encoding? set f [open $filename] fconfigure $f -encoding koi8-r ;# this is important! set text [read $f] close $f For a converter from 7-bit ASCII encoding to Russian Unicodes, see "Ruslish", http://mini.net/cgi-bin/wikit/712.html -- Schoene Gruesse/best regards, Richard Suchenwirth - +49-7531-86 2703 Siemens Dematic AG, PA RC D2, Buecklestr.1-5, 78467 Konstanz,Germany Personal opinions expressed only unless explicitly stated otherwise. From peteris_martinsons at swh-t.lv Wed Jun 20 02:58:50 2001 From: peteris_martinsons at swh-t.lv (Peteris Martinsons) Date: 19 Jun 2001 23:58:50 -0700 Subject: How to change codepage (encoding) in Tcl/Tk Message-ID: <44da3708.0106192258.623311a7@posting.google.com> I have a UI form, written in BeOpen Python 2.1 with Tcl/Tk that has 4 text boxes. I want 2 of them to display text in English and 2 in Russian. Is this possible? If Yes, how do I do this? Which is the property to alter? Peteris From mlunnay at bigpond.net.au Fri Jun 1 21:38:33 2001 From: mlunnay at bigpond.net.au (Michael Lunnay) Date: Sat, 02 Jun 2001 01:38:33 GMT Subject: Sourceforge break-in and Python 2.1 security References: Message-ID: If you are worried about the authenticity of your download you can check them against the md5's posted on the Python site, on the downloads page. Michael "Andres Corrada-Emmanuel" wrote in message news:mailman.991424169.12492.python-list at python.org... > Hello, > > I've been reading the reports of the break-in into SourceForge with > increasing alarm and I'm wondering if there is a security protocol in > place that guarantees the integrity of the Python code being developed > there. > > That is, should I worry that "Fluffy Bunny" claims that he broke into > SourceForge 5 months ago and I downloaded Python 2.1 after that? > > -- > ------------------------------------------------------ > Dr. Andres Corrada email: andres at mamey.com > Mamey - Internet Programming http://www.mamey.com > ------------------------------------------------------ > -- > From new_name at mit.edu Sun Jun 24 08:39:49 2001 From: new_name at mit.edu (Alex) Date: 24 Jun 2001 08:39:49 -0400 Subject: emacs speedbar for python mode? References: <9h24tq$f7b$1@news1.xs4all.nl> <9h2o5m$8is$1@news1.xs4all.nl> Message-ID: Oh. perhaps it's that I'm using FSF emacs, then. Thanks. Alex. From db3l at fitlinxx.com Fri Jun 1 22:27:07 2001 From: db3l at fitlinxx.com (David Bolen) Date: 01 Jun 2001 22:27:07 -0400 Subject: Copying files to multiple comp's on a lan References: <9f8k3v$1i04$1@news.cybercity.dk> <16074dce.0106011606.4a7b987d@posting.google.com> Message-ID: chat at linuxsupreme.homeip.net (Chad Everett) writes: > On 1 Jun 2001 17:06:02 -0700, Jeff Shannon wrote: (...) > > # note Win32 uses \, not / :) > > machines = [ "\\Mach1\C" , "\\Mach2\C" , "\\Mach3\C" ] But note that you have to make these raw strings or double quote the \ for those strings to work. (E.g., either r"\\Mach1\C" or "\\\\Mach1\\C") > It also presumes you're using Microsoft networking. True, but the original requester specifically mentioned Windows, so that's probably a reasonable bet. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From brakedon at hotmail.com Thu Jun 7 18:14:27 2001 From: brakedon at hotmail.com (eric_brake) Date: 7 Jun 2001 15:14:27 -0700 Subject: Error checking for 'raw_input( )'? References: <7b515e0f.0106060455.4093daa0@posting.google.com> <9flcus01b04@enews2.newsguy.com> <7b515e0f.0106061427.2386067f@posting.google.com> <9fni1a012nk@enews2.newsguy.com> Message-ID: <7b515e0f.0106071414.5fed7276@posting.google.com> > for example. Is THIS what you want to do...? I'm having > a somewhat hard time understanding your specs, I'll admit, > so making them clearer might help. Thanks for the help, just trying to tie up any possible errors without adding to much to the code I have. :) From SBrunning at trisystems.co.uk Mon Jun 11 06:35:41 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Mon, 11 Jun 2001 11:35:41 +0100 Subject: newbe question Message-ID: <31575A892FF6D1118F5800600846864D78BD15@intrepid> > From: scott snider [SMTP:kklzfan at yahoo.com] > is there a good book or web site that explanes and > teaches python in a step by step way so that when you > are finished with the book or site you have a fully > functioning program? If you haven't programmed before, check out Alan Gauld's 'Learning to Program' at . This teaches Python to complete beginners. If you have programmed before, try 'Dive into Python at . Links to *loads* of tutorials can be found at . And don't forget the Python tutor mailing list, at . Well worth joining if you are learning Python. Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From scarblac at pino.selwerd.nl Tue Jun 5 10:31:10 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 5 Jun 2001 14:31:10 GMT Subject: httplib design question References: Message-ID: Gustaf Liljegren wrote in comp.lang.python: > Why doesn't the HTTP method handle this check instead? I think this is because a new connection is needed for every request. If you simply need to get things, try urllib. -- Remco Gerlich From tim.one at home.com Sat Jun 2 16:13:51 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 2 Jun 2001 16:13:51 -0400 Subject: Inexact representation cases (Re: Against PEP 240) In-Reply-To: <20010602102825.A24372@doublegemini.com> Message-ID: [Clark C . Evans] > >>> 1.1 > 1.1000000000000001 > >>> 7.35 > 7.3499999999999996 > > What is the general pattern for these types > of inexact represenatation? Unsure what you're looking for. In general, a non-zero decimal number D is exactly representable in a binary fp format if and only it can be written in the form D = I/2**J for some (possibly large) integers I and J, and where the possible values of I and J are constrained by how many bits the fp format devotes to them. For IEEE-754 doubles (which is what a Python float becomes on most machines), it must have 1 <= I < 2**53 (that is, I has no more than 53 bits), and the range on J is roughly plus or minus 1000 (yes, it can be made exact, but who cares ). So look at 1.1 == 11/10. Can that be written in the form I/2**J? If so, then 11*2**J == 10*I too. 5 divides 10 evenly, so also divides 10*I. But if 10*I == 11*2**J and 5 divides the left side, then 5 must also divide the right side. But 5 doesn't divide 11 or 2**J, so can't (because 5 is prime) divide their product evenly either. IOW, no matter how many bits you use, 1.1 can't be represented exactly in a binary fp format. It turns out that the closest you can get in IEEE double is 1.1 ~= 2476979795053773 / 2**51 which is, as a *decimal* number, *exactly* 1.100000000000000088817841970012523233890533447265625 *Rounding* that to 17 significant decimal digits is where 1.10000000000000001 comes from in the display. Similarly the best double approximation to 7.35 is 4137682157646643 / 2**49 which is exactly 7.3499999999999996447286321199499070644378662109375 in decimal, which rounds to 7.3499999999999996 for display. Note that the situation isn't symmetric: not every finite decimal fraction is exactly representable as a finite base 2 fraction, but every finite binary fraction *is* exactly representable as a finite base 10 fraction (if you start with I/2**J, just multiply top and bottom by 5**J to get (I*5**J)/10**J). But afraid that's just another stumbling block at first ... From carlf at panix.com Fri Jun 8 15:05:00 2001 From: carlf at panix.com (Carl Fink) Date: 8 Jun 2001 19:05:00 GMT Subject: Use Jython to make true executable? Message-ID: I'm a Python beginner, so forgive me if this question is stupid. A common request on this group is a true compiler to convert a Python script to a directly-executable program. (ELF for Linux, .exe for Windows/DOS, etc.) There apparently used to be a python2c project which was abandoned. Couldn't you develop your program in Jython, "compile" it to Java bytecodes, then run them through GCC? I haven't tried it, but I've read that GCC can convert Java to direct executables. Now, I also am far from a Java expert. For instance, would Swing be convertible using GCC given that it's not free software? So, is this idea so obvious that it has to have a flaw? -- Carl Fink carlf at dm.net I-Con's Science and Technology Programming From not.this at seebelow.org Fri Jun 1 13:30:27 2001 From: not.this at seebelow.org (Grant Griffin) Date: 1 Jun 2001 10:30:27 -0700 Subject: redemo won't close on me Message-ID: <9f8jfj0qj@drn.newsguy.com> Hi Gang, I've experienced a problem with ActivePython 2.1 running on WindowsME <> wherein it won't close the Python interpreter window when I run "redemo.py" (which is a Tkinter app); the only thing I can do is pull the plug. I haven't had a chance to experiment with this to pin it down as being an ActivePython problem, a 2.1 problem, a Tkinter problem, a WindowsME problem <> or a redemo.py problem, but I _have_ run redemo.py successfully on other combinations of Python version, Python distribution, and OS. Has anybody else run into this problem? What's the cure (besides switching OS'es...)? bill-gates'-fiendish-plan-not-to-put-usb-support-into-nt -snags-yet-another-poor-dumb-sucker-ly y'rs, =g2 _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From bill-bell at bill-bell.hamilton.on.ca Wed Jun 20 14:38:09 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Wed, 20 Jun 2001 14:38:09 -0400 Subject: Sufficient conditions for COM local server to be singleton In-Reply-To: <992994169.401.32981.l6@yahoogroups.com> Message-ID: <3B30B551.5747.78FEA9@localhost> My essential question is: I had understood from reading previous discussions on this list that, by default, to make a COM local server fire up in only a single copy it is only necessary to declare "_reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER". However, this doesn't seem to do the trick. The following is a slightly altered version of the "Final Sample" server code from Chapter 12 of the Hammond & Robinson Win32 book (O'Reilly). from win32com.server.util import wrap, unwrap import win32com.client, pythoncom debugging = 0 if debugging: from win32com.server.dispatcher import DefaultDebugDispatcher useDispatcher = DefaultDebugDispatcher else: useDispatcher = None class Parent: _public_methods_ = ['CreateChild', 'KissChild'] _reg_clsid_ = "{41A0B351-A708-48c2-9E12-56C4291E0F42}" _reg_progid_ = "PythonDemos.Parent" _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER def __init__(self): import time self.StartTime = time.asctime() def CreateChild(self): child = Child() child.Name = self.StartTime print "Our Python child is ", child wrapped = wrap( child, useDispatcher=useDispatcher ) print "Returning wrapped ", wrapped return wrapped def KissChild(self, child): print "KissChild called with child ", child dispatch = win32com.client.Dispatch(child) print "KissChild called with child named ", dispatch.Name child = unwrap(child) print "The Python child is ", child class Child: _public_methods_ = [] _public_attrs_ = ['Name'] def __init__(self): self.Name = "Unnamed" if __name__=='__main__': import win32com.server.register win32com.server.register.UseCommandLine(Parent, debug=debugging) I have just verified (using 'diff') that the only differences between this code and the original version of it are the following: 1. 'pythoncom' is imported (in order to have access to the constant mentioned at the beginning of this message). 2. 'debugging' is set to 0 (rather than 1, to switch off debugging) 3. different CLSID 4. _reg_clsctx_ is set as mentioned above 5. an __init__ is added to the Parent class to save instantiation time in an instance variable 6. CreateChild() sets name of child to Parent instantiation time. When I inhibit complete execution of the following code (by setting a break on its final line in PythonWin) and run the same code meanwhile in a DOS box Parent is created twice, as evidenced by the different times for the names of the children. import win32com.client, msvcrt, pythoncom ParentObj = win32com.client.Dispatch("PythonDemos.Parent") child = ParentObj.CreateChild() print "DRIVECHAPTER12.PY: Child's name is ", child.Name ParentObj.KissChild(child) print "DRIVECHAPTER12.PY: I kissed my child" pass My apologies for returning so often to this topic! From pras_patel at yahoo.com Thu Jun 28 01:07:40 2001 From: pras_patel at yahoo.com (prashant patel) Date: 27 Jun 2001 22:07:40 -0700 Subject: Web Application framework (python/java) References: Message-ID: "Colin Meeks" wrote in message news:... > You might want to have a look at http://www.programmedintegration.com. This > site is generated entirely in Python. We developed our own solution as we > couldn't find anything that worked the way we did. I'd be more than happy to > answer any specific questions you have. > > Colin > > "prashant patel" wrote in message > news:ef87e612.0106262052.5c9f068e at posting.google.com... > > I am Intrested in created a web application famework, on which and > > developer,a web novice and created his application. I also wanted to > > make it in python. since i have my skill in java, it is also a > > potential. but since python is more productive i would like to make it > > in python, also the time constraint in which i have to devliver this > > product. My question is java has a lot of web related > > tools, since i am new to python i am not familair with the web > > libraries in python,also going through core python programming quickly > > to find out what i can do with it. i want to do it in python, can it > > be a language to concieve the > > "web application famework". please give your thought and suggestion. > > prashant. My boss want me to deliver a product, that also fast. i figured that in the give context insted of java i will use python. Now create a level of abstraction (i.e a framework) on that the user can reach another level of abstraction using the framework, what he get is his desired application. now to start with a customer such as a web developer , a hr manager(to manage the office chores) anything. Though the sprectrum in pretty wide initailly it could be narrowed to to just on type of customer and go on building. I have not tried zope, can it create such a appl. But diffrent type of business calls for diffrent work arounds this is what i want to achive. May be two or there type of customer. please let me now you comments. From pinard at iro.umontreal.ca Sun Jun 24 00:42:51 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 24 Jun 2001 00:42:51 -0400 Subject: Python scripting [was: Re: emacs speedbar for python mode?] In-Reply-To: <9h2bo2$335$1@news1.xs4all.nl> References: <9h24tq$f7b$1@news1.xs4all.nl> <9h2bo2$335$1@news1.xs4all.nl> Message-ID: [Boudewijn Rempt] > Thank! I've only just bit the bullet and started to use emacs - after > I found out there really isn't an alternative for writing docbook. > I do wish I hadn't put it off for so long, though. I've used vi and > nedit for more than half a decade... If I could only script Emacs with Python! Emacs LISP is not so bad, it has a lot of virtues, yet writing Scheme or Python is more pleasurable to me. Of course, I'm a bit aware of the Guile project. Why not Python, then? In these days, soon in the morning, before I'm fully awake, I vaguely dream of big things, like developing semi-automatic Emacs LISP to Python converters (a bit like CWeb does for Knuth Pascal code) and with this, whatever would be necessary to replace or interface with the Emacs C core. :-) In my dreams still, I start the exercise with Gnus or Calc, as the result would be quite useful in itself. Sigh! By the way, and despite I'm awake by now, did someone ever benchmarked Python vs Emacs LISP for comparable algorithms, at least speed-wise, and maybe memory-wise also? -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From jp at ulgo.koti.com.pl Sat Jun 16 04:07:45 2001 From: jp at ulgo.koti.com.pl (Jacek =?iso-8859-2?Q?Pop=B3awski?=) Date: 16 Jun 2001 08:07:45 GMT Subject: Pmw: how to clear ScrolledListBox ? Message-ID: I add items by .insert, what is correct way to remove all items? -- She never breaks into the conversation He seems to be the reason why she lives She tries to be the perfect kind of stranger But we always seem to love the most The ones who never give "Between Two Hearts" - Ronnie James Dio From akuchlin at mems-exchange.org Fri Jun 29 10:18:19 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 29 Jun 2001 10:18:19 -0400 Subject: PEP scepticism References: Message-ID: <3dbsn71iac.fsf@ute.cnri.reston.va.us> "Tim Peters" writes: > So what do you do about the curious disconnect between supply and demand in > Open Source projects? You got list comprehensions because Greg Ewing (and Beats me. This is nothing new, in that interesting tasks get worked on, and boring ones don't. I haven't updated the bookstore in a while, or tried to kick the catalog-sig into life, or released various bits of software sitting on my disk, because such tasks would be pretty boring, and I have more entertaining possibilities open to me. Greg Ward moved back to Montreal, and now does practically no hacking or writing in his spare time at all. Unfortunately, practically *everyone* considers these tasks dull. --amk (www.amk.ca) "For interrogation? Good, I enjoy interrogations." "Yes, you look the type." -- General Raven and the Doctor, in "Genesis of the Daleks" From philh at comuno.freeserve.co.uk Sun Jun 17 20:37:29 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Mon, 18 Jun 2001 01:37:29 +0100 Subject: Two minor syntactic proposals References: Message-ID: On Mon, 18 Jun 2001 00:18:07 +0100, Gareth McCaughan wrote: >> qclass Thing: >> insvar v, w >> def myMethod(p): >> print p, v, x >> def otherMethod(): >> myMethod(1) >> someFunction() >> >> would be equivalent to: >> >> class Thing: >> def myMethod(self, p): >> print p, self.v, x >> def otherMethod(self): >> self.myMethod(1) >> someFunction() > >I confess that my initial reaction is "eeurgh", which may well >be how others react to my proposals. Quite possibly. Bear in mind that about half of all syntax errors I have with Python as missing out "self"s. > I think your qclass/insvar >proposal breaks the following principles of Pythonic style: > > - "Explicit is better than implicit" (one of the timbots > rules from way back). "self" really *is* a function argument, > and eliminating all mention of it feels uncomfortable. > Not to mention that "qclass" binds "self" without saying > so. Is there anything else in Python that binds things > that it doesn't mention? I can't think of any right now. > > - "No cryptic identifier names". Why "qclass"? Why not > "xclass" or "zclass"? (Does the "q" actually stand for > something?) "Quick" actually. > How easy will it be to remember that it's > "insvar", not "instvar" or "insvars"? good question. Perhaps "instance" or "var" would be better. >> Note that a qclass definition would have to know what its methods and instance >> variables were, including those inherited from superclasses, for this to work. >> Is this feasible? > >I don't understand what you mean by "know what its instance variables >are"; new instance variables can materialize on the fly on a per-class >or per-instance basis. I know that. I mean the defined ones. >Anyway, why would it need to know that? I was thinking in terms of a preprocessor that changes my language (q-Python or whatever you want to call it, into python) Say it has a line: print x (in q-python) It needs to know whether this means, in Python: (1) print self.x or (2) print x It all depends on whether x is a defined instance variable. -- ## Philip Hunt ## ## philh at comuno.freeserve.co.uk ## From atodd at spam.free.email.com Tue Jun 26 21:56:49 2001 From: atodd at spam.free.email.com (Andy Todd) Date: Wed, 27 Jun 2001 01:56:49 GMT Subject: zodb install problem on Windows References: Message-ID: "Neil Hodgson" wrote in : [snip definition of install problem] > > Which is caused by the Unix specific: > > data_files = [("etc", ["zeo.conf"]), > ("/etc/rc.d/init.d", ["misc/zeo"]), > ("/usr/local/bin", ["misc/zeod"]), > ] > > Any ideas on how to install on Windows? > > Neil > > > Hi all, I'm failing terribly here. I've commented out that section of the setup.py file for the ZEO module and everything seems to have installed correctly. But now I am getting an error; """ >>> import ZODB Traceback (most recent call last): File "", line 1, in ? File "ZODB\__init__.py", line 85, in ? import sys, ExtensionClass, TimeStamp, cPersistence, Persistence ImportError: No module named ExtensionClass >>> """ If I go into the "ExtensionClass" directory and try and run "python setup.py build" I get the following output; """ running build running build_py not copying src\Xaq.py (output up-to-date) running build_ext building 'ExtensionClass' extension cl.exe /c /nologo /Ox /MD /W3 /GX -IC:\PROGRAMMING\PYTHON21\Include /Tcsrc/ExtensionClass.c /Fobuild\temp.win32-2.1\Release\ExtensionClass.obj error: command 'cl.exe' failed: No such file or directory """ Any suggestions? Thanks in advance, Andy -- Content free posts a speciality From sholden at holdenweb.com Mon Jun 18 12:08:56 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 18 Jun 2001 12:08:56 -0400 Subject: Loading select queries into objects References: Message-ID: >From http://www.lyra.org/greg/python/: """dtuple.py This module wraps up return tuples from the fetch* methods in the Python Database API. Using this class, the return tuples can be treated as tuples, dictionaries, or objects with attributes corresponding to the column names. The module is memory efficient -- a "tuple descriptor" is shared across all result rows, and the result row "wrapper" is very lightweight. The speed is quite reasonable. """ Thanks to Greg Stein for an excellent solution to this problem. regards Steve -- http://www.holdenweb.com/ "Graham Ashton" wrote in message news:yCmX6.1448$h45.8877 at news.uk.colt.net... > Hi. I've just started playing with database access from Python and have > stumbled across yet another hole in my knowledge of Python idioms. > > I've got a class that has an attribute for each column in a database > table, and an accessor method that sets the value of each attribute. I > then populate the attributes with the result of a database query. > > Here's an example: > > query = """ > SELECT column1, column2, some_column > FROM a_table > """ > > cursor = self.db.cursor() > cursor.execute(query) > tup = cursor.fetchone() > > self.column1(tup[0]) # this could be better! > self.column2(tup[1]) > self.some_column(tup[2]) > > What I'm wondering is; is there an idiomatic way of applying the values > in a tuple to a list of functions? In Perl I'd use map(), but I'm not > sure if there's a "cleaner" way in Python. > > When the number of columns grows large the above is not only ugly, but a > nightmare to maintain. > > Thanks. From Emmanuel.Goldstein at web.de Wed Jun 27 12:46:06 2001 From: Emmanuel.Goldstein at web.de (Emmanuel.Goldstein at web.de) Date: Wed, 27 Jun 2001 16:46:06 GMT Subject: Changing the PDF Info-block References: <9h1ro8$bk9vc$1@ID-3710.news.dfncis.de> <9h2bel$bblq4$1@ID-7529.news.dfncis.de> Message-ID: <9hd2g0$d0lb1$1@ID-3710.news.dfncis.de> "Karl M. Syring" wrote: >Thew only free solution I know of is the Etymon PJ >(http://www.etymon.com/pj/). It is written in Java, but even this may not be >a showstopper. > >Karl M. Syring > Thank you for the tip. It seems to be exactly what I need. Jan From lac at cd.chalmers.se Fri Jun 1 02:01:52 2001 From: lac at cd.chalmers.se (Laura Creighton) Date: Fri, 1 Jun 2001 08:01:52 +0200 (MET DST) Subject: docstrings, invention there of Message-ID: <200106010601.IAA08860@boris.cd.chalmers.se> We think we were the first people to ever a) put the doc in the code b) make the interpreter extract them. We haven't been able to find anybody earlier than us, at any rate. If somebody is out there, I hope he is reading this newsgroup so we can find out. You _know_ when you are not first, the rest of the time you just wonder. I was working for Sun when Gosling was making Oak which became Java. (I think. They were in a different building and I wasn't quite sure what they were doing at the time ... so maybe this was _before_ Oak was being made.) I do not think that I showed him Genesis directly, but we were in the same community at the same time --- and even if I left Sun before Genesis got docstrings, I pretty well infected everybody I knew about Genesis as soon as I found out about it, and the number of people Gosling and I have in common fit comfortably in a large football stadium. At some incredibly early Java conference that Sun put on somebody got up and asked where they came from and they said, er, some MUD, and then somebody else at the conference reported the conversation to me. I've read it in a trade rag too. For more ask Jacob Hall?n jacob at cd.chalmers.se. I don't know the exact details of how this was done, cause I was backing the `code and documentation get out of sync. Ideally we should have no documentation in the code at all.' position at the time. Indeed, it very likely was done in Genesis before my first time there, and I just refused to use it until told to. It is hard to remember that far back, but that was my position on documentation all through the 70s and 80s, so if I were there I know what I said. Laura From wj691781 at bcm.tmc.edu Mon Jun 4 12:46:46 2001 From: wj691781 at bcm.tmc.edu (Wen Jiang) Date: Mon, 04 Jun 2001 11:46:46 -0500 Subject: Using SMTPlib. References: <9fg9hd$l27$1@news.inet.tele.dk> Message-ID: <3B1BBB76.424B6523@bcm.tmc.edu> I have a function which might be just what you need. Wen def SendMail(to="",subject="Your Subject",msg="",images=[]): import smtplib, socket, StringIO, MimeWriter, base64 fromaddr=os.environ["USER"]+"@"+socket.gethostname() if not to: to=fromaddr tos=[[to,'']] else: import re mailaddrp=re.compile(r"([A-Za-z0-9._-]+@[A-Za-z0-9_-]+(\.[A-Za-z0-9_-]+)*)") tos=mailaddrp.findall(to) server = smtplib.SMTP('localhost') server.set_debuglevel(0) for cto in tos: outputfp = StringIO.StringIO() # Create a MimeWriter object w = MimeWriter.MimeWriter(outputfp) w.addheader("Subject", subject) w.addheader("To", cto[0]) w.addheader("MIME-Version", "1.0") w.flushheaders() # Now we create a plain text segment and write the instructions file into it w.startmultipartbody("mixed") instructions = w.nextpart() instFile = instructions.startbody("text/plain") instructions.flushheaders() instFile.write(msg) # Now we create a base64 encoded segment and write the diary file into it # as an attachment if images: for img in images: subwriter = w.nextpart() subwriter.addheader("Content-Transfer-Encoding", "base64") subwriter.addheader("Content-Disposition", 'inline; filename="%s"' % img) f = subwriter.startbody('application/octet-stream; name="%s"' % img) subwriter.flushheaders() f.write(base64.encodestring(open(img, 'rb').read())) w.lastpart() server.sendmail(fromaddr, cto[0], outputfp.getvalue()) server.close() Brian Andersen wrote: > > Hi. > > I'm in the process of writing my very first project in Python - a webmail > application. > I've tried the SMTPlib and it work out fint, but the mails I send don't have > a subject. > > I've tried the example that is in the Pythondocumentation for the SMTPlib > and it works well, but how do I insert a subject field? > > The same goes for CC end BCC-fields. Are they handled by the SMTPlib or is > it something that I must handle in my program? > > Hope you can help me. > > Best regards. > Brian. From gardner at cardomain.com Tue Jun 5 16:55:57 2001 From: gardner at cardomain.com (Jonathan Gardner) Date: Tue, 5 Jun 2001 13:55:57 -0700 Subject: integers References: <9fjd8q$qb6$1@charm.magnus.acs.ohio-state.edu> Message-ID: <9fjgqf$rp0$2@brokaw.wa.com> Locke wrote: > is there such thing as > someint++ > or > someint-- > or > someint += 2 > in python?? > > it is a pain in the butt writing > someint = someint + 1 > > Thanks! It's also a pain in the butt writing someint += 1 (Yes, I know I am very lazy). What is the reason that python doesn't have increment or decrement operators? From m.faassen at vet.uu.nl Wed Jun 6 18:08:39 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 6 Jun 2001 22:08:39 GMT Subject: Newbie: How independent are multiple python processes? References: Message-ID: <9fm9l7$d92$3@newshost.accu.uu.nl> Ron Scinta wrote: > I am wondering how much individual python processes are independent? > Meaning, if I am running proc1 and proc2, I assume they each have their own > python interpreter running. > But, what if proc1 crashes the python interpreter and core dumps for > example. Are there shared resources between these two processes that could > affect proc2? Python Shared Libraries? If you're actually running multiple processes you should be as safe or unsafe as running *any* application in multiple processes. Processes are supposed to run in isolation from each other, and many OSes do a good job at this, so it's normally pretty safe. If you're thinking about multiple *threads* however (which look a lot like processes on some platforms, like Linux), the situation is entirely different. If one thread crashes the entire app will likely be in trouble. Core dumps created by python interpreters are however usually pretty rare. What kind of application do you have in mind? Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From Eugene.Leitl at lrz.uni-muenchen.de Thu Jun 28 07:29:26 2001 From: Eugene.Leitl at lrz.uni-muenchen.de (Eugene Leitl) Date: Thu, 28 Jun 2001 13:29:26 +0200 (MET DST) Subject: calling all python hackers (fwd) Message-ID: -- Eugen* Leitl leitl ______________________________________________________________ ICBMTO : N48 10'07'' E011 33'53'' http://www.lrz.de/~ui22204 57F9CFD3: ED90 0433 EB74 E4A9 537F CFF5 86E7 629B 57F9 CFD3 ---------- Forwarded message ---------- Date: Wed, 27 Jun 2001 22:04:37 -0600 (MDT) From: Ronald G Minnich To: linuxbios at lanl.gov Subject: calling all python hackers I'd sure like to have that handy python config GUI that shows a user the mainboard available, lets the user select one form a scrolling list, and helps them through the config process. Anybody want to take me up on this? ron From emile at fenx.com Fri Jun 15 09:22:23 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 15 Jun 2001 06:22:23 -0700 Subject: Problems with readlines() References: <9gcmt4$d28$1@bambi.zdv.Uni-Mainz.DE> Message-ID: <9gd2e0$8mn42$1@ID-11957.news.dfncis.de> I don't see how that function can return varied results. Can you pare down the problem code to the smallest subset that exhibits the problem and post that? There's got to be something outside these four lines contributing to this. -- Emile van Sebille emile at fenx.com --------- "Christian Maus" wrote in message news:9gcmt4$d28$1 at bambi.zdv.Uni-Mainz.DE... > hello there, > > i wrote a function readfile() which reads all lines in a file and stores > them in an array. > > infile = open('/tmp/tacfile', 'r') > array = infile.readlines() > infile.close() > return array > > the strange thing is, the more often I call this function, the lines read > by it decrease, e.g I have a file containing 838 lines, i get 838 lines, > then 738 lines, then 624 and so on... > > When I simply do cut and paste for this code in my program, everything > works fine, only when I call it via it's functionname I get this strange > effect. > > Any idea what the problem might be? > > best regards > > christian From ykingma at accessforall.nl Tue Jun 19 05:01:46 2001 From: ykingma at accessforall.nl (Ype Kingma) Date: Tue, 19 Jun 2001 10:01:46 +0100 Subject: Function lookup using a directory. References: <29pX6.14682$cF.320097@news1.nokia.com> <3B2E4CA6.AF9C5D84@accessforall.nl> Message-ID: <3B2F14F5.9582C9F0@accessforall.nl> andy.pevy at nokia.com wrote: > > Hi Ype > > Ype Kingma wrote: > > Andy, > > > In addition to the earlier replies: > > > Your run() method seems to be checking for > > presence of arguments, so you might > > consider defining it with an extra '*' as: > > > class Help0: > > def run(self, *which): > > if len(which) == 1: > > print 'Help no args' > > else: > > print 'Help args' > > > This will give you a tuple with the passed arguments, > > in your case an empty tuple. > > The argument passed to thee run method is a list, so does this still necessary ??. That depends on what you want to check in the method. Your own code (below) calls the method without arguments: > >> h.run() # Call the run method of the selected class. This would cause 'which' to be set to an empty tuple for the execution of the method. Calling it as: h.run([]) would cause 'which' to be set to a tuple containing an empty list. In case you want the empty list to be the default value define the method as: def run(self, which=[]): This would cause the invocation h.run() to have 'which' bound to an empty list during execution. Good luck, Ype > > > Have fun, > > Ype > > > andy.pevy at nokia.com wrote: > >> > >> Hi Guys > >> > >> I am having trouble with the directory data type. What I want to > >> do is to set up a directory that I can use to parse a command entered by > >> the user, and have a directory return the name of a class to handle the > >> command. Like this :- > >> > >> command_table = {'0': 'Help0', > >> '1': 'Help1', > >> '2': 'Help2', > >> '3': 'Help3' } > >> > >> class Help0: > >> > >> def run(self,which): > >> if len(which) == 1: > >> print 'Help no args' > >> else: > >> print 'Help args' > >> > > [snip] > >> > >> if __name__ == '__main__': > >> > >> command = user_input() > >> > >> try: > >> h = command_table[command[0]] > >> except: > >> print command[0]+' not found' > >> > >> h.run() # Call the run method of the selected class. > >> > > > -- > > email at xs4all.nl > > -- > > We were always told that a million monkeys typing for a million years > would eventually produce the works of Shakespeare. Now, thanks to the > Internet, we know this is not true. -- email at xs4all.nl From Randy.L.Kemp at motorola.com Thu Jun 7 09:06:05 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Thu, 7 Jun 2001 08:06:05 -0500 Subject: Why should I use python if I can use java Message-ID: Well said, and I agree. Java has it's place and Python has it's place. And we have talked about EJB in these lists, along with open source, but is everyone aware that four strong open source, ejb movements exist? www.jboss.org www.evidian.com/jonas www.enhydra.org www.openejb.org So far, in my experience, jboss is ahead of the game, and all the above do have one thing in common with Python: They are all open source. Python is cool! Java is Cool! You just need to know when to use each. I wouldn't drive a boat on the Chicago freeway, or a motorcycle on Lake Michigan. -----Original Message----- From: Geoffrey Gerrietts [mailto:geoff at homegain.com] Sent: Wednesday, June 06, 2001 5:32 PM To: python-list at python.org Subject: RE: Why should i use python if i can use java mik asks: > i' m a python newbie but I've this prob. i have seen Jython .. > > what has python dat java does not????????? As someone who just recently spent a lot of time on this group explaining Java's benefits, I think my karma may demand something of an about face. I can't tell you what you'll like best about Python, or what you'll use most, but I can tell you how things have worked for me. I think it can be summed up in a sentence: Python is a lot more flexible than Java. That doesn't mean that you can do some things in Python that you can't in Java; it just means that some things are much easier to do in Python than in Java. I might go so far as to say most things. Reflection in Java is a pain in my ass. It's inconvenient and it's pretty difficult to get at the actual methods or properties to call them. Python makes that very simple, to the point of trivial. Python makes it very easy to grab hold of what you want when you want it. It's a lot easier for me to write components that can accomodate any object at all without relying on whether standard interfaces have been implemented. It's also very easy to manipulate functions or methods, copy them between objects, or otherwise manipulate the results of my introspection. Unit-testing under Python is a lot easier, or has proven so for me. Because you have almost total control over the objects you import and use, you can stick in "stubs" for standard library components, so that your "stub" returns standardized values. You can also do it for user-contributed components. Prototyping and experimenting is easier under Python, too. I slap together a few lines of code into a file, then python -i -- the Python interpreter runs my lines, then gives me a command prompt, so I can experiment with the data, try various combinations of function calls, or otherwise validate my work. In Python, I know how to write classes whose instances are other classes. In Python, I know how to write a routine that generates a string of python code, then executes the contents of the string. These are highly dynamic features that I don't know how to exploit in Java, if it's even practical to do so. Note that you /can/ do it in Java, but it may take you ten or twenty or a thousand lines of Java to do what one or two or five lines of Python do quite easily. These are all features I can say that I've used in Python -- used the hell out of some of them. They lack in Java, or are more difficult to access. --- Geoff Gerrietts Software Engineer, HomeGain.com 510-655-0800 x4320 From qrczak at knm.org.pl Fri Jun 22 12:43:29 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 22 Jun 2001 16:43:29 GMT Subject: Lookup all available registered Codecs at once? References: <3B28F412.3D36FFA6@stroeder.com> Message-ID: Thu, 14 Jun 2001 19:40:55 GMT, Fredrik Lundh pisze: > Something like this might work: Or might not. This is Python 2.1: [...] (, , , ) Traceback (most recent call last): File "", line 5, in ? File "/usr/local/lib/python2.1/encodings/__init__.py", line 47, in search_function mod = __import__(modname,globals(),locals(),'*') File "/usr/local/lib/python2.1/encodings/mbcs.py", line 14, in ? class Codec(codecs.Codec): File "/usr/local/lib/python2.1/encodings/mbcs.py", line 18, in Codec encode = codecs.mbcs_encode AttributeError: 'codecs' module has no attribute 'mbcs_encode' -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From philh at comuno.freeserve.co.uk Tue Jun 26 19:06:02 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Wed, 27 Jun 2001 00:06:02 +0100 Subject: Should I use a dictionary? References: <9h93p9$4d8$1@panix2.panix.com> Message-ID: On 25 Jun 2001 21:41:13 -0700, Aahz Maruch wrote: >In article , >Greg Jorgensen wrote: >> >>When you want to sort the messages, use your own sort function to compare >>the message date/time: > >That's a Bad Idea if there are a lot of messages; such comparison >functions are expensive. How else do you do sorting, without comparisons? The comparisons could be made quicker by caching the date values returned from the getdate() method. This would avoid having to reparse them. Anyway, with quicksort you only have to do n*log2(n) comparisons, IIRC. -- ==== Philip Hunt == philh at comuno.freeserve.co.uk ==== Want to stop global warming? Do you support the Kyoto Treaty? Then boycott Esso (ExxonMobil in the USA). See www.stopesso.com for details. From aleaxit at yahoo.com Fri Jun 29 03:33:00 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 29 Jun 2001 09:33:00 +0200 Subject: How to tell if interpreter is in interactive mode References: <9gl7ba07u8@enews2.newsguy.com> <9gv2s2$ao024$1@ID-59885.news.dfncis.de> <3b33133a.13483590@news.unbc.ca> Message-ID: <9hhavc0nmj@enews2.newsguy.com> "Levente Sandor" wrote in message news:3b33133a.13483590 at news.unbc.ca... ... > >> In module sys, an attribute named ps1 exists during interactive > >> interpreter sessions. IDE's such as IDLE and PythonWin also set ... > >The only catch is that this attribute is not yet > >defined when sitecustomize is imported. ... > Try this: > > import sys > > def IsInteractive(): > try : > if sys.ps1: return 1 > except: pass > return 0 > > print IsInteractive() Futile: as Thomas indicated, this does not work if you place it in sitecustomize.py. sitecustomize is imported very early, before such attributes of module sys as ps1 and argv are set up. One possible workaround in some cases might be...: as early as the import of site, and sitecustomize, it's not known yet if the session is going to be interactive. But by the same token, if it IS going to be interactive, then Python has not yet looked at the PYTHONSTARTUP environment variable to determine whether to use a startup file. Therefore, sitecustomize.py MAY modify os.environ["PYTHONSTARTUP"] *AND* thus affect Python's behavior at the later stage of interactive/non-interactive determination. If your desired site-customization behavior, that differs for interactive and non-interactive sessions, can be effected as: -- prepare things in sitecustomize.py assuming the session is *NOT* interactive, -- and later if it turns out to BE interactive, fix things in sitecustomizeinteractive.py, then you can do it. For example, in sitecustomize.py: import os os._save_old_startup = os.environ.get("PYTHONSTARTUP") os.environ["PYTHONSTARTUP"] = "sitecustomizeinteractive.py" # proceed with other settings assuming non-interactive and in sitecustomizeinteractive.py: import os # finish up settings for interactive session, then: del os.environ["PYTHONSTARTUP"] old_startup = os._save_old_startup del os._save_old_startup if old_startup: os.environ["PYTHONSTARTUP"] = old_startup try: execfile(old_startup) except: pass This is untested (except I did check that, in Python 2.1 at least, setting os.environ["PYTHONSTARTUP"] at the time of sitecustomize does work as intended) and will no doubt need tweaking (e.g., use full path for the "customize when interactive" script), but it might be a start. I believe a more solid solution would need reworking a bit the architecture of Py_Main in Modules\main.c, so that the various parameters that Py_Main uses to decide whether to use PYTHONSTARTUP (command==NULL and filename==NULL and stdin_is_interactive, presumably) are also collected into one flag and made available already at PyInitialize time. But there are some decisions to be taken -- for example, when the -i flag ("inspect", but I've always thought of it as "interactive":-) is used, Python does give an interactive prompt after running the specified script, BUT it's not "interactive" in the sense that it doesn't source PYTHONSTARTUP earlier. So presumably this flag may need to be exposed separately, too, in order to let some sitecustomize.py distinguish between "interactive in the normal, full sense" and "interactive only because -i was explicitly specified". And I'm not sure how to generalize that to other cases, where Python is NOT started by means of Py_Main... Alex From michael at stroeder.com Mon Jun 11 07:11:14 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Mon, 11 Jun 2001 13:11:14 +0200 Subject: python-ldap and openldap-2.0.7 References: Message-ID: <3B24A752.77EDFB83@stroeder.com> Sandipan Gangopadhyay wrote: > > It seems that the openldap-2.0.7 client-API has changed. Which exact/patched version of python-ldap are you using? > Can python-ldap / web2ldap access the 2.0.7 slapd ? Depends on which patched version of python-ldap you're using. As you might have noticed and the API changed. Currently the OpenLDAP 2.0.x patches are unofficial and python-ldap lacks a real official release anyway... You'd better subscribe to python-ldap-dev list on http://lists.sourceforge.net/lists/listinfo/python-ldap-dev and discuss it there. Before you might also want to review some discussions about building python-ldap against OpenLDAP 2.0 on http://www.geocrawler.com/lists/3/SourceForge/1568/0/. Ciao, Michael. From duncan at NOSPAMrcp.co.uk Tue Jun 12 06:04:06 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Tue, 12 Jun 2001 10:04:06 +0000 (UTC) Subject: UML <-> Python References: <87iti78vwy.fsf@lucifer.home.spb> Message-ID: Eugene Morozov wrote in news:87iti78vwy.fsf at lucifer.home.spb: > I'm a newbie in UML, but I disagree with you. First of all UML isn't > just about design, I use it mostly for analysis. And when designing > python program using UML you can avoid things you mentined completely > (adding attributes on the fly, etc.) or invent some kind of notaion > for them by yourself. This could cause problem only in round-trip > engineering tools but no such tools exist for Python, AFAIK. Doesn't ObjectDomain support round-trip for Python? -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From fredrik at pythonware.com Tue Jun 5 20:22:03 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 06 Jun 2001 00:22:03 GMT Subject: Dynamic class problem References: <9nie+IAgvTH7Ew4A@jessikat.fsnet.co.uk> Message-ID: Robin Becker wrote: > I'm trying to figure out how to recode a class that is giving a shadow > warning under 2.1 I don't have the mental bandwidth to figure out what you're doing here, but I can explain why you're getting that error: > the relevant code is > > def __getitem__(self, index): > try: > return self._children[index] > except KeyError: > Klass = self._prototype here, you create a local variable named "Klass". > if Klass in _ItemWrapper.keys(): (you meant _ItemWrapper.has_key(Klass), didn't you?) > WKlass = _ItemWrapper[Klass] > else: > class WKlass(Klass): here, you refer to that local variable. > def __getattr__(self,name): > try: > return Klass.__getattr__(self,name) here, you access a *global* variable named Klass. under 2.2, this will refer to the local variable instead. > except: > return getattr(self._parent,name) > _ItemWrapper[Klass] = WKlass > > child = WKlass() > child._parent = self > for i in filter(lambda x,K=child.__dict__.keys(): x in K,child._attrMap.keys()): > del child.__dict__[i] > > self._children[index] = child > return child > > the idea is that I want to generate a child instance based on the _prototype class > which has a single overridden getattr method. This code seemed to be working in 2.0, > but I'm getting warnings now do you have a global Klass class? if not, 2.1 just pointed out that your code didn't always work... Cheers /F From greg at cosc.canterbury.ac.nz Thu Jun 7 23:31:22 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 08 Jun 2001 15:31:22 +1200 Subject: How do you develop in Python? References: <050620011516094693%pecora@anvil.nrl.navy.mil> <3B1D4916.8F572A51@letterror.com> Message-ID: <3B20470A.69BAD389@cosc.canterbury.ac.nz> Last time I developed a Python application using IDLE, I created a module containing a big list of 'reload' statements for all my modules in an appropriate order. Whenever I changed anything, I reloaded that module. Crude, perhaps, but it worked! -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From senux at senux.com.NOSPAM Fri Jun 15 03:40:19 2001 From: senux at senux.com.NOSPAM (Brian Lee) Date: Fri, 15 Jun 2001 07:40:19 GMT Subject: crypt module on win32? References: <3B299A96.C42FC98C@senux.com.NOSPAM> Message-ID: <3B29BC21.CEE6097B@senux.com.NOSPAM> I use md5crypt.py instead of crypt.py as default module in Python. Follow is the web site of md5crypt. http://www.sabren.net/code/python/crypt/ I colud use the module(md5crypt) by just copying the module file into library directory of Python. - Brian,. Brian Lee wrote: > > Hi, I want to use some Python code on MS-Windows. The code use crypt > module > but there is no such module on Python for MS-Windows. Any other modules > which > works like crypt module? Or... any ideas? > - Brian,. From lac at cd.chalmers.se Wed Jun 6 11:08:32 2001 From: lac at cd.chalmers.se (Laura Creighton) Date: Wed, 06 Jun 2001 17:08:32 +0200 Subject: creating new Tkinter widget classes In-Reply-To: Your message of "Wed, 06 Jun 2001 16:26:54 +0200." <200106061426.QAA10840@boris.cd.chalmers.se> Message-ID: <200106061508.RAA10965@boris.cd.chalmers.se> Don't bother. Got an even cooler idea of how to do this now. Laura . . From gmcm at hypernet.com Thu Jun 7 14:29:20 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 07 Jun 2001 18:29:20 GMT Subject: McMillan Installer 4 error ImportError: No module named posixpath References: <3b1ea684$1_4@127.0.0.1> <3b1f6fbe_2@127.0.0.1> Message-ID: <90B99DAA2gmcmhypernetcom@199.171.54.154> [posted and mailed] bkc at Murkworks.com (Brad Clements) wrote in <3b1f6fbe_2 at 127.0.0.1>: >Thanks, but I did remove posixpath from the excludes in the .cfg file, >and rebuilt using Builder.py > >The Builder.log shows (I think) that posixpath gets included. When I follow David's advice (which is exactly what I would've said), I have no problem (using a simple test script that imports mimetypes and calls guess_type()). If you still have problems, please email me the Builder.log and your .cfg file. - Gordon From nas at python.ca Fri Jun 29 10:44:43 2001 From: nas at python.ca (Neil Schemenauer) Date: Fri, 29 Jun 2001 07:44:43 -0700 Subject: Not enough Python library development [was PEP scepticism] In-Reply-To: ; from guido@python.org on Fri, Jun 29, 2001 at 12:26:22PM +0000 References: <9hfqb5$dsllb$3@ID-89274.news.dfncis.de> <3dhex01n1m.fsf@ute.cnri.reston.va.us> Message-ID: <20010629074443.A9409@glacier.fnational.com> Guido van Rossum wrote: > I'm guilty of this myself: by nature, I'm more interested in making > the language better than in adding convenience to finding 3rd party > modules. I think many people on the python-dev list are guilty. We should concentrate more on improving the standard library. IMHO, there is lots of room there for improvement. Neil From arisen at start.no Thu Jun 21 15:03:04 2001 From: arisen at start.no (=?ISO-8859-1?Q?Andr=E9?=) Date: 21 Jun 2001 12:03:04 -0700 Subject: NT Service and COM References: Message-ID: "Duncan Booth" wrote in message news:... > Has anyone got a simple example of doing an NT service that also acts as a > COM server? It looks as though it shouldn't be too hard, but if someone > else has already done it I wouldn't mind copying. > Hi. I found this example in Python Programming on Win32, page 349. I have not tested it. Am typing in a hurry, beware of tpyos: import win32serviceutil import win32service import win32event class PythonService(win32serviceutil.ServiceFramework): _svc_name_ = "PythonService" _scv_display_name_ = "The smallest possible python service." def __init__(self, args): self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) def scvStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) win32event.SetEvent(self.hWaitStop) def SvcDoRun(self): win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE) if __name__ == "__main__": win32serviceutil.HandleCommandLinw(PythonService) -- Regards Andr? Risnes From aleaxit at yahoo.com Mon Jun 4 15:29:43 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 4 Jun 2001 21:29:43 +0200 Subject: What does x[:]=[4,5,6] mean? References: <9fb7cu$lq6$1@newsreaderg1.core.theplanet.net> <87elt2u5rr.fsf@litterbox.meowing.net> <9fgm2k$at7$1@brokaw.wa.com> Message-ID: <9fgnn20nm3@enews2.newsguy.com> "Jonathan Gardner" wrote in message news:9fgm2k$at7$1 at brokaw.wa.com... ... > The bottom line is the assignment operator _never_ makes a copy of > something - the end result is to make the variables point to the object on > the right hand side. Hmmm... assignment to a _slice_ may be slightly different in this regard, so, given the subject of this thread, take care... >>> a=[1,2,3] >>> b=[4,5,6] >>> a[:]=b >>> c=b >>> b[1]=99 >>> a [4, 5, 6] >>> b [4, 99, 6] >>> c [4, 99, 6] >>> See? The a[:]=b *has* "made a copy of something" -- quite different from the c=b. No references to the object bound to b have been added by the slice assignment -- rather, the items have been copied. You could say it's the work of a's __setitem__ (or built-in list's equivalent thereof) when it receives a slice argument, but it may be simpler to explain as the assignment doing the copy in this case, I think. Alex From bobh at hslda.org Thu Jun 21 10:06:58 2001 From: bobh at hslda.org (Robert) Date: 21 Jun 2001 07:06:58 -0700 Subject: Getting info on who is using a file on Windows... Message-ID: <4a249347.0106210606.ef3e16a@posting.google.com> I am on a Windows network and I am trying to see who is connected to an access database. I have been perusing the docs but nothing has jumped out and hit me in the head. Any ideas? Bob From hamish_lawson at yahoo.co.uk Mon Jun 25 18:08:15 2001 From: hamish_lawson at yahoo.co.uk (=?iso-8859-1?q?Hamish=20Lawson?=) Date: Mon, 25 Jun 2001 23:08:15 +0100 (BST) Subject: How to get time.strptime for Windows Message-ID: <20010625220815.52397.qmail@web11005.mail.yahoo.com> On various occasions people who have missed having the time.strptime function on Windows have been referred to a Python implementation by Andy Markebo that is available at http://www.fukt.hk-r.se/~flognat/hacks/strptime.py After installation in a suitable place on the Python path, this is then available as strptime.strptime. However perhaps you would like to be able to refer to it as time.strptime (maybe you have other code that expects to call it as such)? But there's no time.py file to cut and paste the code from strptime.py into. We can, though, make use of the fact that imported modules are mutable objects in Python and so make time.strptime be an alias for strptime.strptime: import time, strptime time.strptime = strptime.strptime del strptime You can even have this aliasing done automatically by putting the above code in a file sitecustomize.py on the Python path; the Python interpreter automatically tries to import this module when it starts up. Thus: Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> from time import strptime >>> strptime('2001-07-8', '%Y-%m-%d') (2001, 7, 8, 0, 0, 0, 0, 0, 0) Hamish Lawson ____________________________________________________________ Do You Yahoo!? Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk or your free @yahoo.ie address at http://mail.yahoo.ie From MarkH at ActiveState.com Wed Jun 20 04:50:00 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 20 Jun 2001 08:50:00 GMT Subject: idle BUG References: <3b2fba2f.1443851@24.0.228.33> Message-ID: <3B3063B8.3070206@ActiveState.com> Mike Clarkson wrote: > I know you're not-a-gui-guy, but can you help with python.exe compile > and link flags? Has anyone build Tkinter with Cygwin, and if so, does > the same problem show up there? What help specifically? python.c is compiled with: /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"x86-temp-release\python/python.pch" /YX /Fo"x86-temp-release\python/" /Fd"x86-temp-release\python/" /FD /c python.exe is linked with: odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:console /incremental:no /pdb:"./python.pdb" /debug /machine:I386 /out:"./python.exe" Mark. From stephen-news at telekinesys.com Thu Jun 7 13:44:46 2001 From: stephen-news at telekinesys.com (Stephen) Date: 7 Jun 2001 10:44:46 -0700 Subject: Directory chooser for Tkinter Message-ID: <40f7645c.0106070944.4d71d203@posting.google.com> I was surprised by the lack of a directory chooser. Also I found very few references to it on the web. Is there any reason for not including the following code in tkFileChooser.py? The tk_chooseDirectory appeared in all versions of tk since 8.3 (and earlier on some platforms afaik) Stephen. # directory dialog # # - initialdir: initial directory. preserved by dialog instance. # - initialfile: initial file (ignored by the open dialog). preserved # by dialog instance. # - parent: which window to place the dialog on top of # - title: dialog title def askOpenDirectory(**options): "return directory chosen or empty string if cancelled" class OpenDirectory(Dialog): command = "tk_chooseDirectory" return apply(OpenDirectory, (), options).show() From brian at sweetapp.com Mon Jun 18 02:52:42 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Sun, 17 Jun 2001 23:52:42 -0700 Subject: FW: __getattr__ and other customization methods Message-ID: <000601c0f7c3$45f34c70$445d4540@D1XYVL01> Mark wrote: > Brian Quinlan wrote: > >> Is there any reason why getattr, when called on an instance, should >> call that instance's __getattr__ method for other customization >> methods (methods starting with __)? > > Otherwise you have no way of saying "this method does not exist". That is not quite true. If you know before hand that you need access to these methods (e.g. during construction), you can add them directly to your instance. However, I understand that this might not be desirable or possible when you are proxying a remote object. > Consider an object that wraps another object - ie, a proxy. > > Some objects you proxy may provide a __len__ method, while others may > not. However, Python changes behaviour based on the *existence* of this > method. Generally you will want your proxy to behave exactly the same > as the proxied object. If you want this to work in all cases, you will have to do some weird stuff anyway. A lot of proxy implementations provide a __repr__ method, which means that they cannot proxy that method. There probably isn't a convenient way of proxying an __init__ call, etc. > Further, it is, IMO, much cleaner this way. Special method names are > just attributes. The lack of surprises here makes for a cleaner model. > I agree there are gotchyas, but I don't think it should be any > different. I think classifying special methods as "just attributes" is understating their participation in Python's object module. I would weight the need to proxy customization methods with the frequencies of gotchyas. And if you really need to proxy customization methods, there could be another method to serve your needs: __getspecial__ or __getreserved__ or __getcustomization__ From dougfort at downright.com Tue Jun 19 13:57:46 2001 From: dougfort at downright.com (Doug Fort) Date: 19 Jun 2001 18:57:46 +0100 Subject: Extracting words from a string : *fast* References: <0UEX6.268$8H6.170349568@news.telia.no> Message-ID: <3b2f929a_6@news5.uncensored-news.com> Thomas Weholt wrote: > Hi, > > I need to extract words from a string. This method will be used extensivly > in a indexer so it needs to be as fast as possible. > > It needs to split words by case, numbers, spaces and chars like ,.-_/\*' > etc. Returns a list of lower-case entries of the words found or a > dictionary of were the words are keys and number of occurences are values. > > Ex. > > s = 'This is a.test for ThomasWeholt - magic42' > print getWords(s) > ----------------------------------------------------- > ['this','is','a','test','for','thomas','weholt','magic','magic42'] > > The text to be processed are mostly small in size but can also be huge, > etc. 1-10MB. > > Thomas > > > Have you seen Dr. David Mertz's article on developing a Python indexer? He addresses the problem of identifying words, check out http://gnosis.cx/publish/programming/charming_python_15.txt -- Doug Fort Senior Meat Manager Downright Software LLC http://www.downright.com ______________________________________________________________________ Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com With Seven Servers In California And Texas - The Worlds Uncensored News Source From pete at visionart.com Tue Jun 5 19:16:41 2001 From: pete at visionart.com (Pete Shinners) Date: Tue, 5 Jun 2001 16:16:41 -0700 Subject: PyGame, IDE problems References: Message-ID: <9fjogs$cde$1@news.unitel.co.kr> "Nick Perkins" wrote > I can not run the example programs from Pygame from within > either PythonWin or IDLE. I am running Py 2.1 on NT4. > ( They both freeze up ) > > The examples do run by themselves, (ie not from within an IDE). > Also, curiously enough, they do run from within Boa > Constructor's editor. hi nick. the problem with IDLE and PythonWin is that they run the python code in the same interpreter as the editor itself runs in. this isn't just a problem with pygame, but with GUI libraries and just about anything involving graphics. what both these editors "should" be doing is running the program in a seprate process. owell. i can recommend the SCiTE editor, which works on most platforms. it has most of the editing features of pythonwin, but does the right thing by running your programs in a separate process. http://www.scintilla.org/SciTE.html i hear komodo also does a proper job of this, but its a bit too bulky and expensive for me to bother with. http://www.activestate.com/Products/Productivity/ASPN_Komodo my personal preference has just been a dressed up dos-shell sitting next to my editor, and jumping back and forth between them. at some point i want to make a good effort at running cygwin's bash instead of the dos prompt :/ From dubldekabus at hotmail.com Thu Jun 7 21:57:35 2001 From: dubldekabus at hotmail.com (pilgrim) Date: Fri, 8 Jun 2001 11:57:35 +1000 Subject: GROUP TAKEOVER IN PROGRESS References: <3A29743F.CAA91142@my-Deja.com> <92dtj6$5dh$1@bob.news.rcn.net> <69cl4tk6bitr0oi376ngtjp0m1bs7ucnk4@4ax.com> <902430AC4moondustapexnet@209.99.56.9> <93hn81$l4m$1@nnrp1.deja.com> <9025628F7moondustapexnet@209.99.56.9> <3a5c8520_1@news.foxinternet.com> <902581E21moondustapexnet@209.99.56.9> <3a5ce21b_1@news.foxinternet.com> <4A982771F09.psskvxvn@vluxxijwai.net> Message-ID: Mr Kohler, I am only new at this so please excuse the mistypes - Like I said, I'm only new at this. From matthew.russell at securetrading.com Wed Jun 13 05:50:17 2001 From: matthew.russell at securetrading.com (Matt Russell) Date: 13 Jun 2001 02:50:17 -0700 Subject: memory profiling References: Message-ID: I am aslo interested in finding a way to track memory leaks in python programs. Does one have to have the module resource.c compiled into the interpreter B 4 using something such as memprof_c or are their other tools availble for tracking memory leaks? TIA Matt Geoffrey Gerrietts wrote in message news:... > I'm sure this question has been asked and answered a few times now, but I > can't seem to find an answer for it, either in the FAQ or in the newsgroup > archives. > > How do people do memory profiling in python? I'd like to compare, for > instance, the memory consumed by a dictionary-based approach versus a list > or tuple based approach. I've seen the tool in mxTools, sizeof, which is > nice, but that doesn't seem to address the big "random" factor, the empty > pointers in the dictionary. > > Does a tool exist that will let me measure this in some reasonably > straightforward way? Are other people doing any kind of memory profiling, or > do folks just "eyeball it"? Am I missing something blatantly and plainly > obvious that I should be embarassed for not seeing? > > Thanks in advance, > --G. > > --- > Geoff Gerrietts > Software Engineer, HomeGain.com > 510-655-0800 x4320 From loewis at informatik.hu-berlin.de Mon Jun 18 07:20:20 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 18 Jun 2001 13:20:20 +0200 Subject: libiconv & python References: <9gke1t$2bbo$1@proxy.niit.ru> Message-ID: Stepan Koltsov writes: > I wrote a small wrapper for libiconv, is it needed to anybody? Or maybe > it was written earlier (I could not find) ? One such wrapper, exposed as a codec, is available in sf.net/projects/python-codecs. Regards, Martin From emile at fenx.com Fri Jun 22 09:02:19 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 22 Jun 2001 06:02:19 -0700 Subject: How to display all the methods supported by an instance using dir( )..please hel References: Message-ID: <9gvfs6$b6kmc$1@ID-11957.news.dfncis.de> dir(t) returns the instance attributes. func is an attribute of the class test. class test: def __init__(self): self.data = 100 def func(self): pass t = test() print dir(t) print t.__class__ print dir(t.__class__) If your class inherits behavior from other classes, you'll want to look at the __bases__ attribute as well. print test.__bases__ HTH, -- Emile van Sebille emile at fenx.com --------- "Learn Python" wrote in message news:mailman.993191674.4878.python-list at python.org... > > hi all, > i'm a begginer in python, > This is what i have: > > class test: > def __init__(self): > self.data = 100 > def func(self): > pass > if __name__ == '__main__': > t = test() > dir(t) ==> i want this to list data and func > > But it does'nt list func :-(. What methods s'd i provide in addition so that > dir( ) can recognize func() which happens to be a instance method attribute? > I guess this s'd be possible bcos when i say > l = [] and then dir(l), i get all the list attributes. I want the same kind > of behaviour for my class instance as well. > > thanks in advance > karthik. > _________________________________________________________________________ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. > > From chris.gonnerman at newcenturycomputers.net Tue Jun 19 08:58:04 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Tue, 19 Jun 2001 07:58:04 -0500 Subject: Indentation References: Message-ID: <003201c0f8bf$7fd54860$0101010a@local> ----- Original Message ----- From: "Pilgrim" > I'm new to programming so take it easy on me :-) > > I'm going through a book by Ivan Van Laningham and have gotten to > indentations. In the example I'm trying duplicate he as written three lines > from the command prompt. After the third line is a new indentation and then > the next line starts back at the beginning without the command prompt >>> > and starts with an "elif" statement. According to his tip to start a new > line you just hit return twice when you are done with the indentation. OK > that works fine and starts me at a new prompt >>> but when I type the next > line starting with a "elif" statement it gives me a SyntaxError: invalid > syntax. What I'm I missing? You've got it *almost* right. When you are typing a control-flow structure at the interactive prompt, you *don't* press enter twice before the next control-flow keyword. To wit: Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. Alternative ReadLine 1.4 -- Copyright 2001, Chris Gonnerman >>> t = 1 >>> if t == 1: ... print "one" ... elif t == 2: ... print "two" ... else: ... print "something else" ... one >>> What you are doing is this: >>> if t == 1: ... print "one" ... one >>> elif t == 2: File "", line 1 elif t == 2: ^ SyntaxError: invalid syntax >>> Pressing Enter twice ends the code block, but the if ... elif ... else structure must not be broken up this way. From reggie at merfinllc.com Fri Jun 29 13:50:19 2001 From: reggie at merfinllc.com (Reggie Dugard) Date: Fri, 29 Jun 2001 10:50:19 -0700 Subject: BLT through Pmw In-Reply-To: <3b37079e$1@news01.datazug.ch> Message-ID: Volker, I've just been catching up with my e-mail and I didn't see any response to your question, so I thought I'd put in my 2 cents. I'm not sure if this is the "correct" way, but this is how I got it to work. I installed BLT under the tcl directory found in the standard python distribution. I then moved tcl\lib\tcl8.3\blt2.4 up to tcl\tcl8.3\blt2.4 so that the pkgIndex.tcl file could be found by TCL. I also made sure that the tcl\bin directory is in the path so that the DLL's could be found. I played with this a while before I got it to work and this method is a kludge, so if you find a cleaner way to do the install, I'd appreciate it if you'd pass it on. I hope this helps; good luck! Reggie Dugard Merfin, LLC Voice: 925-937-4560 1460 Maria Lane, Suite 420 FAX: 925-937-4530 Walnut Creek, CA 94596 Mailto:reggie at merfinllc.com -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Volker Dobler Sent: Monday, June 25, 2001 3:46 AM To: python-list at python.org Subject: BLT throug Pmw Hello, I would like to use BLT 2.4u throug Pmw 0.8.5 from Python 2.1 on an Windwos box but Pmw cannot find the BLT package. I installed the BLT package from the self extracting Windows installer found on the BLT home page in various locations but none worked. As I am unfamiliar with the tcl/tk-directory organisation I do not know wether all files are in the right place. Does anyone have any experince with this setup? Where should the BLT libraries be (relativily to the Python21 or Tcl diretory)? The demos included in the BLT distribution do not work either, they suffer from the same problem: "Can't find BLT package" Thanks a lot in advance for any idea. Volker Dobler From BPettersen at NAREX.com Mon Jun 11 16:20:38 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Mon, 11 Jun 2001 14:20:38 -0600 Subject: PEP 259: Omit printing newline after newline Message-ID: <6957F6A694B49A4096F7CFD0D900042F27D452@admin56.narex.com> > From: Guido van Rossum [mailto:guido at digicool.com] > > Subject: PEP 259: Omit printing newline after newline This would probably break most of the cgi scripts I did at my last job without giving any useful error message. But then again... why should I care ? -- bjorn From iddwb at imap1.asu.edu Wed Jun 20 20:19:49 2001 From: iddwb at imap1.asu.edu (iddwb) Date: Thu, 21 Jun 2001 00:19:49 +0000 Subject: using os.system and ps2pdf Message-ID: Problem. I need to read stdin, and convert it to pdf. Luckily, stdin will give me postscript. So, I thought I simple script would work. Invoking the ps2pdf program manually works fine to create the pdf. Unfortunately, the following code doesn't allow ps2pdf to do its work fully, It creates an empty pdf. Is there a better way to call an external program than os.system? Alternatively, could reading stdin be dropping something? any advice would be appreciated. #!/usr/local/bin/python import os, sys, tempfile if __name__ == '__main__': psf = tempfile.mktemp("psf") pdf = tempfile.mktemp("pdf") ps = open(psf, "w") ps.write(sys.stdin.read()) ps.close print "ps2pdf %s %s" % (psf, pdf) os.system("ps2pdf %s %s" % (psf, pdf)) David Bear College of Public Programs/ASU From thomas at gatsoft.no Wed Jun 27 06:49:51 2001 From: thomas at gatsoft.no (Thomas Weholt) Date: Wed, 27 Jun 2001 10:49:51 GMT Subject: Python for Commercial Games? References: <9haoiv$jnv$1@mtc1.mtcnet.net> Message-ID: "Blade of Darkness" was released some time ago and was written partially in Python. It was a pretty cool game too, so it's possible to at least do parts of such a project in Python. I think it came with some code too, so you could look at that for tips. PyGame uses SDL and there's allready some games popping up that's using those libs. "Blade .." got rather good reviews too by the way. Thomas "Kevin Riggle" wrote in message news:9haoiv$jnv$1 at mtc1.mtcnet.net... > I *do* realize that I'm posting to comp.lang.python , so please humor me > anyway... > > I am in process of designing a computer game; problem is, I want to at > least have a snowball's chance in Hades of selling the game. My question: > Would it be possible to write the dang thing in Python (PyWin), or is C/C++ > the better option in the Windows-centric world of game development right > now? Thanks in advance, > > Kevin > > From fig at localhost.localdomain Wed Jun 6 19:45:35 2001 From: fig at localhost.localdomain (Stephen R. Figgins) Date: Wed, 06 Jun 2001 23:45:35 -0000 Subject: Cookbook on the DevCenter Message-ID: The latest additions to the Python cookbook are now featured on the front page of the O'Reilly Network Python Dev Center. http://www.onlamp.com/python Look for it on the right underneath feature content. -Stephen From alan.gauld at bt.com Mon Jun 11 14:08:33 2001 From: alan.gauld at bt.com (Alan Gauld) Date: Mon, 11 Jun 2001 19:08:33 +0100 Subject: Has anyone used UML? References: <9flodi$32m$1@brokaw.wa.com> <3b228485.13884244@news.laplaza.org> Message-ID: <3B250921.F9F1D571@bt.com> Mats Wichmann wrote: > Yes, it's kind of interesting that way. Three of the main > practitioners of OO methodologies and modeling strategies all ended up > working for Rational, leaving them with the odd situation of having > the proponents of three different modelling schemes on staff. Not true! Rumbaugh and then Jacobson specifically joined Rational to create the UML. By the time they joined they already recognised the need for a unifying language. Rational Rose(the CASE tool) already existed (indeed was at version 2 at least) and was based on Booch's notation. The first version to support UML still had Booch as default... > all... on the other hand, it may be that Rational Rose really is > "that damn good" (personally, I have zero experience with it). When it first appeared (around 1992) it was the best thing available - almost the only thing available - for "round trip engineering". ie You could draw a design, generate code, modify the code and then suck the code changes back into your design. First time I saw that I was astounded at how good it was. Nowadays several tools do the same tricks - with pretty much equally unsuccessful results! But they are all better than nothing for a significant sized project. Likewise they are all overkill for a small one! Alan g. From Sir-XaoS at gmx.net Wed Jun 27 08:43:22 2001 From: Sir-XaoS at gmx.net (C. Koehler) Date: Wed, 27 Jun 2001 14:43:22 +0200 Subject: access to subfolders Message-ID: <3B39D4EA.A000782F@gmx.net> here we go for another stupid newbie question: I'm trying to deal with a subfolder within a pythonscript. I'll have to add to properties and to store a file from an upload form. I tried it as follows--- [id shall be the name of the subfolder and is given by me] container._.getitem(id).manage_addProperty('user',AUTHENTICATED_USER.getName(),'string') container._.getitem(id).manage_addProperty('data',ZopeTime().strftime('%m/%d/%Y - %I:%M%p'),'string') container._.getitem(id).manage_addProduct['OFSP'].manage_addFile(id+'.pdf',context.REQUEST['pdf']) by trying out this, I discovered a access proplem: I'm logged in as admin, but the script won't work. So: What's the problem with it? note: everything I try with "container._.getitem(id)" fails 'cos of access props, but I don't know how to do it alright [I mean refering to the subfolder] could somebody please help me [again]? thx, Christian From root at rainerdeyke.com Tue Jun 19 13:05:04 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Tue, 19 Jun 2001 17:05:04 GMT Subject: PEP 255: Simple Generators References: <9glhg7$dlk$1@nntp6.u.washington.edu> Message-ID: <4DLX6.320220$oc7.29444949@news2.rdc2.tx.home.com> "Neil Schemenauer" wrote in message news:mailman.992918729.26233.python-list at python.org... > Rainer Deyke wrote: > > In other words, whether a function is a generator or not is determined at > > run-time. The following would work, right? > > > > def f(x): > > if x == 5: > > yield 5 # Look ma, I'm a generator. > > return > > else: > > return x # Or maybe not. > > No and no. The above code would raise a syntax error when > compiled. In that case, there definitely should be a separate syntax for generators. Consider: def f(): return yield 'Never reached.' Is this function a generator? Yes, but only if nobody removes the seemingly redundant 'yield' statement. Or consider a case like this: def f(x): if x == 0: do_something() elif x == 1: do_something_else() # ... elif x == 99: yield 5 Here we have a very long function that doesn't fit on the screen all at once. A person looking at the upper part would think it a normal function, and only somebody who sees the bottom part of the function knows it's a generator. If the last case becomes redundant for some reason and is removed, the semantics of the entire function change. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From emile at fcfw.fenx.com Mon Jun 18 10:25:41 2001 From: emile at fcfw.fenx.com (Emile van Sebille) Date: 18 Jun 2001 09:25:41 -0500 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Jun 18) Message-ID: <61E8742D7FA565D0.947F39CBDB17547A.0BBA068ABA038F40@lp.airnews.net> Andrew Kuchling's been busy this week, announcing version 0.3 of the Quixote Web development toolkit... http://groups.google.com/groups?ic=1&q=msgid:mailman.992279041.25730.clpa-moderators at python.org ... a fresh package of ZODB and ZEO available... http://groups.google.com/groups?ic=1&q=msgid:mailman.992380331.21323.clpa-moderators at python.org ... and launches a quest for warts... http://groups.google.com/groups?ic=1&q=msgid:mailman.992543370.22014.python-list at python.org ... the cure for which is generally accepted to be hypnosis. For when time travel simply won't do. http://www.uniontrib.com/news/diversions/strange/20000329-1210strange9.html Cyril Slobin releases a dos version of python. http://groups.google.com/groups?ic=1&q=msgid:dc44b395.0106121341.26de828a at posting.google.com Jon Saenz announces PyClimate 1.1, for the analysis of atmospheric and oceanic data sets. http://groups.google.com/groups?ic=1&q=msgid:mailman.992510340.9024.clpa-moderators at python.org David Hart revives the calls for a python CPAN, but with a twist. http://groups.google.com/groups?ic=1&q=msgid:oFRV6.2073$PA4.763051146 at newssvr17.news.prodigy.com The nagging license concerns introduced with 1.6b1, in particular with regard to GPL compatibility, have been worked out for new and bug-fix releases. See Guido's post for more. http://groups.google.com/groups?ic=1&q=msgid:mailman.992706505.26148. python-list at python.org Tim Peters points out a new tutorial reference on floating point. http://python.sourceforge.net/devel-docs/tut/node14.html PEPs: Tim Peters releases PEP 255, adding a new keyword that enables Simple Generators... http://python.sf.net/peps/pep-0255.txt ... even while pointing out that keywords rarely actually make it into the language. http://groups.google.com/groups?ic=1&q=msgid:mailman.992695645.13636.python-list at python.org David Goodgear introduces PEPs 256,257 & 258, a trio of docstring related standards to support DPS (Docstring Processing System) Framework http://python.sf.net/peps/pep-0256.txt Docstring Conventions http://python.sf.net/peps/pep-0257.txt DPS Generic Implementation Details http://python.sf.net/peps/pep-0258.txt Guido confirms we're paying attention by introducing PEP 259 ... http://groups.google.com/groups?ic=1&q=msgid:mailman.992290220.14360.python-list at python.org ... and withdrawing it a few days later. http://groups.google.com/groups?ic=1&q=msgid:mailman.992449110.8527.python-list at python.org ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the daily python url http://www.pythonware.com/daily comp.lang.python.announce announces new Python software. Be sure to scan this newly-revitalized newsgroup at least weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Michael Hudson continues Andrew Kuchling's marvelous tradition of summarizing action on the python-dev mailing list once every other week. http://starship.python.net/crew/mwh/summaries/ http://www.amk.ca/python/dev The Vaults of Parnassus ambitiously collect Python resources http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ The Python Software Foundation has replaced the Python Consortium as an independent nexus of activity http://www.python.org/psf/ Cetus does much of the same http://www.cetus-links.de/oo_python.html Python FAQTS http://python.faqts.com/ 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 tricks of the trade: http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python&num=100 http://groups.google.com/groups?meta=site%3Dgroups%26group%3Dcomp.lang.python.* Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://groups.google.com/groups?oi=djq&as_q=+Python-URL!&as_ugroup=comp.lang.python Suggestions/corrections for next week's posting are always welcome. [http://www.egroups.com/list/python-url-leads/ is hibernating. Just e-mail us ideas directly.] To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From urner at alumni.princeton.edu Mon Jun 4 00:55:42 2001 From: urner at alumni.princeton.edu (Kirby Urner) Date: Sun, 03 Jun 2001 21:55:42 -0700 Subject: nested scopes in IDLE? (2.1) Message-ID: I can get the nested scopes feature to work in modules of course, using the from __future__ import nested_scopes thing, but if I just boot IDLE and try to write the following compose function, it errors out: def compose(f,g): return lambda f,g,x: f(g(x)) There's the old workaround from pre-nested scopes Pythons: def compose(f,g): """with thanks to Dustin Mitchell""" return lambda _f=f,_g=g,x: _f(_g(x)) but that's what we want to get away from, and do, in 2.1 -- but apparently not when entering defs interactively in IDLE (vs. in saved .py files). Perhaps issuing >>> from __future__ import nested_scopes in IDLE has no effect because we're already into it too far by that time (whatever that means) i.e. this statement has to happen at "the top". Perhaps there's a source code tweek I could make to my IDLE which includes the nested scopes feature by default? Clues? Kirby CC by email please: pdx4d at teleport.com or the above From scarblac at pino.selwerd.nl Tue Jun 19 06:27:55 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 19 Jun 2001 10:27:55 GMT Subject: nested classes References: Message-ID: Bjorn Pettersen wrote in comp.lang.python: > > From: Mats Wichmann [mailto:xyzmats at laplaza.org] > > Java and C++ are compiled. The class definition is instructions to > > the compiler, and can be self-referential, because the /reference/ is > > not going to happen until the class is loaded - no inconsistency. Not > > so for Python, the class definition is code that is actually run to > > build the class object, and before that object has been built, there's > > nothing to refer to yet, as Alex said. > > But that's an implementation detail only, since it works perfectly for > functions: > > def foo(): > foo() The difference is that a class is executed when it's defined, and a function is executed when it is called. By the time the function is called, 'foo' exists, of course. -- Remco Gerlich From chrishbarker at home.net Tue Jun 19 19:39:41 2001 From: chrishbarker at home.net (Chris Barker) Date: Tue, 19 Jun 2001 16:39:41 -0700 Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: <73PX6.317$zE1.418988@news.uswest.net> Message-ID: <3B2FE2BD.F210FA8A@home.net> Kevin Altis wrote: > what is missing is the tight coupling of a GUI environment. I'm not sure if I mean the same thing as Kevin, but this is a big problem. ALL the GUI options for Python (tkinter, wxPython, PyQT, PyGTK, etc.) are wrappers around a GUI toolkit made for some other laguage, for some other purpose. This is a major limitation. What Python needs is a Native GUI toolkit. Guido talked about it in the past, saying that the interface would likely be something like tkinter, but nothing is happening on that front. What I imagine is this: A GUI library that is built for Python, that interacts well with the Python library and all the native type. This library would, for instance, expect to get a Python list whne is needed a list of items. It would be written in C++ (or maybe C). It would be platform independent. The strength in this approach is that the core library could just as easily be extended in either Python or C/C++. This way, the community could develop nice higher-level widgets and really expand the toolbox. It could be used from either C/C++ or Python. This way, one could develop a C/C++ app with an embedded python interpreter, and GUI code could be run from either language, the transition would be easy. Many of these features now exist in wxPython. That is why I am using it. However, wxPython is a thin wrapper around a C++ class library. This is a good thing because it allows common documentation and the wrappers can be produced with SWIG. It is a bad thing because you end up writing Python code that is not natural (pythonic), and a whole lot more verbose and complex than it needs to be. It also suffers some from performance issues do to translating from Python lists to wxLists, generating wrappers around C++ objects, etc. I don't understand the details, but the issues are there. wxWindows and Python also share a lot of duplicate functionality: sockets, database access, process control, file system manipulations, etc. etc. This doesn't mean that we would have to start from scratch, I'm sure a lot of the underlying code from wxWindows, or Fox, or FLTK, or GTK, or whatever could be used, but it would be a substantial effort. If such a toolkit existed, PythonCard would be a whole lot easier to write, as would many other tools. Unfortunatly, Python is suffering, in this respect, from an Free Software problem: people build what they need, and putting a wrapper around an existing toolkit gets them something that works, with a whole lot less effort than writing something new. So we now have ten wrappers, and no native toolkit. :-( Well, I've proposed, and I've whined, and I have neither the time nor the skills to do it, so I'm done for the moment. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From shalehperry at home.com Sat Jun 30 17:40:54 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Sat, 30 Jun 2001 14:40:54 -0700 (PDT) Subject: Q: newbie wants to eval() In-Reply-To: <3b3e3e81$0$88189$2c3e98f8@news.voyager.net> Message-ID: import string known_vars = ('foo', 'bar', 'baz') input = 'foo = 2' var, data = string.split(input) if var in known_vars: exec(input) # eval takes an expression, assignment is not else: print "unknown variable: %s" % var for key in globals().keys(): if key[0] != '_': print key From urner at alumni.princeton.edu Mon Jun 4 12:55:41 2001 From: urner at alumni.princeton.edu (Kirby Urner) Date: Mon, 04 Jun 2001 09:55:41 -0700 Subject: Question re local bindings in nested scopes Message-ID: <8gdnht4as9mg09un8vu2ci2re80p2ujssq@4ax.com> I don't get why the following two functions, each with internal functions that take advantage of lexical scoping (new in 2.1), behave so differently: from __future__ import nested_scopes def spam(a,b): def bar(): output = [] print b print a output.append(a+1) return output return [x for x in bar()] def foo(a,b): def bar(): output = [] print b print a a += 1 output.append(a) return output return [x for x in bar()] >>> spam(1,10) 10 1 [2] >>> foo(1,10) 10 Traceback (most recent call last): File "", line 1, in ? foo(1,10) File "d:\program files\python21\ocn\test.py", line 38, in foo return [x for x in bar()] File "d:\program files\python21\ocn\test.py", line 34, in bar print a UnboundLocalError: local variable 'a' referenced before assignment I can fix foo() by assigning a to s and doing the increment on s: def foo(a,b): def bar(): output = [] print b print a s = a # added this line s += 1 # added this line output.append(s) return output return [x for x in bar()] But should a=a+1 (or a += 1) really break the initial binding of a to the outer scope? Is this intended? Given a and b initialize to the outer scope values just fine in spam(), it seems odd to unbind an already initialized variable at "compile time" just because we add 1 to it. Seems too subtle for its own good. a=a+1 would seem a runtime operation on a variable that is already initialized at compile time thanks to lexical scoping. Kirby CC replies/insights to pdx4d at teleport.com and/or above address please From loewis at informatik.hu-berlin.de Fri Jun 8 13:27:06 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 08 Jun 2001 19:27:06 +0200 Subject: gc issues References: <655abd4a.0106080504.66a9d6a0@posting.google.com> Message-ID: etoffi at bigfoot.com (e toffi) writes: > i know this will require some *very* careful prgramming techniques. > can anyone point me in the right direction? Basically, you need to announce the objects of one language to the other language's garbage collector. E.g. when you provide Smalltalk objects to a Python interpreter, you probably do this by creating Python wrapper objects. So you need to tell the Smalltalk garbage collector that the object is alive as long as there is a Python wrapper around it. How you do this would depend on the Smalltalk GC API. A Python object is normally released by having its reference counter drop to zero. If that happens, the Python wrapper is released, and should tell the Smalltalk GC that now the ST object is now available for collection again. If you can create cycles involving both ST and Py objects, things become complicated. For Python, you need to implement a traversal function that enumerates all directly-reachable Python objects from an ST object. That probably means that you need traversal capabilities on ST objects. Whether this is possible and how this is done again depends on the details of the ST GC API. To summarize: as long as you don't create cycles involving objects from both languages, you only need to make sure that objects referenced from one language are not collected by the collector of the other language. If you have cycles of mixed languages, I doubt there is prior art integrating the GC routines. Regards, Martin From sholden at holdenweb.com Wed Jun 27 09:45:45 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 27 Jun 2001 09:45:45 -0400 Subject: Escaping SQL in python References: <3B39A1B8.A7FCE4C7@kvarteret.uib.no> Message-ID: The *best* way to handle this is to use dynamic SQL, and let the module do the quoting. For example: conn = some_db_module.connect(args) cursor = conn.cursor() data = ("O'Brian", "Seamus") sql = """INSERT INTO my_table (LastName, FirstName) VALUES (?, ?)""" cursor.execute(sql, data) The question marks are parameter markers, and they are replaced in the executed SQL statement by successive elements of the data tuple provided as the second argument to cursor.execute(). Beware, though. There are five different parameter styles, so the style you have to use might depend on the engine you are using. Hopefully this will be enough to enlighten you on a further reading of the DB API documentation. regards Steve -- http://www.holdenweb.com/ "Erno Kuusela" wrote in message news:kuoframchq.fsf at lasipalatsi.fi... > In article <3B39A1B8.A7FCE4C7 at kvarteret.uib.no>, Kjetil Nyg?rd > writes: > > | Is there a method to escape ' " \ and the like in python auto-magiacaly > | ? > > it is not portable between different sql dialects, so there is no > generic way. the database-specific modules can provide such a function, > but it is usually easy to write one yourself. > > -- erno From mwh at python.net Fri Jun 22 12:37:27 2001 From: mwh at python.net (Michael Hudson) Date: 22 Jun 2001 17:37:27 +0100 Subject: popen References: <3B336FCD.77678C54@noaa.gov> Message-ID: "Benjamin.Altman" writes: > I was wondering when something like popen2 would used over popen. When you need access to both the stdout and the stdin of the spawned process? > What> is the advantage of running as a sub-process? popen "runs as a sub-process" too. Either you or I are failing to understand something here... Cheers, M. -- Slim Shady is fed up with your shit, and he's going to kill you. -- Eminem, "Public Service Announcement 2000" From jhweeks at earthlink.net Sat Jun 16 12:38:57 2001 From: jhweeks at earthlink.net (John Weeks) Date: Sat, 16 Jun 2001 16:38:57 GMT Subject: gzip.py failure Message-ID: I'm running Python 2.0 from the SuSE 7.1 distribution. I'm getting an attribute error when trying to umcompress a gziped file. The error occurs on line 210 of the gzip.py module: if self.decompress.unused_data != "": There doesn't seem to be an "unused_data" attribute for the "decompress" object. Running this program: from gzip import * def gf(): f=GzipFile("g.data","r") c=f.read() print c gf() produces the following: Traceback (most recent call last): File "tt.py", line 7, in ? gf() File "tt.py", line 4, in gf c=f.read() File "/usr/lib/python2.0/gzip.py", line 149, in read self._read(readsize) File "/usr/lib/python2.0/gzip.py", line 210, in _read if self.decompress.unused_data != "": AttributeError: unused_data Anybody have any ideas? Thanks, JW jhweeks at earthlink.net From gmcm at hypernet.com Mon Jun 25 09:52:29 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 25 Jun 2001 13:52:29 GMT Subject: Standalone .exe's using installer/builder question References: <9gsld3$5n6$1@plutonium.btinternet.com> <90C76054Egmcmhypernetcom@199.171.54.155> <90C7AD776gmcmhypernetcom@199.171.54.155> <9h77t7$kr6$1@uranium.btinternet.com> Message-ID: <90CB61DD0gmcmhypernetcom@199.171.54.155> Gaz wrote: >Im still having trouble getting standalone >(http://www.mcmillan-inc.com/builder.html) to work on WinME, this is my >autoexec.bat file:- [snip snip] >any ideas why this isn't working? im thinking that when i first run >'SetupTK.py' its not finding certain .dlls or something? 'cos i get more >or less the same 'No module found' in the console when i run it! >suggestions would be greatly apprieciated! :) Your PATH looks fine, the build messages look fine, so your guess looks correct. SetupTK does make some assumptions about your Tcl/TK install. The important thing is that the "trees" option in tk.cfg names the directory the holds the tcl8.N and tk8.N directories. Some tcl/tk tools will put the .dlls into windows/system, which throws off the search for the tcl/tk lib files. You can just edit tk.cfg manually. Here's what mine looks like: [TK] type = CARCHIVE name = tk.pkg trees = D:\Programs\Tcl\bin\../lib support = 0 installscript = installTK.py extypes = .lib expatterns = demos, images - Gordon From grante at visi.com Sat Jun 2 11:53:08 2001 From: grante at visi.com (Grant Edwards) Date: Sat, 02 Jun 2001 15:53:08 GMT Subject: Inexact representation cases (Re: Against PEP 240) References: <9f273c21ar5@enews2.newsguy.com> Message-ID: On Sat, 2 Jun 2001 10:28:25 -0500, Clark C . Evans wrote: >On Thu, May 31, 2001 at 01:17:31AM -0400, Tim Peters wrote: >| >>> 1.1 >| 1.1000000000000001 >| >>> 7.35 >| 7.3499999999999996 > >What is the general pattern for these types of inexact >represenatation? 1/10 (base 10) is not representable in a finite base-2 number, in the same way that 2/3 is not representable in a finite base-10 number. The same goes for 35/100 -- Grant Edwards grante Yow! I will establish at the first SHOPPING MALL in visi.com NUTLEY, New Jersey... From guido at python.org Sat Jun 30 08:59:04 2001 From: guido at python.org (Guido van Rossum) Date: Sat, 30 Jun 2001 12:59:04 GMT Subject: Augmented Assignment (was: Re: PEP scepticism) References: Message-ID: Paul Prescod writes: > My point is that it is hard for a new user to "believe me" (or at least > understand me) when I say that tuples are not mutable but they see them > changing right in front of their eyes: > > >>> a=(1,2,3) > >>> a+=(8,3) > > The old behaviors strongly emphasized the non-mutability of things. The > new operators undermine that understanding. Maybe the benefits outweigh > this cost but I've seen this misunderstanding myself so I know it is a > real cost. I have a few slides with some very effective pictures showing what's going on here, after which it is a non-issue. --Guido van Rossum (home page: http://www.python.org/~guido/) From sill at optonline.net Fri Jun 29 18:46:02 2001 From: sill at optonline.net (Rainy) Date: Fri, 29 Jun 2001 22:46:02 GMT Subject: Discussions and developing References: Message-ID: On Sat, 30 Jun 2001 01:25:20 +0400 (MSD), Roman Suzi wrote: > Hello, > > you, like myself, read (and write) to this mail-list/usenet group devoted > to our beloved Python. > > We generate several megabytes per month. > > Python code (src) is 15-20 Mb. > > So, we could type one Python per 2 months. (Well, if we count quoting, > probably in 6 months, but still impressive figure). > > Just why reacting to PEPs and accusations/opinions in newsgroup is more > attractive than writing good piece of code for library, for some > interesting Open Source project? (Am I alone or others also experience > this temptation?) > > Lets imagine that 1/3 of the letters to c.l.p is converted to useful > Python code. But no! It's far more interesting to react to yet another > PEP! As for me, it probably takes 20 to 30 times longer to write a piece of useful code vs. an email or a usenet post of same length. > > And this happens because reacting/disputing/flaming/... is a (small) fight > between human beings and not between human being and dumb machine which > need to be coded. > > May be, with time some kind of subject-against-subject programming > technique will be invented, I dunno, and disputes will create not > only tryth but quality code. Program gaming bots that compete? I think there's a game called fighting bots or something similar. > > I do not know how to convert my recent c.l.p. addiction into something > useful for all. (if I only new how to be productive after full-time > work...) It is useful, just not as useful as great useful programs. I think you're missing the fact that you can't do the same thing without breaks. I code, get tired and/or bored, read k5 or usenet, post, watch simpsons, code some more, all that in while 1: loop ;-). If I try to keep coding while bored/tired, it's inefficient - I either hit a stonewall or (worse) do something dumb that I'll have to recode and, I found, taking a rest (changing activity is a form of rest!) makes more sense in the long run. > > So, I personally decided to shut up and not to participate in prolonged > PEP discussions where no special protest must be expressed. This will > be better for everyone, including myself. > > Lets silence for 1 day in memory of Jim Ellis, one of the Usenet > creators, who died 28.6.2001. > > Sincerely yours, Roman Suzi -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: http://silmarill.org/cymbaline From tismer at tismer.com Tue Jun 12 18:21:25 2001 From: tismer at tismer.com (Christian Tismer) Date: Wed, 13 Jun 2001 00:21:25 +0200 Subject: Creating Typeinfo for Python COM servers? References: <9fnocb$550f3$1@ID-59885.news.dfncis.de> <3B1F69CD.5000704@ActiveState.com> <9fofhe$5c8p0$1@ID-59885.news.dfncis.de> Message-ID: <3B2695E5.7D6A68B8@tismer.com> Thomas Heller wrote: > > "Mark Hammond" wrote in message news:3B1F69CD.5000704 at ActiveState.com... > > Thomas Heller wrote: > > > > > Is it possible to (let python) create type-information for > > > a COM server written in python? > > > > Umm - yes and no :) > > > > Technically, yes. Everything needed has been exposed, and indeed some > > "concept" code has been done. > Thanks, Mark. > > Ok, I found Christian Tismer's code (which seems to be the most > recent one?). It looks like it is doable... Where did you dig that out? If I had finished a fourth of he projects that I started, I'd be a rich man :-)) If you like to, we can put that back on the boiler plate, of course. I though someone else took over and this were done already. No? cheers - chris -- Christian Tismer :^) Mission Impossible 5oftware : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net/ 14163 Berlin : PGP key -> http://wwwkeys.pgp.net/ PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com/ From aleaxit at yahoo.com Thu Jun 14 07:17:54 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 13:17:54 +0200 Subject: Python grammar.. References: <3b281e48.38650376@news.laplaza.org> Message-ID: <9ga6hc02m8k@enews1.newsguy.com> "Mats Wichmann" wrote in message news:3b281e48.38650376 at news.laplaza.org... ... > >> Yes, but if I were designing a language today, I think I would > >> request you to be EXPLICIT about "ignoring the return value" -- ... > Seems like you could do it the other way around...add a bit of > something to the function def to say "this is a procedure". Should To the *DEF*? Why ever, and what good would that do, given the name-to-object association is performed dynamically anyway?! The lack of return, or 'return' w/o args, or 'return None', is all that's needed to signify that the function is not returning a value _this_ time. I'm talking about run-time controls, NOT compile-time ones...! Alex From sill at optonline.net Wed Jun 13 17:15:44 2001 From: sill at optonline.net (Rainy) Date: Wed, 13 Jun 2001 21:15:44 GMT Subject: how to get teh path of a script References: <3B27C7A9.3B9D3F4B@free.fr> Message-ID: On Wed, 13 Jun 2001 20:05:29 GMT, St?phane BAUSSON wrote: > Hello > > I would like to get for exemple in my_script.py located at > /home/toto/my_script.py to get in my_script.py the value "/home/toto" > ... > Any hint ? > > Thanks > > Stephane > > -- > stephane.bausson at free.fr - Toulouse (France) > > > import os print os.getcwd() -- Jupiter and Saturn Oberon Miranda And Titania Neptune Titan Stars can frighten - Syd From thomas at xs4all.net Thu Jun 7 05:48:58 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 7 Jun 2001 11:48:58 +0200 Subject: WHY is python slow? In-Reply-To: <4.3.2.7.2.20010607144657.042f8328@bdg.centrin.net.id>; from steven@haryan.to on Thu, Jun 07, 2001 at 02:52:36PM +0700 References: <4.3.2.7.2.20010607144657.042f8328@bdg.centrin.net.id> Message-ID: <20010607114858.Y690@xs4all.nl> On Thu, Jun 07, 2001 at 02:52:36PM +0700, Steven Haryanto wrote: > Although it is generally accepted that Python is slower than > Java/Perl/Ruby, a layman like me would be curious to know why > exactly this is so. In other words, why is the implementation > of a language like Ruby (which is on par with Python in terms > of 'everything is an object', strong reflection, dynamic > nature). > My first guess would be the ubiquitous use of dictionaries? As far as I know, Python dictionaries aren't particularly slow. I also have no reason to believe that Perl is indeed structurally faster than Python, excepting perhaps regular expressions and serious string munching. Tim has stated before that idiomatic Python is faster than idiomatic Perl on his machine (but then, that's Windows .) I don't know that Ruby is faster than Python, but I know jack shit about Ruby, so I can't say much about it. Java is faster probably because it was designed to be almost-compilable. Python is a lot more dynamic than is Java, and a compiler can take much less for granted. That said, the biggest reason Java is faster than Python is probably the money thrown into it. If someone was to fund Python the way Java has been funded, who knows ;) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From emarkp at CSUA.Berkeley.EDU Fri Jun 1 15:13:24 2001 From: emarkp at CSUA.Berkeley.EDU (E. Mark Ping) Date: Fri, 1 Jun 2001 19:13:24 +0000 (UTC) Subject: Iteration index References: <9f63lo$rb0$1@zeus.polsl.gliwice.pl> Message-ID: <9f8pgk$11l6$1@agate.berkeley.edu> In article , D-Man wrote: >Yes, but I think > >s = ('a', 'b', 'ala', 'a') >for i in xrange( len( s ) ) : > print i , s[i] > >is easier to read, and you don't have the chance of forgetting to >increment the counter. Agreed. But does it introduce n^2 complexity? I can't find anything in the python docs that says that indexing into a list is O(1)--and most people assume that indexing into a list is O(n). -- Mark Ping emarkp at soda.CSUA.Berkeley.EDU From nas at python.ca Mon Jun 18 21:08:07 2001 From: nas at python.ca (Neil Schemenauer) Date: Mon, 18 Jun 2001 18:08:07 -0700 Subject: PEP 255: Simple Generators In-Reply-To: <9glhg7$dlk$1@nntp6.u.washington.edu>; from owen@astrono.junkwashington.emu on Mon, Jun 18, 2001 at 11:32:31AM -0700 References: <9glhg7$dlk$1@nntp6.u.washington.edu> Message-ID: <20010618180807.A8534@glacier.fnational.com> Russell E. Owen wrote: > * A generator looks like a function until you find the "yield" statement > inside. I think this will make the code much harder to read. One keyword > buried anywhere in a function totally changes its behavior. Not really. For example, the functions def f1(n): for i in range(n): yeild i def f2(n): return iter(range(n)) do pretty much the same thing. "yeild" is just a handy way of creating iterators. Neil From jp at ulgo.koti.com.pl Sun Jun 10 06:20:21 2001 From: jp at ulgo.koti.com.pl (Jacek =?iso-8859-2?Q?Pop=B3awski?=) Date: Sun, 10 Jun 2001 10:20:21 +0000 (UTC) Subject: return from class? Message-ID: I use python and Tkinter. I have "Add product" window: NAME: [.entry.] PRICE: [.entry.] PRODUCER: [.label.] [Button] When I click "button" - another window should open, with Listbox of corporations, then I should select on corporation and click "OK" in that window, then id of that corporation should be returned to this "add product window". So I created other class - with listbox, scrollbar, button, but I don't know what should I write in command function for button "OK". Class instance should be destroyed and return value - id of selected corporation. How to do this? -- She never breaks into the conversation He seems to be the reason why she lives She tries to be the perfect kind of stranger But we always seem to love the most The ones who never give "Between Two Hearts" - Ronnie James Dio From gerson.kurz at t-online.de Sat Jun 9 02:11:23 2001 From: gerson.kurz at t-online.de (Gerson Kurz) Date: Sat, 09 Jun 2001 06:11:23 GMT Subject: Just a small quine References: <3b1fa942.11180453@news.t-online.de> <9fru2m$5n2f8$1@ID-91520.news.dfncis.de> Message-ID: <3b21bcf9.498656@news.t-online.de> On Sat, 9 Jun 2001 00:08:23 +0530, "Rajarshi Guha" wrote: >What *is* a quine? A quine is a self-reproducing program: a program, whos output is the program code itself. For more detailed info and examples of quines in various programming languages, see http://www.nyx.net/~gthompso/quine.htm From me at nospam.com Sat Jun 2 18:30:47 2001 From: me at nospam.com (Bart Kowalski) Date: Sat, 2 Jun 2001 18:30:47 -0400 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> Message-ID: > I agree totally, but fact is 99.99999% of the commersial world uses win32. LOL! This is just ludicrous. It's more like 0.01% yeah. You are ignoring all the embedded processors (watches, cell-phones, calculators, etc), all serious research work (supercomputing), most of the internet (servers, routers), and many other complex systems (nuclear reactor controllers, spacecraft controllers, flight simulators). Your "commersial world" (sic) includes but a very insignificant portion of the market which is called "the home user". This is the low quality part of the software world. The populace. The part that doesn't require 80 GB/sec bandwidth or microsecond response times. Many of us couldn't care less about that part of the market and are very happy providing quality software for the remaining 99%. Bart. From mwh at python.net Wed Jun 20 11:57:15 2001 From: mwh at python.net (Michael Hudson) Date: 20 Jun 2001 16:57:15 +0100 Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: <3B2EADB0.9DBC6FC8@earthlink.net> <3B2EC98E.FE0F1B6E@earthlink.net> Message-ID: "Kevin Altis" writes: > Argh, yes you do need to register, sorry. It says in the heading under "group settings" "Archives for members only" which suggests that there's some other option (& in fact I know there's some other option - qv. http://groups.yahoo.com/group/python-list ) > Well, there aren't that many messages yet. I'm open to suggestions > for another place to run a mailing list that doesn't require > registration. You can subscribe without registering (I have!), just not log into the website. Set the archives to public (I don't know how to do this, I'm afraid, but I'm certain it can be done), and *I'll* be happy enough. Cheers, M. -- This makes it possible to pass complex object hierarchies to a C coder who thinks computer science has made no worthwhile advancements since the invention of the pointer. -- Gordon McMillan, 30 Jul 1998 From guido at digicool.com Sat Jun 23 14:18:33 2001 From: guido at digicool.com (Guido van Rossum) Date: Sat, 23 Jun 2001 14:18:33 -0400 Subject: Trouble downloading Python-2.0.1 In-Reply-To: Your message of "Sat, 23 Jun 2001 14:10:55 EDT." References: Message-ID: <20010623182017.YCWU4013.femail3.sdc1.sfba.home.com@cj20424-a.reston1.va.home.com> A follow-up: - The SourceForge file was truncated. SF appears to be experiencing serious difficulties at this point; I don't know if that had anything to do with it. (Someone also stole the Windows files that Tim had uploaded the night before the release...) - The python.org files were broken in a bizarre way: for some reason it was a gzipped gzipped tarball. I must've done something like "tar czf - Python-2.0.1 | gzip >Python-2.0.1.tgz". I've fixed the tgz file on python.org, updated the MD5 checksum, and added a note to the top of the page explaining the confusion. I'll upload the good tgz file to SF as soon as I can log in there. --Guido van Rossum (home page: http://www.python.org/~guido/) From akuchlin at mems-exchange.org Mon Jun 11 17:47:12 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 11 Jun 2001 17:47:12 -0400 Subject: PEP 259: Omit printing newline after newline References: Message-ID: <3dd78ag04f.fsf@ute.cnri.reston.va.us> Guido van Rossum writes: > I propose to skip printing the newline when it follows a newline > that came from data. -1; I'd rather see a strip_trailing_whitespace argument added to .readlines(), or some alternative idiom encouraged that sidesteps the issue. Magical behaviour is bad. And since this is an incompatible change, it should be triggered by some __future__ incantation. I don't see how that would be implemented, though, given that this changes the meaning of a particular opcode. --amk From fredrik at pythonware.com Tue Jun 12 15:02:24 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 12 Jun 2001 19:02:24 GMT Subject: Python for win32 development, GUI, Database, dlls References: <9fnrc8$lmp$1@newnews.mikom.csir.co.za> <9g5lue$ird$5@216.39.170.247> Message-ID: <4HtV6.4801$G4.715200@newsc.telia.net> David LeBlanc wrote: > and i'm not sure about commercial use (resale - I think internal use is > unrestricted) of PIL. PIL is free for all sorts of commercial use -- but if your company makes money from it, please consider sponsoring the development by purchasing a support package: http://www.pythonware.com/products/pil/support.htm Support customers also have access to the PIL Plus package (see the site for details). Cheers /F Fredrik Lundh, CTO Secret Labs AB / PythonWare From djc at object-craft.com.au Mon Jun 18 20:10:20 2001 From: djc at object-craft.com.au (Dave Cole) Date: 19 Jun 2001 10:10:20 +1000 Subject: csv-0.3 released References: <3B2E5BFB.F0EAB859@home.net> Message-ID: >>>>> "Skip" == Skip Montanaro writes: Chris> This appears to mean that the CSV parser is slower that Chris> string.split, and as far as I can tell, does pretty much the Chris> same thing. What am I missing? Skip> CSV files can be syntactically more complex than simply Skip> inserting commas between fields. For example, if a field Skip> contains a comma, it must be quoted: Skip> 1,2,3,"I think, therefore I am",5,6 Skip> Also, you can quote fields (as above, but the quotes are not to Skip> be kept in the parsed output. The above should yield Skip> ['1', '2', '3', 'I think, therefore I am', '5', '6'] Skip> Since fields are quoted using quotation marks, you also need a Skip> way to escape them. This is usually done by doubling them: Skip> 1,2,3,"""I see,"" said the blind man","as he picked up his Skip> hammer and saw" Skip> There are probably more rules, but the comma and quoting rules Skip> eliminate simple string.split as a possibility. I believe the Skip> author was only using his simple example as a bit of input that Skip> could be fed to both string.split and csv.parser. A more accurate explanation is that the author was too lazy/busy to produce a good a good example like this. The other thing that it supports is multi-line records. When you export data from Access and Excel you sometimes get files which look like this: 1,2,3,"""I see,"" said the blind man","as he picked up his hammer and saw" That is a single record split over three lines with text fields containing embedded newlines. This is what happens when you pass that data line by line to the CSV parser. ferret:/home/djc% python Python 2.0 (#0, Apr 14 2001, 21:24:22) [GCC 2.95.3 20010219 (prerelease)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import csv >>> p = csv.parser() >>> p.parse('1,2,3,"""I see,""') >>> p.parse('said the blind man","as he picked up his') >>> p.parse('hammer and saw"') ['1', '2', '3', '"I see,"\012said the blind man', 'as he picked up his\012hammer and saw'] Note that the parser only returns a list of fields when the record is complete. - Dave -- http://www.object-craft.com.au From chat at linuxsupreme.homeip.net Thu Jun 14 16:44:22 2001 From: chat at linuxsupreme.homeip.net (Chad Everett) Date: 14 Jun 2001 15:44:22 -0500 Subject: Redhat 7.1 and Python 2.1 References: <20010524235013.K690@xs4all.nl> Message-ID: On 14 Jun 2001 13:49:37 -0600, Jason R. Mastaler wrote: >Thomas Wouters writes: > >> > > - Why doesn't Redhat ship with Python 2.1? The 1.5.2 it ships with >> > > is a little dated isn't it? >> > Yes, totally. >> >> > The reasons according to a couple RedHat developers are: >> >> > "Compatibility - the newer versions aren't compatible with 1.5, and >> > they don't even store modules in the same location." >> >> > "Binary compatibility issues. We don't break binary compatibility in >> > a minor release, and the binary format for python modules has >> > changed." >> >> I find it terribly amusing how those two 'problems' cancel each >> other out. Binary compatibility shouldn't be an issue because >> modules are stored in different locations anyway! It's really not >> that hard to ship both python1.5 and python2.0 (and python2.1, and >> python2.1.1, and ... ;) > >Apparently what they meant was that a module built for python on Red >Hat Linux 7.x needs to work on all 7.x releases. Thus, the primary >python can't be upgraded during the cycle. > And the reason they don't ship with both Python 1.5.2 and Python 2.1 is? -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From chrishbarker at home.net Fri Jun 8 15:16:30 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 08 Jun 2001 12:16:30 -0700 Subject: Mutable class attributes are shared among all instances, is it normal ? References: <27vvht4uslv2ibq2q8ee4tovg86e7qempb@4ax.com> <3B201662.6DB35744@home.net> <991975696.169576@yabetcha.drizzle.com> Message-ID: <3B21248E.C27B8DF3@home.net> Donn Cave wrote: > I have no argument with the facts here, but I have to disagree about > the reason for the confusion. Of course, it's very difficult to ever know the reason for someone elses confusion. > It should be clear from this that the distinction between mutable > and immutable objects here is actually completely irrelevant, I'm not sure it's completely irrelevant. The question is: are you mutating an existing object, or are you re-assigning a name to a new object. Since you can't do the former to an imutable object, it does make a difference. Perhaps the real source of the confusion is that assignement can be used to do both. The to newbe, the distiction between: l = [1,2,3] and l[:] = [1,2,3] is not terribly obvious. When you see: l.append([1,2,3]) It's more obvious that you are changing something in place. Note that the original post asked about "Mutable class attributes", so I did think the confusion had to do with mutable vs. not mutable. He was trying to do the same thing with a mutable and a non-mutaable type, and not getting the same results. > and > when we introduce this red herring into the picture we make a simple > matter much harder to understand. (It's so often repeated here, yet > makes no sense to me. I don't wish to pick on this post, the author > went went to considerable trouble to help out and I'm just off on a > rant about this detail, because the subject has the word "mutable".) I don't feel picked on. I think this is always a difficult subject for new users to get a handle on, I know it took me a while. I'd love to find the best way to explain it. > When I write "self.x = a", it does not matter in any way whether > self.x is mutable. It is purely irrelevant. true, and I did try to make that clear. > To understand why "self.x = a", we really have to understand the > Python object/reference/namespace model, which again has nothing > to do with mutability. If you understand what "self.x = a" means > in that model ("make name 'x' in namespace 'self' refer to the > same object as name 'a' in the default namespace[s], possibly > hiding another name in a posterior namespace" ... uh, there has > to be a better way to say that!) We really do need to find a better way, I wish I had it! That wasn't bad, however. > Now I think what people mean to point out here, is that given the > realities of life with Python, one may choose to substitute > "self.x = a" with some expression that modifies a mutable object, > like "self.x[0] = a". That's fine, but of course the point is > not that self.x is mutable, the point is that you are modifying it. I think the point is not that self.x is mutable, but that self.y is NOT mutable. In other languages, x points to a particular piece of memory, and if you write x = somethingnew, that same memory is being used. In a number of begining programming texts I have seen variables described as boxes that numbers can be put in. Python mutable types can be boxes, and their contents changed without changing the box intself, but python imutable types are NOT boxes, so the distinction is important. Now I have to wonder if the original poster is more or less confused. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From quinn at regurgitate.ugcs.caltech.edu Wed Jun 27 16:49:39 2001 From: quinn at regurgitate.ugcs.caltech.edu (Quinn Dunkan) Date: 27 Jun 2001 20:49:39 GMT Subject: irix5 demos (was: Re: PEP 260: simplify xrange()) References: Message-ID: On Wed, 27 Jun 2001 00:38:15 -0400, Tim Peters wrote: >>> although-it-would-be-impolite-to-ask-we-why-still-ship-a-directory- >>> full-of-crufty-old-irix5-demos-in-the-std-library-ly > >> Perhaps because the Irix community would be quite Irate if they were >> removed? > >Doubt it: the Irix5 library files haven't really been touched since 1993. >For several years we've also shipped an Irix6 library with all the same >stuff. But I suppose releasing a new OS was a symptom of SGI picking on its >users too . Then I suggest that the new warning framework be used to tag all those with obsolete warnings in the next release. See if angry irix5-using hordes suddenly turn up, and if they don't, remove the libs in the release after that. I suspect even irix5 users would be interested in more cross-platform solutions nowadays. just-one-small-skirmish-in-the-war-against-distribution-bloat-ly y'rs From writeson at earthlink.net Mon Jun 18 09:03:46 2001 From: writeson at earthlink.net (Doug Farrell) Date: Mon, 18 Jun 2001 13:03:46 GMT Subject: Python 2.0 and wxPython 2.0 References: <3B2D8EC1.80202@senux.com.NOSPAM> Message-ID: Brian, Will do. If it doesn't import (which I think is the case as I remember an error message of that sort), what should I do about it? Is there some PATH environment variable I should set? Thanks for the quick reply by the way. Doug "Brian Lee" wrote in message news:3B2D8EC1.80202 at senux.com.NOSPAM... > Doug Farrell wrote: > > >Hi all, I have Mandrake 8.0 installed on my system and I'm a little > >confused. I went to try and install wxPython (which I downloaded from the > >website) and the system tells me it's already installed, which is great! > >However, I downloaded the demo and I can't seem to run any thing there. Does > >anyone know what's going on and how I might fix this? I'm a relative linux > >newbie... > > > >Thanks in advance, > >Doug Farrell > > > > Try to import the module on Python prompt to check whether your wxPython > is placed correctly or not. > > $ python > Python 2.1 (#1, May 30 2001, 10:38:50) > [GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-81)] on linux2 > Type "copyright", "credits" or "license" for more information. > >>> import wxPython > >>> > > - Brian,. > > From rnd at onego.ru Wed Jun 20 09:17:02 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 20 Jun 2001 17:17:02 +0400 (MSD) Subject: [Tutor] cgi FieldStorage __str__ problem - I think... In-Reply-To: <31575A892FF6D1118F5800600846864D78BD6B@intrepid> Message-ID: On Wed, 20 Jun 2001, Simon Brunning wrote: > > form = cgi.FieldStorage() > formstrings = {} > for formfield in form.keys(): > formstrings[formfield] = form[formfield].value > mailtext = mailtemplate % formstrings > > (I tried form.values() first, but the FieldStorage object doesn't seem to > support it.) > > Not pretty, but it works. Much like myself, really. > > > Or maybe trying to do this with a single % call is a bit too cute. > > Yeah, but it would have been cool, no? No. It's a security risk. Just ALWAYS check user inputs on CGI or other places. Strip "../" and other things, depeding on what you do with your data. Etc. Even if you are the only user of your CGI, make it a habit to check input. It's a good habit. And your mail template is exploitable, I guess, to spam the World, because you direct user input into it, checking nothing. Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From Attila.Feher at lmf.ericsson.se Thu Jun 7 03:37:15 2001 From: Attila.Feher at lmf.ericsson.se (Attila Feher) Date: Thu, 07 Jun 2001 10:37:15 +0300 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3b1cdc84.5514@bolder.com.co.za> <9fleid$3rp$1@oslo-nntp.eunet.no> <3B1E4951.7F36D4E4@alcyone.com> <3B1E50E1.35AE59C@lmf.ericsson.se> <3B1E52DA.BBC9FC32@alcyone.com> <3b1e5601.3970@bolder.com.co.za> <3B1E5836.E7F1D88F@lmf.ericsson.se> Message-ID: <3B1F2F2B.89C7E28B@lmf.ericsson.se> TGOS wrote: > > On Wed, 06 Jun 2001 19:20:06 +0300, Attila Feher > wrote: > > > And they don't program in Pascal! :-))) > > Why not? http://www.pbm.com/~lindahl/real.programmers.html Worth reading. The one I've read originally was translated to Hungarian, where "quiche eaters" made no sense so it was simply cut out and changed to the term something like greenhorn, but... it is a term from those clotches weared by children usually having the buttons on the back. So the term "quiche eater" was there "backbuttoned" (direct translation from Hungarian) - so that is one reason why I had no idea about quiche - the other is that all I know from France is the world most expensive highway tools of the world... on the Hungarian highways run by French companies... :-))) A From raskol at hushmail.com Wed Jun 13 11:49:14 2001 From: raskol at hushmail.com (raskol) Date: Wed, 13 Jun 2001 11:49:14 -0400 Subject: design patterns in python Message-ID: <3b2786d5$1_3@newsfeeds> Hey folks, Being interested in looking at (and understanding) design patterns [GOF] in python... and having gone through the obligatory google searches etc.. I am still somewhat frustrated by the lack of currently available information relating to this specific subject. I mean there ARE some smatterings of implementation and insight, but as of now there is no single source for python patterns that has developed anything like authoritative mass or actually succeeded in 'comprehensively' covering the patterns in GOF book. Being a newbie, still a minor snakelet, I was wondering if there would be interest in an effort by some of the more lucid pythonistas out there to contribute their offerings to some central source: say the python cookbook or sourceforge or whatever. twould be a great service to the community! BTW I found this to be a useful link for an overview of the situation: http://thinkware.se/cgi-bin/thinki.cgi/PythonPatterns cheers, raskol @ hushmail.com -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From gregj at pobox.com Sat Jun 16 05:22:06 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Sat, 16 Jun 2001 09:22:06 GMT Subject: IP address to binary conversion References: Message-ID: <2zFW6.182795$p33.3762571@news1.sttls1.wa.home.com> "Jeroen Wolff" wrote in message news:vqajitkao6tvll7ads8v84nbatp1hhr8jn at 4ax.com... > > > > >>>> host = n & mask > >>>> net = n - host > > >>>> print "net: %X host: %X" % (net, host) > >net: C0000000 host: A80201 > > > Is there a way back to present the calculated results in a doted > decimal notation? The posted solutions using socket/struct are fine. Here's another way: --- def numToDottedQuad(n): "convert long int to dotted quad string" d = 256 * 256 * 256 q = [] while d > 0: m,n = divmod(n,d) q.append(str(m)) d = d/256 return '.'.join(q) --- Greg Jorgensen PDXperts LLC Portland, OR, USA gregj at pdxperts.com From nperkins7 at home.com Wed Jun 6 00:04:39 2001 From: nperkins7 at home.com (Nick Perkins) Date: Wed, 06 Jun 2001 04:04:39 GMT Subject: integers ( ++ operator ? ) References: <9fjd8q$qb6$1@charm.magnus.acs.ohio-state.edu> <9fjgqf$rp0$2@brokaw.wa.com> <696rhtkhgtf4o1i5u05e4k9pvujb8kmqaa@4ax.com> Message-ID: "Alan Daniels" wrote in message > I believe the new "x += 1" syntax is just synactic sugar which serves > as shorthand for "x = x + 1", although I'd have to delve through the > interpreter source code to be 100% sure. ..no need to look at the interpreter source: >>> x=10 >>> id(x) 3161552 >>> x+=1 >>> id(x) 3161960 x does indeed refer to a different object. In other languages, this effect could be written something like: x = new Integer( x.intValue() + 1 ) ..the object that x used to refer to, is simply garbage-collected. (unless other names also refer to it). I don't think I need x++ when x+=1 is only one character more. Furthermore, if we had x++ people would be tempted to use it inside an expression, which I think would have to be illegal. ( I defer to the experts on that point ) From rnd at onego.ru Sun Jun 10 22:51:09 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 11 Jun 2001 06:51:09 +0400 (MSD) Subject: Global in multiple files In-Reply-To: Message-ID: On Sun, 10 Jun 2001, Rainer Deyke wrote: >"Roman Suzi" wrote in message >news:mailman.992195796.5861.python-list at python.org... >> On 10 Jun 2001, Artur Skura wrote: >> >> >>Why do you need global variable in the OOP design anyway? >> > >> >I knew you would say that! ;) >> >> Yes, of course. Because in True Object Design there is no place for >> anything global. > >That's a silly philosophy. That was said with irony. There is always TheUniverse object. It is global, depending on philosophy and religion ;-) >Classes are objects; are they allowed to be global? Classes belong to meta-system, which serves the purpose of description of the system. That's why classes are usually global. At least at the module level. >What about objects that provide a higher level of abstraction than >classes? The same. >-- >Rainer Deyke (root at rainerdeyke.com) >Shareware computer games - http://rainerdeyke.com >"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Monday, June 11, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Useless Invention: Fur sink." _/ From dsh8290 at rit.edu Wed Jun 20 12:16:12 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 20 Jun 2001 12:16:12 -0400 Subject: Any other Python flaws? In-Reply-To: <636fd38f.0106200145.337888a3@posting.google.com>; from tiago.henriques@portugal.sun.com on Wed, Jun 20, 2001 at 02:45:05AM -0700 References: <3b296534.514160393@wa.news.verio.net> <3b2a94a6.591842855@wa.news.verio.net> <636fd38f.0106200145.337888a3@posting.google.com> Message-ID: <20010620121612.C7492@harmony.cs.rit.edu> On Wed, Jun 20, 2001 at 02:45:05AM -0700, Tiago Henriques wrote: | | While we're on the subject of namespaces, one thing that I've felt | from the beginning was missing from Python is a way to navigate the | name space tree like a file system. | | For example, instead of typing: | dir(os.path) | dir(os) | | one could type: | cd(os.path) | dir() | cd(..) | dir() | pwd() | 'os' | | or something similar. This could also be coupled with a context | dependant help function. | | This is not so much a wart as a missing feature, but I feel it would | make python even more enjoyable for newbies. Well, this doesn't belong in Python. Remember that Python is a programming language. It happens to currently have an implementation that is interpreted and also allows for interactive use. This feature you are looking for (both the "os shell-like module browsing and the context-sensitive help) belong in IDEs, not the language itself. I agree that it would be nice to have some sort of object browser, and even a context-sensitive jump-to-the-documentation feature (in the object browser), but that is a task for an IDE/debugger. -D From bos at hack.org Sun Jun 17 13:42:09 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Sun, 17 Jun 2001 19:42:09 +0200 Subject: list.sort() Message-ID: <3B2CEBF1.CCF5377D@hack.org> I know the sort-method on lists changes the list in-place and doesn't return anything, but I'm still confused. Take these examples: >>> l = [4,3,2] >>> l = l >>> l [4, 3, 2] The list is unchanged, even after assigning it to itself. But: >>> l = l.sort() >>> l >>> print l None If we split the problem into parts, "l.sort()" sorts l and it becomes [2,3,4]. I expected it to be [2,3,4] after assigning it to itself (after it got sorted), but the list seem to got deleted instead. I don't like this behaviour, at all. Why does Python behave like this? Why does sort() change lists _in-place_, instead of returning a list? -- Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From aleaxit at yahoo.com Fri Jun 1 12:23:09 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 1 Jun 2001 18:23:09 +0200 Subject: Returning 'None' on Instantiation ? References: Message-ID: <9f8fhf0ie2@enews1.newsguy.com> "Dave Haynes" wrote in message news:c396ce35.0106010528.46f144db at posting.google.com... > Is there a way to optionally return 'None' on instantiation? I'm Sure! Just make sure that what you call for instantiation is a FUNCTION and you can return whatever you like. This design pattern is called "factory functions". > thinking of something like the following: > > class myClass: > def __init__(self, param): > > if : > > else: > Refactor to: class myClass: def __init(self, param): _myClass = myClass def myClass(param): if : return _myClass(param) else: return None The Pythonic twist on this is that we let the factory function's name re-bind the class's name, so from the point of view of any caller it's transparent that we ARE using a factory-function. This is not strictly necessary and in fact it could be clearer to have different names, but it's one possibility. > myParam = GetParam() > myObj = myClass(myParam) > > if myObj: > print 'Okay' > else: > print 'Couldn't make myObj from myParam' This caller-code works exactly as you desire when you use factory-function. > This is a fairly common state of affairs. Sure, that is why Factory is such a crucial design pattern -- the start of them all, in fact. > If there's nothing specific > in Python to accomodate this, what methods are considered robust by > this NG? Factory is perfectly-robust. The only Python specific part is the possibility to "reuse the names", but it's debatable whether that adds anything to actual use, and it sure doesn't add anything to _robustness_:-). Alex From tim.one at home.com Fri Jun 1 02:31:30 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 1 Jun 2001 02:31:30 -0400 Subject: docstrings, invention there of In-Reply-To: <200106010601.IAA08860@boris.cd.chalmers.se> Message-ID: [Laura Creighton] > We think we were the first people to ever a) put the doc in the code > b) make the interpreter extract them. We haven't been able to find > anybody earlier than us, at any rate. If somebody is out there, I > hope he is reading this newsgroup so we can find out. You _know_ when > you are not first, the rest of the time you just wonder. Guido wouldn't claim that docstrings were original with Python. I'm not sure who "we" refers to here, or to what "the interpreter"; Python's docstrings were most directly inspired by the similar facility in Emacs's elisp interpreter (and it wasn't original there either, of course -- the idea of attaching doc properties to Lisp atoms and extracting them via introspection must go back several decades). From db3l at fitlinxx.com Wed Jun 13 15:31:03 2001 From: db3l at fitlinxx.com (David Bolen) Date: 13 Jun 2001 15:31:03 -0400 Subject: [wxPython] Help with wxChoice! References: Message-ID: "SNYDER, BARRON F. (AIT)" writes: > But since you ask , I'm actually trying to append to a wxChoice control > that was laid out using wxDesigner. Since the widget code is automatically > generated from wxDesigner, I have to get the handle of the specific widget I > want by using wxPyTypeCast. Hmm, I just tried that as well (not with wxDesigner, but using FindWindowById on my own created wxChoice window) and it's working for me, so at first glance I would think that the code you're using ought to work. You didn't mention which wxPython release you're using - I suppose it could be a bug somewhere. Or could there be anything in the auto-generated code by wxDesigner that is perhaps clearly out the choice box at some point in time after you add the information? You might adding some debugging print's or something just after you append to the choice, using something like the FindString or GetString methods to try to determine if the choice thinks the new information has been added at that point in time. If so, then it would be an indication that something later on during processing (which could still be before the control is actually displayed to the screen) is removing information. You might also try directing this to the wxPython mailing list (wxpython-users at lists.wxwindows.org) and see if anyone there has any other suggestions. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From johnroth at ameritech.net Sun Jun 10 17:43:40 2001 From: johnroth at ameritech.net (John Roth) Date: Sun, 10 Jun 2001 14:43:40 -0700 Subject: Use Jython to make true executable? References: Message-ID: "Carl Fink" wrote in message news:slrn9i7bnv.o9r.carlf at panix2.panix.com... > In article , Michael Hudson wrote: > > > This is very unlikely to speed things up as much as you expect. I've > > never produced accurate numbers, but I'm fairly sure Python's runtime > > is dominated by locating applicable methods, not the dispatch loop in > > ceval.c. If you could analyse a program sufficently to compute (some > > of) these methods at compile time, *then* you might start to see a > > real speed up (especially if this let you unbox some integers & > > floats). > > Yeah, but Jython/gcc wouldn't involve ceval.c at all, would it? I > mean, presumably gcc would compile the methods themselves, and in an > optimized manner. Unfortunately, this is an essentially impossible problem. Note I said "essentially," not "absolutely." The essence is that anything you say in Python, even if it's as simple as "a = b + c" involves uncertainty at --run time-- about what you mean. If b and c are integers, then it means one thing. If they are floats, then it means something else. If they are strings, it means a third thing. If they are some kind of user defined objects that have overloaded "+" then hopefully the object knows what it means - the interpreter sure doesn't. If you could give the compiler a clue, say something like "a and b are integers that will never exceed the hardware definition of maxint," then a compiler would have something it could generate efficient code for. As it is, a compiled Python program would essentially be a long series of function calls to the same functions that the byte codes invoke. As Michael Hudson has commented, exactly how much this would squeeze out of run time is currently unknown, but it's unlikely to be major. In addition, I would think that a compiler could only optimize certain things, such as integer and floating arithmetic, method and function lookups, and a couple of more esoteric things. Strings and collection types, as well as much of the more interesting esoteric dynamic behavior will still require library functions. John Roth > -- > Carl Fink carlf at dm.net From tim.one at home.com Tue Jun 26 20:27:10 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 26 Jun 2001 20:27:10 -0400 Subject: PEP 260: simplify xrange() In-Reply-To: Message-ID: [Mark 'Kamikaze' Hughes] > Looks reasonable - are there any uses of the advanced behaviors in > the standard libraries? Heh. I expect Guido would say "braindead" instead of "advanced" . I was amazed to find that-- outside of the test suite --there are fewer than two dozen uses of xrange() in the entire distribution. I was even more amazed to find that almost all of them were added by me! All but one are of the "for yadda in xrange():" variety. The exception is types.py's necessary but unique XRangeType = type(xrange(0)) Apart from that, I know of several instances of spead-freak code not in the distribution (and not mine either) that does infinity = xrange(sys.maxint) # or even via the default-arg trick for whatever in whatchamacallit: for i in infinity: yadda yadda yadda if youbetcha: break I figure that will still work. > ... > You know, this is one of the things that amazes me about Python - > you actually *remove* features that aren't useful. He *wants* to -- not always possible, though. For example, Guido has little use for anything but floating-point numbers, but all the crybaby users keep whining for more string features . i-may-be-able-to-channel-him-but-for-some-reason-he-never-lets-me- speak-for-him-ly y'rs - tim From me at mikerobin.com Wed Jun 27 12:23:07 2001 From: me at mikerobin.com (Michael Robin) Date: 27 Jun 2001 09:23:07 -0700 Subject: Python for Commercial Games? References: <9haoiv$jnv$1@mtc1.mtcnet.net> Message-ID: <52e5ab5f.0106270823.599f61ae@posting.google.com> I assume you've seen PyGame?? It's great - I'm playing with it myself now. Check out: http://pygame.seul.org/ So, from a technical POV you should be OK. Only a real CPU-soaker should be a problem. Check out Solar Wolf for a great professional looking game written in PyGame. As for the for licensing issues, you should be ok too -- here's a response I got recently regarding licensing issues: ----------- >From Pete Shinners (the pygame guy...): ...with the LGPL you are allowed to sell the game binary only however you see fit. the requirement is that if you use the pygame libraries (and sdl, etc) you can only ship binaries that are from the original pygame source. if you end up making any changes to pygame you must release those changes. you can still release the game without shipping the source, the only source needed are any changes you make to pygame... your best bet is to send any pygame changes in to me. i'll likely add the changes into the real pygame source, and then there's no need for you to release any source. ---------------- hope this helps, mike "Kevin Riggle" wrote in message news:<9haoiv$jnv$1 at mtc1.mtcnet.net>... > I *do* realize that I'm posting to comp.lang.python , so please humor me > anyway... > > I am in process of designing a computer game; problem is, I want to at > least have a snowball's chance in Hades of selling the game. My question: > Would it be possible to write the dang thing in Python (PyWin), or is C/C++ > the better option in the Windows-centric world of game development right > now? Thanks in advance, > > Kevin From aleaxit at yahoo.com Thu Jun 14 06:06:43 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 12:06:43 +0200 Subject: Python grammar.. References: <3B28458C.F171FDB0@my.signature> Message-ID: <9ga2bu02i71@enews1.newsguy.com> "Steve Holden" wrote in message news:eoc#XQJ9AHA.269 at cpmsnbbsa07... > "Greg Ewing" wrote in message > news:3B28458C.F171FDB0 at my.signature... > > "Delaney, Timothy" wrote: > > > > > > a 1 ' OK > > > a(1) ' memory leak > > > > The "memory leak" part of that sounds like a bug in the > > implementation. It doesn't say anything about the merits > > or otherwise of the syntax. > > > Probably not, but if there'd been only one way to call procedures at least > Microsoft would have been forced to fix the problem rather than accepting > two syntaxes but only implementing one correctly. VB is, in any case, a Maybe this is the reason behind the incompatible change in the move VB.6 -> VB.NET (one of many): all calls to function and subroutines *DO* now require parentheses -- the parentheses in the call are not optional any more. > total dog's breakfast from a language point of view. It looks like VB.NET is marginally better (since all of the incompatible changes move it closer to Python: it now has a return statement, which can take a value -- mandatory parentheses on calls, as I mentioned -- no more "default value" on objects -- no more distinction between LET and SET assignments -- etc, etc). Alex From rnd at onego.ru Sat Jun 23 11:12:13 2001 From: rnd at onego.ru (Roman Suzi) Date: Sat, 23 Jun 2001 19:12:13 +0400 (MSD) Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: Maybe we can define generators like this, for example: def f(x): f.is_generator = 1 for i in x: yield k Here we explicitely tell that we want "function" to be a generator! (If we forget to do it, then it will be equivalent to: def f(x): ### f.is_generator = 1 for i in x: yield.append(k) return yield ) Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Saturday, June 23, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "He's not dead, Jim, he's just metabolically challenged." _/ From aahz at panix.com Fri Jun 29 01:56:57 2001 From: aahz at panix.com (Aahz Maruch) Date: 28 Jun 2001 22:56:57 -0700 Subject: threading question? References: Message-ID: <9hh5b9$j2r$1@panix3.panix.com> In article , Blue whale wrote: > >I am relatively new to python. Can anyone guide me to a good resource >where I can learn more about the threading module in python. I just >know that using threads one can write a program which can perform >multiple tasks indepedently and simultaneously. http://starship.python.net/crew/aahz/ -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Nothing fails like prayer" --bumper snicker From thomas at gatsoft.no Tue Jun 26 06:57:38 2001 From: thomas at gatsoft.no (Thomas Weholt) Date: Tue, 26 Jun 2001 10:57:38 GMT Subject: Any examples of more advanced use of minidom? Message-ID: Hi, I need more info and examples on use of the minidom-module. Does anybody got any snippets of code or examples to share? Thomas From haaserd at yahoo.com Fri Jun 8 16:25:06 2001 From: haaserd at yahoo.com (haaserd) Date: Fri, 08 Jun 2001 13:25:06 -0700 Subject: How do I serve an image from a Python Script? Message-ID: <3B2134A2.EFE1736F@yahoo.com> Hi, I am trying to serve an image from a Python script using Apache under Windows. My simple HTML statement: a picture ...and my simple script: #!c:/Python20/python.exe import sys def pix(): n = 'c:/My Pictures/Sample.jpg' p = open(n,'rb') apix = p.read() p.close() sys.stdout.write("content-type: image/jpeg\n\n") sys.stdout.write(apix) sys.stdout.flush() if __name__ == '__main__': pix() As you can see I am ignoring the CGI fields for the moment and am just trying to serve up an image. Through debugging statements that I have removed, I know the program crashes on the statement sys.stdout.write(apix) if the picture is over 200,000 bytes. On small images (10k), the script runs to completion, but no image appears. What am I doing wrong? TIA, Roger Haase From jkraska1 at san.rr.com Mon Jun 18 12:45:41 2001 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 18 Jun 2001 16:45:41 GMT Subject: qt or gtk? References: <9gk8he$8gl$1@brokaw.wa.com> Message-ID: >>Is this true for both qt for X and qt for windows or only for X qt? > > The GNU Public License does not specify what operating systems >it applies to. If you can build or modify the GPL version of QT to work >with the Windows operating system, then you can build GPL programs for >Windows with QT. The current source of Qt currently written for Windows is not covered by the GPL. While what you say is correct about the X codebase, the X codebase would have to be enormously modified to get it to work for Windows, and is probably beyond the inclination and abilitites of the poster who asked the question. C// From sdm7g at Virginia.EDU Thu Jun 21 23:25:04 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Thu, 21 Jun 2001 23:25:04 -0400 (EDT) Subject: Another Wart! string.find() [ was: namespace issue? ] In-Reply-To: <9gucf9$ruc$1@slb3.atl.mindspring.net> Message-ID: On Thu, 21 Jun 2001, Andrew Dalke wrote: > >>> print string.find.__doc__ > find(s, sub [,start [,end]]) -> in > > Return the lowest index in s where substring sub is found, > such that sub is contained within s[start,end]. Optional > arguments start and end are interpreted as in slice notation. > > Return -1 on failure. > >>> print string.index.__doc__ > index(s, sub [,start [,end]]) -> int > > Return the lowest index in s where substring sub is found, > such that sub is contained within s[start,end]. Optional > arguments start and end are interpreted as in slice notation. > > Raise ValueError if not found. > > > >>> > > Only difference is what to do when the substring isn't found; > return -1 or raise a ValueError. Of course, this introduces a difference in the behavior of string.index and list.index ( see the note in other post about whether strings should even be sequences ... ) and so creates another pothole for the unwary! -- Steve Majewski From rvprasad at cis.ksu.edu Tue Jun 19 19:23:13 2001 From: rvprasad at cis.ksu.edu (Venkatesh Prasad Ranganath) Date: 19 Jun 2001 18:23:13 -0500 Subject: Partially evaluated functions Message-ID: Hi, I have used ML and it is interesting how it is possible to specialize a function by partially evaluating when in curried form. Is partially evaluated functions possible in python? If there has been a discussion about it, where can I find the jist of the discussion? def conv(a, b, c): return (a + b) * c faren2cel = conv(b = -32, c = 5 / 9) The above example is naive, but surely used in proper way it can make life easy while programming. I think this would be great when trying to use patterns. waiting for reply, -- Venkatesh Prasad Ranganath From bernhard at intevation.de Fri Jun 29 05:04:44 2001 From: bernhard at intevation.de (Bernhard Reiter) Date: 29 Jun 2001 09:04:44 GMT Subject: PEP scepticism References: Message-ID: <9hhgbc$e50ak$2@ID-89274.news.dfncis.de> In article , "Tim Peters" writes: > [Bernhard Reiter] >> This a general warning against the second system syndrom in Python. >> >> Maybe I am a hypocritical sceptic, but I have the impression that >> some feeping creatureism is introduced into Python. > > These are different issues to me: while feature bloat is a symptom of > Second System Syndrome, the latter goes much deeper than *just* the former. Agreed. It is good to see that you are aware of the problem (as expected). Take my voice on the stack of people that think we should be even more conservative about the additions. >> This might reduce the main advantage of Python to be clear and easy >> and mostly have one good formulation on how to express what you want >> to program in a structured way. > > While I expect everyone would agree those are advantages of Python, I doubt > there's consensus that those 4 advantages are "the main" advantage. > Language design is more complex than that. Rethinking this I still think this are _the main_ advantages compared to other languages. What do you think the main advantages are? :) >> Examples are: >> - augmented Assigments >> - Lists comprehensions >> - Simple Generators > > Two of those were widely debated over the course of a decade, I know. I've participated once IIRC. > They aren't legitimate examples of Second System > Syndrome, in part because of that: they aren't examples of the system > designer taking large leaps of faith on untested and unreviewed ideas. Agreed. However not having augmented assignment made me think about it and the clarity you gain when writing it more explicitly. > If you want a SSS *prospect* to worry about, try PEPs 252 through 254 >> On the other the sum of language constructs is growing and harder to >> understand as a complete system. > > Not even Scheme stayed *braindead* austere forever, you know . That's why fresh, small languages are designed sometimes... > BTW, I agree with Paul that this has nothing to do with the PEP process. See my response to him and Barry. Maybe my subject of the original was suboptimal, but there is some connection and I had to start expression what my concern is somewhere. Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) FSF Europe (fsfeurope.org) From tim.one at home.com Tue Jun 5 20:20:48 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 5 Jun 2001 20:20:48 -0400 Subject: floating point in 2.0 In-Reply-To: <3B1D154B.81016685@home.net> Message-ID: [Aahz] > Actually, 2.0 *still* lies: > > >>> 0.1 > 0.10000000000000001 > >>> '%.55f' % 0.1 > '0.1000000000000000055511151231257827021181583404541015625' > > It just lies less than it used to. Note that this is platform-dependent, and even across platforms that conform fully to IEEE-754: they're allowed to display only zeroes after the 17th significant decimal digit. [Chris Barker] > What the heck are all those digits at the end? Talk about lies, you can > be sure all those digits aren't being stored (at least not in an IEEE > 754 64bit double, which stores approx. 16 decimal digits. Approx. > because it is really a given number of binary digits. I don't have the > exact number off of the top of my head). A 754 double has 53 bits. You're familiar with base 2, so this should be easy: 1/2**1 = 0.5 1/2**2 = 0.25 1/2**3 = 0.125 1/2**4 = 0.0625 1/2**5 = 0.03125 and so on, until 1/2**53 = 0.00000000000000011102230246251565404236316680908203125 Now what do you think the exact decimal value of the exact IEEE double 1/2 + 1/2**53 is? rhetorical-question-no-answer-required-ly y'rs - tim From phd at phd.fep.ru Sat Jun 30 13:30:21 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Sat, 30 Jun 2001 21:30:21 +0400 (MSD) Subject: Why Not Translate Perl to C In-Reply-To: Message-ID: On Sat, 30 Jun 2001, Levente Sandor wrote: > In article , Oleg Broytmann > says... > > This is about Perl, but it applies to Python as well. And of course not > >only to C, but to native code too. > > > >http://www.perl.com/pub/a/2001/06/27/ctoperl.html > > > > "A C program to do what your Perl program does would have to do most of > >the same things that the Perl interpreter does when it runs your Perl > >program. There is no reason to think that the C program could do those > >things faster than the Perl interpreter does them, because the Perl > >interpreter itself is written in very fast C." > > I think there is a very serious reason to think that. Of course, calling a C > function from an interpreted language isn't significantly slower than doing the > same thing in machine code. But just compare some "pure" Python functions or > loops to their C equivalents. > > "4.7 cStringIO -- Faster version of StringIO > The module cStringIO provides an interface similar to that of the StringIO > module. Heavy use of StringIO.StringIO objects can be made more efficient by > using the function StringIO() from this module instead." > (From the Python Library reference) Yes, but you cannot write a compiler that will translate StringIO into cStringIO. Python is too dynamic for this. If Python will ever get static typing, things will become much better and we can return to the task of building a compiler. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From gReGlAnDrUm at earthlink.net Sat Jun 30 11:48:23 2001 From: gReGlAnDrUm at earthlink.net (Greg Landrum) Date: Sat, 30 Jun 2001 08:48:23 -0700 Subject: File-like objects for reading zip files? Message-ID: <9hks27$549$1@slb2.atl.mindspring.net> Hi, I have a .zip archive containing a very large text file (~2.3 MB compressed, ~520MB uncompressed). I'd like to have a file-like object for working with this file so that I never need to uncompress it. In case this isn't clear enough, I'd like to be able to do something like this: import magiczipthing f = magiczipthing.FileLikeObject('bigfile.zip','r') l = f.readline() while l: process_line(l) l = f.readline() >From my perusal of the docs, it doesn't look like the zipfile module supports this type of interaction. Is there any way to accomplish this task? Thanks, -greg From opengeometry at yahoo.ca Mon Jun 11 17:59:04 2001 From: opengeometry at yahoo.ca (William Park) Date: Mon, 11 Jun 2001 17:59:04 -0400 Subject: Python grammar.. In-Reply-To: ; from john.thai@dspfactory.com on Mon, Jun 11, 2001 at 05:27:18PM -0400 References: Message-ID: <20010611175904.A1301@node0.opengeometry.ca> On Mon, Jun 11, 2001 at 05:27:18PM -0400, John wrote: > I previously asked whether Python accepts function arguments without > the opening/closing brackets and commas, like so: foo(x,y) would > become foo x y. The answer to this was no. So, I am wondering if it > would be easy to modify the source and rebuild the interpretor to > accept this format? I tried modifying the Grammar file but that > didn't seem to work... Wouldn't it be easier to write a script to translate 'foo x y' to 'foo(x,y)' ? -- William Park, Open Geometry Consulting, 8 CPUs cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From dkirtley at panam.edu Wed Jun 27 16:43:13 2001 From: dkirtley at panam.edu (David Kirtley) Date: 27 Jun 2001 13:43:13 -0700 Subject: Sorting Apache Log Files References: <3B37B94D.E444BC5D@cs.utwente.nl> Message-ID: <1ca31bad.0106271243.58052b7@posting.google.com> > Lenny Self wrote: >>> SNIP <<< > import string > > datestamp1 = line1[string.find(line1,"[") + 1:string.rfind(line1,"]")] > datestamp2 = line2[string.find(line2,"[") + 1:string.rfind(line2,"]")] > # Compare the date stamps and return appropriate value > if datestamp1 < datestamp2: > return -1 > elif datestamp2 < datestamp1: > return 1 > else: > return 0 >ist.sort(compare) > Writing sorted list to new file >pen("d:/work/newfile.txt","w").writelines(list) That won't work like you think it will. That will do a lexographic comparison (alphabetical) that will partially work but not when they are on boundiries (worst case example: Jan < Apr works but Jul < Aug doesnt.) The way to handle it is to convert it to a numeric time value: for the default Apache log format:: 00/Mon/0000/00:00:00 from time import * timestamp = "00/Mon/0000/00:00:00" #<- insert a real timestamp here. myTime = mktime(strptime(timestamp,"%d/%b/%Y:%H:%M:%S")) Now you can use myTime to make the comparison. David Kirtley From ghockleyNOSPAM at home.com Mon Jun 18 18:44:18 2001 From: ghockleyNOSPAM at home.com (Glenn A. Hockley) Date: Mon, 18 Jun 2001 22:44:18 GMT Subject: Newbie Help on ODBC & Apostrophes References: <0zuX6.276651$eK2.57158115@news4.rdc1.on.home.com> Message-ID: <6vvX6.277150$eK2.57269805@news4.rdc1.on.home.com> Steve, Thanks for the quick reply. This is exactly what I looking for. I knew there had to be a way to use a single quote without having it mess up the SQL statement. Thanks again, Glenn Steve Holden wrote in message news:eNO7ZSE#AHA.261 at cpmsnbbsa07... > The preferred way to perform operations of this nature is to use dynamic > SQL. In this technique you put "parameter markers" in your SQL to represent > the substitutions you intend to make, then you pass the SQL statement to > cursor.execute() with an additional argument, which is a tuple containing > the data you want to substitute. > > In this way your first example would become: > > myCursor.execute("SELECT * FROM MyTable WHERE Name=?", ("O'Brien",)) > > and your second > > myCursor.execute("INSERT INTO MyTable values (?)", ("Glenn",)) > > The cursor performs any escaping required. > > However, if your statements are fixed then parameterisation might seem to be > an overcomplication. Your second example is valid SQL, but your first would > need to become: > > myCursor.execute("SELECT * FROM MyTable WHERE Name='O''Brien'") > > In other words, doubling the quotes escapes them, and SQL treats two > adjacent single-quotes inside a string constant as a single single-quote. In > the general case where you are dealing wiht arbitrary strings bound to > names, you can use the string replace() method to replace each single quote > with two before you use the string inside a SQL statement. > > Hope this helps > > regards > Steve > -- > http://www.holdenweb.com/ > > > "Glenn A. Hockley" wrote in message > news:0zuX6.276651$eK2.57158115 at news4.rdc1.on.home.com... > > Hi, > > > > I have a question that probably has a very simple answer. I am trying to > > use an Access database via the PythonWin ODBC modules to store a list of > > names. I get these names via a form on a web page through CGI. My > problem > > lies with a name with an apostrophe in it, such as O'Brien for example. In > > this case, the ODBC statement doesn't seem to work. > > > > For example, if I try to do the following: > > > > myCursor.execute("SELECT * FROM MyTable WHERE Name='O'Brien'") > > > > it obviously doesn't work. However, the name is retrieved from the web > site > > and is automatically insterted into this string. > > > > From what I have read, to use a string in an ODBC execution statement > > requires that it be surrounded by single quotes. For example: > > > > myCursor.execute("INSERT INTO MyTable values ('glenn')") > > > > So is there a way to make it so that if the user enters name with an > > apostrophe, that this apostrophe doesn't cause my program to crash, and > that > > the name is added to the database with the apostrophe in it? > > > > Hopefully that makes sense... > > > > thanks > > > > > > > > > From helend at accessone.com Tue Jun 5 01:59:22 2001 From: helend at accessone.com (Helen Dawson) Date: Tue, 05 Jun 2001 05:59:22 GMT Subject: O(n^2) is bad - can it be fixed? References: <3B15E5B2.D9F0E414@accessone.com> Message-ID: <3B1C75D3.2801AB08@accessone.com> Just for the interest of those who are interested in the original Win9x behaviour and want to see what it does to the memory map, I have posted a text memory map of the Win98 address space of Python.exe after running my append script. This is the script that kept appending characters to a Python list until Win98 ran out of address space, but not memory. http://www.cygnus-software.com/papers/pythonmemorymap.txt You can see the heaps, starting at 4088K and getting bigger by 4K until memory is filled. Completely understanding the memory map requires understanding MMUs and the Win32 allocator system, but the rough idea should be clear. Reserved means that address space is reserved but not memory. Committed means that memory is reserved also. Address space is allocated in 64K chunks, which is why there are reserved blocks that are 4K to 60K at the end of heaps. "Amiguous Ambiguous Unkown" means that that block has multiple "states" and "protection" flags and that the type of the memory is not known. But trust me, the 4Gbyte+ chunks are mostly heaps. Bruce/Helen Dawson Helen Dawson wrote: > Tim Peters wrote: > > > [Bruce Dawson] > > > ... > > > Now obviously I can fix this problem - switch from list to array, > > > > No, array doesn't even do as much as lists used to do to avoid quadratic > > behavior. Your test case simply didn't try arrays big enough for this to > > Darn. > > > Maybe. As I mentioned in another msg, when I did a straight C realloc > > double-the-size test (no Python) and put it in a loop, the end result was > > that Win98SE froze on about the 6th iteration. If you haven't noticed yet > > in other contexts, take the hint : Win9x is not a robust platform. > > Oooohhhh yeah. I've managed to avoid doing any significant development > on Win9x - I've run NT variants for seven years - but my code still needs > to run on Win9x. Such a pity. > > As further proof of how bizarre the Win9x behavior is, I hypothesized that > if I went: > > range(4000000) > > in the PythonWin interactive window before running my script that I might > get better performance. Indeed I do. Win9x will then run my script to > completion, and *much* faster also. > > The range(4000000) statement creates a list with four million elements > (obviously) which forces a large heap to be created. Since the list is > immediately destroyed, the heap is empty and available. Then, all > subsequent growing of my other lists run quite nicely because the > allocations all fit in the large heap, so realloc() works without any > copying. > > A truly gross hack, mentioned purely for amusement purposes. From seefeld at sympatico.ca Mon Jun 18 14:23:33 2001 From: seefeld at sympatico.ca (Stefan Seefeld) Date: Mon, 18 Jun 2001 13:23:33 -0500 Subject: nested classes References: <3B2E2D3A.75F329D@sympatico.ca> <9glchv$kcm$1@plutonium.compulink.co.uk> Message-ID: <3B2E4725.535AB18E@sympatico.ca> gbreed at cix.compulink.co.uk wrote: > > What am I doing wrong ? The above is possibly a bit driven > > by my C++ programming style. What is the python way of doing > > this ? > > You can get that to work in C++? It looks strange to me, I'm > sure you can't be trying to do what you think you're trying to > do. This is the nearest I can think of that works: uh, what do *you* think that I'm trying to do, then ? :) What I'm arguing about is a matter of name resolution. I sure can open a scope 'A' in C++, insert a new scope 'B' into it, and from within that access other symbols declared in scope 'A'. In fact, I don't need to qualify them (i.e. 'foo' instead of 'A::foo' for any symbol 'foo' in the scope 'A' is just fine) if I'm inside that scope, no matter how deeply nested (of course, as long as there are no ambiguities). > > >>> class A: > ... prefix = 'usr/local' > ... > >>> class B(A): > ... datadir = A.prefix+'/share' > ... > >>> A.prefix > 'usr/local' > >>> B.datadir > 'usr/local/share' ok, that works because B derives from A, i.e. the definition of 'A' is complete at the point where B's definition starts. > >>> class A: > ... prefix = os.path.join('usr','local') > ... > >>> class B(A): > ... datadir = os.path.join(A.prefix, 'share') good idea, thanks. the original 'prefix' stems from 'configure', i.e. my python file 'foo.py' is generated from 'foo.py.in' by means of the autotools (autoconf, configure, ...) Thanks, Stefan From greg at cosc.canterbury.ac.nz Thu Jun 21 00:52:27 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 21 Jun 2001 16:52:27 +1200 Subject: PEP 255: Simple Generators References: <9gnv2o$its$1@nntp6.u.washington.edu> Message-ID: <3B317D8B.A729897C@cosc.canterbury.ac.nz> "Barry A. Warsaw" wrote: > > They are very different because the body of a generator function > defines the generator object's .next() method, but the def names the > generator object's factory function. That's an interesting point -- there are actually two separate things going on, but the syntax is collapsing them into one construct. At one point, I considered proposing that instead of generator *functions*, there should be a generator *statement*. A function returning a generator-iterator would then be written as def f(args): generator g: ... yield x ... return g The idea was that executing the generator statement would create a new generator-iterator and bind it to g. The advantage would be that creation of the generator-iterator would be made explicit, and the new keyword would signal that some sort of new flow control is going on. Then I got to thinking about whether executing the generator statement should create a new local namespace, or whether it should re-use the surrounding one. The latter could have bad consequences if you wrote code which executed a given generator statement more than once in a given function invocation, so it seems like it should create a new local namespace for its body to execute in. But then the generator statement is starting to take on some of the characteristics of a function definition, whereas the point of making it a different statement was to keep them separated. So in the end I decided that combining their functions into one statement was a reasonable thing to do after all. But I still felt that something was needed to distinguish it from an ordinary function definition, since it's doing rather *more* than just defining a function. So I settled on generator g(args): ... -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From sholden at holdenweb.com Wed Jun 13 07:08:32 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 13 Jun 2001 07:08:32 -0400 Subject: Has anyone used UML? References: <9flodi$32m$1@brokaw.wa.com> <3b228485.13884244@news.laplaza.org> <3B250921.F9F1D571@bt.com> <9g5oml$ird$6@216.39.170.247> Message-ID: On a current-affairs note I'm teaching close to Boston right next to Rational's offices this week. Is there a message you'd like me to deliver in person? ;-) regards Steve -- http://www.holdenweb.com/ "David LeBlanc" wrote in message news:9g5oml$ird$6 at 216.39.170.247... > In article <3B250921.F9F1D571 at bt.com>, alan.gauld at bt.com says... > > Mats Wichmann wrote: > > > Yes, it's kind of interesting that way. Three of the main > > > practitioners of OO methodologies and modeling strategies all ended up > > > working for Rational, leaving them with the odd situation of having > > > the proponents of three different modelling schemes on staff. > > > > Not true! Rumbaugh and then Jacobson specifically joined > > Rational to create the UML. By the time they joined they > > already recognised the need for a unifying language. > > wellll.... actually Rational bought both Rumbaugh's and Ivarson's > companies and they came along with the sale. From what I hear there is a > good deal of not so cordial dislike between/among the "3 amigos" > carefully hidden from the hoi poli of course. > > > Rational Rose(the CASE tool) already existed (indeed was at > > version 2 at least) and was based on Booch's notation. The > > first version to support UML still had Booch as default... > > > > > all... on the other hand, it may be that Rational Rose really is > > > "that damn good" (personally, I have zero experience with it). > > > > When it first appeared (around 1992) it was the best thing > > available - almost the only thing available - for "round > > trip engineering". ie You could draw a design, generate code, > > modify the code and then suck the code changes back into > > your design. First time I saw that I was astounded at how > > good it was. Nowadays several tools do the same tricks > > - with pretty much equally unsuccessful results! But they > > are all better than nothing for a significant sized project. > > > > Likewise they are all overkill for a small one! > > > > Alan g. > > > For all the ado about UML, there seems to be few competitors to Rose, at > least that i'm aware of and, unlike most good innovations in the computer > world, there has been little trickle-down of quality software to the > generic small-shop programmer level. Perhaps that's due to little > competition, the perception that one doesn't have the time to actually do > decent design in today's competitive market and that abomination called > XP (development by comittee - oh please - it's what the Japanese are > working hard to get away from!) > From GADGILP at INFOTECH.ICICI.com Mon Jun 18 02:15:20 2001 From: GADGILP at INFOTECH.ICICI.com (GADGIL PRASAD /INFRA/INFOTECH) Date: Mon, 18 Jun 2001 11:45:20 +0530 Subject: Python equivalent of CPAN Library modules Message-ID: <718A0962DFC2D4119FF80008C7289E4701A01FC1@ICICIBACK3> hello, I kinda find larry wall's thaught very interesting. And his complete openness of ppl choosing lang other than perl. So, what I wanna ask is, is it technically possible to use perl modules from python programs.. ? not parrot maybe but something in between.... /prasad -----Original Message----- From: Martin von Loewis [mailto:loewis at informatik.hu-berlin.de] Sent: Saturday, June 16, 2001 11:25 PM To: python-list at python.org Subject: Re: Python equivalent of CPAN Library modules davehurt at flash.net (David Hurt) writes: > I would appreciate any feedback on the practicality/usefulness/etc. of this > effort. I think it will be a huge effort, and it might be that the outcome is not all that useful, e.g. you might find that the most often requested CPAN modules have already good Python equivalents. I'm not sure what you'd do when the Python module offers the same functionality, but with a totally different API. That said, if you volunteer to do the work, I'm sure many people would be interested to see what the result is. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list . -------------- next part -------------- An HTML attachment was scrubbed... URL: From rcstadheim at scarabweb.com Sat Jun 9 10:09:10 2001 From: rcstadheim at scarabweb.com (Alex) Date: Sat, 9 Jun 2001 16:09:10 +0200 Subject: SV: HTTPSHandler ??? (where is it) References: Message-ID: Thank you for the tip! Regarding the patching of the python socket, does it involve a lot of research/work (I'm basically new to sockets)? Regards, Rolf C Stadheim Robin Becker skrev i meldingsnyheter:X9O04LAsFJI7EwlC at jessikat.demon.co.uk... > have a search on parnassus for M2crypto; that has quite good wrapper for > ssl stuff and there's certainly a replacement for urllib/httplib that > handles https. It does work, but some report problems with memory leaks. > > On the other hand it is possible to patch the python socket code to work > with ssl and I have gone that route and found it works well on the > client side. > -- > Robin Becker From rnd at onego.ru Thu Jun 28 15:08:52 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 28 Jun 2001 23:08:52 +0400 (MSD) Subject: PEP scepticism In-Reply-To: <3dhex01n1m.fsf@ute.cnri.reston.va.us> Message-ID: On 28 Jun 2001, Andrew Kuchling wrote: >bernhard at intevation.de (Bernhard Reiter) writes: >> I agree as a python programmer (which I meant by "python user" btw). >> There are important additions (e.g. unicode) and the language >> has to be maintained. > >I've noticed that in online forums, people now rarely beat up on >Python for the language itself, except for the old reliable >indentation knee-jerk reaction. Instead people write about how >convenient CPAN makes it to find modules, or how useful the XML >modules are, or how EJB lets them write elaborate business systems. I >don't think improving Python the language will win new converts at >this point; improving the standard library, development environments, >or the documentation is more likely to bear fruit. I think improving Python itself is also improving what you've just mentioned. Of course, libraries are important and they are being developed. I also think that changes in Python were caused be need of practice and not some aestetism of GvR. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Thursday, June 28, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "It is better to wear out than to rust out." _/ From johnroth at ameritech.net Thu Jun 14 18:11:54 2001 From: johnroth at ameritech.net (John Roth) Date: Thu, 14 Jun 2001 15:11:54 -0700 Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gatpj$4vr$1@tyfon.itea.ntnu.no> Message-ID: "Magnus Lie Hetland" wrote in message news:9gatpj$4vr$1 at tyfon.itea.ntnu.no... > "David LeBlanc" wrote in message > news:9gao5s$8ft$7 at 216.39.170.247... > > One thing that bugs me about Python is that there's no really good way to > > have named constants so that magic numbers can be avoided. Assigning to a > > variable that (should) never changes is not the same (i.e. the "should > > never" part). > > > > My proposal: > > > > alias httpport : 80 > > Hm. Unconventional use of the colon, isn't it? (For Python, I mean.) I don't see the problem with the colon - after all, isn't that the syntax for a key: value pair that will go into the dictionary? I'd just as soon have it called "const" rather than "alias", though. > Anyway - what is it you want with this? The reasons I want it are very simple: 1. it avoids coding errors when you have to have the same string constant in the code in multiple places. It's a lot easier for the compiler to complain about an uninitialized variable than to check lots of code with Eyeball Mark I. 2. Sometimes the "magic number" just isn't really very descriptive. Picking good names for things is part of what makes your module understandable six months from now. >Efficiency, on enforcing > the non-changing state of the variables? If I call something "const", then I want it to be CONSTANT, not something that can be changed at the whim of a coding mistake, or a misguided "cute hack." > > I can't really see the need for this myself - but if something like it is > ever implemented, I really hope we won't have similar solutions to those > used to simulate private variables. I mean... > > >>> _const_httpport = 80 > >>> _const_httpport = 90 > Traceback (most recent call last): > File "", line 1, in ? > ConstError: constant '_const_httpport' is already defined > > > > > Dave LeBlanc > > -- > > Magnus Lie Hetland http://www.hetland.org > > "Reality is that which, when you stop believing in > it, doesn't go away." -- Philip K. Dick > > > From Bill.Scherer at VerizonWireless.com Mon Jun 4 10:53:50 2001 From: Bill.Scherer at VerizonWireless.com (Scherer, Bill) Date: Mon, 4 Jun 2001 10:53:50 -0400 (EDT) Subject: Python as REXX replacement? In-Reply-To: <9fg5l3$deo$1@news.rchland.ibm.com> Message-ID: IBM has ported Python v1.4. see: http://www-1.ibm.com/servers/eserver/zseries/zos/unix/python.html On Mon, 4 Jun 2001, Larry Whitley wrote: > A friend in Poughkeepsie currently uses REXX as his scripting language but > is becoming increasingly interested in Python. He asked if there is a > version that runs on the IBM 390 systems under VM or MVS? Does a port to > 390 (also known as zSeries) exist? > > Larry > > > William K. Scherer Sr. Member of Applications Staff - Verizon Wireless Bill.Scherer_at_VerizonWireless.com From hbn at imada.sdu.dk Fri Jun 1 13:51:24 2001 From: hbn at imada.sdu.dk (Henrik Berg Nielsen) Date: Fri, 1 Jun 2001 19:51:24 +0200 Subject: Copying files to multiple comp's on a lan References: <9f8k3v$1i04$1@news.cybercity.dk> Message-ID: <9f8km3$1ior$1@news.cybercity.dk> Hi once more, I forgot to mention that the files to be copied range anywhere from 1K to several hundred MB. Henrik Berg Nielsen "Henrik Berg Nielsen" wrote in message news:9f8k3v$1i04$1 at news.cybercity.dk... > Hi all, > > I'm rather new to Python, and this is my first post in this NG (as you can > probably tell). I hope that you guys can get the meaning of my writings as > english is not my native language, so I apology beforehand for any > spelling/grammatical errors. > > I need to make a small script thats capable of copying a file from the > machine that its being run on to all the other machines on the lan. The > target path on all the other machines should be the same. The script should > take the path of the source file and the remote path to the shared folder(s) > as arguments. I'll define all the machines the file is to be copied to > elsewhere. > > Where do I start when making such a script? What kind of builtins should I > know of and which functions will be useful in my work? What do I need to > investigate closer (I've never tried network programming before)? > > I used to do this filecopying for each machine seperately with the Windows > Explorer, and seeing as its something that I do rather often, I'm beginning > to get a little bugged by this tedious method, and have decided that now its > time to make it a little more automated. > If you know of an already existing program that can accomplish this task for > me any pointers would be greatly appreciated. > > Thanks in advance, > > Henrik Berg Nielsen > > From chris.gonnerman at newcenturycomputers.net Tue Jun 12 07:58:21 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Tue, 12 Jun 2001 06:58:21 -0500 Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: Message-ID: <001401c0f336$fbdca9a0$0101010a@local> From: "Roman Suzi" > No, no! Do not take print away! It help to migrate from Basic! ;-) This is the best single reason I can see OTHER than not breaking existing scripts. Not just BASIC, but Perl, and SO MANY other languages have a print statement. IMHO Alex's output() function is not really necessary. If you hate print, use fileobj.write(), and leave us print-users alone. Aesthetics alone are not a good enough reason for such a fundamental and painful change. From pfortin at pfortin.com Fri Jun 8 10:57:10 2001 From: pfortin at pfortin.com (Pierre Fortin) Date: Fri, 08 Jun 2001 10:57:10 -0400 Subject: Import bug...? Re: expat not found...? References: <3B1FD859.E1649F7D@pfortin.com> Message-ID: <3B20E7C6.34F53B43@pfortin.com> I wrote: [snipped] > Compiled 2.1 on Linux Mandrake 7.2 system (incl expat)... > > Yet, when I run a sample script (from > http://www-106.ibm.com/developerworks/xml/library/l-pxml.html?open&l=912,t=grx,p=xpyth)... > > xmlsaxtest.py: > "Simple SAX example, updated for Python 2.0+" > import string > import xml.sax > from xml.sax.handler import * > > it won't even get past the imports... > > Traceback (most recent call last): > File "xmlsaxtest.py", line 3, in ? > import xml.sax > File "xml.py", line 1, in ? > import _xmlplus.parsers.expat > ImportError: No module named _xmlplus.parsers.expat > > Probably missing something obvious/subtle; but... YUP... subtle... Just found that this error was caused by another test file "xml.py" in my test directory. This raises a question: if "import foo.bar.baz" really means "foo/bar/baz...", shouldn't import ignore any files such as ./foo.py, foo/bar.py, etc....? Thanks, Pierre From mcfletch at home.com Mon Jun 25 03:20:05 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Mon, 25 Jun 2001 03:20:05 -0400 Subject: Pythoin MUD (PyMUD?) In-Reply-To: <3B36D220.52C5CB86@cosc.canterbury.ac.nz> Message-ID: <000001c0fd47$428f8060$a9807018@cr706570a> In stackless, what you could do is establish a policy that any given micro-thread cannot run longer than user.max_timeslices_per_thread (or whatever you name it), then alter uthread.py's inner loop to enforce that policy. Your other threads would still get their timeslices while the bad thread runs, and the wizard would get a "QuotaExceeded" error raised in their micro-thread if it goes too far. Getting that error, they either recode their loop or petition for a quota increase. Enjoy yourselves, Mike -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Greg Ewing Sent: June 25, 2001 01:55 To: python-list at python.org Subject: Re: Pythoin MUD (PyMUD?) Remco Gerlich wrote: > > you need only one drunken wizard to > code an infinite loop, and your driver locks up. I haven't found a solution > yet Stackless could be a solution. Pre-emptively scheduled microthreads. Your drunken wizard's code still runs forever, but other things can happen at the same time. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg -- http://mail.python.org/mailman/listinfo/python-list From barry at digicool.com Sat Jun 30 11:19:32 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Sat, 30 Jun 2001 11:19:32 -0400 Subject: PEP scepticism References: <9hfg1n$du33c$1@ID-89274.news.dfncis.de> <3B3BB077.1E51F2C9@ActiveState.com> Message-ID: <15165.60932.387078.639489@anthem.wooz.org> >>>>> "ph" == phil hunt writes: >> he PEP champion (a.k.a. Author) should first ttempt to ascertain >> whether the idea is PEP-able. ph> How do I ascertain this? ph> Who decides whether something is a "small enhancement"? ph> The changes i propose would be two separate PEPs (I assume) -- ph> or would they be added to PEP-42 (which is a list of small ph> features)? If you look at PEP 42, you'll see that most of those "small enhancements" really fix minor limitations, bugs, or misfeatures in the implementation, or library. An example of a PEP-42'ish small enhancement (that never actually made it to PEP 42) is to extend {}.update() to accept any "mapping" object instead of just concrete dictionaries. Anything that changes the language is almost by definition PEP-able, and I would place optional-pass and multiline comments squarely in that category. Very often, such ideas seem simple on the face of it, but actually have quite subtle and complex implications on the language (as you're brief outline of /*...*/ shows!) -Barry From prem at engr.uky.edu Tue Jun 5 16:28:17 2001 From: prem at engr.uky.edu (Prem Rachakonda) Date: 5 Jun 2001 13:28:17 -0700 Subject: Plotting Surfaces with GnuPlot-Python?? Message-ID: Hi, I have a problem in plotting contours/surfaces. The problem description is as follows: x---> y z1-1 z1-2 z1-3 z1-4 z1-5.......z1-5000 | z2-1 z2-2 z2-3 z2-4 ... | z3-1 z3-2 z3-3 z3-4 ... V ... ... . . z100-1.........................z100-5000 I have the above matrix z of size [100,5000], each value representing the height in z-axis(5000 points in x multiplied by 100 scans in y) I have three matrices now, x[5000], and y[100] and z[100,5000] And I would like to plot the contour(surface) with this x,y,z data. My python code goes like this:(Only a part of it is displayed here) *************************************************** scalex=1.2 scaley=2.4 scalez=3.6 size=100 g=Gnuplot.Gnuplot() g.clear() g.("set view 90,0") #The function 'dlmread' reads the matrix from a number of files(set by 'size' and the z will have the number of rows=size and the number of columns='5000' z=reshape((array(iotools.dlmread('Folder_1','data.txt',size,100,5100))*scalez),(5000,size)) x=(arange(0.,7800))*scalex y=(arange(0,size))*scaley g('set parametric') g('set data style dots') g('set contour base') g.splot(Gnuplot.GridData(z,x,y, binary=0)) *************************************************** If is set 'size=1', ie. try to plot only one set of values to get the profile of the surface, I get it absolutely right, but only a profile..not the surface. If I set size=2, ie. try to plot two sets of values, I get 4 plots of the profile and the every value in x is halved. If I set size=3, then I get 9 plots and x is reduced to 1/3rd I am not sure I understood how 'splot' plots the surface. Please let me know if there is a way to solve this problem. Why does the data gets scaled down??? From just at letterror.com Sun Jun 10 05:04:57 2001 From: just at letterror.com (Just van Rossum) Date: Sun, 10 Jun 2001 11:04:57 +0200 Subject: How do you develop in Python? References: <050620011516094693%pecora@anvil.nrl.navy.mil> Message-ID: <3B23383A.3BE91586@letterror.com> Nick Perkins wrote: > I want an IDE to provide at least the following: > 1. Each run takes place in a fresh, clean environment. > 2. The IDE stays responsive while a program is run. > 3. The IDE can kill a running program. For me, 1. should be entirely optional: I usually *prefer* to keep working in an existing environments, and only clean up (start over) when I've messed things up beyond repair. As an example of this way of working: I've developed the MacPython IDE largely in *itself*. It's a medium-sized app, but restarting it for every minor change would've been a pain. Instead, I work on it while it's running, updating modules and individual classes, and seeing effect *immediately*. This is amazingly effective with Python, due to its dynamic nature. Yet there are cases where this is not possible or too hard: eg. developing GUI apps that use a different GUI/mainloop than the IDE. A separate interpeter is simply the best option. But as has been written before in this thread: to conveniently do this one would like to have a good communications channel between the IDE and the app in question: for debugging, tracebacks, object browsers, etc. Such a thing is not all that easy to create in a cross-platform manner, but I would agree that this is where Python IDE's should be heading. Just From spam at sightreader.com Sun Jun 10 07:21:09 2001 From: spam at sightreader.com (Bufu) Date: Sun, 10 Jun 2001 04:21:09 -0700 Subject: How do you develop in Python? References: <050620011516094693%pecora@anvil.nrl.navy.mil> Message-ID: <006c01c0f19f$73b1cc60$1301010a@personal.net> Have you tried Komodo? - Ken ----- Original Message ----- From: "Nick Perkins" Newsgroups: comp.lang.python To: Sent: Sunday, June 10, 2001 1:13 AM Subject: Re: How do you develop in Python? > I use NT, and I have yet to find a free IDE that I am really happy with. > > This is a serious shortcoming of Python. I know, the language itself is not > resposible for giving me a wonderful free IDE, but in the mind of a Python > user, the IDE is part and parcel of the language, and integral to the > *experience of Python. Python, the laguage is wonderful, but weak IDEs make > it look bad. I have used PythonWin, IDLE, Boa Constructor, and SciTe. > > With all apologies to those who developed these FREE IDE's... (it is not > fair to complain about free software, and that is not my intention here -- I > am sure that I could not do any better).. I simply, (and selfishly), wish > that I could use Python to the full potential of the language itself, > without being hindered by an IDE that freezes up, leaves behind runaway > processes, or crashes. > > IDLE freezes up frequently. > PythonWin freezes a bit less, and seems unable to kill a runaway program. > Boa Constructor is more stable than these two, and allows you to kill a > runaway program without killing the editor. However, it won't take you to > the line that caused an error, which is very irritating. (broken feature) > SciTe seems interesting, but I haven't figured out how to configure it, yet, > and util I do, it's useless. (me being lazy, but still...) > > I want an IDE to provide at least the following: > 1. Each run takes place in a fresh, clean environment. > 2. The IDE stays responsive while a program is run. > 3. The IDE can kill a running program. > > Another thing I would like, but that may have, i dunno, ..implications..? > 1. The IDE should handle the sys.path so that Python does not fail to find a > file that I currently have open, or is in the same directory. > > > Is it not possible to start a 'fresh' interpreter for each run? Or is that > not actually desirable for some reason? Would that make it impossible to > kill it or get tracebacks, etc? Do we need a Python IDE that does not run > itself in Python? > ( i guess SciTE doesn't....maybe I'll give that another go..) > > BTW, which free IDEs are currently being maintained and improved? > How much work is being done, and how many people are doing it? > ( keep up the good work!, if this means you!) > > p.s. i know, i know, emacs, vim, etc etc....but I have become a bit of a > windows softie, and have an aversion to such things. I am going to use > emacs in my next life, and learn lisp as my first language..... > > > > -- > http://mail.python.org/mailman/listinfo/python-list From sdm7g at Virginia.EDU Thu Jun 21 16:32:53 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Thu, 21 Jun 2001 16:32:53 -0400 (EDT) Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) In-Reply-To: Message-ID: On Wed, 20 Jun 2001, Tim Peters wrote: > Heh. If you had only finished *your* generator implementation 9 years ago > instead of getting sucked into the continuation pit, we could be using > > sdm f(i): > suspend i+1 > > today . I think one of the bug missing pieces to make it fit smoothly into Python was iterators. My 'suspend value' actually got transformed into returning the tuple (value, suspended-frame), so to use it in a loop required something like: iterf = function # don't mung up the global name while 1: value, iterf = iterf( args... ) ... # first time, call the function # all others, call the suspended activation frame Back in those ancient pre-PEP days, Guido was much more conservative. And there were fewer people to bounce ideas off of --- I recall I was soliciting ideas for a more pythonic syntax, but there wasn't much interest. ( And the above hack was even too ugly for ME to defend! ) -- Steve From thomas at xs4all.net Fri Jun 29 16:33:03 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 29 Jun 2001 22:33:03 +0200 Subject: types.CodeType doesnt exist? In-Reply-To: <25b2e0d9.0106290513.3a2f4c71@posting.google.com> References: <25b2e0d9.0106290513.3a2f4c71@posting.google.com> Message-ID: <20010629223303.B8098@xs4all.nl> On Fri, Jun 29, 2001 at 06:13:47AM -0700, gods1child wrote: > Platform: Win2000, Python 2.0 > I was looking at the copy.py source and found this snippet > ----------------------------------------------------- > d = {} > d[types.UnicodeType] = _copy_atomic > try: > d[types.CodeType] = _copy_atomic > except AttributeError: > pass > d[types.TypeType] = _copy_atomic > ----------------------------------------------------- > under what circumstances will the types module not have attribute CodeType? When running in restricted mode, according to this checkin message: revision 1.8 (of types.py) date: 1997/09/04 22:12:34; author: guido; state: Exp; lines: +15 -6 Added some try-excepts so that it can be imported in restricted mode (though some type names are undefined in that case, e.g. CodeType (inaccessible), FileType (not always accessible), and TracebackType and FrameType (inaccessible). Aint-CVS-fun-ly y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From aleaxit at yahoo.com Wed Jun 6 05:49:50 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 6 Jun 2001 11:49:50 +0200 Subject: 2 language applications References: <9fk6ll$4ln39$1@ID-44371.news.dfncis.de> Message-ID: <9fkubv0i48@enews2.newsguy.com> "Cristian Echeverria" wrote in message news:9fk6ll$4ln39$1 at ID-44371.news.dfncis.de... > Hi > > I have a gui application with all the messages in spanish, now I want to > include an option that allow the user to choose the language. > > Wich is the right way to do things like this? > Any suggestion that can help me? > > (I'am using Python2.0 and wxPython 2.3 on win9X) See standard Python module gettext -- it's part of core Python so you should have it in any distribution. The tools to *generate* the needed messagefiles may or may not be part of your Python distribution -- if you can't find them, get a Python *source* distribution and look for Tools/i18n. (Not sure why this VERY useful directory is not included in some distributions - it's just two Python scripts after all!-). Say I have this big Python application saluta.py...: print "buon giorno!" print "ciao!") print "buona sera!" First I internationalize it as follows: import os,gettext os.environ.setdefault("LANGUAGE","it") gettext.install('saluta') print _("buon giorno!") print _("ciao!") print _("buona sera!") The key thing is marking with _(...) the strings which ARE to be translated! Now I can't run it...: D:\py21>python saluta.py Traceback (most recent call last): File "saluta.py", line 4, in ? gettext.install('saluta') File "d:\python21\lib\gettext.py", line 251, in install translation(domain, localedir).install(unicode) File "d:\python21\lib\gettext.py", line 238, in translation raise IOError(ENOENT, 'No translation file found for domain', domain) IOError: [Errno 2] No translation file found for domain: 'saluta' D:\py21> I have to prepare a message file first...: D:\py21>python \python-2.1\Tools\i18n\pygettext.py saluta.py D:\py21>type messages.pot # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR ORGANIZATION # FIRST AUTHOR , YEAR. # msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "POT-Creation-Date: Wed Jun 06 11:29:12 2001\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: ENCODING\n" "Generated-By: pygettext.py 1.3\n" #: saluta.py:5 msgid "buon giorno!" msgstr "" #: saluta.py:7 msgid "buona sera!" msgstr "" #: saluta.py:6 msgid "ciao!" msgstr "" D:\py21> Now I have to edit this textfile to prepare the needed .po files -- after the beginning metadata (to be suitably edited), I'll have an it.po something like: #: saluta.py:5 msgid "buon giorno!" msgstr "buon giorno!" #: saluta.py:7 msgid "buona sera!" msgstr "buona sera!" #: saluta.py:6 msgid "ciao!" msgstr "ciao!" and an en.po something like: #: saluta.py:5 msgid "buon giorno!" msgstr "good morning!" #: saluta.py:7 msgid "buona sera!" msgstr "good evening!" #: saluta.py:6 msgid "ciao!" msgstr "hello!" So I compile them: D:\py21>python \python-2.1\Tools\i18n\msgfmt.py en.po D:\py21>python \python-2.1\Tools\i18n\msgfmt.py it.po And prepare the needed directories (lots of intermediate mkdir's snipped:-): D:\py21>mkdir \python21\share\locale\it\LC_MESSAGES D:\py21>mkdir \python21\share\locale\en\LC_MESSAGES and put the .mo files in the right places: D:\py21>copy it.mo \python21\share\locale\it\LC_MESSAGES\saluta.mo 1 file(s) copied. D:\py21>copy en.mo \python21\share\locale\en\LC_MESSAGES\saluta.mo 1 file(s) copied. D:\py21> And NOW it finally runs properly: D:\py21>python saluta.py buon giorno! ciao! buona sera! D:\py21>set LANGUAGE=en D:\py21>python saluta.py good morning! hello! good evening! I hope this simple toy example helps you get started... it's a rich and complex system, meant to cover potentially very large applications with dozens of languages, modules that must not touch global settings, etc, etc, and it works quite smoothly over its broad range of applicability, even though it MAY look like a BIT of an overkill when just looking at one simple case such as this one!-) Alex From chat at linuxsupreme.homeip.net Tue Jun 26 15:58:55 2001 From: chat at linuxsupreme.homeip.net (Chad Everett) Date: 26 Jun 2001 14:58:55 -0500 Subject: UserDict and setattr References: Message-ID: OK, I just needed to add the following to DictWrap: def __setattr__(self,name,value): if name == "data": self.__dict__[name] = value else: self.__dict__['data'][name] = value On 26 Jun 2001 12:56:55 -0500, Chad Everett wrote: > >Using UserDict and overriding getattr, I can create dictionary wrappers >that allow dictionary lookups via getattr. Using the example below: > >apple = Fruit( {'name':"apple",'color':'red'} ) >carrot = Veggie( {'name':"carrot",'color':'orange'} ) > >apple.color # returns 'red' >apple['color'] # returns 'red' > >apple['color'] = 'green' >apple.color # returns 'green' >apple['color'] # returns 'green' > >apple.color = 'brown' >apple.color # returns 'brown' >apple['color'] # returns 'green" !!!!!!!!! > >Obviously, setattr needs to be altered to also update >the dictionary (via __setitem__) and not just the instance's >attributes > >I cannot seem to find a way to override setattr so that I >can get the get a __setitem__ called to update the dictionary. > >Please Help!!! > > >Code sample follows: > > >import UserDict > >class DictWrap(UserDict.UserDict): > > def __init__(self,initdict): > self.data = initdict > > def __getattr__(self,name): > return self.data[name] > > >class Fruit(DictWrap): > > > def __init__(self,initdict): > DictWrap.__init__(self,initdict) > > >class Veggie(DictWrap): > > > def __init__(self,initdict): > DictWrap.__init__(self,initdict) > > >apple = Fruit({'name':"apple",'color':'red'}) >carrot = Veggie({'name':"carrot",'color':'orange'}) > > > > > >-----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- >http://www.newsfeeds.com - The #1 Newsgroup Service in the World! >-----== Over 80,000 Newsgroups - 16 Different Servers! =----- -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From castor at snafu.de Wed Jun 6 18:36:56 2001 From: castor at snafu.de (Wolfgang Lipp) Date: Wed, 06 Jun 2001 22:36:56 GMT Subject: is this a python bug? References: <6564c76c.0105302046.2f24ab47@posting.google.com> Message-ID: <1106_991867016@ns.seowon.ac.kr> BTW, Mike, I tried your code, class Child: def __init__(self, parent): self.__dict__['parent'] = parent def __getattr__(self, attr): self.parent.a = 1 self.parent.b = 1 self.parent.c = 1 return getattr(self.parent, attr) class Parent: def __init__(self): self.a = Child(self) print Parent().__dict__ and it *is* exactly the problem of mutation-while-accessing problem! thanks! -wolf From bokr at accessone.com Tue Jun 12 15:25:25 2001 From: bokr at accessone.com (Bengt Richter) Date: Tue, 12 Jun 2001 19:25:25 GMT Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: <9g4nec0cnr@enews2.newsguy.com> Message-ID: <3b266453.317327753@wa.news.verio.net> On Tue, 12 Jun 2001 11:29:50 +0200, "Alex Martelli" wrote: [...interesting stuff...] > >So, summarizing: in Python, keyword statements either >affect the namespace using them, or affect the control >flow that uses them. > >All, that is... except ONE. > >That one is: print. A keyword statement that neither >affects the namespace, nor control flow. An anomaly, >therefore, that sticks out like a sore thumb. Surely >not such a huge one that it's worth breaking 99% of >existing scripts to remove it:-). *However* -- why >keep overloading it with magic and extra "convenience" >features...? Glyph may be right in paradoxically >claiming that just such tweaking will eventually show >everyone that print is just best not used:-). > >To HELP migration to a function for what is now done >with print, I think such a built-in function should be >added contextually to this latest 'print' change. Yes, >yes, it IS un-Pythonic to provide several ways to do >the same task, but, here, I think, we need to patch >over the non-Pythonic existence of print itself:-). > >I believe the new print-like built-in function should >ideally be named print, but we can't do it, because >keywords are reserved. Sigh. Among the alternatives, Is it not possible to back out a keyword if it doesn't break a lot of code? If it were possible, wouldn't reducing the keyword count be a Good Thing? What if print were definable as a peculiar unary operator whose precedence and associativity led to its being called with a tuple constructed from the typical print args? If this operator was defined as a builtin function, you could hook in whatever you liked. If there were a general capability to define named operators with rules for precedence and associativity etc to gather arguments, you could do print as just one example of a general capability. >we have: write (misleading as it recalls the write >method of file-objects), output (makes for a nice >pair with input, which, however, has its own nasty >problems:-), emit, say (a la Rexx), echo (a la sh), >and many others, including non-words that decorate >these basic words (doprint, etc). > >Whatever name is used (assume 'output' for definiteness, >without loss of generality), I think the print-like >function should accept arbitrary unnamed arguments >(to be treated just like the items now passed to >print) optionally followed by named arguments to >supply the same tweaks that now print supplies (and >maybe a few more) -- names are doubtful, but...: > file=sys.stdout the output file-object to use > newl=1 1 emit a newline at the end > UNLESS the last item printed > is a string ending in \n > (like print will now work) > 0 no newline at the end (like > print with a trailing comma) > 2 force newline at the end in > any case (like print today) > (others?) Alternatively (and possibly more concisely) borrow an idea from C++ "Standard I/O Manipulators" and pass references to standard 'manipulator' objects? [...] >Having output as a built-in function would encourage >using it in lieu of the print statement, which, in >turn, would allow the usual kind of tricks that are >available for built-ins but not for statements, such >as wrapping/overriding (you can do that for print with >a user-defined file-like object, to some extent, but >not fully -- the file-like object cannot know where >a given print statement begins or ends, it can only >intercept specific write and softspace accesses). > I like wrappability. As for PEP 259, please count one newbie vote against. In general, I'd prefer that a language provide a clean way to create a solution to a problem, rather than having a particular solution built in. I like orthogonality too. From micronospampad at nospam.yahoo.com Tue Jun 5 19:49:01 2001 From: micronospampad at nospam.yahoo.com (Mahesh Padmanabhan) Date: Tue, 05 Jun 2001 17:49:01 -0600 Subject: Interesting speed benchmark Message-ID: <3B1D6FED.4070506@nospam.yahoo.com> Hello, To email me remove "nospam" from the email address. I came across this web site: http://www.twistedmatrix.com/~glyph/rant/python-vs-java.html in which the author does some (by his own admission) subjective benchmarks between java and python. While most of it is usual stuff, the one test that stood out was the following: (I am using a Debian woody system with Python 2.1 and JDK 1.3 from blackdown on an Intel system) Python program: --------------- class ObjectTest: pass for i in xrange(1000): root=ObjectTest() for j in xrange(10000): root.next=ObjectTest() root=root.next Time: real 1m23.326s user 1m23.290s sys 0m0.060s Java program: ------------- public class ObjectTest { public ObjectTest next; public static void main(String[] args) { for (int i = 0; i < 1000; i++) { ObjectTest root = new ObjectTest(); for (int j = 0; j < 10000; j++) { root.next=new ObjectTest(); root=root.next; } } } } Time: real 0m2.428s user 0m2.190s sys 0m0.220s There is a huge difference in performance. In fact I tried this under Windows NT 4 SP5 with Python 2.1 and jdk1.3 from SUN and got similar results. I am very curious to know why Python takes so much time. Thanks Mahesh From andymac at bullseye.apana.org.au Fri Jun 15 21:54:06 2001 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Sat, 16 Jun 2001 11:54:06 +1000 (EST) Subject: statically linking the entire runtime (HPUX Python2.1) In-Reply-To: <3B29C168.2F929D8F@snakefarm.org> Message-ID: On Fri, 15 Jun 2001, Carsten Gaebler wrote: > I noticed that you can't build the curses module statically. The linker > then complains about duplicate definitions of 'tputs' in libncurses and > libtermcap. Is there a way to get around this? Do you really need to link in libtermcap?? I had been under the impression that libncurses contained all necessary functionality. -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andrew.macintyre at aba.gov.au (work) | Snail: PO Box 370 andymac at bullseye.apana.org.au (play) | Belconnen ACT 2616 andymac at pcug.org.au (play2) | Australia From looie+gnus at aracnet.com Thu Jun 21 18:03:48 2001 From: looie+gnus at aracnet.com (Michael Powe) Date: 21 Jun 2001 15:03:48 -0700 Subject: namespace issue? References: <87k825ljrz.fsf@elbereth.ccraig.org> Message-ID: >>>>> "Christopher" == Christopher A Craig writes: Christopher> Michael Powe writes: >> >>> def GetNum2(): ... AC = raw_input("Area Code: ") ... PN = >> raw_input("Phone Number: ") ... if not PN : PN = '000-0000' >> ... if not AC : AC = '503' ... if len(PN) < 8 and not >> string.find(PN,'-'): ... Ph = PN[:3] + '-' + PN[3:] ... return >> Ph Christopher> string.find(PN, '-') succeeds (since PN contains a Christopher> '-'), so len(PN)<8 and not string.find(PN,'-') Christopher> returns false, meaning that Ph = PN[:3] + '-' + Christopher> PN[3:] is never executed, and Ph is not defined when Christopher> the return statement is reached. Actually, it doesn't contain the dash. The dash is only inserted if I press the enter key, leaving the PN string empty. In the case of an empty string, the default string of zeroes is put into the variable. But, the error persists even if I take that conditional out. However, you pointed me in the right direction. The 'not string.find(PN, '-')' part of the conditional is returning false when there is no dash in the string. If I take that part of the conditional out, and just use the first part, it works as designed. So now the question is, 'why'? Am I misusing the string.find() function? Okay, string.find() returns -1 when the string is not found, which would seem to be what I expected, a false result. Maybe python doesn't treat -1 as false? Well, I'll try being explicit and testing for -1 return. I probably have just confused myself hopelessly. Thanks for the ... clue. I saw a great line in an email today -- "Is that the clue phone ringing? I think it's for you." And I think I'll go answer it. Christopher> So, yes, it is because of the conditional, but no it Christopher> has nothing to do with namespaces. (unlike in C or Christopher> C++, in Python not all blocks get their own Christopher> namespaces, only functions, modules, and classes (and Christopher> probably something I forgot)) Christopher> Also, yes, raw_input returns a string. Okay, thanks. mp -- Michael Powe looie at aracnet.com michael at trollope.org "All we are basically are monkeys with car keys." -- Northern Exposure From sholden at holdenweb.com Tue Jun 12 07:11:47 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 12 Jun 2001 07:11:47 -0400 Subject: ODBC and date References: Message-ID: "Maurice HUET" wrote in message news:FYHU6.106$GJ3.438333 at nnrp3.proxad.net... > Hello, > > I want transfert data from a progress database to a MySql database with > python and the ODBC module. (Win plateform) > How can I specify date selection in the SQL order ? > The date data cause problem (dbidate type) when i want write tem in a > text file between then two database ? > > Someone have a solution ? > Had you thought of writing one program that connects to both databases? It is then relatively easy to transfer data from one to the other. Here's some code which creates a Gadfly database from an ODBC source, doesn't use dates but it might get you started. Two ODBC sources should be no more difficult... regards Steve # # Create the gadfly database from the "Webdata" ODBC source # import gadfly import odbc ocn = odbc.odbc("Webdata") ocu = ocn.cursor() gcn = gadfly.gadfly() gcn.startup("webdata", "gadfly") gcu = gcn.cursor() gcu.execute("create table PgData (PgName varchar, PgNum integer, PgText varchar)") ocu.execute("select PgName, PgNum, PgText from PgData") gcu.execute("insert into PgData (PgName, PgNum, PgText) values (?, ?, ?)", ocu.fetchall()) gcn.commit() for obj in (gcu, ocu, gcn, ocn): obj.close() print "gadfly database created" From aleaxit at yahoo.com Wed Jun 20 15:03:22 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 20 Jun 2001 21:03:22 +0200 Subject: Interfacing GUI applications..? References: <3B18032E.21AF631E@pfortin.com> <16074dce.0106200912.7b9bc793@posting.google.com> Message-ID: <9gqs2c01c2m@enews1.newsguy.com> "Jeff Shannon" wrote in message news:16074dce.0106200912.7b9bc793 at posting.google.com... ... > One suggestion for "something else"... there is a Visual Basic function > "sendkeys()" that does exactly what is requested--it simulates keyboard Easily usable from Python too (as it's packaged as part of the Windows Scripting Host, a free download from Microsoft if you don't have it already installed). See an example, e.g., at: http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/65107 Pity it won't help the original poster (who's on Linux) -- unfortunately, generic scriptability under Unix-y systems tends to be horrible for all non-text-mode applications (except, I'm told, those built with certain clever toolkits -- no direct experience, sorry). Ah, *COM*...! Alex From thecalm at NOSPAM.btinternet.com Mon Jun 25 12:33:54 2001 From: thecalm at NOSPAM.btinternet.com (Gaz) Date: Mon, 25 Jun 2001 17:33:54 +0100 Subject: any idea how i could test if a variable is a floating point number? References: <9h76io$ht3$1@neptunium.btinternet.com> <9h7790$l0e$1@plutonium.compulink.co.uk> Message-ID: <9h7p43$aob$1@uranium.btinternet.com> thanks :) gaz wrote in message news:9h7790$l0e$1 at plutonium.compulink.co.uk... > > any idea how i could test if a variable is a floating point > number? > > type(variable)==type(1.0) From gbgbgb at gmx.de Fri Jun 22 03:37:59 2001 From: gbgbgb at gmx.de (gbgbgb at gmx.de) Date: Fri, 22 Jun 2001 07:37:59 -0000 Subject: Codeobjects of Modules? Message-ID: <9guskn+dkta@eGroups.com> Thanks for the info about the unmarshalling .pyc-files. Thats exactly what I wanted. The reason why I want to use JavaScript for the PVM is simply that you can find JS everywhere. The "only" problem is that Microsoft and Netscape are using different flavours of this language and even the versions differ very much. But this affects only the DOM and not the semantics or syntax of the language it self. My vision is that one can implement Client/Server-Applications on top of an Webbrowser in one language: Python. yours Gunter From paulp at ActiveState.com Sat Jun 30 15:13:59 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sat, 30 Jun 2001 12:13:59 -0700 Subject: Python compiler References: <20010630145541.94405.qmail@web13007.mail.yahoo.com> Message-ID: <3B3E24F7.D0ECBFF7@ActiveState.com> Eric Merritt wrote: > >... > > I wasn't trashing java as a language (or python for > that matter) they are both good languages, python > being better in my opinion. My complaint was about > speed. Most of the time the speed of java and python > is adiquate, but sometimes I require speed. Also it > would be nice to get a big speed increase by just > compiling. Anyhow, I did not meen it as a complaint > just a nice thing to have. Well, there are Java compilers now (in fact there have been for a long time) but I would say that if what you need is speed, the best solution is often to code in Python and then rewrite your inner loops in C. Or even profile your Python and then optimize it. You'll be amazed how much speed you can squeeze out if you concentrate on your problem areas. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From nperkins7 at home.com Fri Jun 1 19:58:40 2001 From: nperkins7 at home.com (Nick Perkins) Date: Fri, 01 Jun 2001 23:58:40 GMT Subject: infinite precision (was Re: Against PEP 240) References: <9f0fc80280a@enews2.newsguy.com> <9f3sa5$45p$1@panix6.panix.com> <9f51p601lqg@enews2.newsguy.com> <9f5fpf$qo9$1@panix2.panix.com> <9f5lrt026g6@enews2.newsguy.com> Message-ID: ..that's better, now you two boys shake hands... If I had to think of something that was unbounded but not infinite, I would say the surface of the Earth. It is unbounded becuase you can walk in any direction for ever, but the area in not infinite. Just goes to show how human language is inexact, subjective, dynamic, etc... (don't know how this relates to PEP240) From loewis at informatik.hu-berlin.de Tue Jun 5 04:47:30 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 05 Jun 2001 10:47:30 +0200 Subject: Why doesn't this work as expected? References: <9fi5j5$pk6$0@216.39.170.247> Message-ID: David LeBlanc writes: > I'm trying to build a directory walker, doing some work on each actual > file found in each directory. However, when I run the below code snippet > on a directory containing both sub-directories and files, it says that > all are not dirs. > > What is not right? You need to concatenate the file name to the path, or change the working directory: > def getDirs(): > print dircache.listdir("l:/languages/python") > > for dir in dircache.listdir("l:/languages/C"): dir = "l:/languages/C/"+dir > if os.path.isdir(dir): > print dir, "is a dir" > else: > print dir, "is not a dir" > > getDirs() Regards, Martin From GeorgLohrer at gmx.de Mon Jun 4 00:26:35 2001 From: GeorgLohrer at gmx.de (Georg Lohrer) Date: Mon, 04 Jun 2001 06:26:35 +0200 Subject: XML examples needed References: <3b1aa296.13311941@news.laplaza.org> Message-ID: On Sun, 03 Jun 2001 20:59:12 GMT, xyzmats at laplaza.org (Mats Wichmann) wrote: >Sigh. Sometimes all this stuff makes me feel really stupid. > >I'm trying to figure out some really basic usage of XML in Python. I >have a document that I'd like to structure as XML and use Python to >generate an output file from it: the XML is for maintainability of the >"raw data", but it needs to be turned into something much more complex >eventually (a web page with embedded javascript). A fourtnight ago I was in the same situation. After discovering that there are two basically different ways and many more different implementation approaches some light comes into the things. First of all we have two different ways of accessing XML-stuff in Python. One to access it via the the SAX-interface (Standard-API-XML). This interface will callback different methods of yours for getting the starting of an item or the end and of course for characters between these two. The other is the DOM (Document-Object-Model). It uses also the SAX but it provides a higher level interface or representation to/of the XML-data. A DOM-data-structures are built up of 'nodes'. Every node will have siblings or childs. Even the bottom childs will contain the pure data. As an example I give you a code snippet of my facade class for accessing XML: class XMLFacade: """The XMLFacade produces an internal representation of the interfaces description file (XML). The internal data structure holding all interface informations is build as shown: Get internal data structure with 'interfaces = xml_facade.interfaces' The structure is easy (for more details have a look at the DTD): interfaces[key] = (corba_servant, corba_client, originate_message, answer_message) key = string corba_servant = (object-id, implemenation, ns_context_list) object-id = string implementation = string corba_client = (narrow_id, ns_context_list) narrow_id = string ns_context_list = [string] originate_message = string answer_message = string An example of usage could be run by starting the XMLFacade.py stand-alone with xml-file-name as first parameter: 'python ./XMLFacade.py ./interfaces.xml' """ def __init__(self, xml_file_path = None): """Initialize internal variables""" print "c'tor of XMLFacade()" self.__interfaces = {} self.__valid = 0 self.__reader = Sax2.Reader(validate=1) # validate with DTD if xml_file_path: xml_dom_object = self.parse(xml_file_path) self.extract(xml_dom_object) def __del__(self): print "d'tor of XMLFacade()" #------------------------------------------------------------------------ # Access methods # The access could be done by executing "instance.member_var" def _get_interfaces(self): return self.__get_interfaces() def __get_interfaces(self): """Private member method""" return self.__interfaces #------------------------------------------------------------------------ # Public methods def getText(self, node): """Get text-data out of passed node""" assert node.nodeType == Node.ELEMENT_NODE str = "" if node.hasChildNodes(): cnl = node.childNodes for i in range(cnl.length): tn = cnl.item(i) assert tn.nodeType == Node.TEXT_NODE str += tn.data return str def parse(self, xml_file_path=None): """Parse given XML-File and check against DTD if it is valid.""" if xml_file_path: from xml.sax._exceptions import SAXParseException try: xml_dom_object = self.__reader.fromUri(xml_file_path) except SAXParseException, ex: print "XML not valid (checked against DTD)!n%s"%ex sys.exit(1) return xml_dom_object def extract(self, xml_dom_object=None): """Extract interfaces out of given DOM-document object""" self.__interfaces = {} if xml_dom_object: self.parseXML(xml_dom_object) def parseXML(self, xml_dom_object): assert xml_dom_object.nodeType == Node.DOCUMENT_NODE entry_list = xml_dom_object.getElementsByTagName("ENTRY") for i in range(entry_list.length): # process all 'Entry'-keys key = "" object_id = "" implementation = "" nscs_list = [] # servant's NS_CONTEXT list narrow_id = "" nscc_list = [] # client's NS_CONTEXT list originate_message = "" answer_message = "" entry_node = entry_list.item(i) assert entry_node.nodeType == Node.ELEMENT_NODE kl = entry_node.getElementsByTagName("KEY") key = self.getText(kl.item(0)) # only one KEY-element accepted/expected #- SERVANT -------------------------------------------------------------- csl = entry_node.getElementsByTagName("CORBA_SERVANT") # CORBA_SERVANT list assert csl.length > 0 cs_node = csl.item(0) # only one SERVANT-element accepted/expected oil = cs_node.getElementsByTagName("OBJECT_ID") # assert oil.length == 1 # there must be one OBJECT_ID oi_node = oil.item(0) object_id = self.getText(oi_node) impll = cs_node.getElementsByTagName("IMPLEMENTATION") # assert impll.length == 1 # there must be one IMPLEMENTATION impl_node = impll.item(0) implementation = self.getText(impl_node) nscs_list = [] # NS_CONTEXT servant list nscsl = cs_node.getElementsByTagName("NS_CONTEXT") # NS_CONTEXT list assert nscsl.length > 1 # at least one entry for j in range(nscsl.length): nscs_node = nscsl.item(j) nscs_list.append(self.getText(nscs_node)) #- CLIENT ccl = entry_node.getElementsByTagName("CORBA_CLIENT") assert ccl.length > 0 cc_node = ccl.item(0) # only one CLIENT-element accepted/expected nidl = cc_node.getElementsByTagName("NARROW_ID") # assert nidl.length == 1 # there must be one NARROW_ID nid_node = nidl.item(0) narrow_id = self.getText(nid_node) nscc_list = [] # NS_CONTEXT client list nsccl = cc_node.getElementsByTagName("NS_CONTEXT") # NS_CONTEXT list assert nsccl.length > 1 # at least one entry for j in range(nsccl.length): nscc_node = nsccl.item(j) nscc_list.append(self.getText(nscc_node)) #- ORIGINATE_MESSAGE ---------------------------------------------------- oml = entry_node.getElementsByTagName("ORIGINATE_MESSAGE") if oml.length > 0: oml_node = oml.item(0) # only one CLIENT-element accepted/expected originate_message = self.getText(oml_node) #- ORIGINATE_MESSAGE ---------------------------------------------------- aml = entry_node.getElementsByTagName("ANSWER_MESSAGE") if aml.length > 0: aml_node = aml.item(0) # only one CLIENT-element accepted/expected answer_message = self.getText(aml_node) self.__interfaces[key] = ((object_id, implementation, nscs_list), \ (narrow_id, nscc_list), \ originate_message, answer_message) #============================================================================== def _print_interfaces(interfaces = None): print "Interfaces read:" if interfaces and len(interfaces.keys()) > 0: for key in interfaces.keys(): interface = interfaces[key] servant = interface[0] object_id = servant[0] implementation = servant[1] nscs_list = servant[2] client = interface[1] narrow_id = client[0] nscc_list = client[1] originate_message = interface[2] answer_message = interface[3] print "Key: %s"%key print " Object-ID:%s"%object_id print " Implementation:%s"%implementation print " Servant's NS_Context:",nscs_list print " Client's narrow() Id:",narrow_id print " Client's NS_Context :",nscc_list print " Originate message :",originate_message print " Answer message :",answer_message print else: print "No keys found!" #============================================================================== def _test(): """Testing of XMLFacade()""" import os if len(sys.argv) <= 1: print "Usage:" print "python ",sys.argv[0]," " print sys.exit(1) print "Extract interfaces out of given xml-file\n" if not os.path.isfile(sys.argv[1]): print "Give xml-file(-path) as first parameter" sys.exit(1) xml_facade = XMLFacade() xml_dom_object = xml_facade.parse(sys.argv[1]) xml_facade.extract(xml_dom_object) interfaces = xml_facade.interfaces _print_interfaces(interfaces) del xml_facade print "\n\nDo the same with c'tor setup" xml_facade = XMLFacade(sys.argv[1]) _print_interfaces(xml_facade.interfaces) #============================================================================== if __name__ == '__main__': _test() The XML will look like this: BBEcho BBEechoObjectID BBEcho_i callProcessing CellConfiguration CellConfigCh Example.BBEchoResponse callProcessing CellConfiguration CellConfigChResponseHandler MsgBBEcho MsgBBEchoResponse The DTD looks like this: The whole work is done in XMLFacade.parse_xml(). It extracts the data out of the XML-DOM and fills up lists of different items. These lists will be used in the next steps of the whole application. It's pretty easy to start with a simple XML/DTD and do all 'by-hand' directly running the Python-interpreter. You'll get a deeper understanding if you can see the different data-structures and data-items during processing. Ciao, Georg From careye at spamcop.net Thu Jun 28 06:07:44 2001 From: careye at spamcop.net (Carey Evans) Date: 28 Jun 2001 22:07:44 +1200 Subject: Check out O'Reilly's Open Source Convention Highlights References: <3B3AA82D.1A0FE860@seebelow.org> Message-ID: <87els4dij3.fsf@psyche.dnsalias.org> atodd at spam.free.email.com (Andy Todd) writes: > Path: psyche.dnsalias.org!news02.tsnz.net!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!nntp-relay.ihug.net!ihug.co.nz!newsfeed.mesh.ad.jp!sjc1.nntp.concentric.net!newsfeed.concentric.net!newsfeed.ozemail.com.au!ozemail.com.au!not-for-mail [...] > Greetings from far, far, away, Not that far away. I guess it seems further when posts from across the ditch get here via the US and Japan, though. -- Carey Evans http://home.clear.net.nz/pages/c.evans/ "Quiet, you'll miss the humorous conclusion." From gardner at cardomain.com Thu Jun 14 14:11:44 2001 From: gardner at cardomain.com (Jonathan Gardner) Date: Thu, 14 Jun 2001 11:11:44 -0700 Subject: VI References: <9g9f1v$7oqr5$1@ID-11957.news.dfncis.de> Message-ID: <9gaul7$mth$2@brokaw.wa.com> Emile van Sebille wrote: > I always liked the description that vi has two modes: one beeps at you, > and the other destroys your file. ;-) When I was first learning vi, I found the beeps quite common. What was even more mystical is the way it would mangle your text with ease. A great way to learn how to use vi is to go to normal mode, and type a random letter. That's how I learned about and . Cool feature. > Actually, I use it daily. I'd just prefer something (oh, ok, _anything_) > else. I am addicted to vi. I can't imagine editing text any other way. If only I could get those little textboxes in web forms to use vi instead of basic textedit stuff... oh well. From bsb at winnegan.de Fri Jun 1 17:57:21 2001 From: bsb at winnegan.de (Siggy Brentrup) Date: 01 Jun 2001 23:57:21 +0200 Subject: How to find the package a module belongs to ? In-Reply-To: <90B3AAB72gmcmhypernetcom@199.171.54.155> References: <90B3AAB72gmcmhypernetcom@199.171.54.155> Message-ID: <87d78nsw1q.fsf@winnegan.de> gmcm at hypernet.com (Gordon McMillan) writes: > Jeff Sandys wrote: > ... > [Sasa Zivkov] > >> I have a package containing several modules. > >> Is is possible, within a module, > >> to say "give me the package I belong to" ? > > Strictly speaking, no, not automatically, because module x within package p > may be loaded as p.x or just as x. > [Jeff] > >It would sure be nice to pull this information from some > >secret variable without having to explicitly name them. > > But every module has a __file__ attribute that will tell you (whether the > module is loaded as x or p.x) that it came from some/path/p/x.py. > Just use the module's __name__ attribute, in both cases it's 'p.x'. A module is part of a package iff it's __name__ attribute contains a '.'. >>> import xml.dom.html as H >>> H.__name__ 'xml.dom.html' >>> import socket as S >>> S.__name__ 'socket' Regards Siggy -- Siggy Brentrup - bsb at winnegan.de - http://www.winnegan.de/ ****** ceterum censeo javascriptum esse restrictam ******* From mal at lemburg.com Thu Jun 21 11:49:00 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Thu, 21 Jun 2001 17:49:00 +0200 Subject: How to call cleanup code in a Python extension module References: <9gt0sd$lfc$1@news.tuwien.ac.at> <15154.4623.444106.182370@beluga.mojam.com> Message-ID: <3B32176C.D299238@lemburg.com> Skip Montanaro wrote: > > Markus> ... I wonder where to put the cleanup code when the module is > Markus> unloaded since I have not found a delxxx() function. > > Take a look at the C atexit(3) library function. Note that it will only get > called if your program terminates by a call to exit(3), which may not be the > case when an exception is raised. Python allows you to register atexit() like functions which are executed when Python exits (see e.g. the source code of mxDateTime for an example). Note that unloading of extensions at runtime is not supported by Python. This would require DLL unloading which is not implemented in a platform independent way (it probably could be done, though). As always: patches are welcome :-) -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From nperkins7 at home.com Tue Jun 12 11:15:46 2001 From: nperkins7 at home.com (Nick Perkins) Date: Tue, 12 Jun 2001 15:15:46 GMT Subject: Recursive algorithms anyone? References: <1f0uhtgmhb0vlud6pof6i4mctqjdq8l2eu@4ax.com> Message-ID: oops, in my haste to use 'map', i forgot about the k param... ..but this works: from __future__ import nested_scopes def additem(k,L): def _additem(x): if type(x) is type([]) : return map (_additem,x) else : return x+k return _additem(L) From loewis at informatik.hu-berlin.de Thu Jun 21 14:00:43 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 21 Jun 2001 20:00:43 +0200 Subject: How to change codepage (encoding) in Tcl/Tk References: <44da3708.0106192258.623311a7@posting.google.com> Message-ID: peteris_martinsons at swh-t.lv (Peteris Martinsons) writes: > I want 2 of them to display text in English and 2 in Russian. Is this > possible? If Yes, how do I do this? Which is the property to alter? Your best bet is to pass Unicode object to Tkinter. Regards, Martin From carlf at panix.com Sun Jun 24 12:46:51 2001 From: carlf at panix.com (Carl Fink) Date: 24 Jun 2001 16:46:51 GMT Subject: Is this a true statement? References: <3b34939b.410758@nntp.sprynet.com> <3b35ebc3.1024709@nntp.sprynet.com> <9h516e$c2a4d$1@ID-11957.news.dfncis.de> <3b3611b0.10735139@nntp.sprynet.com> Message-ID: In article <3b3611b0.10735139 at nntp.sprynet.com>, David C. Ullrich wrote: > Whether anyone belives it or not, I _did_ have actual questions > at the start of this. It was said that you cannot write a device > driver in Python because Python cannot access hardware interrupts > (or whatever). I don't see how a program _writing_ a device > driver needs to do that, so I don't see what it has to do with > whether you can write a device driver in Python. The implication of "write" there meant "write a device driver in Python that is executed by the Python interpreter." -- Carl Fink carlf at dm.net From aleaxit at yahoo.com Wed Jun 6 17:50:44 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 6 Jun 2001 23:50:44 +0200 Subject: Generating Multiple Class Instances References: <3B1E9271.B05CC4E3@fnal.gov> Message-ID: <9fm8rq050a@enews1.newsguy.com> "Paul Prescod" wrote in message news:mailman.991861150.19995.python-list at python.org... ... > You aren't changing the list. You're just reading from it, never writing > to it. Here's a straightforward way to do it: > > flavornames = ['up', 'down', 'strange', 'charm', 'top', 'bottom'] > flavors = [] > for each in flavornames: > flavors.append(Quark()) More straightforward IMHO: flavors = [Quark() for each in flavornames] > for each in flavors: > print each.color > > I still don't know where to get the colors or masses. Also, don't you > want to somehow associate the flavornames with the quarks you create? I hypothesized in another post (where I shared just your doubts, but we 'crossed':-) to serve both purposes by giving Quark's __init__ the flavorname as argument: flavors = [Quark(each) for each in flavornames] presumably the body of Quark.__init__ would bind that name as self.name as well as pass it to getcolor & getmass... Alex From steven_shaw at users.sourceforge.net Tue Jun 12 00:30:29 2001 From: steven_shaw at users.sourceforge.net (Steven Shaw) Date: 11 Jun 2001 21:30:29 -0700 Subject: Learning OOP... References: <9fm8ti$d92$1@newshost.accu.uu.nl> Message-ID: <503ca784.0106112030.3d434e08@posting.google.com> Java is the language that best suits your requirements. 1. OOP and "business/enterprise oriented" 2. A good career move! 3. Code reuse - I guess so 4. Debugging tools - free IDEs JBuilder and Forte 5. Strong typing no generics - use GJ for generics in Java 6. Java is pretty easy to learn - a no brainer. Perhaps not quite as easy to earn as Python. 7. Reduced development times could come from Java's automated garbage collection. 8. Java is portable and scalable? 9. There's so much Java open source code available it's not funny. http://jakarta.apache.org/ http://enhydra.org/ http://exolab.org/ http://jacorb.org/ 10. Source code is familiar (to C/C++ programmers, anyway) and easy to read. 11. Many Java tools are free - like the JDK. The compilers are ok but you can't seem to get a free native compiler just yet. gcj is on the way. JVMs are freely available for most platforms. You've not mentioned performance as a criteria - otherwise my recommendation would have been made more difficult :-) Perhaps you are not elucidating some requirements that led you to think of ADA? Perhaps that language is used widely in your industry? Java can be used effectively with Jython for the things you decide it's best you don't have strong typing. Understand that the edit/compile/run turnaround can sometimes slow down development when using Java (compared to using Python/Jython). Using an IDE such as JBuilder or Forte should help with this problem. From cribeiro at mail.inet.com.br Fri Jun 1 07:21:54 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Fri, 01 Jun 2001 08:21:54 -0300 Subject: O(n^2) is bad - can it be fixed? In-Reply-To: References: <5.0.2.1.0.20010531195829.025f2e60@mail.inet.com.br> Message-ID: <5.0.2.1.0.20010601081527.025b20a0@mail.inet.com.br> At 22:32 31/05/01 -0400, Tim Peters wrote: >... Guido had more than enough of >slowing down every case to cater to unreasonable cases when he worked on >ABC. As a result, Python's builtin types strive to be just as dumb as >possible <0.9 wink>. I can see the wisdom of Guido on this. Taken separately, each little such "optimization" slows down the most common case very little. Looking only at it it seems reasonable. But when you get hundreds of such optimizations, the resulting code is bloated and *much* slower that the simpler one would ever be. Anyway, (as said before) Python nature makes it easy to solve it my means of extensions. A different list implementation could be done and exposed using some well known interfaces. Maybe it proves to be faster for every case; if it does so, nobody would mind patching The Source with it, dont you think? Who's volunteer? :-) Carlos Ribeiro From dsh8290 at rit.edu Thu Jun 7 13:26:36 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 7 Jun 2001 13:26:36 -0400 Subject: Why should i use python if i can use java In-Reply-To: ; from dwig@advancedmp.net on Thu, Jun 07, 2001 at 09:49:36AM -0700 References: <9fngvl011jg@enews2.newsguy.com> Message-ID: <20010607132636.B14962@connecticut.cs.rit.edu> On Thu, Jun 07, 2001 at 09:49:36AM -0700, Don Dwiggins wrote: | Alex Martelli quotes Glyph Lefkowitz: | >> > an elegant way of implementing singletons (or does it? anyone?) | >> | >> Aah, the singleton. Global variables for the new millennium. First of | >> all, the singleton "pattern" is usually a bad idea. If you have a class | | > *AMEN, HALLELUJAH*! This makes two of us sharing this dislike | > for the Singleton Design Pattern, so I'm not a Singleton any | > more -- see, that's one typical issue with Singleton DP, what | > starts out as a singleton often becomes not one:-). | | According to the GOF "Applicability" section on Singleton: | Use the Singleton pattern when | - there must be exactly one instance of a class, and it must be | accessible to clients from a well-known access point. | - when the sole instance should be extensible by subclassing, and | clients should be able to use an extended instance without modifying | their code. | | If you take the whole description of the Singleton pattern seriously, to say | that you "hate" the pattern would seem to mean that you don't believe that | programs should ever need something that satisfies these criteria. Is that | true for both of you? Whether it is or not, I'd like to hear a bit more | explanation for the strong emotional reaction to the pattern. Alex Martelli discussed his views with me a couple months ago. He explained that flyweight proxies can serve the same need as a singleton, but without the subtle problems the Single DP can present. The flyweight proxies don't hold any state of their own, but rather delegate everything to the single instance of a private class. The proxies can be copied around, instantiated at will, etc. They are "normal" objects. This issue is especially important in C++ where the compiler can automatically create and call a copy constructor for your object. This is a very brief summary of what Alex showed me. I'm sure he will see your question and give you the long, detailed, explanation he is so skilled at :-). -D From aleaxit at yahoo.com Mon Jun 18 05:02:09 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 18 Jun 2001 11:02:09 +0200 Subject: why is there no class (static) methods in Python ? References: <3B2D114E.7B39D954@intraware.com> Message-ID: <9gkg2i0278e@enews2.newsguy.com> "Richard Gruet" wrote in message news:3B2D114E.7B39D954 at intraware.com... > Hi all, > > I (and other people on the Python french mail list) wonder why there > are no class (static) methods in Python. You cannot define a really > unbounded (ie to an instance) method within the namespace of a class. > It's not natural nor elegant to have to create an instance to call a > method which is not related to a particular instance. We would like to > be able to write things like: > > class C: > def staticFoo(x): print x > > C.staticFoo(1) http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/52304 Alex From matt at mondoinfo.com Fri Jun 29 16:00:48 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Fri, 29 Jun 2001 20:00:48 GMT Subject: Tkinter problem in sizing a frame References: Message-ID: On Fri, 29 Jun 2001 11:04:45 -0400, Joe Potter wrote: >In the following code (adopted from "Python and Tkinter Programming") >I find that I can set the minimum size for the root widget. However, >I can not seem to tell Tk that I want two sub-frames each of which I >want to take up half the parent frame. All I get is two sub-frames >that take up as much room as need to display the label in each. Joe, You were very close. The problem was the fill and expand are options to the packer, not the widgets themselves. (I don't know why the widgets don't complain that they don't understand those options.) I think this will do what you want: from Tkinter import * root = Tk() root.title('Frame Size') root.geometry("600x300") # Dont really need this frame f = Frame(root) xf = Frame(root, relief=GROOVE, borderwidth=5) jf = Frame(root, relief=GROOVE, borderwidth=5) Label(xf, text="You shot him!").pack(side=LEFT, pady=10) Label(jf, text='heck if I know !??').pack(side=LEFT, padx=10) jf.pack(side=TOP,fill=Y,expand=1) xf.pack(side=BOTTOM,fill=Y,expand=1) #f.pack() root.mainloop() Regards, Matt From chapman at bioreason.com Fri Jun 15 14:25:16 2001 From: chapman at bioreason.com (Mitch Chapman) Date: Fri, 15 Jun 2001 12:25:16 -0600 Subject: Any other Python flaws? References: Message-ID: <3B2A530C.5F798823@bioreason.com> Andrew Kuchling wrote: > > I was updating my page of possible Python design flaws > (http://www.amk.ca/python/writing/warts.html) last night to take 2.1 > into account. 2.1's nested scoping fixes one major wart, and the > other major one, the type/class dichotomy, might get fixed in 2.2 if > the descr-branch in CVS turns out well. (It's neat that the two > largest ones may both get fixed before 2001 is out.) > > That leaves the remaining warts as minor wibbling about 'do' > statements, print >>, and the like. Are there any other flaws that > should be added? > > --amk I suspect from some of your follow-ups that "uncancellable threads" does not fit the purpose of your design flaws page, and in any case it's covered by a PEP (42?). Even so, since the problem extends across all platforms I'll propose it. The fact that threads cannot be cancelled -- except when they are written to permit "cooperative" cancellation -- limits their usefulness. If you need cancellable long-running background computations, the only reasonable solution is often a convoluted subtask management framework. I've been lucky in needing such a framework only for Unix variants. Variations in IPC semantics among the major OS platforms would make a cross-platform subtask management framework even harder to maintain. -- Mitch Chapman Mitch.Chapman at bioreason.com From mwh at python.net Tue Jun 19 06:28:48 2001 From: mwh at python.net (Michael Hudson) Date: 19 Jun 2001 11:28:48 +0100 Subject: The Scoop on Python Input? References: Message-ID: GulickDO at uReach.com writes: > Hey gang. I recently fell in love with Python for Linux and have > been doing a fair amount of work programming console-based apps. I > have about three or four Python reference books and was pretty > disappointed how poorly the concept of "input" was covered in the > books! So maybe someone here can send me in the right direction. > > Is there a Python input function that will get just one character > from the keyboard without waiting for enter to be pressed? (like getch > () in C++?) I found a module that provides getch(), but it is > restricted to Window's-based platforms. > > Any suggestions would be appreciated. > > Thanks. > > G. > > Does this http://groups.google.com/groups?ic=1&th=bd4b730087a1bf22 help? Cheers, M. -- Famous remarks are very seldom quoted correctly. -- Simeon Strunsky From ullrich at math.okstate.edu Sun Jun 24 09:42:55 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 24 Jun 2001 13:42:55 GMT Subject: Is this a true statement? References: <3b34939b.410758@nntp.sprynet.com> Message-ID: <3b35ed3b.1401529@nntp.sprynet.com> On 23 Jun 2001 15:34:56 GMT, carlf at panix.com (Carl Fink) wrote: >In article , Chris >Gonnerman wrote: > >> Writing TO a device driver is easy enough... the previous poster >> was talking about writing the DRIVER in Python. No OS I'm aware >> of takes device drivers in any languages other than assembler, C, >> and/or C++. > >He's making a very finicky, nitpicking, and frankly silly point: the >device driver is a sequence of bytes. You can write that sequence of >bytes *directly as machine code* from Python, in the sense that you >can have a Python program that would create a valid device driver >file by opening it, writing those bytes to it, and closing it. As opposed to a program written in C that writes a device driver: It opens a file, writes bytes to it, and closes the file. (Doesn't it??? What _else_ does it do?????) >Essentially he's deliberately misunderstanding what "write" means, >using the "write to a file" meaning instead of "create a new program" >meaning. I may well be misunderstanding something, but it's not deliberate. What _is_ the distinction between "write to a file" and "create a new program"? (I'm assuming that the "program" in question is the device driver. _Is_ that something other than a file? And if not then what does a C program that writes device drivers do, other than write a file?) >-- >Carl Fink carlf at dm.net David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From ullrich at math.okstate.edu Sun Jun 3 15:16:44 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 03 Jun 2001 19:16:44 GMT Subject: random References: <9fcu3601vet@enews2.newsguy.com> <3b1a564f.2986926@nntp.sprynet.com> <9fds6l01lo4@enews2.newsguy.com> Message-ID: <3b1a8820.15741847@nntp.sprynet.com> On Sun, 3 Jun 2001 19:29:00 +0200, "Alex Martelli" wrote: [things which do not include any clarification of exactly when I refused to give the definition of some term I was using snipped] You really feel for some reason it's ok for you to be as insulting as you like, eh? Why is that? Sorry. Probably you're going to claim that that wasn't clear. Lemme rephrase in the language you've been using: string.upper("""You really feel for some reason it's ok for you to be as insulting as you like, eh? Why is that?""") I hope that's clearer. Anyone who doesn't see what's so insulting about accusing someone of refusing to define his terms in a "debate" about mathematical issues should request a clue. (Preferably in private and not of me. I'm certain Tim could explain what I find so totally unacceptable about it for example, whether he feels the same way or not.) It's certainly possible that I failed to give some definition when asked because I didn't notice the request buried in the rest of this stuff. Which is why I've asked him to clarify when I did this. Repeatedly. David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From db3l at fitlinxx.com Thu Jun 14 13:33:14 2001 From: db3l at fitlinxx.com (David Bolen) Date: 14 Jun 2001 13:33:14 -0400 Subject: Pure Python mini-DB and NCurses References: <4a7fde99.0106140057.1e2fb285@posting.google.com> Message-ID: ryanmorillo at hotmail.com (Ryan) writes: > As for the ncurses I'm just trying to figure out why it would be used. > If anyone has a reason other than novilty I would appreciate it as I > can't understand what Guido was thinking when he put it in. I don't suppose you've only been working with computers since the typical interface was graphical, have you? Curses is a long time (of which ncurses was a more recent enhanced version) API for handling text mode console-like output that wasn't purely stream oriented. That is, it permitted control of an addressable text display (e.g., put text at position (1,1)) rather than just writing lines of text one after the other. It also supports tracking screen contents, so that you can do the equivalent of pop-up menus, fill-in-forms, and so on, all on a textual device. Definitely not a novelty when that's your output device, although certainly less common nowadays. Before GUIs came along this was the normal mode of operation - everything was textual, except for dedicated graphical devices/terminals. And it's still a very common operational mode (particularly under Unix, and particular for administrative tasks). Definitely not a novelty. Think of it as the difference under Windows between running EDIT at the MS-DOS prompt, and using notepad. Both edit files, but EDIT has to manage its "windows" as part of the console display, and not graphically. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From benjamin.altman at noaa.gov Fri Jun 22 12:18:21 2001 From: benjamin.altman at noaa.gov (Benjamin.Altman) Date: Fri, 22 Jun 2001 12:18:21 -0400 Subject: popen Message-ID: <3B336FCD.77678C54@noaa.gov> I was wondering when something like popen2 would used over popen. What is the advantage of running as a sub-process? From tdelaney at avaya.com Tue Jun 26 20:29:14 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Wed, 27 Jun 2001 10:29:14 +1000 Subject: Mutable Strings? Message-ID: [ snip request for Java StingBuffer equivalent ] Try using a character array (not list - although as has been pointed out, you can use a list and join the elements - that is the standard python idiom, but an array is closer to a StringBuffer). import array s = array.array('c') # optionally, s = array.array('c', 'initial string') s.fromstring('abc') s.fromstring('defg') print s.tostring() Tim Delaney From glen at enabledventures.com Fri Jun 8 18:35:34 2001 From: glen at enabledventures.com (Glen Starchman) Date: Fri, 08 Jun 2001 15:35:34 -0700 Subject: WHY is python slow? References: Message-ID: <3B215336.B62001CD@enabledventures.com> > now, if we accept the postulate that premature programme optimisation > is an evil and that python has been around much longer than ruby, has > much better documentation and that in Bruce Eckel's words: > > "...I usually find that this question [Do you have any opinions about > the Ruby language, especially compared to Python?]is asked by someone > who is considering learning to program, and was snagged by the fact > that Ruby is new, and perhaps thinks that it's going to be the next > great thing like Java. From everything I can see, it's not. For some > reason, the creator of the language saw Python and decided to do a > clone, and people who had never used Python thought it was a good > idea. Harsh, maybe, but that's my impression: if you've used Python > at all, you wouldn't give Ruby a second glance. " > > Ouch! That's quite a stinging criticism. However, the statement "The author saw Python and decided to do a clone" is asinine. Ruby inherits more from Smalltalk than from Python. Ruby has many Perl-like qualities without the syntactic mess. Ruby pretty much kicks ass. Now, before I am accused of starting (or encouraging) a language war, understand that Python is still far and away my favorite language (although currently I am doing more with the Java/Python hybrid Jython). Both Python and Ruby (and, begrudgingly, Perl) have a place in the developer's toolbox. I look at it like this: if my mood fits Python, I code in Python... if I feel like a little Ruby, I code it in Ruby. Language wars are counterproductive. From daha at best.com Fri Jun 15 15:07:23 2001 From: daha at best.com (David S. Harrison) Date: Fri, 15 Jun 2001 19:07:23 +0000 (UTC) Subject: PEP 255: Simple Generators References: Message-ID: <9gdmdb$3c4$1@nntp1.ba.best.com> This is an awesome PEP. I have used Icon extensively in the past and I have found generators to be very useful and elegant. It was not exactly clear in the proposal, but will it be possible to enumerate elements outside of the "for" idiom? Sometimes it is useful to get elements out of a generator in different parts of a program. For example, the first few elements might be consumed by one function, and the next by another. Is this possible under PEP 255? David S. Harrison (daha at best.com) From mwh at python.net Fri Jun 8 21:48:57 2001 From: mwh at python.net (Michael Hudson) Date: 09 Jun 2001 02:48:57 +0100 Subject: nested scopes oddity/BUG References: Message-ID: Robin Becker writes: > When I try to run this script > ##################### > from __future__ import nested_scopes > def gen(B): > class W(B): > __base=B > def __init__(self): > B.__init__(self) > return W > > class C: > def __init__(self): > pass > ##################### > > I get > > Fatal Python error: non-string found in code slot > > abnormal program termination > > this with 2.1 on Win9x. It works fine and dandy if I remove the spurious > __base=B This is fixed in CVS. I bumped into it writing very similar code a couple of weeks back, and found it had already been mended... 2.1.1-here-we-come-ly y'rs M. -- ARTHUR: But which is probably incapable of drinking the coffee. -- The Hitch-Hikers Guide to the Galaxy, Episode 6 From jm7potter at hotmail.com Wed Jun 27 08:29:52 2001 From: jm7potter at hotmail.com (Joe Potter) Date: Wed, 27 Jun 2001 08:29:52 -0400 Subject: newbie with major "lambda" problem (perhaps a scope problem as well) References: Message-ID: On Tue, 26 Jun 2001 17:11:12 GMT, "Rainer Deyke" wrote: >"Joe Potter" wrote in message >news:n8dhjt8qmel0ajjae7tv9gmjf60c39qag5 at 4ax.com... >> My question is *why* the lambda is allowed to call the perfectly defined >function >> fetch, but a direct call of fetch is not. > >Consider: > >def f(): > return 5 > >'f' is a function that returns the number 5. >'lambda: f()' is also a function that returns the number 5. >'f()' is not a function at all, but just the plain number 5. >'(lambda: f())()' is also just the plain number 5. >'lambda: (lambda: f())()' is a function again. > >Tkinter wants a function. > >Get it now? I am close. Please see my reply to Chris Barker for the last of my troubles. I do thank you very much for your kind efforts. Regards, Joe From aleaxit at yahoo.com Fri Jun 29 09:24:58 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 29 Jun 2001 15:24:58 +0200 Subject: the center of the world (was Re: Check out O'Reilly's Open Source Convention Highlights) References: <3B3AA82D.1A0FE860@seebelow.org> <3B3B2DED.5303198A@seebelow.org> <9hhri7019jd@enews2.newsguy.com> Message-ID: <9hhvk901f2a@enews2.newsguy.com> "Konrad Hinsen" wrote in message news:m366df8mcy.fsf at chinon.cnrs-orleans.fr... > "Alex Martelli" writes: > > > to 'population centers'. Of course I could get different > > centers by choosing different weighing factors (country GNP > > rather than country population, for example). > > Or by Python expertise ;-) Know any freely available databases indicating latitude and longitude of Python experts...? > > Hmmm, if the coordinates were on a plane, finding the weighed center > > would be trivial, but offhand I can't think of how to do it on a > > sphere's surface -- I guess there must be some way more suitable > > than just solving a generalized extremization problem -- can anybody > > suggest one...? > > What's so bad about it? Searching for a global minimum in two > variables is not so difficult. All the more within finite coordinate > intervals. Of course there might be no global minimum at all. Think positive -- there may be SEVERAL locations that are global minima... Alex From aleaxit at yahoo.com Fri Jun 8 05:05:37 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 8 Jun 2001 11:05:37 +0200 Subject: Learning OOP... References: <9fm8ti$d92$1@newshost.accu.uu.nl> Message-ID: <9fq4gv04np@enews1.newsguy.com> "Rod Weston" wrote in message news:f7ce0059.0106071525.6c9688fb at posting.google.com... > The reasons I feel a need to learn OOP languages are as follows: ... > 2. Career choices - any programmer in today's market needs to be OOP > conversant and productive, preferably with a language that will be > recognized and used 'a lot', thereby generating profitable > opportunities. Yep. But I don't think Ada is most marketable today (you'll no doubt want to check on comp.lang.ada!-) -- the "recognized and used a lot" OO languages are rather Java, C++, Visual Basic. > 5. I want strong and flexible data typing - I know it sounds like an > oxymoron. I want the typing to be especially powerful (restrictive) > but I want to be able to define the constraints of the types myself. Eiffel and Haskell are the two best matches for this requisite IMHO -- in different senses -- when conjoined with the later requirement that the checking be (at least to some extent) a static (i.e., compile-time) one. > Not all the objectives relate to OOP, but most do. From what I've > seen so far, Ada best meets my criteria but I have not done enough > research yet to be willing to gamble my future on it. Most of your criteria are of the "motherhood and apple pie" kind -- most languages will CLAIM to meet them:-). 2 and 5 are the really-specific ones, and they clash. The popular languages in 'career choice' terms have variously defective datatyping systems -- O'Haskell may be perfect in this way (Eiffel isn't AFAIK -- unless they've plugged it recently, covariance implies a gaping hole -- and of course contracts aren't mostly compile-time-checked, but run-time-checked), but you won't find many contracts specifying it:-). Anyway, Python doesn't do "especially restrictive" anything -- so, since this restrictiveness is part of your specs, you'll have to look elsewhere than in this group. (Many of us Pythonistas have had more experience with "bondage and discipline" languages than we care to recount, and that's a big part of why we're Pythonistas today...:-). Alex From scarblac at pino.selwerd.nl Mon Jun 11 03:28:43 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 11 Jun 2001 07:28:43 GMT Subject: BUG? list-comprehension's inconsistency? was: Re: list-display semantics? References: Message-ID: Roman Suzi wrote in comp.lang.python: (snippage) > 3->>> [[x for x in [1, 2, 3]], [y for y in [4, 5, 6]]] > [[1, 2, 3], [4, 5, 6]] > > (it was a discovery to me to know that I can delimit > naked list comprehensions by "," inside list definitions!) >>> [1, 2] [1, 2] >>> [[1,2,3], [4,5,6]] [[1,2,3], [4,5,6]] >>> [[x for x in in [1, 2, 3]], [y for y in [4, 5, 6]]] [[1,2,3], [4,5,6]] That is, you just rediscovered something you already knew :) -- Remco Gerlich From djc at object-craft.com.au Mon Jun 18 23:31:44 2001 From: djc at object-craft.com.au (Dave Cole) Date: 19 Jun 2001 13:31:44 +1000 Subject: Sybase module 0.26 released Message-ID: What is it: The Sybase module provides a Python interface to the Sybase relational database system. The Sybase package supports almost all of the Python Database API, version 2.0 with extensions. The module works with Python versions 1.5.2 and later and Sybase versions 11.0.3 and later. It is based on the Sybase Client Library (ct_* API), and the Bulk-Library Client (blk_* API) interfaces. The 0.20 and later releases are a reimplementation of the module using a thin C wrapper on the Sybase-CT API, and a Python module to provide the DB-API functionality. It is still a work in progress, but should be good enough for most purposes. Changes for this release: - A collection of Sybase example programs was found and converted to use the sybasect module. This highlighted some bugs and many omissions. For the curious the example programs have been included in the release. array_bind.py diag_example.py mult_text.py bulkcopy.py dynamic_cur.py params.py cursor_sel.py dynamic_ins.py rpc.py cursor_upd.py example.py timeout.py On the whole I have avoided relying on using Sybase CT library callback functions. The timeout.py example program requires the use of a callback. Since callbacks cause the Python interpreter to be reentered, you cannot compile the module with multi-thread support. This is controlled via the WANT_THREADS #define in sybasect.h - The ntsetup.py distutils program was merged into the setup.py - The Buffer type was renamed to DataBuf to avoid type name clashes with the Python BufferType. - Bug was fixed in blk_bind() which was passing Python type object by value instead of by reference - oops. - All of the extension types in the sybasect module are now exported. - More work has been done on the documentation. There is very little outstanding programming work for the module. Most future work will be concentrated on the documentation. Where can you get it: http://www.object-craft.com.au/projects/sybase/ - Dave -- http://www.object-craft.com.au From mixo77 at usa.net Wed Jun 13 04:50:56 2001 From: mixo77 at usa.net (mixo) Date: Wed, 13 Jun 2001 10:50:56 +0200 Subject: Traceback output Message-ID: <3B272970.4BA5D01C@usa.net> How can I catch output from "traceback.print_exc()"? I would to be able to do is write the information in a file . I From alten at math.chalmers.se Mon Jun 11 06:32:33 2001 From: alten at math.chalmers.se (Fredrik Altenstedt) Date: Mon, 11 Jun 2001 12:32:33 +0200 Subject: PyBison Message-ID: Hi, Does anybody know where I may find the PyBison package by Scott Hassan. There are scattered references to it all over the web, which all seem to point to http://coho.stanford.edu/~hassan/Python/pybison.tar.gz, which forwards to the dead link http://dotfunk.com/hassan/homepage/Python . (His ordinary homepage is at http://dotfunk.com/hassan/homepage/, but his contact info is password protected, so I guess he does not wish to be disturbed). /Fredrik Altenstedt Fredrik Altenstedt Email: alten at math.chalmers.se Department of Mathematics Phone: +46 31 7725379 Chalmers University of Technology S-412 96 Gothenburg, SWEDEN From sill at optonline.net Tue Jun 19 05:50:09 2001 From: sill at optonline.net (Rainy) Date: Tue, 19 Jun 2001 09:50:09 GMT Subject: The Scoop on Python Input? References: Message-ID: On Tue, 19 Jun 2001 02:59:57 -0000, GulickDO at uReach.com wrote: > Hey gang. I recently fell in love with Python for Linux and have > been doing a fair amount of work programming console-based apps. I > have about three or four Python reference books and was pretty > disappointed how poorly the concept of "input" was covered in the > books! So maybe someone here can send me in the right direction. > > Is there a Python input function that will get just one character > from the keyboard without waiting for enter to be pressed? (like getch > () in C++?) I found a module that provides getch(), but it is > restricted to Window's-based platforms. > > Any suggestions would be appreciated. > > Thanks. > > G. Yep, there is a way but it isn't too pretty. It's covered in python faq. It only seems to work for 2.1, though :/. Also, there doesn't seem to be any way to unget the character, i.e. make a progress indicator that shows 37% 42% etc but in one place as something progresses, except in curses. > > -- Lucifer Sam Siam cat Always sitting by your side Always by your side That cat's something I can't explain - Syd From brian at sweetapp.com Sat Jun 16 13:25:12 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Sat, 16 Jun 2001 10:25:12 -0700 Subject: Writing new codecs Message-ID: <002201c0f689$4d46c550$445d4540@D1XYVL01> I just finished writing a modified UTF-7 encoder/decoder in Python and am planning on contributing it back. My question is regarding form: should new codecs be written in C or Python? AFAIK, Python does not currently include any codecs written in Python (I'm not counting the character mapping ones or the trivial wrappers around C code). Is this because the current codecs are all "important" and future codecs should be implemented elsewhere to avoid adding too much junk to codecmodule.c and unicodeobject.c? Or is the pattern of providing the actual implementation in unicodeobject.c going to continue? Cheers, Brian From rossini at blindglobe.net Thu Jun 14 16:09:04 2001 From: rossini at blindglobe.net (A.J. Rossini) Date: 14 Jun 2001 20:09:04 GMT Subject: kmeans cluster analysis ? References: Message-ID: <9gb5l0$rb$0@216.39.145.92> >>>>> "TS" == Thomas Sicheritz-Ponten writes: TS> William Park writes: >> On Wed, Jun 13, 2001 at 09:50:32PM +0200, Thomas >> Sicheritz-Ponten wrote: > Before reinventing the wheel ... does >> anybody know of a python > implementation of the kmeans cluster >> analysis or (preferable) > bi-secting kmeans ? >> >> Need more detail (sigh!) >> TS> For a short description of kmeans and bi-secting kmeans check: TS> http://www-users.cs.umn.edu/~karypis/publications/Papers/PDF/doccluster.pdf TS> (preferable starting with a distance matrix ...) Implemented in R (www.r-project.org), a GNU GPL'd statistics package. Connect via RSPython (www.omegahat.org), for embedding R in Python. best, -tony -- A.J. Rossini Rsrch. Asst. Prof. of Biostatistics U. of Washington Biostatistics rossini at u.washington.edu FHCRC/SCHARP/HIV Vaccine Trials Net rossini at scharp.org -------- (wednesday/friday is unknown) -------- FHCRC: M-Tu : 206-667-7025 (fax=4812)|Voicemail is pretty sketchy/use Email UW: Th : 206-543-1044 (fax=3286)|Change last 4 digits of phone to FAX From JamesL at Lugoj.Com Sat Jun 9 12:50:53 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Sat, 09 Jun 2001 09:50:53 -0700 Subject: is c faster? References: Message-ID: <3B2253ED.2F490A7F@Lugoj.Com> akhar wrote: > would C code be faster? Yes. > by what factor? Without knowing what you are doing, one can only guess. If you are already using PIL and numpy as implied by your note, then it may be a small factor. If you have any remaining loops within loops, then you would definitely gain by coding that portion in C. From ejr at cs.berkeley.edu Thu Jun 7 20:05:02 2001 From: ejr at cs.berkeley.edu (Edward Jason Riedy) Date: Fri, 8 Jun 2001 00:05:02 +0000 (UTC) Subject: Numeric Programming for Everybody References: <9fo98s$bui$03$1@news.t-online.com> Message-ID: <9fp4re$2sgt$2@agate.berkeley.edu> And Georg Mischler writes: - - I just noticed the following on an invoice I have to pay: [...] - Obviously, some programmer decided on granting me a rebate - of one german Pfennig. Um, was there another column in Euros? If so, you may have seen an oddity of exchange rates. See paper #22 at http://europa.eu.int/euro/html/rubrique-defaut5.html?rubrique=133&lang=5 Jason -- From bwalker at earth1.net Tue Jun 5 19:46:28 2001 From: bwalker at earth1.net (Bill Walker) Date: Tue, 5 Jun 2001 19:46:28 -0400 Subject: Bios calls in Python? Message-ID: Is it possible to make BIOS calls in Python (Windows version)? In particular, I would like to plot graphic points in EGA resolution to the console screen. From whisper at oz.nospamnet Fri Jun 22 13:06:43 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 22 Jun 2001 17:06:43 GMT Subject: [OT] MS EULA -- (will ActiveState become outlaws? ;-) References: <3B32F81F.259DBA46@chello.nl> <3B33644D.E32B4215@pfortin.com> Message-ID: <9gvtv3$n2e$1@216.39.170.247> In article <3B33644D.E32B4215 at pfortin.com>, pfortin at pfortin.com says... > This page was visible with NS4.77/Linux yesterday; now, it stalls for a few > seconds, then presents a "page not found" screen... either they are shutting > out NS and/or Linux, or they've removed it... Today MS IE 5.5 stalls and then puts up a "page cannot be found" 404 page. I wonder if MS legal woke up and smelled the gathering litigation clouds. I'm not a lawyer, but this smacks of restraint of trade or unfair competition at least. Of course, that's par for the course at MS, but even they are not usually so stupid as to hand the opposition a smoking gun like this. Roeland Rengelink wrote: > > Well, as I see it the GPL licence is morally equivalent to > > > > 1. This is raging commie stuff > > 2. You can't use raging commie stuff in conjunction with evil empire > > stuff > > > > and this microsoft licence is morally equivalent to > > > > 1. This is evil empire stuff > > 2. You can't use evil empire stuff in conjunction with raging commie > > stuff > > > > For once the free software movement and microsoft seem to agree on > > something > > > > More seriously, the lack of a definition of ''use'' under (ii), and the > > misleading definition of Potentially Viral Software gives the impression > > that this was written by their PR department, rather than their lawyers. > > > > But then, I know as little about law as I do about PR. > > > > Roeland Fascism or communism - what choices! Hopefully, while this is something important to watch, it won't overshadow "World Domination Phase II" that's embodied in Windows XP - "Your wallet is our wallet and our thoughts are your thoughts because we control the links". Of course the good news about XP is that it's a poster child for Linux. > Pierre > Dave LeBlanc From mike_haspert at credence.com Tue Jun 19 20:33:18 2001 From: mike_haspert at credence.com (Mike Haspert) Date: 19 Jun 2001 17:33:18 -0700 Subject: Examples\pde build problem, SWIG with NT and VC++ References: Message-ID: I eventually found the answer in swig.org's archives. For the curious: Removing extern "C" is correct, but don't edit the wrapper: Patch python.swg and pyexp.swg so that #include "python.h" is above extern "C". mike_haspert at credence.com (Mike Haspert) wrote in message news:... > I am new to Python and SWIG. I managed to build the pde example in the SWIG > doc using VC++6.0, Python2.1, and SWIG1.1, but only after commenting out > extern "C" around #include python.h. in pde_wrap.cpp (and changing the extension > of the output file from .c to .cpp). Everything seems to work but I am not confident > I've done the right thing and suspect that I'm doing a newbie thing like using/not using > some option incorrectly. > > Should I expect the wrapper file to need tweaks or not? > Has anyone working with SWIG and VC++ built this example? > If so, did you hit this problem, and do you have a better idea than tweaking the > wrapper? > > Thanks in advance for any help. > -mlh From robin at jessikat.fsnet.co.uk Thu Jun 14 19:18:38 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 15 Jun 2001 00:18:38 +0100 Subject: idle BUG References: Message-ID: In article , John Roth writes > >"Robin Becker" wrote in message >news:pkvruLAg7QK7Ewi3 at jessikat.fsnet.co.uk... >> I think this must be a bug in Tkinter, but since no one ever responds I >> thought I'd whine about idle instead. >> >> I run python2.1 Win95 OSR2. >> Start a command window >> run python idle.py > >It also happens when you try to execute from the DOS command >line. that's what I mean by command window (a dos box). >> Kill the idle window using the mouse (click on the x). In some unknown >> percentage of cases (like 50%) the process hangs and doesn't return to >> the command window. > >It may be connected with exception handling. My purely subjective impression >is that I get it irregularly when there has been an exception, and seldom >(or never) >if there hasn't been one. > well in my testing I take idle as the canonical Tkinter app as the MDFL supports it so well. I start idle and then kill it using the x close button. Certainly there may be exceptions in the code that aren't reported, but certainly in this test I don't cause them since idle is started and stopped. >I also hadn't related it to the close button as opposed to the File|Exit >command. >I think that's a significant fact, since they have two very, and I mean >very, different >processing paths. not really, the event is mapped to the root destroy somehow. Certainly different widgets etc are involved. I've just explicitly hit the File.exit and now have a hung dos box. > >> The hung process is very destructive and makes it impossible to reboot >> the machine properly. This bug has been present for a very long time and >> I'm fed up with it. > >I get rid of the command line with the three fingered salute >(CTL-ALT-DELETE). >Sometimes (not always) this causes Windows to hang on shutdown. Then it goes >through a disk check on startup. > >> It's clearly some kind of race between python and Tcl/Tk. The problem >> doesn't occur on win2k so I guess there's some difference between the >> run times that helps. > >Technically, it can't be a "race" condition, since there is only one process >(or not so, Tcl/Tk has an event window TclNotifier that is listening for events. As we know that Tcl can do asynchronous stuff (eg after) it's fairly obvious that races can and do occur even when python isn't threading. >thread). I suspect the difference is that Win 9x and Win 2k may post events >in different orders, thus causing the confusion. They are, after all, >completely >different code bases, and Win 2K doesn't have the global lock that Win 9x >has when it's accessing legacy 16bit functionality. > >> similar apps in pure tcl/tk don't show this behaviour although it's >> possible to make them do stupid things. > >I remember running across a patch somewhere reasonably official to the >Tk event handling kernel to allow Python to get a somewhat different set of >conditions on waiting for events. Since I know nothing about the issues, it >went >in the eyeball and promptly migrated to random access memory, where it >lost any association with a URL. > >Wish I could help more, but I'm not a windows developer, so I am very shakey >on using the developer tools, like event traces. I'd like it fixed, but it's >going to have >to wait on someone who knows low level Windows development. > ... I remember trying to do this once before. I found where the hang was happening, but couldn't find how it occurred. I don't have the experience really to figure out the bad event sequence. -- Robin Becker From claird at starbase.neosoft.com Mon Jun 18 11:15:29 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 18 Jun 2001 10:15:29 -0500 Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? References: Message-ID: <89D114BF3BD225D5.E9FA3807B7B9343E.0E60F30E3177AFDB@lp.airnews.net> In article , Roman Suzi wrote: . . . >I still remember HyperCard with warm feelings. It had very comfortable >look&feel both from developer's and user's perspective. Every object had >it's own script, which contained event handlers. Events were forwarded >automatically from contained objects to containers and if not handled, >Hypercard was the last who intercepted them. (Much like exceptions). > >Very nice scheme, which allowed to concentrate on the GUI and application >logic, and not on the message propagation details. > >What I wanted to say, is that GUI programming is really easy when tools >are like HyperCard: conceptually simple and powerful. Because all that >complication comes from not hiding unnecessary details. Tk is like >Assembly of GUI, while higher level is needed. > >After HyperCard (and SuperCard, HyperStudio to some extent) I have not >seen anything near the quality and simplicity, unfortunately... Well, >probably Squeak (sp?) is near, but it is thing in itself. . . . Do you realize a modernized HyperCard is still commercially supported ? -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From cfelling at iae.nl Thu Jun 14 11:37:03 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 14 Jun 2001 17:37:03 +0200 Subject: base converter References: Message-ID: <9galmv$3bv$1@animus.fel.iae.nl> Jeroen Wolff wrote: ... > Me it is to convert an ip addresses like (192.168.2.1/24) into a 32 > bits integer. Also the mask i wil convert to a 32 bit interger. Via > converting the 4 octets into its binary representation. Put all the 32 > bits in a string and convert it to a interger. After that i can do an > AND between these two integers and calucate the network part of it. ... > Maybe i'm on the wrong track to solve my problem..... you might try: import operator address, mask = "192.168.2.1/24".split("/") mask = 2 ** long(mask) - 1 octets = [long(x) for x in address.split(".")] shifted_octets = [octet << shift for (octet,shift) in zip(octets, [24,16,8,0])] address = reduce(operator.add, shifted_octets) -- groetjes, carel From ullrich at math.okstate.edu Sun Jun 3 11:39:39 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 03 Jun 2001 15:39:39 GMT Subject: Obsolesence of <> References: <3B17787F.266644CB@student.gu.edu.au> <3B1707A3.86AB1789@artenumerica.com> <3B17E8B3.F64581DE@artenumerica.com> <3B17FE8E.EFDF95F2@san.rr.com> <3B182360.1C6362FB@artenumerica.com> <89lS6.123310$eK2.28576139@news4.rdc1.on.home.com> Message-ID: <3b1a5905.3681821@nntp.sprynet.com> On Sun, 03 Jun 2001 06:52:52 GMT, "Nick Perkins" wrote: >In defense of Jose, i think he was trying to provide >a 'total order relation' on the complex numbers, >whereas the 'simple' method is a 'partial order relation'. > >The difference would be that in a total order relation, >no two different complexes would map to the same real, >so no two different complexes would compare as 'equal'. > >I am not sure is Jose succeeds, or if that is even possible. >I seem to remember that it is possible,...i think... It's certainly possible to define a total order on the complex numbers, for example by comparing tuples lexicographically (as I gather was suggested). What's not possible is to define a total order on the complexes that will make the complexes into what's called an "ordered field" - that's a field with an order (so far ok) with certain compatibility requirements between the field structure and the order. >Personally, i would compare complex numbers by their >distance to the origin ( in the 2D complex plane ). >This could be optimized by directly comparing the >sum of sqaures of the real and imag parts, without >bothering to do the sqrt to find the actual distance >to the origin. But _this_ does not define a total order on the complexes because different complexes do compare the same. David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From e9525429 at fbma.tuwien.ac.at Tue Jun 26 03:28:13 2001 From: e9525429 at fbma.tuwien.ac.at (Christoph) Date: Tue, 26 Jun 2001 08:28:13 +0100 Subject: python as plugin language Message-ID: <993529827.54981@newsmaster-04.atnet.at> newbie warning ;-) could someone please enlighten me! I want to embed python in my app as a scripting language... I have succeeded in extending python via swig. Not what I want, because main() has to come from my c-app. Then i can embed python in a c program with things #include "Python.h" and Py_Initialize(), etc. but that is still not what i want, because i have no idea how I can call C-Funktions with this approach... clear what i mean? I fear not... >From my app I want to load a plugin (a python script) and from this script I want to access functions of my app. Some pointers would be _very_ welcome!! From trclark at home.com Thu Jun 21 02:06:57 2001 From: trclark at home.com (TC) Date: Thu, 21 Jun 2001 06:06:57 GMT Subject: JSP vs Python any takers Message-ID: <5agY6.517092$166.10724721@news1.rdc1.bc.home.com> Hi ALL 1) If you have python script does the python interpreter have to recompile the code every time it is executed from a WEB page, can it be compile once like java can on a JSP page 2) On a linux apache box is there a python add-in that allows phython script to be used to create dynamic pages like you can when you use python script on an M$ IIS web server 3) Pound for pound how does a JSP app scale vs a python WEB app why would I use python over JSP From guido at python.org Thu Jun 21 22:24:08 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 22 Jun 2001 02:24:08 GMT Subject: PEP 255: Simple Generators References: <20010621083153.A19734@glacier.fnational.com> Message-ID: Neil Schemenauer writes: > Glyph Lefkowitz wrote: > > Stackless is problematic, but I think that an implementation > > similiar to that of generators could give us microthreads. > > When I get back from vacation I'll write up a PEP; if you'd > > like to give me a hand, feel free to drop me an email :) > > This would indeed be great news. I've spent quite a bit of time > thinking about this and the stackless approach is best solution I > can think of. As Neil said. This would be great news! PEP 255 doesn't solve your problems, it was never intended to -- but if you have an idea how we *can* solve your problem, YOU are the one to write it up! --Guido van Rossum (home page: http://www.python.org/~guido/) From s713221 at student.gu.edu.au Sat Jun 23 20:45:43 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Sun, 24 Jun 2001 10:45:43 +1000 Subject: How to install python on clean RH7.1 install References: <3b313462.13451051@news1.on.sympatico.ca> <3B33F025.D275AAB1@student.gu.edu.au> <3b35170a.268083173@news1.on.sympatico.ca> Message-ID: <3B353837.6A68A329@student.gu.edu.au> Ken wrote: > Thanks for your response. I'm going to give up on the idea of > replacing 1.5 for now... in the effort to get 2.1-5 up. > > I'm still stuck. I already have the rpm openssl (and its development > library) installed, and the rpm install for python still claims that > it's failing dependencies for the files in question. Here is a > snippet of the RPM install, using -vv > > ----------------------- > # rpm -i -vv python2-2.1-5.i386.rpm > ... > D: Requires: libutil.so.1 YES (db > provides) > D: opening db index /var/lib/rpm/Name create mode=0x42 > D: Requires: libcrypto.so.0.9.6 NO > D: package python2-2.1-5 require not satisfied: libcrypto.so.0.9.6 > D: Requires: libcrypt.so.1 YES (db > provides) > ... > D: Requires: libreadline.so.4.1 YES (db > provides) > D: Requires: libssl.so.0.9.6 NO > D: package python2-2.1-5 require not satisfied: libssl.so.0.9.6 > ... > D: opening db index /var/lib/rpm/Conflictname create mode=0x42 > error: failed dependencies: > libcrypto.so.0.9.6 is needed by python2-2.1-5 > libssl.so.0.9.6 is needed by python2-2.1-5 > D: ========== recording tsort relations > D: ========== tsorting packages > D: 0 (1,1) python2-2.1-5 > D: ========== successors only (presentation order) > D: closed db index /var/lib/rpm/Depends > D: closed db index /var/lib/rpm/Conflictname > D: closed db index /var/lib/rpm/Providename > D: closed db index /var/lib/rpm/Basenames > D: closed db index /var/lib/rpm/Name > D: closed db index /var/lib/rpm/Packages > > ------------- > > You can see that it failed the dependencies for the files > libcrypto.so.0.9.6, and libssl.so.0.9.6. > > Just in case I was losing it, I checked for the RPMs the files would > be in by running: > > # rpm -qf /usr/lib/libssl.so.0.9.6 > openssl-0.9.6-3 > # rpm -qf /usr/lib/libcrypto.so.0.9.6 > openssl-0.9.6-3 > > ... which I'm assuming is telling me what RPMs the files exist in. To > double check, I ran the following: > > # rpm -q openssl > openssl-0.9.6-3 > > ... and verifying the openssl package gave me: > > #rpm -V openssl > > .. (nothing) - which I'm assuming means everything is well. > > Please advise! > > Thanks, > > kc *totally bewildered* Um. Have you checked to see if the libraries are on your file system using ls? I'm suspecting that they would be. If they are, it must be something to do with the dynamic loader, ld, but I've never had to play with that seriously. If you get REALLY desperate, you could always grab the source rpm and build using rpm --rebuild python*src.rpm; rpm -U /usr/src/RPM/RPMS/i386/python*rpm. -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From slhath at home.com Fri Jun 1 18:53:26 2001 From: slhath at home.com (Scott Hathaway) Date: Fri, 01 Jun 2001 22:53:26 GMT Subject: php alternatives in python References: Message-ID: Thanks for the help! Scott "Geoff Talvola" wrote in message news:mailman.991323356.25762.python-list at python.org... > At 01:56 PM 5/31/01 +0000, Scott Hathaway wrote: > > >I am just researching. Here is my problem. My company writes all of our > >api's (engines) with Python (when cross-platform is needed) or VB (when COM > >is needed). Then, we use PHP for any web work. So, when I try to replace a > >programmer or hire a new one, I have to find someone who is versed in PHP, > >Python, and VB. This is not an easy task. It would really help if I could > >narrow things down to one language. > > > >Python could easily replace the COM needs that we gain from VB, but we do > >not have anyone in our office who can create a GUI in Python as easily or > >effectively as with VB. I hope that Python.NET will change that. So, if I > >can replace PHP with Python, we could do all of our development in one > >language. > > > >I have looked at Zope, but it seems more like Cold Fusion than ASP or PHP. > >I really want something like ASP or PHP, if possible. > > > >Thanks, > >Scott > > Webware lets you use either Servlets (Python classes) or PSPs (Python > Server Pages -- Python embedded in HTML, just like ASP and PHP). I > actually use a mixture of both -- I have some pages as Servlets, and some > as PSP's inherited from Servlets. But you could certainly design a whole > site just using PSPs. > > As far as stability and speed go, Webware seems very fast (if you deploy > using Apache and the special Apache Webware module) and stable, but since > I've never used PHP I have no idea how it compares. > > For your GUI needs, I like wxPython using the commercial tool wxDesigner to > assist with the layout. Once you get used to the way wxDesigner lays out > GUIs using sizers, you'll never want to go back to doing it the VB > way... Admittedly, it will be a hard sell for people who have been using > VB for a long time, and there is a bit of a learning curve in learning > wxPython. But Python is so much nicer as a language than VB that I'm > willing to put up with a somewhat more cumbersome GUI-building process to > be able to write all the code in Python. > > > -- > > - Geoff Talvola > gtalvola at NameConnector.com > From tdelaney at avaya.com Sun Jun 17 22:51:04 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Mon, 18 Jun 2001 12:51:04 +1000 Subject: New statement proposal for Python Message-ID: [Lots of stuff snipped from people, primarily Alex and Dave] I'm having a lot of trouble with this proposal. I believe I am against parts of it in principal, but am heavily in favour of the basic idea behind it (which I have expressed before). 1. I am heavily against the use of the "alias:" syntax. However, I will use the "alias" terminology here. 2. I am unclear about what is actually being proposed. I have seen conflicting statements by Dave, so wish to clear it up. Please choose one of the following. a. An alias would perform a textual substitution before the code is compiled (as in a C #define). b. An alias would be evaluated where it is assigned/created, and thereafter its value would be constant. c. An alias would be evaluated using the local namespace each time it is encountered, and the result used in the expression. In my mind, (b) is a constant, and (c) is an alias. (a) should not even be considered. The root of the problem which I believe people are trying to solve is making things provably constant. There are two things involved here: 1. Preventing a reference from being rebound. 2. Preventing a mutable instance from being modified. Both of these are almost completely doable now. 1. Preventing a reference from being rebound: As Alex has posted, and I agree, replacing a module with a restricted __setattr__() does most of what we wish here. A perhaps better option though would be to have a builtin object called "const". This has a few advantages, and 1 disadvantage: a. There is no need to "import const" (advantage). b. It does not interfere with a module named "const" created by someone else - local namespace takes precedence over builtin (advantage). c. The __builtin__.__dict['const'] object could be replaced by something else (normally a disadvantage). This could be changed by making __builtin__.__dict__ not actually be a dictionary, but a class instance which disallows rebinding certain references (such as "const"). 2. Preventing a mutable instance from being modified This could be done for class instances by an immutable() builtin function. This function would change the __setattr__() function of the instance to one which raises an Exception, and nothing else. a. This would only work for class instances - not classes or types. With the type/class difference going away, it comes down to only class objects having problems with this. Until this difference goes away, lists could be converted to tuples by immutable(), but dictionaries remain a problem. b. Someone could get around the immutable() function by replacing the __setattr__() method after it is called. Tim Delaney From root at rainerdeyke.com Tue Jun 19 14:30:17 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Tue, 19 Jun 2001 18:30:17 GMT Subject: PEP 255: Simple Generators References: <9glhg7$dlk$1@nntp6.u.washington.edu> <4DLX6.320220$oc7.29444949@news2.rdc2.tx.home.com> Message-ID: "Neil Schemenauer" wrote in message news:mailman.992973455.16313.python-list at python.org... > Rainer Deyke wrote: > > def f(): > > return > > yield 'Never reached.' > > > > > > Is this function a generator? Yes, but only if nobody removes the seemingly > > redundant 'yield' statement. > > def f(): > return x > x = 1 > > Is "x" a local variable? Most of your arguments apply to local > variables as well. Not really. Using a local variable before it is assigned is just plain wrong, whereas returning an empty iterator from a generator is likely to become a common idiom. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From gerhard.nospam at bigfoot.de Mon Jun 25 05:38:42 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Mon, 25 Jun 2001 11:38:42 +0200 Subject: installing MySQLdb with Python 2.1 References: <3b36a319.369414049@news1.on.sympatico.ca> Message-ID: On Mon, 25 Jun 2001 02:35:35 GMT, Ken wrote: >Hi, > >I'm trying to install MySQLdb for use with Python 2.1, on a RH 7.1 >system. Unfortunately, I succeeded using the RPM, and it embedded it >into the Python 1.5.2 release (and not the 2.1). How would I get this >to work with 2.1? (ie. when I type "import MySQLdb" in python2, there >is an error...). Hopefully this will work: - get the source distribution of MySQLdb - use "python2 setup.py build" to build it and - "python2 setup.py install" to install it. You can make RPMs with "python2 setup.py bdist_rpm". Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://highqualdev.com public key at homepage public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From senux at senux.com.NOSPAM Wed Jun 20 21:13:26 2001 From: senux at senux.com.NOSPAM (Brian Lee) Date: Thu, 21 Jun 2001 01:13:26 GMT Subject: How to install python on clean RH7.1 install References: <3b313462.13451051@news1.on.sympatico.ca> Message-ID: <3B314A85.3000807@senux.com.NOSPAM> Ken wrote: >Hi, > >I'm trying to install Python 2.1-5 onto a newly installed RH7.1. The >RH install was done pretty cleanly, so not a lot of the RPMs have been >installed (I've installed some along the way, as dependencies came >up). > >My quesions are these: > >1). Is it possible to "upgrade" the python 1.5.2 that is installed >with RH7.1? (I couldn't easily avoid installing it - because it was a >dependency for a lot of packages. That said, I cannot easily >uninstall the RPM for 1.5.2). > Yes, there are may RPM packages which requires Python. So it's not easy to unstall Python on RedHat Linux system. >2). If not, what way is more or less a fail-safe way of installing >python into a new directory. I have tried the following already: > >- installing from the src.rpm file -- the installer stopped short of >creating the RPM file... something about it not finding a lot of files >(that it was to have compiled). It made it through the check, and did >about 5 minutes of compiling, then stopped. > >- installing from the rpm file. The dependencies failed were >libcrypto, and libssl -- but I have NO idea where to find these >(preferrably RPMs). > # rpm -qf /usr/lib/libcrypto.a openssl-devel-0.9.6-3 Try to install Python again after installing openssl* packages. I think it was failed to build new rpm file fro *.src.rpm because the lib files are not exist. Good luck! >Any ideas would be greatly appreciated! > >Kc > - Brian,. From msoulier at storm.ca Mon Jun 4 23:28:54 2001 From: msoulier at storm.ca (Michael P. Soulier) Date: Tue, 05 Jun 2001 03:28:54 GMT Subject: floating point in 2.0 Message-ID: Greetings people. My apologies if this has been covered. In Python 1.5.2, I could do this: good = (0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0) I could then get back exactly this when I output the value of "good". However, with Python 2.0, I get this: >>> good (0.0, 0.10000000000000001, 0.20000000000000001, 0.29999999999999999, 0.40000000000000002, 0.5, 0.59999999999999998, 0.69999999999999996, 0.80000000000000004, 0.90000000000000002, 1.0) Now, I'm assuming that this has something to do with the way that Python 2.0 stores floating-point numbers, but this could get confusing during debugging. Could someone explain this behaviour? Much appreciated and cheers, Mike -- Michael P. Soulier "With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead." -- RFC 1925 From bsass at freenet.edmonton.ab.ca Fri Jun 29 15:42:44 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Fri, 29 Jun 2001 13:42:44 -0600 (MDT) Subject: Augmented Assignement (was: Re: PEP scepticism) In-Reply-To: <6qels376dj.fsf@abnoba.intevation.de> References: <6qn16r7i69.fsf@abnoba.intevation.de> <6qels376dj.fsf@abnoba.intevation.de> Message-ID: On 29 Jun 2001, Bernhard Herzog wrote: > "Steve Holden" writes: > > I suppose that depends. Given the following initialization code: > > > > lst = [1, 2, 3] > > tpl = (1, 2, 3) > > lstx = lst > > tplx = tpl > > > > would you expect the same results from > > > > lst += ["extra"] > > tpl += ("extra", ) > > Well, this could modify lst and/or tpl in place ... > > > > > and > > > > lst = lst + ["extra"] > > tpl = tpl + ("extra", ) > > ... while this usually creates new objects and doesn't modify either lst > or tpl (unless they implement __add__ in an unsual way). > > > to be the same? yes > So, I wouldn't expect them to behave in the same way. > OTOH, consider the statement > > x += (1,2,3) > > Does that modify x in place? This works regardless of whether x is a > tuple or a list, but if x is a list x is modified in place while if it's > a tuple it isn't. (interestingly enough x += [1,2,3] gives a TypeError > if x is a tuple.) It would be nice if this was "fixed"... lists and tuples should behave the same (well, except for that mutability thing). It doesn't bother me at all that implicit mutability mutating would be going on, the ability to use tuples as "locked" versions of lists sounds too appealing. > One consequence for me is that I'll very careful with augmented > assignments. It seems to me the only situation in which their use should > be considered is when it's OK to modify the object on the LHS in place > (which is basically what the pep says, too). How about _if_ lists and tuples differed only in their mutability; concatenating, extending, appending, slices and indexing would become ways to lock and unlock subsets of the sequence. I don't do enough programming to know just how useful this would be, the symmetry is nice but maybe it would be too much work for too little gain. - Bruce From jeremy.silver at synchrologic.com Wed Jun 20 17:47:27 2001 From: jeremy.silver at synchrologic.com (Jeremy Silver) Date: 20 Jun 2001 14:47:27 -0700 Subject: WinCERAPI extension Message-ID: <728a73c6.0106201347.63e3f3c6@posting.google.com> Hi, I was wondering if anyone could tell me how to get or build the "wincerapi" extension for Python 2.1. I have all of the CE SDKs on my machine, but I can't seem to figure out a way to get the wincerapi extension. Any help would be greatly appreciated! Thanks, Jeremy Silver From steffen.ries at sympatico.ca Fri Jun 29 08:12:55 2001 From: steffen.ries at sympatico.ca (Steffen Ries) Date: 29 Jun 2001 08:12:55 -0400 Subject: list of lists, object doesn't support item assignment? References: Message-ID: Manfred Bartz writes: > >>> xy = (1,2),(2,2) > >>> print xy, xy[0] > ((1, 2), (2, 2)) (1, 2) > >>> xy[1]=(3,4) > TypeError: object doesn't support item assignment > > Is there a way to assign the list (3,4) to an element of xy? > What am I missing? You are using tuples instead of lists. Tuples are immutable, i.e. you can't assign new elements to an existing one. To use lists do the following: xy = [[1,2], [2,2]] xy[1] = [3,4] print xy xy[1][0] = 5 print xy /steffen -- steffen.ries at sympatico.ca <> Gravity is a myth -- the Earth sucks! From roman at speeder.org Sun Jun 17 23:16:41 2001 From: roman at speeder.org (Roman Milner) Date: 17 Jun 2001 22:16:41 -0500 Subject: forcing python to build a static libpython2.1.a References: Message-ID: <878ziqjx46.fsf@speeder.org> >>>>> "MH" == Michael Hudson writes: MH> Roman Milner writes: >> Is there an easy way to have the build process disable dynamic >> loading? I just want a plain old static libpython2.1.a. >> MH> I think the most efficuient way to do what you want is to MH> uncomment the modules you want to build statically in MH> Modules/Setup. Read the comments in the top of MH> Modules/Setup.dist in the source distribution for more info. That doesn't seem to achieve what I want. What you suggest will build the chosen modules statically into the python executable binary. What I need is a static libpython2.1.a that I can link against other things. ^Roman From nperkins7 at home.com Thu Jun 14 22:57:23 2001 From: nperkins7 at home.com (Nick Perkins) Date: Fri, 15 Jun 2001 02:57:23 GMT Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> Message-ID: "David LeBlanc" wrote in message news:9gbsdv$8ft$9 at 216.39.170.247... > alias true: 1 ... >...read so nicely to be able to say "if something is true" it's even easier than that: if something: ... ..which can 'read' just as well, if you choose your names accordingly. ..but on a more general note, am i to understand that you are suggesting C-style macros, where code is 'physically substituted', before being run? That would be a Bad Thing, i think. C was a nice little language before it turned into a giant mess of macro substitutions. From greg at cosc.canterbury.ac.nz Thu Jun 7 22:15:09 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 08 Jun 2001 14:15:09 +1200 Subject: Why no 'elif' in try/except? References: <3B1A06EE.F484930A@snakefarm.org> <3B1A29DE.9876770D@accessforall.nl> <9fgiip$h48$1@neon.noos.net> Message-ID: <3B20352D.19EB25CD@cosc.canterbury.ac.nz> Marcin 'Qrczak' Kowalczyk wrote: > > 'else if' would mean exactly what 'elif' means today - it's still > a special rule, but not an additional keyword. Yes, it's unambiguous, although I'm not sure what the implications would be for the parser the way it currently works. Maybe I'll try to implement it one day and find out! If there isn't any difficulty, my guess is that Guido simply didn't think of it at the time (or when he did think of it, the time machine was away for repairs). -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From threeseas at earthlink.net Mon Jun 18 21:47:27 2001 From: threeseas at earthlink.net (Timothy Rue) Date: Tue, 19 Jun 2001 01:47:27 GMT Subject: NOW v0.35 !!! >Re: Python version of IQ has been updates (IQ v0.34.python) References: <3B2A7F5E.MD-1.4.4.padf@ihug.com.nz> <3871.567T2214T9794928threeseas@earthlink.net> <87puc3ao42.fsf@pooh.honeypot> <2509.568T2823T9766233threeseas@earthlink.net> <9gkftm026v9@enews2.newsguy.com> Message-ID: <2426.569T1447T13014525threeseas@earthlink.net> On 18-Jun-01 03:59:32 Alex Martelli wrote: >"Timothy Rue" wrote in message >news:2509.568T2823T9766233threeseas at earthlink.net... >> ......... it'd be nice to incorporate into IQ, the ability to >> access files thru the internet in a way that is as simple as accessing >> a file on the system you are using IQ on. >If you use Python, that's trivial -- just open the URL string with >urllib.urlopen, exactly like you would open a filepath string with >the builtin function open, and you'll get a file(-like) object ready >for reading through all the usual fileobject methods (.read, readline, >etc etc). If the URL is actually a filepath, urllib.urlopen just >delegates the work to the built-in open, so you can also choose to >ALWAYS use urllib.urlopen (when you're opening for _reading_, of >course -- if you open for *writing*, it's different:-) and it just >works. Not sure what the other scripting languages offer for this. Cool! Ok I tried it by changing all "open()" to urllib.urlopen() and of course adding "urllib" to the import line. But no go.... Actually this message is greatly edited and I do have it working and a new version 0.35 posted to: http://home.mindspring.com/~timrue/python/python-IQ.html I am just reading files so there is no problem with needing to write. In the process...I know my script uses the tell and seek methods, but I am also already keeping track of how many lines have been read (which can replace tell) and can do a readline loop to replace seek. (EVENTUALLY I was going to have to do this anyway but was using tell and seek because it's faster or at least was in the case of Arexx) For the test I'm using the KNMVIC.iq file because it has tagged in it a valid url (as a file to look thru): http://www.mindspring.com/~timrue/IQ-1-9-1999.html That really was extreamly simple in getting Internet file access going!!! Of course I had a few other things to clean up or change in the process, but it's DONE!!! Thank Alex and those on the python IRC channel. --- *3 S.E.A.S - Virtual Interaction Configuration (VIC) - VISION OF VISIONS!* *~ ~ ~ Advancing How we Perceive and Use the Tool of Computers!* Timothy Rue What's *DONE* in all we do? *AI PK OI IP OP SF IQ ID KE* Email @ mailto:timrue at mindspring.com >INPUT->(Processing)->OUTPUT>v Web @ http://www.mindspring.com/~timrue/ ^<--------<----9----<--------< From aahz at panix.com Thu Jun 7 16:13:16 2001 From: aahz at panix.com (Aahz Maruch) Date: 7 Jun 2001 13:13:16 -0700 Subject: Task isolation in Python? References: Message-ID: <9fon8s$mek$1@panix6.panix.com> In article , Adrian Solis wrote: > >I'm thinking that if I spawn new processes and kill misbehaving ones, I'll >be able to mostly acheive this goal, but Python's process control under >Win2k is lacking. Even with the Win32 extensions? -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "NRE is a lot like cocaine. Feels great while you're on it, makes you feel very special and talented, and you become highly annoying to those who aren't on it." --Stef From bkc at Murkworks.com Thu Jun 28 13:31:50 2001 From: bkc at Murkworks.com (Brad Clements) Date: Thu, 28 Jun 2001 13:31:50 -0400 Subject: Python for pocket pc? References: Message-ID: <3b3b6d19$1_5@goliath.newsgroups.com> I'm working on the iPaq port, should be ready to try pretty soon. Get on the python-ce mailing list to be notified. -- Brad Clements, DevNet Sysop 5 Developer Network Sysop Team "Bill Walker" wrote in message news:tji0c1ghg0pm45 at corp.supernews.com... > Has anyone ported python to the Pocket PC? The Windows CE version on the > Python page does NOT work, wont install -- wrong processor I think. > > > > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From no-spam at hotmail.com Sun Jun 3 15:23:46 2001 From: no-spam at hotmail.com (DJ) Date: Sun, 3 Jun 2001 12:23:46 -0700 Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> <3B1A5D10.A7139942@iinet.net.au> Message-ID: <9fe2n0$1kar$1@nntp1.ba.best.com> ANother good book (meaning, not so thick) is "UML DIstilled" by Fowler. You can get a good feel for UML, and also catch some cross currents, in < 200 pages. The UML User Guide is nice too, but you get a lot of "sell" from the originators; and the text is verbose, making one wonder if the authors ever heard of Strunk & White. UML and Python ? Hmm, probably more like Perl and VBScript... Python is for people who want their code to be reused ;) -D John Bell wrote in message news:3B1A5D10.A7139942 at iinet.net.au... > Hi Frank, > > I've used a couple of formal methodologies in my time and am just getting into > UML. The book that I'm reading is by the authors of UML: "The Unified > Modeling Language User Guide" Grady Booch, James Rumbaugh and Ivor Jacobsen; > Addison Wesley Longman; ISBN 0-201-57168-4. This is a decent starting point. > They also do a UML Reference Manual (ISBN 0-201-30998-X) which I haven't > bought. They're both part of a HUGE series (about 60 books) by AWL on the > topic. > > An important point is that UML is only part of the overall methodology they > recommend. All three authors work for Rational Software (the people who make > Rational Rose, the leading commercial UML product) who recomend an approach > documented in "The Unified Software Development Process" (Same authors ISBN > 0-201-57169-2) which I also haven't read. > > If you're interrested in Software then I know of the following that's not in > the commercial arena: > > * I read the other day that the new version of dia (0.88.1) to some degree > supports UML for Python specifically! I downloaded it yesterday (from > Sourceforge I think) but haven't looked at it yet. > > * There are a couple of Python specific UML projects underway on sourceforge > but they seem to be pre-alpha. > > * When I bought the Workstation Deluxe version of Redhat 7.0 there was some S/W > called metaedit+ included that is a major league UML kit. See > www.metacase.com. Note that this was 7.0. I haven't got my 7.1 set yet and > don't know if it's included. > > The key site to look at (if you haven't already) is www.omg.com (click on the > UML icon. > > As I said I'm pretty early in the process of looking at all this. I've gone > through the tutorial that comes with Metaedit+ and I'm about half way through > the UML User Guide. My first impressions are that this is a GOOD THING. I > gave up seat of the pants programming when I left uni but have found my normal > methodologies don't work so well with Python. I'm always retrofitting classes > rather than designing from a class based approach. This often leads to massive > rewrites that are wasteful. Luckily my Python work is for my own business > rather than for a customer! I'm hopeful that UML will lead to me writing > better Python the first time. > > John > > Frank Millman wrote: > > > After 15 years of designing applications using the good old "seat of the > > pants" method, I have decided that, if I am to move forward, I need a more > > formal methodology. > > > > I have recently read about UML (Unified Modelling Language), a > > standards-based method of designing and documenting any software project. It > > looks interesting, but it seems to have a steep learning curve. > > > > Does anyone have any knowledge or experience of UML that they would like to > > share? > > > > TIA > > > > Frank Millman > > -- > > Regards, > John Bell > > > From dsh8290 at rit.edu Tue Jun 26 19:18:33 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 26 Jun 2001 19:18:33 -0400 Subject: PEP 260: simplify xrange() In-Reply-To: ; from rnd@onego.ru on Tue, Jun 26, 2001 at 11:51:12PM +0400 References: <20010626153909.A16590@harmony.cs.rit.edu> Message-ID: <20010626191832.B16690@harmony.cs.rit.edu> On Tue, Jun 26, 2001 at 11:51:12PM +0400, Roman Suzi wrote: | | And also I think "x in xrange(...)" and | "x not in xrange(...)" should not be dropped, | because it is very near to | | for x in xrange(...) | | and has interesting use as in: | | if n in xrange(1, 101, 2): # odd number from [1, 100] | ... Cute, but how about (for this particular example) if 1 <= n <= 101 and n % 2 == 1 : ... or def odd_in_range( n , lower , upper : return 1 <= n <= 101 and n % 2 == 1 if odd_in_range( n , 1 , 101 ) In fact, prior to the PEP, I didn't know that xrange() could be used anywhere except a for loop. I hadn't tried, nor had I read the docs ;-). -D From mal at lemburg.com Mon Jun 11 16:55:13 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Mon, 11 Jun 2001 22:55:13 +0200 Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: <200106112007.f5BK7eW22506@odiug.digicool.com> Message-ID: <3B253031.AB1954CB@lemburg.com> Guido van Rossum wrote: > > Please comment on the following. This came up a while ago in > python-dev and I decided to follow through. I'm making this a PEP > because of the risk of breaking code (which everybody on Python-dev > seemed to think was acceptable). > > --Guido van Rossum (home page: http://www.python.org/~guido/) > > PEP: 259 > Title: Omit printing newline after newline > ... > Scope > > This only affects printing of 8-bit strings. It doesn't affect > Unicode, although that could be considered a bug in the Unicode > implementation. It doesn't affect other objects whose string > representation happens to end in a newline character. I guess I should fix the Unicode stuff ;-) > Risks > > This change breaks some existing code. For example: > > print "Subject: PEP 259\n" > print message_body > > In current Python, this produces a blank line separating the > subject from the message body; with the proposed change, the body > begins immediately below the subject. This is not very robust > code anyway; it is better written as > > print "Subject: PEP 259" > print > print message_body > > In the test suite, only test_StringIO (which explicitly tests for > this feature) breaks. Hmm, I think the above is a very typical idiom for RFC822 style content and used in CGI scripts a lot. I'm not sure whether this change is worth getting the CGI crowd upset... Wouldn't it make sense to only use this technique in inter- active mode ? -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From aahz at panix.com Wed Jun 13 13:27:38 2001 From: aahz at panix.com (Aahz Maruch) Date: 13 Jun 2001 10:27:38 -0700 Subject: BIG problem if readline strips newlines References: <9g5urc$hrl$1@panix6.panix.com> Message-ID: <9g87qa$8e4$1@panix6.panix.com> In article , Pete Shinners wrote: > >i guess there would just be a problem with the >while 1 idiom > > while 1: > line = file.readline(chomp=1) > if not line: break > >not as big a problem as i originally thought. not with >xreadlines and other new looping methods that get us >away from the while 1 standard Not even a problem at all, given that anyone using a Python with a chomp mode *has* to have xreadlines() (and probably iterators). -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Just because I'm selling you into slavery doesn't mean we can't be friends." B-movie cliche Hall of Fame (_Bounty Hunter: 2002_) From bedge at troikanetworks.com Fri Jun 29 12:40:21 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Fri, 29 Jun 2001 09:40:21 -0700 Subject: pdb name truncation Message-ID: <20010629.094021.1605894428.12508@troikanetworks.com> When I step into something wrong, pdb logs a message like this: (Pdb) n NameError: "global name ...s not defined" Is there some setting to get it to expand the ... It's annoying to have to restart not under pdb to see what error actually was. Thanks, Bruce. From laurent.pointal at wanadoo.fr Mon Jun 4 13:25:12 2001 From: laurent.pointal at wanadoo.fr (Laurent Pointal) Date: Mon, 04 Jun 2001 17:25:12 GMT Subject: Controlling CDR drives using Python in Windows References: Message-ID: gerhard.nospam at bigfoot.de (Gerhard H?ring) wrote in : >On Sat, 02 Jun 2001 22:04:03 -0300, Carlos Ribeiro wrote: >>I'm looking for information on how to control a CDR drive from Windows, >>using Python scripts, of course. I'm planning to automate my home >>backups using Python scripts. If someone has any information on how to >>make it work, I'll be glad to know. > >If you want to burn CDR on Windows, I think your best bet is to try to >get the command line tools cdrecord, mkisofs and friends to compile on >Windows. > >You could then use os.system or popen2 to control them. See GNU-Win32 project, AFAIR cdrecord has already been ported to Win32 platform. A+ Laurent. From aleaxit at yahoo.com Thu Jun 14 10:19:26 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 16:19:26 +0200 Subject: weird behavior wrapping global functions into classes References: <0cahit44sql68p8pd2qgt59f600neha687@4ax.com> Message-ID: <9gah5j02v9@enews1.newsguy.com> "Les Schaffer" wrote in message news:0cahit44sql68p8pd2qgt59f600neha687 at 4ax.com... > been losing sleep over this one... > > why does the following code successfully wrap the built-in open function > into a class, but shelve's open method gets incorrectly (??) taken as an > instance method? notice that everything works fine for the Flat version, Whenever a function is accessed as an attribute of a class or instance (and in the latter case, it's found in the class and not in the instance itself), it's transmuted into a method (unbound and bound, respectively). So, if you do need a callable to NOT have method behavior, wrap the function in a non-function callable; cfr., e.g.: http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/52304 for more discussion, but it boils down to: class Callable: def __init__(self, anycallable): self.thecallable = anycallable def __call__(self, *args, **kwds): return self.thecallable(*args, **kwds) and > class NumFlat(NumStorage): > mode = 'w' > DB = 'flat.txt' > #db = open(DB, mode) > dbopen=open change the last line into dbopen = Callable(open) Alex From tim.one at home.com Fri Jun 15 20:34:01 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 15 Jun 2001 20:34:01 -0400 Subject: call-by-reference (was Re: Any other Python flaws?) In-Reply-To: <9ge78p$pn4$1@nntp6.u.washington.edu> Message-ID: [Donn Cave] > ... > Python has "call by the one right way". I usually say Python does "call by object". Then people go "hmm, what's that?". If you say "call by XXX" instead, then the inevitable outcome is a tedious demonstration that it's not what *they* mean by XXX. Instead I get to hear impassioned arguments that "by object" is what any normal person means by YYY . BTW, I believe Barbara Liskov first coined "call by object" to describe argument-passing in CLU. which-was-also-the-one-right-way-ly y'rs - tim From fschaef at ces.clemson.edu Wed Jun 27 20:09:50 2001 From: fschaef at ces.clemson.edu (Schaefer, F.) Date: Wed, 27 Jun 2001 17:09:50 -0700 Subject: Centering a Tkinter Toplevel Message-ID: <3B3A75CE.DD40FF11@ces.clemson.edu> Hi, I was wondering how it could be possible to have a 'hello-screen' while the rest of the modules are loading. Unfortunately, I was to able to find out how to determine the WM-Screensize. Does anybody know how to do this in Tkinter ? Thanks -- ________________________________________________________________________ Frank Schaefer (Phone: 001-864-656-0482, FAX: 001-864-656-4435) R. 236, Fluor Daniel Building, Mech. Eng. Clemson University, SC 29634, USA From sholden at holdenweb.com Thu Jun 21 21:45:06 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 21 Jun 2001 21:45:06 -0400 Subject: Meta: PEP discussion (was Re: PEP 255: Simple Generators) References: Message-ID: <6oxY6.413$u4.8075@e420r-atl1.usenetserver.com> I seem to remember an Icon generator function would use suspend val to return val as the next value in the generator's sequence. The really nice part was that there were two loping constructs, one of which was explicitly used in a generative context, so you'd say (something like): i := every gen(x, y) where gen() was a generator. regards Steve -- http://www.holdenweb.com/ "Paul Prescod" wrote in message news:mailman.993092013.32732.python-list at python.org... > "Steven D. Majewski" wrote: > > > >... > > > > Also, as another former Icon-er, I tend to lean with Tim > > on the syntax issue. > > Did icon switch from eager evaluation of the function to lazy evaluation > based on the occurrence of a keyword somewhere in the function? > > -- > Take a recipe. Leave a recipe. > Python Cookbook! http://www.ActiveState.com/pythoncookbook > > From altis at semi-retired.com Tue Jun 19 17:01:35 2001 From: altis at semi-retired.com (Kevin Altis) Date: Tue, 19 Jun 2001 14:01:35 -0700 Subject: Re. PythonCard - was Re: Event-driven GUIs ... References: Message-ID: <73PX6.317$zE1.418988@news.uswest.net> I just had to chime in. I was a hardcore HyperCard (HC) developer at one time and built a variety of add-ons and stand-alone applications, including Organizer + (a PIM), my first commercial app. Anyway, Python is the closest I've come to the fun I had creating and exploring in HyperCard, but of course, Python "out-of-the-box" is much more capable at doing real-world tasks and interfacing to other components and applications. As others have said, what is missing is the tight coupling of a GUI environment. All of the current GUI solutions feel like work, compared to whipping up something in Visual Basic, Delphi, etc. Given that many people think MS has basically broken whatever simplicity VB had with the transition to VB .NET, there is actually a huge opportunity to woo VB developers over to Python if a commercial-quality Python GUI/IDE environment was available. I'm guessing that at some point, O'Reilly will probably catch a clue and write a "Python for VB programmers" book, but they haven't done a "Python for Perl programmers" book yet, so I may be wrong. Getting back to HyperCard. Remember that HC was closed and proprietary and the HC team tooks its sweet time in adding features. Color support was always a hack job and even though 2.0 added printing, menus and other UI elements that looked like what users expected on the Mac, it was difficult to impossible to actually create an HC app that had the Mac look and feel and operated the way a Mac user would expect. In Python terms, it is like trying to make a first-class app for Windows or the Mac using tk, you just can't do it, your app will always look like a tk app. The good news is that wxPython (and maybe other UI toolkits or DHTML/DOM) looks like it will fit the bill. HC was also difficult and error-prone to extend, Python is easy to extend. So, I'm in favor of a PythonCard environment as well as a set of modules that would ship with the standard distribution, to simplify running anything built in PythonCard. If enough people are interested, we could even form a SIG. It would probably benefit everyone to take a look at projects such as Sash http://sash.alphaworks.ibm.com/ and Squeak http://www.squeak.org/ to better define what people want and don't want. If you wanted to run arbitrary PythonCard code from the net, then you probably want to run the Python interpreter in some form of restricted mode, and/or require digital signatures to be associated with projects to reduce the risk of running viruses, trojans, etc. Right now, Python by default is wide open. ka "Spicklemire, Jerry" wrote in message news:mailman.992975010.18077.python-list at python.org... > Hi Roman, Neil, et. al., > > Neil suggested: > > "However, the market, which was given several HyperCard like products to > choose from, has decided against this form of development environment." > > to which Roman replied: > > "The market ways are unpredictable, because decisions are made not on the > basis of technical merits but with some strange reasoning behind." > > > Just my $.02 about "the market" where Open Source and FREE software > is concerned. There is actually something of a parallel universe > phenomenon at work, an inevitable side effect of the Web and it's > predecessors. Python is a great example of a tool that is virtually > invisible to "the market", but which has been thriving nonetheless. > Think Linux, prior to about 1997. > > As many Java and C++ refugees frequenting these lists can attest, > "the market" no longer has the last word. We're witnessing the > birth of a "paramarket". Python has risen on its merit entirely > independent of "conventional wisdom", "market forces", "public > relations", "strategic imperative", and other counterproductive > distractions. > > So, as for Python Card- Go For It! If HyperCard faded due to > "extenuating circumstances", perhaps a comeback is in order. > > Later, > Jerry S. > > > > > From root at rainerdeyke.com Mon Jun 18 22:25:18 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Tue, 19 Jun 2001 02:25:18 GMT Subject: nested classes References: <3B2E2D3A.75F329D@sympatico.ca> <9glchv$kcm$1@plutonium.compulink.co.uk> <3B2E4725.535AB18E@sympatico.ca> <3b2e8989.32036776@news.laplaza.org> Message-ID: "Mats Wichmann" wrote in message news:3b2e8989.32036776 at news.laplaza.org... > Java and C++ are compiled. The class definition is instructions to > the compiler, and can be self-referential, because the /reference/ is > not going to happen until the class is loaded - no inconsistency. Not > so for Python, the class definition is code that is actually run to > build the class object, and before that object has been built, there's > nothing to refer to yet, as Alex said. That's the way it is now, but it doesn't have to be that way. Consider modules. Circular references between modules work because the module object is created and added to 'sys.modules' before any code in the module is executed: # A.py: # Module 'A' already exists when the following line executes. import B # B.py: import A The same principle could be applied to classes, though that isn't necessarily a good idea. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From albert at lindeverlag.at Tue Jun 5 07:35:09 2001 From: albert at lindeverlag.at (Albert Brandl) Date: 5 Jun 2001 12:35:09 +0100 Subject: Vienna Python Interest Group Message-ID: <3b1cb5dd@e-post.inode.at> Hi! There exists a new PIGgie: The Vienna Python Interest Group, aka VPIGgie. We're a handful of people and would be happy if the group would grow. We have a mailing list at onelist: VPIGgie at onelist.com If you are located in Vienna and interested in Python, I'd invite you to join us. Please drop me a mail or join the list. Our next meeting will be centered about the Webware application server. Details will be sent to the list. Have fun, Albert Brandl From chrishbarker at home.net Mon Jun 4 17:12:53 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 04 Jun 2001 14:12:53 -0700 Subject: formatting numbers References: Message-ID: <3B1BF9D5.3A8C0937@home.net> > michael montagne wrote in message > news:e5SS6.69668$FS3.619704 at sjc-read.news.verio.net... > > value from the database it reads "49". I need to add the leading digits > if > > they are there so this number would read "00049". In MSAccess I used > > Format(num,"00000"). How can I do that with Python? try string.zfill >>> import string >>> string.zfill(49,5) '00049' >>> Question: is there a way to do this with string methods? -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From alf at leo.logilab.fr Wed Jun 27 03:52:17 2001 From: alf at leo.logilab.fr (Alexandre Fayolle) Date: Wed, 27 Jun 2001 07:52:17 +0000 (UTC) Subject: Windows Registry Message-ID: Hi, Could someone tell me how to access the windows registry with python (or point me to the right section of the manual). TIA Alexandre Fayolle -- http://www.logilab.com Narval is the first software agent available as free software (GPL). LOGILAB, Paris (France). From p.caven at ieee.org Wed Jun 20 00:04:53 2001 From: p.caven at ieee.org (Peter Caven) Date: Wed, 20 Jun 2001 00:04:53 -0400 Subject: Properties in Python References: Message-ID: <025701c0f93e$291feaa0$875e8d18@CO778161a> Thanks Michal, I hadn't thought about actually overriding __getattr__ and __setattr__ . I'll look a bit closer at your code later. -- Peter ----- Original Message ----- From: "Michal Wallace" To: "Peter Caven" Cc: Sent: Wednesday, June 20, 2001 12:14 AM Subject: Re: Properties in Python > ... > > I use a class that overrides __getattr__ and __setattr__ .. It looks > first for a get_XXX or set_XXX method... > > The only trick is that you can't store the actual data in __dict__ > this way, because __dict__ gets accessed before __getattr__ (at least > it did back in 1.52).. You have to maintain your own dictionary > instead. > > The code below is the base class I use. Probably could use a cleanup, > but there you go.. > > Cheers, > > - Michal > ------------------------------------------------------------------------ > www.manifestation.com www.sabren.net www.linkwatcher.com www.zike.net > ------------------------------------------------------------------------ From bmstroh at cavtel.net Thu Jun 14 06:40:06 2001 From: bmstroh at cavtel.net (Brent Stroh) Date: Thu, 14 Jun 2001 06:40:06 -0400 Subject: ftplib only posting 52 bytes? References: <9mcgitkhpmkcrql5uhk5bsi94q8nquo4em@4ax.com> Message-ID: <935hit8u3cg66p7culq15ei4vjbe4q4it9@4ax.com> David Bolen wrote: >One thought is that you're not opening the file in binary for the >transfer. Although you're using a binary store store operation at the >FTP level, that only notifies the server to process the incoming >stream without conversion. The FTP module is still reading the file >through your text mode file object, and probably stopping at what it >thinks is an EOF when it sees the first ^Z (ASCII 26) in the file. That was it - can't believe I didn't think of that. :) Thanks! From ullrich at math.okstate.edu Mon Jun 4 10:39:21 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 04 Jun 2001 14:39:21 GMT Subject: random References: <9fcu3601vet@enews2.newsguy.com> <3b1a564f.2986926@nntp.sprynet.com> <9fds6l01lo4@enews2.newsguy.com> Message-ID: <3b1b99ce.4573141@nntp.sprynet.com> On Sun, 3 Jun 2001 19:29:00 +0200, "Alex Martelli" wrote: >"David C. Ullrich" wrote in message >news:3b1a564f.2986926 at nntp.sprynet.com... > ... >> > but some would say the finite >> >program is not "an algorithm" because it's not finite in time -- it >> >may never halt >> >> Halting _is_ part of the standard definition of "algorithm"; >> this is not what "some" would say. > >Sorry, you are simply wrong. Take for example (seems to >be in Google's cache only, not at the originally referenced >URL, so be fast in checking it:-): > >http://www.google.com/search?q=cache:2nixCLVhh-0:phobos.cs.unibuc.ro/mitecs/ >work/dietrich_r.html+probabilistic+algorithm+terminate&hl=en > >""" >First, mathematicians and computer scientists sometimes sharply >restrict the definition of "algorithm." They take the definition of >"algorithm" given here, and use it to define the notion of an effective >procedure. Then they define an algorithm as an effective procedure >which always halts or terminates. >""" > >Note the "sometimes". I concur with this author. Many say >"algorithm" without requiring absolute certainty of termination, >while others use "effective procedure" for the general concept >and only allow the use of the word "algorithm" when certainty >of termination can also be proven. I was certainly aware that people sometimes use the word this way and sometimes use the word that way. Which usage is more common is not something that one can decide by finding one web site. And which usage is more common is really not important. Delete what I said about halting being part of the definition of "algorithm" if you want. The _point_ I was trying to make is that there is a reason that people are sometimes more interested in algorithms that are guaranteed to halt - it's not just an arbitrary detail inserted for the fun of making the (utterly nonstandard and highly controversial) definition longer. >Once people stopped using "algorithm" to mean only what is >today properly called "deterministic algorithm" Hmm. So you think that formerly the word "algorithm" did include the requirment that it halt. Answer me this: In that quote from JVN, do you surmise that the "arithmetic methods" he was referring to were algorithms that halt, or do you think he meant to include RNG's that do not return RN's? Me, I'm running out to write a paper on the halting problem. Now that the meaning of the word "algorithm" has changed there _is_ an algorithm to determine whether a TM halts: Run it and wait, forever if necessary. Gonna be famous, unless the referee thinks it's silly and rejects the paper. > and include >also what is today called "probabilistic algorithm", it was, I >think, quite proper that termination constraints fall also by >the wayside. Consider just one example, >http://www.di.unipi.it/~augusto/pub/selection/papers-pdf/dc.pdf >the probabilistic algorithm it analyzes is by itself not necessarily >terminating. "MOST OFTEN" it will terminate with a provably >correct result quite a bit sooner than its deterministic brother, >but quite possibly it might just keep going on and on instead. > >Not quite the exact kind of probabilistic algorithm most used >today (e.g. for probabilistic testing of primeness) which does >terminate in finite time BUT maybe with a wrong answer -- >arguably more useful when applicable, And arguably less relevant in support of the idea that an "algorithm" is not required to halt. (But never mind that, I don't care how we define words as long as we don't prove falsehoods by letting the definition drift between hypothsis and conclusion.) >since I _known_ where >my algorithm hasn't terminated (yet) so that corrective action >may be taken. Of course, _in practice_, as long as probability >of non-termination (just like, probability of the answer being >the wrong one for the more often used kind of probabilistic >algorithm) can be set as small as desired by appropriate steps, >the actual usefulness of the probabilistic approach is just as >good as that of the deterministic one. > > >> There's a _reason_ it's part of the definition. Elsewhere >> you've claimed to be an engineer, seeming to imply you're >> interested in practical matters. If you have a solution to >> a problem but the "solution" takes infintely much time >> does it really seem like a _useful_ solution in practical >> terms? > >Sure, just like a solution that may not in fact be one (the >answer from the other kind of probabilistic algorithm). On >the practical plane, probabilities, when high enough, are >amply sufficient -- in real life we ain't gonna get any >certainty anyhow. > > >> Like say we want to use Omega to give a "perfect" >> arithmetic RNG. We can do that. Except that when >> we call x = rand() the call _never_ _returns_. >> If you're really interested in RNG's that never >> return then I take back everything I've said, >> yes, JVN was wrong, there's no problem with >> arithmetic RNGeneration. > >I only need a high-enough probability of termination >within a given finite time for one requested random >bit. Say I monitor the process from the outside and >if it's not done in (whatever) I raise an exception, >take some corrective action, kill the runaway process. > >I don't request an infinite number of bits to be >generated in finite time, OBVIOUSLY. You'd better not require _one_ bit to be generated in finite time. >I don't need >infinitely many bits for whatever use I'm putting >that random-number to -- just one bit at a time. > > >> >So where's the "state of sin" in this arithmetical and >almost-algorithmical- >> >except-for-the-little-detail-of-finiteness approach to randomness? >> >> The quote from JVN was about someone _using_ arithmetic methods to >> generate random numbers. If someone is "using" an RNG that _never_ >> _returns_ then he is _not_ generating random numbers. (A fortiori >> he is not using arithmetic methods to generate random numbers.) > >On those occasions when the algorithm (or effective procedure, >or call it as you wish as long, as you don't call it late for dinner) >is not terminating [within some needed time], detection of the >fact and a back-up plan will be needed. So what? Aren't random >bits still emerging -- one after the other -- in finite time on most >occasions, with whatever probability we request if we can devote >sufficient resources to the task? We are not getting "perfectly random" bits if we use an arbitrary timeout. (Defined elsewhere - the meaning of the phrase seemed clear to everyone else.) If we're going to settle for an RNG that's good enough for one particular purpose it does not require any magic to get this; doesn't take Omega to do. An RNG that's good enough for one particular purpose is not what I've been talking about. Even if we're only interested in one particular problem, we are still in a state of sin using an arithmetic generator that's good enough unless we _verify_ that it _is_ good enough to answer the current question to the accuracy requested. >I strongly doubt this method is practical or can be made practical, >differently from many other uses for probabilistic algorithms, though >I would hardly be astonished if somebody more clever or lucky than >me did manage to come up with a practical use. But, so what? Where >was "practically useful" requested to avoid "a state of sin"? Also I realized last night that I don't think that the bits of Omega are any good whatever for an RNG, even if we _could_ know somehow what the bits were. I want to look at the "definition" of Omega again before expanding on this... >Alex > > > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From ullrich at math.okstate.edu Tue Jun 26 09:40:36 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Tue, 26 Jun 2001 13:40:36 GMT Subject: Is this a true statement? References: Message-ID: <3b389000.1020345@nntp.sprynet.com> On Mon, 25 Jun 2001 11:37:00 -0400 (EDT), "Steven D. Majewski" wrote: > > >On 25 Jun 2001, Martin von Loewis wrote: > >> The point is that a program that writes a device driver is not the >> device driver itself. Instead, the program that writes a device driver >> is typically called 'compiler' or 'linker'. You can certainly write >> compilers and linkers in Python, and some people have actually done so. >> >> However, 'writing a program that generates a device driver' is not at >> all the same as 'writing a device driver'. > >Both methods involve writing an abstract specification for a device >driver in some language, which gets transformed by a chain of several >programs into an actual device driver. > >If you write it in macro-assembler, macro statements get expanded into >basic assembler. Would you say that you can't write a device driver >in macro -- only in assembler ? > >What we mean by writing a device driver (in some language) is >describing a device driver. This all seems to be an argument >over whether the map is or is not the territory. > > >Despite the fact that he waited till I conceded to him to concede >and leave me out on a limb :-), Sorry. Didn't actually mean to concede anything regarding any actual matters of fact. I realized that the reason that so many comments were making no sense to me is that people were using a definition of "write a device driver in X" that I didn't realize was the definition being used. Conceded only that _given_ that definition then of course you cannot write a device driver in Python. I didn't mean to concede that it was the "right" definition - arguing over the "correctness" of definitions is too silly even for me, definitions are what they are, by definition. > I think David made an interesting >point about Turing equivalence -- it's reach is a bit farther than >I had thought: A device driver *IS* a computable function of a >textual description of a device driver. > >However, I still object to folks throwing around *unqualified* >statements about the equivalence of all programming languages -- >Turing equivalence is still a rather narrow form of equivalence, >and it doesn't at all imply that anything you can do in one language, >you can do it another -- unless you have a very curious definition >of "do" that perhaps only involves talking about doing. > >( In this particular case, the specification of the problem: > "write a device driver" was so loose as to allow such an > impractical solution. If someone else wants to challenge that > notion, I'll be sure to be more specific of the requirements > next time! ) > > >-- Steve Majewski > >( And I DO wish more languages had adopted Intercal's "Please" > statement -- it would make programs so much nicer to read! ) > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From dougfort at downright.com Tue Jun 12 14:41:52 2001 From: dougfort at downright.com (Doug Fort) Date: 12 Jun 2001 19:41:52 +0100 Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> Message-ID: <3b266270$1_7@news5.uncensored-news.com> thinkit wrote: > humans should use a power of 2 as a base. this is more logical because it > synchs with binary, which is at the very heart of logic--true and false. > it is more natural perhaps, to use decimal--but logic should, and will, > win out. > > Why shouldn't I use whatever base I find convenient at the moment: 2, 10, 16, 60.... If I need to communicate a number to you, my software agent or PDA should convert it to whatever units you are using at the moment. Note that the movement to convert the U.S. to the metric system is fading away. If I need to give you a measurement in I can convert it to cm, or cubits, or whatever. Instead of having a single monolithic number base, or measurement system, (or programming language) why shouldn't we have hundreds or thousands or millions? We've got these computers now, we don't need to count on our fingers or measure with our feets. -- Doug Fort Senior Meat Manager Downright Software LLC http://www.downright.com ______________________________________________________________________ Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com With Seven Servers In California And Texas - The Worlds Uncensored News Source From ben.hutchings at roundpoint.com Thu Jun 28 15:47:10 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 28 Jun 2001 12:47:10 -0700 Subject: Simple question (launch a program) References: <9hf6v6$ps0$1@taliesin.netcom.net.uk> Message-ID: "MDK" writes: > Hi, > > I'm on a Win2K platform. I'm sure that this has been asked before but when > I do a search on the internet I get back too many irrelevant hits because of > the keywords. > > Anyways, how do I launch a program that is in a directory with long file > names? Put double-quotes around the name. But frankly, running random external command-line programs under Windows is a nightmare if (like me) you want to make your program bullet-proof. Different programs have different ways of parsing their command-line. Some attempted workarounds just make things worse. You're much safer using COM. From threeseas at earthlink.net Fri Jun 15 02:08:18 2001 From: threeseas at earthlink.net (Timothy Rue) Date: Fri, 15 Jun 2001 06:08:18 GMT Subject: Python version of IQ has been updates (IQ v0.34.python) Message-ID: <505.566T11T1243597threeseas@earthlink.net> http://www.mindspring.com/~timrue/python/IQ.34.py Read the code header. http://www.mindspring.com/~timrue/python/python-IQ.html --- *3 S.E.A.S - Virtual Interaction Configuration (VIC) - VISION OF VISIONS!* *~ ~ ~ Advancing How we Perceive and Use the Tool of Computers!* Timothy Rue What's *DONE* in all we do? *AI PK OI IP OP SF IQ ID KE* Email @ mailto:timrue at mindspring.com >INPUT->(Processing)->OUTPUT>v Web @ http://www.mindspring.com/~timrue/ ^<--------<----9----<--------< From john.thai at dspfactory.com Wed Jun 27 17:03:32 2001 From: john.thai at dspfactory.com (John) Date: Wed, 27 Jun 2001 17:03:32 -0400 Subject: Extending python & mutability Message-ID: When extending python, if I have a function that is expecting a list whose contents are mutible, can I modify the contents and will the changes be reflected in back in Python? Thanks, John From kkto at csis.hku.hk Fri Jun 15 03:23:06 2001 From: kkto at csis.hku.hk (Isaac To) Date: 15 Jun 2001 15:23:06 +0800 Subject: Inner classes References: Message-ID: <7ipuc6p5ph.fsf@enark.csis.hku.hk> >>>>> "Geoffrey" == Geoffrey Gerrietts writes: Geoffrey> Sounds like this could be reasonably simulated with a Geoffrey> __getattr__ that delegates? An example that seems to implement Geoffrey> the requirement as described, follows. Or something like the following. Things get rather funny... (and absurd.) Anyway, I don't like inner class: it makes things much more difficult to follow. I attribute its existence not to the lack of multiple inheritance, but to the lack of "friend". (Well... friend's are sometimes useful.) A Java inner class can use all the private fields of its outer class. Were the "inner" class a normal class with a reference to the outer class, the programmer would have to use package access for those fields of "outer" needed by "inner". In C++, we would make "inner" a friend of the "outer". But Java's idea of access control is much more coarse-grained. However, there is no access control in Python, so the use of inner class in Python is... you guess it. # Mixin class Inner: def __init__(self, container): self.__container = container def __getattr__(self, attr): return getattr(self.__container,attr) class Outer: def __init__(self, v): self.v = v class __MyInner(Inner): def __init__(self, container, val): Inner.__init__(self, container) self.val = val def f(self): return self.g() + self.v + self.val def getInner(self, val): return Outer.__MyInner(self, val) def g(self): return self.v oInst = Outer(4) iInst = oInst.getInner(2) print oInst.g() print iInst.f() From timr at probo.com Fri Jun 22 02:43:37 2001 From: timr at probo.com (Tim Roberts) Date: Thu, 21 Jun 2001 23:43:37 -0700 Subject: Properties in Python References: <3b31ebb9.553666@nntp.sprynet.com> Message-ID: "Steven D. Majewski" wrote: > >On Thu, 21 Jun 2001, David C. Ullrich wrote: > >> It's curious, the guy who wrote C# seems to be a fan >> of Object Pascal, aka Delphi... (maybe there's a >> simple explanation for that) > >I believe that they guy microsoft hired to do C# is the same guy >that did Delphi -- would that be a simple enough explanation ? Yes, indeed. In fact, it is the same guy who wrote the original Turbo Pascal: Anders Hejlsberg. I believe that's why David coyly included the "" in his post... -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From nas at python.ca Tue Jun 19 13:56:35 2001 From: nas at python.ca (Neil Schemenauer) Date: Tue, 19 Jun 2001 10:56:35 -0700 Subject: PEP 255: Simple Generators In-Reply-To: <4DLX6.320220$oc7.29444949@news2.rdc2.tx.home.com>; from root@rainerdeyke.com on Tue, Jun 19, 2001 at 05:05:04PM +0000 References: <9glhg7$dlk$1@nntp6.u.washington.edu> <4DLX6.320220$oc7.29444949@news2.rdc2.tx.home.com> Message-ID: <20010619105635.B14229@glacier.fnational.com> Rainer Deyke wrote: > def f(): > return > yield 'Never reached.' > > > Is this function a generator? Yes, but only if nobody removes the seemingly > redundant 'yield' statement. def f(): return x x = 1 Is "x" a local variable? Most of your arguments apply to local variables as well. Neil From wart at softhome.net Tue Jun 19 12:40:51 2001 From: wart at softhome.net (Wartan Hachaturow) Date: 19 Jun 2001 20:40:51 +0400 Subject: Comprehensive Python Archive Network References: <87n1762ddv.fsf@penguin.aktivist.ru> Message-ID: <87iths2zjg.fsf@penguin.aktivist.ru> >>>>> "mal" == mal writes: mal> AFAIK, ActiveState will contribute its PPM tools back to Python, so mal> those may become what we all have been dreaming of the last few years mal> ;-) BTW, I've got one crazy idea.. What if we would come in contact with CPAN people, and would just adopt current CPAN to store python modules? We would at least have Web-interface ready, and we would have to only write modules to download modules and install modules. -- Wartan. ...she made you tea, ask for your autograph...What a laugh!... From morten at pool.informatik.rwth-aachen.de Tue Jun 19 06:02:02 2001 From: morten at pool.informatik.rwth-aachen.de (Morten Gulbrandsen) Date: Tue, 19 Jun 2001 12:02:02 +0200 Subject: import anydbm Message-ID: <3B2F231A.3E8A8A0@pool.informatik.rwth-aachen.de> Hello, I have a small python problem, #!/usr/bin/python import anydbm file = anydbm.open("filename.txt") # link to external file file['key'] = 'data' # store data by key data = file['key'] # fetch data by key import cgi form = cgi.FieldStorage() # parse form data (stdin, environ) if form.has_key('name'): showReply('Hello, ' + form['name'].value) """ morten at debian:~/Python/lpython/unix/examples$ chmod u+x *.py morten at debian:~/Python/lpython/unix/examples$ ls -l *.py -rwxr--r-- 1 morten morten 857 Jun 19 11:56 page054.py morten at debian:~/Python/lpython/unix/examples$ ./page054.py Traceback (innermost last): File "./page054.py", line 5, in ? file = anydbm.open("filename.txt") # link to external file File "/usr/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 morten at debian:~/Python/lpython/unix/examples$ example typed from page 54 Learning Python Oreilley Help For programmers, written by Mark Lutz what am I doing wrong ? """ Yours Sincerely Morten Gulbrandsen From s713221 at student.gu.edu.au Fri Jun 15 23:51:03 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Sat, 16 Jun 2001 13:51:03 +1000 Subject: Redhat 7.1 and Python 2.1 References: <20010524235013.K690@xs4all.nl> Message-ID: <3B2AD7A7.3995447E@student.gu.edu.au> > >Apparently what they meant was that a module built for python on Red > >Hat Linux 7.x needs to work on all 7.x releases. Thus, the primary > >python can't be upgraded during the cycle. > > > > And the reason they don't ship with both Python 1.5.2 and Python 2.1 is? True, there's certainly a precedence: KDE1.* as kde-* and KDE2.* as kde2-* then KDE2.* as kde-* and KDE1.* functionality as kde-compat bash1 as bash and bash2 as bash2 glibc-5* as glibc-compat when we switched over to glibc-6* It gets a bit messy I admit as to what you'd put as the kick-start line on each python script, but they've been able to migrate more difficult hurdles before. Maybe they secretly hate the new python? -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From aahz at panix.com Tue Jun 26 18:30:29 2001 From: aahz at panix.com (Aahz Maruch) Date: 26 Jun 2001 15:30:29 -0700 Subject: threadpool References: Message-ID: <9hb2e5$btr$1@panix6.panix.com> In article , Yirong Shen wrote: > >Can anyone suggest a good threadpool implementation for Python? Dunno about a "good" one, but if you'd like the skeleton of a usable and working one, see http://starship.python.net/crew/aahz/ -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Those who do not remember the past are condemned to repeat it." From jcollins at boulder.net Sun Jun 10 09:52:51 2001 From: jcollins at boulder.net (Jeffery D. Collins) Date: Sun, 10 Jun 2001 07:52:51 -0600 Subject: Grail Python2.1 In-Reply-To: <20010606125415.D12381@connecticut.cs.rit.edu>; from dsh8290@rit.edu on Wed, Jun 06, 2001 at 12:54:15PM -0400 References: <9flevu$495$1@wanadoo.fr> <20010606125415.D12381@connecticut.cs.rit.edu> Message-ID: <20010610075251.B10546@boulder.net> Apparently, httplib has changed considerably since 1.5. Here is a patch that fixes the error, but is undoubtedly the wrong approach. The module httpAPI.py may require some redesign... Index: httpAPI.py =================================================================== RCS file: /cvsroot/grail/grail/src/protocols/httpAPI.py,v retrieving revision 1.32 diff -u -r1.32 httpAPI.py --- httpAPI.py 1999/06/29 21:49:25 1.32 +++ httpAPI.py 2001/06/10 13:44:58 @@ -81,14 +81,14 @@ def close(self): if self.file: self.file.close() - if self.sock: + if self._conn.sock: try: - self.sock.close() + self._conn.sock.close() except socket.error: # What can you do? :-) pass self.file = None - self.sock = None + self._conn = None class http_access: @@ -175,7 +175,7 @@ def pollmeta(self, timeout=0): Assert(self.state == META) - sock = self.h.sock + sock = self.h._conn.sock try: if not select.select([sock], [], [], timeout)[0]: return "waiting for server response", 0 @@ -232,7 +232,7 @@ self.readahead = self.readahead[maxbytes:] return data try: - data = self.h.sock.recv(maxbytes) + data = self.h._conn.sock.recv(maxbytes) except socket.error, msg: raise IOError, msg, sys.exc_traceback if not data: @@ -241,7 +241,7 @@ return data def fileno(self): - return self.h.sock.fileno() + return self.h._conn.sock.fileno() # To test this, use ProtocolAPI.test() -- Jeffery Collins (http://www.boulder.net/~jcollins) From jkraska1 at san.rr.com Mon Jun 11 14:55:18 2001 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 11 Jun 2001 18:55:18 GMT Subject: Learning OOP... References: <3b25059c.5089017@news.laplaza.org> Message-ID: >I've heard a number of folks claim that while inheritance is powerful, >it's often used where it need not to be, and that perhaps one should >think composition first. As an amusing side-node, Python objects, under the hood, use composition to build up their inheritance graph. C// From qrczak at knm.org.pl Tue Jun 19 16:34:46 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 19 Jun 2001 20:34:46 GMT Subject: list.sort() References: <3B2CEBF1.CCF5377D@hack.org> Message-ID: 17 Jun 2001 22:29:37 +0200, Martin von Loewis pisze: > Now, some people might expect sort and reverse to return a *new* > array. That would be more expensive in many cases. Plus, changing it > *now* is not appropriate: it would break code that expects that .sort > sorts inplace, whereas a method that returns a new object would not > sort the object itself. #define sort sort or reverse And there is a little problem in adding new functions or methods which return a sorted copy. It's more efficient to do l = dict.keys() l.sort() for x in l: than for x in sort(dict.keys()): because the original list is not needed here, so making a copy is wasteful. But the new sort function can't destroy the original in all cases. So the new idiom would be slower in some cases which suggest that it fits better. The reality is that generally *three* versions of sorting are desirable: 1. return a sorted copy, 2. sort in place, 3. return a sorted copy while forgetting about the original. The only case where one variant can optimally implement another is 2 implementing 3. Other five cases have some unnecessary overhead, especially for reversing. It follows that it's sufficient to provide 1 and 2 in the core, and 3 can be expressed using 2. Actually Python provides only 2. The problem is that although it's more efficient to implement 3 by 2 than by 1, it looks nicer the other way around, as I said above. I'm afraid that providing all three variants is too much complexity and confusion. There is no perfect solution. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From christian at rocketnetwork.com Wed Jun 13 14:22:01 2001 From: christian at rocketnetwork.com (Christian Reyes) Date: Wed, 13 Jun 2001 11:22:01 -0700 Subject: binary file comparison with the md5 module References: <9g8ahr$s6t$1@bob.news.rcn.net> Message-ID: <9g8b37$12m$1@bob.news.rcn.net> eureka! after some more research i have discovered the very handy "filecmp" module. problem solved. cheers, christian "Christian Reyes" wrote in message news:9g8ahr$s6t$1 at bob.news.rcn.net... > I'm trying to write a script that takes two binary files and returns whether > or not their data is completely matching. > > One of my peers suggested that an efficient way to do this would be to run > the md5 algorithm on each file and then compare the resultant output. Since > md5 returns a unique 128-bit checksum of it's input, this should > theoretically work. > > The problem i'm having is with reading the binary file in as a string. > > I tried opening the file with the built-in python open command, and then > reading the contents of the file into a buffer. But I think my problem is > that when I read the binary file into a buffer, the contents get tweaked > somehow. I would expect the print statement to give me some huge string of > gibberish but instead what I get is 'RIFFnap'. Regardless of what size the > file is. I'll try to read in a 5 meg file and all I get when I try to print > the buffer is some variation of 'RIFFxxx' (where xxx is any arbitrary set of > 3 characters). > > >>> x = open('d:\\binary.wav') > >>> buf = x.read() > >>> print buf > 'RIFFnap' > > Anyway, if any of you have a better suggestion for me, I'd really appreciate > it. > > Basically all i'm looking for is an efficient method of comparing binary > data files. > > Thanks for your time, > christian > > From heinlr at gmx.de Sat Jun 9 12:26:33 2001 From: heinlr at gmx.de (ssh) Date: Sat, 9 Jun 2001 18:26:33 +0200 Subject: wxToolTip Message-ID: <9ftifm$2028$1@wrath.news.nacamar.de> hi does anybody know a) how you can move a ToolTip Window to a specified Position b) how you can control the OPENED Window Time ? best regards raimund From j_f9 at yahoo.com Wed Jun 13 08:35:05 2001 From: j_f9 at yahoo.com (F. Tourigny) Date: Wed, 13 Jun 2001 05:35:05 -0700 (PDT) Subject: VI Message-ID: <20010613123505.88702.qmail@web14506.mail.yahoo.com> VI is fun in its own special way, and portable, and I'm using it all the time but, personnaly, I definitely wouldn't promote its use for regular python programming, expecially for large scripts. Relatively powerful, but too basic. Greetings, Frederic > From: "Pilgrim" > Subject: VI > Date: Wed, 13 Jun 2001 11:28:55 GMT > Can someone tell me what "vi" is for a text editor > to work with python? > Where can I get this? __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/ From huaiyuan at rac2.wam.umd.edu Sun Jun 3 20:40:40 2001 From: huaiyuan at rac2.wam.umd.edu (Huaiyuan) Date: 03 Jun 2001 20:40:40 -0400 Subject: Why isn't Python king of the hill? References: <393D961EA4FCD311B03F00D0B746D65803275E5F@HQSXCH01> Message-ID: Thomas Wouters writes: > On Sat, Jun 02, 2001 at 06:12:59PM -0400, Tim Peters wrote: > > sum = 0 > > for i in range(1, 101): > > sum += 1/i > > > In floating-point instead they'd get > > > > 5.1873775176396206 > > This must be a very hypothetical python, given that in current Python they'd > get > 1 > instead . Not hypothetical; but alternative: CMUCL release x86-linux 2.5.2 18c+ 2 May 2001 build 2174, running on nomad Send questions to cmucl-help at cons.org. ... Loaded subsystems: Python 1.0, target Intel x86 * (loop for i from 1 to 100 summing (/ 1 i)) 14466636279520351160221518043104131447711/2788815009188499086581352357412492142272 * (coerce * 'double-float) 5.187377517639621d0 Sorry, couldn't resist... --huaiyuan From hbn at imada.sdu.dk Fri Jun 1 13:41:45 2001 From: hbn at imada.sdu.dk (Henrik Berg Nielsen) Date: Fri, 1 Jun 2001 19:41:45 +0200 Subject: Copying files to multiple comp's on a lan Message-ID: <9f8k3v$1i04$1@news.cybercity.dk> Hi all, I'm rather new to Python, and this is my first post in this NG (as you can probably tell). I hope that you guys can get the meaning of my writings as english is not my native language, so I apology beforehand for any spelling/grammatical errors. I need to make a small script thats capable of copying a file from the machine that its being run on to all the other machines on the lan. The target path on all the other machines should be the same. The script should take the path of the source file and the remote path to the shared folder(s) as arguments. I'll define all the machines the file is to be copied to elsewhere. Where do I start when making such a script? What kind of builtins should I know of and which functions will be useful in my work? What do I need to investigate closer (I've never tried network programming before)? I used to do this filecopying for each machine seperately with the Windows Explorer, and seeing as its something that I do rather often, I'm beginning to get a little bugged by this tedious method, and have decided that now its time to make it a little more automated. If you know of an already existing program that can accomplish this task for me any pointers would be greatly appreciated. Thanks in advance, Henrik Berg Nielsen From aleaxit at yahoo.com Fri Jun 15 06:15:54 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 15 Jun 2001 12:15:54 +0200 Subject: IP address to binary conversion References: Message-ID: <9gcn9l02v7f@enews1.newsguy.com> "Jeroen Wolff" wrote in message news:vqajitkao6tvll7ads8v84nbatp1hhr8jn at 4ax.com... > > > > >>>> host = n & mask > >>>> net = n - host > > >>>> print "net: %X host: %X" % (net, host) > >net: C0000000 host: A80201 > > > Is there a way back to present the calculated results in a doted > decimal notation? >>> import socket, struct >>> print socket.inet_ntoa(struct.pack("!L",host)) 0.168.2.1 >>> Alex From dsh8290 at rit.edu Thu Jun 7 21:29:46 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 7 Jun 2001 21:29:46 -0400 Subject: Python Shareware? In-Reply-To: ; from jchen@263.net on Thu, Jun 07, 2001 at 05:17:31PM -0700 References: Message-ID: <20010607212946.B18140@harmony.cs.rit.edu> On Thu, Jun 07, 2001 at 05:17:31PM -0700, Jian Chen wrote: | I am considering writing some shareware in python. I got some | questions about it: | | 1. Is there any good shareware in python? where can I find? Not too much "shareware" that I know of, but you can find lots of Open Source (aka "Free") software in the Vaults of Parnassus (there's a link in the left-hand column on python.org). | 2. Is python suitable to write shareware? as I konw, it is not easy to | pack python programs in standlone exe program? is there any tools for | the packing & installing of python software? It's suitable for writing applications, whether shareware or otherwise. | 3. How can I lock/secure my python shareware? That's a good question. I recently heard a quote from the group that was trying to make DVDs (or other future media format) un-copyable. Trying to make bits uncopyable is like trying to make water unwet. You can implement (or buy) some mechanism to enforce some sort of lock/licensing thing, but it is very difficult to correctly and completely implement such a mechanism. Any mechanism can be cracked by a diligent person anyways. You could talk with the writer of wxDesigner and see what he uses (if he's willing to tell ;-)). -D From jp at ulgo.koti.com.pl Sun Jun 10 08:21:38 2001 From: jp at ulgo.koti.com.pl (Jacek =?iso-8859-2?Q?Pop=B3awski?=) Date: Sun, 10 Jun 2001 12:21:38 +0000 (UTC) Subject: return from class? References: Message-ID: I will try to explain this better... I need to select "corporation". I need it in many places in my application, so I decided to create class SelectCorporation. This class should open window with Listbox. User should select one item from that Listbox, then click "OK". I don't know what to do when OK is clicked. I should destroy window, and class instance, but how to return value to the class which called SelectCorporation? -- Hot wind, moving fast across the desert We feel that our time has arrived The world spins, while we put his dream together "Stargazer" A tower of stone to take him straight to the sky - Ronnie James Dio From nhodgson at bigpond.net.au Tue Jun 12 05:46:48 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Tue, 12 Jun 2001 09:46:48 GMT Subject: How do you develop in Python? References: <050620011516094693%pecora@anvil.nrl.navy.mil> Message-ID: Nick Perkins: > With all apologies to those who developed these FREE IDE's... > (it is not fair to complain about free software, and that is > not my intention here -- I am sure that I could not do any > better).. But if there weren't any complaints, then we wouldn't know what to fix . > SciTe seems interesting, but I haven't figured out how to > configure it, yet, and util I do, it's useless. (me being lazy, > but still...) SciTE is the dumbest on your list, not attempting to be a debugger at all and just executing a Python file in an external process and piping the output into a window. > I want an IDE to provide at least the following: > 1. Each run takes place in a fresh, clean environment. > 2. The IDE stays responsive while a program is run. > 3. The IDE can kill a running program. These are fairly easy although chances of a process kill differs between OS versions. > Is it not possible to start a 'fresh' interpreter for each run? Or is that > not actually desirable for some reason? Would that make it impossible to > kill it or get tracebacks, etc? Do we need a Python IDE that does not run > itself in Python? What is hard if Python is run out of process is to performing debugging operations such as single stepping and examining variables. > ( i guess SciTE doesn't....maybe I'll give that another go..) Go on, but I bet you'll want a real debugger after a short period and that is something I'm unlikely to find the time to add to SciTE. > BTW, which free IDEs are currently being maintained and improved? > How much work is being done, and how many people are doing it? > ( keep up the good work!, if this means you!) SciTE gets lots of additions but there is not much quality control so at any time several of the features are sure to work strangely. Boa is alive but progressing slowly. PythonWin doesn't see much improvement as Mark is very busy with a lot of work including Komodo. PythonWin could be fairly easily made to have an option to run programs in another process but not allowing debugging. With open source though, its a matter of someone being sufficiently motivated (or annoyed) to invest the effort. Neil From Marcin.Kasperski at softax.com.pl Tue Jun 19 14:13:07 2001 From: Marcin.Kasperski at softax.com.pl (Marcin Kasperski) Date: Tue, 19 Jun 2001 20:13:07 +0200 Subject: Nontrivia: compilation/linkage problems with Python on Tru64 troublesome for omniORB Message-ID: <3B2F9633.5DCF2491@softax.com.pl> { I post this letter to comp.lang.python for discussion, python sourceforge bugtracker to make sure someone reads it and omniorb at uk.research.att.com as important appendix to the letter about compiling omniORB on Tru64 } I am currently trying to compile Python/OmniORB/OmniORBpython suite on Tru64 Unix (the new name for Digital Unix/OSF) with DEC CXX 6.2. For the longer story search for my next post, but I have some important observations about Python. Are they bugs? Anyone skilled to check it further is welcome. In case I should post this somewhere else, please let me know. The tests described below used Python 2.1. The problem which forced me to perform this analysis happened during compilation of omniORB 3.0.3. I start from the less important things going to the more important. 1) While compiling Python with DEC CXX (below you will find why I did it), I got the error message (on Include/structmember.h) about incorrect usage of language extension (probably they in some situations use 'readonly' in the way similar to 'const'). I have not diagnosed it in the great detail (seems that compiler options and pragmas set by python makefiles influence the situation somehow) but changing readonly to - say - read_only should not spoil anything and will help. I worked around the problemy by using cxx -Dreadonly=_readonly as the compiler name. 2) In contrary to most configure scripts, Python configure script ignores environment variable CC. The problem is in case switch checking wheter --with-gcc or --without-gcc is specified: if test "${with_gcc+set}" = set; then (....) else case $ac_sys_system in OSF1) CC=cc without_gcc=;; (...) To compile python with cxx I manually edited the line above but I think compiling python with compiler different than cc and gcc should be possible in the natural way. In case people dislike CC checking, maybe --with-cc=<...> could be done? 3) So, let's tell why I needed to compile python with DEC CXX. While using 'default' (compiled with cc) python, I was unable to use python extension modules written in C++ (I got the problem while trying to compile and use _omniidl module from omniORB but seems it would be the same for others): - the '_omniidlmodule.so' file links correctly and is correct - attempts to import it results in python -c 'import _omniidl' Traceback (innermost last): File "", line 1, in ? ImportError: dlopen: Unresolved symbols The problem is caused by the lack of symbols from libcxx.so (C++ compiler shared library). I am not expert regarding dlopen but seems that python, while loading the module, does not load shared libraries the module depends on (at least on Tru64). After I recompiled python with cxx (mainly to get the python executable linked permanently with libcxx.so so this library is present while my module is being imported) the problem disappeared and the module imported and worked correctly. -- http://www.mk.w.pl / Marcin.Kasperski | Internetowy arkusz pracy (timesheet): @softax.com.pl | http://www.mk.w.pl/programy/timesheet @bigfoot.com \ From msw at redhat.com Fri Jun 8 00:07:56 2001 From: msw at redhat.com (Matt Wilson) Date: Fri, 8 Jun 2001 00:07:56 -0400 Subject: [pygtk] HTML Widget In-Reply-To: <991967480.4503.0.camel@ZOOstation.cc>; from rob@ZOOstation.cc on Fri, Jun 08, 2001 at 02:31:20PM +1200 References: <991967480.4503.0.camel@ZOOstation.cc> Message-ID: <20010608000756.D8993@devserv.devel.redhat.com> On Fri, Jun 08, 2001 at 02:31:20PM +1200, Rob Brown-Bayliss wrote: > > Is there any reason for not building by default? for example stability? When I wrote the binding the API wasn't stable, and I haven't touched it since. So, I guess the answer is "yes." ;) Matt From aahz at panix.com Sat Jun 2 15:22:57 2001 From: aahz at panix.com (Aahz Maruch) Date: 2 Jun 2001 12:22:57 -0700 Subject: Against PEP 240 References: Message-ID: <9fbeeh$nor$1@panix6.panix.com> In article , Roman Suzi wrote: > >This said, what is the right way to deal with >currencies in Python right now? Tim Peters's FixedPoint.py: ftp://ftp.python.org/pub/python/contrib-09-Dec-1999/DataStructures/FixedPoint.py You *probably* want to set the precision to three or four places so that rounding errors don't propagate. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 I surf faster than you do, monkey boy. (My take on Netscape vs. Lynx) From mcherm at destiny.com Tue Jun 12 17:35:42 2001 From: mcherm at destiny.com (mcherm at destiny.com) Date: Tue, 12 Jun 2001 16:35:42 -0500 Subject: [Python-Dev] PEP 259: Omit printing newline after newline Message-ID: <1511a11611.116111511a@destiny.com> It pains me to admit it <1.0 wink>, but Alex has done it again. He's taken a contentious discussion about a messy issue and, in his inimitable wordy manner, has clarified it and provided an excellent solution: First, he says: > So, summarizing: in Python, keyword statements either > affect the namespace using them, or affect the control > flow that uses them. > > All, that is... except ONE. > > That one is: print. Very interesting point. He goes on to say: > Having output as a built-in function would encourage > using it in lieu of the print statement, (which is IMHO not so good) > which, in > turn, would allow the usual kind of tricks that are > available for built-ins but not for statements, such > as wrapping/overriding (which IMHO *IS* very good) Then in a later message, he manages to pull it all together: > If an output function were defined, it could play the > same role wrt the print statement as __import__ plays > wrt the import and from statements. The statement > would remain (of course: breaking a vast majority of > all scripts would be silly), *AND* it would be > defined and documented to internally invoke the function. > > So the programmer gets a chance to "override" the > function and get a global effect even when another > module used the statement instead. Perhaps, in this > spirit, the function should be named __print__, then. This is a REALLY GOOD SOLUTION!!!!!!! (1) It keeps around the extremely-useful "print" statement. (2) It allows "power-users" to intelligently modify the behavior of that statement. (3) It does so in a pythonic way... working the same way as __import__, and REDUCING, not increasing the amount of "magic" in Python. (Currently "print" is magical with regard to space separation. To me it's somehow better if that "magic" is a feature of some built-in default __print__ function rather than a feature of the opcode!) And best of all.... if we'd had __print__ in the first place, then >> would never have made it into the language! <0.01 wink>. So... I'm hoping that someone knowlegable will write this up as a PEP to compete with 259. And I apologize to Guido for having been one of the dev-reading-folks to encourage 259 in the first place. Ever-amazed-at-the-feats-of-knowledge-and-clarity-that-our-bots-are- capable-of-ly yours, Michael Chermside (mcherm at destiny.com) PS: I believe no one should be asking others to do work unless they're willing to volunteer to do it themselves. I'm really not knowlegable enough about Python yet to be a good PEP author. But if no one else steps forward to write it or manages to convince me there's a better solution within, say the next week, then I guess I've committed myself to writing the PEP. Since I'm a lousy writer, I hope someone else likes this idea and steps forward. From DavidLnospamm at raqia.com Tue Jun 5 18:56:53 2001 From: DavidLnospamm at raqia.com (David Lees) Date: Tue, 05 Jun 2001 18:56:53 -0400 Subject: Numeric Programming for Everybody (was Re: I had a thought ...) References: <3b1cb719$0$12248$ed9e5944@reading.news.pipex.net> Message-ID: <3B1D63B5.CFE70253@raqia.com> Neil, I am a Python newbie, but I must disagree completely with your view. You should worry a lot about numeric representation and are being really cavalier for someone doing 'real world application'. IF you use floating point in my opinion you really should understand what is going on underneath. Understanding why you can not blithely add 0.1 1000 times and expect to get 100 is important for many real world applications. Further, even if you stick to fixed point, you better know how many bits are in your representation or you risk overflow. My point is that understanding the internal representation, regardless of the type of programming you do should be important. david lees Neil Benn wrote: > > Hello, > > > How can the language > > accommodate the differing needs of the learner and dilettante on the one > > hand, and the specialists in various kinds of numeric programming on the > > other? > > Or should it? As a programmer interested in interfacing to serial devices > over RS-232, I really don't care about the intricacies of floating point > calculations. If practically 2+2=4, then I'm fine with that. I think in > the majority of real world applications, in a pragmatic sense most people > don't care of the intricacies of number representation as long as it works > (which in 99.9999999% of cases - it does for a fixed, static > implementation). Leave that to the experts, it's not just learners who > don't care about the floating point philosophies. > > For highly specialised programming requirements (e.g. mathematical work, > advanced neural netoworking) then highly specialised tools should be used, > obviously that's a personal opinion not a statement! For everything else, > just get it to work and work reliably. > > Cheers, > > Neil > > "Don Dwiggins" wrote in message > news:mailman.991685948.23344.python-list at python.org... > > Tim Peters writes: > > > [Don Dwiggins] > > >> See http://support.microsoft.com/support/kb/articles/Q172/3/38.ASP for > > >> one use of Currency having nothing to do with money. > > > > > Cute! In an earlier, unrelated thread, we learned that the Currency > type is > > > really a 64-bit int, conceptually scaled by a factor of 10000. The > > > performance counter API uses 64-bit ints directly. So they're the same > > > thing, except that the VB code at the link has to fiddle around > multiplying > > > the Frequency value by a magic 10000 to get VB to *treat* the value like > a > > > real 64-bit int. OTOH, in (Ctr2 - Ctr1) / Freq, the 10000's cancel out > so > > > they dare not play with magic multipliers in *that* context. Oh ya -- I > bet > > > all the VB programmers understand this in sufficient detail to bet the > > > business on . > > > > This, and the various threads on numeric representation and computation, > > triggered the following thoughts: > > > > - Common number systems can't be completely and accurately represented in > > computers -- some limitations and/or approximations must be accepted. > > > > - This is widely acknowledged among programmers, but not obvious to > > newcomers. > > > > - Many of those who acknowledge it don't have a complete understanding of > > the "limitations and/or approximations" and the sometimes subtle > > consequences for building software that handles numbers "reasonably". > (As > > evidence, I offer the discussions in this group. I also freely admit > > that, if I were to undertake serious floating-point programming again, > I'd > > have to brush up on the details.) > > > > - For many purposes, a relatively naive level of understanding is > sufficient > > -- provided it's accompanied by an appreciation that there's more to it, > > and that one may be required to learn the details of floating point, > > rational representations, etc. > > > > So, what are the implications for "Computer Programming for Everybody"? > How > > much and what knowledge should the newbie be expected to master, to avoid > > falling into various traps? What conceptual model(s) of numbers should a > > language (say, for example, Python) present to the learner to be generally > > useful without making it too easy to go wrong? How can the language > > accommodate the differing needs of the learner and dilettante on the one > > hand, and the specialists in various kinds of numeric programming on the > > other? > > > > -- > > Don Dwiggins "Solvitur Ambulando" > > Advanced MP Technology > > dwig at advancedmp.net > > > > From pinard at iro.umontreal.ca Sat Jun 23 11:03:43 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 23 Jun 2001 11:03:43 -0400 Subject: emacs speedbar for python mode? In-Reply-To: <9h24tq$f7b$1@news1.xs4all.nl> References: <9h24tq$f7b$1@news1.xs4all.nl> Message-ID: [Boudewijn Rempt] > Wonderful! Is there perhaps also a way to automatically > open the speedbar? I use the following. Only the last line really matters to you. :-) ;;;; `Speedbar' mode. (eval-after-load "speedbar" '(push '(background-color . "floral white") speedbar-frame-parameters)) (when (and window-system (load "speedbar" t)) (setq speedbar-verbosity-level 0) ;; REVOIR: Le curseur reste dans le speedbar, malgr? le save-excursion. (save-excursion (speedbar-frame-mode 1))) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From tim.one at home.com Mon Jun 18 21:44:35 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 18 Jun 2001 21:44:35 -0400 Subject: Python Idioms? In-Reply-To: <9gm9fk$pfm$1@news.chatlink.com> Message-ID: [David Stanek] > In reading through the Python source code I came across some oddities. > In some modules, specifically threading, the instance objects are > created using a kind of factory method. > e.g. > class _X: > pass > > def X(*tupArgs, **dicArgs): > return apply(_X, tupArgs, dicArgs) > > When the class could just as easily been named X. Is there an > advantage to doing things this way? This is a trick Guido uses simply to make sure you can't subclass X. The threading.py classes in particular *may* someday grow more-efficient platform-specific implementations, and by playing this trick now Guido ensures that he doesn't have to compromise on speed later by needing to continue supplying a class. The only real example of that now is threading.Lock, whose definition is simply (chasing it down): Lock = thread.allocate_lock So Lock maps directly to a C function now; RLock and Condition etc may also someday, but we couldn't make that change if code relied on subclassing from RLock and Condition etc. > Also I noticed in the same module: > import sys > _sys = sys > del sys > > What does this do? You still have a reference to the module. What > difference does it make what the name is. Module-level names with a leading underscore are ignored by "import *". So this is for people using "from threading import *": they won't pollute their own namespace with _sys, but *would* pollute it with "sys" if the rename weren't done. Since threading.py was written, a better way to spell this was introduced: import sys as _sys BTW, in this particular case, there's a comment right in the module: # Rename some stuff so "from threading import *" is safe From Attila.Feher at lmf.ericsson.se Wed Jun 6 12:20:06 2001 From: Attila.Feher at lmf.ericsson.se (Attila Feher) Date: Wed, 06 Jun 2001 19:20:06 +0300 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3b1cdc84.5514@bolder.com.co.za> <9fleid$3rp$1@oslo-nntp.eunet.no> <3B1E4951.7F36D4E4@alcyone.com> <3B1E50E1.35AE59C@lmf.ericsson.se> <3B1E52DA.BBC9FC32@alcyone.com> <3b1e5601.3970@bolder.com.co.za> Message-ID: <3B1E5836.E7F1D88F@lmf.ericsson.se> goose wrote: [SNIP] > > *REAL* computer users don't buy games ... they write their own > And they don't program in Pascal! :-))) A From thamza.nospam at flash.net Tue Jun 26 01:00:29 2001 From: thamza.nospam at flash.net (Tim H) Date: Tue, 26 Jun 2001 05:00:29 GMT Subject: win32ras on win98? Message-ID: Does win32ras work on win98? I was playing around with rastest.py in the win32ras\Demos. I get this result: C:\Python\win32\Demos>python rastest.py -l All phone-book entries: Traceback (most recent call last): File "rastest.py", line 136, in ? main() File "rastest.py", line 125, in main ShowConnections() File "rastest.py", line 35, in ShowConnections for (name,) in win32ras.EnumEntries(): pywintypes.api_error: (610, 'RasEnumEntries', 'The buffer is invalid.') ActiveState Python 2.1.0 latest build (211?) on Win98. I'm pretty much a newbie to Python so am maybe missing something obvious. I was also playing with win32ras.EnumConnections and getting a similar error. Thanks, Tim From thomas.heller at ion-tof.com Wed Jun 13 02:59:21 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Wed, 13 Jun 2001 08:59:21 +0200 Subject: Creating Typeinfo for Python COM servers? References: <9fnocb$550f3$1@ID-59885.news.dfncis.de> <3B1F69CD.5000704@ActiveState.com> <9fofhe$5c8p0$1@ID-59885.news.dfncis.de> Message-ID: <9g72th$7e02j$1@ID-59885.news.dfncis.de> "Christian Tismer" wrote in message news:mailman.992384541.26086.python-list at python.org... > > > Thomas Heller wrote: > > Ok, I found Christian Tismer's code (which seems to be the most > > recent one?). It looks like it is doable... > > Where did you dig that out? > Somewhere in the pycom-dev archives. > If I had finished a fourth of he projects that I started, I'd > be a rich man :-)) > > If you like to, we can put that back on the boiler plate, of course. > I though someone else took over and this were done already. No? > Doesn't seem so. I hope to finish this within the next few days. Thomas From gerhard.nospam at bigfoot.de Mon Jun 25 17:02:00 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Mon, 25 Jun 2001 23:02:00 +0200 Subject: 'with' statement in python ? References: Message-ID: On Mon, 25 Jun 2001 20:33:11 +0200 (CEST), asgard wrote: >Hello, >writing self before every object's method really drives me >crazy. Shouldn't there be 'with' statement like in Pascal, ie. > >self.a=1 >self.b=2 > >could be written as > >with self: > a=1 > b=2 > >? Of course it would work with other names too. You can use any name instead of self, some people use simply "s", for example. I prefer code where self is used, though. If this were a problem for me, I'd write an editor macro and map it to alt-s or something. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://highqualdev.com public key at homepage public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From bokr at accessone.com Sun Jun 10 17:54:27 2001 From: bokr at accessone.com (Bengt Richter) Date: Sun, 10 Jun 2001 21:54:27 GMT Subject: list-display semantics? References: <9g0dhl$if1$1@news.nsysu.edu.tw> Message-ID: <3b23cb5f.147099387@wa.news.verio.net> On Mon, 11 Jun 2001 02:29:47 +0800, "jainweiwu" wrote: >Hi all: >I tried the one-line command in a interaction mode: >[x for x in [1, 2, 3], y for y in [4, 5, 6]] >and the result surprised me, that is: >[[1,2,3],[1,2,3],[1,2,3],9,9,9] >Who can explain the behavior? >Since I expected the result should be: >[[1,4],[1,5],[1,6],[2,4],...] >-- >Pary All Rough Yet. >parywu at seed.net.tw > > I think the first comma made your expression legal and equivalent to [x for x in ([1, 2, 3], y) for y in [4, 5, 6]] so x took on two values: [1, 2, 3] and the incoming value of y, which happened to be bound to a left-over 9 from some previous activity, because the bindings for the elements of the sequence ([1, 2, 3], y) were set up before the y loop got started. So the loop y sequenced 4-5-6 for for three elements of [1, 2, 3] and then x took on the value of y from the tuple which hadn't changed it was created, hence the 9, for three more elements of the final result. The actual values for the y loop make no difference except that the last will be available next time. Do a del y and you will get a NameError exception if you try to re-run your statement. Since you used y for the for expression, if you ran the expression again, you'd get 6's in the place of the 9's. >>> y='y' >>> [x for x in [1, 2, 3], y for y in [4, 5, 6]] [[1, 2, 3], [1, 2, 3], [1, 2, 3], 'y', 'y', 'y'] >>> [x for x in [1, 2, 3], y for y in [4, 5, 6]] [[1, 2, 3], [1, 2, 3], [1, 2, 3], 6, 6, 6] Then note the 6 left over from the first go above. Try the following (with [4,5,6]) to get what you expected. (I left off the 6 to avoid line wrap here :) >>> [[x,y] for x in[1,2,3] for y in [4,5]] [[1, 4], [1, 5], [2, 4], [2, 5], [3, 4], [3, 5]] (caveat lector: I am neither Latinist nor Python guru yet ;-) From erno-news at erno.iki.fi Wed Jun 27 06:41:05 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 27 Jun 2001 13:41:05 +0300 Subject: Escaping SQL in python References: <3B39A1B8.A7FCE4C7@kvarteret.uib.no> Message-ID: In article <3B39A1B8.A7FCE4C7 at kvarteret.uib.no>, Kjetil Nyg?rd writes: | Is there a method to escape ' " \ and the like in python auto-magiacaly | ? it is not portable between different sql dialects, so there is no generic way. the database-specific modules can provide such a function, but it is usually easy to write one yourself. -- erno From rpyron at alum.mit.edu Mon Jun 25 03:27:41 2001 From: rpyron at alum.mit.edu (Robert Pyron) Date: Mon, 25 Jun 2001 07:27:41 GMT Subject: Any other Python flaws? References: <9gr8o8$hhq$4@newshost.accu.uu.nl> <9h5b36$cg0$2@newshost.accu.uu.nl> Message-ID: <7opdjt85g3895mfn3u1jhku1vk3qi5ok4m@4ax.com> On 24 Jun 2001 18:21:26 GMT, m.faassen at vet.uu.nl (Martijn Faassen) wrote: >Remco Gerlich wrote: >> Is the PSU license TGPLV (Totalitarian GeeInYou-Script Pubic [sic] License >> Virus) compatible? >> ... > >Yes, like all other software, the PSU license causes any TGPLV'ed software >to be PSUPL-ed. Since PSUPL infection proceeds at a rate faster than >that of the speed of light (it even has access to time travel), the PSUPL >will win. I may have an example of this. I have here a copy of the 3rd edition of "The Icon Programming Language", which assures me right on the back cover that "Icon source code and implementations... are in the pubic domain..." Bob P From thomas at cintra.no Wed Jun 13 15:59:41 2001 From: thomas at cintra.no (Thomas Weholt) Date: Wed, 13 Jun 2001 19:59:41 GMT Subject: Postgresql Woes References: <436ad7a4.0106131131.57bc1cd1@posting.google.com> Message-ID: Look at the examples in the PyGreSQL-package. I believe there's some examples doing this exact thing. "Sreekant" wrote in message news:436ad7a4.0106131131.57bc1cd1 at posting.google.com... > Hi folks > > I have made a few web sites with postgresql but never needed to know > the list of tables available in the database through pg module. > > I guess you can use psql and \dt command or os.popen('psql ... , to > get the list of tables. But is there a decent way of finding out > through python and postgresql [pg] module , all the tables in a > database! > > eg: > con=pg.connect("mydb") > tbl=pg.query("show all tables from mydb") or something similar ?? > > Thanks a lot for your time > sreekant From gerson.kurz at t-online.de Tue Jun 26 10:18:35 2001 From: gerson.kurz at t-online.de (Gerson Kurz) Date: Tue, 26 Jun 2001 14:18:35 GMT Subject: Threads, Callbacks, Classes [Long] References: <3b3889b9.530187@news.t-online.de> Message-ID: <3b3897be.4119390@news.t-online.de> Folks, it gets weirder. Here is a test DLL (MSDEV project) plus a testscript: http://www.p-nand-q.com/python/pxfstest.zip (6438 Bytes) Its really easy, just two functions, one synchronous, one asynchronous. a) given a msgport of the form import Queue msgport = Queue.Queue() a callback "msgport.put" works, *if* called from the same thread. it does NOT work if called from another thread - no message will be posted in this case. b) If I use a callback function (see pxfstest.py), I get the error messages Fatal Python error: PyEval_ReleaseThread: wrong thread state Fatal Python error: PyThreadState_Get: no current thread and an exception somewhere in python21_d.dll (I'm using ActiveState ActivePython 2.1) even though the callback got called properly. I'm completely @ loss what happens here. From paulp at ActiveState.com Sat Jun 30 05:58:20 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sat, 30 Jun 2001 02:58:20 -0700 Subject: Python compiler References: <20010630030055.10593.qmail@web13003.mail.yahoo.com> Message-ID: <3B3DA2BC.2E52A118@ActiveState.com> Eric Merritt wrote: > > Hello All, > > I am new to python after having converted from java. > One of the problems I always had with java was the > lack of a native code compiler. That's a strange thing to hold against a language. How does it affect you? I could build an executable for you in either Java or Python that was indistinguishable from one that was native code compiled without disassembling it. If your complaint is that Java (or Python) is too slow, I think you should say that. If your complaint is that you can't write standalone binaries in it (you can), you should say that. I'd like to understand what you really need so I can tell you whether Python has what you need or not. > Will python ever have > one of these? I have seen references to projects such > as py2c etc, but they all seem dead. Is there an > inherent problem in creating a compiler for python or > is it just very difficult. Unfortuanatly I am not a > big compiler guru though I would be willing to help if > I could. Just curious. Creating a compiler for Python is difficult and as it isn't really needed to accomplish most people's goals, nobody has done it. We could put a bunch of effort into it but we'd come back to that executable that is basically indistinguishable from the one I could give you today without the compiler. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From crj003 at yahoo.com Thu Jun 28 08:49:30 2001 From: crj003 at yahoo.com (Rich J) Date: 28 Jun 2001 05:49:30 -0700 Subject: What is my module name? References: Message-ID: <5c8ecb0b.0106280449.79160a3c@posting.google.com> > I have a module with a function below I > use __name__ to return the module name. > However, when I call the function from > outside, it returns '__builtin__'. Is > there a way to have this function return > the module name regardless of where it > is called? > > def myName(): return __name__ > > Thanks! > > Clark Clark, You don't need to do that. If you want to know the name of the module it is available after importing the module. # Name.py def myName(): # code for myName ... Now all you have to do is import the module: import Name # And here is where you can get the name of the module name_of_module = Name.__name__ # = 'Name' From andymac at bullseye.apana.org.au Mon Jun 25 18:49:16 2001 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Tue, 26 Jun 2001 08:49:16 +1000 (EST) Subject: Tkinter and TkTable In-Reply-To: <3B378B89.6D235698@ces.clemson.edu> Message-ID: On Mon, 25 Jun 2001, Schaefer, F. wrote: > I'm in need of a table widget to display some query data. There is this > popular TkTable Widget, which I would like to use. Does anybody have > any idea howto include it into Tkinter (and why it isn't already > included). I'm no expert on things Tcl/Tk/Tkinter, but I suspect you have two options:- 1) if your TkTable is dynamically loadable inside a Wish, you can probably use Tkinters Tk call interface to issue the appropriate command to load the TkTable module. You then either use the call interface to drive the widget, or create a suitable subclass of a Tkinter widget that wraps the call interface. 2) modify _tkinter to include the TkTable extension in the standard Tcl/Tk manner - after initialising Tcl & Tk, initialise TkTable. This will be in the module initialisaton code in _tkinter.c. You still need to use Tkinter's call interface to drive the widget. #1 seems the most favourable course to me. -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andrew.macintyre at aba.gov.au (work) | Snail: PO Box 370 andymac at bullseye.apana.org.au (play) | Belconnen ACT 2616 andymac at pcug.org.au (play2) | Australia From rdsteph at earthlink.net Sun Jun 3 04:41:34 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Sun, 03 Jun 2001 08:41:34 GMT Subject: Jython book Message-ID: <3B18A928.E6E8B4C6@earthlink.net> It seems to me there is a huge opportunity for someone to come out with the first good book on Jython. It is a good tool, but a really good book would be of immense help. >From what I have seen of the knowledge of some on this list, the capability is there for someone to write a definitive masterpiece. I hope anyway. Maybe Alex Martelli??? From john.thai at dspfactory.com Wed Jun 13 15:03:28 2001 From: john.thai at dspfactory.com (John) Date: Wed, 13 Jun 2001 15:03:28 -0400 Subject: PyArg_ParseTuple part 2 References: Message-ID: <4OOV6.248837$Z2.2878033@nnrp1.uunet.ca> Okay, here's some code (I've omitted some of the error checking for simplicity): static PyObject *PyGetComInterface(PyObject *self, PyObject *args) { PyObject *t; PyObject *pyList; int x; // extract list PyArg_ParseTuple(args, "O!", &PyList_Type, pyList); // make a tuple version of list t = PyList_AsTuple(pyList); // extract an integer from list *Note: t is always null at this point if (t != NULL) { PyArg_ParseTuple(t, "i", &x); fprintf(stdout, "List contains: %d\n", x); } Py_INCREF(Py_None); return Py_None; } "Michael Hudson" wrote in message news:m3g0d4w7gy.fsf at atrus.jesus.cam.ac.uk... > "John" writes: > > > Hi, > > > > In an extended python c function, I use PyArg_ParseTuple to extract a > > list object from python. I then use PyList_AsTuple to get a tuple version > > of the list. I'm expecting an list of 2 integers, so I use PyArg_ParseTuple > > again, passing in this new derived tuple, and specifying "ii". Should this > > not work? First, after I call PyList_AsTuple, I get NULL back instead of a > > PyObject. Second, lets say I pass variable x (from python) = [1,2] into my > > function, right after making this function call foo(x), no matter what I > > type, either x, or just enter, I get the following msg: > > > > SystemError: C:\Code\python\dist\src\Objects\listobject.c:1317: bad argument > > to > > internal function > > > > Anyone know what's going on? > > Err, you are specifying your function as METH_VARARGS, right? (Just a > guess). Otherwise, how about showing us some code - I can't really > follow your description above. > > > Related questions: Is there a fast way of extracting elements from a list, > > other than using PyList_GetItem, then converting the PyObject into the type > > you are looking for? > > Well, there's PyList_GET_ITEM, but no, not really. Lists store > PyObject*s - what were you expecting? > > > And why isn't there a PyInt_FromInt(int) function? > > There's PyInt_FromLong - is that what you're after? > > Cheers, > M. > > -- > Presumably pronging in the wrong place zogs it. > -- Aldabra Stoddart, ucam.chat From sholden at holdenweb.com Thu Jun 21 21:58:05 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 21 Jun 2001 21:58:05 -0400 Subject: DBX Files References: Message-ID: Here's a file which does process Outlook Epxress .dbx files, but there's been no polishing on it yet so you'll have to hack it to do what you want. Hope it helps. regards Steve -- http://www.holdenweb.com/ "mbraden" wrote in message news:mailman.993091232.31786.python-list at python.org... I recently had some e-mail in my Outlook express, inbox. With some very important data. I downloaded everything on my hard-drive, to a CD, because the computer had be restored. In doing so, when I copied everything back, the computer put in in Windows Explorer, and in a DBX file, which I can't read. Can you please help???????????????? Thanks, Mary -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: inbox.py URL: From aleaxit at yahoo.com Sun Jun 10 15:35:10 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 10 Jun 2001 21:35:10 +0200 Subject: Catching Errors References: <3B20E042.DA0AF3C1@usa.net> <9fqpii$5mk9n$1@ID-11957.news.dfncis.de> Message-ID: <9g0idm01lap@enews1.newsguy.com> "Emile van Sebille" wrote in message news:9fqpii$5mk9n$1 at ID-11957.news.dfncis.de... > If you want to capture error output to a file, you can also try: > > c:\> python errors-catch.py 2>errors.txt That doesn't help on Windows/98 (nor on NT, I think), as would seem to be suggested from the 'c:\>' prompt...: D:\py21>python -c "import sys;print>>sys.stderr,sys.argv" 2>oo.txt ['-c', '2'] D:\py21>dir oo.txt Volume in drive D is DISCO D Volume Serial Number is 4140-11E0 Directory of D:\py21 OO TXT 0 06-10-01 9:32p oo.txt 1 file(s) 0 bytes 0 dir(s) 354,697,216 bytes free The '2' becomes a program-argument and the redirection is of standard-output anyway. Alex From DavidLNoSpam at raqia.com Thu Jun 14 19:00:59 2001 From: DavidLNoSpam at raqia.com (David Lees) Date: Thu, 14 Jun 2001 19:00:59 -0400 Subject: Simple example of BaseHTTPServer use References: <3B2928F0.A467C8B6@raqia.com> <3b293b80_1@news5.uncensored-news.com> Message-ID: <3B29422B.2A28D7CF@raqia.com> I have his example on page 198 in front of me. But I am puzzled, because the http headers need a line: 'Content-length: (number of bytes in content goes here)', but when I execute an end_headers() before generating content into wfile, how can the correct value go into Content-length? In fact is 'Content-length' even being generated? david lees Doug Fort wrote: > > David Lees wrote: > > > I would like to use the BaseHTTPServer class to handle a PUT and send > > back some http. I am sending the headers back correctly I think, but no > > data appears to be going back. I am probably using the wfile instance > > variable incorrectly. Here is sample code I am working on. > > > > def do_PUT(self): > > self.send_response(200,'\n') > > self.send_header("Content-type", "text/html") > > self.wfile.write('junker goes\nout here\n') > > self.end_headers() > > > > > > > > Thanks in advance. > > > > David Lees > > > I believe you need to call end_headers() before attempting to send any > data. end_headers() writes a blank line which is followed by the data. I > recommend Frederik Lundh's book "Python Standard Library" from O'Reilly, it > has good clear examples and list lists at US$29.95 unlike the bloated $50 > books that line the shelves. > > -- > Doug Fort > Senior Meat Manager > Downright Software LLC > http://www.downright.com > > ______________________________________________________________________ > Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com > With Seven Servers In California And Texas - The Worlds Uncensored News Source > From geoff at homegain.com Tue Jun 5 13:46:19 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Tue, 5 Jun 2001 10:46:19 -0700 Subject: Has anyone used UML? Message-ID: <393D961EA4FCD311B03F00D0B746D65803275E6A@HQSXCH01> I'm told by one recent pop-psychology trend that people have different learning styles -- some do better learning by sight, others do better learning by sound, still others learn better when in motion. I find that doing all three -- drawing little UML widgets on the whiteboard while talking to a colleague -- really unlocks a lot of problems for me, and lets me think through consequences more clearly. I also find that slapping UML widgets together in Visio helps me think about subsystem composition and specific processing tasks. It's a convenient way for me to think from subsystem requirements to specific interfaces and objects. It's pretty rare that the UML I generate makes its way into someone else's hands, let alone into a formal repository somewhere. But it is useful to me; it takes some of the burden of visualization off my short-term memory and puts it onto Visio's shoulders. I used Dia for a while, but grew frustrated with their support for some of the UML I was trying to use (Use case diagrams, at the time); that was several months ago and I heartily recommend investigating Dia, too. I plan to, whenever I get some breathing room between my projects. The O'Reilly Nutshell book has some successes and some failures. It tries to explain both UML and its role in the RUP (Rational Unified Process) without directly talking about RUP. That makes for much deep-wading before you actually get to the part of the book you care about, which is what the little diagramming widgets mean. I've had peers borrow the UML in a Nutshell book because it's got more details, but almost universally, they prefered to cut their teeth on UML Distilled. I read a bunch of the O'Reilly book, and learned some. The majority of the book didn't make sense until I had a couple courses in Rational's engineering process, though. The majority of my UML knowledge came from using Visio and learning by doing. How sad is that? :) Thanks, --G. --- Geoff Gerrietts Software Engineer, HomeGain.com 510-655-0800 x4320 From nperkins7 at home.com Sun Jun 10 01:49:44 2001 From: nperkins7 at home.com (Nick Perkins) Date: Sun, 10 Jun 2001 05:49:44 GMT Subject: New guy question References: Message-ID: ..of course you can also run your program from the >>> prompt: ( in addition to Alex's suggestion: >>>execfile('alook.py') ) >>> import alook ..will effectively 'run' your program. ( actually it loads it into the current namespace, -- more or less the same thing) ( note that you leave of the .py extension ) The file alook.py must be on the sys.path -- another issue ) ..but the next time you will have to type: >>> reload(alook) .. because Python will not import the same thing twice, even if the file has changed. "D-Man" wrote in message news:mailman.992138655.8349.python-list at python.org... > On Sat, Jun 09, 2001 at 11:28:51PM +0000, Glen Mettler wrote: > | I have a small script I entered from a Python book that works when I run it > | using F5. > | However, when I go to the console and enter python alook.py, I get an error > | message: > | > | >>> python alook.py > | SyntaxError: invalid syntax > | > | I am too new to this to know why. > > As Alex indicated, it is not a problem with understanding python. I > have seen that "new" Wintel-PC users often don't know what a shell is. > A "shell" is a prompt provided by the OS to enter commands. On > "Wintel" boxes it used to be called DOS. Now it is either called > "MS-DOS Prompt" or "Command Prompt" and can be found under the Start > menu. On a Unix system their are many different shells, and the shell > is the first thing you will learn. A shell is where you would type > things like "cd" "copy" "del", etc. There you can type "python > alook.py" (assuming alook.py is in the current directory) to run the > program. The prompt (for a DOS shell) is "C:\>" or something similar. > > You have the "Python Interactive Interpreter" there, indicated by the > ">>>" prompt. In this shell-like window you can enter python > statements only. No OS commands are allowed because they aren't > python code. > > If you have any more questions re shells and DOS/Windows feel free to > ask. You may also be interested in the "Tutor" list, > tutor at python.org. > > HTH, > -D > > From tim.one at home.com Sun Jun 24 00:31:15 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 24 Jun 2001 00:31:15 -0400 Subject: New windows case sensitivity in Python 2.1? In-Reply-To: <3b355b8c.16707301@nntp.ix.netcom.com> Message-ID: [Mike Clarkson, on http://python.sourceforge.net/peps/pep-0235.html ] > Thanks Tim, but I think what I'm seeing is not what PEP 235 intended, > or there is an imprecision in the PEP that needs elucidating. > > In my example of trying to 'import _tkinter' failing, when I open a > DOS command window, and change to the Dll's directory, a DIR shows me > > _TKINTER PYD 22,528 06-13-01 10:53p _TKINTER.PYD > > Now the thing that decided _tkinter.pyd should be stored as > _TKINTER.PYD was the M$ installer that put the file there (AS binary), > or my WinZip and/or tar in the case of a source distribution. The correct solution is to point this out to the supplier of whatever it is you're running that created this thing. WinZip doesn't change case, the PythonLabs Windows installer creates _tkinter.pyd with the correct case (and always has, BTW, ever since there was a installer), and I have no personal knowledge of a distribution gimmick lame enough to do this to you. > Needless to say, I think Python should work on Windows no matter > what archiver is used to unpack or install it. I'm not sure what that means, but am reading it as "I think Python should work no matter how badly filename case gets mangled". But it never did, and doesn't now either, except when you set PYTHONCASEOK. 2.1 tightened the rules in the interest of x-platform predictability and portability. > The PEP wanted: it > can't cause any existing non-exceptional Windows import to fail, > because any existing non-exceptional Windows import finds a > case-sensitive match first in the path -- and it still will. In context, that's in the paragraph near the end about the consequences of "rule #B", which isn't relevant here. What you're seeing is mentioned explicitly in the final paragraph: The potential damage is here: #2 (matching on ALLCAPS.PY) is proposed to be dropped. Case-destroying filesystems are a vanishing breed, and support for them is ugly. We're already supporting (and will continue to support) PYTHONCASEOK for their benefit, but they don't deserve multiple hacks in 2001. Case-destroying archivers and installers are also a vanishing breed, but I didn't think that also needed to be said . > but it's now failing because the so-called long file name is all upper > case, due to the archiver/installer. I think for a 'non-exceptional > Windows import' the comparison to 8.3 compliant targets (_tkinter.pyd) > must be first case-INsensitive match, no matter what PYTHONCASEOK is. Believe it or not, yours is the first complaint about this we've gotten. Since it's functioning as designed and as documented, it won't be considered a bug, but you could champion another PEP to add back some kind of Windows hackery here. I would not be in favor of such a PEP, but can't predict how much support it would gather. > When I do a (case sensitive) DOS command in the Dll's directory: > > rename _tkinter.pyd foo > rename foo _tkinter.pyd > > DIR shows me > > _TKINTER PYD 22,528 06-13-01 10:53p _tkinter.pyd > > and the import works, so the import is matching against the long > filename; > ... > Setting PYTHONCASEOK works, but we can't set it on Windows no matter > what archiver is used to unpack or install Python. Why not? Packages can now rely on PEP 235's rules to work across all Python platforms, and some will break if you set PYTHONCASEOK, but some will also break if you just hack the snot out of ALLCAPS.PY. If you want the latter, you have to accept that some packages won't work, and I'm not sure that set isn't identical to the set of packages that fail under PYTHONCASEOK. PYTHONCASEOK will hurt you only if you install packages on the path that contain files whose names differ only in case (which is still unusual); or if you develop code using it and are sloppy about case, then try to port to any other platform. braindead-file-installers-shouldn't-be-fixed-by-the-interpreter-ly y'rs - tim From dsh8290 at rit.edu Mon Jun 18 15:41:41 2001 From: dsh8290 at rit.edu (D-Man) Date: Mon, 18 Jun 2001 15:41:41 -0400 Subject: Any other Python flaws? In-Reply-To: ; from mwh@python.net on Mon, Jun 18, 2001 at 08:10:12PM +0100 References: <3B2A5F6A.5A61183@destiny.com> Message-ID: <20010618154140.A4913@harmony.cs.rit.edu> On Mon, Jun 18, 2001 at 08:10:12PM +0100, Michael Hudson wrote: | D-Man writes: | | > On Fri, Jun 15, 2001 at 02:18:04PM -0500, Michael Chermside wrote: | > | Oh well... at least people don't bump into this one much. And if you | > | accidently clobber it, you can restore things with: | > | | > | def __None(): | > | pass | > | None = __None() | > | > Well, that doesn't work. One of the key features of 'None' is that | > there only ever exists a single instance. This would create a new, | > unique, instance bound to (a more local) 'None'. | | No it wouldn't. Try it! Yeah, he used 'def', not 'class'! | I agree that what Michael posted doesn't really do what he wanted; but | it doesn't do what you said, either. It seems to, with some cursory tests in the interactive interpreter. I would have to look at the source to see _how_ the function implicitly returns 'None' to understand why it doesn't behave as intended. -D From prem at engr.uky.edu Mon Jun 18 20:58:19 2001 From: prem at engr.uky.edu (Prem Rachakonda) Date: 18 Jun 2001 17:58:19 -0700 Subject: fprintf(): Python Equivalent???? Message-ID: HI, Does python have some function which does a formatted file writing functionality similar to C's fprintf(fp,"%s %s",string1, string2); If so, could you please let me know. Prem. From root at rainerdeyke.com Fri Jun 15 00:22:22 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 15 Jun 2001 04:22:22 GMT Subject: profile.run won't run! References: Message-ID: <24gW6.284794$oc7.18522490@news2.rdc2.tx.home.com> "Nick Perkins" wrote in message news:UreW6.237306$eK2.50518869 at news4.rdc1.on.home.com... > I can't get profile.run to work.. > > def solve_problem(): > ...blahblahblah > > solve_problem() # works > exec("solve_problem()") # also works > > but.. > > profile.run("solve_problem()") > > ... > File "c:\python21\lib\profile.py", line 356, in run > return self.runctx(cmd, dict, dict) > File "c:\python21\lib\profile.py", line 362, in runctx > exec cmd in globals, locals > File "", line 1, in ? > NameError: name 'solve_problem' is not defined > > Am I missing something? 'profile' operates on the module '__main__', which is the module of the interactive interpreter and/or the main script. If you are trying to call it from a different module, try profile.run("import module;module.solve_problem()") where 'module' is the name of the module that contains the function 'solve_problem'. Alternately, try this: import __main__ __main__.solve_problem = solve_problem profile.run('solve_problem') This should work even if 'solve_problem' is not in a real module at all. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From nospam at nospam.de Sun Jun 17 14:15:33 2001 From: nospam at nospam.de (Uwe Hoffmann) Date: Sun, 17 Jun 2001 20:15:33 +0200 Subject: Global Namespace References: <9gim6l$2in$1@s1.uklinux.net> Message-ID: <3B2CF3C5.A2E9F6A7@nospam.de> Charlie Dyson wrote: > > This question either has a simple answer, or there is no way to do this at > the moment. I want to be able to set a variable in the global namespace to > a given value. Easy? What if all you have is a string containing the name > of the variable. I need a pointer to the global namespace. So > > class MyClass: > def mymethod(self, varname, varvalue): > setattr(pointer_to_global_namespace, varname, varvalue) i think you can use: globals()[varname] = varvalue instead of setattr(....) > > m = MyClass() > m.mymethod('var', 'ASDF') > print var # Should print 'ASDF' > > Any ideas? Is there a __builtins__ funtion that provides a > reference/pointer/whatever you call it to the global namespace. > > Thanks in advance, > > Charlie Dyson - charlie at charliedyson.net From stain at prigioniero.it Mon Jun 4 11:50:30 2001 From: stain at prigioniero.it (Nicola S.) Date: Mon, 04 Jun 2001 15:50:30 GMT Subject: How to get the size of an object? Message-ID: Is there a way to get the size of an object in Python? I mean something like 'sizeof' C operator... TIA From stevencooper at isomedia.com Thu Jun 28 15:26:08 2001 From: stevencooper at isomedia.com (stevencooper at isomedia.com) Date: Thu, 28 Jun 2001 12:26:08 -0700 Subject: PEP scepticism In-Reply-To: ; from rnd@onego.ru on Thu, Jun 28, 2001 at 08:57:56PM +0400 References: <9hfg1n$du33c$1@ID-89274.news.dfncis.de> Message-ID: <20010628122608.A2556@isomedia.com> On Thu, Jun 28, 2001 at 08:57:56PM +0400, Roman Suzi wrote: > On 28 Jun 2001, Bernhard Reiter wrote: > > >This a general warning against the second system syndrom in Python. > >Maybe I am a hypocritical sceptic, but I have the impression that > >some feeping creatureism is introduced into Python. > >This might reduce the main advantage of Python to be clear and easy > >and mostly have one good formulation on how to express what you want > >to program in a structured way. > > > >Examples are: > > - augmented Assigments > > - Lists comprehensions > > - Simple Generators > > I can't see these as bad things which make Python worse! > If you do not want to use them - please do so. > > ---end quoted text--- FWIW - I totally agree with the original premise. If Python already offers a reasonable way to do something I would vote for not adding an alternative. Keystroke reduction saves the original programmer time. But it costs other people more time when they read the code. The more language idioms that exist to support a particular need the more chance the code reader will have to work harder to understand the code writer. Manditory indentation policy was a brilliant choice, IMO, precisely because it assured that one programmer's style would be readable to another. The same applies to language constructs. The fewer choices that are available the more likely it is that the code-reader will understand the work of the code-writer. Regards, Steve -- \_O< \_O< \_O< ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Steve Cooper Redmond, WA From barry at digicool.com Fri Jun 15 00:26:10 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Fri, 15 Jun 2001 00:26:10 -0400 Subject: Any other Python flaws? References: <9gbe4e$gla$2@newshost.accu.uu.nl> Message-ID: <15145.36451.532484.812954@anthem.wooz.org> >>>>> "MF" == Martijn Faassen writes: MF> This may be considered a minor quibble; the mandatory use of MF> () in case of multiple arguments to the % string interpolation MF> operator: Yup, that one bugs me sometimes too... MF> You also don't seem to have listed the single element tuple MF> wart ...as does this one. The other one that annoys me is the need for backslashes at the ends of lines that are wrapped, but only sometimes. Another one is the fact that you can't mix try/finallys with try/excepts. Also, the fact that you can't write while entry = thingie.next(): And that you're still allowed to write != when you mean <> ... :) Other than the ones you've hit on or have already been fixed (or are in the process of being fixed), most of my other annoyances are with various libraries, but that's not a fault of the language. All in all, pretty minor quibbles. -Barry From phd at phd.fep.ru Wed Jun 20 05:49:04 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Wed, 20 Jun 2001 13:49:04 +0400 (MSD) Subject: rexec works strange... In-Reply-To: <9dab6033.0106200125.252a9673@posting.google.com> Message-ID: On 20 Jun 2001, Ivan wrote: > The following code shows it is possible > to exit a process from rexec code - > is this a bug in python rexec module? > Is there a fix? Do not allow importing sys. Or catch SystemExit exception and do not exit. Or pass stripped sys to the protected code - without exit function. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From whisper at oz.nospamnet Fri Jun 15 23:08:11 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 16 Jun 2001 03:08:11 GMT Subject: New statement proposal for Python References: <9gao5s$8ft$7@216.39.170.247> <9gbsdv$8ft$9@216.39.170.247> Message-ID: <9geiir$324$1@216.39.170.247> In article , philh at comuno.freeserve.co.uk says... > On 15 Jun 2001 02:37:51 GMT, David LeBlanc wrote: > > > >Creating an inherent means of creating constants (or my preferred > >aliases) is good computer science as someone else mentioned in a reply > >post. Magic numbers are bad - they're sloppy programming and a source of > >errors if they must be used in several places etc. OTOH, aliases clarify > >program meaning and imho make things more comprensible to newbies. > > Surely a newbie can understand that if you assign a variable to a > value, and then never change it, then it is working as a constant. > > I have no problem having cxonstants like this, e.g. > > programVersion = "0.2.7" > > it seems to me that: > > alias programVersion: "0.2.7" > > is no clearer, and is an extra something for a learner to have to learn. > Entities should not be multiplied unnecessarily! I absolutely agree that entities shouldn't be multiplied unnecessisarily! However your suggestion in fact does just that: there is nothing that prevents one from reassigning to programVersion in some module you import. Oops... The important difference is that you can't change the replacement text of an alias once set: it's immutable. > > I > >think all would agree that "if something is true:" is clearer then "if > >something is not 0:". > > What's wrong with: > > if something: > > which is what I would use here. Hardly worth mentioning that if (something) is a common source of error in languages like C and C++ where the missing boolean is assumed. > > Likewise, "userpermissions" is much more meaningful > >then 0677 > > Indeed so. And in python, one can say: > > userPermissions = 0677 And in Python, 432 lines later one can say userPermission = 0777 and then scratch one's head as to why file permissions have gone awry. If it where an alias, you'd get a usefull error: Error: attempt to change alias. > (Personally I prefer the way Smalltalk handles non-decimal radixes, > i.e. 8r677) That I can agree with :> > >One can certainly argue that this is syntactical sugar. It does however > >serve a multitude of good purposes among which are: maintainability; > >clarity; consistancy; correctness; good programming habbits; > > When I hear that phrase, I reach for my gun. Go and use Pascal or > Eiffel if you're into bondage-and-discipline. Oh god am I tempted... but i'll refrain. Dave LeBlanc From davehurt at flash.net Wed Jun 13 18:19:00 2001 From: davehurt at flash.net (David Hurt) Date: Wed, 13 Jun 2001 22:19:00 GMT Subject: Python equivalent of CPAN Library modules Message-ID: Hello, Before I begin, I want to state that I am a python AND perl user. I typically prefer python. At last year's python conference, the theme seemed to be "batteries included" referring to the high availability and quality of pre-built functionality in the python standard library. One thing I think may help python is the availability of even more "batteries" in the form of additional modules available. One such source may be the perl CPAN repository. The CPAN has a collection of very high quality libraries for a variety of applications. If these libraries could be converted to equivalent python, then the libraries could be used for python programs :) I think this could be done, as python is roughly equivalent to perl in terms of language features (dynamic structures, regular expressions, hash=dict, array=list, etc). I have even done some things like this before Python->perl conversions and perl->python conversions I have a couple of questions before I start on some grand effort. 1. Has anyone looked at doing something like this before? 2. Would anyone be interested in the results? 3. Is this even a worthwhile effort? I am a part-time grad student and full-time employee. I may use this effort as a project for credit if possible. My general plan is this 1. Examine the CPAN archive and map the Perl modules to equivalent python standard library modules (and contributed modules in the Vaults of Parnassus) (I imagine that this will be a HUGE effort) 2. Get a list of the most commonly requested CPAN modules 3. Convert the highest CPAN module that is not already mapped to python and submit to the Vaults of Parnassus 4. Repeat steps 1-3 until some arbitrary time or until the "most important" 20-30% of the CPAN modules have a python equivalent. I would appreciate any feedback on the practicality/usefulness/etc. of this effort. Thanks, David Hurt davehurt at flash.net From MarkH at ActiveState.com Sat Jun 9 02:43:41 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sat, 09 Jun 2001 06:43:41 GMT Subject: ActivePython and WSH problem References: <3B200C2D.5020701@ActiveState.com> Message-ID: <3B21C5C0.1090708@ActiveState.com> JohnB wrote: > Thanks Mark, that got me working with WSH. > > However, both when executing those commands, and when running the .wsf file, > I get the following warning: > "d:\python21\lib\regsub.py:15: DeprecationWarning: the regsub module is > deprecated; please use re.sub() > DeprecationWarning)" > > It seems that running the .wsf file wants to register something. Do you know > what's up with that? This is a warning that can safely be ignored. The ActiveScripting implementation uses the regsub module, and I need to update it to use re. Infact, I will do this now :) ... Done, and checked into CVS! Mark. From rnd at onego.ru Wed Jun 6 16:08:18 2001 From: rnd at onego.ru (Roman Suzi) Date: Thu, 7 Jun 2001 00:08:18 +0400 (MSD) Subject: Learning OOP... In-Reply-To: Message-ID: On 6 Jun 2001, Rod Weston wrote: >Trying to decide which language to learn first. I have programming >experience in PICKBASIC and now want to learn OOP.At this point, I am >leaning toward learning Ada and then Python. Any ideas on why I >should or should not use these languages in this sequence? Though I am not familiar with Ada very well (it seemed to me very over-weight long time ago), I think that you can learn OOP... by learning Ada and Python in parallel. This way you will be able to see OO* in a broader sense than if you learn something before. Probably, you can also add C++ to the mixture. Oh, yes, and forget Basic ;-) (joking) But it is necessary to remember that OOP is a third phase of OOA-OOD-OOP. Good luck! Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Wednesday, June 06, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Why is the cat sitting on my head?" _/ From aahz at panix.com Tue Jun 5 00:57:31 2001 From: aahz at panix.com (Aahz Maruch) Date: 4 Jun 2001 21:57:31 -0700 Subject: floating point in 2.0 References: Message-ID: <9fhorr$866$1@panix3.panix.com> In article , Michael P. Soulier wrote: > > My apologies if this has been covered. Not only that, it has been covered ad nauseum over the last couple of weeks. Do a Gooja search at http://groups.google.com/ for some relevant info (use "python floating point 2.0") -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Do not taunt happy fun for loops. Do not change lists you are looping over." --Remco Gerlich, comp.lang.python From dnew at san.rr.com Sun Jun 3 14:20:27 2001 From: dnew at san.rr.com (Darren New) Date: Sun, 03 Jun 2001 18:20:27 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3B183CFF.A90213BA@san.rr.com> <9fa54s0fkb@enews2.newsguy.com> Message-ID: <3B1A7FEB.E466824E@san.rr.com> Alex Martelli wrote: > _Complete_ information about how the numbers are generated > requires complete information about the state of their generator. Yep. The fun thing about quantum physics is that *complete* information is available about the state of the generator, and you *still* don't know when the atom will pop. That's exactly what Einstein was complaining about. > Position and velocity vector for each of these atoms are part of > system's state. So, if Heisenber Principle holds, how are you > going to have complete information about this state? Well, that's what quantum physics is all about, isn't it? > If my physical system is designed and considered in ways > that are macroscopic enough to escape uncertainty effects, They can't be. But you can make the probability of something funky happening arbitrarily small. It's still possible all the air in the room will happen to bounce over to the same half at once, but very very unlikely. > Is your claim, then, that "randomness" MUST be used ONLY > for systems which, at the level of observation under discussion, No. The point I'm discussing is that an algorithm cannot generate randomness. No matter how much complexity you add to a mathematical formula, it's still 100% predictable if you know what the formula is. This is untrue of physical random number generators. > Chaotic effects may > well ensure that the number of bits of information that would > be needed to obtain prediction is higher than any practical > measure. In an algorithm, it's never going to be bigger than your seed. > So what is so special, that distinguishes a computer system > from a deck of cards -- considering both systems at a > macroscopic enough level that quantum effects can be > ignored, which is easier for the deck of cards I think but > is commonly done for well-designed computers too:-) -- > so that I *could* get randomness from one and not the > other? You don't get randomness from a deck of cards. You get randomness from *shuffling* a deck of cards. The randomness comes from not knowing exactly what the fingers were doing. If you shuffled the cards algorithmically (e.g., with a mechanical card shuffler that very reliably put them in the same order) then they wouldn't be random at all, *if* you knew exactly how the mechanical card shuffler worked. That's the equivalent of using an algorithm to generate pseudo-random numbers. > It seems more fruitful to me to consider the amount > of information, i.e., a quantitative assessment of randomness, > rather than claim that only if that amount is 'infinite' can > the word 'randomness' be properly used. It depends, again, on which meaning of "random" you want to use. For some folks, "unpredictable" and "random" are two different things. > Taking a set of states and deeming them equivalent can > perfectly well be done -- who ever gets an "exact" number > from physical measurement anyway?! It applies just as > well to the finite definition of randomness. Is fine. If you want to call "unpredictable" and "random" the same thing, power to you. I thought you were trying to understand the Von Neuman quote, not to argue that he's using words you don't like. > > I think "random" here means "unpredictable". Tossing dice will lead to > > random/unpredictable results, even if you know everything there is to > > know about the dice and the table. Generating numbers between 1 and 6 > > will not be unpredictable if you know the seed and algorithm. > > If you have COMPLETE information about the dice &c (taking > a HUGE number of bits, no doubt) you can predict their > trajectories, bounces (if allowed), rolls, AND final results. No. Quantum effects will screw that up. > Why should these macroscopic-physics effect be inherently > unpredictable as you claim? If you start with a pooltable with perfect spheres for poolballs, perfectly racked, you cannot sink all 15 balls with your eyes closed. The probability cloud for the location of the last ball will be larger than the pooltable. > If you have complete information about the algorithm and > the relevant part of the state of the computer where it > runs, again you have predictability. And that's why VN said calling it "random" is sinful. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. This is top-quality raw fish, the Rolls-Rice of Sushi! From brian at sweetapp.com Sun Jun 17 16:52:57 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Sun, 17 Jun 2001 13:52:57 -0700 Subject: __getattr__ and other customization methods Message-ID: <003d01c0f76f$7cf7a990$445d4540@D1XYVL01> Is there any reason why getattr, when called on an instance, should call that instance's __getattr__ method for other customization methods (methods starting with __)? I ask because there are clear advantages in not doing so i.e it prevents potential infinite loop problems when used for proxying, potential problems with the return type of __repr__, etc [1]. I would imagine that there isn't a lot of code out there that depends on receiving __getattr__ calls for customization methods. And there is a lot of code that has to specifically defend against it. So what do you think? Time for a PEP? [1] As a concrete example, both of these problems occur when doing a dir() or print on a PyXSL SOAPProxy instance (I'll submit the fix later). From amartin at wpsnetwork.com Mon Jun 18 11:08:12 2001 From: amartin at wpsnetwork.com (Aurelio Martín) Date: Mon, 18 Jun 2001 17:08:12 +0200 Subject: Problems with urllib References: <3B2DCC2B.B3DCDDD5@nokia.com> Message-ID: <9gl5h4$9ebfo$1@ID-50400.news.dfncis.de> Joonas Paalasmaa escribi? en el mensaje de noticias 3B2DCC2B.B3DCDDD5 at nokia.com... > I get the following error message when trying to open a website with > urllib. > Internet connections are ok and I can access the page with browser. > Platform is WinNT4. > > >>> indexfile = urllib.urlopen("http://www.python.org").readlines() > Traceback (most recent call last): > File "", line 1, in ? > indexfile = urllib.urlopen("http://www.python.org").readlines() > File "c:\python21\lib\urllib.py", line 71, in urlopen > return _urlopener.open(url) > File "c:\python21\lib\urllib.py", line 176, in open > return getattr(self, name)(url) > File "c:\python21\lib\urllib.py", line 283, in open_http > h.putrequest('GET', selector) > File "c:\python21\lib\httplib.py", line 432, in putrequest > self.send(str) > File "c:\python21\lib\httplib.py", line 374, in send > self.connect() > File "c:\python21\lib\httplib.py", line 358, in connect > self.sock.connect((self.host, self.port)) > File "", line 1, in connect > IOError: [Errno socket error] (10060, 'Operation timed out') I just tried the same sentence in my NT4 SP5 system with Python 2.1 and it works. Maybe www.python.org was busy at the time of your request, or your Internet connection was down for a little while. From rcameszREMOVETHIS at dds.removethistoo.nl Mon Jun 11 19:03:27 2001 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Mon, 11 Jun 2001 23:03:27 GMT Subject: [wxPython] layout manager? References: <3B24ADE9.99D61FEE@senux.com.NOSPAM> Message-ID: Brian Lee wrote: > Hi? I'm a newbie at wxPython and this is wxPython specific question. > > Is there any examples of controlling window layout in wxPython? I > read some docs on http://wxpython.org/ but I don't understand it. > And the short examples in the docs do not work. The docs are for C++, and are not 100% accurate for wxPython. Specifically. for wxLayoutContraints I've noticed that "Most constraints are initially set to have the relationship wxUnconstrained, which means that their values should be calculated by looking at known constraints. The exceptions are width and height, which are set to wxAsIs to ensure that if the user does not specify a constraint, the existing width and height will be used, to be compatible with panel items which often have take a default size." is wrong: you need to set the constraints for width and height explicitly to wxAsIs. The wxPython demo is a more reliable source of information and code snippets. > What I actually want is to control size of component in a window. If > user resize the window, the component in the window should be > resized. I think setting a static value for position and size is not > good for my program. Look for wxBoxSizer or wxLayoutConstraints or LayoutAnchor in the documentation. Also check the demo: there are examples to be found in the 'Windows Layout' section. WxLayoutConstraints is the most flexible of the layout managers, wxBoxSizers is fine if you simply want a row or column of things. The one trick wxBoxSizers can do which WxLayoutConstraints lacks is the ability to fix the aspect ratio of a resizable subwindow. Keep in mind that layout managers can be used on multiple levels: you can use wxPanels within wxPanels (or wxFrames) and use autolayout on each of those. Using subpanels can make life a lot easier, and has the added advantage of making your code less cluttered, as each wxPanel only needs to handle those events coming from or addressed to the subwindows or controls on that particular panel. Robert Amesz From greg at cosc.canterbury.ac.nz Wed Jun 20 02:28:13 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 20 Jun 2001 18:28:13 +1200 Subject: PEP 255: Simple Generators References: <3B2EEF5A.8FF0DAFB@cosc.canterbury.ac.nz> Message-ID: <3B30427D.5A90DDE7@cosc.canterbury.ac.nz> Olaf Delgado Friedrichs wrote: > > If I understand correctly, this should work: > > def f(): > for i in range(5): > for x in g(i): > yield x > > def g(i): > for j in range(10): > yield i,j Yes, I realised that shortly afterwards. But I think we're going to get a lot of questions from newcomers who have tried to implicitly nest iterators and are very confused about why it doesn't work and what needs to be done to make it work. An explicit generator definition syntax would help here, I think. First of all, it would be a syntax error to use "yield" outside of a generator definition, so they would be forced to declare the inner one as a generator. Then, if they neglected to make the outer one a generator too, it would look like this: def f(): for i in range(5): g(i) generator g(i): for j in range(10): yield i,j from which it is glaringly obvious that f() is NOT a generator, and therefore can't be used as one. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From Eugene.Leitl at lrz.uni-muenchen.de Thu Jun 28 07:34:36 2001 From: Eugene.Leitl at lrz.uni-muenchen.de (Eugene Leitl) Date: Thu, 28 Jun 2001 13:34:36 +0200 (MET DST) Subject: [Mojonation-devel] need good entropy gathering under win32 (fwd) Message-ID: -- Eugen* Leitl leitl ______________________________________________________________ ICBMTO : N48 10'07'' E011 33'53'' http://www.lrz.de/~ui22204 57F9CFD3: ED90 0433 EB74 E4A9 537F CFF5 86E7 629B 57F9 CFD3 ---------- Forwarded message ---------- Date: Wed, 27 Jun 2001 18:27:25 -0700 From: zooko at zooko.com Reply-To: mojonation-devel at lists.sourceforge.net To: mojonation-devel at lists.sourceforge.net Subject: [Mojonation-devel] need good entropy gathering under win32 Could some clueful win32 hacker, please see `randsource.py'[1] and give it a strong source of randomness (we just need an initial seed of 160 bits). Here is an article saying how to do it: [2] Thanks! Zooko [1] http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/~checkout~/mojonation/evil/common/crypto/Python/randsource.py?content-type=text/plain [2] http://now.cs.berkeley.edu/~daw/rnd/cryptoapi-rand _______________________________________________ Mojonation-devel mailing list Mojonation-devel at lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/mojonation-devel From JamesL at Lugoj.Com Tue Jun 26 20:06:23 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Tue, 26 Jun 2001 17:06:23 -0700 Subject: PEP 260: simplify xrange() References: Message-ID: <3B39237F.1A7EF3F2@Lugoj.Com> Guido van Rossum wrote: > Here's another sweet and short PEP. What do folks think? Is > xrange()'s complexity really worth having? Are there still known bugs that will take some effort to repair? Is xrange constantly touched when changes are made elsewhere? If no to both, then I suggest don't fix what ain't broken; life is too short. (Unless it is annoying you to distraction, then do the deed and get it over with.) From whisper at oz.nospamnet Fri Jun 1 17:30:46 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 1 Jun 2001 21:30:46 GMT Subject: Can Python be used for UTF/Double Bytes/Asian Characters? References: <5f28b650.0105310946.1298918b@posting.google.com> Message-ID: <9f91i6$qf5$0@216.39.170.247> In article <5f28b650.0105310946.1298918b at posting.google.com>, akiyomiya at hotmail.com says... > Does Python have a module or some sort of class that can be used for > UTF/Double Bytes/Asian Characters? > > I heard that Perl has a module that you can use for UTF/Double > Bytes/Asian Characters. So I am wondering if Python works same way or > better. > > We are modifying a search (Inktomi), so people can input UTF/Double > Bytes/Asian Characters and search for some documents. > > Thank you in advance. > > AK > I don't know about DBCS or Asian characters, but Unicode is a standard feature in Python 2.0 (and maybe also Python 2.0, but i'm only sure about 2.1). I don't know if the regular expression stuff has been made unicode aware or not. If not, then you might want to look into Tcl, which does have a complete Unicode implementation, including regular expressions. >From reading stuff in the comp.lang.tcl newsgroup, Tcl seems quite well regarded in the Asian language community. Hopefully Python will suit you though. Dave LeBlanc From dsh8290 at rit.edu Wed Jun 20 12:22:39 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 20 Jun 2001 12:22:39 -0400 Subject: qt or gtk? In-Reply-To: ; from noselasd@frisurf.no on Wed, Jun 20, 2001 at 02:52:26PM +0200 References: Message-ID: <20010620122239.D7492@harmony.cs.rit.edu> On Wed, Jun 20, 2001 at 02:52:26PM +0200, Nils O. Sel?sdal wrote: | | "D-Man" wrote : | | > wxWindows and wxPython look nice, though I haven't worked with them | > enough to know if I like the style of the interface. | | It looks like MFC to me, and MFC is NOT nice... I was talking about the API, and I have never used MFC, so I can't comment there. If you mean the user interface (ie the pixels drawn on-screen)? If so, then you are correct, but only if you are using MS Windows and wxMFC. (I suppose one could build wxGTK on MS Windows using GTK for windows, or an appropriate X server) wxWindows provides an API that is constant, regardless of platform. That API is then implemented in terms of the platform's native toolkit (wxMFC, wxGTK, wxMotif, wxMac, others?). The end result is application (your) code that is portable and a look-and-feel that is (almost) identical to the native look-and-feel. -D From chrishbarker at home.net Thu Jun 21 15:43:35 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 21 Jun 2001 12:43:35 -0700 Subject: Subject: ?Numpy: number of elements in an array? References: <1grY6.4168$yp1.152397@www.newsranger.com> Message-ID: <3B324E67.438DF950@home.net> Norman Shelley wrote: > In Numpy how does one get the number of elements in an array? > > This seems to do it > reduce(mul, a.shape, 1) A little simpler: product(a.shape) or: len(a.flat) > but shouldn't there be a straight forward, function/method to do it? maybe, but it is probably pretty rare to want to know the number of elements without needing to know the shape. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From gardner at cardomain.com Tue Jun 5 16:52:18 2001 From: gardner at cardomain.com (Jonathan Gardner) Date: Tue, 5 Jun 2001 13:52:18 -0700 Subject: Obsolesence of <> (fwd) References: <9f6el30dv5@enews2.newsguy.com> <3B16D681.E12A4554@Lugoj.Com> <9f7pmt029se@enews1.newsguy.com> <3B17D9B9.E3CA8EC8@Lugoj.Com> Message-ID: <9fjgjl$rp0$1@brokaw.wa.com> James Logajan wrote: > Alex Martelli wrote: >> The "pseudo-mathematical" ideas being those based on < and > which >> Lulu just proposed? Well then, if those ideas have any worth, then, >> GIVEN (as decided by the BDFL) that < and > don't apply, neither >> must <>. The only "justification" needed for != is: SOME inequality >> operator is needed, and it must definitely not be <>, which WRONGLY >> suggests analogies to < and >. > > Shrug. You haven't made a specific case for "!=". I say that one may segue > from "<>" as applied to simple numbers, to application to sets of other > things where "<>"'s semantic historical origins aren't as valid. You seem > to insist that any hint of properties in the notation used for real > numbers should not be used for analogous operations on other sets or > groups. I say that is contrary to how mathematical and programming > notation evolves to best suit programmers. Consider for a moment > multiplication. On real numbers the operation is commutative. On matrices > it is not. (And it is computationally more involved.) Yet the same > multiplication symbol or notation may be used in both cases. Even in > Python a symbol like "*" may be applied to a number and a string with a > non obvious meaning. But "+" may not be applied to a mix of strings and > numbers. By the way, do you object to "+" used for string concatenation? > (This WRONGLY suggests an analogy to numeric addition.) If not, why is it > okay to take "+" or "*" and put them to use for things that are not > numbers, but it is not okay for "<>"? > >> "There should be one, and ideally only one, obviously correct way >> to do something". Having two entirely synonymous operators is >> unPythonic. It's an ideal, of course, not a practical reality -- >> pow(x,y) vs x**y, apply(spam,args) vs spam(*args), etc, shows that >> multiple ways to "do something" can and will survive in Python >> (particularly for legacy/historical reasons). It's still a worthy >> ideal to aim at, in my humble opinion. Okay, drawing on your example of matrices and such, and taking the statement that There Is NOT More Than One Way To Do It: In mathematics, there are several ways to write multiplication. And, in some cases, they have different meanings. In grade school, we learned 'x' means multiply. In Junior High School and High School, we were taught that "ab" means "a x b" and "a . b" means "a x b". (The period should be a dot.) Then, in Vector Calculus, I was taught that "x" (cross products) and "." (dot products) mean two different things. In fact, because of the last property of multiplication, you can't write a general multiplication function for vectors. You have to implement two seperate methods. So, taking the argument back to <> and !=: Maybe we should decide that <> means "greater than or less than" and != means "not equals to, or not ==". Therefore, you can ensure that noone tries to <> two complex numbers, but they certainly can != two complex numbers. These two things, in math at least, are two different things. You will never catch a mathematician writing "Vector A <> Vector B" because it doesn't make sense. But, in the end we are limited by ASCII. Hopefully, when everyone uses unicode editors, and when they figure out how to get their keyboard to work properly, we can adopt a more mathematical terminology, and include several more operators that aren't in ASCII (like the dot for dot product). In the end, shouldn't we try to make what is written in the program as legible to mathematicians as possible? I mean, the closer the language stays to math, the more logical it will be. From matt at sergeant.org Tue Jun 5 13:38:14 2001 From: matt at sergeant.org (Matt Sergeant) Date: Tue, 05 Jun 2001 18:38:14 +0100 Subject: PYML, Python, Perl and Zope References: Message-ID: <3B1D1906.90272E2C@sergeant.org> John Abbe wrote: > > PYML looks very neat for web delivery (Python embedded in HTML). > > http://www.pyml.org/ > > With Python 2.1 does it still need the SGML thing? > > Is there anything like it for Perl? Along with the other suggestions here, don't forget to check out AxKit (there's a similar project for Python that is still quite early in the development stages, but I forget it's name). AxKit is designed for developing sites designed to be delivered to different devices, or in different styles. It's pretty similar to the Apache Cocoon project. PS: Please don't cross-post to both the perl and python newsgroups. Pick a newsgroup you want to hear from and post there. Follow-ups set. -- /|| ** Founder and CTO ** ** http://axkit.com/ ** //|| ** AxKit.com Ltd ** ** XML Application Serving ** // || ** http://axkit.org ** ** XSLT, XPathScript, XSP ** // \\| // ** mod_perl news and resources: http://take23.org ** \\// //\\ // \\ From emile at fenx.com Fri Jun 1 10:28:30 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 1 Jun 2001 07:28:30 -0700 Subject: Returning 'None' on Instantiation ? References: Message-ID: <9f891j$2o2mf$1@ID-11957.news.dfncis.de> The Object self is created before __init__ populates it and survives __init__. You could use __nonzero__ to meet your example's needs: >>> class myClass: def __init__(self, arg): self.isValid = 1 if arg < 5: self.isValid = 0 def __nonzero__(self): return self.isValid >>> a = myClass(3) >>> if a: print "OK" >>> b = myClass(8) >>> if b: print "OK" OK >>> HTH, Emile van Sebille emile at fenx.com --------- ----- Original Message ----- From: "Dave Haynes" Newsgroups: comp.lang.python Sent: Friday, June 01, 2001 6:28 AM Subject: Returning 'None' on Instantiation ? > Is there a way to optionally return 'None' on instantiation? I'm > thinking of something like the following: > > class myClass: > def __init__(self, param): > > if : > > else: > > > > myParam = GetParam() > myObj = myClass(myParam) > > if myObj: > print 'Okay' > else: > print 'Couldn't make myObj from myParam' > > This is a fairly common state of affairs. If there's nothing specific > in Python to accomodate this, what methods are considered robust by > this NG? > > > Best Regards, > > > Dave. From aleaxit at yahoo.com Mon Jun 4 03:16:12 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 4 Jun 2001 09:16:12 +0200 Subject: random References: Message-ID: <9fflo602q4r@enews2.newsguy.com> "Laura Creighton" wrote in message news:mailman.991632672.19827.python-list at python.org... > Gang, you have forgot what I said about sampling error. Lets try a different > thought experiment. > > If you decide to go north or south based on whatever train arrives > first, randomly arriving at the train station will not help you because > if the trains run 1 an hour and at the 00 going n and the 10 going s > you are 5 to 1 more likely to find the next train is north no matter > how crazy your work schedule is. I'm not sure what you mean by "won't help you" in this context (I think I've missed a post of yours since I don't recall the sampling error reference). Under your posited conditions, it seems to me that, if you can arrive at the station at any time with a uniform distrib., then p(N)=5/6, p(S)=1/6. Instead of 1 full bit of information, then, your going North or South will carry: -log2(5/6) = 0.263 when you go N (5/6 of the time), -log2(1/6) = 2.585 when you go S (1/6 of the time) with an expected value of (5/6)*0.263+(1/6)*2.585 = 0.65 bits of information. I'm not sure if this satisfies any given definition of "perfectly random", because it seems to depend entirely on the definition. In a sequence of such N/S bits there will be some weak 'pattern' (of order 0) making them carry less than 1 bit of information (unpredictability, "surprise") each, but no other (on the thought experiment as given). Starting from a analysis of lot of such bits, an observer can estimate the 5/6 probability and therefore predict future bits (probabilistically) better than if the distribution was uniform. But it still takes an amount of information O(N) to compress a sequence of N such bits, we just have a slightly lower multiplicative constant than if the two outcomes were equally likely. We could presumably compress a million such bits into 650,000+K' bits where K' does not depend on the number of bits being compressed (it's the size of the program stricto-sensu doing the decoding of the compressed stream, by Huffman or whatever). Alex From aleaxit at yahoo.com Wed Jun 6 18:04:37 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 7 Jun 2001 00:04:37 +0200 Subject: floating point in 2.0 References: <3B1E50C9.7D2509F4@shore.net> <9flkoi$ofu$1@panix2.panix.com> <3B1E6A67.2B33C197@shore.net> Message-ID: <9fm9kg05qs@enews1.newsguy.com> "Kurt B. Kaiser" wrote in message news:3B1E6A67.2B33C197 at shore.net... ... > As I recollect from my APL days, there was a FUZZ factor which could > be set to control the comparison. It would be nice if Python could > overload == with something like that when comparing floats. Yeah, and let's put a quad-IO (nothing to do with I/O -- it used to change Index Origin!) in it too...:-( I did most of my thesis work in APL (then had to redo it in Fortran and Assembler, but that's another story) and used APL2 heavily later (in IBM Research), and I recall those darned globals that broke my routines when used in somebody else's workspaces as the worst blights on an otherwise interesting language (if you had the right terminal/keyboard/typewriter ball/&c:-). Alex From skip at pobox.com Thu Jun 21 09:02:28 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 21 Jun 2001 08:02:28 -0500 Subject: Line Coverage Analyser In-Reply-To: <02r3jtco1lmi7foqu5a7lt34kor6v631tg@4ax.com> References: <02r3jtco1lmi7foqu5a7lt34kor6v631tg@4ax.com> Message-ID: <15153.61540.995462.996100@beluga.mojam.com> Lothar> Is there something like TrueCoverage from Numega to do this with Lothar> Python programs. Take a look at the Tools/scripts/trace.py script in recent Python distributions. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From steve at hkit.net Mon Jun 25 12:25:29 2001 From: steve at hkit.net (Steve S.L. Wong) Date: Tue, 26 Jun 2001 00:25:29 +0800 Subject: Can anyone build ExtensionClass.c using Borland compiler? References: <92ae279c.0106211619.44db8b47@posting.google.com> Message-ID: python setup.py build --compiler=bcpp works on the version of ZODB that I later downloaded from sourceforge site. Thanks John. "John Machin" ????? news:92ae279c.0106211619.44db8b47 at posting.google.com... > "Steve S.L. Wong" wrote in message news:... > [snip] > > But this fails: > > > > Error: Unresolved external '__Py_DeAlloc' referenced from > > C:\PYTHON21\ZODB\ZODB\EXTENSIONCLASS\SRC\EXTENSION.OBJ > > Is this an *EXACT* cut-and-paste of the error message? > > C:\Python21\include>grep -i _py_dealloc *.h > object.h:extern DL_IMPORT(void) _Py_Dealloc(PyObject *); > object.h:#define _Py_Dealloc(op) ((op)->ob_type->tp_free++, > (*(op)->ob_type->tp_ > dealloc)((PyObject *)(op))) > object.h:#define _Py_Dealloc(op) > (*(op)->ob_type->tp_dealloc)((PyObject *)(op)) > object.h: _Py_Dealloc((PyObject *)(op)) > object.h: _Py_Dealloc((PyObject *)(op)) > > ===> There is no two-leading-underscores-and-capital-A function/macro > in the > include files. There is a one-leading-underscore-and-lowercase-a > variety. The extra underscore is added on the trip from .c to .obj but > Borland don't change the case of your letters! If the source actually > has 'A', then while awaiting better advice, you may like to try it > with the 'A' changed to an 'a'. > > Otherwise you have a number_of_underscores problem ... sorry, can't > help, this is black magic to me. > > However here's a very potent white magic spell: use the distutils kit > to build your extensions. It saves all the mucking about with weird > Borland command-line syntax, makefiles, etc. Once you've created a > 'setup.py' (which itself becomes good documentation!) for each > extension, extensions just *build*. > > DOS-prompt> python setup.py build --compiler=bcpp > > This is documented in the 'Installing Python Modules' manual. > > Hope this helps, > John From syring at email.com Sat Jun 23 11:09:07 2001 From: syring at email.com (Karl M. Syring) Date: Sat, 23 Jun 2001 17:09:07 +0200 Subject: Changing the PDF Info-block References: <9h1ro8$bk9vc$1@ID-3710.news.dfncis.de> Message-ID: <9h2bel$bblq4$1@ID-7529.news.dfncis.de> schrieb > Hi there! > I want to change the Info-Block (Author, Title...) of PDFs I already created > with Ghostscript. I didn't find any freeware tool for this and thought that > perhaps it can be done with Python. Thew only free solution I know of is the Etymon PJ (http://www.etymon.com/pj/). It is written in Java, but even this may not be a showstopper. Karl M. Syring From pfortin at pfortin.com Thu Jun 7 15:39:05 2001 From: pfortin at pfortin.com (Pierre Fortin) Date: Thu, 07 Jun 2001 15:39:05 -0400 Subject: expat not found...? Message-ID: <3B1FD859.E1649F7D@pfortin.com> Compiled 2.1 on Linux Mandrake 7.2 system (incl expat)... ... gcc -fPIC -g -O2 -Wall -Wstrict-prototypes -I. -I./Include -DHAVE_CONFIG_H -I/usr/local/src/Python/expat/xmlparse -c ./Modules/pyexpat.c -o Modules/pyexpat.o gcc -shared Modules/pyexpat.o -L/usr/local/src/Python/expat -lexpat -o Modules/pyexpat.so ... Yet, when I run a sample script (from http://www-106.ibm.com/developerworks/xml/library/l-pxml.html?open&l=912,t=grx,p=xpyth)... xmlsaxtest.py: "Simple SAX example, updated for Python 2.0+" import string import xml.sax from xml.sax.handler import * class QuotationHandler(ContentHandler): ... it won't even get past the imports... Traceback (most recent call last): File "xmlsaxtest.py", line 3, in ? import xml.sax File "xml.py", line 1, in ? import _xmlplus.parsers.expat ImportError: No module named _xmlplus.parsers.expat Probably missing something obvious/subtle; but... There is no README file in the expat distribution; though I imagine it needs to be installed somewhere... if so, what goes where precisely...? Thanks, Pierre PS: here are the files I have in expat: # ll -R | grep -v \\.[hco] | grep -v \/$ .: total 154 -rw-r--r-- 1 pfortin pfortin 1190 May 9 2000 Makefile -rw-r--r-- 1 pfortin pfortin 1398 Aug 17 2000 expat.dsw -rw-r--r-- 1 pfortin pfortin 141176 Jun 2 10:26 libexpat.a ./bin: total 183 -rw-r--r-- 1 pfortin pfortin 53248 May 21 2000 xmlparse.dll -rw-r--r-- 1 pfortin pfortin 81920 May 12 2000 xmltok.dll -rw-r--r-- 1 pfortin pfortin 49152 May 21 2000 xmlwf.exe ./gennmtab: total 30 -rwxr-xr-x 1 pfortin pfortin 15594 Jun 2 00:52 gennmtab* -rw-r--r-- 1 pfortin pfortin 3718 Oct 22 1998 gennmtab.dsp ./lib: total 42 -rw-r--r-- 1 pfortin pfortin 29496 May 21 2000 xmlparse.lib -rw-r--r-- 1 pfortin pfortin 12042 May 12 2000 xmltok.lib ./sample: total 3 -rw-r--r-- 1 pfortin pfortin 245 Jun 21 1998 build.bat ./xmlparse: total 308 -rw-r--r-- 1 pfortin pfortin 141176 Jun 2 00:52 libexpat.a -rw-r--r-- 1 pfortin pfortin 7056 May 12 2000 xmlparse.dsp ./xmltok: total 256 -rw-r--r-- 1 pfortin pfortin 5909 Aug 17 2000 xmltok.dsp ./xmlwf: total 190 -rwxr-xr-x 1 pfortin pfortin 126852 Jun 2 00:52 xmlwf* -rw-r--r-- 1 pfortin pfortin 4554 May 12 2000 xmlwf.dsp From t_messmer at yahoo.com Wed Jun 13 22:21:37 2001 From: t_messmer at yahoo.com (Tom Messmer) Date: Wed, 13 Jun 2001 19:21:37 -0700 Subject: os.statvfs on FreeBSD References: Message-ID: <20010613.192137.1977648522.11910@pozzo.endpage.com> By the way, The module statvfs.py is in the directory /usr/lib/python20/ which is in my PYTHONPATH. Just can't tell why its not loading... Tom In article , "Tom Messmer" wrote: > For some reason the default installation of python-1.5 and Python-2.0 on > FreeBSD(From the ports collection) does not include the os.statvfs() > routine. Does anyone know A. Why? and B. How to fix it? I need this > thing! > Thanks! > Tom From cce at clarkevans.com Sat Jun 2 13:06:51 2001 From: cce at clarkevans.com (Clark C . Evans) Date: Sat, 2 Jun 2001 12:06:51 -0500 Subject: Inexact representation cases (Re: Against PEP 240) In-Reply-To: ; from grante@visi.com on Sat, Jun 02, 2001 at 03:53:08PM +0000 References: <9f273c21ar5@enews2.newsguy.com> Message-ID: <20010602120651.A26639@doublegemini.com> On Sat, Jun 02, 2001 at 03:53:08PM +0000, Grant Edwards wrote: | >| >>> 1.1 | >| 1.1000000000000001 | >| >>> 7.35 | >| 7.3499999999999996 | > | >What is the general pattern for these types of inexact | >represenatation? | | 1/10 (base 10) is not representable in a finite base-2 number, | in the same way that 2/3 is not representable in a finite | base-10 number. | | The same goes for 35/100 *slaps hand against head and says "Duh!"* Thanks! Clark From xyzmats at laplaza.org Sat Jun 9 16:16:56 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Sat, 09 Jun 2001 20:16:56 GMT Subject: How do you develop in Python? References: <050620011516094693%pecora@anvil.nrl.navy.mil> <9fjfer$gt0$1@nereid.worldonline.nl> <3B2129AC.90BA8650@home.net> Message-ID: <3b228429.13792672@news.laplaza.org> >2) All three of these IDEs (and others, I'm sure) use the same >interpreter to run the IDE as the program you are working on. If you >were to "clear all" you'de wipe out the IDE as well. I'd lke to see an >IDE that used a separate copy of the interpreter, but it would make >writting a debugger (and other introspective tools) a lot harder. I believe this is somewhere around the corner. Of course, since I can't /see/ around the corner, I don't know how far away it actually is. -- mats From aleaxit at yahoo.com Fri Jun 1 04:17:12 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 1 Jun 2001 10:17:12 +0200 Subject: a sample code References: <9f7dki$29n$1@diana.bcn.ttd.net> Message-ID: <9f7j2a01nu3@enews1.newsguy.com> "Abel" wrote in message news:9f7dki$29n$1 at diana.bcn.ttd.net... > HI: > > I'm looking for a sample of code of a simple HTTP Server in Python.(i want > just the basic code) > Where can I find it ? d:\Python21\Lib\SimpleHTTPServer.py, if d:\Python21 is the directory to which you have installed Python 2.1 (adjust accordingly if you have installed it elsewhere:-). You'll need to also look at the class used as the base for class SimpleHTTPRequestHandler defined in that source file, of course -- so, see Lib\BaseHTTPServer.py, and you'll see that, in turn, subclasses stuff from the SocketServer.py source in the same directory. I consider this setup in the Python library an EXCELLENT simple example of object-oriented design, btw. Alex From opengeometry at yahoo.ca Sat Jun 2 13:48:37 2001 From: opengeometry at yahoo.ca (William Park) Date: Sat, 2 Jun 2001 13:48:37 -0400 Subject: What does x[:]=[4,5,6] mean? In-Reply-To: <9fb7cu$lq6$1@newsreaderg1.core.theplanet.net>; from fgeiger@datec.at on Sat, Jun 02, 2001 at 07:22:25PM +0200 References: <9fb7cu$lq6$1@newsreaderg1.core.theplanet.net> Message-ID: <20010602134837.A826@node0.opengeometry.ca> On Sat, Jun 02, 2001 at 07:22:25PM +0200, Franz GEIGER wrote: > In site.py I saw > sys.path[:] = L This copies L[0], L[1], ... to sys.path[0], sys.path[1], ... respectively. > What does this mean? Why is the '[:]'? Why not simply > sy.path = L ? This assigns "variable id" of L to sys.path. So, when you access 'sys.path' next time, it will access what 'L' will access. -- William Park, Open Geometry Consulting, 8 CPU cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc. From tjreedy at home.com Sat Jun 30 12:58:41 2001 From: tjreedy at home.com (Terry Reedy) Date: Sat, 30 Jun 2001 16:58:41 GMT Subject: Support for "wide" Unicode characters References: Message-ID: <5zn%6.2300$Z6.1039816@news1.rdc2.pa.home.com> > Code point > > If you imagine Unicode as a mapping from integers to > characters, each integer represents a code point. Some are > really used for characters. Some will someday be used for > characters. Some are guaranteed never to be used for > characters. I find this ambiguous. Is 'codepoint' a synonym for integer (in range 0 to MAX)? or just for integer that does or might someday represent a character? Does 'some' (in all three uses) refer to integers or codepoints? From gerson.kurz at t-online.de Tue Jun 26 09:42:50 2001 From: gerson.kurz at t-online.de (Gerson Kurz) Date: Tue, 26 Jun 2001 13:42:50 GMT Subject: Threads, Callbacks, Classes [Long] Message-ID: <3b3889b9.530187@news.t-online.de> I want to implement a wrapper for an asynchronous API in win32, that uses window messages for completions. Wrapping synchronous functions from a DLL seems to work easily enough, but I have serious trouble with the asynchronous ones. Question 1a: I would like to make sure I understand how to properly issue a python callback. Here is my C code: --- cut here --- static PyObject* func_TestCallback(PyObject* self, PyObject* args) { PyObject* callback; if( !PyArg_ParseTuple(args,"O",&callback) ) { PTrace( "ERROR, PyArg_ParseTuple() failed" ); return NULL; } PyObject_CallFunction(callback,"s","It worked !"); return Py_None; } --- cut here --- and this is how I can issue the callback from Python: --- cut here --- import pxfs def myfunc(x): print x pxfs.TestCallback(myfunc) --- cut here --- This seems to work. Its not asynchronous yet, but at least the function gets called. However, I have a feeling I should somehow deal with the returncode of PyObject_CallFunction ? Question 1b: As a followup on this, the code doesn't seem to work if I give a member function: --- cut here --- import pxfs, Queue msgport = Queue.Queue() pxfs.TestCallback(msgport.put) --- cut here --- I would expect that the callbacks puts a message in the queue, but it doesn't seem to work: no message is received when I later ask msgport.get(). Question 2A: How to issue a callback from another thread. The same code shown above doesn't work if issued from another thread (a thread that has not been created by python, but by the asynchronous API). I have found a way to get it "partially" to work - my callback gets called - but eventually the python interpreter bails out with thread state errors. I didn't quite get the (meager) documentation on this. This is what I do: - When requesting the function, I save PyThreadState_Get()->interp - In the thread, I do --- cut here --- // m_ips is the interpreterstate saved from another thread PyThreadState* pts = PyThreadState_New(m_ips) PyEval_AcquireThread(m_pts); PyObject_CallFunction(m_callback,"s","It Worked"); PyEval_ReleaseThread(m_pts); --- cut here --- - In the python program, I do --- cut here --- import pxfs, Queue msgport = Queue.Queue() def sendmessage(x): global msgport print "SENDMESSAGE CALLED USING", x msgport.put(x) # This will start a NT native thread and do the # code shown above pxfs.TestDeferredCallback(sendmessage) while 1: msg = msgport.get() print "GOT MESSAGE", msg --- cut here --- I see the "SENDMESSAGE CALLED USING" bit, and then an invalid thread state occurs. - Question 2B: Do I have to call PyThreadState_Delete() at some point? - Question 2C: Is there a more elaborate discussion on this topic (Threads & Callbacks in Python) available somewhere on the net ? Question 2D: Is my approach maybe completely wrong ? My problem is: the existing API drives hardware. The hardware functions can take a long time (several minutes), during which normal user input should be possible. On Windows, you have a message queue and you have to manually keep this alive to wait for async completions. I could use win32api style window handles for the message processing, but the code would quickly become as messy as it is in C. (A windows message has two longs as parameters - thats it). I would love to use the Queue.Queue mechanism, because it allows for much more "elaborate" messages, but Queue.Queue seems to block the windows message queue (its probably implemented using semaphores and not window handles ?). Also, I later would like to add some wxPython GUI to it. AFAIK callbacks would suit that framework best. Question 3: How to export classes Exporting functions from an extension DLL is easy enough. How do I export classes ? Exporting types seems to work (I tried the example from the docs) but I don't see where I would add my class members to a custom type. From greg at cosc.canterbury.ac.nz Mon Jun 25 01:54:40 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Mon, 25 Jun 2001 17:54:40 +1200 Subject: Pythoin MUD (PyMUD?) References: <9gqq3t$hvs$1@brokaw.wa.com> Message-ID: <3B36D220.52C5CB86@cosc.canterbury.ac.nz> Remco Gerlich wrote: > > you need only one drunken wizard to > code an infinite loop, and your driver locks up. I haven't found a solution > yet Stackless could be a solution. Pre-emptively scheduled microthreads. Your drunken wizard's code still runs forever, but other things can happen at the same time. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From dnew at san.rr.com Mon Jun 4 13:16:17 2001 From: dnew at san.rr.com (Darren New) Date: Mon, 04 Jun 2001 17:16:17 GMT Subject: I NEED to TEACH you something, QUICK! References: <9ffreg$j4s$1@neon.noos.net> Message-ID: <3B1BC263.EB9C14CD@san.rr.com> Boyd Roberts wrote: > i don't think she's suffering from mania so lithium is unlikely. > nor from psychotic episodes. A shame there's no over-the-counter drug to help with off-topic postings. ;-) -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. This is top-quality raw fish, the Rolls-Rice of Sushi! From karmen2001 at HOTMAIL.COM Wed Jun 6 15:20:26 2001 From: karmen2001 at HOTMAIL.COM (mik) Date: Wed, 6 Jun 2001 21:20:26 +0200 Subject: Has anyone used UML? References: <9flodi$32m$1@brokaw.wa.com> Message-ID: <9flvpp$cj6$1@news.tudelft.nl> i think that you have to use ArgoUML is free.......... and you can understand why use uml .www.argouml.com "Elf Sternberg" wrote in message news:9flodi$32m$1 at brokaw.wa.com... > In article > Harald Hanche-Olsen writes: > > >+ Tim Churches : > > >| No experience (I am in a similar situation to you wrt UML), just > >| some advice: don't buy the O'Reilly book 'UML in a Nutshell' - it is > >| the only O'Reilly title I have encountered which is truly woeful > >| (most are quite good). > > >Hmm. Has it occured to you that this might be a reflection on UML > >rather than on the book per se? > > No, it's true. The UML book by O'Reilly is atrocious. The > author tries *so hard* to convince the reader that UML is not about > modelling programs but about modelling "business practices" that he goes > overboard avoiding programming examples. The author also seems to > introduce topics at random without going through the process of actually > creating a model for the user to use. > > The big problem I have with UML is that it's owned, lock, stock > and barrell, by Rational Rose. Every book I have seen on the subject > cheerleads Rational Rose products and makes it sound like, "yes, you can > do it without Rational Rose, but you can also build a computer with > tinkertoys. Why do that when we'll give your our > superduperdeluxeUMLpackage for only $79,999.95?" > > UML is nothing more than a simple way of describing program > models. Two of the better books I've seen on the subject are "A UML > Pattern Language" (totally buzzword compliant, but the concise summary > of "what UML is" in part 1 and the "best UML practices" collection in > part 2 were worth it) and "Building Web Applications with UML" (again, > because the summary is precise and maybe because appservers are my field > of specialization), but the latter is a Rational cheerleader. > > Oddly, it's the little things that help. I didn't really grok > the relationship between a Use Case and a Sequence Diagram until someone > told me "In a sequence diagram, the vertical bar is the lifetime of an > instance; the horizontal bars are applications of a use case." And then > a lot of the OO stuff I'd been using for years clicked. > > ... and then it was time to refactor. :-) > > Elf > > -- > Elf M. Sternberg, rational romantic mystical cynical idealist > http://www.halcyon.com/elf/ > > Dvorak Keyboards: Frgp ucpoy ncb. ru e.u.bo.v From amartin at wpsnetwork.com Mon Jun 18 13:29:57 2001 From: amartin at wpsnetwork.com (Aurelio Martín) Date: Mon, 18 Jun 2001 19:29:57 +0200 Subject: Setting Dialog Box Captions ?? References: Message-ID: <9gldqt$9gkgf$1@ID-50400.news.dfncis.de> Peter Moscatt escribi? en el mensaje de noticias mQlX6.140495$ff.1066592 at news-server.bigpond.net.au... > How does one place a "Title" in the master frame ? > > For example, if I was to have the following code: > > from Tkinter import * > root=Tk() > w=Label(root, text="Hello World") > w.pack() > root.mainloop() > > And now I wanted to place "This is My Test Dialog" as the caption for the > root frame - how would I doo this ? > > Regards > Pete > > root.title( "This is My Test Dialog" ) From xyzmats at laplaza.org Sat Jun 9 16:18:12 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Sat, 09 Jun 2001 20:18:12 GMT Subject: Jython's tutorial. Where? References: Message-ID: <3b22843b.13810638@news.laplaza.org> On Fri, 8 Jun 2001 18:24:58 -0400, D-Man wrote: >On Fri, Jun 08, 2001 at 07:22:21PM +0000, Luigi wrote: >| Hello, >| >| Where I can find tutorial about Jython? > >It interprets normal Python source and has nearly all of the standard >library with it (only missing OS specific stuff and C dependant >stuff). Thus the standard Python documentation applies >(http://www.python.org/docs). Basically, yes. If you're coming from the Java world, you'll find Python easy to learn, but with some surprises. A tutorial in that direction sure wouldn't hurt, but I think we'll get that in the form of books - it looks like several publishers have projects in the works or on the drawing board. Roughly speaking, when we talk about "Python" we often mean the whole package - core language and libraries. The core language is the same in Jython; while a good chunk of the ("C" Python) libraries /are/ available anything that requires a C extension probably isn't (perhaps "probably" is too strong...the extension part could have been recoded to depend on some standard Java class). If you're using Jython as a way to work with Java, you're mostly interested in working with Java libaries anyway so the "standard library" becomes a somewhat less important factor. -- mats Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From mwh at python.net Mon Jun 18 18:28:50 2001 From: mwh at python.net (Michael Hudson) Date: 18 Jun 2001 23:28:50 +0100 Subject: Any other Python flaws? References: <3B2A5F6A.5A61183@destiny.com> Message-ID: D-Man writes: > On Mon, Jun 18, 2001 at 08:10:12PM +0100, Michael Hudson wrote: > | D-Man writes: > | > | > On Fri, Jun 15, 2001 at 02:18:04PM -0500, Michael Chermside wrote: > | > | Oh well... at least people don't bump into this one much. And if you > | > | accidently clobber it, you can restore things with: > | > | > | > | def __None(): > | > | pass > | > | None = __None() > | > > | > Well, that doesn't work. One of the key features of 'None' is that > | > there only ever exists a single instance. This would create a new, > | > unique, instance bound to (a more local) 'None'. > | > | No it wouldn't. Try it! > > > > Yeah, he used 'def', not 'class'! I wondered if that was what you thought. > | I agree that what Michael posted doesn't really do what he wanted; but > | it doesn't do what you said, either. > > It seems to, with some cursory tests in the interactive interpreter. Yeah, it looks the same, but None is being found in the global namespace, not the builtin one like normal. I can't think of any remotely sane situation where this would make a difference, but the difference is there. Eg. consider assigning to __builins__.None (I don't recommend actually doing this!). > I would have to look at the source to see _how_ the function > implicitly returns 'None' to understand why it doesn't behave as > intended. Because falling off the end of a function compiles into a LOAD_CONST instruction with an argument of Py_None and nothing you can do in Python will affect the value of (the C symbol) Py_None. Cheers, M. -- Just getting something to work usually means writing reams of code fast, like a Stephen King novel, but making it maintainable and high-quality code that really expresses the ideas well, is like writing poetry. Art is taking away. -- Erik Naggum, comp.lang.lisp From donod at home.com Fri Jun 8 03:50:45 2001 From: donod at home.com (Don O'Donnell) Date: Fri, 08 Jun 2001 07:50:45 GMT Subject: ROGER SESSIONS DISQUALIFIES JYTHON AS "FREEWARE" Message-ID: <3B208271.50B6D0D0@home.com> In the current issue of his monthly newsletter "ObjectWatch": http://www.objectwatch.com/issue_33.htm Roger Sessions, author of "COM+ and the Battle for the Middle Tier", and ever a strong proponent of the Microsoft mantra from COM to DCOM to COM+ to .NET, in his main article "IS JAVA LANGUAGE NEUTRAL", searches for languages, other than Java, which run on the Java platform. I read it avidly, expecting to find kind words about Jython. Alas, he classifies JPython/Jython as "Freeware" and lumps it together with "School/Hobby projects" and says: "Both of these categories include technologies that show the feasibility of generating JBC from sources other than Java (a capability that is not in dispute), but do not include actual supported implementations that would be used in a large commercial project." (JBC == Java bytecode) I just thought that some of you Jython programmers out there (I only use the C version myself) might want to take issue with him. -Don From mwh at python.net Sun Jun 17 05:12:29 2001 From: mwh at python.net (Michael Hudson) Date: 17 Jun 2001 10:12:29 +0100 Subject: Type/Class Distinction References: <9gdpbp$61k$6@newshost.accu.uu.nl> <9gfp64017jh@enews1.newsguy.com> <9ggc6n$f22$1@newshost.accu.uu.nl> Message-ID: m.faassen at vet.uu.nl (Martijn Faassen) writes: > Alex Martelli wrote: > > "Martijn Faassen" wrote in message > > news:9gdpbp$61k$6 at newshost.accu.uu.nl... > > ... > >> Right now we have to *treat* 'types' differently from 'classes'. For > >> built-in objects you have to use the type() construct to check what > >> you're dealing with, but for class instances you use isinstance(). > >> > >> Wouldn't it be nice if the language allowed something like this: > >> > >> if isinstance(foo, int): > > > You're behind the times, I think (if I understand you correctly): > > So I am! I wasn't aware this was the case. Does not seem to be mentioned in > Andrew Kuchling's 'What's new in Python 2.1'. Well, that would be because it wasn't "new in Python 2.1"; >>> import types >>> isinstance(1, types.IntType) 1 works in 1.5.2 (the oldest version I have lying around). I found: ----------------- revision 2.112 date: 1997/12/02 19:11:45; author: guido; state: Exp; lines: +15 -10 Support type objects in isinstance(). E.g. isinstance('',types.StringType) will return true now instead of raising a TypeError exception. This is for JPython compatibility. ----------------- in the CVS logs for Python/bltinmodule.c, which seems to be just before Python 1.5 came out. Cheers, M. -- The rapid establishment of social ties, even of a fleeting nature, advance not only that goal but its standing in the uberconscious mesh of communal psychic, subjective, and algorithmic interbeing. But I fear I'm restating the obvious. -- Will Ware, comp.lang.python From eppstein at ics.uci.edu Wed Jun 20 14:42:08 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Wed, 20 Jun 2001 11:42:08 -0700 Subject: PEP 255: Simple Generators References: <3B303FE5.735A5FDC@cosc.canterbury.ac.nz> <90C65699Dgmcmhypernetcom@199.171.54.194> Message-ID: I'm wondering if it wouldn't make sense to allow a non-empty return statement in a generator, with the semantics that the object being returned is itself some kind of iterator that is used to continue the sequence. i.e. def integers(i): yield i return integers(i+1) ...thus allowing a more functional-programming-like lazy iteration. There would thus also be very little difference between a function that returns an iterator, and a generator that does some yields before returning an iterator. Of course you could rewrite this particular example by wrapping a loop around the body, and in general you could simulate the same behavior with another loop in place of the return stmt: def integers(i): yield i for j in integers(i+1): yield j But, that adds an unnecessary middleman in the implementation, and looks uglier. (Disclaimer, I haven't read all previous discussions on the subject, quite likely someone else has already proposed this and been shot down, in which case I'd appreciate a pointer to the refutation.) -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From aleaxit at yahoo.com Mon Jun 11 12:21:35 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 11 Jun 2001 18:21:35 +0200 Subject: Learning OOP... References: <535V6.147522$oc7.8844949@news2.rdc2.tx.home.com> Message-ID: <9g2r6f0jso@enews2.newsguy.com> "Rainer Deyke" wrote in message news:535V6.147522$oc7.8844949 at news2.rdc2.tx.home.com... > "Alex Martelli" wrote in message > news:mailman.992248937.25086.python-list at python.org... > > The > > problem is the entanglement, NOT inheritance, which, in Python, > > is just a neat and powerful reuse-mechanism -- no more, no less. > > Counterexample: the exception hierarchy. True, 'except' (for the current class-based exceptions) is defined to work on the basis of inheritance. You can, if you wish, implement similar "typecheck-like" mechanisms yourself by using the built-in isinstance function (but I would not recommend it as a general Python programming practice -- it's just a notch above type(foo)==type(bar) in terms of annoyance; however, if I had to design from scratch an exception catching mechanism for Python WITHOUT benefit of PEP's 245 and 246, I cannot think of anything better than the inheritance-based kludge). Alex From samschul at pacbell.net Fri Jun 15 15:23:39 2001 From: samschul at pacbell.net (Samuel Schulenburg) Date: 15 Jun 2001 12:23:39 -0700 Subject: Any other Python flaws? References: Message-ID: I see a problem that only occurs in the IDLE, or Winpython environment. the following interactive command session will cause either environment to shut down. >>> a=open("Somefile.txt","r") >>> a.read() the "a.read() command under python.exe will output the file stream to the console. The following will work under IDLE, or WinPython: >>> a= open("somefile.txt","r") >>> s = a.read() >>> print s but >>> a= open("somefile.txt","r") >>> s=a.read() >>> s will also cause the environment to shut down. Sam Schulenburg From jkraska1 at san.rr.com Sat Jun 16 15:04:35 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 16 Jun 2001 19:04:35 GMT Subject: Writing new codecs References: Message-ID: >It's really your choice. For rarely-used encodings, writing them in >Python might make them more maintainable. But then, dealing with >individual bytes in C is often easier than in Python. I found it pretty easy after I learned the array and struct modules. Mind you, manipulating detailed bytes is pretty slow in Python. In my case, it didn't matter, however, as the end result was an easy application to write which ran "fast enough". There are many, many situations in which this is a perfectly fine outcome. C// From mertz at gnosis.cx Wed Jun 20 16:00:15 2001 From: mertz at gnosis.cx (Dr. David Mertz) Date: Wed, 20 Jun 2001 16:00:15 -0400 Subject: Suggested amendment to PEP 255 (fwd) Message-ID: One more non-vote for a new spelling of "generator." Despite protestations to the contrary by the timbot, I see the very subtle and late-in-the-definition-body use of 'yield' as a train wreck waiting to happen. Never mind newbies, I am certain that *I* would stumble over the difference between generators and (real) functions all the time. As spelling goes, I like: generator foo(args): the best. But the other suggestions below are sufficiently good also. Yours, David... -------- Forwarded message -------- Newsgroups: comp.lang.python Date: 20 Jun 2001 07:38:28 -0700 From: morton at dennisinter.com (damien morton) Subject: Re: Suggested amendment to PEP 255 Simon Brunning wrote in message news:... > > From: Greg Ewing [SMTP:greg at cosc.canterbury.ac.nz] > > I suggest dropping the "def" altogether and using: > > > > generator foo(args): > > ... > > yield x > > ... > > This gets my vote. Or it would. If I had a vote. Which I don't. > > *Excellent* PEP, BTW! > > Cheers, > Simon Brunning > TriSystems Ltd. > sbrunning at trisystems.co.uk Im 100% with this too. doubleplusgood would be my vote, if I had one. Generators do seem different enough from functions to warrant a different syntax. some other syntax possibilities: gen foo(args): yield x def foo(args) generator: yield x def foo(args) as generator: yield x def generator foo(args): yield x From akuchlin at mems-exchange.org Fri Jun 29 18:41:25 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 29 Jun 2001 18:41:25 -0400 Subject: Not enough Python library development [was PEP scepticism] References: Message-ID: <3dy9qalxii.fsf@ute.cnri.reston.va.us> Roman Suzi writes: > CPyAN is much more complex task, because there are: > > - security considerations > - integration with distutils > - probably, one day python will allow the "import" shown above > (I even think it is already possible) > - dependency resolution framework... Not necessarily. An annoying habit of the Python community is to write an initial requirement list that's so forbiddingly long that everyone is frightened away and nothing is ever implemented. But you don't have to implement everything to have something useful. Case in point: Parnassus, which does exactly 0 of the above 4 items, yet it's definitely not useless. --amk From SBrunning at trisystems.co.uk Wed Jun 6 09:07:07 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Wed, 6 Jun 2001 14:07:07 +0100 Subject: Error checking for 'raw_input( )'? Message-ID: <31575A892FF6D1118F5800600846864D78BCED@intrepid> > From: brakedon at hotmail.com [SMTP:brakedon at hotmail.com] > What is the best way to detect whether number or letter strings were > entered into the "raw_input( )" field. I want to be able to send a > error message to the user if they enter the incorrect type > (numbers,letters,etc). The isdigit string method might come in handy here - see Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From JeffH at ActiveState.com Wed Jun 20 15:08:39 2001 From: JeffH at ActiveState.com (Jeff Hobbs) Date: Wed, 20 Jun 2001 12:08:39 -0700 Subject: [repost] Embedding menus in frames prevents alt+key defaults? References: Message-ID: <3B30F4B7.8181C8B9@ActiveState.com> Tim Christian wrote: > > >>>>> "Tim" == Tim Christian writes: > > Tim> Howdy, I'm learning how to use Python and Tkinter using Mark > Tim> Lutz' _Programming_Python_ (2nd edition) and have run into an > Tim> odd side effect. It may be Tk specific (OT?), but I'll ask > Tim> here anyway. Lutz discusses the relative merits of embedding > Tim> menus into top level windows versus frames. The frames route > Tim> seems like a good idea for reusable objects. However, after > Tim> I embed menus into frames, I notice that the menu items, > Tim> though underlined, are no longer selectable via the Alt key > Tim> (eg, Alt+F doesn't bring up the "File" menu, though the "F" > Tim> character is underlined). Is this typical behavior? Perhaps > Tim> it's just a problem under my development platform (Windows > Tim> 2000, Python 2.1)? It seems like you might be using the old-style menus, because that is what the frames route would require. You can still make "reusable" menus using the new menu mechanism (since 8.0). You can see the code that is triggered with old-style menus in the menu.tcl runtime library file. The new-style ones are native menus on Windows and Mac, so the OS will grab the Alt key event when it needs to. -- Jeff Hobbs The Tcl Guy Senior Developer http://www.ActiveState.com/ Tcl Support and Productivity Solutions From danielm at cronus.res.cmu.edu Tue Jun 19 23:12:16 2001 From: danielm at cronus.res.cmu.edu (Dan Moskowitz) Date: 19 Jun 2001 20:12:16 -0700 Subject: How do I access the last "un-caught" variable in the interpreter? Message-ID: <39503ed5.0106191912.5b054b42@posting.google.com> Pretty simple question: >>> 2+2 4 >>> # can i access the 4 if i didn't catch it in a var? Is there some variable for the last result returned from the interpreter? I thought that I used to know how to do it, but I've forgotten. Anyone know? interpreter.last ? Thanks, -dan From just at letterror.com Tue Jun 5 17:03:19 2001 From: just at letterror.com (Just van Rossum) Date: Tue, 05 Jun 2001 23:03:19 +0200 Subject: How do you develop in Python? References: <050620011516094693%pecora@anvil.nrl.navy.mil> Message-ID: <3B1D4916.8F572A51@letterror.com> Lou Pecora wrote: > > I program in Python occassionally and would like to do more of it. But > here's a development conundrum I run into a lot (there are more complex > examples, but I'll give an easy one). I am developing module A.py > which imports B.py in the IDE. I am running test code which is also in > A.py as I incrementally develop A.py. Then I need to change B.py and, > of course, the import does not import the new changes since import only > works once. Hence, to "refresh" B.py I have to quit the IDE and > restart, open A.py and run. This is clumsy. However, the above > scenario is not uncommon and more complex interdependencies of modules > appear to make it unavoidable. Anyone know a way to get around this > "import" problem? I know there is a "reload", but then I have to > import and change my modules' code to "reload" or something each time I > work with them. Any help appreciated. > > I use Python on a Macintosh. Nice IDE, otherwise. It's simple: if you modify B.py, _run_ B.py to refresh it (*). A.py will see the changes. It's hardly ever neccesary to quit the MacPython IDE. *) In other words: if B.py has already been imported, running it it will execute it in B's old namespace, effectively refreshing it for everybody to see. Just From uioziaremwpl at spammotel.com Sun Jun 17 04:16:41 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Sun, 17 Jun 2001 10:16:41 +0200 (CEST) Subject: += overloading? In-Reply-To: Message-ID: On Sun, 17 Jun 2001, Roman Suzi wrote: > On Sat, 16 Jun 2001, Neil Macneale wrote: > > >I am creating a colored stringbuffer class, and I want to append words to > >the buffer with the '+=' operator. Ex: > > > >>>>csb = CSB("INIT STRING") > >>>>csb += "Hello" > >>>>print csb > >INIT STRINGHello > > > >would be the desired effect. I can't seem to find anything in the lib > >docs about overloading that operator though. Am I looking in the wrong > >place? It is also important that a new object is NOT created every time > >the operator is used, because that would be a waste. > > class CSB: > def __iadd__(self, x): > self._string += x Don't forget the "return self" or similar. Bye, Carsten -- Carsten Geckeler From thomas at cintra.no Sat Jun 16 13:54:25 2001 From: thomas at cintra.no (Thomas Weholt) Date: Sat, 16 Jun 2001 17:54:25 GMT Subject: Fastest way to extract used namespaces from a piece of XML? Message-ID: I need the fastest code available for extracting all namespaces used in a piece of xml. I got this code for doing this, but it's slow as hell. Any clues? from xml.sax import saxlib, saxexts from cStringIO import StringIO import string class NamespaceParser(saxlib.HandlerBase): """NamespaceParser - extract namespaces used in a piece of xml""" def __init__(self): self.namespaces = {} def startElement(self, name, atts): try: namespace, tagname = string.splitfields(name, ':') self.namespaces[string.upper(str(namespace))] = None except: pass def getNamespaces(xml_text): internal_parser = NamespaceParser() parser = saxexts.make_parser() parser.setDocumentHandler(internal_parser) xml = StringIO(xml_text) parser.parseFile(xml) return internal_parser.namespaces.keys() Thomas From rjroy at takingcontrol.com Fri Jun 15 17:48:12 2001 From: rjroy at takingcontrol.com (Robert Roy) Date: Fri, 15 Jun 2001 21:48:12 GMT Subject: Any other Python flaws? References: <9gbe4e$gla$2@newshost.accu.uu.nl> Message-ID: <3b2a80ed.326615828@news1.on.sympatico.ca> On 14 Jun 2001 22:33:50 GMT, m.faassen at vet.uu.nl (Martijn Faassen) wrote: >Andrew Kuchling wrote: >> I was updating my page of possible Python design flaws >> (http://www.amk.ca/python/writing/warts.html) last night to take 2.1 >> into account. 2.1's nested scoping fixes one major wart, and the >> other major one, the type/class dichotomy, might get fixed in 2.2 if >> the descr-branch in CVS turns out well. (It's neat that the two >> largest ones may both get fixed before 2001 is out.) > >> That leaves the remaining warts as minor wibbling about 'do' >> statements, print >>, and the like. Are there any other flaws that >> should be added? > >This may be considered a minor quibble; the mandatory use of () in >case of multiple arguments to the % string interpolation operator: > >"%s" % "foo" > >"%s %s" % "foo", "bar" # doesn't work right > >"%s %s" % ("foo", "bar") > Would that not allow for more ambiguities than its worth? It would make nested tuples would be extremely dangerous. This is clear ('this', '%s %s' % ('foo', 'bar'), 'that') If I change my format string to '%s %s %s' the interpreter will yell at me if I do not add an element to my tuple This is not ('this', '%s %s' % 'foo', 'bar', 'that') If I change my format string as above and fail to add the appropriate element to the tuple, I have an extremely hard to find bug. Bob From m.hadfield at niwa.cri.nz Wed Jun 20 20:28:23 2001 From: m.hadfield at niwa.cri.nz (Mark Hadfield) Date: Thu, 21 Jun 2001 00:28:23 +0000 (UTC) Subject: using os.system and ps2pdf References: Message-ID: <000401c0f9e9$121cfe00$d938a8c0@Hadfield> ----- Original Message ----- From: "iddwb" > import os, sys, tempfile > > if __name__ == '__main__': > psf = tempfile.mktemp("psf") > pdf = tempfile.mktemp("pdf") > ps = open(psf, "w") > ps.write(sys.stdin.read()) > ps.close > print "ps2pdf %s %s" % (psf, pdf) > os.system("ps2pdf %s %s" % (psf, pdf)) Replace ps.close with ps.close() ps.close is a function object. If you type ps.close at the interpreter you get a string representation of the function, something like If you include it in a .py file it does nothing. To *invoke* a function, you need the parentheses. Been there done that. --- Mark Hadfield m.hadfield at niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield National Institute for Water and Atmospheric Research -- Posted from clam.niwa.cri.nz [202.36.29.1] via Mailgate.ORG Server - http://www.Mailgate.ORG From thinkit8 at lycos.com Wed Jun 13 18:42:39 2001 From: thinkit8 at lycos.com (thinkit) Date: 13 Jun 2001 15:42:39 -0700 Subject: humans and logic References: <9g5d3p0f0p@drn.newsguy.com> <3b27823b.19626140@news.btinternet.com> Message-ID: <9g8q8v0uns@drn.newsguy.com> In article <3b27823b.19626140 at news.btinternet.com>, danny.ayers_nospam at btinternet.com says... > >On 12 Jun 2001 08:39:37 -0700, thinkit wrote: > >>humans should use a power of 2 as a base. this is more logical because it >>synchs with binary, which is at the very heart of logic--true and false. it is >>more natural perhaps, to use decimal--but logic should, and will, win out. > >the main use of numbers is in numerical operations such as counting, >not logical ones > >what would tbe he advantage in using powers of 2 be anyway? isn't the >idea of computers for them to do this kind of work for us? well we can have computers do our work easier since we'll be speaking on hexadecimal. From tgos at spamcop.net Thu Jun 7 12:23:11 2001 From: tgos at spamcop.net (TGOS) Date: 7 Jun 2001 11:23:11 -0500 Subject: best language for 3D manipulation over web ? References: <3B1A47EA.AFBD45E8@lmf.ericsson.se> <3B1B1825.8109BA83@lmf.ericsson.se> <2v4ohtgldvce84sn87kh1eg1lnes37getq@4ax.com> <3B1C9E65.B73A4FE@lmf.ericsson.se> <3B1DFD87.F3BFDB57@lmf.ericsson.se> Message-ID: On Wed, 06 Jun 2001 12:53:11 +0300, Attila Feher wrote: >> So when I say UNIX is more secure than Windows, I mean UNIX itself, which is >> the kernel, hardware driver, software drivers (like file systems) and the >> programs that are absolutely necessary. > > And what can you do with it? :-))) Having a UNIX usually means to > people: sendmail, awk, egrep, cat, etc. etc. many-many little utilities: > which are great and which make UNIX tick... Let's assume you need a router...all you need for that is a UNIX/Linux kernel and a boot script...that's it. Maybe you also install an SSH client (that only allows connection from the local network) to change configuration, but despite that you don't need anything. Such a router easily fit onto a floppy disc...even a router with extra firewall may fit onto a single floppy disc. Now let's build that system with WinNT...how much useless components do you have to install, that are never used later on, but might cause security holes? Exactly ^_^ Despite that, I doubt that WinNT actually has router/firewall functions implemented into its kernel, so you are forced to install third party software for this. For a webserver you'll only need kernel and webserver application (the OS and ONE piece of third party software). Sure, depending on what this server shall be able to do (PHP, Perl, SSI, etc.) you may have to install a lot more than only those 2, but whatever you need, you always just install the absolute minimum necessary for your server. >> When installing a UNIX system that shall be secure, you should disable >> everything during installation that can be disabled (including server software, >> XServer, etc.). A XServer for example is such a big security hole, that you can >> push a whole elephant through it and nobody would recognize it ^_^ > > Uhhhh. This I did not know. Why is it so? XServers usually have permanently opened ports and every open port is a security risk. Sure, usually you can configure the XServer to disable those ports within the configuration file, but let's stay realistic: XServers do have bugs as well. XServers are often "super applications", IOW they aren't treated like normal user applications (my one has an own kernel module for speed boost, so it can directly access hardware) and most admins forget that XServers can be a security hole (IOW they don't disable the open ports). Iif you make a SSH login to another PC and then start a XServer application, the window it creates is then displayed on your desktop, not on the local one. Now what if you can manipulate a XServer so it always forwards all Window data to those open ports? Then a hacker/cracker would be able to see what's going on at your screen for example. So if you are building a router, firewall or webserver...don't install any XServer, it's neither necessary nor advisable. Despite that, many crashes on UNIX/Linux PCs are the fault of the XServer. If it crashes, it pulls all graphical apps into nirvana. The IRIX PCs at university are VERY stable, but their XServer crashes twice a day. If that happens, you can't operate the system anymore from your local desktop, but if you login from another PC, you'll see that everything is fine (you can still run whatever you like without problems). So the OS itself didn't crash, just the XServer. If you kill the XServer and restart it again, the PC will continue to work. > Actuall Win31/311 Win95/8/me can be installed w/o GUI... I mean not > connected to the NET, install and then do some hack and U can remove the > whole GUI. Sure: Open system.ini and replace "shell=Explorer.exe" with another GUI. Try "shell=command.com" and you run Windows in text mode. You can start Windows apps, that's no problem. E.g. type "start winamp" and then you can listen to MP3 music. You just don't have a Desktop, a Taskbar or a Startbutton. That way you don't get rid of the GDI, but of the Explorer (you can now delete the EXE file as well as some other files). To get rid of the GDI, you must download an alternative GDI (those exist) and simply exchange those two. Thanks to "Rundll" you can create BAT files for shutting down your PC and other things you are missing now. But I doubt that this all is possible in WinNT. >> And you must be careful when speaking about UNIX security holes. One of the >> biggest security holes of all times was (or maybe still is) SENDMAIL. It needs >> root rights to run correctly and that is a danger. You can intentionally crash >> it (e.g. provoking a stack overflow and that way executing own code) and such a >> crash can result in a new shell with root rights. That was one of the easier >> ways to get root rights and immediately everyone said: >> "Look, UNIX isn't secure at all!" > > How can U get a root shell when you crash sth? (I am not a cracker). Don't ask me. > I mean shouldn't the kernel/shell/whatever realize that the setuid stuff > is out and simply return back? Sendmail has plenty of buffers and some buffers were way too small. E.g. if you use a 2000 char long e-mail address, but the buffer is only 50 chars and Sendmail doesn't check this, data will get written beyond the limits of this buffer (that's a disadvantage of direct memory access instead of using a char array). Now you can get Sendmail executing a command for you, like "bash" and this bash is then a root shell, because it was invoked by a root process. > Isn't it so that the shell start up and > it exec-s the setuid stuff, so there is no shell at all with root > effective user? I don't know the details either, sorry. But some of Sendmails bugs can be found here: http://www.wwdsi.com/demo/saint_tutorials/Sendmail_vulnerabilities.html > OK, but we all know that a UNIX system _does_ include sendmail and all > the other stuff in people's mind. Well, there are alternatives to Sendmail. Despite that, I found a webpage that describes how you can install and use Sendmail, WITHOUT assigning root access to it. > I mean having a web server which > cannot notify me of events (alarms) is not that good. :-( There certainly other ways to notify you. Despite that, a Unix system can send mails without Sendmail, e.g. via an external SMTP server (the one where your mailbox is hosted). >> I personally like the system of "wrappers". You neither use UNIX or Windows >> APIs directly. You create your own wrapper API, that in once case is wrapped >> around the UNIX/Linux APIs and once around the Windows APIs. > > Yep. But let's say I want to make a non-open-source stuff. Then use non open source wrappers ^_^ Or even better, write your own wrapper. Never thought about creating your own GUI library? Where all functions are named like you want and that is optimized for your needs? Just create such a library for your favorite system. Every method within your library will only have a few lines of code and then make use of native OS libraries for their actual task. In your application, you just make use of your own GUI library (you'll loose maybe 1-2% of GUI speed through this wrapping, but usually you won't even notice). If you now want to get your application running on a different system, just pull out your library skeleton, delete all native functions and replace them with native functions of this OS. Sometimes you will have to alter the surrounding code a bit, but that's not a lot of work. That's then _your own_ wrapper library. And even if your application is so shitty that nobody wants to every buy it...maybe you get rich by selling your wrapper library ^_- I once made a game wrapper for Windows and Linux, with enough functions to create very simple games (puzzle or card games, not Quake3 ^,^) and it was already running very well (still had some bugs, but I'm sure I had fixed those)...then I found out that I can write those simple games in Java (where it also runs on other systems, not just Windows and Linux) and there's no dramatically speed difference, so I dumped this project as a whole. My library was too slow and not flexible enough for larger projects anyway, but it was an interesting experience and up to now my only real experience with C++ (as I told you before, we only learn Java). >> Windows as a whole ins't open source, nevertheless you trust in its security, >> don't you? ^_- >> Despite that, some parts are open source. > > Yep. And it does has a Java VM(?) installed with IE... :-)))) That's > why you need to know a lot to make the secure install. Well, in case of Win9x, you can simply delete all Java classes and then Java is gone. I don't use IE's Java, I surf the web with Opera (I'm proud to say that I'm registered Opera user ... finally a piece of software I bought instead of applying a crack ^,^) and Opera has no own Java. You must install a JRE of your choice (currently using Sun JVM 1.3) and Opera will use it. BTW it will use it directly, without the plug-ins that are needed for IE and NS. It directly accesses the DLL where the JVM is inside - the same way the appletviewer is doing it. Opera is currently the ONLY browser that is able to do this. > Anyone making assembly optimizations should be aware of that he creates > _highly_ nonportable code. But also highly speed optimized one. > If one goes with C++ (and C) it is many > times unnecessary, even evil. A well written C/C++ code will provide > the same ASM stuff. That depends. Most compilers allow you to preview your C++ code in Assembler, the way it is also translated when getting compiled. If you take a look at that code and compare it to hand written code, it's quite different. A tiny C++ program may result in 1,000 lines Assembler code, while when you write the same thing directly in Assembler, you may only need 400 lines. Despite that you can make use of processor features like SSE2, which can perform certain calculations 4 times faster than using classic x86 instructions; very helpful when applying the same function onto an whole array of numbers. C++ won't use those features, because therefor it would need to know how the program behaves during runtime. Sure, this code will only run on a specific platform, often only on a specific CPU, but nonetheless it's done pretty often. This doesn't mean that your whole application can't be cross-platform. You may write the same function multiple times: 1. Plain C++ 2. x86 Assembler (386 or higher) 3. x86 Assembler (Pentium MMX or higher) 4. x86 Assembler (Pentium3 SSE or higher) 5. x86 Assembler (AMD Athlon 3DNow or higher) 6. x86 Assembler (Pentium4 SSE2 or higher) 7. PowerPC Assembler (...sorry, don't know those numbers...) 8. PowerPC Assembler (with 'AltiVec' or whatever their extension is called) 9. some other CPU 10. some other CPU 11. some other CPU 12. some other CPU Now when your program starts, it detects the CPU of your system and depending on what it found, 2 - 12 is used. If the CPU type is unknown, there's still 1 that got compiled on that system and that way will certainly run. I bet optimizations of that kind are done in applications like: Maya 3.0a http://www.aw.sgi.de Houdini 4.1 http://www.sidefx.com Both run on: WinNT, Win2000, Linux and IRIX. In case of Maya, a Mac version is currently in development. [ Windows Registry ] > And once it crashes you have to reinstall _everything_, probably > including nice data loss... Exactly, that's why applications shouldn't store their data there. So I can reinstall Windows, without being forced to reinstall a single application. That way I would loose file associations, but that's not such a big deal. >> Every user should have his/her own registry (and not just a sub-tree) > > TOTALLY agreed. See, we can agree to many different things ^__^ Especially if every user had his/her own registry, different users could have different file associations (one user may like to open DOC files with Word, but someone else may like to open them with StarWriter) and different hardware settings (sometimes that's an advantage). >> Forte? >> Nah, I don't use Forte, I use JBuilder. > > Can one get one to learn for free? Sure. The current version (JBuilder 5) is commercial, but they were kind enough to give away their older version (JBuilder 4) for free! Go here: http://www.inprise.com/jbuilder/foundation/ And download it for free. They support the following platforms: Windows, Linux and Solaris JBuilder itself is written in Java, but it comes with an own JDK and an own setup application (both are native). Once its installed, I was able to delete its custom JDK (but careful, you can't delete everything of it. If two of the JAR files are missing, some features don't work anymore!) and to manipulate it, so that it now runs with the JDK that I installed on my system previous to JBuilder. IOW in theory you are even able to run it on other UNIX systems than Solaris. Before you can use it after install, you must register at the Inprise homepage to get an activation key. This registration is for free, you just answer a few questions and they'll send you the key via e-mail. >> You can't really filter the web. You can try, but it will never be really >> effective. > > Simple. One allows only few addresses/IPs to be reached :-))) Opposite > filtering :-))) I don't think they are doing this...actually I know it. Do you know Audiogalaxy? It's like Napster (sharing MP3 files), but unlike Napster it's still unfiltered and they even have a client for Linux. I use it once a while and there you can look who's online at the moment (of course you don't see the real names of people, just their screen names), sorted by country. And once a while a few people from China are online ^_^ And as I know the Chinese government, I doubt that they would allow users to access Audiogalaxy, because they also have discussion forums there. So Chinese people can discuss with the rest of the world. > Hm. RAM will be the issue here. Let's say it that way: One thing that makes Java slow is the garbage collector and the more RAM you have, the less often it must start to clean it up. IBM's JVM is faster than Sun's, but it also uses more RAM (where Sun's uses 16 MB, IBM's may use 22 MB) ...maybe not a coincident. Java doesn't need a very fast CPU (remember, very simple devices can run Java like cell phones), but a decent amount or RAM is pretty helpful. > Now if U have a C++ programmer (experienced, with his nice libraries) I > guess he will do a better quality work before the new Java guy learn > what is an array :-))) But the C++ programmer may use direct memory access and the result is something like Sendmail, which doesn't happen when using an array. ^_- Despite that, C++ programmers don't need to know what an array is? > And still on suggestion: before start programming in Java: learn what > goes on behind the scenes! Otherwise you are lost when you encounter a > problem. That's what I'm currently trying. The first thing I did was looking at the source code of all classes that are shipped with Java and I found out that they seem to be rather optimized for small size than for high speed. > Ps: Maybe we should go on in private? I am just waiting in fear for the > first guy from some NG to say: this is not a discussion forum :-(( Really? So what is it? IMHO a Newsgroup *is* the prototype of a discussion forum and Usenet was created for discussions. But the e-mail address in my header is valid, so you can also reply via mail if you prefer. -- TGOS From grante at visi.com Sat Jun 2 13:13:49 2001 From: grante at visi.com (Grant Edwards) Date: Sat, 02 Jun 2001 17:13:49 GMT Subject: Why isn't Python king of the hill? References: <9fa5fi0fru@enews2.newsguy.com> <9fb5fl$26kf$1@agate.berkeley.edu> Message-ID: On Sat, 2 Jun 2001 16:49:58 +0000 (UTC), E. Mark Ping wrote: >>I know that it is. But when you start depending on that fact, >>you're doomed. > >That's silly and just plain wrong. You should depend on understanding >how FP works. And in this case, 1.0 + 2.0 == 3.0 every time on every >platform that I've run into--I don't know that because I just happened >to try it out, but rather I know how the FP works on those platforms >and know that it is correct. So do I. But every time I've seen an application _depend_ on exact representations, its caused problems. Perhaps the FP code you've seen was better, but in my experience code that depends on exact represention has caused problems. >>>> should always treat floating point operations as if there are >>>> small random numbers being thrown in at every step. So you >>> >>>I think this is exactly what Kahan describes as one of the >>>widespread (and false) myths about floating point. >> >>Of course it is not true. But if you pretend it is, you've got >>a much better chance of producing working code. > >You should definitely read Pete Becker's articles in the June, July >and October 2000 issues of The C/C++ Users Journal. He explains why >you're statement is insufficient and incorrect. For instance, two >very large numbers might really be the same, but be off by a bit. Huh? They're the same, but they're not the same? >Checking the difference of the values will yield another large number, >and a method like "IsCloseTo" will incorrectly fail. How can it fail? Either A is within X% of B or it isn't. What's the problem? >Really, floating point arithmetic has well-defined semantics; guessing >and treating them as if they have random components is the lazy and >error-prone way to use them. I'm not guessing. I know how IEEE floating point works and have implimented various parts of it over the years. The applications programmers I've dealt with would have been far, far better off if they never depended on exact representation. I'm sure you hang out with a much brighter crowd than I. -- Grant Edwards grante Yow! Did I say I was a at sardine? Or a bus??? visi.com From piet at cs.uu.nl Fri Jun 8 15:39:28 2001 From: piet at cs.uu.nl (Piet van Oostrum) Date: 08 Jun 2001 21:39:28 +0200 Subject: run function in background? References: Message-ID: >>>>> Damian Menscher (DM) writes: DM> Is there a way to run a function in python in the background? DM> Ideally I'd want something like DM> def my_func(params): DM> stuff here DM> for i in range(10): DM> print "starting a process" DM> my_func(params) & DM> where the & indicates that shouldn't stop the flow of the program, DM> so the loop would continue and have all 10 go simultaneously. Use threads. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From gbreed at cix.compulink.co.uk Tue Jun 5 08:33:15 2001 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: 5 Jun 2001 12:33:15 GMT Subject: Trouble with Python in ASP development References: <2auR6.3608$lM3.84473@news1.oke.nextra.no> Message-ID: <9fijib$9kq$1@plutonium.compulink.co.uk> In article <2auR6.3608$lM3.84473 at news1.oke.nextra.no>, thomas at cintra.no (Thomas Weholt) wrote: > I'm trying to use python as script-language in ASP, using MS IIS. > When something in my python-code raises an exception the loading of the > page > just stops, > and nothhing after the code that raises the exception is sent to the > client. > No error-message is given. I've never known the exception not be displayed, unless you suppress it. Try viewing the HTML source in the browser to see if the message is hiding. > Is there any way to get more info from ISS or find out what goes wrong? > Passing the same parameters to a Kunde-object in the python interpreter > works just fine. In ASP it just won't work. I'm not sure what your problem is here. The exceptions IIS generates are of type com_error. So put from pywintypes import com_error at the top of the page. Then some exception handling could be except com_error, ohdear: Response.Write(str(ohdear)) Which, IIRC, shows what would have been displayed if you hadn't caught the exception. It does have to be str and not repr in this case. All of which may have no connection with what you wanted to know ... Graham From msoulier at storm.ca Wed Jun 6 22:47:24 2001 From: msoulier at storm.ca (Michael P. Soulier) Date: Thu, 07 Jun 2001 02:47:24 GMT Subject: Windows editor? References: <3af2c38f.341431824@News.CIS.DFN.DE> <1103_991870550@ns.seowon.ac.kr> Message-ID: <0XBT6.147858$eK2.35771422@news4.rdc1.on.home.com> On Wed, 06 Jun 2001 23:35:50 GMT, Wolfgang Lipp wrote: >> > > > >What's a good Python editor for programming under Windows, >> > > > >specifically Windows 2000? According to Google archives it seems >> > > > >this question > > try www.textpad.com http://www.vim.org -- Michael P. Soulier "With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead." -- RFC 1925 From jh at web.de Wed Jun 13 16:17:15 2001 From: jh at web.de (Jürgen Hermann) Date: Wed, 13 Jun 2001 22:17:15 +0200 Subject: how to get teh path of a script References: <3B27C7A9.3B9D3F4B@free.fr> Message-ID: <9g8hl9$o0a$05$1@news.t-online.com> "St?phane BAUSSON" schrieb im Newsbeitrag news:3B27C7A9.3B9D3F4B at free.fr... > Hello > > I would like to get for exemple in my_script.py located at > /home/toto/my_script.py to get in my_script.py the value "/home/toto" os.path.normpath(os.path.dirname(os.path.abspath(sys.argv[0}))) From bernhard at intevation.de Tue Jun 19 03:51:46 2001 From: bernhard at intevation.de (Bernhard Reiter) Date: 19 Jun 2001 07:51:46 GMT Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions of event-driven Python? References: <3B2B60AD.942719AE@earthlink.net> <9gkio3$9jcft$5@ID-89274.news.dfncis.de> <3B2D3975.31BF1984@earthlink.net> Message-ID: <9gn0ai$a8p03$1@ID-89274.news.dfncis.de> In article <3B2D3975.31BF1984 at earthlink.net>, Ron Stephens writes: > Is there an extensive tutorial or good documentation of wxPython on the web > that one can learn from? I agree with my fellow posters David and Chris, the demo code is most valuable. Also not that there is a short tutorial coming with Boa (about its usage of course) if you check the help options. I have missed the first times I was checking out Boa. :) Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) FSF Europe (fsfeurope.org) From arturs at iidea.pl Sun Jun 10 16:12:51 2001 From: arturs at iidea.pl (Artur Skura) Date: 10 Jun 2001 20:12:51 GMT Subject: Global in multiple files References: Message-ID: On Sun, 10 Jun 2001 21:55:17 +0400 (MSD), Roman Suzi wrote: >On 10 Jun 2001, Artur Skura wrote: > >>>Why do you need global variable in the OOP design anyway? >> >>I knew you would say that! ;) > >Yes, of course. Because in True Object Design there is no place for >anything global. You have to make some class instance of which will manage >userlist. Mhm. It seems a little too much overhed for a simple list of users. The problem is I need it in many places. So even if I create class ManageUsers, set userlist=ManageUsers(), then userlist.add(user), it will not solve my problem - it might solve for one class only, so probably I need to rearange everything. >>I just want to keep this one little global, userlist, in order >>not to do some strange acrobatics later. It's clean, simple, >>keeps the number of arguments to pass to ther functions small etc. > >After seven years of trial and error I could say that I begin to >understand OOP ;-) > >I thought that way about arguments too. It only says that your object >design is not done right way. (It usually happens when it's first try >anyway). The problem is how to do it in this case? It seems this is not exactly within the scope of this group. But the necessity of having userlist available from (almost) everywhere seems still obvious to me. >>>I blame myself each time I maintain code with global variables: >>>the code can't be easily reconfigured, creates other problems. >>>Globals are allright only in short scripts which has no chance >>>to grow larger. >> >>In this case it fits perfectly. I need to acces userlist from any place, >>any moment. > >Maybe some object could be used to represent the functionality with a >proper method. For example, AuthoriseUser(). It's a singleton in your >situation. But if later you decide to have more userlists, you could add >it to authorisation chain. No, that part of the code (authorisation etc.) is not important now. It all will be rewritten, anyway. But I need to be able to know the value of userlist from within instances of TS_Command.Handle(), also from my main module, and - because the project is a little specific - from TS_System and maybe some other classes. So some solution would be to pass userlist as an argument of TS_Command instance, but somehow it won't work. >>OK, suppose I want to do away with global userlist. >>I want to pass it to TS_Command instance. Will it work? No. Why? > >You still think in terms of structural design. Even modular design already >has some precautions against globals. Objects are here to completely >eliminate the problem. Tell me how :) I think maybe I', stuck against some exception - I really need this list everywhere... >>I have no idea... You see, I don't want to stick fanatically to my >>global, any solution is fine, provided that I can split my code >>and see it working as before, when it was all in one file. >>This 'userlist' is my last obstacle. > >It's not. It's just first iteration of object analysis/design/programming >you did. (In fact, your classes has hard-coded many things. Probably you >will want to change this in the future.) For sure - I'm jus experimeting, it will al be rewritten, maybe in another language, I just want to check out different ways (Ruby seems elegant, also I spare some finger-gimnastics when I have to change indentation of a whole function only because I added one condition etc.) >It's real fun to return to the same design after some time >and look at it critically. > >Thus, I do not critisize you here. I am trying to express what I myself >felt when I tried to reimplement something with objects. At first try >you have objects wrong. (This is seen from the amount of cross-usages). > >It's a painful process which decreeses quality of the code at first. But >then it starts to pay off. Bad object design is worse than bad structural >one, someone said, but good OD is better than good structural. > >Try to rethink your design. Maybe your code will have other >classes than you have now, and will be less lines. Could you suggest some good books about OO? I want to make things easy for someone who might want to add functionality to that code, so it must not be ugly. (BTW I would like to thank other people for pointing out the possibility of having global.py module etc. Yes, it solves my problem for now, but maybe I should really redesign it as Roman suggest to eliminate the need. No, I still don't know how :)) Regards, Artur -- http://www.wolneprogramy.org "Jakos nie kusi mnie perspektywa zostania wsiowym glupkiem znajacym sie tylko na komputerach i zarabiajacym mnostwo kasy" -- lcamtuf From gmcm at hypernet.com Sat Jun 16 11:57:06 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 16 Jun 2001 15:57:06 GMT Subject: coroutines? References: <9gdnp8$80c$1@panix3.panix.com> Message-ID: <90C277ABAgmcmhypernetcom@199.171.54.155> [posted and mailed] eppstein at ics.uci.edu (David Eppstein) wrote in : >In article <9gdnp8$80c$1 at panix3.panix.com>, aahz at panix.com (Aahz Maruch) >wrote: >> See PEP 255, posted just a couple of days ago. ;-) > >Looks like a very nice feature, but I don't think it solves my problem [snip] >PEP 219 looks more relevant, but doesn't look ready for prime time >(and hasn't been ported to the Mac)... Stackless is functionally ready for prime time (it's in use in a number of ventures, some commercial). It's API is not terribly friendly, but the main reason it's a pie-in-the-sky PEP is controversy over the changes to the core (in terms of comprehensibility). It certainly builds (and works) on the mac. Not sure what pre-built releases are available. - Gordon From careye at spamcop.net Sun Jun 10 06:18:55 2001 From: careye at spamcop.net (Carey Evans) Date: 10 Jun 2001 22:18:55 +1200 Subject: Unicode problem References: Message-ID: <87snh8ab8w.fsf@psyche.dnsalias.org> "Shaun Pen" writes: > From the unicode website, I find that the character code for the > hiragana "NA" is "306a" (JIS). I know it outputs as ? (JIS). > > **So how do I get from "306a" to ? ??? ** Python doesn't currently come with the necessary codecs for Japanese, including Shift-JIS. You can download them from: http://pseudo.grad.sccs.chukyo-u.ac.jp/~kajiyama/python/ Once you have them, you can encode the Unicode character as a Shift-JIS bytestream: >>> na = u'\u306a' >>> na.encode('japanese.shift_jis') '\202\310' >>> print na.encode('japanese.shift_jis') ? OK, I made the last line up - my xterm is configured for ISO-8859-1, not Shift JIS. -- Carey Evans http://home.clear.net.nz/pages/c.evans/ "Quiet, you'll miss the humorous conclusion." From greg at cosc.canterbury.ac.nz Wed Jun 13 22:36:17 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 14 Jun 2001 14:36:17 +1200 Subject: Tkinter canvas item bind/break problem Message-ID: <3B282321.EAF54C20@cosc.canterbury.ac.nz> I have a Tkinter canvas item with a binding for mouse clicks, and a similar binding for the canvas itself. I want the item binding to take precedence over the canvas binding. According to my reading of the docs for the Tk canvas widget, and my understanding of how Tkinter works, I should be able to achieve this by returning "break" from the handler for the canvas item. But this doesn't seem to work -- both handlers get called when I click on the item (the item one first, then the canvas one.) Anyone know what might be going wrong? Do canvas item bindings work differently from regular bindings in this regard? Code snippet illustrating the problem is attached below. Versions I am using are: Python version: 1.5.2 (#1, Nov 29 1999, 13:42:43) [GCC 2.8.1] Tk version: 8.0 Tcl version: 8.0 ------------------------------------------------------------------- import Tkinter, Canvas, sys def click_canvas(event): print "Canvas clicked at", event.x, event.y def click_item(event): print "Item clicked at:", event.x, event.y return "break" print "Python version:", sys.version print "Tk version:", Tkinter.TkVersion print "Tcl version:", Tkinter.TclVersion root = Tkinter.Tk() canvas = Tkinter.Canvas(root, width = 300, height = 200) canvas.pack() item = Canvas.Rectangle(canvas, 50, 50, 100, 100, fill = "green") canvas.bind("", click_canvas) item.bind("", click_item) root.mainloop() ------------------------------------------------------------------- Thanks for any help, Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand greg at cosc.canterbury.ac.nz http://www.cosc.canterbury.ac.nz/~greg From darked at my-deja.com Fri Jun 15 18:10:07 2001 From: darked at my-deja.com (Darek Kedra) Date: 15 Jun 2001 15:10:07 -0700 Subject: Distutils error on a VPS References: Message-ID: "tracy s. ruggles" wrote in message news:... <---SNIP---> > _mysql.c:41: mysql.h: No such file or directory > _mysql.c:42: mysqld_error.h: No such file or directory > _mysql.c:43: errmsg.h: No such file or directory > error: command 'gcc' failed with exit status 1 <---END---> I've got the very same messages on Linux Mandrake 8.0. Installing MySQL-devel solved this problem. Do you have '/usr/include/mysql' and '/usr/lib/mysql' ? Greetings Darek Kedra From dpgrote at lbl.gov Tue Jun 12 13:18:33 2001 From: dpgrote at lbl.gov (David P Grote) Date: Tue, 12 Jun 2001 10:18:33 -0700 Subject: Build problem with unicode and 2.1 Message-ID: <3B264EE9.4010405@lbl.gov> I am trying to build python 2.1 on a 64-bit machine (Cray-T3E) and have run into a problem with unicode. The Py_UNICODE type is required to be a 16-bit long, unsigned int. But, on the T3E, there are no types that are less than 4 bytes long. Both wchar_t and the unsigned short are 4 bytes long. So, whenever python is started, it just quits when it imports the unicode stuff, complaining that the size of Py_UNICODE is too big. Is there a way around this problem? Has anyone else built 2.1 on such a machine? Will the code work OK if I just comment out the line in the unicode init routine which checks the length of the Py_UNICODE type and run with a 4-byte long Py_UNICODE? Thanks for your help Dave From noselasd at frisurf.no Wed Jun 20 04:14:52 2001 From: noselasd at frisurf.no (Nils O. Selåsdal) Date: Wed, 20 Jun 2001 10:14:52 +0200 Subject: problems with jython References: Message-ID: "Tyler Coumbes" wrote in message news:tivrc9jrqd8c1e at corp.supernews.com... > I got jython 2.0 and am trying to run it with IBMJava2-13. > I get this error > *sys-package-mgr*: processing new jar, > '/home/flounder/jython-2.0/jython.jar' > SIGSEGV 11 (*) segmentation violation > stackpointer=0xbffc1cf8 > > and it just keeps going at 100% cpu and doesn't stop > What could cause that? a bug? have you tried the Sun VM, or blackdowns (www.blackdown.org) From emile at fenx.com Fri Jun 29 22:40:54 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 29 Jun 2001 19:40:54 -0700 Subject: Simple question (launch a program) References: <9hf6v6$ps0$1@taliesin.netcom.net.uk> <9hf868$941$1@newsreaderg1.core.theplanet.net> <9hil2h$3qa$1@taliesin.netcom.net.uk> Message-ID: <9hjeg8$dtrpr$1@ID-11957.news.dfncis.de> Maybe you need a raw string? eg: >>> system(r"C:\Program Files\KeyNote\keynote.exe") -- Emile van Sebille emile at fenx.com --------- "MDK" wrote in message news:9hil2h$3qa$1 at taliesin.netcom.net.uk... > > "Franz GEIGER" wrote in message > news:9hf868$941$1 at newsreaderg1.core.theplanet.net... > > Did you try os.system()? > > > > Regards > > Franz > > > > Yes. If I do > >>> system("notepad") > notepad launches and I get a return code of 0. > > However, if I do: > >>> system("C:\Program Files\KeyNote\keynote.exe") > I get a return code of 1 and nothing happens. > > > > From altis at semi-retired.com Mon Jun 18 21:36:39 2001 From: altis at semi-retired.com (Kevin Altis) Date: Mon, 18 Jun 2001 18:36:39 -0700 Subject: Teaching Pyhton on Wintel References: <1ev6xe3.15eskd91k2u1eaN%p.agapow@ic.ac.uk> <3B2E887A.92DE8176@home.net> Message-ID: <0%xX6.1012$Lt1.646550@news.uswest.net> IDLE is included in the ActivePython distribution in \Python21\Tools\idle if you feel the desire to use it. In addition, PythonWin does have an interactive prompt built-in or you can launch a separate Python interpreter shell. Actually, I don't think there is anything in IDLE, that isn't included in PythonWin, except that lovely IDLE tk interface ;-) ka "Sheila King" wrote in message news:ii3tits64uq6jct3qfbs9r28c683ln8m7v at 4ax.com... > On Mon, 18 Jun 2001 16:02:18 -0700, Chris Barker > wrote in comp.lang.python in article <3B2E887A.92DE8176 at home.net>: > > :I second the notion to use PythonWin (it comes with the activestate > :distribution). I found it a lot easier to get started with than IDLE. > > I just taught a two week survey of Python to high school students who > had been working with C++ all year and just did Python at the end as a > closing cap to the course. > > I put both PythonWin and IDLE on the machines, and let them use > whichever they preferred. > > PythonWin does handle prompts in a funny way (I prefer the command line > look, myself), and there were some other issues (I can't recall at the > moment), so sometimes it was nice to also have IDLE on the machines. > Some students preferred on or the other, so they had a choice. > > -- > Sheila King > http://www.thinkspot.net/sheila/ > http://www.k12groups.org/ > From noselasd at frisurf.no Thu Jun 21 09:38:09 2001 From: noselasd at frisurf.no (Nils O. Selåsdal) Date: Thu, 21 Jun 2001 15:38:09 +0200 Subject: JSP vs Python any takers References: <5agY6.517092$166.10724721@news1.rdc1.bc.home.com> Message-ID: "TC" wrote in message news:5agY6.517092$166.10724721 at news1.rdc1.bc.home.com... > Hi ALL > > 1) If you have python script does the python interpreter have to recompile > the code every time > it is executed from a WEB page, can it be compile once like java can on > a JSP page Its compiled to' bytecode' bytecode is still interpreted though, and many things are slower than java..(java dynamically compiles to native when needed...) > 2) On a linux apache box is there a python add-in that allows phython script > to be used to create > dynamic pages like you can when you use python script on an M$ IIS web > server ok... You dont need the embedded python module/interpreter to to that, you can use CGI. > 3) Pound for pound how does a JSP app scale vs a python WEB app > > why would I use python over JSP Unless you enjoy using python, require some python features/libraries, you shouldnt.. probably... also, look at http://webware.sourceforge.net/ From erik at thingamy.net Mon Jun 4 10:13:35 2001 From: erik at thingamy.net (Erik Enge) Date: Mon, 4 Jun 2001 16:13:35 +0200 (CEST) Subject: makepasswd In-Reply-To: <3B1B838B.BC9FD4CC@oek.dk> Message-ID: On Mon, 4 Jun 2001, Peter I. Hansen wrote: > Is there a python funtion to generate passwords ? (Like the perl > makepasswd) I'm sure there is a better one, but this is something I implemented a year or two ago. This can make pronouncable passwords, I've trained it ;) It's ugly and over-documented, but it worked last time I tested it. Pick it up at: . From olavb at yahoo.com Thu Jun 28 07:38:03 2001 From: olavb at yahoo.com (Olav) Date: 28 Jun 2001 04:38:03 -0700 Subject: Python embebbed with Oracle SQL*Plus References: <9hebu5$12lo$1@news.idiom.com> Message-ID: "James T. Dennis" wrote in message news:<9hebu5$12lo$1 at news.idiom.com>... > In comp.lang.python Olav wrote: > > > Some time ago I did some Oracle SQL*Plus on UNIX, > > and I was able to write quite powerful scripts > > embebbed in ksh (Korn Shell). > > > Is something similar possible with Python? > > I presume your ksh scripts were passing > SQL code to an sql command (possibly in > the form of "here" documents). > > For course you can build arbitrary commands > in Python and invoke the system to execute > them. (sys.system()?). This is a very simple Cygwin/NT example: *************** PLUS33 scott/tiger at prod_sa < (fwd) Message-ID: <9y/F7kKkX0RK092yn@bellatlantic.net> Jose' Sebrosa wrote: |The problem with complexes is to arrange them in a unidimentional structure. As |we can map R to C (and vice-versa), it is possible: |[...complex mapping C --> R...] |Thats the only way I can figure to invent a comparison between two complexes, |and it seems preety absurd to me... Here's an obvious way to well-order two complex numbers: def lexigraphic_order(c1,c2): if c1.real < c2.real: return -1 elif c1.real > c2.real: return 1 else: return cmp(c1.imag,c2.imag) For most purposes, the lexigraphic order has little mathematical use. Here's another obvious one that has a bit of mathematical meaning: def magnitude_order(c1,c2): if c1==c2: return 0 elif abs(c1)==abs(c2): return cmp(c1.real,c2.real) else: return cmp(abs(c1),abs(c2)) I-could-probably-even-order-unicode-strings-ly yours, Lulu... From yirong99 at stanford.edu Tue Jun 26 15:38:54 2001 From: yirong99 at stanford.edu (Yirong Shen) Date: Tue, 26 Jun 2001 12:38:54 -0700 Subject: threadpool Message-ID: Can anyone suggest a good threadpool implementation for Python? Thanks, Yirong From djc at object-craft.com.au Tue Jun 26 23:07:44 2001 From: djc at object-craft.com.au (Dave Cole) Date: 27 Jun 2001 13:07:44 +1000 Subject: Sybase module 0.28 (Brown Paper Bag) released Message-ID: What is it: The Sybase module provides a Python interface to the Sybase relational database system. The Sybase package supports almost all of the Python Database API, version 2.0 with extensions. The module works with Python versions 1.5.2 and later and Sybase versions 11.0.3 and later. It is based on the Sybase Client Library (ct_* API), and the Bulk-Library Client (blk_* API) interfaces. The 0.20 and later releases are a re-implementation of the module using a thin C wrapper on the Sybase-CT API, and a Python module to provide the DB-API functionality. It is still a work in progress, but should be good enough for most purposes. Changes for this release: After shooting my mouth off about the cool things that you can do with bulkcopy I went back and tested my claims. I found that I had not implemented support for the bulkcopy optional argument to Sybase.connect()... Changes for this release: - The following claim I made earlier today on comp.lang.python is now true: If your source data is CSV format then you can use another one of the modules I wrote to load it into a format suitable to feeding the bulkcopy object in the Sybase module. The module was written specifically to handle data type data produced by Access and Excel. http://www.object-craft.com.au/projects/csv/ >>> import Sybase, csv >>> >>> db = Sybase.connect('SYBASE', 'user', 'password', bulkcopy = 1, auto_commit = 1) >>> db.execute('create table #bogus (name varchar(40), num int)') >>> >>> p = csv.parser() >>> bcp = db.bulkcopy('#bogus') >>> for line in open('datafile').readlines(): >>> fields = p.parse(line) >>> if fields: >>> bcp.rowxfer(line) >>> print 'Loaded', bcp.done(), 'rows' - Documentation updates. - Dave P.S. Hopefully there will be a period of more than one day before the next release... -- http://www.object-craft.com.au From barry at digicool.com Mon Jun 18 02:07:54 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Mon, 18 Jun 2001 02:07:54 -0400 Subject: Two minor syntactic proposals References: Message-ID: <15149.39610.576730.159327@anthem.wooz.org> GM> Suppose you have a class and want to add a new method to GM> it. (Why? It's someone else's, you aren't allowed to change GM> the source, and subclassing won't do because these things are GM> created by code you don't control.) GM> You can do it, thus: | def new_method(self, x): | something_else() | return x+1 | Thing.new_method = new_method Long ago, I propsed being able to do something like class Thing: pass def Thing.new_method(self, x): something_else() return x+1 No new syntax is necessary, and it would allow more separation of interface and implementation, allowing the /interface/ to be the class definition, maybe even scarecrow-ish in nature, while the implementation could be completely separated into a separate file, or farther down in the same file. It never caught on, but this was in the (way) pre-PEP days. If there's interest, I could write up a PEP on this. -Barry From just at letterror.com Sat Jun 9 12:52:03 2001 From: just at letterror.com (Just van Rossum) Date: Sat, 09 Jun 2001 18:52:03 +0200 Subject: spell method chaining? References: <19l8IVAAgJI7EwAk@jessikat.demon.co.uk> <3B2111FF.D998EEE4@letterror.com> <3B21D830.E823D70F@letterror.com> <$6JOJKAxteI7EwQC@jessikat.fsnet.co.uk> Message-ID: <3B225433.11E13251@letterror.com> Robin Becker wrote: > > In article <3B21D830.E823D70F at letterror.com>, Just van Rossum writes > Well what I'm really interested in is dynamically wrapping classes for a property collection. (erm, I didn't write that, you did ;-) > With a simple ion that's fairly easy, but when the collection is over a class then the wrapper > __getitem__ has to try and chain getattr to either go through the wrapped class or if that fails > to try the collection. > > the main code looks like > > _ItemWrapper={} > > class TypedPropertyCollection(PropHolder): > def __init__(self, exampleClass): > #give it same validation rules as what it holds > self.__dict__['_value'] = exampleClass() > self.__dict__['_children'] = {} > > def __getitem__(self, index): > try: > return self._children[index] > except KeyError: > Klass = self._value.__class__ > if _ItemWrapper.has_key(Klass): > WKlass = _ItemWrapper[Klass] > else: > class WKlass(Klass): > def __getattr__(self,name): > try: > return self.__class__.__bases__[0].__getattr__(self,name) > except: > return getattr(self._parent,name) > _ItemWrapper[Klass] = WKlass > > child = WKlass() > child._parent = self > for i in filter(lambda x,K=child.__dict__.keys(): x in K,child._attrMap.keys()): > del child.__dict__[i] > > self._children[index] = child > return child > > it currently uses the __bases__ trick for compatibility with earlier python, but that goes wrong > under certain conditions the gen(gen(C)) recursion etc. The nested scopes version would work OK. I can't deduct from this code what on earth it's supposed to be _doing_: it's way too convoluted for me to parse. But I'm wondering: is subclassing really the best solution for the problem? Instead of painfully trying to dynamically create classes, why don't you use containment and delegation? As in: class Wrapper: def __init__(self, object): self.__object = object def __getattr__(self, name): # this is enough for retrieving attrs, if attrs are set-able, you # also need to need a corresponding __setattr__ and __delattr__ return getattr(self.__object, name) def __getitem__(self, index): return Wrapper(self.__object[index]) # whatever Just From rnd at onego.ru Sun Jun 24 13:48:47 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 24 Jun 2001 21:48:47 +0400 (MSD) Subject: Python scripting [was: Re: emacs speedbar for python mode?] In-Reply-To: <1bq4h9.tq8.ln@twocups.sirinet.net> Message-ID: On Sun, 24 Jun 2001, Bud Rogers wrote: >Fran?ois Pinard wrote: > >> If I could only script Emacs with Python! Emacs LISP is not so bad, >> it has a lot of virtues, yet writing Scheme or Python is more >> pleasurable to me. > >> In these days, soon in the morning, before I'm fully awake, I vaguely >> dream of big things, like developing semi-automatic Emacs LISP to >> Python converters (a bit like CWeb does for Knuth Pascal code) and >> with this, whatever would be necessary to replace or interface with >> the Emacs C core. :-) In my dreams still, I start the exercise with >> Gnus or Calc, >> as the result would be quite useful in itself. Sigh! > >I have had similar thoughts. Imagine a programmer's editor of the >calibre of [x]emacs that used python as a built in extension language >in the same way that emacs uses lisp. Did you mean Cool Edit? Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, June 24, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "Ok, I pulled the pin. Now what? Where are you going?" _/ From llothar at mailandnews.de Sat Jun 16 07:29:12 2001 From: llothar at mailandnews.de (Lothar Scholz) Date: Sat, 16 Jun 2001 13:29:12 +0200 Subject: qt or gtk? References: Message-ID: On Sat, 16 Jun 2001 05:52:12 GMT, sill at optonline.net (Rainy) wrote: > >I want to learn python gui programming in linux. I think tk looks too ugly, so >I narrowed down the choice to two main contenders, qt and gtk. Which of these >has more complete and up-to-date python bindings? Are there other reasons >to prefer one of these over another for python gui work? Why are you always selecting between QT and GTK ?????? There is for example www.fox-toolkit.org with a python binding. From thomas at cintra.no Tue Jun 19 16:04:24 2001 From: thomas at cintra.no (Thomas Weholt) Date: Tue, 19 Jun 2001 20:04:24 GMT Subject: Server design choices Message-ID: Hi, I got a Three-tier XML-based "server" ( it's not a server yet, - read on ) where a postgreSQL-database stores pieces of xml in a standardized format. The data is fetched and updated thru a DataProvider object. In the middel-tier the data is parsed into Python Objects and some methods are provided to get xml-data into and out of the database, along with some methods to parse the output of calls to the DataProvider into XML to pass on the the application tier. In the application tier the xml is parsed into HTML, WAP, plain text etc. and data is sent into the lower levels by using SOAP-like ( soon real SOAP ) requests. The problem now is this: - each time a object is created, an instance of DataProvider is created too. Each instance of DataProvider creates another connection to the database. This should be done in a pooled-fashion. - the xml for each object is stored in seperate files, not in the module itself, and loaded on import. The reason for this is to ease updating the xml-files. This increases time importing modules. When all modules are loaded and connection created, the system reacts quickly and all is well. A simple CLI test script shows this. What I don't know is how the system will react when it is accessed thru a web-browser or a planned CLI-based client etc. I want to create a server, a long-time running process where all loading of modules are done and there's a pool of postgresql-connections. I want to use mod_python to implement the web-interface and use SOAP for all non-browser interfaces. How is loading of modules etc done in mod_python? when the apache -server starts or when I user calls my python-driven pages? Would I be able to get acceptable performance at higher loads? I also wanted to look into creating a complete SOAP-based server, where the Apache server could connect using SOAP and format SOAP-responses into HTML for the client. What would be the easiest way of doing this? This way the modules would be loaded and all connections ready. The bottom line is: how could I create a system where response time is at a minimum? By writing a stand-alone server, independant of the apache-server the contents going to be served by, perhaps based on SOAP or by making simple classes that could be used in mod_python? Examples on how to create a threaded-server for this purpose would help alot. Any clues or hints would be great. Thomas From web.mail at lycos.com Wed Jun 27 00:26:30 2001 From: web.mail at lycos.com (Alan Green) Date: 26 Jun 2001 21:26:30 -0700 Subject: the indentaion for grouping thing References: <3b34de9a$1_2@anonymous> <9h2qpa$6bg$1@slb0.atl.mindspring.net> <3b38f4a5_1@anonymous> Message-ID: <270c68fe.0106262026.2c3fc12c@posting.google.com> Anonymous wrote in message news:<3b38f4a5_1 at anonymous>... > Like I said, all answers like "well, just use product x" don't fly because > it's not just me that has to use the script. I want my scripts to be > maintainable by people I don't necessarily know of. I consider it a design > flaw to have the language dependent upon artificial solutions that are > external to the language in order to have it be maintainable. > > Anyway, nothing will change, so is there a product like I asked about that > validates and parsers python with paired delimiters added? Not pindent, and > not comments, because the script has to be unparseable by python without the > pre-processor. Well, product x should meet your needs. ;*) alan From bill-bell at bill-bell.hamilton.on.ca Wed Jun 27 19:28:10 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Wed, 27 Jun 2001 19:28:10 -0400 Subject: ActiveX Controls in Python In-Reply-To: <993614973.1685.43600.l10@yahoogroups.com> Message-ID: <3B3A33CA.12523.58D2F24@localhost> davidw at weblink.com.au (David White) wrote, in part: > "Bill Bell" wrote in message > > 2. So host the ActiveX in Python code written with the aid of > > wxPython. I haven't responded to your first question about wxPython's functionality as compared with that of MFC because I believe that Robin Dunn has already done so. > Since I'll be doing the final product using MFC, I was hoping to do > the prototype using Python's MFC bindings; also, I haven't used > wxWindows before, and time is going to be quite an issue - so it'd be > better to use MFC due to my familiarity with it. What I was suggesting ~might~ have been useful as a prototype for use in elliciting feedback from users and to a much less degree understanding the techniques that would be needed. However, it appears to me that you might want to make a series of versions that start with Python driving MFC and culminate in C++ driving MFC. In that case, I think you're probably right. Good luck! Bill From hamish_lawson at yahoo.co.uk Sat Jun 16 19:28:15 2001 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: 16 Jun 2001 16:28:15 -0700 Subject: Python equivalent of CPAN Library modules References: Message-ID: <915a998f.0106161528.223d755b@posting.google.com> David Hurt wrote: > One thing I think may help python is the availability of even > more "batteries" in the form of additional modules available. > One such source may be the perl CPAN repository. I think this is an excellent idea. When I can't find a Python module for a given task, I usually check out CPAN to see if there is a Perl module that I can borrow and translate. I have myself thought before about suggesting a systematic translation of the most useful Perl modules, so I'd be willing to help where I can. There are a few gaps in the Python module space, and I think it would help Python if those were plugged (of course, by the same taken there are many modules available for Python that aren't available for Perl). > My general plan is this > > 1. Examine the CPAN archive and map the Perl modules to equivalent python > standard library modules (and contributed modules in the Vaults of Parnassus) > (I imagine that this will be a HUGE effort) > 2. Get a list of the most commonly requested CPAN modules > 3. Convert the highest CPAN module that is not already mapped to python and > submit to the Vaults of Parnassus > 4. Repeat steps 1-3 until some arbitrary time or until the "most important" > 20-30% of the CPAN modules have a python equivalent. The number of modules in CPAN is huge and often there are several different modules taking a different tack on solving the same basic problem. Moreover a good number are probably quite specialised or may be little used. I'd suggest not trying to map all the CPAN modules to Python equivalents first off, but instead going straight to step 2 and doing the attempted mapping for each CPAN module as you come to it. Hamish Lawson From sholden at holdenweb.com Thu Jun 28 15:17:06 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 28 Jun 2001 15:17:06 -0400 Subject: Extending python & mutability References: Message-ID: "John" wrote ... > When extending python, if I have a function that is expecting a list whose > contents are mutible, can I modify the contents and will the changes be > reflected in back in Python? > >>> def change(a, l): ... a = 34 ... l.append("extra") ... return a, l ... >>> a1 = 12 >>> l1 = ["nothing"] >>> a2, l2 = change(a1, l1) >>> a1, l1 (12, ['nothing', 'extra']) >>> a2, l2 (34, ['nothing', 'extra']) In other words, immutable arguments changed inside a function continue to hold their original values (because you are only binding the argument name to a new value). Mutable arguments changed inside a function will reflect their updated values (since you have actually changed the value to which the argument was bound). As you can also see, a functioncan return a complex type like a tuple, allowing you to return values based on immutable arguments in whatever quantity you like. regards Steve -- http://www.holdenweb.com/ From sdm7g at Virginia.EDU Thu Jun 21 23:17:18 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Thu, 21 Jun 2001 23:17:18 -0400 (EDT) Subject: Another Wart! string.find() [ was: namespace issue? ] In-Reply-To: <5.0.2.1.0.20010621223405.02b6dec0@mail.mindspring.com> Message-ID: On Thu, 21 Jun 2001, Chuck Esterbrook wrote: > >Zero is natural whenever you are thinking in terms of offsets: > > every ruler starts with an implied 0 inches (or cm. or other). > > Rulers don't have much to do with lists. The first measures; the second > contains. True. But the initial discussion was about a function that finds the offset into a string of a substring. And when you have to add or subtract those offsets, zero based offsets are better. We're talking about what is essentially "pointer arithmetic" even though there are no C pointers involved. ( That's the real reason C is zero based -- where ever they got the idea from! ) Whether strings should even be considered sequences is another one of those engineering tradeoffs. I've had and seen lots of code that wants to crawl thru possibly nested sequences and do something to the things at the end-leaves. Sometimes strings are supposed to be the exception -- sometimes they aren't. Makes it difficult to write generic code. Lisp has both atomic-symbols and string-sequences, and you can convert from one to the other, so it's possible to get the behavior you want from a generic function if you're willing to be specific with your input. ( Also, symbols are interned strings, so equality testing is just pointer comparison -- and all of the things you do to symbols are usually 'atomic' in the same sense -- you don't need to see their parts. ) I don't disagree with most of your other points -- except that I know that *I* learned zero based sequences in High School math -- N-sub-zero, N-sub-one, ... and I think I've seen it in my kids homework. -- Steve Majewski From sdm7g at Virginia.EDU Fri Jun 1 17:56:26 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Fri, 1 Jun 2001 17:56:26 -0400 (EDT) Subject: random In-Reply-To: <3b17a2f1.411766@nntp.sprynet.com> Message-ID: On Fri, 1 Jun 2001, David C. Ullrich wrote: > On Thu, 31 May 2001 19:52:28 -0400 (EDT), "Steven D. Majewski" > wrote: > > > >On 31 May 2001, Mark 'Kamikaze' Hughes wrote: > > > >> "Anyone who considers arithmetical methods of producing random numbers > >> is, of course, in a state of sin." -John Von Neumann > >> > >> Unless you have random-number-generating hardware, you don't really > >> have truly random numbers. > > > >That's what I was always taught, however in the light of > >Gregory Chaitin's work or randomness in arithmetic: > > > > > > > >JVN may have been wrong. > > ??? There's a _lot_ of stuff there. > > Could you give us a hint regarding exactly what work > of Chaitin's shows we can get "truly random" numbers from > arithmetic algorithms? Pick any one at random, David! ( Starting from the top down isn't a bad strategy either. ) I'm not sure that there is a practical method for a RNG there, and I certainly don't grasp it all, but Chaitin asserts that mathematics is essentially a random process. And you ought to be able to get random numbers out of a random process -- right ? Some of the interest from Physicists in Chaitin's work is that if mathematics is a random process, then that may be at the root of quantum randomness. *IF* you can believe his assertion, then that source of randomness is easier to swallow than the idea that the act of abservation causes some magical effects. The arguments that go with that assertion are more than I could summarize here, even if I did grasp it all myself. >From the Nature article "Randomness everywhere" : | This recent work reinforces the message of algorithmic information | theory that randomness is as fundamental and as pervasive in pure | mathematics as it is in theoretical physics. In our opinion it also | gives further support to `experimental mathematics', and to the | `quasi-empirical' view of mathematics which says that although | mathematics and physics are different, it is more a matter of degree | than black and white > A physical RNG can have the property that one cannot make > any prediction about the value of the next bit even given > _complete_ information about how the numbers are being > generated. An arithmetic algorithm with this property seems > obviously impossible - if you know the algorithm and you > know the current state of the RNG you can predict the > next number... whatever the algorithm is, someone with all > this information can devise a "randomness test" that the > RNG will fail miserably. Or so it seems. Chaitin's Omega number is basically the probability that a randomly generated program will halt -- which is undecideable, but can be approximated experimentally and observing it -- each binary digit of that probability is random. But, how this ties into a basic randomness at the root of mathematics is more than I can grok yet, but some of it is in "Randomness and Complexity in Pure Mathematics" : | One normally thinks that everything that is true is true for a | reason. I've found mathematical truths that are true for no reason at | all. These mathematical truths are beyond the power of mathematical | reasoning because they are accidental and random. | | Using software written in Mathematica that runs on an IBM RS/6000 | workstation, I constructed a perverse 200-page algebraic equation with a | parameter N and 17,000 unknowns: | | Left-Hand-Side(N) = Right-Hand-Side(N). | For each whole-number value of the parameter N, ask whether this | equation has a finite or an infinite number of whole number | solutions. The answers escape the power of mathematical reason because | they are completely random and accidental. | | This work is an extension of famous results of Gdel and Turing using | ideas from a new field called algorithmic information theory. -- Steve Majewski From dsh8290 at rit.edu Fri Jun 1 10:25:32 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 1 Jun 2001 10:25:32 -0400 Subject: Obsolesence of <> (fwd) In-Reply-To: <3B16D681.E12A4554@Lugoj.Com>; from JamesL@Lugoj.Com on Thu, May 31, 2001 at 04:40:49PM -0700 References: <9f6el30dv5@enews2.newsguy.com> <3B16D681.E12A4554@Lugoj.Com> Message-ID: <20010601102532.A7208@harmony.cs.rit.edu> On Thu, May 31, 2001 at 04:40:49PM -0700, James Logajan wrote: | All the proponents of "!=" can point to for justification is the | usage by syntactically unrelated languages, like "C". May as well | start using pointers, malloc, free, etc. So there! ;-) If we were talking about C/C++/Java then it makes more sense : '!' is the logical not operator so != means "not ,erm, assignment". Ok, how about !== for "not equals" ? You wouldn't prefer to use '/=' as Eiffel did, now would you? I think we should use the mathematical symbol of an equality sign with a slash through it. Is that glyph in Unicode? :-) Now-I-just-need-a-Unicode-keyboard-and-some-extra-fingers-ly y'rs -D From nstalkie at tvd.be Wed Jun 27 16:12:30 2001 From: nstalkie at tvd.be (Sammy Mannaert) Date: Wed, 27 Jun 2001 20:12:30 GMT Subject: new to python References: Message-ID: <3B3A408F.18648823@tvd.be> Beebe wrote: > > Hello comp.lang.python, > > I am a Linux User and I am new to Python Programming and this > newsgroup. I don't really know what python is all about so it would be > much appreciated if you would answer my following questions. > > - Is python like c/c++ where you can make pretty much any kind of > program you want whether is be games, gui apps, etc. or is it like cgi > where you can only use it in websites? > you can make almost all the things you can write in c or c++. (kernel drivers in python aren't a good option i believe :) python is interpreted though, so it will give you a performance hit. i don't think you will want to code a quake 3 in python :) you can interface with functions written in c ! so if performance is too low (note that i never had a problem with python performance), you could rewrite the slow code in a c module. > - Is python object oriented? > yes. > - Should I develop in Python? Is it good for programming, is it > powerfull and are job opportunities good for Python developers? > it's very powerful, easy and quick to learn and is very well designed. not too much job opportunities though :( > - When I make a Python program, do I just leave it as a .py file or is > there a way to make it into some kind of executable file like in C++? > When I make a program in Python, how do I distribute it out to people? > Do I just send out the .py file? Does the user need some kind of > runtime environment or something? Do they need to download something > else rather than my program? > the user will need to have python installed. there's also something called freeze which can make a standalone executable, but i never used it, so i can't give you any advice on that. to use it as a "normal" program you can add this to the top of the file : #! /usr/bin/env python your shell (assuming you run linux) will run the line after the '#!' (this particular line works on my freebsd system .. maybe you'll need to make it something like #!/usr/local/bin/python depending on where you installed python) > I know that's a lot of questions but I haven't found them on the net > yet. Please answer my questions if you will by emailing me at > jonbeebe at softhome.net. > > If you email me, that way I'll be sure to recieve the reply, > otherwise, i might miss it. > > Thank you very much, > - Beebe From spam_kill.guse at hobbiton.org Wed Jun 6 12:33:20 2001 From: spam_kill.guse at hobbiton.org (goose) Date: Wed, 06 Jun 2001 16:33:20 GMT Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3b1cdc84.5514@bolder.com.co.za> <9fleid$3rp$1@oslo-nntp.eunet.no> <3B1E4951.7F36D4E4@alcyone.com> <3B1E50E1.35AE59C@lmf.ericsson.se> <3B1E52DA.BBC9FC32@alcyone.com> <3b1e5601.3970@bolder.com.co.za> <3B1E5836.E7F1D88F@lmf.ericsson.se> Message-ID: <3b1e5b50.3adb@bolder.com.co.za> Attila Feher merely scratched his head and went: > goose wrote: > [SNIP] >> >> *REAL* computer users don't buy games ... they write their own >> > > And they don't program in Pascal! :-))) > LOL - neither do they eat quiche ... hehe -- goose ----- " as a matter of fact, I don't find it very funny that this guy has posted the same joke twice in 2 days...... it's bad enough when other people steal jokes off each other but when you rip off your own jokes there's something wrong with you " --atj, cillian on about BretMS From faustus at pureevil.org Wed Jun 6 18:46:13 2001 From: faustus at pureevil.org (Dr. Faustus) Date: 6 Jun 2001 15:46:13 -0700 Subject: Bios calls in Python? References: <3b1e6611.6945219@news.muenster.de> Message-ID: <72e66889.0106061446.5ffae35e@posting.google.com> m.bless at gmx.de (Martin Bless) wrote in message news:<3b1e6611.6945219 at news.muenster.de>... > What about DOS calls? > I know the DOS interrupt "get truename of a file" still exists, and > that's exactly what I'm looking for. (In case of substituted drives). > But I don't know how to call from Python. This will only work on 95/98/Me. It will not work on NT/2K/XP. There is definitely a Win32 API call that will do this on all those platforms. Depending on exactly what you want, this is probably GetFullPathName, which is wrapped in the win32api library. -- Dr. Faustus faustus at pureevil.org From MrTJC at TimChristian.com Mon Jun 18 16:04:21 2001 From: MrTJC at TimChristian.com (Tim Christian) Date: 18 Jun 2001 15:04:21 -0500 Subject: Embedding menus in frames prevents alt+key defaults? Message-ID: Howdy, I'm learning how to use Python and Tkinter using Mark Lutz' _Programming_Python_ (2nd edition) and have run into an odd side effect. It may be Tk specific (OT?), but I'll ask here anyway. Lutz discusses the relative merits of embedding menus into top level windows versus frames. The frames route seems like a good idea for reusable objects. However, after I embed menus into frames, I notice that the menu items, though underlined, are no longer selectable via the Alt key (eg, Alt+F doesn't bring up the "File" menu, though the "F" character is underlined). Is this typical behavior? Perhaps it's just a problem under my development platform (Windows 2000, Python 2.1)? Thanks, Tim. From paulp at ActiveState.com Thu Jun 28 18:32:23 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Thu, 28 Jun 2001 15:32:23 -0700 Subject: PEP scepticism References: <9hfg1n$du33c$1@ID-89274.news.dfncis.de> Message-ID: <3B3BB077.1E51F2C9@ActiveState.com> It annoys me when people equate the PEP process with the adding of features. Features were added before there was a PEP process. Features have been added with out a PEP even since the process existed. The PEP process also handles things like library upgrades and distutils improvements. If you think Python is changing to quickly, that's fine. But what does it have to do with PEPs? -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook From see at my.signature Fri Jun 1 01:24:52 2001 From: see at my.signature (Greg Ewing) Date: Fri, 01 Jun 2001 17:24:52 +1200 Subject: Appliying method to list of objects References: Message-ID: <3B172724.17E588E2@my.signature> Alex wrote: > > You could do this in python2: > > [x.dosomething() for x in list] I can't see how that can be regarded as any better. It's no clearer, and it wastes time doing unnecessary work -- i.e. building a list and then throwing it away. Same goes for using map(). -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From steve at zeropps.uklinux.net Fri Jun 8 13:15:16 2001 From: steve at zeropps.uklinux.net (Steve) Date: 8 Jun 2001 17:15:16 GMT Subject: GROUP TAKEOVER IN PROGRESS References: <902430AC4moondustapexnet@209.99.56.9> <93hn81$l4m$1@nnrp1.deja.com> <9025628F7moondustapexnet@209.99.56.9> <3a5c8520_1@news.foxinternet.com> <902581E21moondustapexnet@209.99.56.9> <3a5ce21b_1@news.foxinternet.com> <4A982771F09.psskvxvn@vluxxijwai.net> Message-ID: On 7 Jun 2001 22:40:35 -0700, Wroot wrote: >shawntaub at yahoo.ca (Shawn Michael Taub) wrote in message news:... >> All your base are belong to us, > >Where is this from? I keep seeing it everywhere. Must be a classic. Something >Pr. Nixon used to say, perhaps? I've seen this link in another group with the post title: ALL YOUR BASE ARE BELONG TO US http://rmitz.org/AYB3.swf I havn't checked the link out yet so don't know how relevant it is. -- Cheers Steve email mailto:steve at zeropps.uklinux.net %HAV-A-NICEDAY Error not enough coffee 0 pps. web http://www.zeropps.uklinux.net/ or http://start.at/zero-pps 3:52pm up 126 days, 16:42, 2 users, load average: 1.00, 1.00, 1.00 From duncan at NOSPAMrcp.co.uk Fri Jun 29 04:12:40 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Fri, 29 Jun 2001 08:12:40 +0000 (UTC) Subject: functional programming and default parameters References: Message-ID: "Nick Perkins" wrote in news:aBV_6.367752$eK2.75191451 at news4.rdc1.on.home.com: > ..suppose i want to create a list of functions with no parameters, > such that: > > fns[0]() -> 0 > fns[1]() -> 1 > fns[2]() -> 2 > etc. > > this does not work: > > > Can this be done without using default parameters? Of course it can, but you might be better off using a functional language if you want to do this kind of thing: ----- begin ---- from __future__ import nested_scopes def create_f(x): def f(): return x return f fnlist = [ create_f(i) for i in range(10) ] print fnlist[0](), fnlist[1]() print fnlist[2](99) ---- end ---- Prints: 0 1 Traceback (most recent call last): File "D:\temp\fn.py", line 8, in ? print fnlist[2](99) TypeError: f() takes no arguments (1 given) You could also get the same effect by making the 'functions' callable class instances (left as an exercise for the reader). -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From joonas at olen.to Mon Jun 11 15:15:05 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Mon, 11 Jun 2001 22:15:05 +0300 Subject: EXECing multiple lines. Message-ID: <3B2518B9.5C5CE56B@olen.to> What might be wrong when I get the following error? >>> exec """for x in range(5): print x""" Traceback (innermost last): File "", line 1, in ? exec """for x in range(5): File "", line 2 print x ^ SyntaxError: invalid syntax >>> From bokr at accessone.com Sun Jun 10 19:19:27 2001 From: bokr at accessone.com (Bengt Richter) Date: Sun, 10 Jun 2001 23:19:27 GMT Subject: BUG? list-comprehension's inconsistency? was: Re: list-display semantics? References: Message-ID: <3b23f1ed.156969349@wa.news.verio.net> On Sun, 10 Jun 2001 23:00:30 +0400 (MSD), Roman Suzi wrote: >On Mon, 11 Jun 2001, jainweiwu wrote: > >BTW, I think it could be list-comprehension's >inconsistency (if not a bug!), look: > >1->>> [x for x in [1, 2, 3], y for y in [4, 5, 6]] # first try >Traceback (most recent call last): > File "", line 1, in ? >NameError: name 'y' is not defined >2->>> [x for x in [1, 2, 3], [y for y in [4, 5, 6]]] >[[1, 2, 3], [4, 5, 6]] >3->>> [[x for x in [1, 2, 3]], [y for y in [4, 5, 6]]] >[[1, 2, 3], [4, 5, 6]] >4->>> [x for x in [1, 2, 3], y for y in [4, 5, 6]] # 2nd try >[[1, 2, 3], [1, 2, 3], [1, 2, 3], 6, 6, 6] > >-- and this lead to subtle errors. It is subtle, but not a bug per se, if you ask me. But it is like a combination of operator precedence and name scope traps for the unwary, which I was ;-) > >There are even two things which seem wrong here: > >A) 1 and 4-s steps differ only because y is now defined. >B) results of step 2 and 3 do not differ, while visually >I've added [] around first item. I think it's the implicit tuplification again, but so long as that's legal we can't complain that 2+3 and 4+1 have the same result, even though the expressions look different ;-) >2->>> [x for x in [1, 2, 3], [y for y in [4, 5, 6]]] Tuplifying: >>> [x for x in ( [1, 2, 3], [y for y in [4, 5, 6]] )] [[1, 2, 3], [4, 5, 6]] or: >>> xtuple = ( [1, 2, 3], [y for y in [4, 5, 6]] ) >>> xtuple ([1, 2, 3], [4, 5, 6]) >>> [x for x in xtuple ] [[1, 2, 3], [4, 5, 6]] >3->>> [[x for x in [1, 2, 3]], [y for y in [4, 5, 6]]] ISTM this one has to be legal, since it's just a list of expressions which individually happen to be (unambiguous) list comprehensions. I.e., >>> xcomp = [x for x in [1, 2, 3]] >>> ycomp = [y for y in [4, 5, 6]] >>> [[x for x in [1, 2, 3]], [y for y in [4, 5, 6]]] [[1, 2, 3], [4, 5, 6]] >>> [ xcomp, ycomp ] [[1, 2, 3], [4, 5, 6]] I hope I am not misleading anyone. I am still new to Python. From gardner at cardomain.com Thu Jun 7 16:23:59 2001 From: gardner at cardomain.com (Jonathan Gardner) Date: Thu, 7 Jun 2001 13:23:59 -0700 Subject: Review my async socket server (Caution: 5 kB attachment) References: <9fma5s$bcn$1@brokaw.wa.com> Message-ID: <9fonn4$shm$1@brokaw.wa.com> Jonathan Gardner wrote: > I wrote an asycnchronous socket server based loosely off of something I > found off the net created by Sam Rushing's Asyncore. I want general > opinions on everything about the code. I have been doing Python for about > a week now, so I want to make sure I am coding properly. If there are any > hints or tips anyone would like to give, I am glad to accept them. > > The attachment is tarred and gzipped. The stuff is only meant to run on > Linux, I don't have a Windows box to test it on... and frankly, Scarlet, I > don't give a darn. =) > One thing I was wondering how to do... is there an easy to print warnings? In Perl you have warn "Something", but I didn't see anything that stuck out in Python. Do you have to print to STDERR in order to do this? From sandipan at vsnl.com Mon Jun 11 06:27:50 2001 From: sandipan at vsnl.com (Sandipan Gangopadhyay) Date: Mon, 11 Jun 2001 15:57:50 +0530 Subject: python-ldap and openldap-2.0.7 Message-ID: <024e01c0f261$2ae3de20$020000c3@node02> It seems that the openldap-2.0.7 client-API has changed. Can python-ldap / web2ldap access the 2.0.7 slapd ? Thanks. Sandipan From dalke at acm.org Tue Jun 19 21:26:35 2001 From: dalke at acm.org (Andrew Dalke) Date: Tue, 19 Jun 2001 19:26:35 -0600 Subject: Partially evaluated functions References: Message-ID: <9gouei$940$1@slb6.atl.mindspring.net> Venkatesh Prasad Ranganath asked: >Is partially evaluated functions possible in python? If there has been a >discussion about it, where can I find the jist of the discussion? > >def conv(a, b, c): > return (a + b) * c > >faren2cel = conv(b = -32, c = 5 / 9) Here's a hack solution for unnamed parameters: class Curry: def __init__(self, func, *args): self.func = func self.args = args self.n = func.func_code.co_argcount def __call__(self, *args): args = self.args + args if len(args) == self.n: return apply(self.func, args) if len(args) > self.n: raise TypeError("too many arguments; expected %d, got %d" % \ (self.n, len(args))) return apply(Curry, (self.func,) + args) >>> def conv(a, b, c): ... return (b + c) * a ... >>> conv = Curry(conv) >>> f2c = conv(5./9., -32) >>> f2c(32) 0.0 >>> f2c(-40) -40.0 >>> f2c(82) 27.7777777778 >>> f2c(212) 100.0 >>> This only works for Python functions since straight C interface code doesn't provide enough information to know how many parameters are needed. I leave as an exercise for the student on how to support named arguments. (Hint: see the various doc extraction programs on how to get a list of parameter names and default values. It's only tedious not hard.) :) Andrew dalke at acm.org From ullrich at math.okstate.edu Thu Jun 7 10:21:11 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Thu, 07 Jun 2001 14:21:11 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> <3b19393d.703539923@news.okstate.edu> <9fgkci0gdu@enews2.newsguy.com> <3b1ce391.2243151@nntp.sprynet.com> <9fj24r01hpj@enews1.newsguy.com> <3b1e3e18.160819@nntp.sprynet.com> <9flm3p01p1n@enews2.newsguy.com> Message-ID: <3b1f8a01.1000266@nntp.sprynet.com> On Wed, 6 Jun 2001 18:35:03 +0200, "Alex Martelli" wrote: >"David C. Ullrich" wrote in message >news:3b1e3e18.160819 at nntp.sprynet.com... > ... >> Answer the question instead of only replying >> to the parts you feel like replying to. > >This thread is long enough without going around >commanding each other what to answer, but for >once I'll make an exception:-) [not fully >responding to this post -- yet -- but only to >the 'mandatory' parts:-)]: > >> _Do_ you think it makes sense to talk about >> the probability that the first digit of pi >> is 3? > >Yes! Fabulous. Let's assume for the sake of argument that pi is normal - it may well be, and it's a number that we have a name for. Pi "is" normal. If this says something about _probability_ of digits of Pi being this or that then the probability of the first digit being 3 is 1/10. (Note that by "first digit I mean the one before the decimal point.) Have you got all the money you need? I have a deal for you: I'm willing to _bet_ that the first digit of Pi is 3, for just about any stakes you name (with suitable escrow arrangements if we start talking about large sums.) Since the probability that the first digit is 3 is just 1/10 I should really ask for 9 to 1 odds here - that would make it a fair bet. But silly me, I'm willing to offer you even money on this! This is an offer you can't refuse, getting even money on a bet where you actually have a 9 to 1 advantage. > Or rather it makes sense to talk of > P(first digit of pi is 3 | y) >for any y representing (if I recall De >Finetti's formula correctly) "a self-consistent >set of beliefs about the state of the Universe". Um. Can you describe for me a self-consisent set of beliefs about the universe y with the property that P(first digit of pi is 3 | y) is something other than 1? Never mind. Don't tell me what self-consistent set of beliefs about the universe makes P(first digit of pi is 3 | y) = 1/10. But please do adopt such a set of beliefs. I could use the money... >I do not believe that it REALLY makes sense >to talk about any P(x), rather than P(x|y), >unless the y can reasonably be taken as >given by the context. I do realize that for >some strange reasons this De Finetti idea >is not universally accepted (yet:-), but >it IS widely accepted enough among scholars >of probability theory that I don't think I >need to defend it in depth -- or is my hope >unfounded and do we need to branch off into >ANOTHER huge subthread about whether >_unconditional_ probabilities "exist"...?-) Heh-heh. If it's hard or impossible to pin something down then we'd better not talk about it, and hence the things you've said about probability must be right. (No, you didn't quite say that.) >> (Or rather: Does it really make sense >> to say that the probability that the first >> digit of pi is 1/10?) > >It surely "makes sense" (like many false >statements can "make sense") but may be >false for any y, if we carefully constrain >all relevant definitions (i.e., it is quite >possible that no y such that the P(x|y), >for the x we've been talking about, which >is self-consistent in the De Finetti sense). Assuming still that Pi _is_ normal: You've _said_ that a normal number _does_ give an RNG satisfying the definition I gave, that is [c] independent digits, each with probability 1/10 (that's the decimal version). I'm not sure _exactly_ what the previous paragraph means, but it seems like you're retracting that - you no longer insist that it _is_ _true_ that the probability that the first digit of Pi is 3 is 1/10? >Alex > > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From smigowsky at dspace.de Fri Jun 29 03:25:33 2001 From: smigowsky at dspace.de (Stefan Migowsky) Date: Fri, 29 Jun 2001 08:25:33 +0100 Subject: AW: WIN32: How to control another windows application (AppActivat e not found) Message-ID: <84257D042AA7D411B3F700D0B7DB9B7C13ABEC@newsintern.dspace.de> You probably have an old Version of the Windows Scripting host. See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wsh/htm/wsV ersion.asp for the Version information. AppActivate was introduced in Version 2.0 of the Windows Scripting host but W98 was shipped with version 1.0. Try to get a new one at http://msdn.microsoft.com/scripting/ Bye Stefan > -----Urspr?ngliche Nachricht----- > Von: cliechti at nospam.mails.ch [mailto:cliechti at nospam.mails.ch] > Gesendet: Freitag, 29. Juni 2001 00:48 > An: python-list at python.org > Betreff: Re: WIN32: How to control another windows application > (AppActivate not found) > > > ---snip-- > > It's a very fragile approach (you're *WAY* better off using the > > Automation interface of the other application -- just about every > > application on Windows exposes some object model via Automation), > > but if you have some legacy app and absolutely must control it > > that way, see for example: > > > > http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/65107 > --- > > i am interested in this too and i tried the recipe from the url above, > but... > > the calculator shows up and then i get the folowing error: > --- > Traceback (most recent call last): > File "sendkeys.py", line 6, in ? > shell.AppActivate("Calculator") > File "d:\python21\win32com\client\dynamic.py", line 437, in > __getattr__ > raise AttributeError, "%s.%s" % (self._username_, attr) > AttributeError: WScript.Shell.AppActivate > --- > > there is no 'AppActivate' nor a 'SendKeys' method available! > > i'am using ActivePython 2.1 build 210 on Win98 any ideas what > this could > be? > > --- shortened piece of source - look at the link above for > the full one!: > import win32api > import win32com.client > shell = win32com.client.Dispatch("WScript.Shell") > shell.Run("calc") > shell.AppActivate("Calculator") > shell.SendKeys("1{+}") > --- > > > TIA > chris > > -- > import re > email = 'cliechti at nospam.mails.ch' > print re.sub('nospam\.','',email) > -- > http://mail.python.org/mailman/listinfo/python-list > From sill at optonline.net Sat Jun 9 17:00:11 2001 From: sill at optonline.net (Rainy) Date: Sat, 09 Jun 2001 21:00:11 GMT Subject: create backup script in python References: <7b515e0f.0106011730.6b1aa82d@posting.google.com> Message-ID: On Sat, 09 Jun 2001 20:28:50 GMT, Rainy wrote: > On 9 Jun 2001 11:26:21 GMT, Fredrik Steen wrote: >> On Sat, 02 Jun 2001 15:22:44 GMT, Rainy wrote: >>> On 1 Jun 2001 18:30:48 -0700, eric_brake wrote: >>>> What is the easiest way to write a file copy script in python? I want >>>> to use the script as a way to backup any file I choose on my hard >>>> drive. Binary mode is best while handling this range of file types, >>>> Correct? >>>> >>>> thank you >>> >>> Backup to where? I made a little script that backs up my home directory >>> to a cdrw disk, it uses mkisofs and cdrecord (unix programs). >>> >>> >> >> Would you share your script? >> > > Sure.. I think I appended it to original message but then someone snipped it. > Anyhoo, here it goes: > > > #!/usr/bin/env python > > #----------------------------------------------------------------------- > # > # > # Send bug reports, comments to Andrei Kulakov > # Last Updated: Fri Aug 11 22:03:27 EST 2000 > # Copyright (C) 2000 Andrei Kulakov > #----------------------------------------------------------------------- > > import os, sys > homedir = os.path.expanduser('~sill/') > # cdrw device (cdrecord argument) > dev = '0,0,0' > > def print_help(): > print 'backup.py script' > print 'Usage: backup.py ' > sys.exit() > > try: > image_file = sys.argv[1] > except IndexError: > print '*** Error: need one argument.' > print_help() > > os.system('cp -r /etc ' + homedir) > os.system('mkisofs -R -o ' + image_file + ' ' + homedir) > os.system('cdrecord -v -blank=fast -speed=2 -dev=' + dev) > os.system('cdrecord -v -dev=' + dev + ' -speed=2 -fs=8m ' + image_file) > answer = raw_input('Erase image file? [Y/n]') > if answer == 'Y' or answer == '': > os.remove(image_file) > os.remove(homedir + '/etc') There's an error here, it should be os.system('rm -f ' + homedir + 'etc') > > -- The point of philosophy is to start with something so simple as not to seem worth stating, and to end with something so paradoxical that no one will believe it. From jp at ulgo.koti.com.pl Fri Jun 15 07:00:35 2001 From: jp at ulgo.koti.com.pl (Jacek =?iso-8859-2?Q?Pop=B3awski?=) Date: 15 Jun 2001 11:00:35 GMT Subject: Pmw, EntryField validator and beep Message-ID: When I create EntryField, I use validate: validate={ 'validator':'alphabetic',"min":"1"} when window with that entryfield appear - there is a beep (audio signal), but when I use just: validate={ 'validator':'alphabetic'} there is no signal, but I need "min 1", becouse I don't want empty strings how to solve it? -- Love is automatic pleasure Virtual reality Terminal hate - it's a calculation Send in the child for connection "Computer God" - Ronnie James Dio From akuchlin at mems-exchange.org Thu Jun 14 10:49:32 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 14 Jun 2001 10:49:32 -0400 Subject: Curses question References: <1462444.zMo0RvPX7a@mysiu-pysiu> Message-ID: <3d7kyff75v.fsf@ute.cnri.reston.va.us> Piotr Waskiewicz writes: > Can I resize curses windows without destroying them? > Or is there bind to curses wresize()? In 2.x, Window objects have a resize() method if it's supported by the curses library. Note that wresize() may be an ncurses extension. Several SYSV curses implementations don't have a wresize() function, so the method isn't supported there; Solaris, IRIX and Tru64 are the relevant platforms here. --amk From m.faassen at vet.uu.nl Mon Jun 4 13:54:40 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 4 Jun 2001 17:54:40 GMT Subject: I NEED to TEACH you something, QUICK! References: Message-ID: <9fgi10$av0$2@newshost.accu.uu.nl> Itamar Shtull-Trauring wrote: > Rainer Deyke wrote: >> Did you actually write all that, or was it algorithmically generated? > Really... can't you recognize a simple Usenet posting on the subject of > "'Usenet discussions about war' as a metaphor for refactoring" when you see > one? Another followup; after having read your post it suddenly makes lots of sense. I am enlightened! Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From m.faassen at vet.uu.nl Wed Jun 20 18:22:41 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 20 Jun 2001 22:22:41 GMT Subject: Any other Python flaws? References: <3B2FFB55.F35720C3@my.signature> Message-ID: <9gr7nh$hhq$2@newshost.accu.uu.nl> Greg Ewing wrote: > "Tony J Ibbs (Tibs)" wrote: >> >> every quilt should contain a deliberate mistake, since >> only God can create something perfect). > Yeek! We'd better be careful with these warts, then -- if > we accidentally remove the last one, we may get smote with > a thunderbolt! There's always the whitespace based indentation. A huge wart according to many. :) Okay-so-those-usually-haven't-actually-*used*-Python-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From guido at python.org Fri Jun 29 12:13:29 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 29 Jun 2001 16:13:29 GMT Subject: Augmented Assignement (was: Re: PEP scepticism) References: <6qn16r7i69.fsf@abnoba.intevation.de> <9hhu6701d5j@enews2.newsguy.com> <6qae2r71hd.fsf@abnoba.intevation.de> Message-ID: Bernhard Herzog writes: > Augmented assignment doesn't actually offer anything that couldn't have > been done with explicit method calls, at least as far as in-place > modification is concerned, because under the covers it actually is a > method call. Explicit is better than implicit. Sorry, I don't understand why people can seriously argue *against* augmented assignment. It just baffles me. What kind of Spartan upbringing did you have? Scheme? Really, I just don't get it. This was by far the most asked-for feature ever! And that quote "explicit is better than implicit" quote is pretty tired by now. It can be used against a whole lot of Python features. --Guido van Rossum (home page: http://www.python.org/~guido/) From crj003 at yahoo.com Tue Jun 19 18:44:48 2001 From: crj003 at yahoo.com (Rich J) Date: 19 Jun 2001 15:44:48 -0700 Subject: Packing a long long type Message-ID: <5c8ecb0b.0106191444.53054b47@posting.google.com> Does anyone know how it would be possible to pack a list containing 'long long' types (like 111111111111111L) and other standard types (int, string, char). I know you can use the struct module to pack all but the 'long long'. I also know you can use the xdrlib module to pack the 'long long'. Any ideas? Thanks, Rich From ngreco at softhome.net Wed Jun 27 14:17:50 2001 From: ngreco at softhome.net (Nahuel Greco) Date: Wed, 27 Jun 2001 15:17:50 -0300 Subject: Python scripting [was: Re: emacs speedbar for python mode?] In-Reply-To: References: Message-ID: <20010627151750.3c2ff366.ngreco@softhome.net> On 26 Jun 2001 07:57:44 -0400 pinard at iro.umontreal.ca (Fran?ois Pinard) wrote: > [Roman Suzi] > > > The question was about Python scripting editor, though. > > In my original message, I was dreaming to script Emacs with Python. In the > resulting thread, someone suggested that Cool Edit could satisfy my dream. I write a post in this list, about something like this, some months ago: http://mail.python.org/pipermail/python-list/2001-January/027035.html - Nahuel Greco Web Development - Open Source - - http://www.codelarvs.com.ar Game Programming - Research - - Freelance coding / sysadmin Networking. The answer is 42. - From nas at python.ca Mon Jun 18 22:44:58 2001 From: nas at python.ca (Neil Schemenauer) Date: Mon, 18 Jun 2001 19:44:58 -0700 Subject: PEP 255: Simple Generators In-Reply-To: ; from root@rainerdeyke.com on Tue, Jun 19, 2001 at 02:25:19AM +0000 References: <9glhg7$dlk$1@nntp6.u.washington.edu> Message-ID: <20010618194458.A8785@glacier.fnational.com> Rainer Deyke wrote: > In other words, whether a function is a generator or not is determined at > run-time. The following would work, right? > > def f(x): > if x == 5: > yield 5 # Look ma, I'm a generator. > return > else: > return x # Or maybe not. No and no. The above code would raise a syntax error when compiled. Neil From geoff at homegain.com Thu Jun 14 18:26:56 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Thu, 14 Jun 2001 15:26:56 -0700 Subject: Inner classes Message-ID: <393D961EA4FCD311B03F00D0B746D65803275EA8@HQSXCH01> > From: Isaac To [mailto:kkto at csis.hku.hk]: > > No if the original poster wants a Java-style inner class. Java > inner class is a rather strange concept. The idea is for the > inner class instance to have a reference to the outer class, > and unlock the namespace of the outer class in methods of the > inner class. Sounds like this could be reasonably simulated with a __getattr__ that delegates? An example that seems to implement the requirement as described, follows. It depends on what you're looking for, but Python has all the requisite tools. It's just a question of why you'd /want/ to do something that absurd. :) Thanks, --G. class Outer: class __Inner: def __init__(self, container): self.__container = container def __getattr__(self, attr): try: res = self.__dict__[attr] except KeyError: try: res = getattr(self.__class__,attr) except AttributeError: res = getattr(self.__container,attr) return res def f(self, spam): return spam + self.g(spam) def Inner(*args): self = args[-1] return self.__Inner(self) def g(self, foo): return foo * 2 oInst = Outer() iInst = oInst.Inner() print oInst.g(5) print iInst.f(5) --- Geoff Gerrietts Software Engineer, HomeGain.com 510-655-0800 x4320 From donn at oz.net Sat Jun 2 01:01:57 2001 From: donn at oz.net (Donn Cave) Date: 2 Jun 2001 05:01:57 GMT Subject: overriding /usr/lib and /usr/include directories References: <20010531.164958.1977648522.1900@mead.troikanetworks.com> Message-ID: <9f9s05$lgv$0@216.39.151.169> Quoth "Bruce Edge" : | I'm building python for an embedded environment, and it's apparently | picking up the library names from /usr/lib. How do I tell it where to look | for shared libs, like libreadline.so.4.2 for example? | | My host has /usr/lib/libreadline.so.4.1, while in my target env my | LD_LIBRARY_PATH points to a dir containing libreadline.so.4.2, and the | python readline module as it's looking for the version it found in | /usr/lib. Sounds like setup.py to me, though I haven't thought very hard about it since you don't say what version of Python or provide much of any other details about what you're doing. Anyway, in 2.1, setup.py builds the dynamically loaded modules, and it has /usr/lib hard-coded. If you want something else, you can just modify setup.py accordingly. I believe it's fairly obvious; you may have to dive way down into the distutils layer beneath setup.py for some things, but /usr/lib should be right there in setup.py. Donn Cave, donn at oz.net From skip at pobox.com Thu Jun 7 13:38:49 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 7 Jun 2001 12:38:49 -0500 Subject: How can I extend raw_input to provide user w/ default input string? In-Reply-To: References: <9fmgli$43f$1@peabody.colorado.edu> <3B1F0D82.DB10E008@yahoo.com> <9fo6g6$36v$1@peabody.colorado.edu> Message-ID: <15135.48169.739967.880960@beluga.mojam.com> >> However, I was thinking about presenting the user with a default >> input and give him/her the ability to edit it. Maybe I should think >> about using Tkinter if this is impossible to do using a console >> interface. Alex> You might want to check out the readline module. I don't think that works. I asked about it a few months ago and got a negatory response from Guido. (Not that it wouldn't be useful, just that the readline module doesn't support it.) There have been a couple packages announced here in the past month or so that are readline replacements. One of them could probably be coerced into providing default values for console inputs. -- Skip Montanaro (skip at pobox.com) (847)971-7098 From dan at eevolved.com Mon Jun 18 23:16:31 2001 From: dan at eevolved.com (dan) Date: Mon, 18 Jun 2001 23:16:31 -0400 Subject: getting a reference to a class inside its definition References: <9noX6.14930$uR5.1138042@news20.bellglobal.com> Message-ID: <7vzX6.18817$Vl2.977150@news20.bellglobal.com> Pearu Peterson wrote: > On Mon, 18 Jun 2001, dan wrote: > >> class SomeClass: >> pass >> SomeClass.clsref = SomeClass > > If it will be used as > >>>> SomeClass().clsref > > then it is equivalent to > >>>> SomeClass().__class__ > > So, why would you want .clsref attribute if .__class__ is > available already? > > Pearu So my question is why answer my question? ;) I'm building a factory class of other classes. One of the factories is a factory of itself... It's also a baseclass, which is why I need it to be an attribute so it can be overloaded later. I hope this satisfies your curiosity :) Dan From greg at cosc.canterbury.ac.nz Thu Jun 21 01:21:13 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 21 Jun 2001 17:21:13 +1200 Subject: PEP 255: Simple Generators References: <3B2EEF5A.8FF0DAFB@cosc.canterbury.ac.nz> <3B30427D.5A90DDE7@cosc.canterbury.ac.nz> <3B305119.6A12DBC2@letterror.com> Message-ID: <3B318449.2492CAD2@cosc.canterbury.ac.nz> Just van Rossum wrote: > > The next two functions are more or less equivalent: > > def returnThreeValues(): > return 1, 2, 3 > > def generateThreeValues(): > yield 1 > yield 2 > yield 3 I would agree with you if you had said they are equivalent *in the following context*: for i in returnThreeValues(): ... for i in generateThreeValues(): ... But you have to fuzz up your thinking somewhat in order to see them as equivalent *in general*, and I can't see fuzzy thinking as anything but a liability when programming. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From glyph at twistedmatrix.com Sun Jun 10 18:14:17 2001 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: Sun, 10 Jun 2001 17:14:17 -0500 (CDT) Subject: Learning OOP... In-Reply-To: <9fvfi801fg8@enews2.newsguy.com> Message-ID: On Sun, 10 Jun 2001, Alex Martelli wrote: > "Glyph Lefkowitz" wrote in message > news:mailman.992131396.542.python-list at python.org... > ... > > Furthermore, I'd say that creating reusable code is *wrong*. > > Interesting strawman, but you haven't come anywhere close > to 'proving' it in the following. I'm sorry, I should have been more clear. "reusable" code is wrong; "usable" code is right. Re-use implies recycling, dragging something out of the garbage to use it again. For example, when you put on your new pair of shoes for a second time, you usually don't think of it as re-use (although you are technically "Using them again"), but it *is* re-use when those shoes are a hand-me-down from an older relative, and have thus exceeded their intended usefulness. > ... "The unit of reuse is the unit of release" ... Robert Martin ... Excellent! Where can I find some writings by this fellow? :) > > projects. Keep your systems small and have them communicate clearly and > > sparsely over encapsulation boundaries, and your code will be useful for > > years; and you'll never have to re-cycle it. > > "Interface segregation principle", "dependency inversion principle", > etc. Again, www.objectmentor.com has good papers on this:-). I hardly think that object orientation has a monopoly on this approach :). The reason that I don't think that these are really OO principles is that the most successful component architecture and reuse framework that I've ever seen is UNIX, which says nothing about objects; only executables, files, and streams. The most revolutionary development in software engineering was the subroutine, closely followed by the data structure. The notion of "objects" has been a useful tool to think with, but much more of a small incremental improvement than the revolution of the subroutine :) > > Insofar as OO helps, it is because OO has a simple and relatively > > universal metaphor for communicating between programs written with vastly > > different design assumptions, even in different languages: message sending > > between objects. However, OO also has the notion of inheritance, which is > > a *huge* impediment to reuse between projects (but can be useful for other > > Except that it's not, when applied well. Python shows well how > suitably designed inheritance can make for smooth framework-code > reuse, e.g. in sgmllib/htmllib and the whole server hierarchy. Code > generators should generate base-classes that are specialized by > inheritance, *NOT* by editing generated sources (a round-trip > nightmare). Mixins allow seamless reuse. Etc, etc... I haven't had good experiences either with inheritance in either of those examples you mentioned. "Aggregate, not inherit". Especially in python, when one can easily forget the oh-so-subtle method chain; def __init__(self, *args, **kw): apply(self.__class__.__bases__[0].__init__, (self,)+args, kw) self.initOtherStuff() > It's true that implementation inheritance CAN too easily create > unintended strong coupling. Scott Meyer's rule of thumb to > "never inherit from a concrete class" (in a C++ setting) shows > to what extremes one could go to ward off that danger... A number of programmers I've met adhere to this rule (Moshe Zadka in particular, I believe ^_^), and I aspire to now. Twisted Python (PLUG: http://twistedmatrix.com ) began life with a rather entangled inheritance structure and I've almost completely deconstructed it... and it's much easier to use for it. > > things). Also, some systems which claim to be "OO" also have static > > typing, which partially negates the value of sending messages. > ...and partially enhances it. Inheriting across language boundaries (where this communication benefit is felt the most) is almost *never* a good idea. If there were a neater way to say "I implement this" than inheriting a base class in Jython, I'd use it. After all, if I'm inheriting a 'final' method from a Jython class and I redefine it (or assign a similiarly-named attribute to an instance) what semantic should that have? What about multiple inheritance? Better yet, trying to do cross-language metaclass hacks? :) It's a semantic accident if any of that stuff works, which I think indicates the fragility of inheritance. > Again, it demands very solid design (I wouldn't be Pythoning if I > didn't think the flexibility of dynamic typing was more often useful > than the rigidity of static typing, but I do have to play devil's > advocate on this thread, I think:-) but when you have it you're well I can see advantages to static typing and efficiency as well, but I see the need to do so. What would that make me? "God's advocate?" We can all see that Python has the divine will on its side now... ;-) > placed. Templates (or other mechanisms for compile-time genericity) > recover a lot of that flexibility at no runtime cost -- Coplien's > "pattern without a name" is IMHO mostly aboyt that (template > class Y: public X, etc). Basically, templates give you > signature-based polymorphism, like Python's, at compile-time only > (thus less flexible, but easier to generate speedy code for, and > sometimes allowing somewhat earlier error diagnosis). The "error diagnosis" argument I can't really argue with (C++ compilers *do* describe more errors at compile-time), but it smells funny to me. I'd guess that C++ just introduces more errors so it can diagnose them. After all, which do you find is usually more error-ridden on the first run -- C++ code or Python code you've written? :) > > This is also, IMHO, against the spirit of object orientation. Smalltalk, > > I'd like to see you say that to Bertrand Meyer's face, given how > intensely he maintains that "the spirit of OO" is statically typed!-) > Me, I might quote the Bard by saying "a pox on both their houses", > but I'll take the reverse tack, praising BOTH dynamic and static > typing. I think OO works well with both, in different ways. Mr. Meyer's thoughts notwithstanding; static typing is a way of making OO more linearly isomorphic to structured programming. For example; --- class Foo: def x(self): blah() ... f = Foo() f.x() --- means that we have to figure out what kind of thing 'f' is before we go to send the message 'x' to it. However, --- class Foo { public: void x() { blah(); }}; ... Foo* f = new Foo(); f->x(); --- is morally equivalent to --- typedef struct _Foo {} Foo; ... Foo* f = malloc(sizeof(Foo)); Foo_x(f); --- So the compiler figures out that it's Foo_x we want to call. If OO is the difference between thinking of data as "behaviorally" instead of "structurally" composed, then non-virtual functions (and the static type information that makes them possible) are against the spirit of OO. When giving this argument in the past, I've been told that my C example is just code written "in an object oriented style". If that's all it takes to have object oriented style, then OO is nothing but a technically sophistocated way of saying "Look! Our programs can deal with both code *AND* data!" > > have anything to do with object orientation. Certainly, provable > > correctness and static typing are at odds with reuse, since they make your > > software more resistant to change. > > Making software resistant to change is neither an intrinsically > bad thing, nor one at odds with software reuse. I DO want the > software that I'm reusing to be unchangeable from the point > of view of behavior that I, the reuser, observe. IMHO making software resistant to change *is* an intrinsically bad thing Embrace change! :). Although I appreciate the desire for the behavior to remain constant across project boundaries, I don't see that static typing helps with this. Python's "file" interface convention has done a lot towards aiding re-use; I believe that's partially because it's so easy to implement. > > The easiest way to have a responsive, efficient program is to prototype > > and prototype and prototype in a flexible, "slow" language, until you've > > got the fastest possible high-level algorythm, then optimize for constant > > Nolo contendere here, but it's SO important it's worth quoting > just to increase the likelihood that it gets read:-). Yes, let's just leave it here :) I also think I should throw in my favorite quote about object-orientation here. From Ian Joyner's paper (book?) "C++??", at http://www.elj.com/cppcv3/ In his conclusions: Perhaps the most important realisation I had while developing this critique is that high level languages are more important to programming than object-orientation. [...] In a nutshell, an object-oriented language that lacks the qualities of a high level language entirely misses the point of why we have progressed from machine coding to symbolic assembler and beyond. **Without the essential high level qualities, OO is nothing but hype.** Eiffel shows that it is important to be high level as well as OO, and I hope that the lesson to be learned by any programming paradigm, not just OO, is that the fundamental is to make the task of programming (that is system development as a whole) easier by the removal of the burden of bookkeeping. (emphasis mine) The irony, of course, is that he used this to pitch Eiffel; but my argument is that eiffel is not high-level *enough*, so we need python ;-) in-real-life-you-only-have-inheritance-when-people-die-ly y'rs, ______ __ __ _____ _ _ | ____ | \_/ |_____] |_____| |_____| |_____ | | | | @ t w i s t e d m a t r i x . c o m http://twistedmatrix.com/users/glyph From tchur at optushome.com.au Sun Jun 3 03:13:20 2001 From: tchur at optushome.com.au (Tim Churches) Date: Sun, 03 Jun 2001 17:13:20 +1000 Subject: Has anyone used UML? References: <991550033.146@nntp01.uskonet.com> Message-ID: <3B19E390.31CEC018@optushome.com.au> Frank Millman wrote: > > After 15 years of designing applications using the good old "seat of the > pants" method, I have decided that, if I am to move forward, I need a more > formal methodology. > > I have recently read about UML (Unified Modelling Language), a > standards-based method of designing and documenting any software project. It > looks interesting, but it seems to have a steep learning curve. > > Does anyone have any knowledge or experience of UML that they would like to > share? No experience (I am in a similar situation to you wrt UML), just some advice: don't buy the O'Reilly book 'UML in a Nutshell' - it is the only O'Reilly title I have encountered which is truly woeful (most are quite good). Tim C From kosh at aesaeion.com Sat Jun 9 02:31:26 2001 From: kosh at aesaeion.com (kosh) Date: Sat, 9 Jun 2001 00:31:26 -0600 Subject: is c faster? References: Message-ID: <9fsfru$786$1@apollo.csd.net> akhar wrote: > I have a script I wrote in python , I love the time it took me to > devellop it faster than i could have done it in C. however after full > review of my code I am not sure I can optimize it any more( it basicaly > consist of importing an image and tranforming into a matrix to perform > some for-looped operations on it) : I went from 20 seconds to 2. I can't > seem to bring the execution time down :( . would C code be faster? by what > factor? can I optimise my code more? how? > > Stephane > > NB: I have a dual-celeron 400mhz with 256Mo of ram and a 20 gig 7200rpm > HDD Also anybody with a G4 with PIL and numpy install to test the speed of > my code?(my friend has a 1GHz and it takes him .65 sec to execute I would > like to know if an altivec enhanced computer would fair better) > > > What does the code for the for loop look like? There are some surprising speedups you can get in python with some strange optimizations. From akhar at videotron.ca Fri Jun 1 01:49:04 2001 From: akhar at videotron.ca (akhar) Date: Thu, 31 May 2001 22:49:04 -0700 Subject: PIL speed and fear Message-ID: I have been using pil for robtic vision, however due to a lack of funding my project is not very far yet ( I have only been parcticing with static images). Now I have been optimising code and all but (I am under windows) I see some lag when I manipulate large images 640*480, what I do that I use pil to split the image into three matrixes and then scan for specified values and filter out others and discontinuities in them, the only real lag apears in two places in the code both coresponding to when I call PIL to show the images resulting from the filters. I noticed that it tries to open a dos session and then shows me the image in paint. I am afraid that for phase two when I start using streams of images directly from the camera that their will be an enormous lag. Is it only because of windows? should I be using something else for realtime video streams like pySDL? or is it windows and I should use freebsd to do this? Regards Akhar From whisper at oz.nospamnet Tue Jun 12 13:02:50 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 12 Jun 2001 17:02:50 GMT Subject: Plugins in Python Message-ID: <9g5hvq$ird$2@216.39.170.247> Hi; How would one generally code something that would look at some dir (or list of dirs), and dynamically load .py or .pyc modules found there that where not previously known to the program. Obviously following a standard API... TIA Dave LeBlanc From marcora at colorado.edu Wed Jun 6 20:08:22 2001 From: marcora at colorado.edu (Edoardo ''Dado'' Marcora) Date: Wed, 6 Jun 2001 18:08:22 -0600 Subject: How can I extend raw_input to provide user w/ default input string? Message-ID: <9fmgli$43f$1@peabody.colorado.edu> I am wondering if it is possible to provide the user with a default input string using raw_input or similar function. Thanx, Dado -- ======================================== ''Sono diverso perche' sono omozigoto.'' http://digilander.iol.it/drago77/corti/omozigoto.wav Edoardo "Dado" Marcora 2727 Folsom St. Apt. 318 Boulder, CO 80304 USA Tel: +1-303-492-3450 (W) +1-303-415-0811 (H) Fax: +1-303-492-7744 Email: Edoardo.Marcora at colorado.edu Home Page: http://ucsu.colorado.edu/~marcora/homepage.htm ======================================== From Daniel.P.Mevorach at williams.edu Mon Jun 11 12:01:33 2001 From: Daniel.P.Mevorach at williams.edu (Daniel P Mevorach) Date: Mon, 11 Jun 2001 12:01:33 -0400 (EDT) Subject: Python and SML Message-ID: I am new to Python and was struck by the similarity to a language I learned in a programming languages course, SML/NJ. It, like Python, is an interpreted language and uses similar syntax for built in tuples, and lists (no dictionaries. The major difference is that SML is a functional language and therefore has some interesting quirks. I was wondering whether SML had any influence on the development of Python? From sh at ttsoftware.co.uk Thu Jun 28 13:01:35 2001 From: sh at ttsoftware.co.uk (Steve Horne) Date: Thu, 28 Jun 2001 18:01:35 +0100 Subject: PEP scepticism References: <9hfg1n$du33c$1@ID-89274.news.dfncis.de> Message-ID: On 28 Jun 2001 14:47:19 GMT, bernhard at intevation.de (Bernhard Reiter) wrote: >This a general warning against the second system syndrom in Python. I think you may have a good point for the future, but I'm actually a big fan of some of those recent additions to Python. Although Python probably makes an excellent teaching language, I'd imagine most Python programmers have used some other languages before. Of the example changes you mentioned... > - augmented Assigments Extremely familiar to anyone with a C, C++ or Java background, and something that I was annoyed to have to live without when I first used Python. I don't remember ever finding the idea of += or -= operators anything but completely natural, even when I first saw them. I'd contest the use of % for mod (the meaning is not immediately obvious) but += and -= are completely natural. The augmented assignments beyond += and -= are simply extending the same principle as far as possible - something Python has always done, and which is a large part of its simplicity. > - Lists comprehensions Another large group of Python programmers have a background in functional languages, and will immediately understand list comprehensions. I can see how at first glance they might look strange, but really they are just describing - rather than listing - the required items. The second glance should be a revelation! Functional languages provide a very useful and very simple approach to many types of problem. The inclusion of functional features into Python is one of its best attributes. Few other languages allow you to switch paradigms to whatever suits your task. But without list comprehensions, the functional features get pretty clunky. I can understand the wish to only have one way to solve any problem, but it really isn't that great an approach. If a task can be attempted using two different approaches, then you have a choice - you don't have to force the first approach to fit. I look forward to a day when there are even more tools in the box. After all, have you ever met an electrician who only owns a single screwdriver? - I think not. Doing a good job means using the right tool for the job, not forcing a single tool to do every job. I first started using Python at version 1.4. The recent evolution of Python has resulted in many of my commonly used scripts becoming much more powerful and useful, yet smaller and much more readable - despite the fact that I only get a chance to work on them at odd moments when there is no rush. If typical Python programs are simpler, more readable, yet at the same time more useful and powerful than was possible in the past - all without spending a lot of time in development - I don't think the time has yet come when we need to worry about excess features. -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From ocschwar at mit.edu Fri Jun 15 07:39:06 2001 From: ocschwar at mit.edu (Omri Schwarz) Date: 15 Jun 2001 07:39:06 -0400 Subject: WxPython questions. References: <9gcmue02uqj@enews1.newsguy.com> Message-ID: "Alex Martelli" writes: > "Omri Schwarz" wrote in message > news:octofrqcedk.fsf at mint-square.mit.edu... > ... > > So my question is, is there a more interactive way to > > play around with wxPython? > > Sure! Just remember that an EMPTY line typed to the > interactive interpreter tells the interpreter that > the compound-statement is finished, as witness the > change of prompt...: Aye! Aye! Aye! Can you tell I'm switching from Perl or what! Thanks! I'll take your advice for future playtime! > > >>> class MyFrame(wxFrame): > > ... def __init__(self, parent, ID, title): > > ... wxFrame.__init__(self, parent, ID, title, > > ... wxDefaultPosition, wxSize(200, 150)) > > ... self.CreateStatusBar() > > ... self.SetStatusText("This is the statusbar") > > ... > > Here you presumably entered an empty line, and so...: > > > >>> menu = wxMenu() > > ...the def and class statements are finished, as evidenced > by the prompt being back to >>>. Just avoid empty lines > except when you *ARE* finished with a compound statement! > > It will be difficult to edit errors &c when working this > way. I suggest you keep two texboxes/terminal-emulator > windows/commandboxes/dosboxes/whatever. Use one to write > small textfiles with your editor of choice, the other to > hold the interactive session in the same directory, and > use Python function execfile to 'gobble' into the > interactive session the textfiles you're editing... Will do. Thanks! -- Omri Schwarz --- ocscwar at mit.edu ('h' before war) Timeless wisdom of biomedical engineering: "Noise is principally due to the presence of the patient." -- R.F. Farr From uioziaremwpl at spammotel.com Fri Jun 22 18:03:33 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Sat, 23 Jun 2001 00:03:33 +0200 (CEST) Subject: PEP 255: Simple Generators In-Reply-To: <9h0crt$rq6$1@slb1.atl.mindspring.net> Message-ID: On Fri, 22 Jun 2001, Andrew Dalke wrote: > Carsten Geckeler: > >So Test is called like a function and returns an instance. But why make a > >different syntax ("class") for defining it? Just because it returns an > >instance instead an integer or another object? According to your > >argument, "def" would be fine. > > There isn't quite enough information to distinguish between at > least some class definitions and function definitions without the > use of a keyword. Consider > > >>> class SuperTest: > ... pass > ... > >>> def Test(SuperTest): > ... def __init__(self, spam): > ... self.spam = spam > ... def __str__(self): > ... return str(self.spam) > >>> t = Test("eggs") > >>> str(t) > 'None' > >>> > > Changing the 'def Test' to 'class Test' changes the > entire meaning of the code. Don't take my `proposal' to change "class" into "def" too serious. Defining classes was thought as a counter-example for using "def" for generators. The point of some posters was, that because calling a generator returns a object, is a reason to justify why "def" is appropriate for defining a generator. I just wanted to point out that "calling a class" (i.e. creating an instance by calling class(args)) also returns an object, but that this is of course not a reason to define it with "def", because the way the definition is evaluated and what is returned is completly different as how a function definition is evaluated (as you pointed out). And the same with generators. Cheers, Carsten -- Carsten Geckeler From mcfletch at home.com Fri Jun 8 06:44:47 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Fri, 8 Jun 2001 06:44:47 -0400 Subject: Network access tying was(RE: Python Shareware?) In-Reply-To: <9fq3p1034u@enews1.newsguy.com> Message-ID: <000401c0f008$0a63ef60$a9807018@cr706570a> But, but, isn't that the basic idea behind Windows and Office XP :o) . That seems to require a constant connection to (the Microsoft version of) the Internet to do even the most basic of things? Please tell me that this couldn't possibly cause a problem! You must be wrong, Microsoft would never do something to make using a computer more annoying and intrusive, fragile and unreliable, would they? Tying critical functionality to the whims of network access, (something which often goes out for weeks at a time in my experience) is a perfectly valid way to hamstring one's users. And in the end, isn't hamstringing our users what we all really want? I mean, who really want these people wandering around on their own power when we could be charging them outrageous licensing fees for the privilege of movement. That's how they get into trouble ;) . Seriously, I agree, there isn't any (as far as I know) way to secure your product, so you might as well just use annoyance to get the job done. Pop-up a dialogue for ten seconds every time the application loads (once the trial period is over). Put a single "register" button (and nothing else) on the dialogue. People likely to pay you for application will be reminded to register. People who would just go ahead and crack (or get cracked versions of) your application will wait for the dialogue to go away (yes, there are weird people who will go to the trouble of cracking even such a simple thing, they are pretty much pathological, and you won't get any money from them anyway). Microsoft might be able to do network tying because their market share approaches unity and they can spend hundreds of millions brainwashing people into ignoring the problems, giving up their privacy etc. But most shareware authors are not in exactly the same situation... though many seem to wish they were... I don't understand why. Enjoy, Mike -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Alex Martelli Sent: June 8, 2001 04:53 To: python-list at python.org Subject: Re: Python Shareware? ... > 3. How can I lock/secure my python shareware? I pass! I don't know of any way to 'secure' a program that's more than, say, a weekend's work to crack, for *ANY* programming language (I do not think there are any, but a negative is hard to prove:-). If you can rely on your users having internet access while running your program, the whole picture changes -- you can then place some key part of the whole operation on a site that is fully in your control, and only accepts requests (e.g. via SOAP or similar means) when it has validated the requestor as a holder of a valid license (it can track 'copied'/'pirated' licenses by noticing too-frequent access requests, etc). In most cases one would still be restricting one's market too much by making a program unusable without internet access. Not a programming-language issue... ... From nas at python.ca Sun Jun 24 19:18:27 2001 From: nas at python.ca (Neil Schemenauer) Date: Sun, 24 Jun 2001 16:18:27 -0700 Subject: PEP 255: Simple Generators, Revised Posting In-Reply-To: ; from bh@intevation.de on Sun, Jun 24, 2001 at 09:07:44PM +0200 References: Message-ID: <20010624161827.C30403@glacier.fnational.com> Bernhard Herzog wrote: > It seems to me that as it stands, empty generators are a bit too > difficult to write, so I think we need an easier way to write them. One > way to write them would be > > def g(): > yield What is wrong with: def g(): return [] If you really want an iterator object you can do: def g(): return iter([]) I don't know why anyone would care though. > If generators weren't created with a def statement it would be a bit > more obvious: > > generator g(): > pass I don't think Guido will be convinced that we need a new keyword just because it makes it easy to write silly code. Neil From cribeiro at mail.inet.com.br Wed Jun 20 22:28:58 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Wed, 20 Jun 2001 23:28:58 -0300 Subject: Who is using PMS (Python Mail System) or a similar solution? Message-ID: <5.0.2.1.0.20010620231000.026d9280@mail.inet.com.br> First let's state my problem: my daily email volume has grown beyond my ability to manage it using Eudora. As of now, using Linux is not and option. I really need to find a scalable personal email solution, and I *really* don't have much time to do it myself. My idea is to have a tool that is able to: - automatically retrieve email from several accounts (fetchmail-like functionality) - keep the message database in some well known format; - implement filters as Python plugins; - optionally, have a web-based interface to check the message database. Before jumping in and coding Yet-Another-Email-Package in Python, I did a search on the Vaults of Parnassus. Of all email packages, PMS - Python Mail System seems to be the closest to what I want. I downloaded it from http://pythonms.sourceforge.net/, and started playing. The documentation is pretty terse - luckily, this is a Python program, and a simple browse through the source files reveals a lot about the functionality. I'm still not sure that I'll be able to make it work inside Windows, though. It seems to be still missing a lot of functionality, but at least the basics seems to be pretty well designed. My question is, does anyone have experience using/customizing PMS on Windows? What do you think of it? Best regards, Carlos Ribeiro From jj at void.si Fri Jun 1 06:20:55 2001 From: jj at void.si (jj) Date: Fri, 01 Jun 2001 12:20:55 +0200 Subject: XML How-To References: <88630c8d.0105301259.55d724ab@posting.google.com> Message-ID: <02reht0jr51o5d32k02hjmfc0j7717q4p3@4ax.com> It work for me: xml.version_info == (0, 6, 5) and 4suite 0.11 JJ On Thu, 31 May 2001 09:13:11 -0700, "Keith Farmer" wrote: >"jj" wrote in message >news:ltobhtkb3lngrdn4neq9f7g8aetsstp5lv at 4ax.com... >> [python] > >PythonWin 2.1 (#15, Apr 23 2001, 18:00:35) [MSC 32 bit (Intel)] on win32. >Portions Copyright 1994-2001 Mark Hammond (MarkH at ActiveState.com) - see >'Help/About PythonWin' for further copyright information. >Traceback (most recent call last): > File "c:\progra~1\python\pythonwin\pywin\framework\scriptutils.py", line >301, in RunScript > exec codeObject in __main__.__dict__ > File "C:\Documents and Settings\kfarmer\Desktop\xml-test.py", line 17, in >? > parser = xml.xpath.XPathParser.XPathParser() >AttributeError: 'xml.xpath' module has no attribute 'XPathParser' > From tim.one at home.com Fri Jun 22 22:28:26 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 22 Jun 2001 22:28:26 -0400 Subject: New windows case sensitivity in Python 2.1? In-Reply-To: <3b33f0f2.6505854@nntp.ix.netcom.com> Message-ID: [Mike Clarkson] > I seem to be seeing a new case sensitivity to the import command under > windows (Win98 FAT 32). ... Yes, this was the topic of PEP 235 (Import on Case-Insensitive Platforms), implemented for Python 2.1. See http://python.sourceforge.net/peps/pep-0235.html for the full story. If for some reason you can't, or don't want to, use matching case, you'll have to set the envar PYTHONCASEOK (to anything -- just so long as it's defined). From loewis at informatik.hu-berlin.de Sat Jun 16 13:41:57 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 16 Jun 2001 19:41:57 +0200 Subject: Dynamically-linked version of Python-2.1 for linux References: Message-ID: "R. Timothy Edwards" writes: > Would someone please check my code and make sure > that it doesn't break the compile process on other OS's (including > Linux versions other than RedHat)? People's opinion on that feature vary widely; I personally believe the Python interpreter should *not* be linked with a shared library, and that it is easier to distribute an embedded application if it has less shared libraries. So to make your suggested patch work, I think it *must* be activated by a configure option. Please have a look at http://sourceforge.net/tracker/index.php?func=detail&aid=400938&group_id=5470&atid=305470 for past discussion on this matter. If you think you can come up with a patch that answers all requirements, please submit a patch to SF; there is no point in people starting with this all over again every few months. It might be that you have to open a new patch for that; if so, please leave a comment in the existing patch pointing to the new one. Once it is on SF, rest assured that people will analyse and criticise your patch, and verify that it works on many systems before integrating it into Python. Regards, Martin From smarsh at hotmail.com Wed Jun 6 01:02:10 2001 From: smarsh at hotmail.com (scott) Date: Wed, 06 Jun 2001 05:02:10 GMT Subject: Interesting speed benchmark References: <3B1D6FED.4070506@nospam.yahoo.com> Message-ID: <3B1DB913.F94A3FDF@hotmail.com> Mahesh Padmanabhan wrote: > (snip) > Python program: > --------------- > > class ObjectTest: > pass > > for i in xrange(1000): > root=ObjectTest() > for j in xrange(10000): > root.next=ObjectTest() > root=root.next > > Time: > > real 1m23.326s > user 1m23.290s > sys 0m0.060s > > Java program: > ------------- > > public class ObjectTest { > public ObjectTest next; > public static void main(String[] args) { > for (int i = 0; i < 1000; i++) { > ObjectTest root = new ObjectTest(); > for (int j = 0; j < 10000; j++) { > root.next=new ObjectTest(); > root=root.next; > } > } > } > } > > Time: > > real 0m2.428s > user 0m2.190s > sys 0m0.220s > > There is a huge difference in performance. (snip) That's certainly a massive difference. Heres a *somewhat* related comparison :-}, specifically python vs. jython. NT4, python 2.0, jython 2.0 with jdk1.3.0. -As I expected, a simple loop generating random numbers ran about 3 times faster in python (6.5 secs) vs jython (19.0 secs): ------------------------ import random, time start = time.time() li = [] sum = 0 for i in range(100000): x = random.gauss(0, 1) li.append(x) sum = sum+x end = time.time() print end - start print sum ----------------------- -Unexpectedly, when I did a slight rewrite to take advantage of jythons ability to use Java classes (specifically java.util.Random) it was just as fast as the python version (6.5 secs)! : ------------------- from java.util import Random #changed this import time start = time.time() li = [] r = Random() #added this sum = 0 for i in range(100000): x = r.nextGaussian() #changed this li.append(x) sum = sum+x end = time.time() print end - start print sum ------------------ Interesting (to me at least..). From chat at linuxsupreme.homeip.net Fri Jun 1 21:17:47 2001 From: chat at linuxsupreme.homeip.net (Chad Everett) Date: 1 Jun 2001 20:17:47 -0500 Subject: Copying files to multiple comp's on a lan References: <9f8k3v$1i04$1@news.cybercity.dk> <16074dce.0106011606.4a7b987d@posting.google.com> Message-ID: On 1 Jun 2001 17:06:02 -0700, Jeff Shannon wrote: >Hm, I'd probably use the os.system() call in preference to reading the >source and then creating new destination files, as D-Man's example does, >though the choice is probably trivial and entirely personal opinion. > >Example: > >--------------------- > import sys > import os > > # note Win32 uses \, not / :) > machines = [ "\\Mach1\C" , "\\Mach2\C" , "\\Mach3\C" ] > > source_file_path = sys.argv[1] > dest_path = sys.argv[2] > > for machine in machines: > # always use os.path.join() when building paths.... > dest_fullpath = os.path.join(machine, dest_path) > cmd_string = "copy %s %s" % (source_file_path, dest_fullpath) > os.system(cmd_string) > >--------------------- > >You'd probably be better off if the machine/drive specs were built using >the functions in os.path as well, but that's a minor detail. I'd also, if >I were writing this script for my own use, add a few print statements to >report on the current status, etc.... I'd also probably put the os.system() >call within a try/except block, just in case. And of course, this all >presumes that you do have write permission on all of these machines. :) > >Jeff Shannon >Technician/Programmer >Credit International It also presumes you're using Microsoft networking. -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From James_Althoff at i2.com Thu Jun 7 13:31:39 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Thu, 7 Jun 2001 10:31:39 -0700 Subject: Why should i use python if i can use java Message-ID: Geoff Gerrietts wrote: >In Python, I know how to write classes whose instances are other classes. Do you mean "whose instances are *themselves* classes"? And if so, How do you do this? (Can you do this in *Python* -- without doing a C extension?) Thanks, Jim >Geoff Gerrietts From emile at fenx.com Thu Jun 28 08:53:43 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 28 Jun 2001 05:53:43 -0700 Subject: PEP 260: simplify xrange() References: <3B39480C.F4808C1F@Lugoj.Com> <9hc97q$rpt$1@slb6.atl.mindspring.net> <3B3A9C39.64C3E1C6@seebelow.org> <9hef08$urt$1@slb3.atl.mindspring.net> <9hf5ru$5el$1@animus.fel.iae.nl> <6qg0ckydud.fsf@abnoba.intevation.de> Message-ID: <9hf9l1$dpvci$1@ID-11957.news.dfncis.de> Bernhard's got it there. If you view the cached page, it tells you this at the top. These terms only appear in links pointing to this page: michael hudson -- Emile van Sebille emile at fenx.com --------- "Bernhard Herzog" wrote in message news:6qg0ckydud.fsf at abnoba.intevation.de... > Michael Hudson writes: > > > Carel Fellinger writes: > > > > > Michael Hudson wrote: > > > ... > > > > Google confuses me; if you search for "michael hudson" my page is the > > > > third hit - but my name doesn't actually appear anywhere on the linked > > > > page! > > What was your exact query (I guess you omitted the quotes)? If I query > for "michael hudson" (including the quotes!) your CV is the first entry > in the result list. > > > > probably it's in a hidden field, like > > > > Nope. These are my web pages we're talking about here! My name > > appears on various bits of my pages (my CV, the python-dev summaries), > > but definitely not on the page google points you to. > > Google also looks at text of the links pointing to a website. E.g. if > there's a link Michael > Hudson on a website, google takes that as a hint that the page > pointed to is about "Michael Hudson". > > Bernhard > > -- > Intevation GmbH http://intevation.de/ > Sketch http://sketch.sourceforge.net/ > MapIt! http://mapit.de/ From burt at dfki.de Fri Jun 22 23:11:46 2001 From: burt at dfki.de (Alastair Burt) Date: 23 Jun 2001 05:11:46 +0200 Subject: [OT] MS EULA -- (will ActiveState become outlaws? ;-) References: Message-ID: "Steven D. Majewski" writes: > No -- it's not the Slashdot Effect (at least in the performance sense). > It's been changed to redirect you to a 'page not found' page. > They very clearly removed it. > Wiser and cooler heads must have prevailed at MS. Or maybe not. The license is there in all its glory under a different URL: http://msdn.microsoft.com/downloads/eula_mit.htm --- Alastair From tim.one at home.com Sat Jun 23 14:10:55 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 23 Jun 2001 14:10:55 -0400 Subject: Trouble downloading Python-2.0.1 In-Reply-To: Message-ID: [posted & mailed] Art, I don't know how to account for it, but I believe you're right on all counts here: the .tgz tarball appears corrupt, and in different ways, on python.org and on SourceForge. Guido is looking into it and will upload new tarballs soon. A really strange thing is that the MD5 checksum on the python.org tarball is as expected; so either the tarball uploaded to python.org was corrupt to begin with, or we're about to get famous . BTW, the Windows downloads appear fine -- this only affects the source (.tgz) downloads. [Art Haas] > I've had a great deal of trouble picking up this version. There seems > to be some sort of error in the archive. Downloading from the > www.python.org site via http ... > > $ ls -l Python-2.0.1.tgz > -rw-r--r-- 1 cs004 spsd 4136960 Jun 23 09:45 Python-2.0.1.tgz > $ gzip -v -t Python-2.0.1.tgz > Python-2.0.1.tgz: > gzip: Python-2.0.1.tgz: decompression OK, trailing garbage ignored > OK > $ tar xvfz Python-2.0.1.tgz > [ ... lots of output ... ] > > gzip: stdin: decompression OK, trailing garbage ignored > tar: Child returned status 2 > tar: Error exit delayed from previous errors > $ > > Picking the file up from sourceforge ... > > $ ls -l Python-2.0.1.tgz > -rw-r--r-- 1 cs004 spsd 3527360 Jun 23 09:40 Python-2.0.1.tgz > $ gzip -v -t Python-2.0.1.tgz > Python-2.0.1.tgz: > gzip: Python-2.0.1.tgz: unexpected end of file > $ > > With the one archive I was able to extract, I'm not sure I have the > entire package. Anyone else seeing this? From foo at ix.netcom.com Fri Jun 8 20:09:33 2001 From: foo at ix.netcom.com (Matt Butler) Date: 8 Jun 2001 17:09:33 -0700 Subject: Win32 Installer on 2.1? References: <50be6f7c.0105220115.612c9912@posting.google.com> <50be6f7c.0106062352.a6f2670@posting.google.com> <50be6f7c.0106071259.13fcbfc3@posting.google.com> <90BA710B4gmcmhypernetcom@199.171.54.154> Message-ID: <50be6f7c.0106081609.2c9cf663@posting.google.com> gmcm at hypernet.com (Gordon McMillan) wrote in message news:<90BA710B4gmcmhypernetcom at 199.171.54.154>... > needs that, drop me a note. Otherwise, I'll keep plugging and roll it into > 4a2. Super-cool! From sdm7g at Virginia.EDU Fri Jun 22 20:04:03 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Fri, 22 Jun 2001 20:04:03 -0400 (EDT) Subject: [OT] MS EULA -- (will ActiveState become outlaws? ;-) In-Reply-To: <3b33ca1a.15203020@news.laplaza.org> Message-ID: On Fri, 22 Jun 2001, Mats Wichmann wrote: > On 22 Jun 2001 17:06:43 GMT, David LeBlanc > wrote: > > :In article <3B33644D.E32B4215 at pfortin.com>, pfortin at pfortin.com says... > :> This page was visible with NS4.77/Linux yesterday; now, it stalls for a few > :> seconds, then presents a "page not found" screen... either they are shutting > :> out NS and/or Linux, or they've removed it... > : > :Today MS IE 5.5 stalls and then puts up a "page cannot be found" 404 > :page. I wonder if MS legal woke up and smelled the gathering litigation > :clouds. I'm not a lawyer, but this smacks of restraint of trade or unfair > :competition at least. Of course, that's par for the course at MS, but > :even they are not usually so stupid as to hand the opposition a smoking > :gun like this. > > No, it really is, as Marc-Andre just said, the "Slashdot Effect": get > your page listed on Slashdot, especially for something > negative-sounding, and two million people try to connect to your site > at the same time. > > A performance problem. No -- it's not the Slashdot Effect (at least in the performance sense). It's been changed to redirect you to a 'page not found' page. They very clearly removed it. Wiser and cooler heads must have prevailed at MS. -- Steve Majewski From ullrich at math.okstate.edu Wed Jun 13 14:44:35 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Wed, 13 Jun 2001 18:44:35 GMT Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: <9g4nec0cnr@enews2.newsguy.com> <3b266453.317327753@wa.news.verio.net> <3b2768b5.1425762@nntp.sprynet.com> <9g80s302q1f@enews1.newsguy.com> Message-ID: <3b27b40a.20713460@nntp.sprynet.com> On Wed, 13 Jun 2001 17:29:05 +0200, "Alex Martelli" wrote: >"David C. Ullrich" wrote in message >news:3b2768b5.1425762 at nntp.sprynet.com... > ... >> >I like orthogonality too. > ... >> So just out of curiosity: Roughly what do you >> mean by "orthogonality" above? > >http://www.dictionary.com/cgi-bin/dict.pl?term=orthogonal >suggests (after several other meanings): > >""" >orthogonal > >Mutually independent; [...] > >[Jargon File] > >(1994-12-21) > >Source: The Free On-line Dictionary of Computing, ? 1993-2001 Denis Howe >""" Right. More or less what I thought. (Straying even farther off topic, the only remaining question is why this reference mentions the "Jargon File" but I can't find it in what seems to be a recent version. Not an important question.) >Alex > > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From tim.one at home.com Sat Jun 23 13:47:06 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 23 Jun 2001 13:47:06 -0400 Subject: Another Wart! string.find() [ was: namespace issue? ] In-Reply-To: <5.0.2.1.0.20010622145446.034b0e40@mail.mindspring.com> Message-ID: [Tim] > Historical note: at the time these functions were designed, negative > indices were not allowed: sequence[negative_int] raised an exception. > Allowing the latter was a later addition to the language, and was a > mixed blessing (for this and other reasons; but I think it was a net > win). [Chuck Esterbrook] > I would be interested to know what other things besides the -1 from > find() were a minus for negative indices...? Nothing deep: Python does bounds-checking for sequence indexing, and assorted cases that are off-by-1 errors in reality (decrementing an index from 0 to -1 by mistake, or an index difference i-j going negative by mistake) started doing unexpected things silently-- instead of raising exceptions --after the change. This makes one class of logic error much harder to track down, and that's a loss when it happens. I get bit by this a couple times per year; it's curious how very rarely it pops up as "the answer" to c.l.py "help!" postings, though. There was also some minor code breakage, in rare cases where code *relied* on catching IndexError exceptions to skip over "don't care" conditions (like using -1 as an explicit "don't care" index in a list of indices -- that simply doesn't work anymore). > ... > I discuss such things because I'm interested in language design and > Python is closest to what I would consider ideal. You must be a pragmatist at heart . takes-one-to-know-one-ly y'rs - tim From thomas at xs4all.net Sat Jun 23 19:22:02 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 24 Jun 2001 01:22:02 +0200 Subject: PEP 255: Simple Generators, Revised Posting In-Reply-To: References: Message-ID: <20010624012202.Q8098@xs4all.nl> On Sat, Jun 23, 2001 at 05:27:45PM -0400, Tim Peters wrote: > The answers can only be "no" if you think of "if 0:" as a C "#if 0" > preprocessor gimmick. The specific value after a Python "if" should have no > effect on statically-determined properties of Python code. Including code size ? We should just disable the dead-code-elimination then, even in -OO mode (otherwise, code would suddenly *start* working when 'compiled' with heavy optimization... that'd be a first ;) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From f91-men at nada.kth.se Mon Jun 18 05:54:01 2001 From: f91-men at nada.kth.se (Mattias Engdegård) Date: 18 Jun 01 09:54:01 GMT Subject: Any other Python flaws? References: Message-ID: Marcin 'Qrczak' Kowalczyk writes: >Except those which don't assign to names at all, like OCaml or Haskell. Naturally, but I think (at least some) people would be upset if we removed side-effects from Python :-) From aleaxit at yahoo.com Tue Jun 12 09:56:26 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 12 Jun 2001 15:56:26 +0200 Subject: PEP 259: Omit printing newline after newline References: <3dd78ag04f.fsf@ute.cnri.reston.va.us> Message-ID: <9g572b01dal@enews2.newsguy.com> "Marcin 'Qrczak' Kowalczyk" wrote in message news:slrn.pl.9ibh7p.2gn.qrczak at qrnik.zagroda... > 11 Jun 2001 17:47:12 -0400, Andrew Kuchling pisze: > > > -1; I'd rather see a strip_trailing_whitespace argument added to > > .readlines(), or some alternative idiom encouraged that sidesteps the > > issue. Magical behaviour is bad. > > print is too magic in the first place. I would rather add write > builtin function, equivalent to sys.stdout.write, and arrange that > write functions are easy to use, i.e. allow multiple arguments, > apply str to them, and maybe have also writeln. Same here, except I don't think "write" is the best name (I'd prefer for example "output", but I consider that minor) AND I don't think two functions are ideal -- rather, one function with a named parameter ln=1 (by default). I.e., where your suggestions might let one code: write(a,b,c) writeln(d,e,f) I'd rather express it: output(a,b,c,ln=0) output(d,e,f) (np for me if ln defaults the other way, or is called in some other fashion). But the differences between your ideas and mine are basically syntax-sugar. Besides several advantages for having this stuff in a function, which I have already mentioned, consider: output(a,b,*manymore) versus... what? print a,b, for item in manymore: print item, print How's that for a statement's "convenience"?-) Having the newline/nonewline choice in a named parameter rather than in two different functions (or syntax forms right now) is a tad more than just sugar: def linend(i, longish=longish): return i==len(longish)-1 or i%10==9 # print no more than 10 per line for i in range(len(longish)): print longish[i], if linend(i): print or # print no more than 10 per line for i in range(len(longish)): write(longish[i]) if linend(i): writeln() vs # print no more than 10 per line for i in range(len(longish)): output(longish[i], ln=linend(i)) Alex From zeitlin at seth.lpthe.jussieu.fr Wed Jun 13 15:22:44 2001 From: zeitlin at seth.lpthe.jussieu.fr (Vadim Zeitlin) Date: 13 Jun 2001 19:22:44 GMT Subject: [wxPython] layout manager? References: <3B24ADE9.99D61FEE@senux.com.NOSPAM> Message-ID: On Mon, 11 Jun 2001 23:03:27 GMT, Robert Amesz wrote: >WxLayoutConstraints is the most flexible of the layout managers, But you shouldn't use them unless you are absolutely sure that you can't achieve the desired layout with sizers (which probably just means that your layout is way too complicated). The sizers are much easier to use and are by far the preferred layout mechanism in wxWindows 2.2. >wxBoxSizers is fine if you simply want a row or column of things. The >one trick wxBoxSizers can do which WxLayoutConstraints lacks is the >ability to fix the aspect ratio of a resizable subwindow. The constraints can do it, of course - just don't use them for it :-) Regards, VZ -- GCS/GM d? H+ s++:-- p2 au--- a- w+ v C+++ UBLS+++ P- L++ N++ E--- W++++ M? V-- -po+ R++ G`` !tv b+++ D--- e++++ u++ h--- f+ r++ n- y? From andy.pevy at nokia.com Wed Jun 20 09:06:37 2001 From: andy.pevy at nokia.com (andy.pevy at nokia.com) Date: Wed, 20 Jun 2001 13:06:37 GMT Subject: Function lookup using a directory. References: <29pX6.14682$cF.320097@news1.nokia.com> Message-ID: Hi Johann Johann Hibschman wrote: > andy pevy writes: >> The killer was the actual code to call the looked up class :- >> try: >> h = command_table[command[0]] >> except: >> print command[0]+' not found' > >> h.run(h(),command) >> It seems that you have to manually pass in the 'self' parameter >> when calling functions this way. > Two points: > 1. That last line should be "h().run()" to be idiomatic. First create > the instance, then run the "run" method. > 2. Why are you using classes at all? If things are really as simple > as you make it seem, just use functions. Well, it is as much a learning excercise as anything, and as such I will have functions in the main programme and classes in the extensions. > -- > Johann Hibschman johann at physics.berkeley.edu -- We were always told that a million monkeys typing for a million years would eventually produce the works of Shakespeare. Now, thanks to the Internet, we know this is not true. From smarsh at hotmail.com Sun Jun 24 11:58:32 2001 From: smarsh at hotmail.com (scott) Date: Sun, 24 Jun 2001 15:58:32 GMT Subject: What's object-oriented? References: Message-ID: <3B360E23.4EEDCAEB@hotmail.com> zoodoo wrote: > > What's the concept/logic behind object-orientation? What is it suppose to > mean? Check this section of Suns Java tutorial (no interfaces in Python, unfortunately): http://java.sun.com/docs/books/tutorial/java/concepts/index.html From James_Althoff at i2.com Fri Jun 8 14:37:02 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Fri, 8 Jun 2001 11:37:02 -0700 Subject: ROGER SESSIONS DISQUALIFIES JYTHON AS "FREEWARE" Message-ID: Don O'Donnell wrote: >In the current issue of his monthly newsletter "ObjectWatch": > >http://www.objectwatch.com/issue_33.htm > >Roger Sessions, author of "COM+ and the Battle for the Middle Tier", and >ever a strong proponent of the Microsoft mantra from COM to DCOM to COM+ >to .NET, in his main article "IS JAVA LANGUAGE NEUTRAL", searches for >languages, other than Java, which run on the Java platform. I read it >avidly, expecting to find kind words about Jython. Alas, he classifies >JPython/Jython as "Freeware" and lumps it together with "School/Hobby >projects" and says: > >"Both of these categories include technologies >that show the feasibility of generating JBC from sources other than Java >(a capability that is not in dispute), but do not include actual supported >implementations that would be used in a large commercial project." I guess this news would come as quite a surprise to our customers who have paid millions of $$$ for our Jython-based products. I suppose you could say that our "hobby projects" have been _very_ rewarding. ;-) (BTW, the total revenue for all of our products -- not just the Jython-base ones -- last year were over a billion dollars so we are not exactly a "small fish" in the commercial software world.) >(JBC == Java bytecode) > >I just thought that some of you Jython programmers out there (I only use >the C version myself) might want to take issue with him. > >-Don From sholden at holdenweb.com Mon Jun 18 18:26:22 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 18 Jun 2001 18:26:22 -0400 Subject: VI References: <3B278900.5828FB59@Lugoj.Com> <9gaunm$mth$3@brokaw.wa.com> <9gdcl10oti@enews1.newsguy.com> <3B2A4CB4.FE31CB72@Lugoj.Com> Message-ID: "James Logajan" wrote in message news:3B2A4CB4.FE31CB72 at Lugoj.Com... > Alex Martelli wrote: > > "Jim Hill" wrote in message > > > And since the expected editor war hasn't broken out, I'll launch a > > > different offensive by proclaiming absolutely and without room for > > > disagreement that it is pronounced "vee eye" and those who say "vye" > > > are bloody peasants who should be repressed by the violence inherent > > > in the system. > > > > I thought _everybody_ knew it's pronounced "six" -- like in "Pope > > Paul VI", no?! > > Is the Pope Muslim? > Only when he's shitting in the woods. From bill-bell at bill-bell.hamilton.on.ca Tue Jun 19 07:57:34 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Tue, 19 Jun 2001 07:57:34 -0400 Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future In-Reply-To: <992910154.405.29761.l10@yahoogroups.com> Message-ID: <3B2F05EE.19992.27F1CA9@localhost> Ron Stephens wrote: > Is there an extensive tutorial or good documentation of wxPython on > the web that one can learn from? I'm new to wxPython (not to mention Python) myself. Since you didn't mention it I would say that I found the demo that accompanies wxPython to be a big help. I've read somewhere that wxPython was "tuned" to be easy to work with and this is certainly my initial impression. - Bill From grante at visi.com Sun Jun 24 20:58:20 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 25 Jun 2001 00:58:20 GMT Subject: Is this a true statement? References: <9h61aa$bg7h5$1@ID-11957.news.dfncis.de> <9h622p$f54$1@panix6.panix.com> Message-ID: On 24 Jun 2001 17:53:45 -0700, Aahz Maruch wrote: >>> One could use a "deeply embedded" Python bytecode interpreter >>> running inside the kernel to allow the user to write a driver >>> in Python. It would take a fair amount of work, but I don't >>> think it would be particularly difficult -- at least under >>> Linux. People have already a lot of the requied work in order >>> to run a Python interpreter on embedded systems. >>> >>> Sounds like a good MS project to me... >> >>I hadn't considered the possibility of a "deeply embedded" python solution, >>but it certainly has possibilities. >> >>Anyone got a virally infected copy of windows os source code to play around >>with? > >I think Grant meant "MS" as in "masters degree". Yes. It's a bit too practical for a PhD. :) -- Grant Edwards grante Yow! .. he dominates the at DECADENT SUBWAY SCENE. visi.com From tim.one at home.com Sat Jun 30 23:03:13 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 30 Jun 2001 23:03:13 -0400 Subject: Not enough Python library development [was PEP scepticism] In-Reply-To: <3B3D0B51.7F458525@ActiveState.com> Message-ID: [Paul Prescod, on what ActiveState has been doing with the Parrot language] > ... > One good example of what our web team has put together is here: > > http://aspn.activestate.com/ASPN/Python/Mail > > I find these archives to be better than other Python archives available > on the Web. Woo hoo! I pissed away an hour earlier this week trying to find an old "dining philosophers" Python example (query on the Tutor list), with no luck. Your archive took me straight to it in a few seconds. So it's already been worth every penny I paid for it. My thanks to the wizards who put this together! a-fat-check-is-in-the-mail-ly y'rs - tim From thecalm at btinternet.com Thu Jun 21 07:22:49 2001 From: thecalm at btinternet.com (Gaz) Date: Thu, 21 Jun 2001 12:22:49 +0100 Subject: Standalone .exe's using installer/builder question Message-ID: <9gsld3$5n6$1@plutonium.btinternet.com> Hi, I've recently downloaded the Installer pkg. from mcmillan inc ( http://www.mcmillan-inc.com/builder.html ) and i wondered if anybody could give me a little guide to using it. This is the test.py script i am using: from Tkinter import * class App: def __init__(self, master): frame = Frame(master) frame.pack() self.button = Button(frame, text="QUIT", fg="red", command=frame.quit) self.button.pack(side=LEFT) self.hi_there = Button(frame, text="Hello", command=self.say_hi) self.hi_there.pack(side=LEFT) def say_hi(self): print "hi there, everyone!" root = Tk() app = App(root) root.mainloop() and this is the command line i use from the RUN promt: C:\WINDOWS\Desktop\temp\Standalone.py test.py -tk anyideas??? i really would like to distribute standalone .exe's of my scripts, ta gaz. From thomas at xs4all.net Fri Jun 1 10:25:41 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 1 Jun 2001 16:25:41 +0200 Subject: Python 2.0 Patch ??? In-Reply-To: ; from pmoscatt@bigpond.net.au on Fri, Jun 01, 2001 at 10:30:41AM +0000 References: Message-ID: <20010601162541.O690@xs4all.nl> On Fri, Jun 01, 2001 at 10:30:41AM +0000, Peter Moscatt wrote: > I currently using Python 2.0 > I am led to believe that there is a patch available for this - where is it > obtainable ?? Moshe Zadka is working on Python 2.0.1, a patch release of 2.0. It's not done, however, and when it is done, it will not be released as a patch to Python 2.0. Rather, it'll be a full install. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From barry at digicool.com Fri Jun 15 13:25:20 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Fri, 15 Jun 2001 13:25:20 -0400 Subject: Any other Python flaws? References: <9gbe4e$gla$2@newshost.accu.uu.nl> Message-ID: <15146.17664.872204.177540@anthem.wooz.org> >>>>> "MH" == Michael Hudson writes: >> Another one is the fact that you can't mix try/finallys with >> try/excepts. MH> Isn't the usual argument about this one that it's not obvious MH> what gets executed when? MH> Eg. does | try: | raise Exception | except Exception: | pass | finally: | print "hullo" MH> print "hullo"? I guess so. Still, the explicitness of what MH> you have to do now seems to me to be a win over the pain of MH> multiple indentations. MH> Cheers, M. who has, on occasion, written functions that start MH> with three successive "try:"s... Same here! ;) Yup, I /know/ why the wart is there, but it still bugs me. now-where's-my-bottle-of-compound-w-snakeoil?-ly y'rs, -Barry From bedge at troikanetworks.com Fri Jun 29 15:40:57 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Fri, 29 Jun 2001 12:40:57 -0700 Subject: pdb name truncation References: <20010629.094021.1605894428.12508@troikanetworks.com> Message-ID: <20010629.124057.1273911899.12508@troikanetworks.com> In article , "Alex" wrote: >> Is there some setting to get it to expand the ... It's annoying to >> have to restart not under pdb to see what error actually was. > > I've had problems with this, too, and your post induced me to finally > fix it instead of work around it. :) (though usually you can get the > complete error by re-executing the line that caused the error from the > pdb prompt, even that's a bit of a pain.) > > Stick this in a file my_pdb.py in a directory that'll be in your > sys.path, and do > > "from my_pdb import set_trace" > > or whatever it is you usually use from there. > [snip fix] Hey, thanks a bunch!! I'll try it. From thomas at xs4all.net Fri Jun 1 10:00:40 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 1 Jun 2001 16:00:40 +0200 Subject: Why can't slice use non-int. indices? In-Reply-To: ; from mwh@python.net on Fri, Jun 01, 2001 at 01:50:14PM +0100 References: <3B168CF7.F44777F9@yahoo.com> <20010531.201603.771151432.2277@bur-jud-175-024.rh.uchicago.edu> Message-ID: <20010601160040.N690@xs4all.nl> On Fri, Jun 01, 2001 at 01:50:14PM +0100, Michael Hudson wrote: > "Ben Wolfson" writes: > > > In article <3B168CF7.F44777F9 at yahoo.com>, "Paul Winkler" > > wrote: > > > > > This is on python 2.1. > > > > > >>>> a = [] > > >>>> a[3:4] > > > [] > > >>>> a[3.2: 4] > > > Traceback (most recent call last): > > > File "", line 1, in ? > > > TypeError: slice indices must be integers > > > > For that matter, why doesn't this work? > Because the sq_item & sq_slice methods in the PySequenceMethod struct > in object.h is declared as taking ints rather than PyObject*s. This > is probably wrong, but it's hard to see how to fix it without breaking > backwards compatibility. Note that we *started* doing this in 2.0. Since 2.0, if an object defines __getitem__ but not __getslice__, all slice operations create a slice object that gets passed to __getitem__. Unfortunately, because of the way classes are implemented, we can't get rid of the are-slice-arguments-really-ints check for class instances. It should be gone for extention classes, but since very few extention classes implement a sq_getitem that handles slice objects, it's hard to tell. Now that we have a warning system, we should probably start warning against the use of __getslice__ to handle slices... Let-me-add-it-to-the-end-of-my-TODO-list-ly yrs ;-P -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From gorny at hobbiton.org Sun Jun 10 15:14:05 2001 From: gorny at hobbiton.org (Gorny) Date: Sun, 10 Jun 2001 21:14:05 +0200 Subject: bind keys References: Message-ID: <1HPU6.12192$93.94140@zonnet-reader-1> That's not what I ment exactly because I did that already. Example: In most editors you have an shortcut to File --> Open file --> by pressing Control -O you imediately open the fileselectionscreen. How do I set these Control-O events so if I press Conrtol-O in my own program it'll open the fileselectionscreen? Greetz, Gorny -- Never trust anything that bleeds for 3-5 days and doesn't die... http://gorny.cjb.net From hoel at germanlloyd.org Thu Jun 7 07:45:11 2001 From: hoel at germanlloyd.org (Berthold Höllmann) Date: 07 Jun 2001 13:45:11 +0200 Subject: avl module by Samual M. Rushing References: <9fnoi8$56h1o$1@ID-11957.news.dfncis.de> Message-ID: "Emile van Sebille" writes: > A quick look on groups.google finds ftp://ftp.gnu.org/pub/gnu/avl which has > versions 1.2.9, 1.3.0 and 1.4.0 I was talking about Python mappings of avl. Samual M. Rushings uses an own avl implemantation and the problems occur in the Python wrapper. Thanks Berthold -- email: hoel at GermanLloyd.org ) tel. : +49 (40) 3 61 49 - 73 74 ( C[_] These opinions might be mine, but never those of my employer. From JamesL at Lugoj.Com Sun Jun 10 17:34:42 2001 From: JamesL at Lugoj.Com (James Logajan) Date: Sun, 10 Jun 2001 14:34:42 -0700 Subject: Global in multiple files References: Message-ID: <3B23E7F2.2760615D@Lugoj.Com> Artur Skura wrote: > (BTW I would like to thank other people for pointing out the > possibility of having global.py module etc. Yes, it solves my > problem for now, but maybe I should really redesign it as Roman > suggest to eliminate the need. No, I still don't know how :)) I would advise against putting any effort into removing a single global; it is not be worth your while. In fact there is nothing "wrong" with globals per se (speaking from ~26 years of programming experience). Don't worry about removing globals, concentrate instead on containment relationships. Some "top level" objects and relationships properly belong in the global name space. P.S. The main execution frame must start from some name space, normally called the "global" namespace. So at least one (and usually more) object references must be contained in it. You can't get around that basic requirement no matter how much object oriented analysis you care to do. P.P.S. I've never been able to figure out why people insist on keeping the global name space as free of objects as possible while not applying that obsession to other name spaces. True, beginners tend to put everything in the global name space, but no insight on how to organize relationships is going to be imparted by telling them not to put things in the global name space. There is a point when that kind of 30-second "wisdom" becomes unwise. From MarkH at ActiveState.com Mon Jun 18 22:53:15 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 19 Jun 2001 02:53:15 GMT Subject: Help, pls: COM local server factory class References: Message-ID: <3B2EBEE0.1060300@ActiveState.com> Bill Bell wrote: > Esteemed Pythonistas: > > The code that appears below is intended to define a COM local > server. (My understanding of some earlier messages on this list is > that it should result in a singleton by default.) Nope. No singleton here. Each client creating your COM object gets a brand new instance of your "COMServer" class - and hence a brand new GUI thread. As it is a local server, you could store the GUI objects in a global - then each process will be able to have a single GUI thread and object that could be shared by many instances of the COM object. Of course, if you know that each process will only ever create a single COM object, then you can just use what you have - until someone creates a second :) Eeek - I just re-read your code. It does looks basically correct - however, in this case you should drop most COM stuff from "class COMServer". Drop all "_reg_" attributes, and do not attempt to register this class. This means that it will not be possible to create the COMServer object directly, and _must_ go via the factory which does implement the singleton behaviour. Note however that this will still only be a "per-process" singleton - but you have no real choice about that considering you are using GUI features. > 2. What is the meaning of the following? ... > File "", line 2, in Factory > com_error: (-2147352567, 'Exception occurred.', (0, 'Python COM > Server Internal Error', 'Unexpected Python Error: > exceptions.TypeError: Objects for SAFEARRAYS must be > sequences (of sequences), or a buffer object.', None, 0, - > 2147467259), None) Probably that as part of your code, you are calling out to _another_ COM object. This other COM object has a prototype that wants a SAFEARRAY, and is therefore expecting a Python list or tuple. You should register your server for debugging. eg "MyServer.py --debug". Then startup Pythonwin's "Tools->Collect Remote Debugging Output" option. You should then see a complete traceback pointing to the specific line that fails. Hope this helps... Mark. From MarkH at ActiveState.com Thu Jun 21 20:31:57 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Fri, 22 Jun 2001 10:31:57 +1000 Subject: Python COM: Unable to create server-side object. References: Message-ID: <3B3291FD.6060301@ActiveState.com> Bill Bell wrote: From the end of your mail: > File "c:\python21\win32com\server\policy.py", line 448, in _wrap_ > raise error, "Object does not support DesignatedWrapPolicy" > win32com.server.policy error: Object does not support DesignatedWrapPolicy This means that _public_methods_ does not exist. (hrm - so why doesn't the error actually say that you ask! It should! It will!) >> class Short: >> _reg_clsid_ = "{74471ADF-9453-4135-87E6-22E1B9499B0D}" >> _reg_progid_ = "Python.Short" >> _reg_desc_ = "PythonCOM test" >> _public_methods = ["isShort"] Trailing underscore missing! Mark. From tim.one at home.com Fri Jun 29 17:43:34 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 29 Jun 2001 17:43:34 -0400 Subject: PEP scepticism In-Reply-To: Message-ID: [phil hunt] > Now there's a challenge! > > PEP1 says: > The PEP champion (a.k.a. Author) should first > attempt to ascertain whether the idea is PEP-able. > Small enhancements or patches often don't need a PEP and can be > injected into the Python development work flow with a patch > submission to the SourceForge patch manager[2] or feature request > tracker[3]. > > How do I ascertain this? > > Who decides whether something is a "small enhancement"? It's like judging pornography: "contemporary community standards". If you have to ask, you're either a pornographer or a juror . > The changes i propose would be two separate PEPs (I assume) -- > or would they be added to PEP-42 (which is a list of small > features)? Separate PEPs are much more visible. Like the Answer to Everything, PEP 42 may be a long time coming. > It seems to me that optional-pass is obvious in its meaning, Sorry, I have no idea what it means. Like you want to be able to use "pass" in more places, but optionally? Or want not to have to use pass in some places where you must use it now? Or ...? > but multi-liner comments aren't. There are three issues: > > 1. what should be the character sequences to begin/end multi > line comments What do you have against the existing method? That is, """This is a multi-line comment. this part of the same comment. so is this.""" It's truly a comment: a statement consisting of just a string is thrown away by the compiler, unless it's in a docstring position (is the first non-comment statement in a module, def or class). Or the other existing method: # This is a multi-line comment. # Although it sure looks like a sequence of # single-line comments . There's really no point answering these questions on c.l.py: that they've been *asked* means the proposals are already controversial, so need PEPs to lay out all sides of the case. I don't know what "optional pass" means, but the multi-line comment business has come up many times, so it would be especially good to PEP that one, in order to lay it to rest (one way or another) for good. From aleaxit at yahoo.com Wed Jun 20 08:35:25 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 20 Jun 2001 14:35:25 +0200 Subject: rexec works strange... References: Message-ID: <9gq5b00jkl@enews1.newsguy.com> "Oleg Broytmann" wrote in message news:mailman.993034023.17205.python-list at python.org... > > (Ivan, please note - I am replying into the newsgroup, too) > > On Wed, 20 Jun 2001, Oleg Broytmann wrote: > > On Wed, 20 Jun 2001, Ivan Ivanov wrote: > > > Thank you for the help, I'll try to figure out how > > > to do the first suggestion - disallow importing sys. > > > This seems to be a good idea, I just don't know > > > how to do it. Do you have better insight? > > Found it: it is the code > > ok_sys_names = ('ps1', 'ps2', 'copyright', 'version', > 'platform', 'exit', 'maxint') > > To disallow sys.exit remove exit from the list. To do it in Python way: Tuple (so you can't actually _remove_ it:-). You're correct in recommending subclassing for such purposes, of course. But sys.exit() is really innocuous, little more than a raise SystemExit. Just .r_exec() the untrusted code in the try: clause of a try/except that catches everything, as is HIGHLY advisable anyway:-), i.e. with a clause of 'except:', and you'll catch SystemExit too. Alex From sholden at holdenweb.com Wed Jun 13 07:42:33 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 13 Jun 2001 07:42:33 -0400 Subject: PEP 259: Omit printing newline after newline References: Message-ID: "Guido van Rossum" wrote in message news:mailman.992290220.14360.python-list at python.org... > Please comment on the following. This came up a while ago in > python-dev and I decided to follow through. I'm making this a PEP > because of the risk of breaking code (which everybody on Python-dev > seemed to think was acceptable). > > --Guido van Rossum (home page: http://www.python.org/~guido/) > > PEP: 259 > Title: Omit printing newline after newline > Version: $Revision: 1.1 $ > Author: guido at python.org (Guido van Rossum) > Status: Draft > Type: Standards Track > Python-Version: 2.2 > Created: 11-Jun-2001 > Post-History: 11-Jun-2001 > In fact a second reading of the PEP makes it clear that the incompatibility issue *shouldn't* be a problem, so there may not be a reason to worry about this. Just the same I'm surprised it's come tot he top of the priority list -- or was it simply one of those "I can do this in ten minutes so I'll ge it off the list" tasks? I admit to checking that the date "April 1" didn't appear anywhere in the text :-) regards Steve -- http://www.holdenweb.com/ From guido at python.org Fri Jun 29 08:32:26 2001 From: guido at python.org (Guido van Rossum) Date: Fri, 29 Jun 2001 12:32:26 GMT Subject: PEP scepticism References: <3dels41dhs.fsf@ute.cnri.reston.va.us> Message-ID: Andrew Kuchling writes: > No it isn't. Adding language features does not improve the confusing > and incomplete MIME modules currently in the standard library. Barry Warsaw is working on mimelib (http://mimelib.sourceforge.net/) and I expect that this will be added to the 2.2 CVS tree soon! > It does not remove the outdated demo programs from the distribution. Maybe, in the light of the successful PEP 260, someone should write a PEP about removing deadwood from the demos? I'm all for it! (Also more ancient library modules can be deprecated, like all the irix5 cruft. Again, I need help here! > It does not add more documentation. I don't think that's an area where Python is currently particularly lacking. Fred has done a great job. (BTW, when are you going to add all the new Python books to the Python bookstore? :-) > It does not bring us any closer to having a module catalog. It does > not increase Python's visibility outside of the Python community. We're working on that. I hope that the Python events at the O'Reilly conference next month and LinuxWorld in August will reach a lot of outsiders. > My point is that users are not currently saying "Gosh, Python > doesn't have generators, so I won't use it." They're saying "Wow, > there's a lot of useful libraries for Java; I'd better use it to be > able to use them." Point taken. --Guido van Rossum (home page: http://www.python.org/~guido/) From aleaxit at yahoo.com Fri Jun 29 17:44:18 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 29 Jun 2001 23:44:18 +0200 Subject: Is this a true statement: Part II References: <9hiifr$sjs$1@taliesin.netcom.net.uk> Message-ID: <9hisnt0256l@enews1.newsguy.com> "Paul Prescod" wrote in message news:mailman.993843346.4433.python-list at python.org... ... > > Why is C++ awful; what's wrong with it? > > C++ is a large and complex language. In my opinion it tries but fails to > work both on the abstraction level of a high level language and a > low-level language which gives it a very confusing runtime model. One In my opinion it tries *AND SUCCEEDS* to work on both of these abstraction levels, which is a good part of what gives it its complexity -- the real killer. Mind you, I'll still use C++ by preference when I need top performance -- it makes me much more productive than C (though I don't know if it was worth the *many* years' worth of experience and study to get to that level), not to mention Eiffel, Ada, and other B&D languages, and (while I do enjoy FP in general -- Haskell is always a pleasure) ML apparently just hits me wrong -- I'm not very productive in it, and my ML code always seems to run slowly (particularly with O'Caml, which is supposed to be the performance world-beater of the FP world) -- presumably just some mental block on my part, but the fact remains. Oh, I'd still be good for writing some highly vectorizable Fortran code if _those_ were the kinds of performance issues at hand, I guess -- but they aren't, generally, and C++ lets me architect my code's structure much better than Fortran (the Fortran I knew -- it HAS been a while:-). Besides, C++ enjoys excellent interfacing to Python -- only Java with Jython is even better (but not in the performance arena:-)... > minute you are doing things that look low-level but are really very > computationally expensive and the next you are being constrained from > doing something that seems reasonable because C++'s designers didn't > want to take the performance hit. After a few years and a few hundred thousands lines of code, you gradually do get to internalize the various design decisions, at least at this level. As for "computationally expensive", there never was any real alternative to profiling after-the-fact to find out where the time is going... C++ is no worse than anybody else in this respect, as it happens. > Plus it is so complicated that the > implementations still vary widely so you have to "port" code from one > compiler to another. That's one of the downsides of complication, yes. Although the common subset of (latest releases of) MSVC++, gcc and Comeau (basically EDG front-end + a little glue to platform-specific compilers, very cheap, very close to the ISO C++ Standard [for the _language_ -- the _library_ is NOT there yet...]), covering a vast majority of platforms, is close enough to the standard to do a LOT of good work. Porting among these three C++ compilers (at least if using one common library, such as SGI's STL and Boost) is no more "porting" than in my experience it was a few years ago to port among the nominally-ISO-standard C compilers of half a dozen major manufacturers. (If the amount of '#if's in Python's sources are a good indication, the difference between C and C++ on this score isn't all that large -- considering the C standard has been out for 12 years, the C++ one for 3, and the latter is at least twice as big as the former, one would expect much more problems in the C++ world compared with what one gets...). My personal opinion, again: C++ is too complex for the human mind (or, at least, mine) to grasp and use at perfect efficiency. But, to paraphrase Churchill...: when you need top performance in general-purpose tasks (particularly to write Python extensions), it's the worst language there is... except only all others. I think that over 90% of programmers would be better off it they had never heard about C++. But, there IS a need for top performance -- in a tiny minority of the source code for a tiny minority of the programs. C++, particularly with templates at their best (www.boost.org for some examples), lets you get top performance with coding that's still quite high-level. It bends your mind, surprises you once a week even if you're the hardest-boiled guru around, and makes you curse (even when you're not using the curses library) -- but it does deliver, when used for what it's really well-suited for (MOST of what gets coded in C++ today would be best coded in Python... but that is another issue!-). Alex (Brainbench MVP for C++ -- declaring interest, as it were:-) From manu at meta-x.org Tue Jun 12 20:24:48 2001 From: manu at meta-x.org (Emmanuel Hocdet) Date: Wed, 13 Jun 2001 02:24:48 +0200 Subject: problem building 2.1 on Solaris 8 Message-ID: <9g6c29$rb3$1@front7m.grolier.fr> i compil python 2.1 on Sparc Solaris 8 with gcc 2.95.3 and have a pbl... :( any idea? manu [...] gcc -o python \ Modules/python.o \ libpython2.1.a -lpthread -lsocket -lnsl -ldl -lthread -lm PYTHONPATH= ./python ./setup.py build Traceback (most recent call last): File "./setup.py", line 14, in ? from distutils.command.build_ext import build_ext File "/opt/compil/Python-2.1.manu/Lib/distutils/command/build_ext.py", line 21, in ? extension_name_re = re.compile \ File "/opt/compil/Python-2.1/Lib/sre.py", line 90, in compile return _compile(pattern, flags) File "/opt/compil/Python-2.1/Lib/sre.py", line 134, in _compile p = sre_compile.compile(pattern, flags) File "/opt/compil/Python-2.1/Lib/sre_compile.py", line 368, in compile code = _code(p, flags) File "/opt/compil/Python-2.1/Lib/sre_compile.py", line 349, in _code _compile_info(code, p, flags) File "/opt/compil/Python-2.1/Lib/sre_compile.py", line 238, in _compile_info lo, hi = pattern.getwidth() File "/opt/compil/Python-2.1.manu/Lib/sre_parse.py", line 173, in getwidth self.width = int(min(lo, sys.maxint)), int(min(hi, sys.maxint)) OverflowError: long int too large to convert make: *** [sharedmods] Error 1 From tundra at tundraware.com Sun Jun 24 17:50:02 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: 24 Jun 2001 21:50:02 GMT Subject: tgrind defs for python? Message-ID: <3B365F85.70952299@tundraware.com> Has anyone created python definitions for 'tgrind' and, if so, where might I find them? TIA, -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From tim.one at home.com Sun Jun 17 23:32:30 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 17 Jun 2001 23:32:30 -0400 Subject: locking dictionaries (was Re: New statement proposal for Python) In-Reply-To: <9gf8990f5c@enews1.newsguy.com> Message-ID: There's a PEP in here somewhere . Eric Raymond brought up similar ideas on Python-Dev some time ago, but nothing came of it then. One concern: since dicts are crucial to Python's performance, we're loathe to add any code to their critical paths, or more memory to the object. Indeed, I spent a fair chunk of my life reducing the internal dict bloat after 2.1 was released, and we got some nice speedups in return. Provided Guido is successful in healing the type/class split, it should be possible to subclass dicts (in Python or C), and you can make those just as slothful as you can bear . [Alex Martelli] > ... > my correspondant was appalled at the idea of using 'bits' to overtly > encode 'a set of options' and I could not find an alternative, as > Python lacks 'sets'. > ... > A dictionary whose lockbits are set to forbid ANY rebinding, > deleting, new-key binding, AND change to the lockbits, could > suddenly and logically sprout hashability, since it becomes an > acceptable key IF it has hashable values (much like a tuple -- > if the items are changeable, the fact that the _container_ is > not does not suffice). But that's an aside, I guess. Earlier talk about freezing a dict actually started in relation to Greg Wilson's PEP to add a set type to Python. He's implementing sets as dicts under the covers, and so sets of sets (etc) require hashing (and freezing) dicts. I don't think we have a slick solution for that. Right now a Set instance sets a .frozen flag when its __hash__ method gets called, and all the mutating Set methods check that flag at the start (raising an exception if it's set). The problem is that the flag gets lit sometimes when it needn't be; e.g., doing if setA in setB: shouldn't freeze setA forever. So hash() is a wrong thing to key on. OTOH, dict[setA] = 42 *must* freeze setA's dict, and the only clue the Set type has is that hash() gets called. So look on the bright side: if you never get these bits, you'll never have to wrestle with managing them either <0.8 wink>. From jkraska1 at san.rr.com Thu Jun 7 12:47:27 2001 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 07 Jun 2001 16:47:27 GMT Subject: priority queue References: Message-ID: >I'm also interested on your binary heap implementation, but I could not get >the module at sourceforge. Any problem that you are aware? It's only available through CVS. It probably also only compiles on Windows, although that's trivially fixed with removal of the dllexport thingies. C// From spam_kill.guse at hobbiton.org Tue Jun 5 09:20:04 2001 From: spam_kill.guse at hobbiton.org (goose) Date: Tue, 05 Jun 2001 13:20:04 GMT Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> Message-ID: <3b1cdc84.5514@bolder.com.co.za> Polterguy merely scratched his head and went: my newbie-two-cents-worth opinion ... don't take offence :-) > [...snip...] > I agree totally, but fact is 99.99999% of the commersial world uses win32. what's your source on this ? *all* the /commercial/ products i've been involved in developing in my short career has been on *nix systems ... a lot of the technical managers out there who want a in-house solution prefer to do it as cheaply as possible ... this means linux/*bsd/etc > So why go through the extra trouble adding cross OS programming when it's I will ... and anyone who's even remotely involved in the team i am in .. > going to increase the cost of releasing a product with a factor of 50?!? no it doesn't - if your talking about rewriting everything else to be like MFC, then it will, but a lean/clean multi-platform lib doesn't need to take 50x longer ... > > All game companies founded on cross OS releases have either gone broke or > are soon to become so! name a few ... and for every one that u name, i'm sure that i can come up with a company that has gone broke *not* doing cross-platform dev. those stats only prove that stats lie, nothing else ... > How much I may hate Bill Gates and that stupid CEO of him who doesn't even > know what HAL means, there's still the facts. > If you want to be successfule and reach 99.9999% of the world use technology > built on win32, DirectX, C++, hell fucking ay, if you can get away with it > use VB!!. Use OBJECT tags in your HTML, use ASP (especially the new ASPX and > the webforms i find XTREMELY interresting...). > you sound like a windows-weanie i had the displeasure of meeting recently ... he kept arguing that i was "killing my career by not working on microsoft stuff" and he refused to believe that there is actually a demand (mayhap, not as large as for windows-ppl) for unix ppl. he kept saying "no one uses that anymore, everone uses windows" ... even though i pointed out to him that, two years ago ppl developing J++ "solutions" were as common as bird droppings, today no one even puts that on their CV, even if they have used it ... they put in "java experiance". 2.5/3 years ago, ppl looking for jobs as access "programmers" were in demand, now ? what happened ? well, sooner or later someone realized that these ppl were not real "programmers", just "applications integrators" who charged too much (access was/still is an expensive product) and moved on to linux/mysql with odbc servers ... much cheaper, and linux programmers are available at the same rate per/hour (maybe less) as your avg solution developer ... going with the flow, and following M$ is a real career limiting move ... just ask all those MCSE's who decided it was the way to go 3 years ago ... where do you think the MCSD's are going to be three years from now ? Microsoft changes the goalposts so often in it's attempt to 'commodotize protocols' (hope i spelt that right), that you have to constantly try to keep up with old technology (whatever happened to OLE - spending money learning that would have been a waste of time - spending the same amount of time and money learning sockets-programming bsd ala style would still stand you in good stead now) ... and before anyone argues about how OLE only underwent a name change, please consider the sheer *volume* of text those changes generated ... and, after all they have done trying to push their 'enhancements' ahead, the linux market is *still* growing (worth, if one believes the redhat site, approx 24% of server's and 18% of desktops - i'm not too sure tho', would have another look for stats around the web when i have the time...) > This is my opinion and I realize this will probably become my own social > suicide, but fact is that every successfule software dealer don't give a > shit about anything but windows... > redhat, suse, mandrake - and that's just the linux ones ... did u ever have a look at lokisoftware ? how about obsidian ? these companies aren't going under, in fact they are thriving in an environment where windows 'supposedly' dominates ... > ...all though it's really sad, and I wish the world was different... > > make your stuff multiplatform ... and not just conformance to 'mfc' or any other proprietry stuff - chances are you'll have to rewrite it when the posts are moved again ... learn opengl over activeX, and java over VB ... build your web-libs with php, not asp, and more ppl will use them ... microsoft's dominance has been dropping over the past few years ... and *may* continue to do so ... *nix has experianced a revival that *no* other piece of software of OS has *ever* done (well, maybe emacs:-) if you want to code stuff that only one platform can run, then only one platform is going to run it ... and we are seeing an explosion in individuality that i have NEVER seen before ... we currently have more different types of hardware than ever before ... double goes for software/os, so don't make the claim that 'everybody' is doing microsoft, 'cos the massive internet still survives on *nix systems ... and if you'r going to code games for microsoft ony;, well, y'know it's your career funeral, not mine. just don't tell me the hogwash that microsoft propogates and expect me to believe it ... -- goose ----- From winterdk at hotmail.com Tue Jun 12 14:37:15 2001 From: winterdk at hotmail.com (Christer Østergaard) Date: Tue, 12 Jun 2001 20:37:15 +0200 Subject: All functions from self and inherited classes References: Message-ID: BTW: My e-mail is winterdk at hotmail.com... not, as stated, wintedk at hotmail.com... :-) Christer From ldw at us.ibm.com Mon Jun 4 10:23:31 2001 From: ldw at us.ibm.com (Larry Whitley) Date: Mon, 4 Jun 2001 09:23:31 -0500 Subject: Python as REXX replacement? Message-ID: <9fg5l3$deo$1@news.rchland.ibm.com> A friend in Poughkeepsie currently uses REXX as his scripting language but is becoming increasingly interested in Python. He asked if there is a version that runs on the IBM 390 systems under VM or MVS? Does a port to 390 (also known as zSeries) exist? Larry From tinu at yeti.ethz.ch Sat Jun 9 03:11:16 2001 From: tinu at yeti.ethz.ch (tinu at yeti.ethz.ch) Date: 09 Jun 2001 09:11:16 +0200 Subject: RS232 support for DOS on 486? References: Message-ID: Thank you for your replies. In this case I am forced to use a DOS box, because it is a rugged version of a handheld with the OS in the PROM, so there is no choice on the OS. Nevertheless I would be grateful for some advice wether a Python version for a 486 exists (apparently python-dx), and if someone has experience whether the RS232 can be poked from there. This is for my personal convenience in order to avoid using a broken language (BASIC) on broken OS. Thank you for further advice Martin L?thi From rsiebler at ibeam.com Thu Jun 21 21:29:33 2001 From: rsiebler at ibeam.com (Robin Siebler) Date: Fri, 22 Jun 2001 01:29:33 GMT Subject: need help with pythonpath References: Message-ID: <1cxY6.9726$Up.285730@sea-read.news.verio.net> Where have you tried to modify it? The easiest thing to do is put the following line into your autoexec.bat set PYTHONPATH=C:\PathtoSearch Notice there are no spaces on either side of the '='. This is important. "NJM" wrote in message news:tj576jotsnhf15 at corp.supernews.com... > I'm probably over looking something obvious, but I'm not able to modify my > pythonpath. I've tried it every way I can think of with no results. > > I'm on a Win 98 machine > > Can any one help?? > > From gerhard.nospam at bigfoot.de Mon Jun 25 13:53:06 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Mon, 25 Jun 2001 19:53:06 +0200 Subject: DCOracle: platforms? References: <2hJZ6.16808$g4.471561@e420r-atl2.usenetserver.com> Message-ID: On Mon, 25 Jun 2001 12:06:48 -0400, Steve Holden wrote: >Cam anyone tell me if they have the DCOracle module working on Windows? The >distribution's web page claims all platforms, but I don't see any Windows >installation instructions, and haven't done enough C development in that >environment to be confident of tackling this without assistance. DCOracle2 is currently in beta testing stage, Windows/Python 2.1 binaries are available. There is also an alternative Oracle module: cxOracle. If you really want the old DCOracle, I have a Python 2.0 binary at my homepage. DCOracle2: http://www.zope.org/Members/matt/dco2 cxOracle: http://www.computronix.com/utilities/ HTH Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://highqualdev.com public key at homepage public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From geoff at homegain.com Thu Jun 14 21:47:41 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Thu, 14 Jun 2001 18:47:41 -0700 Subject: VI Message-ID: <393D961EA4FCD311B03F00D0B746D65803275EAC@HQSXCH01> At the time, I was working in a shop where a fresh disk format and a clean install of the OS was as common as a reboot -- in fact, moreso -- and we had like 30 machines and a plethora of different OS flavors. I did copy my .emacs file from machine to machine, for the first ten or twenty machines. And on some of those machines, I was actually able to take the time to make the customizations so it worked inside that environment. Many of those boxes didn't even /have/ emacs, and so I'd hafta install emacs, too. And then I got sick of it, caved, and learned vi. I don't hate emacs, but I don't really see a compelling reason to go back. I'm pretty comfortable now. :) --- Geoff Gerrietts Software Engineer, HomeGain.com 510-655-0800 x4320 > -----Original Message----- > From: David Bolen [mailto:db3l at fitlinxx.com] > Sent: Thursday, June 14, 2001 3:46 PM > To: python-list at python.org > Subject: Re: VI > > > Geoffrey Gerrietts writes: > > > On the other hand, I use vim religiously now. I can't > imagine editing in > > anything else. I've used emacs, and it used to drive me > absolutely insane > > the way 9/10 of what I wanted to do required typing M-x > > really-longass-function-name, and how I had to re-bind my > keyboard to be > > useful on every new machine I worked on. > > Ah, that's what your .emacs is for... I think mine is probably closing > in on 12+ years old now (before that it was Tops-20 Emacs which was a > different beast) and aside from tweaks/enhancements when upgrading > Emacs it just follows me to each new machine and each new job :-) > > -- > -- David > -- > /------------------------------------------------------------- > ----------\ > \ David Bolen \ E-mail: > db3l at fitlinxx.com / > | FitLinxx, Inc. \ Phone: (203) > 708-5192 | > / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) > 316-5150 \ > \------------------------------------------------------------- > ----------/ > -- > http://mail.python.org/mailman/listinfo/python-list > From hoel at germanlloyd.org Thu Jun 7 07:06:09 2001 From: hoel at germanlloyd.org (Berthold Höllmann) Date: 07 Jun 2001 13:06:09 +0200 Subject: avl module by Samual M. Rushing Message-ID: Hello, I'm trying to use the avl module done by Samual M. Rushing in one of our projects. I got some strange segfaults and tracked them down to avl.so. I did a fix to get over this segfault, but I'm not shure whether the fix affects data integrety. Before I create more tests, is there a newer version then the one from 101098? Or any alternative? Thanks Berthold -- email: hoel at GermanLloyd.org ) tel. : +49 (40) 3 61 49 - 73 74 ( C[_] These opinions might be mine, but never those of my employer. From uioziaremwpl at spammotel.com Fri Jun 29 18:19:56 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Sat, 30 Jun 2001 00:19:56 +0200 (CEST) Subject: Is this a true statement: Part II In-Reply-To: Message-ID: On Fri, 29 Jun 2001, phil hunt wrote: > On Fri, 29 Jun 2001 14:48:23 -0400, MDK wrote: > > > >Why is C++ awful; what's wrong with it? > > I don't think it is awful. > > But it does have drawbacks. The main one, IMO, is that the tasks > it is good at are not the tasks it is mostly used for. > > C++ is a very good system programming language. For wiritng > operating systems, device drivers, windowing systems, programing > language compliers and interpreters, it's a natural choice. > > But for writing GUI applications, it typically isn't, unless > speed is imperative. Well, at least most GUIs _themselves_ are programmed in C/C++. > Write your apps in python. Then convert them to C++ if it doesn't > run fast enough. Cheers, Carsten -- Carsten Geckeler From thomas.hansenNOSPAMORILLSUEYOURASS at entermatch.com Thu Jun 7 03:57:39 2001 From: thomas.hansenNOSPAMORILLSUEYOURASS at entermatch.com (Thomas Hansen) Date: Thu, 7 Jun 2001 09:57:39 +0200 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3b1cdc84.5514@bolder.com.co.za> <9fleid$3rp$1@oslo-nntp.eunet.no> <3b1e4ef5.3788@bolder.com.co.za> <3B1E532F.7158FCFD@lmf.ericsson.se> Message-ID: <9fnbll$o6v$1@oslo-nntp.eunet.no> > Now that was true in Hungary! Maybe not today, but I doubt that big cos > changed a lot. I said I want it w/o OS they said: no way. MS > _forces_them_ to sell Windoze with every PC. I said then I don't want a > HDD in it. They say OK, then it costs +100USD. I say: so long > suckers... and bought a PC from a "garage company". The ridicul is that > I had highest possible MSDN and I was buying this SMP stuff for > development... I already bought the OS for a lot of money from MS. > Actually _all_ OSs including the traditional Chinese versions... And > now comes: the garage PC needed me to install a new vent into it for the > HDD was too hot... So at least where I am you don't get a PC w/o MS OS. > :-((( > > A This is also true for Norway!! From mixo77 at usa.net Fri Jun 8 10:25:06 2001 From: mixo77 at usa.net (mixo) Date: Fri, 08 Jun 2001 16:25:06 +0200 Subject: Catching Errors Message-ID: <3B20E042.DA0AF3C1@usa.net> How can I catch errors that I are usually written to standard output? For example , say I have an error in my code, I would like to to have the ouput written to a file.. The following is what is written to standard output : ------------------------------------------------- Traceback (innermost last): File "errors-catch.py", line 24, in ? print "hello world! s" %test TypeError: not all arguments converted ----------------------------------------------- due to the error in the statement : print "hello world! s" %test # "s" should be "%s" The idea is, I want to simply write it (the error )to a file ! (and I would n't mind as well knowing what the errors is- even if its just an error code) From ullrich at math.okstate.edu Wed Jun 13 09:33:51 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Wed, 13 Jun 2001 13:33:51 GMT Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: <9g4nec0cnr@enews2.newsguy.com> <3b266453.317327753@wa.news.verio.net> Message-ID: <3b2768b5.1425762@nntp.sprynet.com> On Tue, 12 Jun 2001 19:25:25 GMT, bokr at accessone.com (Bengt Richter) wrote: >[...] In general, I'd prefer that a language >provide a clean way to create a solution to a problem, >rather than having a particular solution built in. >I like orthogonality too. Not to change the subject just because every single participant in the "debate" seems to be on the same side (well, except for this Guido guy, whoever he is), but to settle a bet, as it were: Some time ago I said something to someone about the "orthogonality" in Python's design. The guy I was speaking to had never heard the word applied in this context - I tried to explain what it seemed to me the word meant here, he explained back that he was a professional programmer and had never heard of the word, _almost_ stating that it followed that there was no such use of the word, and there we were. So just out of curiosity: Roughly what do you mean by "orthogonality" above? (Don't find it in http://info.astrian.net/jargon/ , although I did just now notice that "Guido" is defined there...) David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From jurberg at my-deja.com Fri Jun 15 08:07:24 2001 From: jurberg at my-deja.com (John Urberg) Date: 15 Jun 2001 05:07:24 -0700 Subject: Integrating a Python GUI into a PowerBuilder App References: <49624b0b.0106121135.61b6bd6c@posting.google.com> <49624b0b.0106140505.79851658@posting.google.com> <9gahru048k@enews1.newsguy.com> Message-ID: <49624b0b.0106150407.626295ca@posting.google.com> "Alex Martelli" wrote: > If a "Java GUI" can be "a child window of the MDI", I'm astonished > (I would have thought it impossible!) -- but if you can do it in > Java you can do it in Python (Jython, to be precise, since it can > use ANY GUI class that Java can use). > > If a "VB GUI" can be "a child window of the MDI", I'm astonished > (I would have thought it impossible!) -- but if you can do it in > VB you can do it in Python (Python on Win32 has excellent COM > support, and so it can control any "VB GUI", since VB exposes > things in COM terms). > > So, no need to settle for either Java or VB. Once you've found > how to use their GUI's "as child windows of the MDI", let us > know, and, albeit bereft of any PowerBuilder knowledge whatever, > it will be reasonably easy for us to show how to use Python. Sorry if I was unclear in my previous post. I can use a Java or VB GUI by making ActiveX controls from GUI panels done in those languages and placing them on a blank PowerBuilder MDI child window. Since I can't do that in Python, I have to find some other way (making a Python window a child of my PB apps MDI frame was one last desperate shot). Seems I'm out of luck. Regards, John Urberg From davygrvy at pobox.com Mon Jun 18 22:47:40 2001 From: davygrvy at pobox.com (David Gravereaux) Date: Mon, 18 Jun 2001 19:47:40 -0700 Subject: ANNOUNCE: itclpython 1.0, done. Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 =============================================================================== ITCLPYTHON -- An [Incr Tcl] class extension. Version 1.0 (June 18, 2001) By David Gravereaux , based on original work by Jean-Luc Fontaine. =============================================================================== == BLURB == With this extension library, you can host python interpreters from Tcl. Supports UNICODE return into Tcl and standard channel redirection. The included source code could be educational if your interested in how to link C++ classes to [Incr Tcl] classes without the use of SWIG. The Py::Interp C++ class(es) might also be useful for embedding Python into applications. == WHERE? == http://sourceforge.net/project/showfiles.php?group_id=13244&release_id=39973 == WHAT'S NEW == o Redirects stdout and stderr from Python into Tcl's channel system. If you happen to be redirecting Tcl's standard channels with a custom channel driver, Python will follow. o Decodes the string sent to Python into iso8859-1. == EXAMPLE USE == C:\WINNT\system32>tclsh84 % package require itclpython 1.0 % set i [python::interp #auto] interp0 % $i exec {import sys} % $i eval {sys.version} 2.1 (#15, Apr 23 2001, 18:00:35) [MSC 32 bit (Intel)] % itcl::delete object $i % exit See itclpython.itcl for the instructions on the methods of the class. == PREREQ's == o ActiveState's Python 2.1 release http://www.activestate.com/ASPN/Downloads/ActivePython/ o Tcl 8.1.0 + http://sf.net/projects/tcl http://www.activestate.com/ASPN/Downloads/ActiveTcl/ o [Incr Tcl] 3.1 + http://sf.net/projects/incrtcl == LICENSE == Simple BSD and don't sue me if it eats your CPU. The user of this software understands that it is provided without warrantee. You are free to derive more software based on this and there is no requirement for making your new work public, nor for refrencing this work. Although, it is a nice gesture of gratitude. -----BEGIN PGP SIGNATURE----- Version: PGPfreeware 7.0.3 for non-commercial use iQA/AwUBOy64UpWWnZEIf0ZhEQI5NgCgnvNC4X8tKmYtTXbIFscxt9HLn74AnjKT syT5EsAVQ0AW4XHygfjqC+Fp =Kf3j -----END PGP SIGNATURE----- From piet at cs.uu.nl Tue Jun 26 11:18:42 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 26 Jun 2001 17:18:42 +0200 Subject: 'with' statement in python ? References: <3b3875f1.110436929@news.tpi.pl> Message-ID: >>>>> macias at bp.com.pl (Maciej Pilichowski) (MP) writes: MP> On Mon, 25 Jun 2001 21:30:36 -0300, Carlos Ribeiro MP> wrote: MP> I have just started learning Python yesterday but... >> def with_is_broken(a): >> with a: >> print x >> >> The snippet above assume that "a" must have a member attribute called "x". MP> Nope. As you referred to Pascal -- if "a" has a member "x" it is read MP> as "a.x", if not it is standalone "x". Python, as it is now has three environments from which it identifies variables: 1. builtin 2. the current module (these 2 together are called global variables) 3. the function (these are called local variables, and in Python 2.1+ these can be nested). If `with' would be implemented there would be a fourth environment, namely the dict of the object given after `with'. It would probably slow down things if you also used local and/or global variables in the `with' block, on the other hand if you used only instance variables it could speed up things a little. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From James_Althoff at i2.com Thu Jun 7 13:50:34 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Thu, 7 Jun 2001 10:50:34 -0700 Subject: Why should i use python if i can use java Message-ID: Alex Martelli wrote: >Far better! Jython's total integration with Java's libraries is >astonishing. You don't need to 'wrap' anything, like you do >in CPython with a typical C library... just USE it -- any Java >library is right there, ready for your Jython use. I can't get >over the detail of how SMOOTHLY it works...!-) I agree completely. Using JPython/Jython we've developed (and released :-) ) a family of very sophisticated B2B applications -- comprising several hundred-thousands of lines of code -- that are in deployment at a number of very large companies with hundreds (ramping up to thousands) of end-users each. The UIs had to be built using the Java/Swing libraries; and Jython made it a breeze. Building Swing UI's using Jython is *much* better than doing it in Java! >Alex Jim From castor at snafu.de Wed Jun 6 19:35:50 2001 From: castor at snafu.de (Wolfgang Lipp) Date: Wed, 06 Jun 2001 23:35:50 GMT Subject: Windows editor? References: <3af2c38f.341431824@News.CIS.DFN.DE> Message-ID: <1103_991870550@ns.seowon.ac.kr> > > > > >What's a good Python editor for programming under Windows, specifically > > > > >Windows 2000? According to Google archives it seems this question try www.textpad.com -wolf From nperkins7 at home.com Fri Jun 15 18:50:35 2001 From: nperkins7 at home.com (Nick Perkins) Date: Fri, 15 Jun 2001 22:50:35 GMT Subject: PEP 255: Simple Generators References: Message-ID: <%iwW6.245075$eK2.51875868@news4.rdc1.on.home.com> ...yeild neat! simple, powerful, and easy to understand! This reminds me of 'contiuations', a la 'call/cc' in Scheme. ( a little harder to understand ) I understand that call/cc can be used to implement all kinds of control structures. Yeild sounds more like "set entry point to current continuation, and return" Could it be used to turn a partially-evaluated function into a first-class object? You could have a function that takes it's arguments, "yeilds" None, and then waits for it's next invocation to actually 'do the dirty work'. ...wait..can they take args?... What are the implications of generators resembling continuations, and what is the liklihood that generators will be used/misused/abused to implement tricky control structures? From chrishbarker at home.net Wed Jun 20 17:00:42 2001 From: chrishbarker at home.net (Chris Barker) Date: Wed, 20 Jun 2001 14:00:42 -0700 Subject: OOP in Python References: <4e2ddb70.0106200954.11faa218@posting.google.com> <9gqsku01cma@enews1.newsguy.com> Message-ID: <3B310EFA.B04C0C31@home.net> Alex Martelli wrote: > A class may have attributes (it's also possible to use a module > attribute, aka 'global variable', of course). Example: > > class Totalizer: > grand_total = 0 > def inc(self): > self.__class__.grand_total += 1 > def dec(self): > self.__class__.grand_total -= 1 > def __str__(self): > return "Total is %d"%self.__class__.grand_total Or make the class attribute a mutable type, and the syntax gets simpler: class Totalizer: grand_total = [0] def inc(self): self.grand_total[0] += 1 def dec(self): self.grand_total[0] -= 1 def __str__(self): return "Total is %d"%self.grand_total[0] # two separate instances one = Totalizer() two = Totalizer() # but they share state! Try: one.inc() two.inc() one.inc() two.inc() print one Nice trick, though, Alex, I hadn't yet discovered that one. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From aahz at panix.com Mon Jun 4 15:08:54 2001 From: aahz at panix.com (Aahz Maruch) Date: 4 Jun 2001 12:08:54 -0700 Subject: I NEED to TEACH you something, QUICK! References: <9fgiae$av0$3@newshost.accu.uu.nl> <9fglsi$ava$1@newshost.accu.uu.nl> Message-ID: <9fgmc6$ckd$1@panix3.panix.com> In article <9fglsi$ava$1 at newshost.accu.uu.nl>, Martijn Faassen wrote: >Martijn Faassen wrote: >> >> old computer displays, or whatever. It nips flamewars in the >> butt. > >'bud'. Sorry about that. Please don't flame me now. :) Why, you arrogant, sexist pig? Your mother wears army boots. Your father lives in a pigsty. You are a nincompoop. Oh, you wanted the argument clinic? I'm sorry, this is abuse. The argument clinic is down the hall, on your left. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 I surf faster than you do, monkey boy. (My take on Netscape vs. Lynx) From MarkH at ActiveState.com Wed Jun 6 20:44:01 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 07 Jun 2001 00:44:01 GMT Subject: How to change Pythonwin background colour? References: <3B1E8047.17E114FC@rhystucker.fsnet.co.uk> <3B1EBEF4.6080103@ActiveState.com> <3B1EC850.7655D790@rhystucker.fsnet.co.uk> Message-ID: <3B1ECE77.5050606@ActiveState.com> rhys wrote: > This is a real problem for me as I have a sensitivity to bright light. > I've downloaded the Pythonwin source - is it just a matter of finding > white_brush or something similar, changing it and recompiling? Open pywin.framework.interact Find the following function: def SetStyles(self): FormatterParent.SetStyles(self) Style = pywin.scintilla.formatter.Style You can add a 3rd param to the "Style()" function. This is an RGB value for the background. Eg: self.RegisterStyle( Style(STYLE_INTERACTIVE_EOL, STYLE_INTERACTIVE_PROMPT, 8421504 ) ) self.RegisterStyle( Style(STYLE_INTERACTIVE_PROMPT, formatInput, 8421504 ) ) etc - note the 3rd param I added - this is win32api.RGB(128,128,128), and gives a pretty horrible grey as the background color. Add it to all or any of the Style() calls you like. If you want to generalize this somehow so the value is read from the registry I would be happy to include if. I may even get around to adding it to the dialog so it can be specified. Mark. From mmartine at tc.fluke.com Tue Jun 19 12:47:16 2001 From: mmartine at tc.fluke.com (Mat Martineau) Date: Tue, 19 Jun 2001 09:47:16 -0700 Subject: Serial IO In-Reply-To: References: Message-ID: As far as I've seen, there are two ways to do serial communication in Python: * On win32 systems, use win32file. There's a demo of this (at least in the ActiveState distribution of Python 2.1) under Python21/win32/Demos/win32comport_demo.py * On Unix systems, you need to use termios. Fortunately, there's an example of how to do this, posted on this newsgroup last November: http://groups.google.com/groups?safe=off&rnum=5&ic=1&selm=t0VQ5.8786%24FU3.2195648%40ptah.visi.com Unfortunately, the stock 2.1 distribution on Linux is pretty much broken for serial communication - an important #include was commented out, so some necessary constants are unavailable. Both 2.0 and snapshots of 2.2 seem to have the constants included correctly. Hopefully, 2.1.1 will fix this issue. Also, the TERMIOS module is deprecated in Python 2.1 (constants were moved to termios), so the code linked above will need to be modified accordingly. Mat Martineau On Tue, 19 Jun 2001, Andrew Todd wrote: > Hey, > I was looking through python.org and I noticed there was a > serial io package for python, but it was for version 1.5. > Is there going to be a release for python 2.1 or 2.2? or is > the code compatible? Also, if anyone knows of any GPIB > modules please let me know. Thanks. > > -Andrew > > From mkent at atlantic.net Thu Jun 7 15:04:16 2001 From: mkent at atlantic.net (MikeK) Date: 7 Jun 2001 12:04:16 -0700 Subject: termios, Python 2.1 and 1.5.2, AIX and SCO Message-ID: Getting the 'termios' module to compile or work on various platforms is like trying to pass a bowling ball. We need to input no-echoing passwords, therefore the need for termios. Building Python 2.1 on aix-4.3-2.1, with termios turned on in Modules/Setup, results in undefined symbol errors for 'VDISCARD' and 'VWERASE'. Building Python 1.5.2 on the same platform, with termios turned on, works fine, and gives us non-echoing passwords via getpass. Building Python 1.5.2 on SCO Open Server 5, with termios turned on, yields echoing passwords. Hmm. Upon further investingation (browsing the getpass.py source code), we found that the configure script believes this platform to be sco_sv3, and that the necessary file Lib/plat_sco_sv3/TERMIOS.py was missing. Running the 'regen' script in that directory created TERMIOS.py, which allowed a build of python with termios turned on. However, when testing getpass, it would now generate a termios.error exception. From investigating this (debugging termios.c), we determined that a call to tcsetattr was returning an error code and setting errno to 22 (Invalid argument). We gave up at that point. Wasn't one of the selling points of Python the ability to write code that would run on multiple platforms? Does anyone have any suggestions on how we can overcome these problems, the desired result being non-echoing passwords done in a portable manner? From loredo at spacenet.tn.cornell.edu Wed Jun 6 19:14:11 2001 From: loredo at spacenet.tn.cornell.edu (Tom Loredo) Date: Wed, 06 Jun 2001 19:14:11 -0400 Subject: Segmentation fault from pxDislin Message-ID: <3B1EB943.4BDC68B5@spacenet.tn.cornell.edu> Hi folks- I use Python 2.1 on a Solaris box, and just installed Dislin and pxDislin. Dislin appears to work fine; I tried the examples in Eric Hagemann's O'Reilly article on it and they all work perfectly. But pxDislin doesn't work, not even the demos. There are no obvious problems (the commands execute silently) until one calls a plot's "show()" method. Then Python just dies due to a segmentation violation. This is the first time in my years of using Python that I've actually seen this happen! Is anyone using the current version of pxDislin successfully? Anyone have any clues what may be going on from their own experience? Thanks, Tom Loredo From BrianQ at ActiveState.com Tue Jun 12 15:13:40 2001 From: BrianQ at ActiveState.com (Brian Quinlan) Date: Tue, 12 Jun 2001 12:13:40 -0700 Subject: Python Shareware? In-Reply-To: Message-ID: <003501c0f373$ca655100$b503a8c0@activestate.ca> Will wrote: > So the notion that there is already a water-tight business model in > shareware is a delusion. I suspect anybody who has written shareware > for any length of time is dispelled of it. Where somebody is > sufficiently new at it to believe the delusion, they will invest lots > of energy looking for ways to "secure" their code. As was pointed out > in earlier responses, this is really futile if "pirates" are > sufficiently motivated. We are way off the beaten path here...but oh well. The guys at Ambrosia (www.ambrosiasw.com) have been successfully distributing shareware for years. And judging by the pictures of their president driving around in his hummer, they are doing ok. From skip at pobox.com Fri Jun 22 07:55:00 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 22 Jun 2001 06:55:00 -0500 Subject: How to display all the methods supported by an instance using dir( )..please hel In-Reply-To: References: Message-ID: <15155.12820.675919.325246@beluga.mojam.com> Karthik> t = test() Karthik> dir(t) Karthik> But it does'nt list func :-(. Dir is pretty straightforward. For objects that have a __dict__ attribute, it just lists the dictionary's keys. A class instance's methods are stored in the class's __dict__, so you could view them with dir(t.__class__) That will only get the methods defined in t.__class__, however. If it has base classes, you'd be better off using the inspect module: >>> class foo: ... def meth1(self, x): ... pass ... >>> class bar(foo): ... def meth2(self, y): ... pass ... >>> t = bar() >>> dir(t.__class__) ['__doc__', '__module__', 'meth2'] >>> import inspect >>> inspect.getmembers (t.__class__) [('__doc__', None), ('__module__', '__main__'), ('meth2', )] Good help for inspect is available online via pydoc: >>> import pydoc >>> pydoc.help(inspect) ... Cheers, -- Skip Montanaro (skip at pobox.com) (847)971-7098 From tim.one at home.com Sun Jun 10 00:50:50 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 10 Jun 2001 00:50:50 -0400 Subject: random In-Reply-To: <3b1bd138.873545372@news.okstate.edu> Message-ID: Sorry for having dropped out of this thread -- one interesting question leads to two, and simply ran out of time for it. Just dropping in long enough to reassure David on one point of pseudo contention: [Tim] >> (e.g., if the 0'th program happens to halt, that would imply >> the halting probability is >= 1/2 across all programs -- but the 0'th >> program isn't generally that smart ). [David C. Ullrich] > Nope - this sounds good but it's specious. With the distribution > I thought Chaitin was using it _would_ follow that Omega > 1/2 > if the 0-th program happened to halt, and with the distribution > he _does_ use things that are equally winkie-sounding _do_ > follow: Pick a program that does happen to halt. If that program > is K bits long then the fact that that particular program halts > _does_ show that Omega > 2^{-K}. That program happens to > be smart enough to imply that the halting probability is > larger than something - with a different distribution it would > just imply that the halting probability is larger than a different > thing. > > So I lied, but it's not as obvious as you say that my lie > _must_ have been wrong - as long as we're just talking > about "a random program" without specifying the distribution > what I said could have been right regardless of questions of how > smart the first program is. All agreed. I wasn't bothered that *a* program could "be that smart", but "the 0th" program specifically: it was pointing at the essential arbitrariness of a measure that depends on how you just happen to tag the machines with ordinals. "Interesting" results in this (and related) field are independent of labeling, so if Chaitin had come up with a result that wasn't so independent, this thread never would have started . >... > That's the best excuse I can contrive. Oh well. You don't need an excuse! I wasn't careful with definitions, and was too keen to keep this all at "fuzzy overview" level. So that's my excuse. > Thought I had the problem of inexact floating point solved. Python beat you to it: A real number is computable iff Python can compute it. Therefore you can enumerate the set of non-computable reals just by picking them from the gaps in the ones Python can compute . for-example-0.1-ly y'rs - tim From not.this at seebelow.org Thu Jun 28 09:25:59 2001 From: not.this at seebelow.org (Grant Griffin) Date: Thu, 28 Jun 2001 08:25:59 -0500 Subject: PEP 260: simplify xrange() References: <3B39480C.F4808C1F@Lugoj.Com> <9hc97q$rpt$1@slb6.atl.mindspring.net> <3B3A9C39.64C3E1C6@seebelow.org> <9hef08$urt$1@slb3.atl.mindspring.net> Message-ID: <3B3B3067.FC47217C@seebelow.org> Michael Hudson wrote: > > "Andrew Dalke" writes: > > > Grant Griffin: > > >BTW, among its many other technological advances, Goggle frees you from > > >having to put "+" in front of stuff. > > > > Huh. Showing my heritage of using altavista for a couple years. > > If I had read the top of the results page I would have seen > > > > ] Google always searches for pages containing all the words in your > > ] query, so you do not need to use + in front of words > > Google confuses me; if you search for "michael hudson" my page is the > third hit - but my name doesn't actually appear anywhere on the linked > page! > > The "did you mean to search for ..." feature is also downright > uncanny. > > They've clearly sold their souls to the devil - there's no other > explanation. Yes! Finally, that explains how they're able to finance the thing without selling banner ads . Actually, there's a very interesting page somewhere on the net that explains how Google works (at least the way it worked at the time the college students who invented it had to write a paper about it.) Among many other clever tricks, they use the text of links _into_ your page as a high-valued description of your page. (The concept here is that these link provide a better, more concise description of a page than the page itself provides--which seems to be true in your case .) According to this theory, there's a link out there into your page that has "Michael Hudson" in it somewhere. (people-who-search-on-their-own-names-deserve-whatever-they-get) --ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From bos at hack.org Mon Jun 18 03:12:36 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Mon, 18 Jun 2001 09:12:36 +0200 Subject: graceful version detection? References: <3B2D2F44.50007@red-bean.com> <3B2D5F78.B581DFF1@home.com> Message-ID: <3B2DA9E4.1BF323A1@hack.org> Don O'Donnell wrote: > But, sys.version_info (new in ver 2.0) is a tuple which makes it ... > or > if sys.version_info < (1, 5, 2): These two lines dont mix. If you run that on 1.5.2 it won't work well. -- Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From skip at pobox.com Fri Jun 22 16:45:55 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 22 Jun 2001 15:45:55 -0500 Subject: How to reload a module in embedded C In-Reply-To: <15155.36696.11013.623900@beluga.mojam.com> References: <15155.36696.11013.623900@beluga.mojam.com> Message-ID: <15155.44675.180333.111357@beluga.mojam.com> Emmanuel> I would like to reload a module, AND the module that are used Emmanuel> in this module. me> Are you trying to reload an extension module written in C? I don't me> think that's supported. In any case, even if your Camera module is me> written in C, reloading it won't recursively reload the modules it Should have been "... written in Python ...". Sorry for the bad proofing. S From mwh at python.net Thu Jun 21 18:23:41 2001 From: mwh at python.net (Michael Hudson) Date: 21 Jun 2001 23:23:41 +0100 Subject: locking dictionaries (was Re: New statement proposal for Python) References: <9gl1rg$p45$1@panix2.panix.com> <3B30203F.B158D356@my.signature> Message-ID: Greg Ewing writes: > Hmmm... wild thought: after type/class healing, > every object will have a __class__ attribute... > if it were changeable... > > d = {'spam':42} > d.__class__ = MyLockedDictClass > > No, probably far too dangerous... > > x = [] > x.__class__ = 3.__class__ > print x > > <<>> On descr-branch: >>> [].__class__ >>> [].__class__ = type(2) Traceback (most recent call last): File "", line 1, in ? TypeError: readonly attribute Assigning to (3).__class__ or "a".__class__ would actually be much more insidious... Cheers, M. -- This makes it possible to pass complex object hierarchies to a C coder who thinks computer science has made no worthwhile advancements since the invention of the pointer. -- Gordon McMillan, 30 Jul 1998 From whisper at oz.nospamnet Sat Jun 16 00:18:25 2001 From: whisper at oz.nospamnet (David LeBlanc) Date: 16 Jun 2001 04:18:25 GMT Subject: PEP 259: Revise to remove context-driven magic from print References: <486de2.0106131406.5c0cbef9@posting.google.com> <9gamor$8ft$6@216.39.170.247> <7r8W6.5407$G4.842350@newsc.telia.net> Message-ID: <9gemmh$324$4@216.39.170.247> In article <7r8W6.5407$G4.842350 at newsc.telia.net>, fredrik at pythonware.com says... > David LeBlanc wrote: > > I don't see why you consider this a joke, nor do I see the > > ignorance and arrogance which you seem to. > > you forgot to mention how many years you've been > programming. > > > > > Nor did I say "Larry said..." but then i've had to go out and shoot myself. Possibly you would prefer that :-) Regards, Dave LeBlanc From jkraska1 at san.rr.com Wed Jun 27 00:06:22 2001 From: jkraska1 at san.rr.com (Courageous) Date: Wed, 27 Jun 2001 04:06:22 GMT Subject: Pythoin MUD (PyMUD?) References: <9gqq3t$hvs$1@brokaw.wa.com> <3B36D220.52C5CB86@cosc.canterbury.ac.nz> <3B395490.89B5AA18@cosc.canterbury.ac.nz> Message-ID: >> It's peudo-preemption, really. Time spent in external modules >> and the like is not preempted, so unexpected behaviors can >> arise. > >Presumably wizards won't be allowed to call code >in arbitrary extension modules, so it shouldn't >be too much of a problem in this case. It's no problem at all, unless your expectations are awry. People sometimes expect "preemptively scheduled threads" to behave as OS-native preemptively scheduled threads. These aren't. And don't. This isn't a complaint or a criticism... just an observation. :-) C// From cribeiro at mail.inet.com.br Sat Jun 30 13:47:19 2001 From: cribeiro at mail.inet.com.br (Carlos Ribeiro) Date: Sat, 30 Jun 2001 14:47:19 -0300 Subject: Augmented Assignement (was: Re: PEP scepticism) In-Reply-To: References: Message-ID: <5.0.2.1.0.20010630140643.02bd8080@mail.inet.com.br> As the current discussion about Augmented Assignment stands, I was wondering if it was not better to make it invalid to use augmented assignment on immutable types. After all it does not make much sense. If the value is immutable, what sense does it make to have it modified inplace? The funny thing is that inplace addition is a nice way to express string concatenation, which is a immutable object... But it inconsistent and misleading ("what are saying? the object is immutable, but you can change it? is it immutable or not?"). Anyway, as it stands, that is little chance to make any change. The current behavior is already established, and any change can break existing code. Better pick another fight. Carlos Ribeiro From James_Althoff at i2.com Mon Jun 18 16:59:43 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Mon, 18 Jun 2001 13:59:43 -0700 Subject: why is there no class (static) methods in Python ? Message-ID: D-Man wrote: >On Mon, Jun 18, 2001 at 12:21:53PM -0700, James_Althoff at i2.com wrote: ><...> >| I notice that yourModule.yourFunction1 >| is exactly what I want, but I need to override yourModule.yourFunction2 in >| order to adapt it for myModule.MyClass. How can I do this (preferably >| WITHOUT resorting to "black magic" and whilst preserving >| "thread-safeness")? > >#### myModule.py > >import yourModule > >myFunction1 = yourModule.yourFunction1 > >def myFunction2( ) : > pass Except that this doesn't work (which is the whole point! :-) ). #### module testcm1 def function1(): function2() def function2(): print 'testcm1.function2' #### module testcm2 import testcm1 function1 = testcm1.function1 def function2( ) : print 'testcm2.function2' #### test run C:\>python Python 2.0b1 (#4, Sep 7 2000, 02:40:55) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> import testcm1 >>> import testcm2 >>> testcm1.function1() testcm1.function2 >>> testcm2.function1() testcm1.function2 >>> In both cases the "original" function2 is being called and the "new" function2 is never invoked. This is because "function1 = testcm1.function1" is just creating a new variable that points to the origina function. It doesn't change the implementation of that function in any way. > >| I am stuck -- because module functions are NOT methods (in the sense that >| they are not associated with an instance) and hence do not participate in a >| "method lookup/override" mechanism. So if I define my own > >As Alex Martelli has demonstrated a few times, you can substitute a >class instance that implements __setattr__ and __getattr__ in place of >the module object in sys.modules. How would such an approach work with "import", "from", "__import__", etc.? Is it really viable to try to create a class whose instances "fake" module objects? And use this as the standard idiom for modules? > >| So true class methods -- methods invoked on class objects with inheritance >| and override (a la Smalltalk) -- are good -- and far better than module >| functions acting as a poor man's substitute therein -- mainly if you >| consider code extensibility and reuse a good thing. > >Maybe the new meta class stuff will help with this? (I don't know) My own metaclass experiments and posts have all tried to provide a mechanism for true class methods. But all metaclass mechanisms in Python that I'm familiar with are awkward, IMHO -- and probably don't and won't get used much (if at all). As far as the class/type healing work that is underway: I hope class methods will be a part of it. But so far the messages from Guido that I've seen indicate that though the class/type healing is a high priority, true class methods as a part of said healing are not necessarily important (to him). So I'm not optimistic. > >-D Jim From db3l at fitlinxx.com Tue Jun 12 19:26:16 2001 From: db3l at fitlinxx.com (David Bolen) Date: 12 Jun 2001 19:26:16 -0400 Subject: Plugins in Python References: <9g5hvq$ird$2@216.39.170.247> Message-ID: David LeBlanc writes: > How would one generally code something that would look at some dir (or > list of dirs), and dynamically load .py or .pyc modules found there that > where not previously known to the program. Obviously following a standard > API... I tend to make plugins for an application a package. One approach is that the __init__ file in the package can inspect the package directory for other modules, and then use __import__ to import them. I normally then populate a well-known dictionary within the __init__ module that applications can use to determine what plugins were loaded. You can also decide to set up the modules for lazy loading using a proxy class if you want to avoid the overhead of actually importing the plugin until needed. Note that one major negative with this approach is that it confuses Python installation tools like py2exe and installer, as they can't follow the dynamic importing, and also because the directory structure may not be similar during execution. So in the cases that I need to package things, I instead write my __init__ such that it contains explicit imports for supported plugins, but nothing more. Then instead of looping through the filesystem, I loop through my local dictionary looking for modules, and then import them (or call well defined entry points in them to let them identify what they support). This does mean they all get imported, but it works regardless of directory structure, and can be packaged. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From nperkins7 at home.com Tue Jun 5 13:55:48 2001 From: nperkins7 at home.com (Nick Perkins) Date: Tue, 05 Jun 2001 17:55:48 GMT Subject: How to put a scrollbar to a frame? References: <9fip1t$5js$1@bcarh8ab.ca.nortel.com> Message-ID: I use the Tkinter Text widget for simple (often debugging) messages: class whatever.... init.. self.text = Text(self) self.text.pack() def say(self,message): self.text.insert(END,message) self.text.see(END) ..It does not have a scrollbar, but automatically scrolls up when messages reach the bottom. .. you can also call text.clear() from time to time "JAY" wrote in message news:9fip1t$5js$1 at bcarh8ab.ca.nortel.com... > Hi there, > > I am pretty new to python. My python script makes a frame in a widget to > display some messages (UNIX system), > it works fine. However, if the message gets too long, the frame will be > extended and make the whole widget bigger > than screen. > > To solve the problem, I want to put a scrollbar to the frame for the > messages so that it's size won't change. But I don't > know how. Could anybody tell me how to do it? > > Thank you in advance, > > JAY > > From wayne.izatt at _nospam_myself.com Thu Jun 7 23:52:37 2001 From: wayne.izatt at _nospam_myself.com (Wayne Izatt) Date: Fri, 08 Jun 2001 03:52:37 GMT Subject: Threading conceptual question References: Message-ID: <9_XT6.40215$cF.1637654@news1.crdva1.bc.home.com> > Is this the sort of thing that is solvable with threads? and maybe more > specifically with win32process.beginthreadex()? also will i need to > recompile python (please say no)? This is what threads are for, and no, you won't need to rebuild Python. > also, i am about to buy a new server, so the question is, do i want/need > more than one processor to do this sort of thing? One processor is good enough for all but the most computationally intensive operations. Instead of reinventing the wheel, however, take a peek at Webkit. It contains a threaded http server that can easily be fitted to most tasks. cheers From dsh8290 at rit.edu Fri Jun 1 11:17:19 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 1 Jun 2001 11:17:19 -0400 Subject: Python + threads + wxWindows = segfault, help! In-Reply-To: ; from gtcopeland@earthlink.net on Thu, May 31, 2001 at 09:53:16PM -0500 References: Message-ID: <20010601111719.A7478@harmony.cs.rit.edu> On Thu, May 31, 2001 at 09:53:16PM -0500, Greg Copeland wrote: | | I'm working on a project that has a multithreaded wxPython | application. I working on an SMP box. Can anyone tell me | what might be causing this to happen? | | Fatal Python error: ceval: orphan tstate I don't know, but wxWindows might not be thread-safe. I don't yet know of a GUI toolkit that is. (GTK+, Swing, and Tkinter aren't) My suggestion is to create a thread that is dedicated to interfacing with the GUI. All other threads should then send callable objects to that thread and request that they are executed a la javax.swing.SwingUtilities.invokeLater() in Swing. HTH, -D From m.faassen at vet.uu.nl Thu Jun 14 18:46:52 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 14 Jun 2001 22:46:52 GMT Subject: PEP 259: Revise to remove context-driven magic from print References: <486de2.0106131406.5c0cbef9@posting.google.com> <9gamor$8ft$6@216.39.170.247> Message-ID: <9gbess$gla$3@newshost.accu.uu.nl> David LeBlanc wrote: [effbot negative response] > I don't see why you consider this a joke, nor do I see the > ignorance and arrogance which you seem to. I think it's kind of > unfortunate that an influential person in the python world, such as > yourself, would swat down someone's idea without even saying why! Quite a > way to discourage people from having new ideas whether right or wrong. > Well, Fredrik did quote some relevant bits from the original proposal that he considered arrogant. It's just the way the effbot works; a Perl regex is sometimes clogging up its neural net. See here for more information on the effbot: http://www.twistedmatrix.com/users/jh.twistd/python/moin.cgi/PythonRolePlayingGame No offense to anyone; some additional consideration on all sides might've helped, but then again everyone's inconsiderate at times, and a strong reply isn't always awful. I wasn't nice to Guido a few posts back, myself. Sorry Guido. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From mac4-devnull at theory.org Sun Jun 24 13:34:37 2001 From: mac4-devnull at theory.org (Neil Macneale) Date: Sun, 24 Jun 2001 10:34:37 -0700 Subject: return number limit? Message-ID: <3b3624aa$0$327$8eec23a@newsreader.tycho.net> I have a function that makes use of several nested if's. In addition, several of the cases have returns, and properies are assumed if certain code is reached as a result. This all seems reasonable to me, and runs just fine. pychecker is telling me that I have too many returns (11). Is there such a limit set in python? Thanks, Neil Macneale -- To reply to me via email, remove the '-devnull' from my address. From VesselinPeev at operamail.com Wed Jun 13 09:39:08 2001 From: VesselinPeev at operamail.com (Vesselin Iliev Peev) Date: Wed, 13 Jun 2001 09:39:08 -0400 Subject: Problem with Python 2.0 demo Message-ID: <3C1CD5A4@operamail.com> Dear Sirs, I had a problem compiling the example from the Python 2.0 source package \demo\embed\demo.c (linking it to python20.lib) from the binary distribution of Python. I get the following: [Linker Error] Unresolved external '_Py_InitModule4TraceRefs' referenced from DEMO.OBJ What could be the reason and a possible solution? I have not modified the source code of the demo or Python. Thank you in advance for your consideration. From phrxy at csv.warwick.ac.uk Fri Jun 29 15:29:43 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Fri, 29 Jun 2001 20:29:43 +0100 Subject: noncommercial Python+QT on Windows? (was Re: qt or gtk?) In-Reply-To: <9hfjho05to@enews1.newsguy.com> References: <9gk8he$8gl$1@brokaw.wa.com> <16074dce.0106181045.139d80a5@posting.google.com> <3b3b40a0@news.uia.ac.be> <9hfjho05to@enews1.newsguy.com> Message-ID: On Thu, 28 Jun 2001, Alex Martelli wrote: > wrote in message news:3b3b40a0 at news.uia.ac.be... > ... > > The licensing for non-commercial applications for Qt/Win32 was changed > > very recently. Have a look here : > > http://www.trolltech.com/company/announce/noncommercial.html > > Very interesting -- NOW, is there a way one can develop Python > software, cross-platform, using Qt, and redistribute it: legally, > for free and with sources? Yes, you can -- But. The license is a bit odd. Snippet below is from Trolltech's FAQ on the subject, at http://www.trolltech.com/developer/faq/noncomm.html ----- Can I make software with the Qt Non Commercial Edition and release it under the GPL, BSD, or Artistic license? BSD and Artistic shouldn't be a problem. GPL however is. One of the key features of the GPL license is that it does not permit the distribution of software linked to non-system libraries that are distributed under different licensing terms. The README in the Non-Commercial download explains this thoroughly. Can I use the Non-Commercial Edition at work for running this Qt-based application I just downloaded? Yes, if the application was legally developed with Qt. Using the Non-Commercial Edition, can I make software for internal use in my company/organization? No. As long as you are on the payroll of the company/organization or are compensated otherwise, this is not a non-commercial setting. You need to buy a Qt Professional or Enterprise Edition license for this. ----- So, you can make software for other people to use in their work, and you can use other people's Qt software in your own work, but you're not allowed to use your own software in your own work (unless you buy the commercial license, of course). So, if you're happy with that, you can develop and release free (beer: yes; speech: ish) software. I guess that according to the letter of the license (but IANAL), and possibly the spirit also, you can develop free software that you then happen to go on to use in a commercial setting, but only if you cross your heart and swear that that wasn't your original intention. Whether your company is happy to take the risk of being prosecuted is, of course, another matter. In fact, the license itself is so short I may as well post it here: > Qt Non Commercial license version 1.0 > > Copyright (C) 2001 - Trolltech AS, Norway. Everyone is permitted to > copy and distribute this license document. > > This license applies to any software containing a notice placed by > the copyright holder saying that it may be distributed under the > terms of the Qt Non Commercial License version 1.0. Such software is > herein referred to as the Software. This license covers distribution > of the Software, use of third-party application programs based on > the Software, and non-commercial development of free software, which > uses the Software. > > Granted Rights > 1.You are granted the non-exclusive rights set forth in this > license provided you agree to and comply with any and all > conditions in this license. Whole or partial distribution of > the Software, or software items that link with the Software, in > any form signifies acceptance of this license. > 2.You may copy and distribute the Software in unmodified form > provided that the entire package, including - but not > restricted to - copyright, trademark notices and disclaimers, > as released by the initial developer of the Software, is > distributed. > 3.You may use the original versions of the Software to compile, > link and run application programs legally developed by you or > by others. However, if an application program gives you access > to functionality of the Software for development of application > programs, reusable components or other software components > (e.g. an application that is a scripting wrapper), usage of the > application program is considered to be usage of the Software > and is thus bound by this license. > 4.You are as an individual granted a personal, non-exclusive > non-transferable license, in a non-commercial setting, to > develop application programs, reusable components and other > software items that link with or in any other way require the > Software. These items, when distributed, are subject to the > following requirements: > a.They must be distributed for free and/or be freely > downloadable. > b.You must ensure that all recipients of machine-executable > forms of these items are also able to receive and use the > complete machine-readable source code to the items without > any charge beyond the costs of data transfer. > c.You must explicitly license all recipients of your items to > use and re-distribute original and modified versions of > the items in both machine-executable and source code > forms. The recipients must be able to do so without any > charges whatsoever, and they must be able to re-distribute > to anyone they choose. > > Limitations of Liability > In no event shall the initial developers or copyright holders be > liable for any damages whatsoever, including - but not restricted to > - lost revenue or profits or other direct, indirect, special, > incidental or consequential damages, even if they have been advised > of the possibility of such damages, except to the extent invariable > law, if any, provides otherwise. > > Warranty disclaimer > The Software and this license document are provided "AS IS" with NO > WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, > MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND > NON-INFRINGEMENT WITH REGARD TO THE SOFTWARE. > > Choice of Law > This license is governed by the Laws of Norway. Disputes shall be > settled by Oslo City Court. John From scohen at xybion.com Fri Jun 29 16:35:45 2001 From: scohen at xybion.com (Stephen D. Cohen) Date: 29 Jun 2001 13:35:45 -0700 Subject: Memory Leak? Considering Tcl/Tk Instead... Message-ID: Gang, I hope someone can help, as I am at a loss. I have a Python program that is the front end for a realtime system. The realtime code sends data to the front panel in the form of Python statements which are executed in a handler by use of the eval statement. The handler looks like this: def fifoHandler (): fifo = open("/dev/rtf42"); instr = fifo.readling() while 1 != 2: instr = fifo.readling() eval(instr) The handler is installed with code that looks like this: root = Tk() hist_data = {} hist_data['avg_delay'] = StringVar() Then hist_data['avg_delay'] is used as a textvariable for a Tk Label item. The realtime code then sends commands up the fifo to set the value of hist_data['avg_delay']. Specifically, an example command might look like: hist_data['avg_delay'].set('11264') The problem that I am having is that the python process seems to grow in size continuously until the machine runs out of resources. I am at a loss to explain what of the above should cause a continous growth in memory usage. Is this a well known memory leak in either Tk or the eval function? Does anybody have any suggestions? I am a long time Tcl/Tk user considering using Python for a new project. I would love to have access to Python's object oriented features and vast library, but if this is the sort of quality I can expect, I'll stick with Tcl - thank you very much. Regards, Steve From pedroni at inf.ethz.ch Wed Jun 13 15:26:24 2001 From: pedroni at inf.ethz.ch (Samuele Pedroni) Date: Wed, 13 Jun 2001 21:26:24 +0200 Subject: Inner classes References: <3b27a1aa.6747983@news.laplaza.org> <3dae3cfcl4.fsf@ute.cnri.reston.va.us> Message-ID: <3B27BE5F.4DCB4894@inf.ethz.ch> Andrew Kuchling wrote: > xyzmats at laplaza.org (Mats Wichmann) writes: > > Nonetheless, I was challenged by someone to describe how it isn't a > > shorcoming in Python that classes don't work this way and didn't > > convince the guy so I'm looking for a more erudite comparison. > > Work *what* way? It's perfectly legal to do this: > > class C: > class inner: > ... stuff for inner class > ... stuff for class C > > --amk Yes, but that's basically a static inner class, you can do C().inner() but the created inner instance will not contain any implicitly created reference to the C instance. To have that you must be explicit: c=C() i=C.inner(c) OTOH python has 1st class functions and most of time with lambdas, bounded method, etc you can achieve the same (even in a less verbose way). Jython design supports and jython coding practice shows that. regards. From boud at rempt.xs4all.nl Sat Jun 23 09:17:46 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 23 Jun 2001 13:17:46 GMT Subject: emacs speedbar for python mode? References: Message-ID: <9h24tq$f7b$1@news1.xs4all.nl> Amardeep Singh wrote: > try M-x speedbar Wonderful! Is there perhaps also a way to automatically open the speedbar? -- Boudewijn Rempt | http://www.valdyas.org From billw at witherspoon-design.com Sun Jun 3 14:41:28 2001 From: billw at witherspoon-design.com (Bill Witherspoon) Date: Sun, 3 Jun 2001 14:41:28 -0400 Subject: Dynamically making lists? References: <000901c0ec5a$dac96f60$fd00a8c0@bill1> Message-ID: <000f01c0ec5c$d0bdf430$fd00a8c0@bill1> Sorry folks, disregard. Use slices, duh. ----- Original Message ----- From: "Bill Witherspoon" To: Sent: Sunday, June 03, 2001 2:27 PM Subject: Dynamically making lists? > Hi all, > > If I have a list -> > > L = ['one', 'two', 'three',......,'one thousand'] > > and I want to split this into several lists with (say) two elements > each -> > > m = ['one', 'two'] > n = ['three', 'four'] > o = ['five', 'six'} > ...... > zz = ['nine hundred ninety nine', 'one thousand'] > > How would I do this? I don't know how many elements are in L before > I run the program. > > It seems like I have to generate variable names on the fly? > Maybe there's something simple I'm missing here. > > Any pointers would be appreciated. > > TIA, > Bill. > > > -- > http://mail.python.org/mailman/listinfo/python-list From phawkins at connact.com Mon Jun 25 12:10:41 2001 From: phawkins at connact.com (phawkins at connact.com) Date: 25 Jun 2001 12:10:41 -0400 Subject: OOP design question References: Message-ID: >>>>> "MW" == Michal Wallace writes: MW> I could be wrong, but I think the your situation is better solved MW> using composition (one object using/owning another) rather than MW> inheritance. I've always found the "is-a" and "has-a" descriptions a good way to distinguish this. Given two objects A and B, when considering whether A ought to be a parent of B, or whether A ought to contain B, ask yourself: is B an A? or does A have a B? -- Patricia Patricia J. Hawkins Hawkins Internet Applications, LLC From maxm at normik.dk Thu Jun 14 05:24:02 2001 From: maxm at normik.dk (=?iso-8859-1?Q?Max_M=F8ller_Rasmussen?=) Date: Thu, 14 Jun 2001 11:24:02 +0200 Subject: design patterns in python Message-ID: <7BD10B680501D411B9DF009027E06F32197D55@exchange> > From: raskol [mailto:raskol at hushmail.com] > Being interested in looking at (and understanding) design > patterns [GOF] in > python... and having gone through the obligatory google > searches etc.. I am > still somewhat frustrated by the lack of currently available > information > relating to this specific subject. I mean there ARE some > smatterings of > implementation and insight, but as of now there is no single > source for > python patterns that has developed anything like authoritative mass or > actually succeeded in 'comprehensively' covering the patterns > in GOF book. Well ... just don't worry about it. As Python grows the design patterns that you will have to code by hand in other lower level languages will get built into Pythons syntax. As I see it Python is an implementation of design patterns in a language. regards Max M From sill at optonline.net Wed Jun 13 18:54:15 2001 From: sill at optonline.net (Rainy) Date: Wed, 13 Jun 2001 22:54:15 GMT Subject: VI References: Message-ID: On Wed, 13 Jun 2001 11:28:55 GMT, Pilgrim wrote: > Can someone tell me what "vi" is for a text editor to work with python? > Where can I get this? > > Here's the idea, in a nutshell: In most other text editors, if you want to use some advanced command, you have function keys (F1-F12), you have numpad, you have a bunch of keys like insert/home/end... and, most importantly, you have ctrl and alt keys. So, in Emacs for instance, to go to the next line you may use cursor key (the downside is that it takes your hands from the homerow) OR, preferably, ctrl-n (if I remember right). Other well known mappings are ctrl-f to find something and End key to go the the end of file, etc. So far we haven't mentioned vi. There is one problem with the above approach that it ventures to fix: the problem is that all these mappings are either taking you off the homerow (which is bad because for a touch-typist that is quite a slowdown) OR if you use alt- and ctrl- mappings, you simply don't have that many of them (considering also that your window manager will often use some of them for window management). Here's how vi fixes that: you get a new mode where you can use all keys a-z and A-Z for advanced commands and custom mappings. For example, if you want to cut 3 lines, you hit 3dd, to paste them you hit p and so on - hundreds of commands. But, of course, vi has to be able to tell whether you want 3dd to appear in you text file or whether you want to cut 3 lines - I'm using vim (a newer more flexible clone of vi) and when I typed 3dd just now, they had to appear in this post. That's why vi(m) has an extra mode for commands, when I want it to take commands, I hit key and use all the commands I need, then navigate to the next place where I want text to be inserted and hit 'i' which is a command to enter 'insert' mode, the mode that works almost exactly like any other editor. There is a tradeoff here - normal editors are very easy to learn but not as powerful, while vi(m) is harder to learn but also adds some powerful tricks to your warchest once you do. If you type a lot (especially code), trying vi may be extremely useful in the long run. There's also an old and unsettled (and perhaps unsettable) argument of vi vs. emacs - emacs is also a very advanced and powerful editor that uses series of mappings like C-x C-c instead of having another mode for commands. It's probably more a matter of taste than anything else - some people can't stand modal interface at all. Here's a short comparison list: emacs - written in elisp, fairly large(28.1mb uncompressed debian package), uses lisp as scripting language, includes many additional functionality like news reading, web browser, mail client, etc etc vim - written in c, lightweight(700kb), uses custom macro language, can use python as scripting languages, does not include any extra functionality but can be 'plugged in' by external programs, for instance I use slrn for news and mutt for mail, and both of them can be set up to use vim for editing text My advice is to try both and see which you like most. -- Lime and limpid green a second scene A fight between the blue you once knew - Syd From tim.one at home.com Sun Jun 3 21:23:00 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 3 Jun 2001 21:23:00 -0400 Subject: Why isn't Python king of the hill? In-Reply-To: Message-ID: [Nick Perkins] > >>> from math import * > >>> sqrt(2)**2 > 2.0000000000000004 > >>> sin(pi) > 1.2246063538223773e-016 > > Neither of these 'errors' would be eliminated by using Rationals. > I am sure there are many similar examples. > > note that: > >>> cos(pi) > -1.0 > actually works, for some reason (luck?) Floats aren't random -- so luck isn't *really* an issue. What is an issue is that the mathematical PI isn't exactly representable as a float (and binary vs decimal has nothing to do with *this* one), so the machine pi is really some other number, pi = PI + tiny where "tiny" is an error in the last bit (or so) introduced by finite precision. Using angle sum formulas, sin(pi) = sin(PI+tiny) = cos(tiny)*sin(PI) + sin(tiny)*cos(PI) = cos(tiny)*0 + sin(tiny)*(-1) = -sin(tiny) = [expanding] -tiny - tiny**3/6 - ... tiny**3/6 is too small to have any effect when added to tiny (finite precision again), so the result you see is plain old -tiny. If you got 0 instead, it would be wrong! If you carry on the example, >>> math.sin(math.pi) 1.2246063538223773e-016 >>> math.log(_)/math.log(2) -52.858531444606918 >>> you can see the result is about 2**-52, right where "it should be" for a low-bit error in PI given that floats have 53 bits of precision. For the other one, cos(pi) = cos(PI+tiny) = cos(PI)*cos(tiny) - sin(PI)*sin(tiny) = (-1)*cos(tiny) - 0*sin(tiny) = -cos(tiny) = [expanding] -1 - tiny**2/2 - ... Since tiny is about 2**-52, tiny**2/2 is about 2**-105, and that's too small to have any effect when added to the 53-bit value of -1.0. So -1.0 on the nose is what you get. Of course sin() and cos() aren't actually *implemented* like that, but a careful implementation will deliver the same result in the end. From aleaxit at yahoo.com Thu Jun 14 10:53:14 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 14 Jun 2001 16:53:14 +0200 Subject: Telling python where to look for a script References: <3B285BFD.D2AC7E26@rk-speed-rugby.dk> <9ga20f02hsk@enews1.newsguy.com> <3B289D8E.96908690@rk-speed-rugby.dk> Message-ID: <9gaj4s06mn@enews1.newsguy.com> "Brian Elmegaard" wrote in message news:3B289D8E.96908690 at rk-speed-rugby.dk... > > > Alex Martelli wrote: > > > > the backslashes:-). A module is meant to be imported. > > A foo.py file can be both, but adapting the path is > > relevant to module-use only, NOT to script-use. All > > clear so far...? > > > No, I'm sorry. Ah, good. > Being in c:\foo I would like to be able to execute bar.py on baz.dat > being in . just by typing: > > c:\foo>python bar.py baz.dat > > Then I need something path-related with scripts, don't I? I think you need to build python.exe to work differently than it does today. I don't believe any amount of black magic in site.py or sitecustomize.py (etc) would convince python.exe to "search" for its bar.py argument elsewhere than in the current directory. Such an alternate python.exe (it had better be named differently I guess) might have value, but we don't have one today. I think the reason this is not perceived to be a problem is that people who work on operating systems don't do it that way. They write, e.g. $ bar.py baz.dat and their OS searches for executable bar.py in the PATH. This works on all Unix variants, and on NT/2000 as well if you tell CMD.EXE that .py is one of the extensions that make a file executable (sorry, I forget the incantation for the latter purpose:-). It *doesn't* work on 95/98/&c, but then I DID say "operating systems"...:-). Alex From xyzmats at laplaza.org Wed Jun 13 22:19:43 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Thu, 14 Jun 2001 02:19:43 GMT Subject: Python grammar.. References: Message-ID: <3b281e48.38650376@news.laplaza.org> On Thu, 14 Jun 2001 10:05:21 +1000, "Delaney, Timothy" wrote: >> "Delaney, Timothy" wrote in message >> news:mailman.992393599.3573.python-list at python.org... >> ... >> > way to do it - a subroutine may or may not return a value, at its >> > discretion, and I should be able to ignore any returned value. >> >> Yes, but if I were designing a language today, I think I would >> request you to be EXPLICIT about "ignoring the return value" -- >> explicit is better than implicit. It IS an occasional cause of >> errors in Python (particularly with newbies) that an expression >> statement's value is silently and implicitly ignored... >> >> >> Alex > >So you would prefer that functions whose return value is ignored must > be called with a keyword ... such as in VB > > call aFunction() > >Personally, I absolutely hate this. Seems like you could do it the other way around...add a bit of something to the function def to say "this is a procedure". Should you actually want to do such a thing... (it may be the path to the dark side, a la "static final private void deranged lunatic spam()" ...) From barry at digicool.com Fri Jun 29 00:26:14 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Fri, 29 Jun 2001 00:26:14 -0400 Subject: PEP scepticism References: <9hfg1n$du33c$1@ID-89274.news.dfncis.de> <3B3BB077.1E51F2C9@ActiveState.com> Message-ID: <15164.870.643998.135074@anthem.wooz.org> >>>>> "PP" == Paul Prescod writes: PP> It annoys me when people equate the PEP process with the PP> adding of features. Features were added before there was a PEP PP> process. Features have been added with out a PEP even since PP> the process existed. The PEP process also handles things like PP> library upgrades and distutils improvements. If you think PP> Python is changing to quickly, that's fine. But what does it PP> have to do with PEPs? The other purpose for PEPs -- IMO more important and often overlooked -- is to provide a concrete historical record for decisions made about the language, its implementations, and its environments. Python's been around a long time, and as Tim is fond of saying, there are almost no new feature suggestions that haven't been brought up many times before. The PEP is now the place which records the decision making process and in that, it serves a very useful function, even (and it some cases more) for when the idea is rejected as when it's accepted. That's quite apart from how the PEP process has influenced the pace of changes to Python. My own personal opinion is that the pace hasn't really changed much over time. What /has/ changed is the size and scope of Python's user base, and the relatively smaller advancement in elegance or power that current changes make, compared to what you can already do in the language. That's not to say that Andrew doesn't make a very important point. In one concrete example though, I know that with my own attempt at improving Python's MIME offerings, I've found that features like extended print have definitely helped the elegance of the library. If I was willing to target Python 2.2 then iterators and generators would as well (I think ;). I have a nagging feeling that `creeping featurism' is like pork-barrel politics. In one breath people will decry the special interests that they don't like or don't care about, while in the next, ask for their own pet project to be funded. It was quite funny to see the same effect at work at IPC9. Lots of hands went up when Guido took a poll on whether the pace of change was too fast. But as the session continued, there were certainly no shortages of new features suggested! -Barry From ykingma at accessforall.nl Tue Jun 12 15:47:06 2001 From: ykingma at accessforall.nl (Ype Kingma) Date: Tue, 12 Jun 2001 20:47:06 +0100 Subject: substitute for c/java's ?: References: <9g5fc4$m8u$01$1@news.t-online.com> Message-ID: <3B2671AF.B226FC54@accessforall.nl> Jochen Riekhof wrote: > > Hi... > > as a newcomer to python (like it a lot!) I found almost everything great > except two things: > 1. (most important) > I am missing something like the c/Java ?: operator. This is so convenient in > many places and saves a lot of typing. > It works like > result = option ? value1 : value2; > which is equivalent to > if option: > result = value1 > else: > resultl = value2 > > Is there anything I overlooked? > You can play tricks with the 'and' and 'or' operators in python. I looked into this briefly and then found these tricks so ugly that I prefer to avoid these operators outside pure boolean expressions. Instead I usually write: if option: result = value1 else: result = value2 just dropping the newlines. It's more verbose than result = option ? value1 : value2 but at least it's clean. > 2. switch (not important) > if elif else is not a proper substitute for switches, as the variable in > question has to be retyped in each if/elif clause. > One can shorten the code by assigning to a temporary variable, but I > consider switch more elegant. The ability > to specify limits like 0 <=x <=10 is cool, however. There is no real equivalent of 'switch' in python. IIRC a few weeks ago there was a thread about using classes to get a similar effect. This requires a separate method for each of the bits of code between the 'case's, so it is not a real substitute. But it's worthwhile to keep this alternative in mind when you find yourself writing long 'if elif elif elif' sequences. Adding a few small (sub)classes can really improve readability. > > Otherwise, one of the coolest languages I learned so far!! > It only gets better. Now if I could only teach my editor to add a ':' each time I type 'def' or 'class' or 'for' or 'while' or 'if' or ... or ... Have fun, Ype -- email at xs4all.nl From Attila.Feher at lmf.ericsson.se Wed Jun 6 12:19:26 2001 From: Attila.Feher at lmf.ericsson.se (Attila Feher) Date: Wed, 06 Jun 2001 19:19:26 +0300 Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> <3b1cdc84.5514@bolder.com.co.za> <9fleid$3rp$1@oslo-nntp.eunet.no> <3B1E4951.7F36D4E4@alcyone.com> <3B1E50E1.35AE59C@lmf.ericsson.se> <3B1E52DA.BBC9FC32@alcyone.com> Message-ID: <3B1E580E.D3EE577B@lmf.ericsson.se> Erik Max Francis wrote: [SNIP] > That competent computer users play games but never buy them is also > ridiculous. Having a bad day? Where did you see me writing this??? I _do_ buy the games (and then my GF plays them :-((( ), what I have told is that those guys I have seen _rarely_ buy the games. Very rarely. Now U can also pay attention to little nuances like this :-))), which is meant showing: no attack etc. BTW the chances that I know enough programmers to make a representative selection is very low. So undertstanding what I write the way you did is plain evil. A From mcherm at destiny.com Thu Jun 21 12:59:08 2001 From: mcherm at destiny.com (Michael Chermside) Date: Thu, 21 Jun 2001 11:59:08 -0500 Subject: Jython for Servlets Message-ID: <3B3227DC.B3D2DD5D@destiny.com> I would like to use Jython to write servlets in python and run them on a java application server (WebLogic or one if its ilk). Seem like this should be pretty easy to do... does anyone have a "hello world" example I can work from? -- Michael Chermside From aahz at panix.com Tue Jun 5 15:52:42 2001 From: aahz at panix.com (Aahz Maruch) Date: 5 Jun 2001 12:52:42 -0700 Subject: integers References: <9fjd8q$qb6$1@charm.magnus.acs.ohio-state.edu> Message-ID: <9fjdaa$aoa$1@panix2.panix.com> In article <9fjd8q$qb6$1 at charm.magnus.acs.ohio-state.edu>, Locke wrote: > >is there such thing as >someint++ >or >someint-- >or >someint += 2 >in python?? If you use Python 2.x, you can use someint+=2 -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "Do not taunt happy fun for loops. Do not change lists you are looping over." --Remco Gerlich, comp.lang.python From syver at NOSPAMcyberwatcher.com Fri Jun 15 04:13:53 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Fri, 15 Jun 2001 10:13:53 +0200 Subject: os.path.expandvars on win32 Message-ID: <9gcg7r$ra3$1@troll.powertech.no> As it is implemented in ntpath.py this function doesn't expand environment variables written the "DOS way"/%VAR_NAME%. Is there any reason, besides time to do it, why this functionality isn't included? I have an Emacs diff for ntpath.py plus a diff for test_ntpath.py that tests the new functionality, if the functionality is wanted. From junkster at rochester.rr.com Tue Jun 19 17:01:56 2001 From: junkster at rochester.rr.com (Benjamin Schollnick) Date: Tue, 19 Jun 2001 21:01:56 GMT Subject: SNMP OIDs for Cisco 6509 & Cable Modems References: Message-ID: In article , "Wayd Wolf" wrote: > > I'm working with the PySNMP software, which doesn't yet handle MIB -> > > OID conversion.... > > > > So I'm a little stuck, I'm having difficultly tracking down the > > actual numeric OID's for a Cisco 6509 & Industry Standard Cable Modems. > > > > Does anyone know how to generate the numeric OID's or where I can > > look up the Numeric OID's? > > > > Yeesh. Hate to follow your cross-post like this, but I'll make it short > and sweet. > Don't know why you're using the NMS you're using, but any SNMP browser > which allows for import of ASN1 compliant MIBs should would with the MIBs > from Cisco. As far as I know. I've imported dozens with some of the software > I'm testing and they all worked. I'd open the MIB in a text editor first > though to confim ASN1 notation. > -Wayd Wolf Well, all of the conferences, deal with SNMP, so it makes sense.... I don't normally cross post. The fact is, I am not using a Network Management Software (NMS), or a SNMP browser.... I am using a SNMP toolkit.... Directly from a programming language.... I'm working on a dedicated network application... For right now, I'm stuck with utilizing the NUMERIC OID's, which I can not seem to find... The MIB's from Cisco do *NOT* conform to the data that I'm seeing back from the Cisco 6506.... - Benjamin BTW-> Since I can't tell what conference you posted to, I'm forced to cross post again to ensure you can see this. Feel free to reply to that SINGLE conference you are in.... From chrishbarker at home.net Thu Jun 7 15:01:57 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 07 Jun 2001 12:01:57 -0700 Subject: How do you develop in Python? References: <050620011516094693%pecora@anvil.nrl.navy.mil> Message-ID: <3B1FCFA5.BA4AF4A0@home.net> Michael Hudson wrote: > but I'd have to admit that I don't use the MacPython IDE, so I might > be missing some specific detail of that implementation. But I don't > think so. This is exactly the same problem as you can get using PythonWin, and why I desperately wish there was a way for the IDE to NOT share the same interpreter as the code you are writing. Then you could just re-start the second interpreter. Anyway, my solution is to use: import B reload(B) # and then, of required: from B import * everywhere when I'm pretty confident that B is finished (maybe not untill I'm giving the code to someone else) I get rid of all the reloads. It's a little slower, but it makes sure I'm always using an up to date version of all my modules that are under develoment. Just van Rossum wrote: > It's simple: if you modify B.py, _run_ B.py to refresh it (*). A.py will see > the changes. It's hardly ever neccesary to quit the MacPython IDE. > > *) In other words: if B.py has already been imported, running it it will > execute it in B's old namespace, effectively refreshing it for everybody > to see. This is a classic, why didn't I think of that? solution. I think I will still use my method for stuff I'm changing a lot, it is less likely that I will forget to do the refresh. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From andy at mindgate.net Wed Jun 27 02:59:13 2001 From: andy at mindgate.net (Andy) Date: Wed, 27 Jun 2001 14:59:13 +0800 Subject: Is this a mimetools/rfc822 bug? References: Message-ID: Actually, I got this problem parsing a multipart/digest when rfc822 module wouldn't recognize the headers in the submessages. I tracked it down to the leading newline right after the boundary string. After reading about it in "Internet Email Protocols: A Developer's Guide" though, it seems that the leading newline was intentional and is how multipart/digest entities are formed. So the rfc822 module's behavior was absolutely correct in this situation. If it had discarded the leading newline, I believe it wouldn't have conformed to the spec. From slobin at ice.ru Tue Jun 12 17:41:11 2001 From: slobin at ice.ru (Cyril Slobin) Date: 12 Jun 2001 14:41:11 -0700 Subject: Python for MS-DOS (was: Re: RS232 support for DOS on 486?) References: Message-ID: slobin at ice.ru (Cyril Slobin) wrote in message news:... > in Windows version. And I'm sure it is still possible to compile modern > versions of Python with djgpp. Maybe I'll do it as a weekend project... So, weekend passes, and Python 2.1 is successfully compiled with DJGPP. Very similar to Python-DX, but with less built-in modules (yet). I myself use it instead of standart Python for Windows because of better readline support (faster, working history file save/load). You can get it from: ftp://ftp.ice.ru/pub/slobin/python/ From James_Althoff at i2.com Mon Jun 4 17:08:45 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Mon, 4 Jun 2001 14:08:45 -0700 Subject: I NEED to TEACH you something, QUICK! Message-ID: Martijn Faassen wrote: >Martijn Faassen wrote: >> old computer displays, or whatever. It nips flamewars in the >> butt. > >'bud'. Sorry about that. Please don't flame me now. :) Are you kidding? "Nip it in the butt" is a keeper!!! Hats off to ya! > >Regards, > >Martijn Jim From alan.gauld at bt.com Wed Jun 20 08:02:16 2001 From: alan.gauld at bt.com (Alan Gauld) Date: Wed, 20 Jun 2001 13:02:16 +0100 Subject: Which IDE ? References: Message-ID: <3B3090C8.66F11030@bt.com> VanPopering wrote: > Which IDE would you recommend for someone *just starting out* > with Python? IDLE or Pythonwin are both OK. IDLE doesn't like running Tkinter(GUI) programs from within the IDE itself but use it as an editor and it'll do OK. OTOH I've had strange results fromPythonwin with Tkinter too. Others have pointed out the advatages of using Emacs/vim/Scite etc as a python aware text editor along with an OS prompt. Thats probably the most reliable technique and is the one I use for writing longer programs or those with lots of files, but for a beginner thats probably not relevant. Alan G. http://www.crosswinds.net/~agauld From dsavitsk at e-coli.net Thu Jun 7 17:00:23 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Thu, 7 Jun 2001 16:00:23 -0500 Subject: Threading conceptual question Message-ID: I am working on an application (on Win2k) based loosly upon the SimpleHTTPServer. Each request from a client will cause a bunch of code to run on the server which may take from less than a second to several minutes. I don't want the server to complete the first process before it starts another, that is, i don't want it to lock up from one request. I also don't care what order the processes finnish in, as typically they will have nothing to do with one another. Is this the sort of thing that is solvable with threads? and maybe more specifically with win32process.beginthreadex()? also will i need to recompile python (please say no)? also, i am about to buy a new server, so the question is, do i want/need more than one processor to do this sort of thing? thanks all, doug From Bill.Scherer at VerizonWireless.com Tue Jun 26 11:25:19 2001 From: Bill.Scherer at VerizonWireless.com (Scherer, Bill) Date: Tue, 26 Jun 2001 11:25:19 -0400 (EDT) Subject: Mutable Strings? In-Reply-To: <20010626151732.31061.qmail@web13005.mail.yahoo.com> Message-ID: On Tue, 26 Jun 2001, Eric Merritt wrote: > Guys, > > I am somewhat new to python and I have a bit of a > question (as a side note, at work, I am a java > programmer mostly). In python, as in java, strings are > immutable objects (types in python I know). In any > case, Java has provided a StringBuffer class that is > basically a mutable string. Allowing you to append, > insert etc without creating a new object. This saves > quite a bit of object creation when any string > processing is required. Try using a list, and then join it when you need the string: Python 2.1 (#1, Apr 24 2001, 13:32:11) [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2 Type "copyright", "credits" or "license" for more information. >>> a = ['a', 'b', 'c'] >>> ' '.join(a) 'a b c' >>> a.append('d') >>> ' '.join(a) 'a b c d' >>> a.insert(3, 'wow!') >>> ' '.join(a) 'a b c wow! d' > > I have been looking for similar functionality in > python and have yet to find it. I tried searching the > archives but any search for terms relating to strings > returns an enormous amount of hits. In any case, are > any of you aware of a anything in python that provides > this type of functionality? I am willing to write my > own I just don't want to reinvent the wheel. > > > __________________________________________________ > Do You Yahoo!? > Get personalized email addresses from Yahoo! Mail > http://personal.mail.yahoo.com/ > > William K. Scherer Sr. Member of Applications Staff - Verizon Wireless Bill.Scherer_at_VerizonWireless.com From rnd at onego.ru Sat Jun 23 11:37:31 2001 From: rnd at onego.ru (Roman Suzi) Date: Sat, 23 Jun 2001 19:37:31 +0400 (MSD) Subject: PEP 255: Simple Generators In-Reply-To: Message-ID: On Sat, 23 Jun 2001, Roman Suzi wrote: >Maybe we can define generators like this, for example: > >def f(x): > f.is_generator = 1 > for i in x: > yield k Oops! Maybe: def f(x): for i in x: yield i f.is_generator = 1 >Here we explicitely tell that we want "function" to be a generator! > >(If we forget to do it, then it will be equivalent to: > def f(x): yield = [] for i in x: yield.append(i) return yield >Sincerely yours, Roman Suzi Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Saturday, June 23, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "He's not dead, Jim, he's just metabolically challenged." _/ From see at my.signature Tue Jun 19 21:00:27 2001 From: see at my.signature (Greg Ewing) Date: Wed, 20 Jun 2001 13:00:27 +1200 Subject: call-by-reference (was Re: Any other Python flaws?) References: <9gcu9g$gm4$1@newshost.accu.uu.nl> <9gd4tq$odb$1@news.mathworks.com> <9gdn37$61k$3@newshost.accu.uu.nl> <9gdt4j$b86$1@news.mathworks.com> <9gdtiu$61u$1@newshost.accu.uu.nl> Message-ID: <3B2FF5AB.E5181BC5@my.signature> Martijn Faassen wrote: > > I think the use of the word 'variable' is ambiguous. :) In Python it's clearer to talk about "names" and "bindings" rather than "variables" and "values". The statement then becomes "you can't change the binding of a name in your caller's namespace", which doesn't leave much room for misunderstanding. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From aleaxit at yahoo.com Sat Jun 2 18:56:06 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 3 Jun 2001 00:56:06 +0200 Subject: random References: Message-ID: <9fbqs902o69@enews1.newsguy.com> "Lulu of the Lotus-Eaters" wrote in message news:mailman.991514764.4040.python-list at python.org... ... > But if you are not happy with mere physical/empirical impossibility, it > works equally well for mathematical impossibles: > > <2+2=5> IMPLIES <2+3=6> > > works fine by application of Peano arithmetic. Using the successor > operator ' and some permitted reasoning: > > Premise: 2+2 = 5 > (1): 2+2'= 5' # successor of equals maintains equality > (2): 2+3 = 6 # rewriting terms in conventional manner > > The reasoning is valid, so the conditional holds. The antecedent is in > extremely bad shape--mathematically impossible--on its own. But so > what? So you can prove "_anything_ else" just as well -- any WFF in the system is now a theorem. You took a simple case, but it should be clear how with a little more work you can prove any other equation for example -- as given x=y you may legitimately add N*x to one side and N*y to the other, &c. Thus, if "I can predict the next bit" was a WFF in the system, <2+2=5> implies and thus the negation of this implication doesn't hold. Alex From m.faassen at vet.uu.nl Wed Jun 20 18:33:37 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 20 Jun 2001 22:33:37 GMT Subject: Any other Python flaws? References: Message-ID: <9gr8c1$hhq$3@newshost.accu.uu.nl> Carsten Geckeler wrote: > On 18 Jun 2001, Martijn Faassen wrote: >> Carsten Geckeler wrote: >> > On 14 Jun 2001, Martijn Faassen wrote: >> Sure, so ( and ) is mandatory. :) I know it's due to operator >> precendence issues. Doesn't mean it's not something that doesn't bite >> people. The actually really weird case is the single element tuple, >> which you can instead write as '% foo'. > Are you annoyed that Python provides this simplification? Surely not. No. I'm not actually annoyed by most of these issues; they're not big enough. They're just things that in some ideal world could possibly be better. :) >> But since single element tuples are a wart by themselves, this extra >> magic is necessary. Perhaps a language is possible where single >> element tuples actually are single elements, though that may introduce >> other warts. > So that's your point. Not the only point. I still think I have a point that the mandatory () around a tuple in that place are a wart. I'd have liked it to be different but that would mean a change in Python's precendence rules that would probably cause other annoyances. > But then propose another way of making one-element > tuples. BTW, I don't see "(1,)" as magic, more as simple given syntax. I see the single element syntax as 'magical syntax', just like: print "foo", is magical syntax. It's just syntax that isn't very pretty as everwhere else the comma implies there either is another element coming or that if it's the last element, the comma is ignored. 'magic' (here Martijn defines magic) is where something suddenly behaves different in a way that's outside of an easy to predict pattern that holds elsewhere. It's where hard to detect subtleties can have uncommonly large effects. Where the mind stumbles. > Since the curly brackets {} are used for dictionaries, normal brackets [] > for lists, there are only the parenthesis () left. And since they are > used for grouping, this special case for one-element tuple is needed. > Although I admit that I doesn't look very nice, I don't see any > alternatives. And the parenthesis aren't even necessary for tuples, which is nice in some circumstances. But in an ideal world there would be another type of brackets on my keyboard. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From rdsteph at earthlink.net Mon Jun 18 21:54:55 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Tue, 19 Jun 2001 01:54:55 GMT Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directionsof event-driven Python? References: Message-ID: <3B2D61C0.9C5147E@earthlink.net> Well, should you ever decide to try to do a relatively simple, experimental beta design of a Python-based Hypercard-like gui-creator, say just for simple user-data input and output (proof of concept, say); I will offer all the coding back-up help these poor fingers can muster, in my limted time and with my limited IQ. I imagine I better work real hard to learn Tkinter or wxPython nex tweek, first, though, or else I won't be of *any* help... Ron Stephens From robin at jessikat.fsnet.co.uk Fri Jun 8 04:48:44 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 8 Jun 2001 09:48:44 +0100 Subject: HTTPSHandler ??? (where is it) References: Message-ID: In article , RCS writes >In the documentation of the ActiveState distribution for Python 2.1 there is >listed as one of the objects of urllib2 the HTTPSHandler (for https >requests). > >On the Python prompt (>>>), the list for dir(urllib2) gives me a reference >to the HTTPHandler (among various other objects), but the HTTPSHandler there >is not. > >Does anyone know something about this? > >Tia, >Rolf C Stadheim > > have a search on parnassus for M2crypto; that has quite good wrapper for ssl stuff and there's certainly a replacement for urllib/httplib that handles https. It does work, but some report problems with memory leaks. On the other hand it is possible to patch the python socket code to work with ssl and I have gone that route and found it works well on the client side. -- Robin Becker From dsh8290 at rit.edu Fri Jun 1 15:35:38 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 1 Jun 2001 15:35:38 -0400 Subject: Iteration index In-Reply-To: <9f8pgk$11l6$1@agate.berkeley.edu>; from emarkp@csua.berkeley.edu on Fri, Jun 01, 2001 at 07:13:24PM +0000 References: <9f63lo$rb0$1@zeus.polsl.gliwice.pl> <9f8pgk$11l6$1@agate.berkeley.edu> Message-ID: <20010601153537.A7896@harmony.cs.rit.edu> On Fri, Jun 01, 2001 at 07:13:24PM +0000, E. Mark Ping wrote: | In article , | D-Man wrote: | >Yes, but I think | > | >s = ('a', 'b', 'ala', 'a') | >for i in xrange( len( s ) ) : | > print i , s[i] | > | >is easier to read, and you don't have the chance of forgetting to | >increment the counter. | | Agreed. But does it introduce n^2 complexity? I can't find anything | in the python docs that says that indexing into a list is O(1)--and | most people assume that indexing into a list is O(n). Does it really matter? Either way you are indexing the same list -- the for loop indexes it automatically or you index it explicitly. It is probably O(n) because it is a linked structure and indexing isn't a computed offset (like C arrays) and it isn't a dict (hashing). (Even if I am wrong in my guess on the list implementation, the index is a runtime calculation, not a compiler-computed-and-now-hardcoded jump from a known memory location). -D From mac4-devnull at theory.org Mon Jun 18 13:13:41 2001 From: mac4-devnull at theory.org (Neil Macneale) Date: Mon, 18 Jun 2001 10:13:41 -0700 Subject: += overloading? References: Message-ID: <3b2e3554$0$331$8eec23a@newsreader.tycho.net> In article , "Roman Suzi" wrote: > On Sat, 16 Jun 2001, Neil Macneale wrote: > >>I am creating a colored stringbuffer class, and I want to append words >>to the buffer with the '+=' operator. Ex: >> >>>>>csb = CSB("INIT STRING") >>>>>csb += "Hello" >>>>>print csb >>INIT STRINGHello >> >>would be the desired effect. I can't seem to find anything in the lib >>docs about overloading that operator though. Am I looking in the wrong >>place? It is also important that a new object is NOT created every time >>the operator is used, because that would be a waste. > > > class CSB: > def __iadd__(self, x): > self._string += x > I am using a list as the data holding element, then appending to it in the __iadd__ function. Then I use ''.join(list) to make a string when the __str__ function is called. I am doing this to minimize the number of string objects created, and figure that append runs in constant time. Is join optomized though? It would defeat the purpose if join worked by creating a new string to join the first two, then added the third, etc. I am assumming that join is implemented in C, and runs in 0(n) time, where n is the number of total characters. Am I assuming incorrectly? I looked at string.py's join function, but that just called another join method, and I don't know where that one is implemented. Thanks, Neil Macneale -- To reply to me via email, remove the '-devnull' from my address. From rob at jam.rr.com Sun Jun 24 09:15:49 2001 From: rob at jam.rr.com (Rob Andrews) Date: Sun, 24 Jun 2001 13:15:49 GMT Subject: What's object-oriented? References: Message-ID: <9KlZ6.83806$lq1.20507963@typhoon.austin.rr.com> zoodoo wrote in message news:GyiZ6.2264$Bp1.299293 at newsread2.prod.itd.earthlink.net... > What's the concept/logic behind object-orientation? What is it suppose to > mean? > > Different people will answer the question in somewhat different ways, but object-oriented programs use "objects" with "behaviors" instead of just procedures. The video game "The Sims" provides some great examples. You can program a general class of objects, such as "human" with some built-in behaviors, such as "talk", "walk", etc. You can call up instances of "human", with special distinctions. For instance, you might want to summon up a human with no legs. This instance of human would be able to talk, but not walk. And you could add specialized behaviors, such as "give birth", "jog", or "grok unix". I'm just a hobbyist, so some of the gurus here will doubtless give a far better answer than this one, but it's a start. Rob -- Useless Python: More fun than underwater frisbee! http://www.lowerstandard.com/python From rkiendl at gmx.net Thu Jun 21 09:30:19 2001 From: rkiendl at gmx.net (Robert Kiendl) Date: Thu, 21 Jun 2001 15:30:19 +0200 Subject: distutils error in py2.1 on win2000 Message-ID: <3B31F6EB.78B29FA9@gmx.net> with any distutils operation on my new python2.1 I get following error ... ? with pdb I know that _pathname_ in the error raising line is '' (empty string) ------- D:\tmp\Gnuplot-1.5>python setup.py install running install Traceback (most recent call last): File "setup.py", line 46, in ? packages=['Gnuplot'], File "d:\python21\lib\distutils\core.py", line 138, in setup dist.run_commands() File "d:\python21\lib\distutils\dist.py", line 899, in run_commands self.run_command(cmd) File "d:\python21\lib\distutils\dist.py", line 918, in run_command cmd_obj.ensure_finalized() File "d:\python21\lib\distutils\cmd.py", line 112, in ensure_finalized self.finalize_options() File "d:\python21\lib\distutils\command\install.py", line 301, in finalize_opt ions 'scripts', 'data', 'headers') File "d:\python21\lib\distutils\command\install.py", line 431, in convert_path s setattr(self, attr, convert_path(getattr(self, attr))) File "d:\python21\lib\distutils\util.py", line 86, in convert_path if pathname[0] == '/': IndexError: string index out of range From xyzmats at laplaza.org Wed Jun 6 10:28:24 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Wed, 06 Jun 2001 14:28:24 GMT Subject: network configuring through a script References: Message-ID: <3b1e3bf3.3670798@news.laplaza.org> On Wed, 06 Jun 2001 11:25:04 GMT, "Francis Meyvis" wrote: >Hi, > >I've W2k with ActiveState Py 2.1 on my notebook. Python provides some access >to COM things. >I'd like to have scripts that configure my notebook for networking at home, >at work, ... >This requires now going into the dialog for >- TCP/IP settings to change the IP address to use DHCP or use a fixed IP >address, > automatic DNS or fixed DNS server >- IE5 properties/connections to setup Dialup or LAN settings. >- the IE5 LAN settings allow further automatic settings and proxy server >settings. > >Are these two also possible from within COM? >Or should one directly modify the registry? > >Can someone point me to MSDN documentation on the inners of these >configuration dialogs? >I look in it but do not find anything usefull (could be that the MSDN I'v >access to is already to old). >Just some pointer would do ... There's an easier way. W2k provides a tool called "netsh" which can change the network settings from a shell prompt, and can also dump an existing setting into a file for later reuse. Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From jkraska1 at san.rr.com Fri Jun 1 21:16:42 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 02 Jun 2001 01:16:42 GMT Subject: Why isn't Python king of the hill? References: <9f7ai7$b4e$1@newshost.accu.uu.nl> <9f84rr$95m$1@panix2.panix.com> <9f936k$b2q$1@newshost.accu.uu.nl> Message-ID: >They all involve numbers with points in them.. and when you do math >with them, the answers may be different. That's about the extent >of my knowledge. While I'm sure you didn't mean it this way, I took the whole of your post as a rather damning condemnation. This sort of confusion is major bad mo-jo. C// From scarblac at pino.selwerd.nl Wed Jun 20 11:15:48 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 20 Jun 2001 15:15:48 GMT Subject: Any other Python flaws? References: <3b296534.514160393@wa.news.verio.net> <3b2a94a6.591842855@wa.news.verio.net> <636fd38f.0106200145.337888a3@posting.google.com> Message-ID: Tiago Henriques wrote in comp.lang.python: > Another annoying missing feature is the absence of command line editing in the > python shell. Perhaps now that the license has been made gnu-compatible it will > be possible to ship python pre-compiled with the readline library, instead of > having to compile python yourself. I have compiled python with readline support > myself, and it's pretty easy, but for the average user who is afraid of makefiless > and compilations, it would be extra-nice if python were a bit more user-friendly > out-of-the-box. This isn't good, because readline is under the GPL. The only thing that the GPL compatibility means is that people are allowed to distribute a version of Python with readline compiled in - *under the GPL*. Python licensed under the GPL would be bad - it couldn't be embedded in non-GPL projects anymore. -- Remco Gerlich From aleaxit at yahoo.com Sat Jun 2 03:39:23 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 2 Jun 2001 09:39:23 +0200 Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3B183CFF.A90213BA@san.rr.com> Message-ID: <9fa54s0fkb@enews2.newsguy.com> "Darren New" wrote in message news:3B183CFF.A90213BA at san.rr.com... > > The quote above contains the premise "even given _complete_ > > information". > > Except you snipped the end of the sentence, which is > "complete information about how they're being generated." > > I can have complete information about exactly how many atoms of uranium > I have in my sample, and still not be able to predict when the next atom > will pop. I have complete information about how the numbers are being > generated (watching a radioactive sample) without any information about > what the next number will be. _Complete_ information about how the numbers are generated requires complete information about the state of their generator. This is a tautology, of course, but you seem to be denying it. "Exactly how many atoms" is NOT complete information about the physical state of a system -- isn't that obvious, and, if so, why are you making statements that appear to imply the reverse? Position and velocity vector for each of these atoms are part of system's state. So, if Heisenber Principle holds, how are you going to have complete information about this state? > > > >A physical system that is macroscopic enough to escape > > > >Heisenbergian conumdrums > > > > > > There is no such system. > > > > In this case, no physical computer is predictable, and all > > we study about algorithms are abstractions -- since a > > computer system IS a physical system, then ALL bits > > coming out from it must be random in your sense of > > the word. > > Nope. Because you have an infinite number of possible states, and you > collapse some of those into a 0 bit and some into a 1 bit. It's because > you're *classifying* states in your brain as 1 or 0, ignoring the > reality that there's an infinite number of voltages that represent 0. So the system becomes "macroscopic enough" - yet the discussant asserted there was no such system. Will you guys please agree to ONE party line, or is Heisenberg uncertainty affecting you too badly? If my physical system is designed and considered in ways that are macroscopic enough to escape uncertainty effects, then (given some possibly huge amount of bits of information, which it may not be easy to obtain, of course) its trajectory in state-space is predictable. Is your claim, then, that "randomness" MUST be used ONLY for systems which, at the level of observation under discussion, ARE inevitably Heisenbergian? A roulette wheel, dice being rolled, cards being well-shuffled, balls being drawn from an urn -- we can enumerate all the classic devices used to obtain randomness "from physical systems" without necessarily encountering quantum effects in action. Chaotic effects may well ensure that the number of bits of information that would be needed to obtain prediction is higher than any practical measure. This, apart from the mention of bits, is the classic way probability theorists frame 'randomness'. I see nothing wrong with it, nor any need to demand that the amount of information needed for prediction be "actually infinite" (if that sentence makes any sense:-) before the word "randomness" can be used. Use of that word has never demanded such "infiniteness", so why should it suddenly impose such demands today? I consider it perfectly correct and proper to treat (e.g.) the results of good card-shuffling as random. So what is so special, that distinguishes a computer system from a deck of cards -- considering both systems at a macroscopic enough level that quantum effects can be ignored, which is easier for the deck of cards I think but is commonly done for well-designed computers too:-) -- so that I *could* get randomness from one and not the other? It seems more fruitful to me to consider the amount of information, i.e., a quantitative assessment of randomness, rather than claim that only if that amount is 'infinite' can the word 'randomness' be properly used. The information I _do not_ have, whether I don't because I _can't in principle have it_ or, as is more likely at a macroscopic level, because it's _impractical enough to determine it, transmit it, store it, process it_. Card-shuffling can be treated this way, in finite terms, and interesting results are obtained on how best to shuffle a deck of cards -- what happens to the deck if you shuffle algorithmically according to certain rules, and what one player (seeing 1 card out of every 4 from the shuffled deck) can determine about the other unseen hands. As the _purpose_ of shuffling the cards at all can be framed as minimizing the amount of information thus leaked, this is theoretically important in studying card-play -- theoretically only, these days, because in every important championship the 'shuffling' is in fact obtained by computer instead, but there is a separate theory about such shuffling and some interest in trying to get roughly as much randomness as a deck being shuffled would contain (which is less than a perfect shuffling affords: players new to computer shuffling used to complain all the time about the 'freak distributions' that kept coming up:-). This sort of application requires finite-mathematics theories, and I don't see why they shouldn't be, as they are, called theories of randomness. The concept of "HOW MUCH" randomness is practically and psychologically important, and becomes useless if the only possible answers are 'infinite' or 'none'. > > If, on the other hand, you maintain that the output > > from a physical system CAN be predictable if that > > system is a computer running your program, then > > what makes you SO certain that NO other physical > > systems can also be predictable in the same sense?-) > > Again, you're talking two diferent things. In the first, you're talking > about "the output will be somewhere between 4.5v and 5.5v on this > wire." The other you're talking about an exact number. Taking a set of states and deeming them equivalent can perfectly well be done -- who ever gets an "exact" number from physical measurement anyway?! It applies just as well to the finite definition of randomness. For example, when cards are dealt, we only deem significant the cards that are received and not the sequence in which they are received -- we collapse several possible states into one significant state. So, 13! states are collapsed into one (assuming the shuffling is such that all sequences are possible -- a big assumption in fact, but I don't think shuffling theory is what we're discussing here). Fine, no problem, and an important consideration when measuring _quantity_ of randomness of course. But of course we do have exact (integer) numbers in finite mathematics -- why shouldn't we? > > quote talks generically about "random", without using > > the word "perfect" you now insert, and without any > > specification of infiniteness as a prerequisite, and, as > > such and without the needed qualifications, it is not > > correct. _with_ the qualifications you want to place, > > it seems to become tautological ("I define X as being > > something that requires infinities: no finite system can > > reach X, it can only approach it") and therefore sterile > > and uninteresting, unless there are hidden layers of > > exoteric meaning nesting in it, I guess. > > I think "random" here means "unpredictable". Tossing dice will lead to > random/unpredictable results, even if you know everything there is to > know about the dice and the table. Generating numbers between 1 and 6 > will not be unpredictable if you know the seed and algorithm. If you have COMPLETE information about the dice &c (taking a HUGE number of bits, no doubt) you can predict their trajectories, bounces (if allowed), rolls, AND final results. Why should these macroscopic-physics effect be inherently unpredictable as you claim? VERY HARD to predict, yes (LOTS AND LOTS of bits), but the dice are VERY massive -- it seems to me a fine measurement system could give me (in principle) the information I need for prediction, CONSIDERING inter alia how many final states I collapse into one significant one ('infinite' number of minutely different dice positions at rest are all considered "a 3 throw" in the end -- just like the computer-system example you posed). Among classical randomness-generating physical systems, the ones of most interest to me are deck of cards, because card-playing (bridge specifically) is my passion, and in that case the finite-mathematics effects are even more in evidence, of course -- there are only 52! distinct states even before collapsing, after all. Yet randomness is there... If you have complete information about the algorithm and the relevant part of the state of the computer where it runs, again you have predictability. The only important issue is -- HOW MUCH information do you need for prediction. If too little info suffices, then the system is not random ENOUGH for a given application -- fine, get a better system, one requiring more information for prediction. It's important to quantify this, as I see things. Trying to forbid the use of the word 'randomness' whenever information amount is finite (deck of cards, rolled dice, roulette wheels, algorithms...) seems totally unproductive and fruitless. Alex From aahz at panix.com Wed Jun 20 20:09:37 2001 From: aahz at panix.com (Aahz Maruch) Date: 20 Jun 2001 17:09:37 -0700 Subject: locking dictionaries (was Re: New statement proposal for Python) References: <9gl1rg$p45$1@panix2.panix.com> <3B30203F.B158D356@my.signature> Message-ID: <9gre01$noi$1@panix2.panix.com> In article <3B30203F.B158D356 at my.signature>, Greg Ewing wrote: >Aahz Maruch wrote: >> >> OTOH, there's been some discussion of locking dicts during certain >> operations to prevent some ugly bugs and crashes. > >I'm given to understand that, in the case of lists, this is achieved >by temporarily changing the type pointer. If a similar thing were done >for dicts, presumably it wouldn't have any effect on the performance of >non-locked dicts. Yes, it would (assuming I understand the discussion correctly), because the code would be simplified by not needing the smarts to deal with dicts mutating in the middle of operations. I don't really know enough to understand what I'm talking about, but it occurred to me that possibly it might make sense to directly implement locked dictionaries and then have the internals use the external API under the covers. (You'd need a second "can't unlock this dict" variable for internal use, but that would only slow down the dict.unlock() operation.) -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "It's not what you know, it's what you *think* you know." --Steve Martin From tdelaney at avaya.com Tue Jun 12 00:19:36 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Tue, 12 Jun 2001 14:19:36 +1000 Subject: [Python-Dev] Feedback on new floating point info in tutorial Message-ID: > Tim Peters wrote: > > > god-created-the-integers-from-1-through-3-inclusive-and-that's-it-ly > > y'rs - tim > > > I thought "many" came after two ... Well, that's true, but large numbers of people forget that "many" itself is a number ... 1, 2, many, many 1, many 2, many many, many many 1, many many 2, many many many, lots! I say throw out FP, BCD, rational. Get rid of integers and long integers. All Python needs is troll representation! It is impossible to have an inexact representation ... although precision may suffer a bit ... Tim Delaney From mertz at gnosis.cx Sat Jun 23 12:45:26 2001 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Sat, 23 Jun 2001 12:45:26 -0400 Subject: Is this a true statement? (fwd) Message-ID: >But you can't *DO* all of the same things in all languages -- for >example: you can write a device driver in a language if you can't >specify interrupt vectors or hardware address pointers. David C. Ullrich wrote: |I thought a device driver was just a file, hence a finite |sequence of bytes. You can certainly use Python to write an |arbitrary sequence of bytes to a file. No doubt it's much easier |in C++ (or rather in typical implementations of C++?) to decide |_what_ sequence of bytes to write to that file One particular program would could write in Python is called a "C++ compiler". While this would not be a particularly *easy* program to write, you *could* write a script called 'gcc.py' that took all the same arguments and input *data* files as a program called 'gcc', and produced as a result bit-identical outputs. This may be a somewhat cumbersome approach to writing a device driver in Python, but... Yours, Lulu... From jeff at ccvcorp.com Mon Jun 18 14:57:59 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: 18 Jun 2001 11:57:59 -0700 Subject: Two minor syntactic proposals References: Message-ID: <16074dce.0106181057.528dfea@posting.google.com> philh at comuno.freeserve.co.uk (phil hunt) wrote in message news:... > > I propose a different way of doing this: make 'self' implied in all > references to instance variables. This involves definiing 2 new keywords, > qclass and insvars. So: > > qclass Thing: > insvar v, w > def myMethod(p): > print p, v, x > def otherMethod(): > myMethod(1) > someFunction() > > would be equivalent to: > > class Thing: > def myMethod(self, p): > print p, self.v, x > def otherMethod(self): > self.myMethod(1) > someFunction() > > Note that a qclass definition would have to know what its methods and instance > variables were, including those inherited from superclasses, for this to work. > Is this feasible? I much prefer having all member variables and member functions explicitly qualified. Having moved to Python from C++, where members can be referred to implicitly, it seems to me that the explicit requirement of Python makes code *much* easier to read--no more hunting about to try to figure out whether a given variable is a class member, or a parameter, or a global, or from some other scope... then there's also this problem (using your notation): qclass Thing: insvar spam def foo(): spam = 23 Does this modify the member variable Thing.spam? Or does it create a new spam variable that is local to Thing.foo()'s scope? I presume that you'd want the former--but the latter behavior is more consistent with the way that Python generally operates (i.e., builtins and globals are re-bound), so having an exception for class members would be potentially confusing. Jeff Shannon Technician/Programmer Credit International From ed_tsang at yahoo.com Tue Jun 19 18:04:05 2001 From: ed_tsang at yahoo.com (ed_tsang at yahoo.com) Date: Tue, 19 Jun 2001 22:04:05 -0000 Subject: How can I format the string according to its length at runtime? Message-ID: <9goi8l+9lqb@eGroups.com> I am trying to supply the precision formating at run time: s = 123 print '(0x%-6X -)'%s where I try to dynamically supply the number 6 from (6- length of s), I can't find a way to dynamically supply that. Anyone hav any idea? Thanks From chrishbarker at home.net Tue Jun 19 12:35:23 2001 From: chrishbarker at home.net (Chris Barker) Date: Tue, 19 Jun 2001 09:35:23 -0700 Subject: The Scoop on Python Input? References: Message-ID: <3B2F7F4B.77065C8E@home.net> Rainy wrote: > > Also, there doesn't seem to be any > way to unget the character, i.e. make a progress indicator that shows > 37% 42% etc but in one place as something progresses, except in curses. Yes, there is. But it's also not pretty: import sys,time for i in range(100): sys.stdout.write(" %i%% \r"%i) sys.stdout.flush() time.sleep(.05) sys.stdout.write("\n") -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From sill at optonline.net Sat Jun 16 00:39:39 2001 From: sill at optonline.net (Rainy) Date: Sat, 16 Jun 2001 04:39:39 GMT Subject: pair programming, vim? Message-ID: Hello, Did anyone try pair programming over the net? In particular, is it possible to set up vim with a shared buffer or, failing that, some other editor? If so, does anyone want to try pair programming some small project? -- "Your password must be at least 18770 characters and cannot repeat any of your previous 30689 passwords. Please type a different password. Type a password that meets these requirements in both text boxes." (Error message from Microsoft Windows 2000 SP1) From tdelaney at avaya.com Wed Jun 13 20:11:45 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Thu, 14 Jun 2001 10:11:45 +1000 Subject: Python grammar.. Message-ID: > Choose a parsing rule and use parens to group things differently. > Python (and many other languages) already need parens to do this for > binary operators ("1-2-3" parses as "(1-2)-3"). > > So you'd probably have to write "Spam(scramble(eggs), ham)" as > "Spam (scramble eggs) ham". I'm sure I'm not the only one who has noticed that with the addition of one set of parentheses we have ... (Spam (scramble eggs) ham) ... look familiar? Tim Delaney From aetodd at wm.edu Wed Jun 27 10:06:13 2001 From: aetodd at wm.edu (Andrew Todd) Date: Wed, 27 Jun 2001 10:06:13 -0400 (EDT) Subject: wxPython or Java In-Reply-To: References: Message-ID: <993650773.3b39e8555cd22@webmail1.wm.edu> Quoting Patrick Kirk: >Is this point and click type GUI creation possible with >wxPython? I have Visual C++ but want the application to >be portable. Is there a web tutorial on how to do this? I don't know if it is possible in wxPython, but I do know that it is tremendously easy in Java. Since you aren't bent on using Python, you might want to consider Java. It would provide the portability you are looking for. Normally I wouldn't recommend Java, but I wrote something about a year ago that seems very similar in only a few pages of code. If you're interested I can send you the source. -Andrew at wm.edu From aleaxit at yahoo.com Sun Jun 10 04:42:40 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 10 Jun 2001 10:42:40 +0200 Subject: Learning OOP... References: Message-ID: <9fvfi801fg8@enews2.newsguy.com> "Glyph Lefkowitz" wrote in message news:mailman.992131396.542.python-list at python.org... ... > Furthermore, I'd say that creating reusable code is *wrong*. Interesting strawman, but you haven't come anywhere close to 'proving' it in the following. > Is libjpeg software reuse? Probably not classified as such, but Of course it's reusable. So, why was it wrong to create it? > One of the things I like the most about python is the first-class > treatment of modules. A module is a far more important unit for useage > than an object. (I do wish that Python had better support for packages; Sure! "The unit of reuse is the unit of release", as per Robert Martin's "release-reuse equivalency principle". RM is an OO guru, by the way. This doesn't necessarily imply class-centered thinking to the detriment of proper modularization...:-). > projects. Keep your systems small and have them communicate clearly and > sparsely over encapsulation boundaries, and your code will be useful for > years; and you'll never have to re-cycle it. "Interface segregation principle", "dependency inversion principle", etc. Again, www.objectmentor.com has good papers on this:-). > Insofar as OO helps, it is because OO has a simple and relatively > universal metaphor for communicating between programs written with vastly > different design assumptions, even in different languages: message sending > between objects. However, OO also has the notion of inheritance, which is > a *huge* impediment to reuse between projects (but can be useful for other Except that it's not, when applied well. Python shows well how suitably designed inheritance can make for smooth framework-code reuse, e.g. in sgmllib/htmllib and the whole server hierarchy. Code generators should generate base-classes that are specialized by inheritance, *NOT* by editing generated sources (a round-trip nightmare). Mixins allow seamless reuse. Etc, etc... It's true that implementation inheritance CAN too easily create unintended strong coupling. Scott Meyer's rule of thumb to "never inherit from a concrete class" (in a C++ setting) shows to what extremes one could go to ward off that danger... > things). Also, some systems which claim to be "OO" also have static > typing, which partially negates the value of sending messages. ...and partially enhances it. Again, it demands very solid design (I wouldn't be Pythoning if I didn't think the flexibility of dynamic typing was more often useful than the rigidity of static typing, but I do have to play devil's advocate on this thread, I think:-) but when you have it you're well placed. Templates (or other mechanisms for compile-time genericity) recover a lot of that flexibility at no runtime cost -- Coplien's "pattern without a name" is IMHO mostly aboyt that (template class Y: public X, etc). Basically, templates give you signature-based polymorphism, like Python's, at compile-time only (thus less flexible, but easier to generate speedy code for, and sometimes allowing somewhat earlier error diagnosis). > > > 5. I want strong and flexible data typing - I know it sounds like an > > > oxymoron. I want the typing to be especially powerful (restrictive) > > > but I want to be able to define the constraints of the types myself. > > > > This isn't the case for Python. Python is flexible and powerful but doesn't > > do constraints very well. :) We like it that way. A language like Java or > > Ada or (perhaps especially) Eiffel is better suited for that. > > This is also, IMHO, against the spirit of object orientation. Smalltalk, I'd like to see you say that to Bertrand Meyer's face, given how intensely he maintains that "the spirit of OO" is statically typed!-) Me, I might quote the Bard by saying "a pox on both their houses", but I'll take the reverse tack, praising BOTH dynamic and static typing. I think OO works well with both, in different ways. > have anything to do with object orientation. Certainly, provable > correctness and static typing are at odds with reuse, since they make your > software more resistant to change. Making software resistant to change is neither an intrinsically bad thing, nor one at odds with software reuse. I DO want the software that I'm reusing to be unchangeable from the point of view of behavior that I, the reuser, observe. If static type checking helps increasing the "firmitas" of the software I reuse, that won't impede its "utilitas" nor its "venustas" from my POV ("firmitas, utilitas, venustas" are Leandro Alberti's and Palladio's three principles of architecture -- solidity, usefulness, beauty -- they were writing about buildings, but, as we know from the impact of Alexander's ideas on modern software engineering, building architecture and software architecture may have more intellectual and cultural connections than one would suspect). The 'open-closed principle' is relevant here... > The easiest way to have a responsive, efficient program is to prototype > and prototype and prototype in a flexible, "slow" language, until you've > got the fastest possible high-level algorythm, then optimize for constant Nolo contendere here, but it's SO important it's worth quoting just to increase the likelihood that it gets read:-). > pretty clear idea of your objectives; but I'd recommend taking a look at > the eXtreme programming books for a differing perspective on software > engineering. XP can definitely be commended. And if one is a static typing freak, that doesn't necessarily mean giving up on XP -- it just takes a _bit_ more upfront design and makes refactoring a bit more work, but as Fowler's book "refactoring" (all examples are in Java) and Martin's take on XP (thinking mostly of use in C++) show, XP is not _just_ for dynamic languages such as Smalltalk and Python (though they do help:-) -- it's a lightweight development process that can be of use in a variety of design and development settings... Alex From nperkins7 at home.com Mon Jun 18 22:59:59 2001 From: nperkins7 at home.com (Nick Perkins) Date: Tue, 19 Jun 2001 02:59:59 GMT Subject: Function lookup using a directory. References: <29pX6.14682$cF.320097@news1.nokia.com> Message-ID: ...another thing to keep in mind is that you could also store functions as the values of the dictionary, just as easily as class instances. Maybe you prefer class instances, but your use of a 'run' method might indicate that what you really want to keep in the dictionary is functions. (your subject line even says so) eg. def Help0(args): blah blah blah ... commands = {0:Help0, ... ..then you can retrieve the function later.. fn = commands[n] ..and call the function by simply using.. fn() ( no run() method necessary ) In Java, you would need to define a class with a 'run' method, but in Python, a function can be passed around like any other object. From Glen.Mettler at home.com Thu Jun 7 19:52:05 2001 From: Glen.Mettler at home.com (Glen Mettler) Date: Thu, 07 Jun 2001 23:52:05 GMT Subject: New Python User Message-ID: Anyone in or near Huntsville, AL willing to tutor a couple of hours a week (for a fee, of course)? Glen From schaffer at optonline.net Thu Jun 14 12:28:14 2001 From: schaffer at optonline.net (Les Schaffer) Date: Thu, 14 Jun 2001 16:28:14 GMT Subject: weird behavior wrapping global functions into classes References: <0cahit44sql68p8pd2qgt59f600neha687@4ax.com> <9gah5j02v9@enews1.newsguy.com> Message-ID: On Thu, 14 Jun 2001 16:19:26 +0200, "Alex Martelli" wrote: >Whenever a function is accessed as an attribute of a class or ^ |___ python coded >instance (and in the latter case, it's found in the class and >not in the instance itself), it's transmuted into a method >(unbound and bound, respectively). $$!!@(*!#(#!!@!@!!@ what the ?????!!!!! sssssssssssssssssss....ssss......s.... how come the built-in open doesnt get transmuted but shelve.open does? just because its not "python-coded"??? anyway, here's how i will deal with this bit of nastiness in the future: class NumStorage: def __init__(self): tup = (self.DB,) if self.mode: tup += (self.mode,) self.db = apply(self.dbops['open'], tup) def close(self): self.db.close() class NumFlat(NumStorage): mode = 'w' DB = 'flat.txt' #silly hack dbops = {'open': open} print 'in NumFlat class definition, dbopen = ', dbopen # ok def store(self, key, value): self.db.write(array2string(value, precision=8)) class NumShelf(NumStorage): mode = None DB = 'test.dbm' #silly hack dbops = {'open': shelf_open} print 'in NumShelf class definition, dbopen = ', dbopen # ok def store(self, key, value): self.db[key] = value your Callable thingy looks okay, but if its that easy, some such thing should be built right into Python so this issue is crystal clear and upfront/outfront. i never asked for dbopen to be a class method, or so i thought, yet i get hammered in an inconsistent way (built-in open: good, python-coded shelve.open: bad). anyway, .... thanks, alex.... les schaffer From michel at digicool.com Mon Jun 18 16:15:16 2001 From: michel at digicool.com (Michel Pelletier) Date: Mon, 18 Jun 2001 13:15:16 -0700 (PDT) Subject: Article on ZODB Programming Message-ID: I've written the first in a series of articles on the Zope Object Database (ZODB). These articles show you how you can use ZODB in your python programs to save your objects in a database transparently. This article does not require any use of Zope, but installing Zope is the easiest way to get ZODB. If your interested in an interesting, object-oriented alternative to relational database, you should check this out: http://www.zope.org/Documentation/Articles/ZODB1 Please cc: me on any responses to this message as I am not on this list. Thanks, -Michel From jdhunter at nitace.bsd.uchicago.edu Sat Jun 2 11:04:06 2001 From: jdhunter at nitace.bsd.uchicago.edu (John Hunter) Date: 02 Jun 2001 10:04:06 -0500 Subject: iterating over lists Message-ID: <1rsnhinct5.fsf@video.bsd.uchicago.edu> I have three lists of equal size: list1, list2 and list3. What I want but doesn't work: for (x1, x2, x3) in (list1, list2, list3): print x1, x2, x3 I know I can do it by keeping a index count variable: N = len(list1) for i in range(1,N): print list1[i], list2[i], list3[i] but am wondering if there is way to create a tuple of named variables as in the (x1, x2, x3) example above. One final question: If I do: for i in range( 1, len(list1) ): print list1[i], list2[i], list3[i] I assume the len(list1) call will only be evaluated once. Is this correct? Thanks, John Hunter From chris.gonnerman at newcenturycomputers.net Wed Jun 13 08:39:04 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Wed, 13 Jun 2001 07:39:04 -0500 Subject: VI References: Message-ID: <004f01c0f405$d940f2a0$0101010a@local> VI is the old BSD Unix text editor, commonly found on all flavors of Unix. "Real" vi isn't available for free AFAIK. If you really want vi go to http://www.vim.org and get vim (VI iMproved) as it is basically compatible but far more powerful. Warning... vi and it's clones have a user interface that takes mucho getting used to, but once you've got it down it is VERY powerful and efficient. ----- Original Message ----- From: "Pilgrim" Newsgroups: comp.lang.python To: Sent: Wednesday, June 13, 2001 6:28 AM Subject: VI > Can someone tell me what "vi" is for a text editor to work with python? > Where can I get this? > > > -- > http://mail.python.org/mailman/listinfo/python-list > > From cce at clarkevans.com Wed Jun 27 13:54:09 2001 From: cce at clarkevans.com (Clark C . Evans) Date: Wed, 27 Jun 2001 13:54:09 -0400 Subject: What is my module name? Message-ID: <20010627135409.A16488@doublegemini.com> I have a module with a function below I use __name__ to return the module name. However, when I call the function from outside, it returns '__builtin__'. Is there a way to have this function return the module name regardless of where it is called? def myName(): return __name__ Thanks! Clark From dougfort at downright.com Thu Jun 14 06:55:28 2001 From: dougfort at downright.com (Doug Fort) Date: 14 Jun 2001 11:55:28 +0100 Subject: Sockets References: <3B285091.8B0C506D@usa.net> Message-ID: <3b289820_6@news5.uncensored-news.com> mixo wrote: > I create a socket and listen for connections in try and , close socket > > in a except. Also, within the try I have a while loop that I create a > socket > once a connection has been made to a client., and close the socket once > data has been sent to a client. Now, my problem is, if at least one > connection is made, when the server dies, I can't restart it as I > can't create a new socket for the server.. Is there something > that hapens when a connection is accepted that prevents a restart > of the server? > > P.S I am using the socket module. > > Try using something like: self.socket.setsockopt(socket.SOL_SOCKET, socket.S_REUSEADDR, 1) Note: This code was lifted from the SocketServer.py library module. It's worth reading that module in detail if you're going to use sockets. -- Doug Fort Senior Meat Manager Downright Software LLC http://www.downright.com ______________________________________________________________________ Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com With Seven Servers In California And Texas - The Worlds Uncensored News Source From sdm7g at Virginia.EDU Mon Jun 25 11:37:00 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Mon, 25 Jun 2001 11:37:00 -0400 (EDT) Subject: Is this a true statement? In-Reply-To: Message-ID: On 25 Jun 2001, Martin von Loewis wrote: > The point is that a program that writes a device driver is not the > device driver itself. Instead, the program that writes a device driver > is typically called 'compiler' or 'linker'. You can certainly write > compilers and linkers in Python, and some people have actually done so. > > However, 'writing a program that generates a device driver' is not at > all the same as 'writing a device driver'. Both methods involve writing an abstract specification for a device driver in some language, which gets transformed by a chain of several programs into an actual device driver. If you write it in macro-assembler, macro statements get expanded into basic assembler. Would you say that you can't write a device driver in macro -- only in assembler ? What we mean by writing a device driver (in some language) is describing a device driver. This all seems to be an argument over whether the map is or is not the territory. Despite the fact that he waited till I conceded to him to concede and leave me out on a limb :-), I think David made an interesting point about Turing equivalence -- it's reach is a bit farther than I had thought: A device driver *IS* a computable function of a textual description of a device driver. However, I still object to folks throwing around *unqualified* statements about the equivalence of all programming languages -- Turing equivalence is still a rather narrow form of equivalence, and it doesn't at all imply that anything you can do in one language, you can do it another -- unless you have a very curious definition of "do" that perhaps only involves talking about doing. ( In this particular case, the specification of the problem: "write a device driver" was so loose as to allow such an impractical solution. If someone else wants to challenge that notion, I'll be sure to be more specific of the requirements next time! ) -- Steve Majewski ( And I DO wish more languages had adopted Intercal's "Please" statement -- it would make programs so much nicer to read! ) From ullrich at math.okstate.edu Mon Jun 4 10:08:02 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 04 Jun 2001 14:08:02 GMT Subject: random References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> <3b1a4ce6.577431@nntp.sprynet.com> <9fdtd301oqk@enews2.newsguy.com> Message-ID: <3b1b945e.3180641@nntp.sprynet.com> On Sun, 3 Jun 2001 19:49:08 +0200, "Alex Martelli" wrote: >"David C. Ullrich" wrote in message >news:3b1a4ce6.577431 at nntp.sprynet.com... > ... >> a place where I was asked for a definition >> and didn't give said definition I'll say oops, >> never mind excuse me. But I don't believe that >> that has happened. Accusing me of refusing to >> supply definitions when asked is egregiously >> insulting. > >Reading back on the thread I saw I did not directly >ask you for the definition, just indicated that the >definition you (and/or Von Neumann) were using >was not clear by such "hints" as: >""" >If by "perfect" randomness VN meant an infinite amount >thereof (by Chaitin measure), he might have said that >""" > >But then I never accused you of not giving the >definition when directly asked to give it -- show >me a place where I said that? Here's a quote from a post a few messages up: "As you do not deign to define your terms (not even to USE them, actually -- that 'perfect' was NOT in the original quote from JVN) unless pushed very hard about it," I suppose that is not _quite_ a direct assertion that I've been directly asked to give a definition which I then did not give, but that's certainly what the "unless pushed very hard about it" sounds like to me. >What I meant by >"not deigning" to give the definition was exactly >your failure to provide it when I was clearly saying >that I could not be sure of what the H*** you (and/or >VN) meant by that "perfect" (I believe you were >actually the one to introduce "perfect" or "true" as >adjectives qualifying "randomness"/"random" on >this thread, but I may be wrong -- I've wasted by >far enough time on this thread without going back >for a detailed exegesis of it:-). > >You did follow up to this subthread and not offered any >definition of that "perfect" (or "true") on the follow-ups, >I do believe. Am I wrong -- did I miss some message >in the huge complex of threads? This has surely been >known to happen on Usenet news at times. Whatever. For the record, although I don't quite agree that it was clear that [this] meant what you say it clearly meant, nor that it was clear that [that] meant what you say it clearly meant, you have in fact clarified what you were getting at. See, where I come from the phrase "push someone very hard for a definition" refers to something like... oh, never mind. >Alex > > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From thomas at xs4all.net Thu Jun 14 15:41:26 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 14 Jun 2001 21:41:26 +0200 Subject: Python 2.0.1c1 - GPL-compatible release candidate In-Reply-To: <200106141730.f5EHUgX03621@odiug.digicool.com> Message-ID: <20010614214126.C1659@xs4all.nl> On Thu, Jun 14, 2001 at 01:30:42PM -0400, Guido van Rossum wrote: > Python 2.1 users can ignore this release, unless they have an urgent > need for a GPL-compatible Python version and are willing to downgrade. > Rest assured that we're planning a bugfix release there too: I expect > that Python 2.1.1 will be released within a month, with the same > GPL-compatible license. (Right, Thomas?) Absolutely. Except, of course, if the PSU grabs me and stuffs me in the same null-entropy bin they did with Mo From pknews at kirks.net Fri Jun 29 04:57:06 2001 From: pknews at kirks.net (Patrick Kirk) Date: Fri, 29 Jun 2001 09:57:06 +0100 Subject: wxPython to create a database front end References: <9hchtv$j9i$1@news6.svr.pol.co.uk> <9hei12$umu$1@newsreaderm1.core.theplanet.net> Message-ID: <9hhft3$5jq$1@nntp.teliafi.net> Many thanks. Boa is very clever so I'll try that. From thomas.hansenNOSPAMORILLSUEYOURASS at entermatch.com Fri Jun 1 03:13:16 2001 From: thomas.hansenNOSPAMORILLSUEYOURASS at entermatch.com (Thomas Hansen) Date: Fri, 1 Jun 2001 09:13:16 +0200 Subject: best language for 3D manipulation over web ? References: Message-ID: <9f7eqe$gvd$1@oslo-nntp.eunet.no> www.wildtangent.com Down the Game Driver, start hitting your favourite *JavaScript*!! editor, off you go... Thomas PS! It's an ActiveX object, wraps around DirectX to make scripting 3D games possible. I've seen it with a "need for speed" kind of game and it really works (on a PII 300mHz, ATI RAGE PRO 8MB) "Jacqueline L. Spiegel" wrote in message news:PctR6.3$jC6.216 at typhoon.nyu.edu... > > Hi All, > > I will be writing a program that needs to be accessible over the web that > will seek to manipulate objects in three dimensions through the access of an > oracle database. I could be manipulating as much as 32 MB of memory (with > respect to data only) in space. I would also need to slice and > interpolate information on the fly. I am a Java programmer, but my fear is > that Java is not as fast as it should be in order to handle such > manipulation (assume users have at least a T1/cable modem connection, and > are not going in by 56K modem) > > What is the best language for this ( I will need to do GUI programming as > well). > > Although I am really comfortable with Java and prefer to go this route, I am > wondering if there is a better and faster way (I feel that Java is slow in > general, even for 2D). If you recommend another language, can you please > recommend which 3D library and GUI library that I would use, as well as > explaining how I (or the language's API) connects to the web browser ? I > am not experienced with "Applet" creation outside of the Java language. > > You attention is greatly appreciated with regard to this matter. > > CC-ing email to jackie at popmail.med.nyu.edu, would also > be greatly appreciated. > > Jacqueline > > > From tim.one at home.com Fri Jun 29 16:32:56 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 29 Jun 2001 16:32:56 -0400 Subject: [Python-iterators] While we're at it... In-Reply-To: <3B3C7E28.7FF6093E@destiny.com> Message-ID: [Michael Chermside] > .., > I agree we should modify a number of std library functions > to use iterators, but random.choice seems to me to be a > very poor (excuse the pun!) choice. Do you have specific ones in mind? Of course *anything* using for ... in x: will automatically accept any x implementing the iterator interface, including all 2.1 sequence types (even those supplied by pre-2.2 extension modules that never heard of the iterator interface), and generators. I tried to cover other reasonable cases (no, not random.choice()) too, but have certainly missed some. Here's from (what will become) the 2.2 NEWS file: - Iterators were added; this is a generalized way of providing values to a for loop. See PEP 234. There's a new built-in function iter() to return an iterator. There's a new protocol to get the next value from an iterator using the next() method (in Python) or the tp_iternext slot (in C). There's a new protocol to get iterators using the __iter__() method (in Python) or the tp_iter slot (in C). Iterating (i.e. a for loop) over a dictionary generates its keys. Iterating over a file generates its lines. - The following functions were generalized to work nicely with iterator arguments: map(), filter(), reduce(), zip() list(), tuple() (PySequence_Tuple() and PySequence_Fast() in C API) max(), min() join() method of strings extend() method of lists 'x in y' and 'x not in y' (PySequence_Contains() in C API) operator.countOf() (PySequence_Count() in C API) right-hand side of assignment statements with multiple targets, such as x, y, z = some_iterable_object_returning_exactly_3_values Anything else come to mind? The core language coverage is pretty broad already, so lots of stuff in the .py libraries should "just work by magic" with any iterable argument. OTOH, we all have blind spots, and, e.g., I never would have thought of the "right-hand side of a multiple-target assignment stmt" context on my own. From mwh at python.net Wed Jun 27 14:16:52 2001 From: mwh at python.net (Michael Hudson) Date: 27 Jun 2001 19:16:52 +0100 Subject: PEP 260: simplify xrange() References: <3B398BBE.A2D455C9@darwin.in-berlin.de> <9hclc1$qv5$1@panix2.panix.com> <3B3A08B5.3C142546@darwin.in-berlin.de> <3B3A1DC0.3583E9D8@ccvcorp.com> Message-ID: Jeff Shannon writes: > To make a long story short, the discussion regarding FP boils down > to the fact that "1.0" cannot be exactly represented in FP. Not true. > Every time you increment your "frange", you are introducing nasty > rounding errors, and by the time you've done several thousand > iterations, they're going to be very significant rounding errors. > And the worst part is that there will be *no indication* of where > the wrong answers are coming from unless you happen to monitor your > frange index throughout a debugging run... and even then it'll only > be clear if you know that the FP problem exists. This is true, though. Glib truism: Floating point arithmetic *is* exact (given a rounding mode), but it's not exactly what you think. My pedant-gland throbs a bit when I see people write "floating point numbers are approximate"... Cheers, M. -- That one is easily explained away as massively intricate conspiracy, though. -- Chris Klein, alt.sysadmin.recovery From jm7potter at hotmail.com Sat Jun 30 06:57:03 2001 From: jm7potter at hotmail.com (Joe Potter) Date: Sat, 30 Jun 2001 06:57:03 -0400 Subject: Tkinter problem in sizing a frame References: Message-ID: On Sat, 30 Jun 2001 01:09:21 GMT, matt at mondoinfo.com (Matthew Dixon Cowles) wrote: >On Fri, 29 Jun 2001 20:58:58 -0400, Joe Potter >wrote: > >>Thanks for the help --- that was the ticket. I did read the fine >>manual, but I missed that part! > >Joe, >You're welcome! Speaking of fine manuals, let me recommend two things >that you may not have come across yet. Fredrik Lundh's excellent An >Introduction to Tkinter is at: > >http://www.pythonware.com/library/tkinter/introduction/index.htm > >It's extremely helpful. I generally have a local copy open when I'm >doing Tkinter programming. Pmw is also extremely useful. It's a set of >compound widgets that would be a big nuisance to build yourself. It's >at: > Thanks for the tip. I downloaded the PDF version just now. I'll read it over today. >http://pmw.sourceforge.net/ > >Between the two of them, they improve the life of a Tkinter coder >hugely. > >Regards, >Matt Thanks again, Matt Regards, Joe From aleaxit at yahoo.com Sat Jun 2 15:07:57 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 2 Jun 2001 21:07:57 +0200 Subject: random (fwd) References: Message-ID: <9fbdhl01s6r@enews2.newsguy.com> "Lulu of the Lotus-Eaters" wrote in message news:mailman.991502104.19290.python-list at python.org... > Coming, admittedly, a bit late to the conversation on this topic, I'm > surprised to find Alex a bit too dedicated to his point... and making a > few errors about which he knows better: > > Someone wrote: > >A physical RNG can have the property that one cannot make > >any prediction about the value of the next bit even given > >_complete_ information about how the numbers are being > >generated. > > "Alex Martelli" wrote: > |This says "GIVEN _complete_ information". Now you say > |you CANNOT "have complete information". The two > |statements are in contradiction. > > No contradiction in this. "If you COULD have complete information you > can not make a prediction" does not imply that you CAN have complete > information. The assertion NOT( IMPLIES ) can never hold, if is an impossibility, because in that case ( IMPLIES X) is true for any X, so its negation is false. So, NOT(X IMPLIES Y) *does* imply X is possible. (X IMPLIES NOT Y) doesn't. But "_even given_ X, not Y" looks like it would be very peculiarly rendered as 'X implies not Y', and 'X does not imply Y', aka 'NOT(X implies Y)', seems like a much more natural translation, doesn't it? > |I _think_ -- but am not a philosopher or mathematician > |so cannot feel sure -- that part of what Goedel shows is > |that arithmetic is powerful enough to model any other > |formal system. > > Well... I *am* a philosopher, and have occassionally pretended to be a > mathematician (not the most convincing pretense though). But I don't > think one needs to be to see what's wrong with the above. > > Assuming "Goedel" means his incompleteness theorem in the above, he > really doesn't show anything like the above. Sorry, I wasn't thinking specifically of his theorem but rather of his way of operating towards it. Given any (finite) axiomatic system, even 'richer' than arithmetic, can't we MODEL that richer system with arithmetic, numbering well-formed formulas &c, by just the same process as Goedel uses to model arithmetic in itself? The fact that we added a few primitive symbols and axioms to the set we started with for arithmetic (be that Peano's or whatever) doesn't appear to me to break down the process. Indeed, doesn't Goedel specifically model "any finite axiomatic system powerful enough to model arithmetic" in arithmetic terms, with his _procedure_ (that he uses to prove his theorem, but that's by the by in this context...)? Again, I'm no philosopher nor a mathematician, so I guess I can't be as sure of such things as you are, but I fail to see the key step here: > Let's say, for example, that the Peano axioms model arithmetic for our > standard. Given the Goedel machinery, we can derive a specific statment > of Peano arithmetic, _I_, that is neither a theorem nor a contradiction > of Peano arithmetic. So far so good. > Therefore, we can create a new system Peano+_I_, that is both consistent > (if arithmetic is) I'm still following... > and not modelled by arithmetic. Please stop right here! Why can't we _model_ the new system in the previous one by applying the 'machinery' afresh? Renumber the symbols (same number as before in this case, right?) and get the Goedel numbers for all the axioms (one more than before)? > Moreover, we can now > derive an infinite number of new theorems of Peano+_I_ that utilize _I_ > in their derivation and that are independent of Peano arithmetic. Oh, I didn't know the 'new' theorems will always be infinitely many -- interesting indeed (is it anything deep or just a trivial by-product of considering "_I_ AND (old theorem)" &c as a new theorem and there being infinitely many old theorems in arithmetic?). But definitely by the by. Aren't we modeling the new 'arithmetic-plus' in the terms of the old arithmetic? Alex From balexander at rsv.ricoh.com Wed Jun 20 15:00:00 2001 From: balexander at rsv.ricoh.com (Bob Alexander) Date: Wed, 20 Jun 2001 12:00:00 -0700 Subject: PEP 255: Simple Generators References: Message-ID: <3B30F2B0.532055D6@rsv.ricoh.com> Here are $.02 from an old Icon hacker. I've been close to the center of Icon development and evolution for over 15 years, and here are some observations to consider: 1. As previously pointed out in these threads, Icon makes no syntactic distinction between a "generating" function and an "ordinary" function that returns a single value. 2. As an Icon programmer, it never occurred to me that there was a need for a syntactic distinction. 3. I don't recall any Icon users ever raising the issue that having such a distinction would improve the language. At some level of theoretical reasoning, it might seem that distinguishing between generator functions and other functions would be helpful. However, in real programming life it doesn't seem to matter. I support Tim's position to keep Python's syntax simple! BTW, in the comments that precede a function definition (or in a docstring), I almost always mention something about what the function returns. That is a great place to communicate to callers and maintainers that it is a generator. Bob Alexander From sholden at holdenweb.com Thu Jun 28 22:13:40 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 28 Jun 2001 22:13:40 -0400 Subject: 'with' statement in python ? References: Message-ID: "Carlos Ribeiro" wrote in ... > At 21:50 25/06/01 +0000, Mark Hadfield wrote: > >From: "asgard" > > > > > > > Hello, > > > writing self before every object's method really drives me > > > crazy. Shouldn't there be 'with' statement like in Pascal, ie. > > > >There was an extensive discussion on this recently. Perhaps you'd like to > >try a search on Google Groups. IIRC the consensus was that adding this to > >Python would not be a good idea, because when "with" blocks are nested they > >become hard to read and possibly ambiguous. > > I'll repeat the same argument that I gave some time ago. Maybe it's a good > answer for this FAQ :-) > [ ... ] The reappearance of the FAQ wizard allowed me to enter: 6.31. Why doesn't Python have a "with" statement like Delphi's Object Pascal? Thanks for your words, Carlos. regards Steve -- http://www.holdenweb.com/ From aleaxit at yahoo.com Tue Jun 19 09:40:46 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 19 Jun 2001 15:40:46 +0200 Subject: Python version of IQ has been updates (IQ v0.34.python) References: <505.566T11T1243597threeseas@earthlink.net> <3B2A7F5E.MD-1.4.4.padf@ihug.com.nz> <3871.567T2214T9794928threeseas@earthlink.net> <87puc3ao42.fsf@pooh.honeypot> <2509.568T2823T9766233threeseas@earthlink.net> <9gkftm026v9@enews2.newsguy.com> <87k829ai6y.fsf@pooh.honeypot> Message-ID: <9gnkp00o7f@enews2.newsguy.com> "Kirk Strauser" wrote in message news:87k829ai6y.fsf at pooh.honeypot... > > At 2001-06-18T08:59:32Z, "Alex Martelli" writes: > > > For regular expressions, they're extremely similar, and both VERY > > hard-going for a beginner. > > Alex, > > I would compare that to "Mathematica's nonlinear equation solvers are VERY > hard-going for non-mathematicians." Perl's RE syntax is designed by and for > people who have pretty much mastered the subject elsewhere. And where would that "elsewhere" be? Once upon a time, you could perhaps count on "a real programmer" having a lot of experience with vi and/or emacs, lexx, grep, egrep, sed, awk -- today, while still widespread and flourishing, these tools are not mainstream. Python and Perl are, but I'd bet that today, for *most* Python and Perl users, the language in question is likely to be their first (and maybe their only) real exposure to RE's. *VERY* hard-going. > > Outside of regular expressions, I do not think anybody would claim Perl's > > concise syntax is anywhere near as easy-to-read as Python's clean and > > spare one. > > I would. Then again, I'm more experienced with C, C++, Java, and other > similar languages. More experienced than whom? I'm a Brainbench MVP for C++, I have about 17 years' experience with C, and I am reasonably familiar with Java. However, I hope I would never make the widespread mistake of confusing what is *FAMILIAR* with what is *INTRINSICALLY* clear and easy to read. > You can write C in Perl if you feel comfortable with it. Not really, since for example in Perl all your variables need a leading '$' which C does not require (unless in a certain case you need a leading '@' instead to get vector context rather than scalar context -- either will be syntactically accepted and they will do subtly different things -- how utterly far we are already from C's rough simplicity, and it's just the start...). > > > Can perl be compiled into byte code for faster startup or put into a stand > > > alone application? Or is Perl strickly an interpreted language? > > > Both:-). You can *buy* "Perl compilers" (e.g. from ActiveState > > and IndigoPerl -- are there others?) that are roughly equivalent > > to what you can do with the free py2exe and McMillan's "install" > > for Python. > > They are also similar to the `perlcc' command that ships with Perl 5.005 and > higher. Specifically, perlcc generates C source that, when compiled, acts > exactly like the original Perl. Is the Perl 5.6 manual page wrong, then? It says: """ The whole compiler suite (`perlcc' included) should be considered very experimental. Use for production purposes is strongly discouraged. ... Bugs in the various compiler backends still exist, and are perhaps too numerous to list here. """ It wouldn't exactly give me a warm fuzzy feeling to rely on something "very experimental", whose "use for production purposes is strongly discouraged". But maybe it's just a case of obsolete docs? > > > Of course you can port IQ to Perl if you want, but in any case (perl, > > > python, rebol, arexx) it'd be nice to incorporate into IQ, the ability to > > > access files thru the internet in a way that is as simple as accessing a > > > file on the system you are using IQ on. > > > If you use Python, that's trivial -- just open the URL string with > > urllib.urlopen, exactly like you would open a filepath string with the > > builtin function open, and you'll get a file(-like) object ready for > > reading through all the usual fileobject methods (.read, readline, etc > > etc). > > Same with Perl. Use the appropriate class, create a URL-fetch object, then > execute it. Read the results just like any other filehandle. It's not quite the same, if you need to do three steps in one case and one in the other, although it's no doubt close. > Perl and Python are roughly equivalent from my understanding. However, it's The sheer power of the two languages is indeed fully comparable. This is put in stark relief by one of the very few empirical studies of programming, http://wwwipd.ira.uka.de/~prechelt/Biblio/jccpprtTR.pdf which used Rexx, Tcl, Java, C and C++ as well as Perl and Python. Totally-unusable programs among those submitted were 1 in 14 for Perl (vs, e.g., 3 of 8 for C); Python was the only language of the 7 for which all submitted programs were usable (0 of 14 unusable). Running times of submitted Perl and Python programs only differed with p=0.15 (well below any statistical significance). Program length, all quality measures, and productivity measures, were all similar between the two languages to well within statistical significance. It's a pity that in most analyses the author, Lutz Prechelt, bracketed Python and Perl together with Tcl and Rexx, which, as the detailed measures show, were _significantly_ slower, bigger and less productive than either P-language. Even WITH this bracketing, overall, 'Script' shows up very well against C/C++, and even better against Java. It's interesting that the two P-languages arrive at roughly similar power by such widely divergent paths. Python's way is simplicity, cleanliness, directness: no special-cases, no ad-hoc context-dependent behavior, ideally "just one obviously right way to perform any given task" (as an ideal, to be sure, not an actual _fact_:-). Perl's is overflowing superabundance of constructs, subtle context-dependence, TMTOWTDI. They cover roughly the same 'ecological niche', yet their 'survival strategies' appear to be opposites on most points. > my opinion that Perl is much more well-supported, with massive amounts of > online documentation and available help. It's true that "Perl documentation" gives 524,000 google hits while "Python documentation" only gives 160,000; I guess us poor Pythonistas will have to be content with reading those 160,000 pages -- let's see, at one page a minute, that's... 111 days (no time off for sleeping or eating, of course). The Perlites will be able to keep reading for 363 days at the same hectic pace. But then, it's only fair -- to reach just about the same power *DOES* take about 3.27 times less study and work in Python, after all:-). As for help, all I've noticed on comp.lang.python were ex-Perlites amazed at how hard we try to HELP new would-be Pythonistas -- nary a "go read the FAQ you jerk" or "that's a CGI question, go ask it elsewhere!" in sight... it may be that the Perl newgroups have vastly changed since I last was a regular there, and that now it's all sweetness and light, but that would sure amaze me. Besides the NG, there's the direct help 'hotline', help at python.org, plus tutor at python.org for those who are specifically trying to learn (or teach) programming itself (using Python as the first programming language -- since it gets its power through simplicity, Python is as suitable as one's first programming language as it is as, say, the thirteenth:-). Alex From sholden at holdenweb.com Thu Jun 14 01:35:20 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 14 Jun 2001 01:35:20 -0400 Subject: Python grammar.. References: <3B28458C.F171FDB0@my.signature> Message-ID: "Greg Ewing" wrote in message news:3B28458C.F171FDB0 at my.signature... > "Delaney, Timothy" wrote: > > > > a 1 ' OK > > a(1) ' memory leak > > The "memory leak" part of that sounds like a bug in the > implementation. It doesn't say anything about the merits > or otherwise of the syntax. > Probably not, but if there'd been only one way to call procedures at least Microsoft would have been forced to fix the problem rather than accepting two syntaxes but only implementing one correctly. VB is, in any case, a total dog's breakfast from a language point of view. regards Steve -- http://www.holdenweb.com/ From mixo77 at usa.net Thu Jun 14 11:54:57 2001 From: mixo77 at usa.net (mixo) Date: Thu, 14 Jun 2001 17:54:57 +0200 Subject: Extending methods Message-ID: <3B28DE51.B9A71F2F@usa.net> How does one extend a method in a class that has been inherited from another class? From andy_todd at spam.free.yahoo.com Thu Jun 28 20:44:15 2001 From: andy_todd at spam.free.yahoo.com (Andy Todd) Date: Fri, 29 Jun 2001 00:44:15 GMT Subject: Python embebbed with Oracle SQL*Plus References: <9hebu5$12lo$1@news.idiom.com> Message-ID: olavb at yahoo.com (Olav) wrote in : >"James T. Dennis" wrote in message >news:<9hebu5$12lo$1 at news.idiom.com>... >> In comp.lang.python Olav wrote: >> >> > Some time ago I did some Oracle SQL*Plus on UNIX, >> > and I was able to write quite powerful scripts >> > embebbed in ksh (Korn Shell). >> >> > Is something similar possible with Python? >> >> I presume your ksh scripts were passing >> SQL code to an sql command (possibly in >> the form of "here" documents). >> >> For course you can build arbitrary commands >> in Python and invoke the system to execute >> them. (sys.system()?). > >This is a very simple Cygwin/NT example: >*************** >PLUS33 scott/tiger at prod_sa <select COU_NAME from M1_countries >/ >quit >eof >******************** >So it is not simply building an SQL-string and calling >some function. Looks like it to me. If the above example is the entire contents of your ksh script (or even a fragment) you can exactly copy it as a Python script. > >It is really like SQL embedded in the script. >There are also mechanism for passing variables back and forth. >(I can easily write a script that takes a sql-statement as an arguments >from the command line, something like osql select "*" from M1_countries) And so you can with Python (using sys.argv). > >Typically what I use it for is regression-testing. I pass arguments >on the command line to the script, execute an SQL-statement and run >the output through sort, grep, diff etc. All of which you can do in Python. > >I guess the mechanism is to build a temporary file, and call sqlplus >with this. > >I think it might be more difficult with Python because it is actually >precompiled and because there is no equivalent of pipes. I believe that your preconception here is that you need to use SQL*Plus to fire SQL statements at an Oracle database. This isn't strictly true. Using one of the db-api modules for Python (DCOracle seems to be the favourite here) you can substiture Python for SQL*Plus as well as ksh, sed, grep, awk, etc and write all of your scripts in one language. Its basically a case of what you are most comfortable with, no one is forcing you to use Python :-) For what its worth, I make my living as an Oracle programmer and I'm in the process of translating my 'toolbox' into Python scripts, if you need more details or any help please feel free to mail me on the address above (you'll need to remove 'spam.free'). I'd also strongly suggest checking out the Database SIG (http://www.python.org/sigs/db-sig/) and the Database topic guide (http://www.python.org/topics/database/) for more background and useful pointers. > >** >Olav > Regards, Andy -- Content free posts a speciality From claird at starbase.neosoft.com Fri Jun 15 19:34:59 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 15 Jun 2001 18:34:59 -0500 Subject: str smarter than round? References: Message-ID: <9F852011A819CAA6.2C9141DBD4DB433F.3BFF2DB5D91E2E16@lp.airnews.net> In article , Tim Peters wrote: . . . >Congratulations! You've elected yourself to be a guinea pig for reading >this new Tutorial Appendix: > > http://python.sourceforge.net/devel-docs/tut/node14.html > >never-ask-a-question-unless-you-really-want-an-answer-ly y'rs - tim > > Is there or will there be a (more) persistent URL for this Appendix? I assumer "node14" is likely to vary every few weeks or so. I ask in public, rather than only pestering timbot, because it occurs to me that the answer might interest others. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From karbak at myrealbox.com Thu Jun 7 17:45:16 2001 From: karbak at myrealbox.com (K. Arun) Date: 08 Jun 2001 03:15:16 +0530 Subject: Cookbook on the DevCenter References: Message-ID: <84r8wwklqr.fsf@localhost.localdomain> >>>>> "Stephen" == Stephen R Figgins writes: Stephen> The latest additions to the Python cookbook are now Stephen> featured on the front page of the O'Reilly Network Python Stephen> Dev Center. Are there any plans to bring out a 'dead trees' version of the Python cookbook, not unlike the Perl Cookbook ? -arun From twofingersalute at atl.mediaone.net Mon Jun 11 14:22:22 2001 From: twofingersalute at atl.mediaone.net (myself) Date: Mon, 11 Jun 2001 18:22:22 GMT Subject: Linux compile Q's Python 2.1 References: <20010609.234511.1943327684.1229@K7.atl.mediaone.net> Message-ID: <20010611.142511.159259470.1720@K7.atl.mediaone.net> In article <20010609.234511.1943327684.1229 at K7.atl.mediaone.net>, "myself" wrote: > Sorry to bother you guys so soon after my last post, but....... > > being unable to properly install from srpm, figured to just > compile/install from source- did it a year or so ago for 1.5, shouldn't > be a big whoop. Bzzzt. > > ./configure- ok > > made a few changes in Modules/Setup, "make", "make test": > > 17 tests skipped: test_al test_bsddb test_cd test_cl test_dbm test_dl > test_gl test_imgfile test_largefile test_minidom test_nis test_pyexpat > test_sax test_sunaudiodev test_sundry test_winreg test_winsound > > doesn't look tragic, seems like I had more skipped tests last time, but > you guys be final arbiters.... "make altinstall libinstall"- well I'm a > bit afraid latest Py will break something the system might need WRT Py > 1.5.2, but only error of note (to my untrained eye) seems reasonable: > I'll have to manually update sys.path. So now I'm looking at creating a > script to start my shiny new IDLE (.08?)- but it *didn't* get installed- > the sources are in my install directory, but nada in > python2.1/site-packages (or anwhere else in /usr/local). What did I > miss?? So: > > [root at K7 Python-2.1]# make uninstall > make: *** No rule to make target `uninstall'. Stop. > > how rude :-( ! I really wanted to start fresh, partly 'cause I didn't > realize that some/most/all of my mods to Setup are handled automagically > by setup.py. Running Mandrake 7.2, gcc-2.95.2-12mdk, installing from > Python-2.1.tgz from Pythonlabs. tcl/tk seemed to install fine. Clues? > Please? (I've surely left out the imp't stuff, but if I knew what it > was, probably wouldn't need to come a beggin' :-> ). PS- I don't have a > PYTHONHOME set (noticed it was a prob. for others). > > TIA, y'all (yep, we _really_do_say_that_)..... hmmm.... seems I remembered simply overwriting the idle install with a snapshot in order to upgrade a previous version, so I copied the idle source from my install directory to the 2.1 site-packages- seems to work after I also created a script to set the env variables for 2.1. thanks for your patience......... From s713221 at student.gu.edu.au Sun Jun 3 07:25:45 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Sun, 03 Jun 2001 21:25:45 +1000 Subject: Python 2.1 dependencies References: <3B18151A.E95C4E4B@ucdavis.edu> Message-ID: <3B1A1EB9.C051301D@student.gu.edu.au> Bruce Wolk wrote: > > On an RH 7.1 system I rebuilt the source RPMs for Python 2.1. But when > I tried to install expat-1.1-3tummy.i386.rpm, I got the following error > > error: failed dependencies: > libexpat.so.0 is needed by abiword-0.7.13-2 > > This is odd, since /usr/lib/libexpat.so.0 is present on my system, but > also what does Python have to do with abiword? > > Bruce Abiword wants libexpat. That much I can figure out, but I'm still confused how you got that message. If expat-*tummy replaces whatever package libexpat.so.0 comes in but doesn't have libexpat.so.0 itself you'll get that message. (Basically abiword is saying, "Hey, I still need that.") Now I don't know why expat-tummy wants to overwrite libexpat.so.0, that's what's got me confused. A listing of expat-tummy only gives /usr/bin/xmlwf /usr/include/expat/xmlparse.h /usr/lib/libexpat.a /usr/share/doc/expat-1.1 /usr/share/doc/expat-1.1/expat.html Of course if you're really worried about this, you could always uninstall abiword. Joal Heagney/AncientHart From uioziaremwpl at spammotel.com Fri Jun 29 15:30:53 2001 From: uioziaremwpl at spammotel.com (Carsten Geckeler) Date: Fri, 29 Jun 2001 21:30:53 +0200 (CEST) Subject: PEP scepticism In-Reply-To: Message-ID: On Fri, 29 Jun 2001, Roman Suzi wrote: [snip] [snipsnip] > Generators are necessary to drop memory usage while leaving > existing usage of functions the same. And I think after > generator's introduction, in things like: > > for line in file.readlines(): > ... > > people will _expect_ generators to be used and will look at > the source to check it. Hopefully, people will NOT expect this to be a generator. If file.readlines() would be a generator you could not get a list of all lines of a file with lines = file.readlines() > So, I can't see how all these advanced features could > harm anybody's ability to read code! See above. Cheers, Carsten -- Carsten Geckeler From ullrich at math.okstate.edu Fri Jun 15 08:54:35 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Fri, 15 Jun 2001 12:54:35 GMT Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: <9g4nec0cnr@enews2.newsguy.com> <3b266453.317327753@wa.news.verio.net> <3b2768b5.1425762@nntp.sprynet.com> <3b28ed01.483389587@wa.news.verio.net> <3b290162.19392474@nntp.sprynet.com> Message-ID: <3b2a03c4.191822@nntp.sprynet.com> On Thu, 14 Jun 2001 20:17:10 -0400, "Steve Holden" wrote: > > >-- >http://www.holdenweb.com/ > > >"David C. Ullrich" wrote ... >> On Thu, 14 Jun 2001 17:19:05 GMT, bokr at accessone.com (Bengt Richter) >> wrote: >> >> >On Wed, 13 Jun 2001 13:33:51 GMT, ullrich at math.okstate.edu (David C. >> >Ullrich) wrote: >> > >> >>On Tue, 12 Jun 2001 19:25:25 GMT, bokr at accessone.com (Bengt Richter) >> >>wrote: >> >> >> >>>[...] In general, I'd prefer that a language >> >>>provide a clean way to create a solution to a problem, >> >>>rather than having a particular solution built in. >> >>>I like orthogonality too. >> >> >> >[...] >> >>So just out of curiosity: Roughly what do you >> >>mean by "orthogonality" above? >> >Roughly, zero dot products ;-) >> >> Thanks. Best answer so far... (so a language >> in which it was essentially impossible to do >> mathematical programming would automatically >> have achieved this orthogonality: no math, hence >> no dot products, for a net total of zero dot >> products altogether. Suddenly Perl seems much >> more orthogonal than Python, who woulda guessed?) >> >Nope. "print" is a feature. "exec" is a feature. Changing the "print" >statement (i.e. moving the language one way or another along the "print" >dimension) does not affect "exec". Hence the two features are orthogonal. If >you multiply its "print"ness by its "exec"ness you get zero. Sort of. Um, thanks for clarifying that. Remind me to include the next time... >Heavens, it's a long time since I studied infinite-dimensional Banach >spaces. I started to make a different silly joke about all this in reply to what Bengt said, decided not to be pedantic. But you mention Banach spaces, now I have to (because there are no "dot products" in Banach spaces; you meant to say "Hilbert spaces" here): "Of course this use of the word 'orthogonal' is really more like the mathematical notion of linear independence than orthogonality. Heh-heh: now the challenge is to define a suitable inner product on feature space, so we can actually talk about features being orthogonal." >feeling-old-ly y'rs -- stEVe > >> >That is, if you view program language feature space >> >as n dimensional, and writing code using a particular >> >feature as movement along a feature vector. >> > >> >Well, roughly something like that. 8-<:^P > > David C. Ullrich ********************* "Sometimes you can have access violations all the time and the program still works." (Michael Caracena, comp.lang.pascal.delphi.misc 5/1/01) From robin at jessikat.fsnet.co.uk Wed Jun 20 04:59:48 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 20 Jun 2001 09:59:48 +0100 Subject: idle BUG References: <3b2e552f.2621005@nntp.ix.netcom.com> <2MTskUAVjoL7Ewqc@jessikat.fsnet.co.uk> <3b2fb646.442466@24.0.228.33> Message-ID: In article <3b2fb646.442466 at 24.0.228.33>, Mike Clarkson writes ... really sorry, but my Win95 box has been declared dead and I am awaiting a new Dell Win2k. I have 2k at work and the problem doesn't seem to happen there. Every year a new OS mumble whine. >No, it's a vanilla ActiveState 2.1, but it's on Windows 98 which >differs a little from Win95. The only change is this self.quit patch. > >Make sure you are not calling or binding self.tk.quit() - use the >patched self.quit() instead. self.tk.quit() is the _tkinter quit, >which just says bail out of the self.tk.mainloop(). It doesn't destroy >any windows, delete any Tk intepreter or even delete any of the tcl >commands declared in Python as callbacks. So it's not at all like a Tk >[exit]. > >If you take idle as an example, after the .mainloop() statement in >PyShell, add the following in main() (NB: console application only): > root.tk.eval('puts [winfo child .]') >after the > root.mainloop() >You'll see that after idle exists its mainloop, there are two Tk >toplevel windows still alive: . and .123456 (some number). >It's because root.tk.quit() does not destroy any windows. > >My patched root.quit() makes sure they're all destroyed. >My theory was/is that the undestroyed windows might be >stopping Python from unloading the Tk and exiting cleanly. > >Note that the next statement in idle main() > root.destroy() >doesn't destroy any Tk windows or intepreter. It's an internal >function that deletes the Python callback functions. It should >probably be renamed to _deletetclcallbacks, and maybe even >included in my patched self.quit() before the tk.evals. > >Mike. > >probably be renamed > > > -- Robin Becker From mwh at python.net Thu Jun 21 18:19:40 2001 From: mwh at python.net (Michael Hudson) Date: 21 Jun 2001 23:19:40 +0100 Subject: PEP 255: Simple Generators References: Message-ID: "Tim Peters" writes: > [Terry Reedy] > > When I first read the PEP, I assumed that def'ed generators would > > somehowreturn the successive yielded values on successive calls (wrong). > > Alas, I believe that. For good or ill, PEPs aren't tutorials, they're aimed > much more at developers of Python (as distinguished from developers using > Python). A good user's intro to Python generators doesn't exist yet > (AFAIK). And writing one's going to be tricky, 'cause a generator is only a big win when there's lots of state that has to be maintained across yields and such an example is necessarily hairy. Same deal for weak refs - a simple example is necessarily contrived. oh-well-ly y'rs M. -- SCSI is not magic. There are fundamental technical reasons why it is necessary to sacrifice a young goat to your SCSI chain now and then. -- John Woods From karthik_guru at rediffmail.com Wed Jun 20 04:55:12 2001 From: karthik_guru at rediffmail.com (karthik_guru at rediffmail.com) Date: Wed, 20 Jun 2001 08:55:12 -0000 Subject: beginner ques: dir( ) does'nt list my instance methods? Message-ID: <9gpodg+t3hp@eGroups.com> class test: def __init__(self): print 'hello test' self.foo = 100 self.bar = 900 def func(self): print 'hello' if __name__ == '__main__': t = test() print dir(t) print t.__dict__ Both dir(t) and t.__dict__ print only foo and bar. They don't print the func which is also a instance attribute (method reference)? But they are printed when i do test.__dict__ and dir(test)..ie why is it not getting printed in the earlier case?(wiht instance) I might be required to do a look up from dir(instance) and if an attribute happens to be of the type method i can invoke it? thanks karthik. From annis at biostat.wisc.edu Tue Jun 12 08:48:23 2001 From: annis at biostat.wisc.edu (William Annis) Date: 12 Jun 2001 07:48:23 -0500 Subject: [Python-Dev] PEP 259: Omit printing newline after newline References: <200106112007.f5BK7eW22506@odiug.digicool.com> <3B253031.AB1954CB@lemburg.com> Message-ID: "Chris Gonnerman" writes: > I have to say, I'm strongly against this PEP... does anyone else agree with > me? I have never before felt compelled to comment on a PEP. I even run into the example case (filtering Unixy config and account maintenance files), bu I have to say "nay" to this one. Loudly. Less magic! -- William Annis - System Administrator - Biomedical Computing Group annis at biostat.wisc.edu PGP ID:1024/FBF64031 Mi parolas Esperanton - La Internacian Lingvon www.esperanto.org From aahz at panix.com Mon Jun 18 17:38:04 2001 From: aahz at panix.com (Aahz Maruch) Date: 18 Jun 2001 14:38:04 -0700 Subject: Any other Python flaws? References: <3B2A5F6A.5A61183@destiny.com> Message-ID: <9glsbs$krq$1@panix6.panix.com> In article , D-Man wrote: > >It seems to, with some cursory tests in the interactive interpreter. >I would have to look at the source to see _how_ the function >implicitly returns 'None' to understand why it doesn't behave as >intended. Because every function returns None as its last, invisible statement. You can test that easily enough. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "It's not what you know, it's what you *think* you know." --Steve Martin From tim_one at email.msn.com Fri Jun 29 14:06:54 2001 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 29 Jun 2001 14:06:54 -0400 Subject: Augmented Assignement (was: Re: PEP scepticism) In-Reply-To: Message-ID: [Guido] > ... > And that quote "explicit is better than implicit" quote is pretty tired > by now. It can be used against a whole lot of Python features. But it can also be used in favor of a whole lot, and that's why we keep it around . i-hear-some-people-even-argued-about-what-jesus-meant-by-simple-words-ly y'rs - tim PS: If "+=" isn't explicit, I have a hard time understanding what "explicit" means. Maybe that Python should be coded at bytecode level, so that STORE_FAST (and friends) always punch you in the face? From f91-men at nada.kth.se Fri Jun 15 05:32:06 2001 From: f91-men at nada.kth.se (Mattias Engdegård) Date: 15 Jun 01 09:32:06 GMT Subject: Any other Python flaws? References: Message-ID: In Andrew Kuchling writes: >I was updating my page of possible Python design flaws >(http://www.amk.ca/python/writing/warts.html) last night to take 2.1 >into account. 2.1's nested scoping fixes one major wart except that it doesn't do it properly - you still cannot assign to a variable bound in a surrounding scope, something you can do in *all* other languages supporting nested scopes. I find this quite frustrating and it leads to ugly workarounds. (the PEP has a short discussion of this but doesn't really give a satisfactory explanation of why it's done that way) >Are there any other flaws that >should be added? That anonymous (lambda) functions can only contain an expression, not statements? Less of a problem, but still ugly and feels like an arbitrary decision, perhaps because it was too hard to make it fit with python's unusual indentation-based syntax. (by the way, your page (Python Warts) claims that python uses call-by-reference, which is a common misconception. Just like most other sensible languages (but unlike C++, Fortran, Pascal) it uses call-by-value. The values, however, are frequently references to objects, which is probably the cause of the confusion. :-) Cheers, Mattias. From morton at dennisinter.com Wed Jun 20 10:38:28 2001 From: morton at dennisinter.com (damien morton) Date: 20 Jun 2001 07:38:28 -0700 Subject: Suggested amendment to PEP 255 References: Message-ID: <4abd9ce7.0106200638.5896c8@posting.google.com> Simon Brunning wrote in message news:... > > From: Greg Ewing [SMTP:greg at cosc.canterbury.ac.nz] > > I suggest dropping the "def" altogether and using: > > > > generator foo(args): > > ... > > yield x > > ... > > This gets my vote. Or it would. If I had a vote. Which I don't. > > *Excellent* PEP, BTW! > > Cheers, > Simon Brunning > TriSystems Ltd. > sbrunning at trisystems.co.uk Im 100% with this too. doubleplusgood would be my vote, if I had one. Generators do seem different enough from functions to warrant a different syntax. some other syntax possibilities: gen foo(args): yield x def foo(args) generator: yield x def foo(args) as generator: yield x def generator foo(args): yield x From root at rainerdeyke.com Wed Jun 20 08:42:28 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 20 Jun 2001 12:42:28 GMT Subject: Partially evaluated functions References: Message-ID: "Nick Perkins" wrote in message news:pDWX6.293707$eK2.59723440 at news4.rdc1.on.home.com... > > "Rainer Deyke" wrote: > > ... > > class curry: > > def __init__(*args, **kwargs): > > self = args[0] > > self.function = args[1] > > self.args = args[2:] > > self.kwargs = kwargs > > def __call__(*args, **kwargs): > > kwargs.update(self.kwargs) > > return self.function(self.args + args, kwargs) > > ... > > This is pretty close to the cookbook version: > > http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/52549 > class curry: > def __init__(self, fun, *args, **kwargs): > self.fun = fun > self.pending = args[:] > self.kwargs = kwargs.copy() > > def __call__(self, *args, **kwargs): > if kwargs and self.kwargs: > kw = self.kwargs.copy() > kw.update(kwargs) > else: > kw = kwargs or self.kwargs > > return self.fun(*(self.pending + args), **kw) My version is superior in that it doesn't use named arguments. Consider: def f(self): print self curry(self = 5) # This will fail with the cookbook version. > I notice that that the cookbook version makes a copy of the kwargs > dictionary. > I suppose this prevents kwargs from being modified after being supplied to > curry. Tests show that 'kwargs' is always a new object in the current implementation, but I suppose that could change in the future. > Also the actual call to the function uses the * and ** operators to 'expand' > the arguments. My version would have those too if I had been paying attention while I was writing it. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From ngps at madcap.dyndns.org Sat Jun 16 12:12:19 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 16 Jun 2001 16:12:19 GMT Subject: pair programming, vim? References: Message-ID: <9gg0h3$55$1@coco.singnet.com.sg> According to Courageous : > >Did anyone try pair programming over the net? In particular, is > it possible > >to set up vim with a shared buffer or, failing that, some other editor? > > I believe that this isn't possible, although I could be mistaken. If you > *do* happen to find a multi-user text editor (multiple cursors, perhaps) > on windows, please let me know. This would be useful to have around. I thought the idea of pair programming is that one person drives while the other, um, navigates. ;-) Not both editing at the same time. I've read that people have used VNC to do distributed pair programming. http://www.uk.research.att.com (Same place that gives you omniORB.) -- Ng Pheng Siong * http://www.post1.com/home/ngps Quidquid latine dictum sit, altum viditur. From root at rainerdeyke.com Wed Jun 20 18:27:54 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 20 Jun 2001 22:27:54 GMT Subject: PEP 255: Simple Generators References: <9gnv2o$its$1@nntp6.u.washington.edu> Message-ID: "David Bolen" wrote in message news:ur8wevrz0.fsf at ctwd0143.fitlinxx.com... > But isn't a generator really just a function that is returning an > iterator? That is, why is it "very" different from a function, > internal implementation aside, which we agree it's not necessary to > reveal. o = f() To the caller, it doesn't matter if 'f' is a function, a generator, a bound method, a class, or any other callable object. That does *not* mean that functions, generators, classes and other callable objects should have the same syntax: they are fundamentally different ways of implementing callable objects. If generators absolutely have to reuse syntax (which is not the case), I would prefer the keyword 'class' over 'def', since calling a generator creates an instance. Reusing 'class' also increases readability since it's easier to see the difference between a generator and a class by looking at the contents. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From loewis at informatik.hu-berlin.de Sat Jun 16 13:43:14 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 16 Jun 2001 19:43:14 +0200 Subject: os.statvfs on FreeBSD References: Message-ID: t_messmer at yahoo.com (Tom Messmer) writes: > For some reason the default installation of python-1.5 and Python-2.0 > on FreeBSD(From the ports collection) does not include the > os.statvfs() routine. Does anyone know A. Why? and B. How to fix it? I > need this thing! You probably need to give some more details for those of us without access to a FreeBSD system. E.g. post some code snippet, and show what error it produces. Regards, Martin From francis.meyvis at sonycom.com Wed Jun 6 07:25:04 2001 From: francis.meyvis at sonycom.com (Francis Meyvis) Date: Wed, 06 Jun 2001 11:25:04 GMT Subject: network configuring through a script Message-ID: Hi, I've W2k with ActiveState Py 2.1 on my notebook. Python provides some access to COM things. I'd like to have scripts that configure my notebook for networking at home, at work, ... This requires now going into the dialog for - TCP/IP settings to change the IP address to use DHCP or use a fixed IP address, automatic DNS or fixed DNS server - IE5 properties/connections to setup Dialup or LAN settings. - the IE5 LAN settings allow further automatic settings and proxy server settings. Are these two also possible from within COM? Or should one directly modify the registry? Can someone point me to MSDN documentation on the inners of these configuration dialogs? I look in it but do not find anything usefull (could be that the MSDN I'v access to is already to old). Just some pointer would do ... --- Kind regards, francis meyvis From info at black-karma.de Tue Jun 26 18:01:30 2001 From: info at black-karma.de (Harvest T. Moon) Date: Wed, 27 Jun 2001 00:01:30 +0200 Subject: Python on BeOS References: Message-ID: <9hb0ib$d4i6k$1@ID-22517.news.dfncis.de> "Andrew Todd" schrieb > Hey, > I haven't found much on the net concerning Python on the > BeOS. I think Python v2.1 has been released for it, but I'm > not sure. Python 2.1 compiles out-of-the-box on BeOS (5), there are also binary-releases available @ http://www.bebits.com one is bundled with Bethon (a GUI modul for BeOS, wrapper for the native C++ calls, which i found not that usefull as it is not thread-safe) and one comes with the Pygame module (a wrapper to SDL). > Anyway, I was just wondering if anyone had any > experience with the language in this OS. Is the language > just as solid as it is in most of the other platforms? Python runs stable and fine for me, but somewhat limited (IMHO). there is no really 'working' GUI module what is really annoying, and i tried several times to get the python modules for PostgreSQL and curses to work, but no luck so far :(( > Are there any sites concerning Python with the BeOS I could > check out? not that i know of :( Harvest T. Moon -- a life less ordinary!! From noSpam at noSpam.com Sat Jun 2 19:19:46 2001 From: noSpam at noSpam.com (Bill Darbie) Date: Sat, 02 Jun 2001 23:19:46 GMT Subject: best language for 3D manipulation over web ? References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com> Message-ID: "Polterguy" wrote in message news:D9cS6.4513$lM3.104799 at news1.oke.nextra.no... > [...snip...] > I agree totally, but fact is 99.99999% of the commersial world uses win32. > So why go through the extra trouble adding cross OS programming when it's > going to increase the cost of releasing a product with a factor of 50?!? > > All game companies founded on cross OS releases have either gone broke or > are soon to become so! Tell that one to the makers of Quake! I think they will disagree. Bill > How much I may hate Bill Gates and that stupid CEO of him who doesn't even > know what HAL means, there's still the facts. > If you want to be successfule and reach 99.9999% of the world use technology > built on win32, DirectX, C++, hell fucking ay, if you can get away with it > use VB!!. Use OBJECT tags in your HTML, use ASP (especially the new ASPX and > the webforms i find XTREMELY interresting...). > > This is my opinion and I realize this will probably become my own social > suicide, but fact is that every successfule software dealer don't give a > shit about anything but windows... > > ...all though it's really sad, and I wish the world was different... > > From r.b.rigilink at chello.nl Fri Jun 22 03:36:51 2001 From: r.b.rigilink at chello.nl (Roeland Rengelink) Date: Fri, 22 Jun 2001 07:36:51 GMT Subject: [OT] MS EULA -- (will ActiveState become outlaws? ;-) References: Message-ID: <3B32F81F.259DBA46@chello.nl> "Steven D. Majewski" wrote: > > Is this the next stage of Microsoft's war against Open Source ? > > Discussion of this on SlashDot : > > ( Right before the article on the Monty Python Action Figures! ) > > If this spreads to all of Microsoft's EULA's, will this make > ActiveState illegal ? They don't specifically mention Python's > license, but they do mention Perl's ( and the "similar to any > of the following" clause would seem to include Python's. ) > > Does anyone know if this should be taken seriously ? > > -- Steve Majewski > > Ironically, NS under Linux refuses to display that ;) > Well, as I see it the GPL licence is morally equivalent to 1. This is raging commie stuff 2. You can't use raging commie stuff in conjunction with evil empire stuff and this microsoft licence is morally equivalent to 1. This is evil empire stuff 2. You can't use evil empire stuff in conjunction with raging commie stuff For once the free software movement and microsoft seem to agree on something More seriously, the lack of a definition of ''use'' under (ii), and the misleading definition of Potentially Viral Software gives the impression that this was written by their PR department, rather than their lawyers. But then, I know as little about law as I do about PR. Roeland -- r.b.rigilink at chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From tim.one at home.com Sun Jun 3 18:14:47 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 3 Jun 2001 18:14:47 -0400 Subject: random In-Reply-To: <3b1a60f3.5711223@nntp.sprynet.com> Message-ID: [David C. Ullrich] > ... > Not that readers are likely to be reading carefully enough that it's > going to matter, but just for the sake of telling no lies: I put > my finger on what was bothering me about what I said here. > It's not true that the sequence of bits of Omega is recursively > enumerable. What's true (assuming that the N-th bit is 1 if the > N-th program halts and 0 otherwise) is that the sequence of N > for which the N-th bit is 1 is recursively enumerable. The > set of N for which the N-th bit is 0 is _not_ recursively > enumerable (and hence the sequence of bits of Omega is not > recursively enumerable.) It's the "assuming that the N-th bit is 1 [iff] the N-th program halts" that's off. Omega is the probability that "a random" program halts, and it won't take long to figure out that "N'th-bit = halts(N-th program)" doesn't work for that (e.g., if the 0'th program happens to halt, that would imply the halting probability is >= 1/2 across all programs -- but the 0'th program isn't generally that smart ). Not that the number you define there isn't interesting in its own right! It's a classic example of a non-computable real that can be approximated from below, and it shares that much with Chaitin's Omega; but, IIRC, it doesn't meet the criteria for randomness (machine I can be related to machine I+1 in an exploitable way s.t. halt(I) gives information about halt(I+1) -- for example, define the encoding s.t. odd-numbered machines J merely prepend a no-op to the J-1 machine, and then halt(J) == halt(J-1), so adjacent bits in the derived sum are strongly correlated). Perhaps the easiest gimmick for programmers to grok is that the set of rationals less than omega is recursively enumerable: Chaitin gives you a generator object g such that the loop while 1: r = g.next() eventually generates every rational number r less than omega. Then the generated sequence of values r_0, r_1, .. approximates omega from below (although only the biggest-so-far-seen are interesting), and for any real epsilon greater than 0 there's *some* i s.t. omega - r_i < epsilon (since every rational less than omega is eventually generated). So a subsequence of the r_i converges to omega. Two results of the theory are that there's no effective way to compute i as a function of epsilon ("you can't tell how close you are"), yet there's no better way to compute omega than by running that loop (you can study the implementation of g.next() all you like, but there's no *fundamentally* better way to do it). That last part eats at the optimizers among us . From not.this at seebelow.org Wed Jun 27 23:37:42 2001 From: not.this at seebelow.org (Grant Griffin) Date: Wed, 27 Jun 2001 22:37:42 -0500 Subject: python2.1 and RedHat7.1 References: Message-ID: <3B3AA686.412A9F30@seebelow.org> Michael Ackerman wrote: > > Hello. > I tried to install the python2.1 rpm for RedHat7.0 on my 7.1 system but > got a > "failed dependency" message saying that it wants: > libcrypto.so.0.9.6, libssl.so.0.9.6 > But these files are present, in /usr/lib. So what's going on? > Any help will be appreciated. > Durn--you mean I upgraded from 7.0 to 7.1 for nothing? never-could-get-that-darn-7.0-thing-to-compile-much-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From japh at flashmail.com Wed Jun 20 13:33:18 2001 From: japh at flashmail.com (Tyler Coumbes) Date: Wed, 20 Jun 2001 12:33:18 -0500 Subject: problems with jython References: Message-ID: Nils O. Sel?sdal wrote: > > "Tyler Coumbes" wrote in message > news:tivrc9jrqd8c1e at corp.supernews.com... > > I got jython 2.0 and am trying to run it with IBMJava2-13. > > I get this error > > *sys-package-mgr*: processing new jar, > > '/home/flounder/jython-2.0/jython.jar' > > SIGSEGV 11 (*) segmentation violation > > stackpointer=0xbffc1cf8 > > > > and it just keeps going at 100% cpu and doesn't stop > > What could cause that? > a bug? have you tried the Sun VM, or blackdowns (www.blackdown.org) > > K, I will try another java VM today. Just thought maybe I had configured something wrong. It says on the site they have used that one though. Oh well. Thanks -- Tyler From haaserd at yahoo.com Thu Jun 7 22:35:07 2001 From: haaserd at yahoo.com (haaserd) Date: Thu, 07 Jun 2001 19:35:07 -0700 Subject: How do I serve an image from a python script? References: <9fos4p$3ms$1@ctb-nnrp1.saix.net> Message-ID: <3B2039DB.8884C4B4@yahoo.com> Hi, I am trying to serve an image from a Python script using Apache under Windows. My simple HTML statement: a picture ...and my simple script: #!c:/Python20/python.exe import sys def pix(): n = 'c:/My Pictures/Sample.jpg' p = open(n,'rb') apix = p.read() p.close() sys.stdout.write("content-type: image/jpeg\n\n") sys.stdout.write(apix) sys.stdout.flush() if __name__ == '__main__': pix() As you can see I am ignoring the CGI fields for the moment and am just trying to serve up an image. Through debugging statements that I have removed, I know the program crashes on the statement sys.stdout.write(apix) if the picture is over 200,000 bytes. On small images (10k), the script runs to completion, but no image appears. What am I doing wrong? TIA, Roger Haase From db3l at fitlinxx.com Tue Jun 12 19:32:08 2001 From: db3l at fitlinxx.com (David Bolen) Date: 12 Jun 2001 19:32:08 -0400 Subject: msvcrt.getch() overly receptive in idle? References: <9g5m7k$gu8$1@nntp6.u.washington.edu> Message-ID: fpm at u.washington.edu (Frank Miles) writes: > I'm trying to get getch() working in Windows (Python 2.0). It seems to > work fine outside of Idle, but inside Idle it immediately returns a > character with the value 255. > > Can anyone point me to the obvious solution? Thanks! I expect that getch() requires a working "console" window, and when you run Idle you don't get one as its set to use pythonw.exe. Thus, it's technically not able to process any keystrokes and returns immediately. You could try to verify that by starting Idle from the command line with the standard python. (But you may have to be in that console window to trigger the getch() to return). A GUI doesn't really have individual keystrokes sent as console characters, but instead receives events upon keypresses. So a getch() call in a GUI application is sort of non-sensical (within the GUI framework). To do the equivalent in a GUI, you'd need to wait for a keypress event. I'm not sure how easy or not it would be to tie into Idle's event loop to notice such a thing. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From akuchlin at mems-exchange.org Fri Jun 29 18:37:07 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 29 Jun 2001 18:37:07 -0400 Subject: PEP scepticism References: Message-ID: <3d1yo2nca4.fsf@ute.cnri.reston.va.us> "Tim Peters" writes: > It's too glib: the canonical example is CPAN, and is there some reason CPAN > is *not* "boring" in the Perl world but is in the Python world? Doubt it. Not at all; CPAN has had bits which were broken for a long time, such as the scripts submission, which I think was broken for a few years. However, the primary catalog feature kept working, probably because: 1) someone wrote it initially, and not much subsequent maintenance was needed. 2) lots of people used it, so if it broke, the resulting screams ensured that someone kept it running. I suspect that an ambitious person could jumpstart the catalog into existence, even if they ignored the catalog SIG completely. Write an initial implementation that's reasonably good, seed it with data from Parnassus or wherever, and push it hard for a few months; if enough people begin adding their new modules, then it'll just bootstrap itself into indispensability, much as Parnassus did. > The real question is why someone else hasn't popped up to do these things. That's another good one; I don't know. Perhaps people think you have to be a serious wizard to contribute, but that's really not true; there's lots you can do without being a genius who rewrites ceval.c at the drop of a hat. People who wanted to gain experience on a free software project would be much better starting off on Python, which you can write docs or write Python code or hack C code, than by initiating yet another small application that never gets finished. I've wondered if a document on how to work with the Python dev team would be a useful thing, and if it would encourage more people to help out. --amk From erlangen72 at hotmail.com Mon Jun 18 23:33:23 2001 From: erlangen72 at hotmail.com (Mark_Pryor) Date: Tue, 19 Jun 2001 03:33:23 GMT Subject: Win32com Item method does not return object References: <3B2EBBE7.8050803@ActiveState.com> Message-ID: <7KzX6.17180$aV1.1793360@newsread1.prod.itd.earthlink.net> Mark Hammond wrote in message <3B2EBBE7.8050803 at ActiveState.com>... >Mark_Pryor wrote: > >> Hi, >> >> New to Python, using Version 2.1 on Win95. >> I have a COM object that has been registered into >> the gen_py folder. As I drill down through the object, I >> issue the Item method of a collection, which should return >> another collection, but fails returning a " tuple ". > > >PythonCOM returns a tuple when there are multiple return values from the >function - typically byref params. > >>>>>c = om.Tags.Item(1) > > >My guess is that for some reason, the Item method takes the int param byref. > >But without seeing that C actually is, it is hard to speculate, but your >best bet may be to write it as: > >c, ignored = om.Tags.Item(1) That's it, your speculation nailed it. c returned this way is now a Tag object, as expected. I get the drop down again and can continue on. Thanks Mark ! > >Mark. > > From michael at trollope.org Fri Jun 22 01:43:26 2001 From: michael at trollope.org (Michael Powe) Date: 21 Jun 2001 22:43:26 -0700 Subject: namespace issue? References: <87k825ljrz.fsf@elbereth.ccraig.org> <9gts54$bv0$1@nntp6.u.washington.edu> Message-ID: <87r8wd2hoh.fsf@cecilia.trollope.org> >>>>> "Donn" == Donn Cave writes: Donn> Quoth Michael Powe : ... | So now Donn> the question is, 'why'? Am I misusing the string.find() | Donn> function? Okay, string.find() returns -1 when the string is Donn> not found, | which would seem to be what I expected, a false Donn> result. Maybe python | doesn't treat -1 as false? Well, Donn> I'll try being explicit and testing | for -1 return. I Donn> probably have just confused myself hopelessly. Donn> | Thanks for the ... clue. I saw a great line in an email Donn> today -- "Is | that the clue phone ringing? I think it's Donn> for you." And I think I'll | go answer it. Donn> You heard the phone ring, picked it up, and heard "Maybe Donn> python doesn't treat -1 as false?" It might be worth your Donn> trouble to check that out. There are a number of different Donn> values that test false in Python, and though different they Donn> tend to have something in common. -1 doesn't fit the Donn> pattern. Apparently so. I'm used to C, in which any return value that is not positive is false. I'm afraid there are a number of "features" like this in python which don't strike me as wonderful. But, I shall soldier on. mp -- Michael Powe Portland, Oregon USA 'Unless we approve your idea, it will not be permitted, it will not be allowed.' -- Hilary Rosen, President, Recording Industry Association of America From alvaro at godsmaze.org Sun Jun 3 05:02:45 2001 From: alvaro at godsmaze.org (Alvaro Lopez Ortega) Date: Sun, 3 Jun 2001 11:02:45 +0200 (CEST) Subject: random problem Message-ID: Hello all! :) I've a little problem with Python 1.5.2 (Debian Potato): === import random File "/usr/lib/python1.5/random.py", line 84, in ? verify('NV_MAGICCONST', 1.71552776992141) File "/usr/lib/python1.5/random.py", line 77, in verify raise ValueError, \ ValueError: computed value for NV_MAGICCONST deviates too much (computed 2,82843, expected 1) === Somebody knows how can I fix it? :-?? Thanks a lot :-) -- Greetings, alo. From aleaxit at yahoo.com Wed Jun 6 05:02:45 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 6 Jun 2001 11:02:45 +0200 Subject: how much does Python model my Compsci course? References: Message-ID: <9fkrjl0bqu@enews2.newsguy.com> "Fredrik Lundh" wrote in message news:E4kT6.2150$G4.322952 at newsc.telia.net... > Roy Katz wrote: > > But Python looks as if it has invented a new form to (perhaps a > > variation on pass-by-ref) param passing, based on whether or > > not the object passed in is mutable (from what I understand...?) > > no, you don't understand ;-) > > the *only* difference between mutable and immutable objects is > that the former have methods that let *you* modify them. > > Python doesn't care. /F is impeccable and succing as usual, but (being verbose as usual) I thought I'd add one caveat to his note about "Python not caring" for the difference between mutable and immutable object (impeccable in terms of argument-passing, but maybe slightly overbroad as more-generally stated)... Python "doesn't care" about mutable/immutable distictions, _except_... ...except that it's free to optimize, if & when it wants, by reusing an existing immutable-object, rather than generating a new one that would be equal to the existing one, when it's convenient for it to notice such reusability. It currently only does that in a few cases, which is why sometimes one gets peculiar results when playing with the 'is' operator (that tests identity rather than equality): D:\ian\good>python Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. Alternative ReadLine 1.4 -- Copyright 2001, Chris Gonnerman >>> 4 is 2+2 1 >>> 400 is 200+200 0 >>> the number 4 is 'reused' as above (small int's are, in this specific implementation), number 400 isn't (in this specific implementation -- one's code should *NOT* depend on that, as next implementation might decide to reuse 400 too, or to stop reusing 4, or...:-). Therefore, one uses '==', NOT 'is', on immutable objects (with the exception of specific single-identity objects such as None or NotImplemented), to avoid falling afoul of such optimizations. (For *MUTABLE* objects, the distinction between '==' and 'is' should hopefully be sharp and clear enough so that one runs no such risks:-). But, of course and to reiterate, this is not relevant to argument-passing in particular... it's a general issue:-). So, nothing /F said is wrong -- I'm just expanding a bit:-). Alex From see at below Wed Jun 20 23:03:39 2001 From: see at below (Paul Foley) Date: 21 Jun 2001 15:03:39 +1200 Subject: PEP 255: Simple Generators References: Message-ID: On 20 Jun 2001 18:05:40 +0200, Denys Duchier wrote: > While possibly aberrant, let me suggest a higher-order programming > approach that would not even require a new keyword but merely a new > primitive which I'll call `generator'. This primitive takes a unary > procedure as argument and returns an iterator. The unary procedure > takes itself a `yield' procedure as argument. Here is the fib example > of the PEP written with my proposal: > def fib(yield): > a, b = 0, 1 > while 1: > yield(b) > a, b = b, a+b > g=generator(fib) Check out http://www.math.uio.no/cltl/clm/node362.html and node347.html -- For th?m se the his cr?ft forl?tt, se bi? fram th?m cr?fte forl?ten. -- ?lfric (setq reply-to (concatenate 'string "Paul Foley " "")) From phd at phd.fep.ru Wed Jun 13 15:53:12 2001 From: phd at phd.fep.ru (Oleg Broytmann) Date: Wed, 13 Jun 2001 23:53:12 +0400 (MSD) Subject: Postgresql Woes In-Reply-To: <436ad7a4.0106131131.57bc1cd1@posting.google.com> Message-ID: On 13 Jun 2001, Sreekant wrote: > I have made a few web sites with postgresql but never needed to know > the list of tables available in the database through pg module. > > I guess you can use psql and \dt command or os.popen('psql ... , to > get the list of tables. But is there a decent way of finding out > through python and postgresql [pg] module , all the tables in a > database! psql does not do any magic. I remember there is a parameter that you cm set and psql will echo the query that it sends to the server. Then you can copy the query into your program. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN.